[PATCH 3/3] powerpc: ps3: Add missing set_freezable() for ps3_probe_thread()
The kernel thread function ps3_probe_thread() invokes the try_to_freeze() in its loop. But all the kernel threads are non-freezable by default. So if we want to make a kernel thread to be freezable, we have to invoke set_freezable() explicitly. Signed-off-by: Kevin Hao --- arch/powerpc/platforms/ps3/device-init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/platforms/ps3/device-init.c b/arch/powerpc/platforms/ps3/device-init.c index e87360a0fb40..878bc160246e 100644 --- a/arch/powerpc/platforms/ps3/device-init.c +++ b/arch/powerpc/platforms/ps3/device-init.c @@ -827,6 +827,7 @@ static int ps3_probe_thread(void *data) if (res) goto fail_free_irq; + set_freezable(); /* Loop here processing the requested notification events. */ do { try_to_freeze(); -- 2.39.2
[PATCH 2/3] powerpc: mpc83xx: Use wait_event_freezable() for freezable kthread
A freezable kernel thread can enter frozen state during freezing by either calling try_to_freeze() or using wait_event_freezable() and its variants. So for the following snippet of code in a kernel thread loop: wait_event_interruptible(); try_to_freeze(); We can change it to a simple wait_event_freezable() and then eliminate a function call. Signed-off-by: Kevin Hao --- arch/powerpc/platforms/83xx/suspend.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/83xx/suspend.c b/arch/powerpc/platforms/83xx/suspend.c index eed325ed08cc..c9664e46b03d 100644 --- a/arch/powerpc/platforms/83xx/suspend.c +++ b/arch/powerpc/platforms/83xx/suspend.c @@ -264,8 +264,7 @@ static int agent_thread_fn(void *data) set_freezable(); while (1) { - wait_event_interruptible(agent_wq, pci_pm_state >= 2); - try_to_freeze(); + wait_event_freezable(agent_wq, pci_pm_state >= 2); if (signal_pending(current) || pci_pm_state < 2) continue; -- 2.39.2
[PATCH 1/3] powerpc: mpc83xx: Add the missing set_freezable() for agent_thread_fn()
The kernel thread function agent_thread_fn() invokes the try_to_freeze() in its loop. But all the kernel threads are non-freezable by default. So if we want to make a kernel thread to be freezable, we have to invoke set_freezable() explicitly. Signed-off-by: Kevin Hao --- arch/powerpc/platforms/83xx/suspend.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/platforms/83xx/suspend.c b/arch/powerpc/platforms/83xx/suspend.c index 9833c36bda83..eed325ed08cc 100644 --- a/arch/powerpc/platforms/83xx/suspend.c +++ b/arch/powerpc/platforms/83xx/suspend.c @@ -261,6 +261,8 @@ static int mpc83xx_suspend_begin(suspend_state_t state) static int agent_thread_fn(void *data) { + set_freezable(); + while (1) { wait_event_interruptible(agent_wq, pci_pm_state >= 2); try_to_freeze(); -- 2.39.2
[PATCH 0/3] powerpc: Fixes and optimization for the freezable kthread
Hi, The main changes include: - Invoke set_freezable() for the kthread which could be frozen - Drop redundant try_to_freeze() invocation Kevin Hao (3): powerpc: mpc83xx: Add the missing set_freezable() for agent_thread_fn() powerpc: mpc83xx: Use wait_event_freezable() for freezable kthread powerpc: ps3: Add missing set_freezable() for ps3_probe_thread() arch/powerpc/platforms/83xx/suspend.c| 5 +++-- arch/powerpc/platforms/ps3/device-init.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.39.2
[PATCH] powerpc: Export mmu_feature_keys[] as non-GPL
When the mmu_feature_keys[] was introduced in the commit c12e6f24d413 ("powerpc: Add option to use jump label for mmu_has_feature()"), it is unlikely that it would be used either directly or indirectly in the out of tree modules. So we export it as GPL only. But with the evolution of the codes, especially the PPC_KUAP support, it may be indirectly referenced by some primitive macro or inline functions such as get_user() or __copy_from_user_inatomic(), this will make it impossible to build many non GPL modules (such as ZFS) on ppc architecture. Fix this by exposing the mmu_feature_keys[] to the non-GPL modules too. Reported-by: Nathaniel Filardo Signed-off-by: Kevin Hao --- arch/powerpc/kernel/cputable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index ae0fdef0ac11..3a8cd40b6368 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -2119,7 +2119,7 @@ void __init cpu_feature_keys_init(void) struct static_key_true mmu_feature_keys[NUM_MMU_FTR_KEYS] = { [0 ... NUM_MMU_FTR_KEYS - 1] = STATIC_KEY_TRUE_INIT }; -EXPORT_SYMBOL_GPL(mmu_feature_keys); +EXPORT_SYMBOL(mmu_feature_keys); void __init mmu_feature_keys_init(void) { -- 2.34.1
Re: [PATCH 3/5] of/platform: introduce a generic way to declare a platform bus
On Thu, Aug 25, 2016 at 08:44:56AM -0500, Rob Herring wrote: > On Mon, Aug 22, 2016 at 9:06 PM, Kevin Hao <haoke...@gmail.com> wrote: > > The specific buses which need to be probed at boot time are different > > between platforms. Instead of put all the buses into the default > > of_default_bus_match_table[] match tables, this patch introduces a > > general way to declare a platform bus. > > I'd prefer to not do this with linker sections if possible. Doesn't > PPC have machine descriptors that you could add the match table to? If > that table exists then arch_want_default_of_probe could return a > pointer to it. Hmm, I thought about adding a match table in ppc_md. But it is very arch specific. I thought maybe other archs also need to probe some arch or even board specific bus, so I introduces these arch independent macros and wish it may be useful for other archs. :-) > > Are there any platforms that work with the default match table? Yes, some boards can work with the default match table. But most won't. > I'd be > fine with adding some strings to the default if that helps. > > { .type = "soc", }, > > device_type is deprecated for FDT, so this shouldn't be needed except > for really old stuff. > > { .compatible = "soc", }, > > Doesn't appear in kernel dts files. Could be out of tree or old ones? > > { .compatible = "simple-bus" }, > > Already handled. > > { .compatible = "gianfar" }, > > Seems like the children of this should be probed by the gianfar driver. > > { .compatible = "gpio-leds", }, > > I don't think this is needed. > > { .type = "qe", }, > > Again, deprecated. > > { .compatible = "fsl,qe", }, > > No issue to add this. Though, you could also probe it from mpc85xx_qe_init(). Do you mean we put all the probe of the specific bus into the corresponding drivers? Yes, if we do so, we probably can shrink the default match table to be something like this: { .compatible = "soc", }, { .compatible = "simple-bus" }, OK, now we have three options to fix this issue: a) Create a separate link section to contain all the buses needed to be probed. Just as what this patch does. b) Put the match table into the machine descriptor. c) Sprinkle the probe of all the specific bus into the corresponding driver (such as gian, pcie controller) and the default probe function only handle the very common buses. So what option do you guys think is best? Thanks, Kevin signature.asc Description: PGP signature
[PATCH 5/5] powerpc/83xx: enable the default of probe
Use the default of probe function of_platform_default_populate_init() to kill the arch specific duplicated codes. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- arch/powerpc/platforms/83xx/asp834x.c | 2 -- arch/powerpc/platforms/83xx/km83xx.c | 2 -- arch/powerpc/platforms/83xx/misc.c| 25 - arch/powerpc/platforms/83xx/mpc830x_rdb.c | 2 -- arch/powerpc/platforms/83xx/mpc831x_rdb.c | 2 -- arch/powerpc/platforms/83xx/mpc832x_mds.c | 2 -- arch/powerpc/platforms/83xx/mpc832x_rdb.c | 2 -- arch/powerpc/platforms/83xx/mpc834x_itx.c | 12 arch/powerpc/platforms/83xx/mpc834x_mds.c | 2 -- arch/powerpc/platforms/83xx/mpc836x_mds.c | 2 -- arch/powerpc/platforms/83xx/mpc836x_rdk.c | 2 -- arch/powerpc/platforms/83xx/mpc837x_mds.c | 2 -- arch/powerpc/platforms/83xx/mpc837x_rdb.c | 2 -- arch/powerpc/platforms/83xx/mpc83xx.h | 1 - arch/powerpc/platforms/83xx/sbc834x.c | 2 -- 15 files changed, 8 insertions(+), 54 deletions(-) diff --git a/arch/powerpc/platforms/83xx/asp834x.c b/arch/powerpc/platforms/83xx/asp834x.c index 575afd6eb36a..2219a1f8c535 100644 --- a/arch/powerpc/platforms/83xx/asp834x.c +++ b/arch/powerpc/platforms/83xx/asp834x.c @@ -34,8 +34,6 @@ static void __init asp834x_setup_arch(void) mpc834x_usb_cfg(); } -machine_device_initcall(asp834x, mpc83xx_declare_of_platform_devices); - /* * Called very early, MMU is off, device-tree isn't unflattened */ diff --git a/arch/powerpc/platforms/83xx/km83xx.c b/arch/powerpc/platforms/83xx/km83xx.c index d8642a4afc74..e2276f12eafe 100644 --- a/arch/powerpc/platforms/83xx/km83xx.c +++ b/arch/powerpc/platforms/83xx/km83xx.c @@ -154,8 +154,6 @@ static void __init mpc83xx_km_setup_arch(void) #endif /* CONFIG_QUICC_ENGINE */ } -machine_device_initcall(mpc83xx_km, mpc83xx_declare_of_platform_devices); - /* list of the supported boards */ static char *board[] __initdata = { "Keymile,KMETER1", diff --git a/arch/powerpc/platforms/83xx/misc.c b/arch/powerpc/platforms/83xx/misc.c index d75c9816a5c9..4a88edd51d1a 100644 --- a/arch/powerpc/platforms/83xx/misc.c +++ b/arch/powerpc/platforms/83xx/misc.c @@ -114,23 +114,6 @@ void __init mpc83xx_ipic_and_qe_init_IRQ(void) } #endif /* CONFIG_QUICC_ENGINE */ -static const struct of_device_id of_bus_ids[] __initconst = { - { .type = "soc", }, - { .compatible = "soc", }, - { .compatible = "simple-bus" }, - { .compatible = "gianfar" }, - { .compatible = "gpio-leds", }, - { .type = "qe", }, - { .compatible = "fsl,qe", }, - {}, -}; - -int __init mpc83xx_declare_of_platform_devices(void) -{ - of_platform_bus_probe(NULL, of_bus_ids, NULL); - return 0; -} - #ifdef CONFIG_PCI void __init mpc83xx_setup_pci(void) { @@ -149,4 +132,12 @@ void __init mpc83xx_setup_arch(void) ppc_md.progress("mpc83xx_setup_arch()", 0); mpc83xx_setup_pci(); + arch_enable_default_of_probe(); } + +BUS_OF_DECLARE_TYPE(type_soc, "soc"); +BUS_OF_DECLARE_TYPE(type_qe, "qe"); +BUS_OF_DECLARE_COMPAT(simple_bus, "simple-bus"); +BUS_OF_DECLARE_COMPAT(gianfar, "gianfar"); +BUS_OF_DECLARE_COMPAT(gpio_leds, "gpio-leds"); +BUS_OF_DECLARE_COMPAT(qe, "fsl,qe"); diff --git a/arch/powerpc/platforms/83xx/mpc830x_rdb.c b/arch/powerpc/platforms/83xx/mpc830x_rdb.c index 272c41c387b9..0d073102cfbb 100644 --- a/arch/powerpc/platforms/83xx/mpc830x_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc830x_rdb.c @@ -46,8 +46,6 @@ static int __init mpc830x_rdb_probe(void) return of_device_compatible_match(of_root, board); } -machine_device_initcall(mpc830x_rdb, mpc83xx_declare_of_platform_devices); - define_machine(mpc830x_rdb) { .name = "MPC830x RDB", .probe = mpc830x_rdb_probe, diff --git a/arch/powerpc/platforms/83xx/mpc831x_rdb.c b/arch/powerpc/platforms/83xx/mpc831x_rdb.c index fd80fd570e67..16926fb95592 100644 --- a/arch/powerpc/platforms/83xx/mpc831x_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc831x_rdb.c @@ -46,8 +46,6 @@ static int __init mpc831x_rdb_probe(void) return of_device_compatible_match(of_root, board); } -machine_device_initcall(mpc831x_rdb, mpc83xx_declare_of_platform_devices); - define_machine(mpc831x_rdb) { .name = "MPC831x RDB", .probe = mpc831x_rdb_probe, diff --git a/arch/powerpc/platforms/83xx/mpc832x_mds.c b/arch/powerpc/platforms/83xx/mpc832x_mds.c index bb7b25acf26f..01c0602347a7 100644 --- a/arch/powerpc/platforms/83xx/mpc832x_mds.c +++ b/arch/powerpc/platforms/83xx/mpc832x_mds.c @@ -92,8 +92,6 @@ static void __init mpc832x_sys_setup_arch(void) #endif /* CONFIG_QUICC_ENGINE */ } -machine_device_initcall(mpc832x_mds, mpc83xx_declare_of
[PATCH 4/5] powerpc/83xx: factor out the common codes of setup arch functions
Factor out the common codes of setup arch functions to a separate function. It does make no sense to print a board specific info in setup arch functions, so use a more general one. For ASP8347E board, there is no pci device node. So it is safe to invoke mpc83xx_setup_pci() in its setup arch function even there is no such invocation in its original setup arch function. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- arch/powerpc/platforms/83xx/asp834x.c | 4 +--- arch/powerpc/platforms/83xx/km83xx.c | 5 + arch/powerpc/platforms/83xx/misc.c| 8 arch/powerpc/platforms/83xx/mpc830x_rdb.c | 5 + arch/powerpc/platforms/83xx/mpc831x_rdb.c | 5 + arch/powerpc/platforms/83xx/mpc832x_mds.c | 5 + arch/powerpc/platforms/83xx/mpc832x_rdb.c | 5 + arch/powerpc/platforms/83xx/mpc834x_itx.c | 5 + arch/powerpc/platforms/83xx/mpc834x_mds.c | 5 + arch/powerpc/platforms/83xx/mpc836x_mds.c | 5 + arch/powerpc/platforms/83xx/mpc836x_rdk.c | 5 + arch/powerpc/platforms/83xx/mpc837x_mds.c | 5 + arch/powerpc/platforms/83xx/mpc837x_rdb.c | 5 + arch/powerpc/platforms/83xx/mpc83xx.h | 1 + arch/powerpc/platforms/83xx/sbc834x.c | 5 + 15 files changed, 22 insertions(+), 51 deletions(-) diff --git a/arch/powerpc/platforms/83xx/asp834x.c b/arch/powerpc/platforms/83xx/asp834x.c index 17e54339f8d9..575afd6eb36a 100644 --- a/arch/powerpc/platforms/83xx/asp834x.c +++ b/arch/powerpc/platforms/83xx/asp834x.c @@ -30,9 +30,7 @@ */ static void __init asp834x_setup_arch(void) { - if (ppc_md.progress) - ppc_md.progress("asp834x_setup_arch()", 0); - + mpc83xx_setup_arch(); mpc834x_usb_cfg(); } diff --git a/arch/powerpc/platforms/83xx/km83xx.c b/arch/powerpc/platforms/83xx/km83xx.c index e7fbd6366abb..d8642a4afc74 100644 --- a/arch/powerpc/platforms/83xx/km83xx.c +++ b/arch/powerpc/platforms/83xx/km83xx.c @@ -130,10 +130,7 @@ static void __init mpc83xx_km_setup_arch(void) struct device_node *np; #endif - if (ppc_md.progress) - ppc_md.progress("kmpbec83xx_setup_arch()", 0); - - mpc83xx_setup_pci(); + mpc83xx_setup_arch(); #ifdef CONFIG_QUICC_ENGINE np = of_find_node_by_name(NULL, "par_io"); diff --git a/arch/powerpc/platforms/83xx/misc.c b/arch/powerpc/platforms/83xx/misc.c index 8899aa9d11f5..d75c9816a5c9 100644 --- a/arch/powerpc/platforms/83xx/misc.c +++ b/arch/powerpc/platforms/83xx/misc.c @@ -142,3 +142,11 @@ void __init mpc83xx_setup_pci(void) mpc83xx_add_bridge(np); } #endif + +void __init mpc83xx_setup_arch(void) +{ + if (ppc_md.progress) + ppc_md.progress("mpc83xx_setup_arch()", 0); + + mpc83xx_setup_pci(); +} diff --git a/arch/powerpc/platforms/83xx/mpc830x_rdb.c b/arch/powerpc/platforms/83xx/mpc830x_rdb.c index 040d5d085467..272c41c387b9 100644 --- a/arch/powerpc/platforms/83xx/mpc830x_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc830x_rdb.c @@ -27,10 +27,7 @@ */ static void __init mpc830x_rdb_setup_arch(void) { - if (ppc_md.progress) - ppc_md.progress("mpc830x_rdb_setup_arch()", 0); - - mpc83xx_setup_pci(); + mpc83xx_setup_arch(); mpc831x_usb_cfg(); } diff --git a/arch/powerpc/platforms/83xx/mpc831x_rdb.c b/arch/powerpc/platforms/83xx/mpc831x_rdb.c index 40e0d8307b59..fd80fd570e67 100644 --- a/arch/powerpc/platforms/83xx/mpc831x_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc831x_rdb.c @@ -28,10 +28,7 @@ */ static void __init mpc831x_rdb_setup_arch(void) { - if (ppc_md.progress) - ppc_md.progress("mpc831x_rdb_setup_arch()", 0); - - mpc83xx_setup_pci(); + mpc83xx_setup_arch(); mpc831x_usb_cfg(); } diff --git a/arch/powerpc/platforms/83xx/mpc832x_mds.c b/arch/powerpc/platforms/83xx/mpc832x_mds.c index cdfa47c4d394..bb7b25acf26f 100644 --- a/arch/powerpc/platforms/83xx/mpc832x_mds.c +++ b/arch/powerpc/platforms/83xx/mpc832x_mds.c @@ -58,8 +58,7 @@ static void __init mpc832x_sys_setup_arch(void) struct device_node *np; u8 __iomem *bcsr_regs = NULL; - if (ppc_md.progress) - ppc_md.progress("mpc832x_sys_setup_arch()", 0); + mpc83xx_setup_arch(); /* Map BCSR area */ np = of_find_node_by_name(NULL, "bcsr"); @@ -71,8 +70,6 @@ static void __init mpc832x_sys_setup_arch(void) of_node_put(np); } - mpc83xx_setup_pci(); - #ifdef CONFIG_QUICC_ENGINE if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) { par_io_init(np); diff --git a/arch/powerpc/platforms/83xx/mpc832x_rdb.c b/arch/powerpc/platforms/83xx/mpc832x_rdb.c index 2ef03e7d248c..09d1bbf25b5d 100644 --- a/arch/powerpc/platforms/83xx/mpc832x_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc832x_rdb.c @@ -197,10 +197,7 @@ static void __init mp
[PATCH 3/5] of/platform: introduce a generic way to declare a platform bus
The specific buses which need to be probed at boot time are different between platforms. Instead of put all the buses into the default of_default_bus_match_table[] match tables, this patch introduces a general way to declare a platform bus. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- drivers/of/platform.c | 12 +++- include/asm-generic/vmlinux.lds.h | 2 ++ include/linux/of.h| 22 ++ include/linux/of_platform.h | 5 + 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 6aaa1438c9cd..a7bfe8504caa 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -488,11 +488,21 @@ int of_platform_populate(struct device_node *root, } EXPORT_SYMBOL_GPL(of_platform_populate); +static const struct of_device_id __bus_of_table_sentinel + __used __section(__bus_of_table_end); + int of_platform_default_populate(struct device_node *root, const struct of_dev_auxdata *lookup, struct device *parent) { - return of_platform_populate(root, of_default_bus_match_table, lookup, + const struct of_device_id *matches; + + if (__bus_of_table != &__bus_of_table_sentinel) + matches = __bus_of_table; + else + matches = of_default_bus_match_table; + + return of_platform_populate(root, matches, lookup, parent); } EXPORT_SYMBOL_GPL(of_platform_default_populate); diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 24563970ff7b..43aa725e86fa 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -179,6 +179,7 @@ #define RESERVEDMEM_OF_TABLES()OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method) +#define BUS_OF_TABLES()OF_TABLE(CONFIG_OF, bus) #ifdef CONFIG_ACPI #define ACPI_PROBE_TABLE(name) \ @@ -542,6 +543,7 @@ IOMMU_OF_TABLES() \ CPU_METHOD_OF_TABLES() \ CPUIDLE_METHOD_OF_TABLES() \ + BUS_OF_TABLES() \ KERNEL_DTB()\ IRQCHIP_OF_MATCH_TABLE()\ ACPI_PROBE_TABLE(irqchip) \ diff --git a/include/linux/of.h b/include/linux/of.h index 3d9ff8e9d803..3a53c898cde9 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1002,12 +1002,28 @@ static inline int of_get_available_child_count(const struct device_node *np) __used __section(__##table##_of_table) \ = { .compatible = compat, \ .data = (fn == (fn_type)NULL) ? fn : fn } + +#define __OF_DECLARE_ALL(table, entry, _name, _type, _compat, _data) \ + static const struct of_device_id __of_table_##entry \ + __used __section(__##table##_of_table) \ + = { .name = _name, \ + .type = _type, \ + .compatible = _compat, \ + .data = _data } #else #define _OF_DECLARE(table, name, compat, fn, fn_type) \ static const struct of_device_id __of_table_##name \ __attribute__((unused)) \ = { .compatible = compat, \ .data = (fn == (fn_type)NULL) ? fn : fn } + +#define __OF_DECLARE_ALL(table, entry, _name, _type, _compat, _data) \ + static const struct of_device_id __of_table_##_name \ + __attribute__((unused)) \ + = { .name = _name, \ + .type = _type, \ + .compatible = _compat, \ + .data = _data } #endif typedef int (*of_init_fn_2)(struct device_node *, struct device_node *); @@ -1020,6 +1036,12 @@ typedef void (*of_init_fn_1)(struct device_node *); _OF_DECLARE(table, name, compat, fn, of_init_fn_1_ret) #define OF_DECLARE_2(table, name, compat, fn) \ _OF_DECLARE(table, name, compat, fn, of_init_fn_2) +#define OF_DECLARE_COMPAT(table, name, compat) \ + __OF_DECLARE_ALL(table, name, "", "", compat,
[PATCH 2/5] powerpc: introduce arch_enable_default_of_probe()
We can use this function to enable the default of probe for one board. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- arch/powerpc/include/asm/setup.h | 1 + arch/powerpc/kernel/of_platform.c | 9 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h index 654d64c9f3ac..213719882fe4 100644 --- a/arch/powerpc/include/asm/setup.h +++ b/arch/powerpc/include/asm/setup.h @@ -24,6 +24,7 @@ extern void reloc_got2(unsigned long); void check_for_initrd(void); void initmem_init(void); void setup_panic(void); +extern void arch_enable_default_of_probe(void); #define ARCH_PANIC_TIMEOUT 180 #ifdef CONFIG_PPC_PSERIES diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c index ace7fe132b6f..77402a14e928 100644 --- a/arch/powerpc/kernel/of_platform.c +++ b/arch/powerpc/kernel/of_platform.c @@ -123,7 +123,14 @@ device_initcall(of_pci_phb_init); #endif /* CONFIG_PPC_OF_PLATFORM_PCI */ +static bool default_of_probe_enabled; + bool __init arch_want_default_of_probe(void) { - return false; + return default_of_probe_enabled; +} + +void __init arch_enable_default_of_probe(void) +{ + default_of_probe_enabled = true; } -- 2.5.5
[PATCH 1/5] of/platform: introduce arch_want_default_of_probe()
In commit fc520f8b4fa3 ("of/platform: disable the of_platform_default_populate_init() for all the ppc boards"), we disable the default of probe for ppc in order to fix some broken boards. But we do want to leverage the default of probe function on ppc arch. So introduce a weak function arch_want_default_of_probe(), we can override it in arch specific code to enable/disable the default of probe per board. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- arch/powerpc/kernel/of_platform.c | 5 + drivers/of/platform.c | 9 ++--- include/linux/of_platform.h | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c index b60a67d92ebd..ace7fe132b6f 100644 --- a/arch/powerpc/kernel/of_platform.c +++ b/arch/powerpc/kernel/of_platform.c @@ -122,3 +122,8 @@ static __init int of_pci_phb_init(void) device_initcall(of_pci_phb_init); #endif /* CONFIG_PPC_OF_PLATFORM_PCI */ + +bool __init arch_want_default_of_probe(void) +{ + return false; +} diff --git a/drivers/of/platform.c b/drivers/of/platform.c index f39ccd5aa701..6aaa1438c9cd 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -497,12 +497,16 @@ int of_platform_default_populate(struct device_node *root, } EXPORT_SYMBOL_GPL(of_platform_default_populate); -#ifndef CONFIG_PPC +bool __init __weak arch_want_default_of_probe(void) +{ + return true; +} + static int __init of_platform_default_populate_init(void) { struct device_node *node; - if (!of_have_populated_dt()) + if (!arch_want_default_of_probe() || !of_have_populated_dt()) return -ENODEV; /* @@ -522,7 +526,6 @@ static int __init of_platform_default_populate_init(void) return 0; } arch_initcall_sync(of_platform_default_populate_init); -#endif static int of_platform_device_destroy(struct device *dev, void *data) { diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 956a1006aefc..02cf1fdaa3d0 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -76,6 +76,7 @@ extern int of_platform_default_populate(struct device_node *root, const struct of_dev_auxdata *lookup, struct device *parent); extern void of_platform_depopulate(struct device *parent); +extern bool arch_want_default_of_probe(void); #else static inline int of_platform_populate(struct device_node *root, const struct of_device_id *matches, -- 2.5.5
[PATCH 0/5] ppc32: use the default of_platform_default_populate_init() for 83xx boards
Hi, This is a follow on patch series of [1]. This tries to drop the arch specific codes of bus probe by using the common of_platform_default_populate_init() function. I just took the 83xx boards as an example. If you guys think that this is doable, I can change the remaining ppc boards to use this method for the of probe. [1] https://patchwork.ozlabs.org/patch/658531/ Kevin Hao (5): of/platform: introduce arch_want_default_of_probe() powerpc: introduce arch_enable_default_of_probe() of/platform: introduce a generic way to declare a platform bus powerpc/83xx: factor out the common codes of setup arch functions powerpc/83xx: enable the default of probe arch/powerpc/include/asm/setup.h | 1 + arch/powerpc/kernel/of_platform.c | 12 +++ arch/powerpc/platforms/83xx/asp834x.c | 6 +- arch/powerpc/platforms/83xx/km83xx.c | 7 +-- arch/powerpc/platforms/83xx/misc.c| 33 +++ arch/powerpc/platforms/83xx/mpc830x_rdb.c | 7 +-- arch/powerpc/platforms/83xx/mpc831x_rdb.c | 7 +-- arch/powerpc/platforms/83xx/mpc832x_mds.c | 7 +-- arch/powerpc/platforms/83xx/mpc832x_rdb.c | 7 +-- arch/powerpc/platforms/83xx/mpc834x_itx.c | 17 +--- arch/powerpc/platforms/83xx/mpc834x_mds.c | 7 +-- arch/powerpc/platforms/83xx/mpc836x_mds.c | 7 +-- arch/powerpc/platforms/83xx/mpc836x_rdk.c | 7 +-- arch/powerpc/platforms/83xx/mpc837x_mds.c | 7 +-- arch/powerpc/platforms/83xx/mpc837x_rdb.c | 7 +-- arch/powerpc/platforms/83xx/mpc83xx.h | 2 +- arch/powerpc/platforms/83xx/sbc834x.c | 7 +-- drivers/of/platform.c | 21 include/asm-generic/vmlinux.lds.h | 2 ++ include/linux/of.h| 22 + include/linux/of_platform.h | 6 ++ 21 files changed, 90 insertions(+), 109 deletions(-) -- 2.5.5
Re: [PATCH] powerpc: populate the default bus with machine_arch_initcall
On Fri, Aug 12, 2016 at 02:39:32PM +1000, Michael Ellerman wrote: > Kevin Hao <haoke...@gmail.com> writes: > > > With the commit 44a7185c2ae6 ("of/platform: Add common method to > > populate default bus"), a default function is introduced to populate > > the default bus and this function is invoked at the arch_initcall_sync > > level. This will override the arch specific population of default bus > > which run at a lower level than arch_initcall_sync. Since not all > > powerpc specific buses are added to the of_default_bus_match_table[], > > this causes some powerpc specific bus are not probed. Fix this by > > using a more preceding initcall. > > > > Signed-off-by: Kevin Hao <haoke...@gmail.com> > > --- > > Of course we can adjust the powerpc arch codes to use the > > of_platform_default_populate_init(), but it has high risk to break > > other boards given the complicated powerpc specific buses. So I would > > like just to fix the broken boards in the current release, and cook > > a patch to change to of_platform_default_populate_init() for linux-next. > > > > Only boot test on a mpc8315erdb board. > > > > arch/powerpc/platforms/40x/ep405.c | 2 +- > > arch/powerpc/platforms/40x/ppc40x_simple.c | 2 +- > > arch/powerpc/platforms/40x/virtex.c | 2 +- > > arch/powerpc/platforms/40x/walnut.c | 2 +- > > arch/powerpc/platforms/44x/canyonlands.c | 2 +- > > arch/powerpc/platforms/44x/ebony.c | 2 +- > > arch/powerpc/platforms/44x/iss4xx.c | 2 +- > > arch/powerpc/platforms/44x/ppc44x_simple.c | 2 +- > > arch/powerpc/platforms/44x/ppc476.c | 2 +- > > arch/powerpc/platforms/44x/sam440ep.c| 2 +- > > arch/powerpc/platforms/44x/virtex.c | 2 +- > > arch/powerpc/platforms/44x/warp.c| 2 +- > > arch/powerpc/platforms/82xx/ep8248e.c| 2 +- > > arch/powerpc/platforms/82xx/km82xx.c | 2 +- > > arch/powerpc/platforms/82xx/mpc8272_ads.c| 2 +- > > arch/powerpc/platforms/82xx/pq2fads.c| 2 +- > > arch/powerpc/platforms/83xx/mpc831x_rdb.c| 2 +- > > arch/powerpc/platforms/83xx/mpc834x_itx.c| 2 +- > > arch/powerpc/platforms/85xx/ppa8548.c| 2 +- > > arch/powerpc/platforms/8xx/adder875.c| 2 +- > > arch/powerpc/platforms/8xx/ep88xc.c | 2 +- > > arch/powerpc/platforms/8xx/mpc86xads_setup.c | 2 +- > > arch/powerpc/platforms/8xx/mpc885ads_setup.c | 2 +- > > arch/powerpc/platforms/8xx/tqm8xx_setup.c| 2 +- > > arch/powerpc/platforms/cell/setup.c | 2 +- > > arch/powerpc/platforms/embedded6xx/gamecube.c| 2 +- > > arch/powerpc/platforms/embedded6xx/linkstation.c | 2 +- > > arch/powerpc/platforms/embedded6xx/mvme5100.c| 2 +- > > arch/powerpc/platforms/embedded6xx/storcenter.c | 2 +- > > arch/powerpc/platforms/embedded6xx/wii.c | 2 +- > > arch/powerpc/platforms/pasemi/setup.c | 2 +- > > That's not a very minimal fix. > > Every one of those initcall changes could be introducing a bug, by > changing the order vs other init calls. > > Can we just go back to the old behaviour on ppc? Sure. How about this one? From 4362b4cdd8a6198df4cc46c628473f0d44e03fa8 Mon Sep 17 00:00:00 2001 From: Kevin Hao <haoke...@gmail.com> Date: Fri, 12 Aug 2016 13:30:03 +0800 Subject: [PATCH v2] of/platform: disable the of_platform_default_populate_init() for all the ppc boards With the commit 44a7185c2ae6 ("of/platform: Add common method to populate default bus"), a default function is introduced to populate the default bus and this function is invoked at the arch_initcall_sync level. But a lot of ppc boards use machine_device_initcall() to populate the default bus. This means that the default populate function has higher priority and would override the arch specific population of the bus. The side effect is that some arch specific bus are not probed, then cause various malfunction due to the miss of some devices. Since it is very possible to introduce bugs if we simply change the initcall level for all these boards(about 30+). This just disable this default function for all the ppc boards. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- drivers/of/platform.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 8aa197691074..f39ccd5aa701 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -497,6 +497,7 @@ int of_platform_default_populate(struct device_node *root, } EXPORT_SYMBOL_GPL(of_platform_default_popula
Re: [PATCH] powerpc: populate the default bus with machine_arch_initcall
On Thu, Aug 11, 2016 at 08:17:52AM -0500, Rob Herring wrote: > On Thu, Aug 11, 2016 at 6:09 AM, Kevin Hao <haoke...@gmail.com> wrote: > > With the commit 44a7185c2ae6 ("of/platform: Add common method to > > populate default bus"), a default function is introduced to populate > > the default bus and this function is invoked at the arch_initcall_sync > > level. This will override the arch specific population of default bus > > which run at a lower level than arch_initcall_sync. Since not all > > powerpc specific buses are added to the of_default_bus_match_table[], > > this causes some powerpc specific bus are not probed. Fix this by > > using a more preceding initcall. > > > > Signed-off-by: Kevin Hao <haoke...@gmail.com> > > --- > > Of course we can adjust the powerpc arch codes to use the > > of_platform_default_populate_init(), but it has high risk to break > > other boards given the complicated powerpc specific buses. So I would > > like just to fix the broken boards in the current release, and cook > > a patch to change to of_platform_default_populate_init() for linux-next. > > The patch that broke things was sitting in -next for some time and no > one reported anything. Are all these boards broken? At least in theory. :-) The effect may be different due to what devices are missed. For me, the Gianfar Ethernet on my mpc8315erdb board is malfunction due to the MIDIO bus is not probed. > > I'm fine to just disable the default call for PPC instead if there's > some chance this does not fix some boards. I have tried to cover all the invocation of of_platform_bus_probe() via machine_device_initcall(). Yes, I maybe missed some boards. But won't we want to take this as a step to use the default populate function since it does remove some reduplication codes? > There could be some other > initcall ordering dependencies. > > > > > Only boot test on a mpc8315erdb board. > > Curious, what would it take to remove the of_platform_bus_probe and > use the default here? We can add additional bus compatibles to match. I thought about this. But the bus compatibles list seems a bit longer and it may cause some side effects on some boards due to all these additional buses. So that changes seem a bit aggressive to me. It does seem a feature for linux-next. The following is the compatible buses list which are needed to be added to the default match table if we want fix all the current broken boards: { .compatible = "fsl,ep8248e-bcsr", }, { .compatible = "fsl,pq2pro-localbus", }, { .compatible = "fsl,qe", }, { .compatible = "fsl,srio", }, { .compatible = "gianfar", }, { .compatible = "gpio-leds", }, { .compatible = "hawk-bridge", }, { .compatible = "ibm,ebc", }, { .compatible = "ibm,opb", }, { .compatible = "ibm,plb3", }, { .compatible = "ibm,plb4", }, { .compatible = "ibm,plb6", }, { .compatible = "nintendo,flipper", }, { .compatible = "nintendo,hollywood", }, { .compatible = "pasemi,localbus", }, { .compatible = "pasemi,sdc", }, { .compatible = "soc", }, { .compatible = "xlnx,compound", }, { .compatible = "xlnx,dcr-v29-1.00.a", }, { .compatible = "xlnx,opb-v20-1.10.c", }, { .compatible = "xlnx,plb-v34-1.01.a", }, { .compatible = "xlnx,plb-v34-1.02.a", }, { .compatible = "xlnx,plb-v46-1.00.a", }, { .compatible = "xlnx,plb-v46-1.02.a", }, { .name = "cpm", }, { .name = "localbus", }, { .name = "soc", }, { .type = "axon", }, { .type = "ebc", }, { .type = "opb", }, { .type = "plb4", }, { .type = "plb5", }, { .type = "qe", }, { .type = "soc", }, { .type = "spider", }, Of course I can choose to use the default function if all you guys think it is better. :-) > The difference between of_platform_bus_probe and > of_platform_bus_populate is the former will match root nodes with no > compatible string. Most platforms should not need that behavior and it > would be nice to know which ones. I don't think this difference would cause any real side effect for these boards. Thanks, Kevin signature.asc Description: PGP signature
[PATCH] powerpc: populate the default bus with machine_arch_initcall
With the commit 44a7185c2ae6 ("of/platform: Add common method to populate default bus"), a default function is introduced to populate the default bus and this function is invoked at the arch_initcall_sync level. This will override the arch specific population of default bus which run at a lower level than arch_initcall_sync. Since not all powerpc specific buses are added to the of_default_bus_match_table[], this causes some powerpc specific bus are not probed. Fix this by using a more preceding initcall. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- Of course we can adjust the powerpc arch codes to use the of_platform_default_populate_init(), but it has high risk to break other boards given the complicated powerpc specific buses. So I would like just to fix the broken boards in the current release, and cook a patch to change to of_platform_default_populate_init() for linux-next. Only boot test on a mpc8315erdb board. arch/powerpc/platforms/40x/ep405.c | 2 +- arch/powerpc/platforms/40x/ppc40x_simple.c | 2 +- arch/powerpc/platforms/40x/virtex.c | 2 +- arch/powerpc/platforms/40x/walnut.c | 2 +- arch/powerpc/platforms/44x/canyonlands.c | 2 +- arch/powerpc/platforms/44x/ebony.c | 2 +- arch/powerpc/platforms/44x/iss4xx.c | 2 +- arch/powerpc/platforms/44x/ppc44x_simple.c | 2 +- arch/powerpc/platforms/44x/ppc476.c | 2 +- arch/powerpc/platforms/44x/sam440ep.c| 2 +- arch/powerpc/platforms/44x/virtex.c | 2 +- arch/powerpc/platforms/44x/warp.c| 2 +- arch/powerpc/platforms/82xx/ep8248e.c| 2 +- arch/powerpc/platforms/82xx/km82xx.c | 2 +- arch/powerpc/platforms/82xx/mpc8272_ads.c| 2 +- arch/powerpc/platforms/82xx/pq2fads.c| 2 +- arch/powerpc/platforms/83xx/mpc831x_rdb.c| 2 +- arch/powerpc/platforms/83xx/mpc834x_itx.c| 2 +- arch/powerpc/platforms/85xx/ppa8548.c| 2 +- arch/powerpc/platforms/8xx/adder875.c| 2 +- arch/powerpc/platforms/8xx/ep88xc.c | 2 +- arch/powerpc/platforms/8xx/mpc86xads_setup.c | 2 +- arch/powerpc/platforms/8xx/mpc885ads_setup.c | 2 +- arch/powerpc/platforms/8xx/tqm8xx_setup.c| 2 +- arch/powerpc/platforms/cell/setup.c | 2 +- arch/powerpc/platforms/embedded6xx/gamecube.c| 2 +- arch/powerpc/platforms/embedded6xx/linkstation.c | 2 +- arch/powerpc/platforms/embedded6xx/mvme5100.c| 2 +- arch/powerpc/platforms/embedded6xx/storcenter.c | 2 +- arch/powerpc/platforms/embedded6xx/wii.c | 2 +- arch/powerpc/platforms/pasemi/setup.c| 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/arch/powerpc/platforms/40x/ep405.c b/arch/powerpc/platforms/40x/ep405.c index 1c8aec6e9bb7..1328cb38e5d7 100644 --- a/arch/powerpc/platforms/40x/ep405.c +++ b/arch/powerpc/platforms/40x/ep405.c @@ -62,7 +62,7 @@ static int __init ep405_device_probe(void) return 0; } -machine_device_initcall(ep405, ep405_device_probe); +machine_arch_initcall(ep405, ep405_device_probe); static void __init ep405_init_bcsr(void) { diff --git a/arch/powerpc/platforms/40x/ppc40x_simple.c b/arch/powerpc/platforms/40x/ppc40x_simple.c index 2a050007bbae..50dce54e6b3b 100644 --- a/arch/powerpc/platforms/40x/ppc40x_simple.c +++ b/arch/powerpc/platforms/40x/ppc40x_simple.c @@ -39,7 +39,7 @@ static int __init ppc40x_device_probe(void) return 0; } -machine_device_initcall(ppc40x_simple, ppc40x_device_probe); +machine_arch_initcall(ppc40x_simple, ppc40x_device_probe); /* This is the list of boards that can be supported by this simple * platform code. This does _not_ mean the boards are compatible, diff --git a/arch/powerpc/platforms/40x/virtex.c b/arch/powerpc/platforms/40x/virtex.c index 91a08ea758a8..d262696b3cbc 100644 --- a/arch/powerpc/platforms/40x/virtex.c +++ b/arch/powerpc/platforms/40x/virtex.c @@ -33,7 +33,7 @@ static int __init virtex_device_probe(void) return 0; } -machine_device_initcall(virtex, virtex_device_probe); +machine_arch_initcall(virtex, virtex_device_probe); static int __init virtex_probe(void) { diff --git a/arch/powerpc/platforms/40x/walnut.c b/arch/powerpc/platforms/40x/walnut.c index e5797815e2f1..9a9c0bccba47 100644 --- a/arch/powerpc/platforms/40x/walnut.c +++ b/arch/powerpc/platforms/40x/walnut.c @@ -42,7 +42,7 @@ static int __init walnut_device_probe(void) return 0; } -machine_device_initcall(walnut, walnut_device_probe); +machine_arch_initcall(walnut, walnut_device_probe); static int __init walnut_probe(void) { diff --git a/arch/powerpc/platforms/44x/canyonlands.c b/arch/powerpc/platforms/44x/canyonlands.c index 157f4ce46386..681fa66ff194 100644 --- a/arch/powerpc/platforms/44x/canyonlands.c +++ b/arch/powerpc/platforms/44x/canyonlands.c @@ -47,7 +47,7 @@ static int __init ppc460ex_device_probe(void)
Re: [PATCH for-4.8 V2 08/10] powerpc: use the jump label for cpu_has_feature
On Mon, Jul 25, 2016 at 04:28:49PM +1000, Nicholas Piggin wrote: > On Sat, 23 Jul 2016 14:42:41 +0530 > "Aneesh Kumar K.V" <aneesh.ku...@linux.vnet.ibm.com> wrote: > > > From: Kevin Hao <haoke...@gmail.com> > > > > The cpu features are fixed once the probe of cpu features are done. > > And the function cpu_has_feature() does be used in some hot path. > > The checking of the cpu features for each time of invoking of > > cpu_has_feature() seems suboptimal. This tries to reduce this > > overhead of this check by using jump label. > > > > The generated assemble code of the following c program: > > if (cpu_has_feature(CPU_FTR_XXX)) > > xxx() > > > > Before: > > lis r9,-16230 > > lwz r9,12324(r9) > > lwz r9,12(r9) > > andi. r10,r9,512 > > beqlr- > > > > After: > > nop if CPU_FTR_XXX is enabled > > b xxx if CPU_FTR_XXX is not enabled > > > > Signed-off-by: Kevin Hao <haoke...@gmail.com> > > Signed-off-by: Aneesh Kumar K.V <aneesh.ku...@linux.vnet.ibm.com> > > --- > > arch/powerpc/include/asm/cpufeatures.h | 21 + > > arch/powerpc/include/asm/cputable.h| 8 > > arch/powerpc/kernel/cputable.c | 20 > > arch/powerpc/lib/feature-fixups.c | 1 + > > 4 files changed, 50 insertions(+) > > > > diff --git a/arch/powerpc/include/asm/cpufeatures.h > > b/arch/powerpc/include/asm/cpufeatures.h index > > bfa6cb8f5629..4a4a0b898463 100644 --- > > a/arch/powerpc/include/asm/cpufeatures.h +++ > > b/arch/powerpc/include/asm/cpufeatures.h @@ -13,10 +13,31 @@ static > > inline bool __cpu_has_feature(unsigned long feature) > > return !!(CPU_FTRS_POSSIBLE & cur_cpu_spec->cpu_features & feature); } > > > > +#ifdef CONFIG_JUMP_LABEL > > +#include > > + > > +extern struct static_key_true cpu_feat_keys[MAX_CPU_FEATURES]; > > + > > +static __always_inline bool cpu_has_feature(unsigned long feature) > > +{ > > + int i; > > + > > + if (CPU_FTRS_ALWAYS & feature) > > + return true; > > + > > + if (!(CPU_FTRS_POSSIBLE & feature)) > > + return false; > > + > > + i = __builtin_ctzl(feature); > > + return static_branch_likely(_feat_keys[i]); > > +} > > Is feature ever not-constant, or could it ever be, I wonder? We could > do a build time check to ensure it is always constant? In the current code, all the using of this function are passing a constant argument. But yes, due to the implementation of jump label, we should add a check here to ensure that a constant is passed to this function. Something likes this: if (!__builtin_constant_p(feature)) return __cpu_has_feature(feature); We need the same change for the mmu_has_feature(). Thanks, Kevin signature.asc Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2 0/3] powerpc: tweak the kernel options for CRASH_DUMP and RELOCATABLE
Please ignore this. Forgot the CC list. Thanks, Kevin On Wed, Jul 13, 2016 at 09:12:53AM +0800, Kevin Hao wrote: > v2: > Compare to v1 [1], the main differences are: > - Still automatically select RELOCATABLE when CRASH_DUMP is enabled. > - Add a new patch to kill RELOCATABLE_PPC32. > > v1: > The first patch fixes a build error when CRASH_DUMP=y && ADVANCED_OPTIONS=n > for ppc32. The second does some cleanup for RELOCATABLE option. > > Kevin Hao (3): > powerpc32: booke: fix the build error when CRASH_DUMP is enabled > powerpc: merge the RELOCATABLE config entries for ppc32 and ppc64 > powerpc32: kill RELOCATABLE_PPC32 > > arch/powerpc/Kconfig | 61 > +++ > arch/powerpc/include/asm/page.h | 6 ++-- > arch/powerpc/kernel/Makefile | 3 +- > arch/powerpc/kernel/vmlinux.lds.S | 2 +- > arch/powerpc/mm/init_32.c | 2 +- > 5 files changed, 29 insertions(+), 45 deletions(-) > > [1] > http://linuxppc-dev.ozlabs.narkive.com/fKHcSZbu/patch-0-2-powerpc-tweak-the-kernel-options-for-crash-dump-and-relocatable > -- > 2.8.1 > signature.asc Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 3/3] powerpc32: kill RELOCATABLE_PPC32
It is seldom used in the kernel code and can be easily replaced by either RELOCATABLE or PPC32. So there is no reason to keep a separate kernel option for this. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- arch/powerpc/Kconfig | 4 arch/powerpc/include/asm/page.h | 6 +++--- arch/powerpc/kernel/Makefile | 3 +-- arch/powerpc/kernel/vmlinux.lds.S | 2 +- arch/powerpc/mm/init_32.c | 2 +- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index a9d847c8a20d..98f7e29e5680 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -481,10 +481,6 @@ config RELOCATABLE setting can still be useful to bootwrappers that need to know the load address of the kernel (eg. u-boot/mkimage). -config RELOCATABLE_PPC32 - def_bool y - depends on PPC32 && RELOCATABLE - config CRASH_DUMP bool "Build a kdump crash kernel" depends on PPC64 || 6xx || FSL_BOOKE || (44x && !SMP) diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h index 51db3a37bced..56398e7e6100 100644 --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -96,7 +96,7 @@ extern unsigned int HPAGE_SHIFT; extern phys_addr_t memstart_addr; extern phys_addr_t kernstart_addr; -#ifdef CONFIG_RELOCATABLE_PPC32 +#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_PPC32) extern long long virt_phys_offset; #endif @@ -139,9 +139,9 @@ extern long long virt_phys_offset; * determine MEMORY_START until then. However we can determine PHYSICAL_START * from information at hand (program counter, TLB lookup). * - * On BookE with RELOCATABLE (RELOCATABLE_PPC32) + * On BookE with RELOCATABLE && PPC32 * - * With RELOCATABLE_PPC32, we support loading the kernel at any physical + * With RELOCATABLE && PPC32, we support loading the kernel at any physical * address without any restriction on the page alignment. * * We find the runtime address of _stext and relocate ourselves based on diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 0c7106df90e6..0719b1a3fb24 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -47,7 +47,6 @@ obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_PPC_BOOK3S_64)+= cpu_setup_ppc970.o cpu_setup_pa6t.o obj-$(CONFIG_PPC_BOOK3S_64)+= cpu_setup_power.o obj-$(CONFIG_PPC_BOOK3S_64)+= mce.o mce_power.o hmi.o -obj64-$(CONFIG_RELOCATABLE)+= reloc_64.o obj-$(CONFIG_PPC_BOOK3E_64)+= exceptions-64e.o idle_book3e.o obj-$(CONFIG_PPC64)+= vdso64/ obj-$(CONFIG_ALTIVEC) += vecemu.o @@ -92,7 +91,7 @@ extra-$(CONFIG_FSL_BOOKE) := head_fsl_booke.o extra-$(CONFIG_8xx):= head_8xx.o extra-y+= vmlinux.lds -obj-$(CONFIG_RELOCATABLE_PPC32)+= reloc_32.o +obj-$(CONFIG_RELOCATABLE) += reloc_$(CONFIG_WORD_SIZE).o obj-$(CONFIG_PPC32)+= entry_32.o setup_32.o obj-$(CONFIG_PPC64)+= dma-iommu.o iommu.o diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S index 2dd91f79de05..b5fba689fca6 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S +++ b/arch/powerpc/kernel/vmlinux.lds.S @@ -165,7 +165,7 @@ SECTIONS . = ALIGN(8); .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET) { -#ifdef CONFIG_RELOCATABLE_PPC32 +#ifdef CONFIG_PPC32 __dynamic_symtab = .; #endif *(.dynsym) diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c index e2d7ba124618..448685fbf27c 100644 --- a/arch/powerpc/mm/init_32.c +++ b/arch/powerpc/mm/init_32.c @@ -64,7 +64,7 @@ EXPORT_SYMBOL(memstart_addr); phys_addr_t kernstart_addr; EXPORT_SYMBOL(kernstart_addr); -#ifdef CONFIG_RELOCATABLE_PPC32 +#ifdef CONFIG_RELOCATABLE /* Used in __va()/__pa() */ long long virt_phys_offset; EXPORT_SYMBOL(virt_phys_offset); -- 2.8.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 2/3] powerpc: merge the RELOCATABLE config entries for ppc32 and ppc64
It makes no sense to keep two separate RELOCATABLE config entries for ppc32 and ppc64 respectively. Merge them into one and move it to a common place. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- arch/powerpc/Kconfig | 65 ++-- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index cb7910b9f10f..a9d847c8a20d 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -458,6 +458,33 @@ config KEXEC interface is strongly in flux, so no good recommendation can be made. +config RELOCATABLE + bool "Build a relocatable kernel" + depends on (PPC64 && !COMPILE_TEST) || (FLATMEM && (44x || FSL_BOOKE)) + select NONSTATIC_KERNEL + help + This builds a kernel image that is capable of running at the + location the kernel is loaded at. For ppc32, there is no any + alignment restrictions, and this feature is a superset of + DYNAMIC_MEMSTART and hence overrides it. For ppc64, we should use + 16k-aligned base address. The kernel is linked as a + position-independent executable (PIE) and contains dynamic relocations + which are processed early in the bootup process. + + One use is for the kexec on panic case where the recovery kernel + must live at a different physical address than the primary + kernel. + + Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address + it has been loaded at and the compile time physical addresses + CONFIG_PHYSICAL_START is ignored. However CONFIG_PHYSICAL_START + setting can still be useful to bootwrappers that need to know the + load address of the kernel (eg. u-boot/mkimage). + +config RELOCATABLE_PPC32 + def_bool y + depends on PPC32 && RELOCATABLE + config CRASH_DUMP bool "Build a kdump crash kernel" depends on PPC64 || 6xx || FSL_BOOKE || (44x && !SMP) @@ -950,29 +977,6 @@ config DYNAMIC_MEMSTART This option is overridden by CONFIG_RELOCATABLE -config RELOCATABLE - bool "Build a relocatable kernel" - depends on FLATMEM && (44x || FSL_BOOKE) - select NONSTATIC_KERNEL - help - This builds a kernel image that is capable of running at the - location the kernel is loaded at, without any alignment restrictions. - This feature is a superset of DYNAMIC_MEMSTART and hence overrides it. - - One use is for the kexec on panic case where the recovery kernel - must live at a different physical address than the primary - kernel. - - Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address - it has been loaded at and the compile time physical addresses - CONFIG_PHYSICAL_START is ignored. However CONFIG_PHYSICAL_START - setting can still be useful to bootwrappers that need to know the - load address of the kernel (eg. u-boot/mkimage). - -config RELOCATABLE_PPC32 - def_bool y - depends on PPC32 && RELOCATABLE - config PAGE_OFFSET_BOOL bool "Set custom page offset address" depends on ADVANCED_OPTIONS @@ -1063,21 +1067,6 @@ config PIN_TLB_IMMR endmenu if PPC64 -config RELOCATABLE - bool "Build a relocatable kernel" - depends on !COMPILE_TEST - select NONSTATIC_KERNEL - help - This builds a kernel image that is capable of running anywhere - in the RMA (real memory area) at any 16k-aligned base address. - The kernel is linked as a position-independent executable (PIE) - and contains dynamic relocations which are processed early - in the bootup process. - - One use is for the kexec on panic case where the recovery kernel - must live at a different physical address than the primary - kernel. - # This value must have zeroes in the bottom 60 bits otherwise lots will break config PAGE_OFFSET hex -- 2.8.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 1/3] powerpc32: booke: fix the build error when CRASH_DUMP is enabled
In the current code, the RELOCATABLE will be forcedly enabled when enabling CRASH_DUMP. But for ppc32, the RELOCABLE also depend on ADVANCED_OPTIONS and select NONSTATIC_KERNEL. This will cause the following build error when CRASH_DUMP=y && ADVANCED_OPTIONS=n because the select of NONSTATIC_KERNEL doesn't take effect. arch/powerpc/include/asm/io.h: In function 'virt_to_phys': arch/powerpc/include/asm/page.h:113:26: error: 'virt_phys_offset' undeclared (first use in this function) #define VIRT_PHYS_OFFSET virt_phys_offset ^ It doesn't have any strong reasons to make the RELOCATABLE depend on ADVANCED_OPTIONS. So remove this dependency to fix this issue. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- arch/powerpc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 0a4cea451cf2..cb7910b9f10f 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -952,7 +952,7 @@ config DYNAMIC_MEMSTART config RELOCATABLE bool "Build a relocatable kernel" - depends on ADVANCED_OPTIONS && FLATMEM && (44x || FSL_BOOKE) + depends on FLATMEM && (44x || FSL_BOOKE) select NONSTATIC_KERNEL help This builds a kernel image that is capable of running at the -- 2.8.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 0/3] powerpc: tweak the kernel options for CRASH_DUMP and RELOCATABLE
v2: Compare to v1 [1], the main differences are: - Still automatically select RELOCATABLE when CRASH_DUMP is enabled. - Add a new patch to kill RELOCATABLE_PPC32. v1: The first patch fixes a build error when CRASH_DUMP=y && ADVANCED_OPTIONS=n for ppc32. The second does some cleanup for RELOCATABLE option. Kevin Hao (3): powerpc32: booke: fix the build error when CRASH_DUMP is enabled powerpc: merge the RELOCATABLE config entries for ppc32 and ppc64 powerpc32: kill RELOCATABLE_PPC32 arch/powerpc/Kconfig | 61 +++ arch/powerpc/include/asm/page.h | 6 ++-- arch/powerpc/kernel/Makefile | 3 +- arch/powerpc/kernel/vmlinux.lds.S | 2 +- arch/powerpc/mm/init_32.c | 2 +- 5 files changed, 29 insertions(+), 45 deletions(-) [1] http://linuxppc-dev.ozlabs.narkive.com/fKHcSZbu/patch-0-2-powerpc-tweak-the-kernel-options-for-crash-dump-and-relocatable -- 2.8.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 0/3] powerpc: tweak the kernel options for CRASH_DUMP and RELOCATABLE
v2: Compare to v1 [1], the main differences are: - Still automatically select RELOCATABLE when CRASH_DUMP is enabled. - Add a new patch to kill RELOCATABLE_PPC32. v1: The first patch fixes a build error when CRASH_DUMP=y && ADVANCED_OPTIONS=n for ppc32. The second does some cleanup for RELOCATABLE option. Kevin Hao (3): powerpc32: booke: fix the build error when CRASH_DUMP is enabled powerpc: merge the RELOCATABLE config entries for ppc32 and ppc64 powerpc32: kill RELOCATABLE_PPC32 arch/powerpc/Kconfig | 61 +++ arch/powerpc/include/asm/page.h | 6 ++-- arch/powerpc/kernel/Makefile | 3 +- arch/powerpc/kernel/vmlinux.lds.S | 2 +- arch/powerpc/mm/init_32.c | 2 +- 5 files changed, 29 insertions(+), 45 deletions(-) [1] http://linuxppc-dev.ozlabs.narkive.com/fKHcSZbu/patch-0-2-powerpc-tweak-the-kernel-options-for-crash-dump-and-relocatable -- 2.8.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v2] powerpc/e6500: hw tablewalk: make sure we invalidate and write to the same tlb entry
On Fri, Oct 16, 2015 at 07:01:55PM -0500, Scott Wood wrote: > On Tue, Aug 18, 2015 at 03:55:56PM +0800, Kevin Hao wrote: > > diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S > > index e4185581c5a7..3a5b89dfb5a1 100644 > > --- a/arch/powerpc/mm/tlb_low_64e.S > > +++ b/arch/powerpc/mm/tlb_low_64e.S > > @@ -68,11 +68,21 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) > > ld r14,PACAPGD(r13) > > std r15,EX_TLB_R15(r12) > > std r10,EX_TLB_CR(r12) > > +#ifdef CONFIG_PPC_FSL_BOOK3E > > +BEGIN_FTR_SECTION > > + std r7,EX_TLB_R7(r12) > > +END_FTR_SECTION_IFSET(CPU_FTR_SMT) > > +#endif > > TLB_MISS_PROLOG_STATS > > .endm > > > > .macro tlb_epilog_bolted > > ld r14,EX_TLB_CR(r12) > > +#ifdef CONFIG_PPC_FSL_BOOK3E > > +BEGIN_FTR_SECTION > > + ld r7,EX_TLB_R7(r12) > > +END_FTR_SECTION_IFSET(CPU_FTR_SMT) > > +#endif > > r7 is used outside the CPU_FTR_SMT section of the e6500 TLB handler. Sorry for the delay response just back from vacation. I will move the load of TCD_ESEL_NEXT out of CPU_FTR_SMT wrap. Thanks, Kevin pgp8Vri6vCjiP.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3] powerpc/e6500: hw tablewalk: make sure we invalidate and write to the same tlb entry
In order to workaround Erratum A-008139, we have to invalidate the tlb entry with tlbilx before overwriting. Due to the performance consideration, we don't add any memory barrier when acquire/release the tcd lock. This means the two load instructions for esel_next do have the possibility to return different value. This is definitely not acceptable due to the Erratum A-008139. We have two options to fix this issue: a) Add memory barrier when acquire/release tcd lock to order the load/store to esel_next. b) Just make sure to invalidate and write to the same tlb entry and tolerate the race that we may get the wrong value and overwrite the tlb entry just updated by the other thread. We observe better performance using option b. So reserve an additional register to save the value of the esel_next. Signed-off-by: Kevin Hao <haoke...@gmail.com> --- v3: Move the load of TCD_ESEL_NEXT out of CPU_FTR_SMT since it is also used for non-SMT codes. Boot test for both SMT and non-SMT mode. v2: Use an additional register for saving the value of esel_next instead of lwsync. arch/powerpc/include/asm/exception-64e.h | 11 ++- arch/powerpc/mm/tlb_low_64e.S| 25 + 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/include/asm/exception-64e.h b/arch/powerpc/include/asm/exception-64e.h index a8b52b61043f..d53575becbed 100644 --- a/arch/powerpc/include/asm/exception-64e.h +++ b/arch/powerpc/include/asm/exception-64e.h @@ -69,13 +69,14 @@ #define EX_TLB_ESR ( 9 * 8) /* Level 0 and 2 only */ #define EX_TLB_SRR0(10 * 8) #define EX_TLB_SRR1(11 * 8) +#define EX_TLB_R7 (12 * 8) #ifdef CONFIG_BOOK3E_MMU_TLB_STATS -#define EX_TLB_R8 (12 * 8) -#define EX_TLB_R9 (13 * 8) -#define EX_TLB_LR (14 * 8) -#define EX_TLB_SIZE(15 * 8) +#define EX_TLB_R8 (13 * 8) +#define EX_TLB_R9 (14 * 8) +#define EX_TLB_LR (15 * 8) +#define EX_TLB_SIZE(16 * 8) #else -#define EX_TLB_SIZE(12 * 8) +#define EX_TLB_SIZE(13 * 8) #endif #defineSTART_EXCEPTION(label) \ diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S index e4185581c5a7..29d6987c37ba 100644 --- a/arch/powerpc/mm/tlb_low_64e.S +++ b/arch/powerpc/mm/tlb_low_64e.S @@ -68,11 +68,17 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) ld r14,PACAPGD(r13) std r15,EX_TLB_R15(r12) std r10,EX_TLB_CR(r12) +#ifdef CONFIG_PPC_FSL_BOOK3E + std r7,EX_TLB_R7(r12) +#endif TLB_MISS_PROLOG_STATS .endm .macro tlb_epilog_bolted ld r14,EX_TLB_CR(r12) +#ifdef CONFIG_PPC_FSL_BOOK3E + ld r7,EX_TLB_R7(r12) +#endif ld r10,EX_TLB_R10(r12) ld r11,EX_TLB_R11(r12) ld r13,EX_TLB_R13(r12) @@ -297,6 +303,7 @@ itlb_miss_fault_bolted: * r13 = PACA * r11 = tlb_per_core ptr * r10 = crap (free to use) + * r7 = esel_next */ tlb_miss_common_e6500: crmove cr2*4+2,cr0*4+2 /* cr2.eq != 0 if kernel address */ @@ -325,7 +332,11 @@ BEGIN_FTR_SECTION /* CPU_FTR_SMT */ bne 10b b 1b .previous +END_FTR_SECTION_IFSET(CPU_FTR_SMT) + + lbz r7,TCD_ESEL_NEXT(r11) +BEGIN_FTR_SECTION /* CPU_FTR_SMT */ /* * Erratum A-008139 says that we can't use tlbwe to change * an indirect entry in any way (including replacing or @@ -334,8 +345,7 @@ BEGIN_FTR_SECTION /* CPU_FTR_SMT */ * with tlbilx before overwriting. */ - lbz r15,TCD_ESEL_NEXT(r11) - rlwinm r10,r15,16,0xff + rlwinm r10,r7,16,0xff orisr10,r10,MAS0_TLBSEL(1)@h mtspr SPRN_MAS0,r10 isync @@ -429,15 +439,14 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_SMT) mtspr SPRN_MAS2,r15 tlb_miss_huge_done_e6500: - lbz r15,TCD_ESEL_NEXT(r11) lbz r16,TCD_ESEL_MAX(r11) lbz r14,TCD_ESEL_FIRST(r11) - rlwimi r10,r15,16,0x00ff /* insert esel_next into MAS0 */ - addir15,r15,1 /* increment esel_next */ + rlwimi r10,r7,16,0x00ff/* insert esel_next into MAS0 */ + addir7,r7,1 /* increment esel_next */ mtspr SPRN_MAS0,r10 - cmpwr15,r16 - iseleq r15,r14,r15 /* if next == last use first */ - stb r15,TCD_ESEL_NEXT(r11) + cmpwr7,r16 + iseleq r7,r14,r7 /* if next == last use first */ + stb r7,TCD_ESEL_NEXT(r11) tlbwe -- 2.4.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: fsl_pci: cast the regs->nip to void * when passing it to probe_kernel_address()
On Tue, Sep 22, 2015 at 12:08:17PM +1000, Michael Ellerman wrote: > On Mon, 2015-09-21 at 17:22 +0800, Kevin Hao wrote: > > With the reimplementation of probe_kernel_address() in commit > > ecc83243e1d4 ("uaccess: reimplement probe_kernel_address() using > > probe_kernel_read()"), the explication of the cast for the addr > > parameter has been dropped. So we have to explicitly cast the > > regs->nip to void * when passing it to probe_kernel_address() in > > order to fix the following build error: > > arch/powerpc/sysdev/fsl_pci.c: In function 'fsl_pci_mcheck_exception': > > arch/powerpc/sysdev/fsl_pci.c:1002:4: error: passing argument 2 of > > 'probe_kernel_read' makes pointer from integer without a cast [-Werror] > > ret = probe_kernel_address(regs->nip, inst); > > ^ > > > > Signed-off-by: Kevin Hao <haoke...@gmail.com> > > --- > > > > This is against linux-next. > > You should be sending this to Andrew Morton, the author of the patch that > caused the breakage. Or at the very least CC'ing him. OK, will repost. Thanks, Kevin pgpQvMP4LPQtu.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: fsl_pci: cast the regs->nip to void * when passing it to probe_kernel_address()
On Mon, Sep 21, 2015 at 09:16:59PM -0500, Scott Wood wrote: > On Mon, 2015-09-21 at 17:22 +0800, Kevin Hao wrote: > > With the reimplementation of probe_kernel_address() in commit > > ecc83243e1d4 ("uaccess: reimplement probe_kernel_address() using > > probe_kernel_read()"), the explication of the cast for the addr > > parameter has been dropped. So we have to explicitly cast the > > regs->nip to void * when passing it to probe_kernel_address() in > > order to fix the following build error: > > arch/powerpc/sysdev/fsl_pci.c: In function 'fsl_pci_mcheck_exception': > > arch/powerpc/sysdev/fsl_pci.c:1002:4: error: passing argument 2 of > > 'probe_kernel_read' makes pointer from integer without a cast [-Werror] > > ret = probe_kernel_address(regs->nip, inst); > > ^ > > > > Signed-off-by: Kevin Hao <haoke...@gmail.com> > > --- > > > > This is against linux-next. > > I don't see ecc83243e1d4 in linux-next. What tree is it in? It's a patch from Andrew Morton. But it seems that the patches commit id from Andrew's tree are not constant. Anyway I just fetched the latest linux-next tree and found this issue was already fixed by commit 3a5f4236fec1 ("uaccess-reimplement-probe_kernel_address-using-probe_kernel_read-fix-fix"). Thanks, Kevin pgpiwjn3B2C06.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] powerpc: fsl_pci: cast the regs->nip to void * when passing it to probe_kernel_address()
With the reimplementation of probe_kernel_address() in commit ecc83243e1d4 ("uaccess: reimplement probe_kernel_address() using probe_kernel_read()"), the explication of the cast for the addr parameter has been dropped. So we have to explicitly cast the regs->nip to void * when passing it to probe_kernel_address() in order to fix the following build error: arch/powerpc/sysdev/fsl_pci.c: In function 'fsl_pci_mcheck_exception': arch/powerpc/sysdev/fsl_pci.c:1002:4: error: passing argument 2 of 'probe_kernel_read' makes pointer from integer without a cast [-Werror] ret = probe_kernel_address(regs->nip, inst); ^ Signed-off-by: Kevin Hao <haoke...@gmail.com> --- This is against linux-next. arch/powerpc/sysdev/fsl_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index ebc1f412cf49..13b9bcf5485e 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -999,7 +999,7 @@ int fsl_pci_mcheck_exception(struct pt_regs *regs) ret = get_user(regs->nip, ); pagefault_enable(); } else { - ret = probe_kernel_address(regs->nip, inst); + ret = probe_kernel_address((void *)regs->nip, inst); } if (mcheck_handle_load(regs, inst)) { -- 2.4.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v2,3/6] powerpc: kill mfvtb()
On Mon, Sep 07, 2015 at 07:29:42PM +1000, Michael Ellerman wrote: > On Mon, 2015-24-08 at 11:20:25 UTC, Kevin Hao wrote: > > This function is only used by get_vtb(). They are almost the same > > except the reading from the real register. Move the mfspr() to > > get_vtb() and kill the function mfvtb(). With this, we can eliminate > > the use of cpu_has_feature() in very core header file like reg.h. > > This is a preparation for the use of jump label for cpu_has_feature(). > > I don't mind this change. But can you elaborate a bit on the issue with using > cpu_has_feature() in reg.h? Just so I can understand the problem. > > I assume you ended up in a big mess of includes when you tried to include > jump_label.h from reg.h? Yes, the "jump_leabel.h" already include "reg.h" implicitly. from arch/powerpc/include/asm/cache.h:6:0, from include/linux/cache.h:5, from include/linux/printk.h:8, from include/linux/kernel.h:14, from include/asm-generic/bug.h:13, from arch/powerpc/include/asm/bug.h:127, from include/linux/bug.h:4, from include/linux/jump_label.h:81, So including "jump_label.h" from "reg.h" will cause a recursive header inclusion problem. Thanks, Kevin pgpzaIgfq7PY_.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 0/6] powerpc: use jump label for {cpu,mmu}_has_feature()
Hi, v2: Drop the following two patches as suggested by Ingo and Peter: jump_label: no need to acquire the jump_label_mutex in jump_lable_init() jump_label: introduce DEFINE_STATIC_KEY_{TRUE,FALSE}_ARRAY macros v1: I have tried to change the {cpu,mmu}_has_feature() to use jump label two yeas ago [1]. But that codes seem a bit ugly. This is a reimplementation by moving the jump_label_init() much earlier so the jump label can be used in a very earlier stage. Boot test on p4080ds, t2080rdb and powermac (qemu). This patch series is against linux-next. [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2013-September/111026.html Kevin Hao (6): jump_label: make it possible for the archs to invoke jump_label_init() much earlier powerpc: invoke jump_label_init() in a much earlier stage powerpc: kill mfvtb() powerpc: move the cpu_has_feature to a separate file powerpc: use the jump label for cpu_has_feature powerpc: use jump label for mmu_has_feature arch/powerpc/include/asm/cacheflush.h | 1 + arch/powerpc/include/asm/cpufeatures.h | 34 ++ arch/powerpc/include/asm/cputable.h | 16 +++--- arch/powerpc/include/asm/cputime.h | 1 + arch/powerpc/include/asm/dbell.h| 1 + arch/powerpc/include/asm/dcr-native.h | 1 + arch/powerpc/include/asm/mman.h | 1 + arch/powerpc/include/asm/mmu.h | 29 ++ arch/powerpc/include/asm/reg.h | 9 arch/powerpc/include/asm/time.h | 3 ++- arch/powerpc/include/asm/xor.h | 1 + arch/powerpc/kernel/align.c | 1 + arch/powerpc/kernel/cputable.c | 37 + arch/powerpc/kernel/irq.c | 1 + arch/powerpc/kernel/process.c | 1 + arch/powerpc/kernel/setup-common.c | 1 + arch/powerpc/kernel/setup_32.c | 5 + arch/powerpc/kernel/setup_64.c | 4 arch/powerpc/kernel/smp.c | 1 + arch/powerpc/platforms/cell/pervasive.c | 1 + arch/powerpc/xmon/ppc-dis.c | 1 + kernel/jump_label.c | 3 +++ 22 files changed, 135 insertions(+), 18 deletions(-) create mode 100644 arch/powerpc/include/asm/cpufeatures.h -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 1/6] jump_label: make it possible for the archs to invoke jump_label_init() much earlier
For some archs (such as powerpc) would want to invoke jump_label_init() in a much earlier stage. So check static_key_initialized in order to make sure this function run only once. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. kernel/jump_label.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index f7dd15d537f9..cfc7d7b65432 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -205,6 +205,9 @@ void __init jump_label_init(void) struct static_key *key = NULL; struct jump_entry *iter; + if (static_key_initialized) + return; + jump_label_lock(); jump_label_sort_entries(iter_start, iter_stop); -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 2/6] powerpc: invoke jump_label_init() in a much earlier stage
So we can use static_key for cpu_has_feature() and mmu_has_feature(). Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. arch/powerpc/kernel/setup_32.c | 2 ++ arch/powerpc/kernel/setup_64.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index bb02e9f6944e..35980a2785ba 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -113,6 +113,8 @@ notrace void __init machine_init(u64 dt_ptr) { lockdep_init(); + jump_label_init(); + /* Enable early debugging if any specified (see udbg.h) */ udbg_early_init(); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index bdcbb716f4d6..f0802a0b4a20 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -250,6 +250,8 @@ void __init early_setup(unsigned long dt_ptr) /* Initialize lockdep early or else spinlocks will blow */ lockdep_init(); + jump_label_init(); + /* printk is now safe to use --- */ /* Enable early debugging if any specified (see udbg.h) */ -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 3/6] powerpc: kill mfvtb()
This function is only used by get_vtb(). They are almost the same except the reading from the real register. Move the mfspr() to get_vtb() and kill the function mfvtb(). With this, we can eliminate the use of cpu_has_feature() in very core header file like reg.h. This is a preparation for the use of jump label for cpu_has_feature(). Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. arch/powerpc/include/asm/reg.h | 9 - arch/powerpc/include/asm/time.h | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index aa1cc5f015ee..d0b5f4b63776 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -1207,15 +1207,6 @@ : r ((unsigned long)(v)) \ : memory) -static inline unsigned long mfvtb (void) -{ -#ifdef CONFIG_PPC_BOOK3S_64 - if (cpu_has_feature(CPU_FTR_ARCH_207S)) - return mfspr(SPRN_VTB); -#endif - return 0; -} - #ifdef __powerpc64__ #if defined(CONFIG_PPC_CELL) || defined(CONFIG_PPC_FSL_BOOK3E) #define mftb() ({unsigned long rval; \ diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 10fc784a2ad4..6f69828458fb 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -106,7 +106,7 @@ static inline u64 get_vtb(void) { #ifdef CONFIG_PPC_BOOK3S_64 if (cpu_has_feature(CPU_FTR_ARCH_207S)) - return mfvtb(); + return mfspr(SPRN_VTB); #endif return 0; } -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 4/6] powerpc: move the cpu_has_feature to a separate file
We plan to use jump label for cpu_has_feature. In order to implement this we need to include the linux/jump_label.h in asm/cputable.h. But it seems that asm/cputable.h is so basic header file for ppc that it is almost included by all the other header files. The including of the linux/jump_label.h will introduces various recursive inclusion. And it is very hard to fix that. So we choose to move the function cpu_has_feature to a separate header file before using the jump label for it. No functional change. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. arch/powerpc/include/asm/cacheflush.h | 1 + arch/powerpc/include/asm/cpufeatures.h | 14 ++ arch/powerpc/include/asm/cputable.h | 8 arch/powerpc/include/asm/cputime.h | 1 + arch/powerpc/include/asm/dbell.h| 1 + arch/powerpc/include/asm/dcr-native.h | 1 + arch/powerpc/include/asm/mman.h | 1 + arch/powerpc/include/asm/time.h | 1 + arch/powerpc/include/asm/xor.h | 1 + arch/powerpc/kernel/align.c | 1 + arch/powerpc/kernel/irq.c | 1 + arch/powerpc/kernel/process.c | 1 + arch/powerpc/kernel/setup-common.c | 1 + arch/powerpc/kernel/setup_32.c | 1 + arch/powerpc/kernel/smp.c | 1 + arch/powerpc/platforms/cell/pervasive.c | 1 + arch/powerpc/xmon/ppc-dis.c | 1 + 17 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 arch/powerpc/include/asm/cpufeatures.h diff --git a/arch/powerpc/include/asm/cacheflush.h b/arch/powerpc/include/asm/cacheflush.h index 6229e6b6037b..3bdcd9231852 100644 --- a/arch/powerpc/include/asm/cacheflush.h +++ b/arch/powerpc/include/asm/cacheflush.h @@ -11,6 +11,7 @@ #include linux/mm.h #include asm/cputable.h +#include asm/cpufeatures.h /* * No cache flushing is required when address mappings are changed, diff --git a/arch/powerpc/include/asm/cpufeatures.h b/arch/powerpc/include/asm/cpufeatures.h new file mode 100644 index ..37650db5044f --- /dev/null +++ b/arch/powerpc/include/asm/cpufeatures.h @@ -0,0 +1,14 @@ +#ifndef __ASM_POWERPC_CPUFEATURES_H +#define __ASM_POWERPC_CPUFEATURES_H + +#include asm/cputable.h + +static inline int cpu_has_feature(unsigned long feature) +{ + return (CPU_FTRS_ALWAYS feature) || + (CPU_FTRS_POSSIBLE +cur_cpu_spec-cpu_features +feature); +} + +#endif /* __ASM_POWERPC_CPUFEATURE_H */ diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h index b118072670fb..ae4b6ef341cd 100644 --- a/arch/powerpc/include/asm/cputable.h +++ b/arch/powerpc/include/asm/cputable.h @@ -556,14 +556,6 @@ enum { }; #endif /* __powerpc64__ */ -static inline int cpu_has_feature(unsigned long feature) -{ - return (CPU_FTRS_ALWAYS feature) || - (CPU_FTRS_POSSIBLE -cur_cpu_spec-cpu_features -feature); -} - #define HBP_NUM 1 #endif /* !__ASSEMBLY__ */ diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h index e2452550bcb1..b91837865c0e 100644 --- a/arch/powerpc/include/asm/cputime.h +++ b/arch/powerpc/include/asm/cputime.h @@ -28,6 +28,7 @@ static inline void setup_cputime_one_jiffy(void) { } #include asm/div64.h #include asm/time.h #include asm/param.h +#include asm/cpufeatures.h typedef u64 __nocast cputime_t; typedef u64 __nocast cputime64_t; diff --git a/arch/powerpc/include/asm/dbell.h b/arch/powerpc/include/asm/dbell.h index 5fa6b20eba10..2d9eae338f70 100644 --- a/arch/powerpc/include/asm/dbell.h +++ b/arch/powerpc/include/asm/dbell.h @@ -16,6 +16,7 @@ #include linux/threads.h #include asm/ppc-opcode.h +#include asm/cpufeatures.h #define PPC_DBELL_MSG_BRDCAST (0x0400) #define PPC_DBELL_TYPE(x) (((x) 0xf) (63-36)) diff --git a/arch/powerpc/include/asm/dcr-native.h b/arch/powerpc/include/asm/dcr-native.h index 4efc11dacb98..0186ba05bfe1 100644 --- a/arch/powerpc/include/asm/dcr-native.h +++ b/arch/powerpc/include/asm/dcr-native.h @@ -24,6 +24,7 @@ #include linux/spinlock.h #include asm/cputable.h +#include asm/cpufeatures.h typedef struct { unsigned int base; diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h index 8565c254151a..74922ad05e6c 100644 --- a/arch/powerpc/include/asm/mman.h +++ b/arch/powerpc/include/asm/mman.h @@ -13,6 +13,7 @@ #include asm/cputable.h #include linux/mm.h +#include asm/cpufeatures.h /* * This file is included by linux/mman.h, so we can't use cacl_vm_prot_bits() diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 6f69828458fb..fa63005f827f 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -18,6 +18,7 @@ #include linux/percpu.h #include asm/processor.h +#include asm/cpufeatures.h /* time.c */ extern unsigned long tb_ticks_per_jiffy; diff --git a/arch/powerpc
[PATCH v2 5/6] powerpc: use the jump label for cpu_has_feature
The cpu features are fixed once the probe of cpu features are done. And the function cpu_has_feature() does be used in some hot path. The checking of the cpu features for each time of invoking of cpu_has_feature() seems suboptimal. This tries to reduce this overhead of this check by using jump label. The generated assemble code of the following c program: if (cpu_has_feature(CPU_FTR_XXX)) xxx() Before: lis r9,-16230 lwz r9,12324(r9) lwz r9,12(r9) andi. r10,r9,512 beqlr- After: nop if CPU_FTR_XXX is enabled b xxx if CPU_FTR_XXX is not enabled Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: Use the open-coded definition and initialization for cpu_feat_keys[]. arch/powerpc/include/asm/cpufeatures.h | 20 arch/powerpc/include/asm/cputable.h| 8 arch/powerpc/kernel/cputable.c | 20 arch/powerpc/kernel/setup_32.c | 1 + arch/powerpc/kernel/setup_64.c | 1 + 5 files changed, 50 insertions(+) diff --git a/arch/powerpc/include/asm/cpufeatures.h b/arch/powerpc/include/asm/cpufeatures.h index 37650db5044f..405a97fe6ef9 100644 --- a/arch/powerpc/include/asm/cpufeatures.h +++ b/arch/powerpc/include/asm/cpufeatures.h @@ -3,6 +3,25 @@ #include asm/cputable.h +#ifdef CONFIG_JUMP_LABEL +#include linux/jump_label.h + +extern struct static_key_true cpu_feat_keys[MAX_CPU_FEATURES]; + +static inline int cpu_has_feature(unsigned long feature) +{ + int i; + + if (CPU_FTRS_ALWAYS feature) + return 1; + + if (!(CPU_FTRS_POSSIBLE feature)) + return 0; + + i = __builtin_ctzl(feature); + return static_branch_likely(cpu_feat_keys[i]); +} +#else static inline int cpu_has_feature(unsigned long feature) { return (CPU_FTRS_ALWAYS feature) || @@ -10,5 +29,6 @@ static inline int cpu_has_feature(unsigned long feature) cur_cpu_spec-cpu_features feature); } +#endif #endif /* __ASM_POWERPC_CPUFEATURE_H */ diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h index ae4b6ef341cd..2ebee2894102 100644 --- a/arch/powerpc/include/asm/cputable.h +++ b/arch/powerpc/include/asm/cputable.h @@ -114,6 +114,12 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start, extern const char *powerpc_base_platform; +#ifdef CONFIG_JUMP_LABEL +extern void cpu_feat_keys_init(void); +#else +static inline void cpu_feat_keys_init(void) { } +#endif + /* TLB flush actions. Used as argument to cpu_spec.flush_tlb() hook */ enum { TLB_INVAL_SCOPE_GLOBAL = 0, /* invalidate all TLBs */ @@ -124,6 +130,8 @@ enum { /* CPU kernel features */ +#define MAX_CPU_FEATURES (8 * sizeof(((struct cpu_spec *)0)-cpu_features)) + /* Retain the 32b definitions all use bottom half of word */ #define CPU_FTR_COHERENT_ICACHEASM_CONST(0x0001) #define CPU_FTR_L2CR ASM_CONST(0x0002) diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index 7d80bfdfb15e..ea94931c5e70 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -15,6 +15,7 @@ #include linux/threads.h #include linux/init.h #include linux/export.h +#include linux/jump_label.h #include asm/oprofile_impl.h #include asm/cputable.h @@ -2195,3 +2196,22 @@ struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr) return NULL; } + +#ifdef CONFIG_JUMP_LABEL +struct static_key_true cpu_feat_keys[MAX_CPU_FEATURES] = { + [0 ... MAX_CPU_FEATURES - 1] = STATIC_KEY_TRUE_INIT +}; +EXPORT_SYMBOL_GPL(cpu_feat_keys); + +void __init cpu_feat_keys_init(void) +{ + int i; + + for (i = 0; i MAX_CPU_FEATURES; i++) { + unsigned long f = 1ul i; + + if (!(cur_cpu_spec-cpu_features f)) + static_branch_disable(cpu_feat_keys[i]); + } +} +#endif diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index f0868f510b3b..93756175a13c 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -115,6 +115,7 @@ notrace void __init machine_init(u64 dt_ptr) lockdep_init(); jump_label_init(); + cpu_feat_keys_init(); /* Enable early debugging if any specified (see udbg.h) */ udbg_early_init(); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index f0802a0b4a20..4cf3894d91fa 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -251,6 +251,7 @@ void __init early_setup(unsigned long dt_ptr) lockdep_init(); jump_label_init(); + cpu_feat_keys_init(); /* printk is now safe to use --- */ -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev
[PATCH v2 6/6] powerpc: use jump label for mmu_has_feature
The mmu features are fixed once the probe of mmu features are done. And the function mmu_has_feature() does be used in some hot path. The checking of the mmu features for each time of invoking of mmu_has_feature() seems suboptimal. This tries to reduce this overhead of this check by using jump label. The generated assemble code of the following c program: if (mmu_has_feature(MMU_FTR_XXX)) xxx() Before: lis r9,-16230 lwz r9,12324(r9) lwz r9,24(r9) andi. r10,r9,16 beqlr+ After: nop if MMU_FTR_XXX is enabled b xxx if MMU_FTR_XXX is not enabled Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: Use the open-coded definition and initialization for mmu_feat_keys[]. arch/powerpc/include/asm/mmu.h | 29 + arch/powerpc/kernel/cputable.c | 17 + arch/powerpc/kernel/setup_32.c | 1 + arch/powerpc/kernel/setup_64.c | 1 + 4 files changed, 48 insertions(+) diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index 3d5abfe6ba67..e091de352a75 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h @@ -109,6 +109,34 @@ DECLARE_PER_CPU(int, next_tlbcam_idx); #endif +#ifdef CONFIG_JUMP_LABEL +#include linux/jump_label.h + +#define MAX_MMU_FEATURES (8 * sizeof(((struct cpu_spec *)0)-mmu_features)) + +extern struct static_key_true mmu_feat_keys[MAX_MMU_FEATURES]; + +extern void mmu_feat_keys_init(void); + +static inline int mmu_has_feature(unsigned long feature) +{ + int i; + + i = __builtin_ctzl(feature); + return static_branch_likely(mmu_feat_keys[i]); +} + +static inline void mmu_clear_feature(unsigned long feature) +{ + int i; + + i = __builtin_ctzl(feature); + cur_cpu_spec-mmu_features = ~feature; + static_branch_disable(mmu_feat_keys[i]); +} +#else +static inline void mmu_feat_keys_init(void) { } + static inline int mmu_has_feature(unsigned long feature) { return (cur_cpu_spec-mmu_features feature); @@ -118,6 +146,7 @@ static inline void mmu_clear_feature(unsigned long feature) { cur_cpu_spec-mmu_features = ~feature; } +#endif extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup; diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index ea94931c5e70..6b505c98520b 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -2214,4 +2214,21 @@ void __init cpu_feat_keys_init(void) static_branch_disable(cpu_feat_keys[i]); } } + +struct static_key_true mmu_feat_keys[MAX_MMU_FEATURES] = { + [0 ... MAX_MMU_FEATURES - 1] = STATIC_KEY_TRUE_INIT +}; +EXPORT_SYMBOL_GPL(mmu_feat_keys); + +void __init mmu_feat_keys_init(void) +{ + int i; + + for (i = 0; i MAX_MMU_FEATURES; i++) { + unsigned long f = 1ul i; + + if (!(cur_cpu_spec-mmu_features f)) + static_branch_disable(mmu_feat_keys[i]); + } +} #endif diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 93756175a13c..8acff5a4bc3e 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -116,6 +116,7 @@ notrace void __init machine_init(u64 dt_ptr) jump_label_init(); cpu_feat_keys_init(); + mmu_feat_keys_init(); /* Enable early debugging if any specified (see udbg.h) */ udbg_early_init(); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 4cf3894d91fa..df6f98f1c46c 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -252,6 +252,7 @@ void __init early_setup(unsigned long dt_ptr) jump_label_init(); cpu_feat_keys_init(); + mmu_feat_keys_init(); /* printk is now safe to use --- */ -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 3/8] jump_label: introduce DEFINE_STATIC_KEY_{TRUE,FALSE}_ARRAY macros
On Fri, Aug 21, 2015 at 08:28:26AM +0200, Ingo Molnar wrote: * Kevin Hao haoke...@gmail.com wrote: These are used to define a static_key_{true,false} array. Signed-off-by: Kevin Hao haoke...@gmail.com --- include/linux/jump_label.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 7f653e8f6690..5c1d6a49dd6b 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -267,6 +267,12 @@ struct static_key_false { #define DEFINE_STATIC_KEY_FALSE(name) \ struct static_key_false name = STATIC_KEY_FALSE_INIT +#define DEFINE_STATIC_KEY_TRUE_ARRAY(name, n) \ + struct static_key_true name[n] = { [0 ... n - 1] = STATIC_KEY_TRUE_INIT } + +#define DEFINE_STATIC_KEY_FALSE_ARRAY(name, n) \ + struct static_key_false name[n] = { [0 ... n - 1] = STATIC_KEY_FALSE_INIT } I think the define makes the code more obfuscated and less clear, the open-coded initialization is pretty dense and easy to read to begin with. OK, I will drop this patch and move the initialization of the array to the corresponding patch. Thanks, Kevin pgpYG6ePRc7ly.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 3/8] jump_label: introduce DEFINE_STATIC_KEY_{TRUE,FALSE}_ARRAY macros
On Fri, Aug 21, 2015 at 08:40:59AM +0200, Ingo Molnar wrote: Please also Cc: peterz and me to the next submission of the series - static key (and jump label) changes go through the locking tree normally, and there's a number of changes pending already for v4.3: Sure. Thanks, Kevin pgpesUVc6FUqb.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 3/8] jump_label: introduce DEFINE_STATIC_KEY_{TRUE,FALSE}_ARRAY macros
On Thu, Aug 20, 2015 at 08:31:58PM +0200, Peter Zijlstra wrote: On Thu, Aug 20, 2015 at 08:14:31PM +0800, Kevin Hao wrote: These are used to define a static_key_{true,false} array. Yes but why... there might have been some clue in the patches you didn't send me, but since you didn't send them, I'm left wondering. Sorry for the confusion. In order to use jump label for the {cpu,mmu}_has_feature() functions on powerpc, we need to declare an array of 32 or 64 static_key_true (one static_key_true for each cpu or mmu feature). The following are the two patches which depends on this patch. https://lkml.org/lkml/2015/8/20/355 https://lkml.org/lkml/2015/8/20/356 So far only DEFINE_STATIC_KEY_TRUE_ARRAY macro is used, but I think it may seem canonical to define the macros for both true or false keys at the same time. Thanks, Kevin pgpTPsr0bvVrm.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 3/8] jump_label: introduce DEFINE_STATIC_KEY_{TRUE, FALSE}_ARRAY macros
These are used to define a static_key_{true,false} array. Signed-off-by: Kevin Hao haoke...@gmail.com --- include/linux/jump_label.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 7f653e8f6690..5c1d6a49dd6b 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -267,6 +267,12 @@ struct static_key_false { #define DEFINE_STATIC_KEY_FALSE(name) \ struct static_key_false name = STATIC_KEY_FALSE_INIT +#define DEFINE_STATIC_KEY_TRUE_ARRAY(name, n) \ + struct static_key_true name[n] = { [0 ... n - 1] = STATIC_KEY_TRUE_INIT } + +#define DEFINE_STATIC_KEY_FALSE_ARRAY(name, n) \ + struct static_key_false name[n] = { [0 ... n - 1] = STATIC_KEY_FALSE_INIT } + #ifdef HAVE_JUMP_LABEL /* -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 8/8] powerpc: use jump label for mmu_has_feature
The mmu features are fixed once the probe of mmu features are done. And the function mmu_has_feature() does be used in some hot path. The checking of the mmu features for each time of invoking of mmu_has_feature() seems suboptimal. This tries to reduce this overhead of this check by using jump label. The generated assemble code of the following c program: if (mmu_has_feature(MMU_FTR_XXX)) xxx() Before: lis r9,-16230 lwz r9,12324(r9) lwz r9,24(r9) andi. r10,r9,16 beqlr+ After: nop if MMU_FTR_XXX is enabled b xxx if MMU_FTR_XXX is not enabled Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/include/asm/mmu.h | 29 + arch/powerpc/kernel/cputable.c | 15 +++ arch/powerpc/kernel/setup_32.c | 1 + arch/powerpc/kernel/setup_64.c | 1 + 4 files changed, 46 insertions(+) diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index 3d5abfe6ba67..e091de352a75 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h @@ -109,6 +109,34 @@ DECLARE_PER_CPU(int, next_tlbcam_idx); #endif +#ifdef CONFIG_JUMP_LABEL +#include linux/jump_label.h + +#define MAX_MMU_FEATURES (8 * sizeof(((struct cpu_spec *)0)-mmu_features)) + +extern struct static_key_true mmu_feat_keys[MAX_MMU_FEATURES]; + +extern void mmu_feat_keys_init(void); + +static inline int mmu_has_feature(unsigned long feature) +{ + int i; + + i = __builtin_ctzl(feature); + return static_branch_likely(mmu_feat_keys[i]); +} + +static inline void mmu_clear_feature(unsigned long feature) +{ + int i; + + i = __builtin_ctzl(feature); + cur_cpu_spec-mmu_features = ~feature; + static_branch_disable(mmu_feat_keys[i]); +} +#else +static inline void mmu_feat_keys_init(void) { } + static inline int mmu_has_feature(unsigned long feature) { return (cur_cpu_spec-mmu_features feature); @@ -118,6 +146,7 @@ static inline void mmu_clear_feature(unsigned long feature) { cur_cpu_spec-mmu_features = ~feature; } +#endif extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup; diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index 7d4fe69a61ed..18a843f139c3 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -2212,4 +2212,19 @@ void __init cpu_feat_keys_init(void) static_branch_disable(cpu_feat_keys[i]); } } + +DEFINE_STATIC_KEY_TRUE_ARRAY(mmu_feat_keys, MAX_MMU_FEATURES); +EXPORT_SYMBOL_GPL(mmu_feat_keys); + +void __init mmu_feat_keys_init(void) +{ + int i; + + for (i = 0; i MAX_MMU_FEATURES; i++) { + unsigned long f = 1ul i; + + if (!(cur_cpu_spec-mmu_features f)) + static_branch_disable(mmu_feat_keys[i]); + } +} #endif diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 93756175a13c..8acff5a4bc3e 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -116,6 +116,7 @@ notrace void __init machine_init(u64 dt_ptr) jump_label_init(); cpu_feat_keys_init(); + mmu_feat_keys_init(); /* Enable early debugging if any specified (see udbg.h) */ udbg_early_init(); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 4cf3894d91fa..df6f98f1c46c 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -252,6 +252,7 @@ void __init early_setup(unsigned long dt_ptr) jump_label_init(); cpu_feat_keys_init(); + mmu_feat_keys_init(); /* printk is now safe to use --- */ -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 7/8] powerpc: use the jump label for cpu_has_feature
The cpu features are fixed once the probe of cpu features are done. And the function cpu_has_feature() does be used in some hot path. The checking of the cpu features for each time of invoking of cpu_has_feature() seems suboptimal. This tries to reduce this overhead of this check by using jump label. The generated assemble code of the following c program: if (cpu_has_feature(CPU_FTR_XXX)) xxx() Before: lis r9,-16230 lwz r9,12324(r9) lwz r9,12(r9) andi. r10,r9,512 beqlr- After: nop if CPU_FTR_XXX is enabled b xxx if CPU_FTR_XXX is not enabled Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/include/asm/cpufeatures.h | 20 arch/powerpc/include/asm/cputable.h| 8 arch/powerpc/kernel/cputable.c | 18 ++ arch/powerpc/kernel/setup_32.c | 1 + arch/powerpc/kernel/setup_64.c | 1 + 5 files changed, 48 insertions(+) diff --git a/arch/powerpc/include/asm/cpufeatures.h b/arch/powerpc/include/asm/cpufeatures.h index 37650db5044f..405a97fe6ef9 100644 --- a/arch/powerpc/include/asm/cpufeatures.h +++ b/arch/powerpc/include/asm/cpufeatures.h @@ -3,6 +3,25 @@ #include asm/cputable.h +#ifdef CONFIG_JUMP_LABEL +#include linux/jump_label.h + +extern struct static_key_true cpu_feat_keys[MAX_CPU_FEATURES]; + +static inline int cpu_has_feature(unsigned long feature) +{ + int i; + + if (CPU_FTRS_ALWAYS feature) + return 1; + + if (!(CPU_FTRS_POSSIBLE feature)) + return 0; + + i = __builtin_ctzl(feature); + return static_branch_likely(cpu_feat_keys[i]); +} +#else static inline int cpu_has_feature(unsigned long feature) { return (CPU_FTRS_ALWAYS feature) || @@ -10,5 +29,6 @@ static inline int cpu_has_feature(unsigned long feature) cur_cpu_spec-cpu_features feature); } +#endif #endif /* __ASM_POWERPC_CPUFEATURE_H */ diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h index ae4b6ef341cd..2ebee2894102 100644 --- a/arch/powerpc/include/asm/cputable.h +++ b/arch/powerpc/include/asm/cputable.h @@ -114,6 +114,12 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start, extern const char *powerpc_base_platform; +#ifdef CONFIG_JUMP_LABEL +extern void cpu_feat_keys_init(void); +#else +static inline void cpu_feat_keys_init(void) { } +#endif + /* TLB flush actions. Used as argument to cpu_spec.flush_tlb() hook */ enum { TLB_INVAL_SCOPE_GLOBAL = 0, /* invalidate all TLBs */ @@ -124,6 +130,8 @@ enum { /* CPU kernel features */ +#define MAX_CPU_FEATURES (8 * sizeof(((struct cpu_spec *)0)-cpu_features)) + /* Retain the 32b definitions all use bottom half of word */ #define CPU_FTR_COHERENT_ICACHEASM_CONST(0x0001) #define CPU_FTR_L2CR ASM_CONST(0x0002) diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index 7d80bfdfb15e..7d4fe69a61ed 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -15,6 +15,7 @@ #include linux/threads.h #include linux/init.h #include linux/export.h +#include linux/jump_label.h #include asm/oprofile_impl.h #include asm/cputable.h @@ -2195,3 +2196,20 @@ struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr) return NULL; } + +#ifdef CONFIG_JUMP_LABEL +DEFINE_STATIC_KEY_TRUE_ARRAY(cpu_feat_keys, MAX_CPU_FEATURES); +EXPORT_SYMBOL_GPL(cpu_feat_keys); + +void __init cpu_feat_keys_init(void) +{ + int i; + + for (i = 0; i MAX_CPU_FEATURES; i++) { + unsigned long f = 1ul i; + + if (!(cur_cpu_spec-cpu_features f)) + static_branch_disable(cpu_feat_keys[i]); + } +} +#endif diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index f0868f510b3b..93756175a13c 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -115,6 +115,7 @@ notrace void __init machine_init(u64 dt_ptr) lockdep_init(); jump_label_init(); + cpu_feat_keys_init(); /* Enable early debugging if any specified (see udbg.h) */ udbg_early_init(); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index f0802a0b4a20..4cf3894d91fa 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -251,6 +251,7 @@ void __init early_setup(unsigned long dt_ptr) lockdep_init(); jump_label_init(); + cpu_feat_keys_init(); /* printk is now safe to use --- */ -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 0/8] powerpc: use jump label for {cpu,mmu}_has_feature()
Hi, I have tried to change the {cpu,mmu}_has_feature() to use jump label two yeas ago [1]. But that codes seem a bit ugly. This is a reimplementation by moving the jump_label_init() much earlier so the jump label can be used in a very earlier stage. Boot test on p4080ds, t2080rdb and powermac (qemu). This patch series is against linux-next. [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2013-September/111026.html Kevin Hao (8): jump_label: no need to acquire the jump_label_mutex in jump_lable_init() jump_label: make it possible for the archs to invoke jump_label_init() much earlier jump_label: introduce DEFINE_STATIC_KEY_{TRUE,FALSE}_ARRAY macros powerpc: invoke jump_label_init() in a much earlier stage powerpc: kill mfvtb() powerpc: move the cpu_has_feature to a separate file powerpc: use the jump label for cpu_has_feature powerpc: use jump label for mmu_has_feature arch/powerpc/include/asm/cacheflush.h | 1 + arch/powerpc/include/asm/cpufeatures.h | 34 + arch/powerpc/include/asm/cputable.h | 16 arch/powerpc/include/asm/cputime.h | 1 + arch/powerpc/include/asm/dbell.h| 1 + arch/powerpc/include/asm/dcr-native.h | 1 + arch/powerpc/include/asm/mman.h | 1 + arch/powerpc/include/asm/mmu.h | 29 arch/powerpc/include/asm/reg.h | 9 - arch/powerpc/include/asm/time.h | 3 ++- arch/powerpc/include/asm/xor.h | 1 + arch/powerpc/kernel/align.c | 1 + arch/powerpc/kernel/cputable.c | 33 arch/powerpc/kernel/irq.c | 1 + arch/powerpc/kernel/process.c | 1 + arch/powerpc/kernel/setup-common.c | 1 + arch/powerpc/kernel/setup_32.c | 5 + arch/powerpc/kernel/setup_64.c | 4 arch/powerpc/kernel/smp.c | 1 + arch/powerpc/platforms/cell/pervasive.c | 1 + arch/powerpc/xmon/ppc-dis.c | 1 + include/linux/jump_label.h | 6 ++ kernel/jump_label.c | 5 +++-- 23 files changed, 137 insertions(+), 20 deletions(-) create mode 100644 arch/powerpc/include/asm/cpufeatures.h -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 1/8] jump_label: no need to acquire the jump_label_mutex in jump_lable_init()
The jump_label_init() run in a very early stage, even before the sched_init(). So there is no chance for concurrent access of the jump label table. Signed-off-by: Kevin Hao haoke...@gmail.com --- kernel/jump_label.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index f7dd15d537f9..df1a7fbe7cd5 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -205,7 +205,6 @@ void __init jump_label_init(void) struct static_key *key = NULL; struct jump_entry *iter; - jump_label_lock(); jump_label_sort_entries(iter_start, iter_stop); for (iter = iter_start; iter iter_stop; iter++) { @@ -229,7 +228,6 @@ void __init jump_label_init(void) #endif } static_key_initialized = true; - jump_label_unlock(); } #ifdef CONFIG_MODULES -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 5/8] powerpc: kill mfvtb()
This function is only used by get_vtb(). They are almost the same except the reading from the real register. Move the mfspr() to get_vtb() and kill the function mfvtb(). With this, we can eliminate the use of cpu_has_feature() in very core header file like reg.h. This is a preparation for the use of jump label for cpu_has_feature(). Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/include/asm/reg.h | 9 - arch/powerpc/include/asm/time.h | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index aa1cc5f015ee..d0b5f4b63776 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -1207,15 +1207,6 @@ : r ((unsigned long)(v)) \ : memory) -static inline unsigned long mfvtb (void) -{ -#ifdef CONFIG_PPC_BOOK3S_64 - if (cpu_has_feature(CPU_FTR_ARCH_207S)) - return mfspr(SPRN_VTB); -#endif - return 0; -} - #ifdef __powerpc64__ #if defined(CONFIG_PPC_CELL) || defined(CONFIG_PPC_FSL_BOOK3E) #define mftb() ({unsigned long rval; \ diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 10fc784a2ad4..6f69828458fb 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -106,7 +106,7 @@ static inline u64 get_vtb(void) { #ifdef CONFIG_PPC_BOOK3S_64 if (cpu_has_feature(CPU_FTR_ARCH_207S)) - return mfvtb(); + return mfspr(SPRN_VTB); #endif return 0; } -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 2/8] jump_label: make it possible for the archs to invoke jump_label_init() much earlier
For some archs (such as powerpc) would want to invoke jump_label_init() in a much earlier stage. So check static_key_initialized in order to make sure this function run only once. Signed-off-by: Kevin Hao haoke...@gmail.com --- kernel/jump_label.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index df1a7fbe7cd5..fcae370f8794 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -205,6 +205,9 @@ void __init jump_label_init(void) struct static_key *key = NULL; struct jump_entry *iter; + if (static_key_initialized) + return; + jump_label_sort_entries(iter_start, iter_stop); for (iter = iter_start; iter iter_stop; iter++) { -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 4/8] powerpc: invoke jump_label_init() in a much earlier stage
So we can use static_key for cpu_has_feature() and mmu_has_feature(). Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/kernel/setup_32.c | 2 ++ arch/powerpc/kernel/setup_64.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index bb02e9f6944e..35980a2785ba 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -113,6 +113,8 @@ notrace void __init machine_init(u64 dt_ptr) { lockdep_init(); + jump_label_init(); + /* Enable early debugging if any specified (see udbg.h) */ udbg_early_init(); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index bdcbb716f4d6..f0802a0b4a20 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -250,6 +250,8 @@ void __init early_setup(unsigned long dt_ptr) /* Initialize lockdep early or else spinlocks will blow */ lockdep_init(); + jump_label_init(); + /* printk is now safe to use --- */ /* Enable early debugging if any specified (see udbg.h) */ -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 6/8] powerpc: move the cpu_has_feature to a separate file
We plan to use jump label for cpu_has_feature. In order to implement this we need to include the linux/jump_label.h in asm/cputable.h. But it seems that asm/cputable.h is so basic header file for ppc that it is almost included by all the other header files. The including of the linux/jump_label.h will introduces various recursive inclusion. And it is very hard to fix that. So we choose to move the function cpu_has_feature to a separate header file before using the jump label for it. No functional change. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/include/asm/cacheflush.h | 1 + arch/powerpc/include/asm/cpufeatures.h | 14 ++ arch/powerpc/include/asm/cputable.h | 8 arch/powerpc/include/asm/cputime.h | 1 + arch/powerpc/include/asm/dbell.h| 1 + arch/powerpc/include/asm/dcr-native.h | 1 + arch/powerpc/include/asm/mman.h | 1 + arch/powerpc/include/asm/time.h | 1 + arch/powerpc/include/asm/xor.h | 1 + arch/powerpc/kernel/align.c | 1 + arch/powerpc/kernel/irq.c | 1 + arch/powerpc/kernel/process.c | 1 + arch/powerpc/kernel/setup-common.c | 1 + arch/powerpc/kernel/setup_32.c | 1 + arch/powerpc/kernel/smp.c | 1 + arch/powerpc/platforms/cell/pervasive.c | 1 + arch/powerpc/xmon/ppc-dis.c | 1 + 17 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 arch/powerpc/include/asm/cpufeatures.h diff --git a/arch/powerpc/include/asm/cacheflush.h b/arch/powerpc/include/asm/cacheflush.h index 6229e6b6037b..3bdcd9231852 100644 --- a/arch/powerpc/include/asm/cacheflush.h +++ b/arch/powerpc/include/asm/cacheflush.h @@ -11,6 +11,7 @@ #include linux/mm.h #include asm/cputable.h +#include asm/cpufeatures.h /* * No cache flushing is required when address mappings are changed, diff --git a/arch/powerpc/include/asm/cpufeatures.h b/arch/powerpc/include/asm/cpufeatures.h new file mode 100644 index ..37650db5044f --- /dev/null +++ b/arch/powerpc/include/asm/cpufeatures.h @@ -0,0 +1,14 @@ +#ifndef __ASM_POWERPC_CPUFEATURES_H +#define __ASM_POWERPC_CPUFEATURES_H + +#include asm/cputable.h + +static inline int cpu_has_feature(unsigned long feature) +{ + return (CPU_FTRS_ALWAYS feature) || + (CPU_FTRS_POSSIBLE +cur_cpu_spec-cpu_features +feature); +} + +#endif /* __ASM_POWERPC_CPUFEATURE_H */ diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h index b118072670fb..ae4b6ef341cd 100644 --- a/arch/powerpc/include/asm/cputable.h +++ b/arch/powerpc/include/asm/cputable.h @@ -556,14 +556,6 @@ enum { }; #endif /* __powerpc64__ */ -static inline int cpu_has_feature(unsigned long feature) -{ - return (CPU_FTRS_ALWAYS feature) || - (CPU_FTRS_POSSIBLE -cur_cpu_spec-cpu_features -feature); -} - #define HBP_NUM 1 #endif /* !__ASSEMBLY__ */ diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h index e2452550bcb1..b91837865c0e 100644 --- a/arch/powerpc/include/asm/cputime.h +++ b/arch/powerpc/include/asm/cputime.h @@ -28,6 +28,7 @@ static inline void setup_cputime_one_jiffy(void) { } #include asm/div64.h #include asm/time.h #include asm/param.h +#include asm/cpufeatures.h typedef u64 __nocast cputime_t; typedef u64 __nocast cputime64_t; diff --git a/arch/powerpc/include/asm/dbell.h b/arch/powerpc/include/asm/dbell.h index 5fa6b20eba10..2d9eae338f70 100644 --- a/arch/powerpc/include/asm/dbell.h +++ b/arch/powerpc/include/asm/dbell.h @@ -16,6 +16,7 @@ #include linux/threads.h #include asm/ppc-opcode.h +#include asm/cpufeatures.h #define PPC_DBELL_MSG_BRDCAST (0x0400) #define PPC_DBELL_TYPE(x) (((x) 0xf) (63-36)) diff --git a/arch/powerpc/include/asm/dcr-native.h b/arch/powerpc/include/asm/dcr-native.h index 4efc11dacb98..0186ba05bfe1 100644 --- a/arch/powerpc/include/asm/dcr-native.h +++ b/arch/powerpc/include/asm/dcr-native.h @@ -24,6 +24,7 @@ #include linux/spinlock.h #include asm/cputable.h +#include asm/cpufeatures.h typedef struct { unsigned int base; diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h index 8565c254151a..74922ad05e6c 100644 --- a/arch/powerpc/include/asm/mman.h +++ b/arch/powerpc/include/asm/mman.h @@ -13,6 +13,7 @@ #include asm/cputable.h #include linux/mm.h +#include asm/cpufeatures.h /* * This file is included by linux/mman.h, so we can't use cacl_vm_prot_bits() diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h index 6f69828458fb..fa63005f827f 100644 --- a/arch/powerpc/include/asm/time.h +++ b/arch/powerpc/include/asm/time.h @@ -18,6 +18,7 @@ #include linux/percpu.h #include asm/processor.h +#include asm/cpufeatures.h /* time.c */ extern unsigned long tb_ticks_per_jiffy; diff --git a/arch/powerpc/include/asm/xor.h b
Re: [PATCH 1/8] jump_label: no need to acquire the jump_label_mutex in jump_lable_init()
On Thu, Aug 20, 2015 at 08:29:03PM +0200, Peter Zijlstra wrote: On Thu, Aug 20, 2015 at 08:14:29PM +0800, Kevin Hao wrote: The jump_label_init() run in a very early stage, even before the sched_init(). So there is no chance for concurrent access of the jump label table. It also doesn't hurt to have it. Its better to be consistent and conservative with locking unless there is a pressing need. Yes, it has no real hurt. IMHO it may cause confusion that the function jump_label_init() may run in two different thread context simultaneously. Anyway if you guys don't think so, I can drop this patch. Thanks, Kevin pgpM0m7ashQJz.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2] powerpc/e6500: hw tablewalk: make sure we invalidate and write to the same tlb entry
In order to workaround Erratum A-008139, we have to invalidate the tlb entry with tlbilx before overwriting. Due to the performance consideration, we don't add any memory barrier when acquire/release the tcd lock. This means the two load instructions for esel_next do have the possibility to return different value. This is definitely not acceptable due to the Erratum A-008139. We have two options to fix this issue: a) Add memory barrier when acquire/release tcd lock to order the load/store to esel_next. b) Just make sure to invalidate and write to the same tlb entry and tolerate the race that we may get the wrong value and overwrite the tlb entry just updated by the other thread. We observe better performance using option b. So reserve an additional register to save the value of the esel_next. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: Use an additional register for saving the value of esel_next instead of lwsync. arch/powerpc/include/asm/exception-64e.h | 11 ++- arch/powerpc/mm/tlb_low_64e.S| 26 ++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/include/asm/exception-64e.h b/arch/powerpc/include/asm/exception-64e.h index a8b52b61043f..d53575becbed 100644 --- a/arch/powerpc/include/asm/exception-64e.h +++ b/arch/powerpc/include/asm/exception-64e.h @@ -69,13 +69,14 @@ #define EX_TLB_ESR ( 9 * 8) /* Level 0 and 2 only */ #define EX_TLB_SRR0(10 * 8) #define EX_TLB_SRR1(11 * 8) +#define EX_TLB_R7 (12 * 8) #ifdef CONFIG_BOOK3E_MMU_TLB_STATS -#define EX_TLB_R8 (12 * 8) -#define EX_TLB_R9 (13 * 8) -#define EX_TLB_LR (14 * 8) -#define EX_TLB_SIZE(15 * 8) +#define EX_TLB_R8 (13 * 8) +#define EX_TLB_R9 (14 * 8) +#define EX_TLB_LR (15 * 8) +#define EX_TLB_SIZE(16 * 8) #else -#define EX_TLB_SIZE(12 * 8) +#define EX_TLB_SIZE(13 * 8) #endif #defineSTART_EXCEPTION(label) \ diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S index e4185581c5a7..3a5b89dfb5a1 100644 --- a/arch/powerpc/mm/tlb_low_64e.S +++ b/arch/powerpc/mm/tlb_low_64e.S @@ -68,11 +68,21 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) ld r14,PACAPGD(r13) std r15,EX_TLB_R15(r12) std r10,EX_TLB_CR(r12) +#ifdef CONFIG_PPC_FSL_BOOK3E +BEGIN_FTR_SECTION + std r7,EX_TLB_R7(r12) +END_FTR_SECTION_IFSET(CPU_FTR_SMT) +#endif TLB_MISS_PROLOG_STATS .endm .macro tlb_epilog_bolted ld r14,EX_TLB_CR(r12) +#ifdef CONFIG_PPC_FSL_BOOK3E +BEGIN_FTR_SECTION + ld r7,EX_TLB_R7(r12) +END_FTR_SECTION_IFSET(CPU_FTR_SMT) +#endif ld r10,EX_TLB_R10(r12) ld r11,EX_TLB_R11(r12) ld r13,EX_TLB_R13(r12) @@ -297,6 +307,7 @@ itlb_miss_fault_bolted: * r13 = PACA * r11 = tlb_per_core ptr * r10 = crap (free to use) + * r7 = esel_next */ tlb_miss_common_e6500: crmove cr2*4+2,cr0*4+2 /* cr2.eq != 0 if kernel address */ @@ -334,8 +345,8 @@ BEGIN_FTR_SECTION /* CPU_FTR_SMT */ * with tlbilx before overwriting. */ - lbz r15,TCD_ESEL_NEXT(r11) - rlwinm r10,r15,16,0xff + lbz r7,TCD_ESEL_NEXT(r11) + rlwinm r10,r7,16,0xff orisr10,r10,MAS0_TLBSEL(1)@h mtspr SPRN_MAS0,r10 isync @@ -429,15 +440,14 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_SMT) mtspr SPRN_MAS2,r15 tlb_miss_huge_done_e6500: - lbz r15,TCD_ESEL_NEXT(r11) lbz r16,TCD_ESEL_MAX(r11) lbz r14,TCD_ESEL_FIRST(r11) - rlwimi r10,r15,16,0x00ff /* insert esel_next into MAS0 */ - addir15,r15,1 /* increment esel_next */ + rlwimi r10,r7,16,0x00ff/* insert esel_next into MAS0 */ + addir7,r7,1 /* increment esel_next */ mtspr SPRN_MAS0,r10 - cmpwr15,r16 - iseleq r15,r14,r15 /* if next == last use first */ - stb r15,TCD_ESEL_NEXT(r11) + cmpwr7,r16 + iseleq r7,r14,r7 /* if next == last use first */ + stb r7,TCD_ESEL_NEXT(r11) tlbwe -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/3] powerpc/e6500: hw tablewalk: optimize a bit for tcd lock acquiring codes
On Fri, Aug 14, 2015 at 09:44:28PM -0500, Scott Wood wrote: I tried a couple different benchmarks and didn't find a significant difference, relative to the variability of the results running on the same kernel. A patch that claims to optimize a bit as its main purpose ought to show some results. :-) I tried to compare the execution time of these two code sequences with the following test module: #include linux/module.h #include linux/kernel.h #include linux/printk.h static void test1(void) { int i; unsigned char lock, c; unsigned short cpu, s; for (i = 0; i 10; i++) { lock = 0; cpu = 1; asm volatile ( 1: lbarx %0,0,%2\n\ lhz %1,0(%3)\n\ cmpdi %0,0\n\ cmpdi cr1,%1,1\n\ addi%1,%1,1\n\ bne 2f\n\ stbcx. %1,0,%2\n\ bne 1b\n\ 2: : =r (c), =r (s) : r (lock), r (cpu) : cr0, cr1, memory); } } static void test2(void) { int i; unsigned char lock, c; unsigned short cpu, s; for (i = 0; i 10; i++) { lock = 0; cpu = 1; asm volatile ( lhz %1,0(%3)\n\ addi%1,%1,1\n\ crclr cr1*4+eq\n\ 1: lbarx %0,0,%2\n\ cmpdi %0,0\n\ bne 2f\n\ stbcx. %1,0,%2\n\ bne 1b\n\ 2: : =r (c), =r (s) : r (lock), r (cpu) : cr0, cr1, memory); } } static int test_init(void) { unsigned long s, e, tm1, tm2; __hard_irq_disable(); /* Just for prefetch */ test1(); s = mftb(); test1(); e = mftb(); tm1 = e - s; /* Just for prefetch */ test2(); s = mftb(); test2(); e = mftb(); tm2 = e - s; __hard_irq_enable(); pr_err(test1: %ld, test2: %ld, %%%ld\n, tm1, tm2, (tm1 - tm2) * 100 / tm1); return 0; } static void test_exit(void) { return; } module_init(test_init); module_exit(test_exit); MODULE_LICENSE(GPL); The results: test1: 156568, test2: 151675, %3 test1: 156604, test2: 151670, %3 test1: 156567, test2: 151684, %3 test1: 156567, test2: 151678, %3 test1: 156567, test2: 151688, %3 test1: 156570, test2: 151683, %3 test1: 156565, test2: 151675, %3 test1: 156565, test2: 151673, %3 It seems that there do have a %3 gain in performance by moving the 3 instructions out of lbarx/stbcx loop. Thanks, Kevin pgpS6_d8tw8Wv.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 3/3] powerpc/e6500: hw tablewalk: order the memory access when acquire/release tcd lock
On Fri, Aug 14, 2015 at 07:44:23PM -0500, Scott Wood wrote: On Fri, 2015-08-14 at 15:13 +0800, Kevin Hao wrote: On Thu, Aug 13, 2015 at 10:39:19PM -0500, Scott Wood wrote: On Thu, 2015-08-13 at 19:51 +0800, Kevin Hao wrote: I didn't find anything unusual. But I think we do need to order the load/store of esel_next when acquire/release tcd lock. For acquire, add a data dependency to order the loads of lock and esel_next. For release, even there already have a isync here, but it doesn't guarantee any memory access order. So we still need lwsync for the two stores for lock and esel_next. I was going to say that esel_next is just a hint and it doesn't really matter if we occasionally get the wrong value, unless it happens often enough to cause more performance degradation than the lwsync causes. However, with the A-008139 workaround we do need to read the same value from esel_next both times. It might be less costly to save/restore an additional register instead of lwsync, though. I will try to get some benchmark number to compare which method is a bit better. Do you have any recommended benchmark for a case this is? lmbench lat_mem_rd with a stride chosen to maximize TLB misses. For the uncontended case, one instance; for the contended case, two instances, one pinned to each thread of a core. I have tried the method to save/restore an additional register for the esel with the following codes: diff --git a/arch/powerpc/include/asm/exception-64e.h b/arch/powerpc/include/asm/exception-64e.h index a8b52b61043f..8267c1404050 100644 --- a/arch/powerpc/include/asm/exception-64e.h +++ b/arch/powerpc/include/asm/exception-64e.h @@ -69,9 +69,9 @@ #define EX_TLB_ESR ( 9 * 8) /* Level 0 and 2 only */ #define EX_TLB_SRR0(10 * 8) #define EX_TLB_SRR1(11 * 8) +#define EX_TLB_R9 (12 * 8) #ifdef CONFIG_BOOK3E_MMU_TLB_STATS -#define EX_TLB_R8 (12 * 8) -#define EX_TLB_R9 (13 * 8) +#define EX_TLB_R8 (13 * 8) #define EX_TLB_LR (14 * 8) #define EX_TLB_SIZE(15 * 8) #else diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S index e4185581c5a7..8d184dd530c4 100644 --- a/arch/powerpc/mm/tlb_low_64e.S +++ b/arch/powerpc/mm/tlb_low_64e.S @@ -68,11 +68,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) ld r14,PACAPGD(r13) std r15,EX_TLB_R15(r12) std r10,EX_TLB_CR(r12) + std r9,EX_TLB_R9(r12) TLB_MISS_PROLOG_STATS .endm .macro tlb_epilog_bolted ld r14,EX_TLB_CR(r12) + ld r9,EX_TLB_R9(r12) ld r10,EX_TLB_R10(r12) ld r11,EX_TLB_R11(r12) ld r13,EX_TLB_R13(r12) @@ -297,6 +299,7 @@ itlb_miss_fault_bolted: * r13 = PACA * r11 = tlb_per_core ptr * r10 = crap (free to use) + * r9 = esel entry */ tlb_miss_common_e6500: crmove cr2*4+2,cr0*4+2 /* cr2.eq != 0 if kernel address */ @@ -334,8 +337,8 @@ BEGIN_FTR_SECTION /* CPU_FTR_SMT */ * with tlbilx before overwriting. */ - lbz r15,TCD_ESEL_NEXT(r11) - rlwinm r10,r15,16,0xff + lbz r9,TCD_ESEL_NEXT(r11) + rlwinm r10,r9,16,0xff orisr10,r10,MAS0_TLBSEL(1)@h mtspr SPRN_MAS0,r10 isync @@ -429,15 +432,14 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_SMT) mtspr SPRN_MAS2,r15 tlb_miss_huge_done_e6500: - lbz r15,TCD_ESEL_NEXT(r11) lbz r16,TCD_ESEL_MAX(r11) lbz r14,TCD_ESEL_FIRST(r11) - rlwimi r10,r15,16,0x00ff /* insert esel_next into MAS0 */ - addir15,r15,1 /* increment esel_next */ + rlwimi r10,r9,16,0x00ff/* insert esel_next into MAS0 */ + addir9,r9,1 /* increment esel_next */ mtspr SPRN_MAS0,r10 - cmpwr15,r16 - iseleq r15,r14,r15 /* if next == last use first */ - stb r15,TCD_ESEL_NEXT(r11) + cmpwr9,r16 + iseleq r9,r14,r9 /* if next == last use first */ + stb r9,TCD_ESEL_NEXT(r11) tlbwe The following is the benchmark number on a t2080rdb board: For uncontended case (taskset -c 0 lat_mem_rd 2048 2097152): origin lwsync r9 2.0 1.958 1.958 1.958 3.0 1.958 1.958 1.958 4.0 1.958 1.958 1.958 6.0 1.958 1.958 1.958 8.0 1.958 1.958 1.958 12.06.528 6.528 6.528 16.06.528 6.528 6.528 24.037.862 37.862 37.861 32.037.862 37.862 37.862 48.037.862 37.862 37.862 64.037.862 37.862 37.862 96.037.862 37.863 37.862 128.0
Re: [PATCH 2/3] powerpc/e6500: hw tablewalk: optimize a bit for tcd lock acquiring codes
On Thu, Aug 13, 2015 at 01:44:43PM -0500, Scott Wood wrote: On Thu, 2015-08-13 at 19:51 +0800, Kevin Hao wrote: It makes no sense to put the instructions for calculating the lock value (cpu number + 1) and the clearing of eq bit of cr1 in lbarx/stbcx loop. And when the lock is acquired by the other thread, the current lock value has no chance to equal with the lock value used by current cpu. So we can skip the comparing for these two lock values in the lbz/bne loop. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/mm/tlb_low_64e.S | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S index 765b419883f2..e4185581c5a7 100644 --- a/arch/powerpc/mm/tlb_low_64e.S +++ b/arch/powerpc/mm/tlb_low_64e.S @@ -308,11 +308,11 @@ BEGIN_FTR_SECTION /* CPU_FTR_SMT */ * * MAS6:IND should be already set based on MAS4 */ -1: lbarx r15,0,r11 lhz r10,PACAPACAINDEX(r13) - cmpdi r15,0 - cmpdi cr1,r15,1 /* set cr1.eq = 0 for non-recursive */ addir10,r10,1 + crclr cr1*4+eq/* set cr1.eq = 0 for non-recursive */ +1: lbarx r15,0,r11 + cmpdi r15,0 bne 2f You're optimizing the contended case at the expense of introducing stalls in the uncontended case. Before the patch, the uncontended case code sequence are: 1: lbarx r15,0,r11 lhz r10,PACAPACAINDEX(r13) cmpdi r15,0 cmpdi cr1,r15,1 /* set cr1.eq = 0 for non-recursive */ addir10,r10,1 bne 2f stbcx. r10,0,r11 bne 1b After the patch: lhz r10,PACAPACAINDEX(r13) addir10,r10,1 crclr cr1*4+eq/* set cr1.eq = 0 for non-recursive */ 1: lbarx r15,0,r11 cmpdi r15,0 bne 2f stbcx. r10,0,r11 bne 1b As you know, the lbarx is a Presync instruction and stbcx is a Presync and Postsync instruction. Putting the unnecessary instructions in the lbarx/stbcx loop also serialize these instructions execution. The execution latency of lbarx is only 3 cycles and there are still two instructions after it. Considering the out of order execution optimization after this patch, do you really think that new uncontended path will become slower due to this additional stall? Does it really matter if there are more instructions in the loop? I really think we should minimize the window of lbarx/stbcx, for following two reasons: - The bigger of this window, the more possible conflicts between the two threads run into this loop simultaneously. - The reservation used by lbarx may be cleared by another thread due to store to the same reservation granule. The smaller the window of lbarx/stbcx, the less possibility to be affected by this. This change just means that you'll spin in the loop for more iterations (if it even does that -- I think the cycles per loop iteration might be the same before and after, due to load latency and pairing) while waiting for the other thread to release the lock. Besides the optimization for the contended case, it also make the code more readable with these changes: - It always seem a bit weird to calculate the lock value for the current cpu in the lbarx/stbcx loop. - The cmpdi cr1,r15,1 seems pretty confusion. It doesn't always do what the comment said (set cr1.eq = 0). In some cases, it does set the crq.eq = 1, such as when running on cpu 1 with lock is acquired by cpu0. All we need to do just clear the cr1.eq unconditionally. Do you have any benchmark results for this patch? I doubt it will get any visible difference. Anyway I will gave it a try. Thanks, Kevin -Scott pgptWm4iwxxv3.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 3/3] powerpc/e6500: hw tablewalk: order the memory access when acquire/release tcd lock
On Thu, Aug 13, 2015 at 10:39:19PM -0500, Scott Wood wrote: On Thu, 2015-08-13 at 19:51 +0800, Kevin Hao wrote: I didn't find anything unusual. But I think we do need to order the load/store of esel_next when acquire/release tcd lock. For acquire, add a data dependency to order the loads of lock and esel_next. For release, even there already have a isync here, but it doesn't guarantee any memory access order. So we still need lwsync for the two stores for lock and esel_next. I was going to say that esel_next is just a hint and it doesn't really matter if we occasionally get the wrong value, unless it happens often enough to cause more performance degradation than the lwsync causes. However, with the A-008139 workaround we do need to read the same value from esel_next both times. It might be less costly to save/restore an additional register instead of lwsync, though. I will try to get some benchmark number to compare which method is a bit better. Do you have any recommended benchmark for a case this is? Thanks, Kevin -Scott pgpQ3_2SiwY2A.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 2/3] powerpc/e6500: hw tablewalk: optimize a bit for tcd lock acquiring codes
It makes no sense to put the instructions for calculating the lock value (cpu number + 1) and the clearing of eq bit of cr1 in lbarx/stbcx loop. And when the lock is acquired by the other thread, the current lock value has no chance to equal with the lock value used by current cpu. So we can skip the comparing for these two lock values in the lbz/bne loop. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/mm/tlb_low_64e.S | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S index 765b419883f2..e4185581c5a7 100644 --- a/arch/powerpc/mm/tlb_low_64e.S +++ b/arch/powerpc/mm/tlb_low_64e.S @@ -308,11 +308,11 @@ BEGIN_FTR_SECTION /* CPU_FTR_SMT */ * * MAS6:IND should be already set based on MAS4 */ -1: lbarx r15,0,r11 lhz r10,PACAPACAINDEX(r13) - cmpdi r15,0 - cmpdi cr1,r15,1 /* set cr1.eq = 0 for non-recursive */ addir10,r10,1 + crclr cr1*4+eq/* set cr1.eq = 0 for non-recursive */ +1: lbarx r15,0,r11 + cmpdi r15,0 bne 2f stbcx. r10,0,r11 bne 1b @@ -320,9 +320,9 @@ BEGIN_FTR_SECTION /* CPU_FTR_SMT */ .subsection 1 2: cmpdcr1,r15,r10 /* recursive lock due to mcheck/crit/etc? */ beq cr1,3b /* unlock will happen if cr1.eq = 0 */ - lbz r15,0(r11) +10:lbz r15,0(r11) cmpdi r15,0 - bne 2b + bne 10b b 1b .previous -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 3/3] powerpc/e6500: hw tablewalk: order the memory access when acquire/release tcd lock
I didn't find anything unusual. But I think we do need to order the load/store of esel_next when acquire/release tcd lock. For acquire, add a data dependency to order the loads of lock and esel_next. For release, even there already have a isync here, but it doesn't guarantee any memory access order. So we still need lwsync for the two stores for lock and esel_next. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/mm/tlb_low_64e.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S index e4185581c5a7..964754911987 100644 --- a/arch/powerpc/mm/tlb_low_64e.S +++ b/arch/powerpc/mm/tlb_low_64e.S @@ -334,6 +334,8 @@ BEGIN_FTR_SECTION /* CPU_FTR_SMT */ * with tlbilx before overwriting. */ + andir15,r15,0 /* add a data dependency to order the loards */ + add r11,r11,r15 /* between the lock and esel_next */ lbz r15,TCD_ESEL_NEXT(r11) rlwinm r10,r15,16,0xff orisr10,r10,MAS0_TLBSEL(1)@h @@ -447,6 +449,7 @@ BEGIN_FTR_SECTION beq cr1,1f /* no unlock if lock was recursively grabbed */ li r15,0 isync + lwsync stb r15,0(r11) 1: END_FTR_SECTION_IFSET(CPU_FTR_SMT) -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 1/3] powerpc/e6500: remove the stale TCD_LOCK macro
Since we moved the lock to be the first element of struct tlb_core_data in commit 82d86de25b9c (powerpc/e6500: Make TLB lock recursive), this macro is not used by any code. Just delete it. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/kernel/asm-offsets.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 98230579d99c..810f433731dc 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -213,7 +213,6 @@ int main(void) offsetof(struct tlb_core_data, esel_max)); DEFINE(TCD_ESEL_FIRST, offsetof(struct tlb_core_data, esel_first)); - DEFINE(TCD_LOCK, offsetof(struct tlb_core_data, lock)); #endif /* CONFIG_PPC_BOOK3E */ #ifdef CONFIG_PPC_STD_MMU_64 -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] powerpc: pci: use %pR for printing struct resource
Use %pR to simplify the debug code. This also make the debug info more readable. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/kernel/pci-common.c | 72 +++- 1 file changed, 19 insertions(+), 53 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index b9de34d44fcb..d44f37854eb1 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -823,23 +823,16 @@ static void pcibios_fixup_resources(struct pci_dev *dev) (reg.start == 0 !pci_has_flag(PCI_PROBE_ONLY))) { /* Only print message if not re-assigning */ if (!pci_has_flag(PCI_REASSIGN_ALL_RSRC)) - pr_debug(PCI:%s Resource %d %016llx-%016llx [%x] + pr_debug(PCI:%s Resource %d %pR is unassigned\n, -pci_name(dev), i, -(unsigned long long)res-start, -(unsigned long long)res-end, -(unsigned int)res-flags); +pci_name(dev), i, res); res-end -= res-start; res-start = 0; res-flags |= IORESOURCE_UNSET; continue; } - pr_debug(PCI:%s Resource %d %016llx-%016llx [%x]\n, -pci_name(dev), i, -(unsigned long long)res-start,\ -(unsigned long long)res-end, -(unsigned int)res-flags); + pr_debug(PCI:%s Resource %d %pR\n, pci_name(dev), i, res); } /* Call machine specific resource fixup */ @@ -943,11 +936,7 @@ static void pcibios_fixup_bridge(struct pci_bus *bus) continue; } - pr_debug(PCI:%s Bus rsrc %d %016llx-%016llx [%x]\n, -pci_name(dev), i, -(unsigned long long)res-start,\ -(unsigned long long)res-end, -(unsigned int)res-flags); + pr_debug(PCI:%s Bus rsrc %d %pR\n, pci_name(dev), i, res); /* Try to detect uninitialized P2P bridge resources, * and clear them out so they get re-assigned later @@ -1132,10 +1121,8 @@ static int reparent_resources(struct resource *parent, *pp = NULL; for (p = res-child; p != NULL; p = p-sibling) { p-parent = res; - pr_debug(PCI: Reparented %s [%llx..%llx] under %s\n, -p-name, -(unsigned long long)p-start, -(unsigned long long)p-end, res-name); + pr_debug(PCI: Reparented %s %pR under %s\n, +p-name, p, res-name); } return 0; } @@ -1204,14 +1191,10 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus) } } - pr_debug(PCI: %s (bus %d) bridge rsrc %d: %016llx-%016llx -[0x%x], parent %p (%s)\n, -bus-self ? pci_name(bus-self) : PHB, -bus-number, i, -(unsigned long long)res-start, -(unsigned long long)res-end, -(unsigned int)res-flags, -pr, (pr pr-name) ? pr-name : nil); + pr_debug(PCI: %s (bus %d) bridge rsrc %d: %pR, parent %p +(%s)\n, bus-self ? pci_name(bus-self) : PHB, +bus-number, i, res, pr, +(pr pr-name) ? pr-name : nil); if (pr !(pr-flags IORESOURCE_UNSET)) { struct pci_dev *dev = bus-self; @@ -1253,11 +1236,8 @@ static inline void alloc_resource(struct pci_dev *dev, int idx) { struct resource *pr, *r = dev-resource[idx]; - pr_debug(PCI: Allocating %s: Resource %d: %016llx..%016llx [%x]\n, -pci_name(dev), idx, -(unsigned long long)r-start, -(unsigned long long)r-end, -(unsigned int)r-flags); + pr_debug(PCI: Allocating %s: Resource %d: %pR\n, +pci_name(dev), idx, r); pr = pci_find_parent_resource(dev, r); if (!pr || (pr-flags IORESOURCE_UNSET) || @@ -1265,11 +1245,7 @@ static inline void alloc_resource(struct pci_dev *dev, int idx) printk(KERN_WARNING PCI: Cannot allocate resource region %d of device %s, will remap\n, idx, pci_name(dev)); if (pr) - pr_debug(PCI: parent is %p: %016llx-%016llx [%x]\n, -pr
[PATCH] powerpc: mpc85xx: flush the l1 cache before cpu down in kexec
We observe a Zero PT_NOTE entries found warning when vmcore_init() is running on the dump-capture kernel. Actually the PT_NOTE segments is not empty, but the entries generated by crash_save_cpu() are not flushed to the memory before we reset these cores. So we should flush the l1 cache as what we do in cpu hotplug. With this change, we can also kill the mpc85xx_smp_flush_dcache_kexec() since that becomes unnecessary. Please note: this only fix the issue on e500 core, we still need to implement the function to flush the l2 cache for the e500mc core. Fortunately we already had proposing patch for this support [1]. Hope we can fix this issue for e500mc after that merged. [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2014-March/115830.html Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/platforms/85xx/smp.c | 51 +-- 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c index 8631ac5f0e57..b8b821697910 100644 --- a/arch/powerpc/platforms/85xx/smp.c +++ b/arch/powerpc/platforms/85xx/smp.c @@ -345,6 +345,7 @@ void mpc85xx_smp_kexec_cpu_down(int crash_shutdown, int secondary) local_irq_disable(); if (secondary) { + __flush_disable_L1(); atomic_inc(kexec_down_cpus); /* loop forever */ while (1); @@ -357,61 +358,11 @@ static void mpc85xx_smp_kexec_down(void *arg) ppc_md.kexec_cpu_down(0,1); } -static void map_and_flush(unsigned long paddr) -{ - struct page *page = pfn_to_page(paddr PAGE_SHIFT); - unsigned long kaddr = (unsigned long)kmap_atomic(page); - - flush_dcache_range(kaddr, kaddr + PAGE_SIZE); - kunmap_atomic((void *)kaddr); -} - -/** - * Before we reset the other cores, we need to flush relevant cache - * out to memory so we don't get anything corrupted, some of these flushes - * are performed out of an overabundance of caution as interrupts are not - * disabled yet and we can switch cores - */ -static void mpc85xx_smp_flush_dcache_kexec(struct kimage *image) -{ - kimage_entry_t *ptr, entry; - unsigned long paddr; - int i; - - if (image-type == KEXEC_TYPE_DEFAULT) { - /* normal kexec images are stored in temporary pages */ - for (ptr = image-head; (entry = *ptr) !(entry IND_DONE); -ptr = (entry IND_INDIRECTION) ? - phys_to_virt(entry PAGE_MASK) : ptr + 1) { - if (!(entry IND_DESTINATION)) { - map_and_flush(entry); - } - } - /* flush out last IND_DONE page */ - map_and_flush(entry); - } else { - /* crash type kexec images are copied to the crash region */ - for (i = 0; i image-nr_segments; i++) { - struct kexec_segment *seg = image-segment[i]; - for (paddr = seg-mem; paddr seg-mem + seg-memsz; -paddr += PAGE_SIZE) { - map_and_flush(paddr); - } - } - } - - /* also flush the kimage struct to be passed in as well */ - flush_dcache_range((unsigned long)image, - (unsigned long)image + sizeof(*image)); -} - static void mpc85xx_smp_machine_kexec(struct kimage *image) { int timeout = INT_MAX; int i, num_cpus = num_present_cpus(); - mpc85xx_smp_flush_dcache_kexec(image); - if (image-type == KEXEC_TYPE_DEFAULT) smp_call_function(mpc85xx_smp_kexec_down, NULL, 0); -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/2] powerpc: fix the dependency issue for CRASH_DUMP
On Mon, May 04, 2015 at 05:17:17PM -0500, Scott Wood wrote: On Thu, 2015-04-30 at 20:29 +0800, Kevin Hao wrote: In the current code, the RELOCATABLE will be forcedly enabled when enabling CRASH_DUMP. But for ppc32, the RELOCABLE also depend on ADVANCED_OPTIONS and select NONSTATIC_KERNEL. This will cause build error when CRASH_DUMP=y ADVANCED_OPTIONS=n. Even there is no such issue for ppc64, but select is only for non-visible symbols and for symbols with no dependencies. As for a symbol like RELOCATABLE, it is definitely not suitable to select it. So choose to depend on it. Why is it definitely not suitable to select it, provided the ADVANCED_OPTIONS dependency is removed, and the FLATMEM dependency is moved to places that select RELOCATABLE? Even with this change, the definition of RELOCATABLE still be something like this: config RELOCATABLE bool Build a relocatable kernel depends on (PPC64 !COMPILE_TEST) || 44x || FSL_BOOKE select NONSTATIC_KERNEL Quoted form Documentation/kbuild/kconfig-language.txt: select should be used with care. select will force a symbol to a value without visiting the dependencies. By abusing select you are able to select a symbol FOO even if FOO depends on BAR that is not set. In general use select only for non-visible symbols (no prompts anywhere) and for symbols with no dependencies. That will limit the usefulness but on the other hand avoid the illegal configurations all over. So it is always error prone to select a kernel option like this. It seems wrong that the user should have to enable ADVANCED_OPTIONS to even see the option to build a crash kernel. Yes, it seems ridiculous. But this is fixed in the patch 2. Thanks, Kevin pgpfHXmRVS_oo.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 0/2] powerpc: tweak the kernel options for CRASH_DUMP and RELOCATABLE
Hi, The first patch fixes a build error when CRASH_DUMP=y ADVANCED_OPTIONS=n for ppc32. The second does some cleanup for RELOCATABLE option. Kevin Hao (2): powerpc: fix the dependency issue for CRASH_DUMP powerpc: merge the RELOCATABLE config entries for ppc32 and ppc64 arch/powerpc/Kconfig | 68 +++- arch/powerpc/configs/ppc64_defconfig | 1 + 2 files changed, 29 insertions(+), 40 deletions(-) -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 1/2] powerpc: fix the dependency issue for CRASH_DUMP
In the current code, the RELOCATABLE will be forcedly enabled when enabling CRASH_DUMP. But for ppc32, the RELOCABLE also depend on ADVANCED_OPTIONS and select NONSTATIC_KERNEL. This will cause build error when CRASH_DUMP=y ADVANCED_OPTIONS=n. Even there is no such issue for ppc64, but select is only for non-visible symbols and for symbols with no dependencies. As for a symbol like RELOCATABLE, it is definitely not suitable to select it. So choose to depend on it. Also enable the RELOCATABLE explicitly for the defconfigs which has CRASH_DUMP enabled. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/Kconfig | 3 +-- arch/powerpc/configs/ppc64_defconfig | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 190cc48abc0c..d6bbf4f6f869 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -429,8 +429,7 @@ config KEXEC config CRASH_DUMP bool Build a kdump crash kernel - depends on PPC64 || 6xx || FSL_BOOKE || (44x !SMP) - select RELOCATABLE if (PPC64 !COMPILE_TEST) || 44x || FSL_BOOKE + depends on 6xx || ((PPC64 || FSL_BOOKE || (44x !SMP)) RELOCATABLE) help Build a kernel suitable for use as a kdump capture kernel. The same kernel binary can be used as production kernel and dump diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig index aad501ae3834..01f7b63f2df0 100644 --- a/arch/powerpc/configs/ppc64_defconfig +++ b/arch/powerpc/configs/ppc64_defconfig @@ -46,6 +46,7 @@ CONFIG_BINFMT_MISC=m CONFIG_PPC_TRANSACTIONAL_MEM=y CONFIG_KEXEC=y CONFIG_CRASH_DUMP=y +CONFIG_RELOCATABLE=y CONFIG_IRQ_ALL_CPUS=y CONFIG_MEMORY_HOTREMOVE=y CONFIG_KSM=y -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 2/2] powerpc: merge the RELOCATABLE config entries for ppc32 and ppc64
It makes no sense to keep two separate RELOCATABLE config entries for ppc32 and ppc64 respectively. Merge them into one and move it to a common place. The dependency on ADVANCED_OPTIONS for ppc32 seems unnecessary, also drop it. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/Kconfig | 65 ++-- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index d6bbf4f6f869..4080a14707bb 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -427,6 +427,33 @@ config KEXEC interface is strongly in flux, so no good recommendation can be made. +config RELOCATABLE + bool Build a relocatable kernel + depends on (PPC64 !COMPILE_TEST) || (FLATMEM (44x || FSL_BOOKE)) + select NONSTATIC_KERNEL + help + This builds a kernel image that is capable of running at the + location the kernel is loaded at. For ppc32, there is no any + alignment restrictions, and this feature is a superset of + DYNAMIC_MEMSTART and hence overrides it. For ppc64, we should use + 16k-aligned base address. The kernel is linked as a + position-independent executable (PIE) and contains dynamic relocations + which are processed early in the bootup process. + + One use is for the kexec on panic case where the recovery kernel + must live at a different physical address than the primary + kernel. + + Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address + it has been loaded at and the compile time physical addresses + CONFIG_PHYSICAL_START is ignored. However CONFIG_PHYSICAL_START + setting can still be useful to bootwrappers that need to know the + load address of the kernel (eg. u-boot/mkimage). + +config RELOCATABLE_PPC32 + def_bool y + depends on PPC32 RELOCATABLE + config CRASH_DUMP bool Build a kdump crash kernel depends on 6xx || ((PPC64 || FSL_BOOKE || (44x !SMP)) RELOCATABLE) @@ -926,29 +953,6 @@ config DYNAMIC_MEMSTART This option is overridden by CONFIG_RELOCATABLE -config RELOCATABLE - bool Build a relocatable kernel - depends on ADVANCED_OPTIONS FLATMEM (44x || FSL_BOOKE) - select NONSTATIC_KERNEL - help - This builds a kernel image that is capable of running at the - location the kernel is loaded at, without any alignment restrictions. - This feature is a superset of DYNAMIC_MEMSTART and hence overrides it. - - One use is for the kexec on panic case where the recovery kernel - must live at a different physical address than the primary - kernel. - - Note: If CONFIG_RELOCATABLE=y, then the kernel runs from the address - it has been loaded at and the compile time physical addresses - CONFIG_PHYSICAL_START is ignored. However CONFIG_PHYSICAL_START - setting can still be useful to bootwrappers that need to know the - load address of the kernel (eg. u-boot/mkimage). - -config RELOCATABLE_PPC32 - def_bool y - depends on PPC32 RELOCATABLE - config PAGE_OFFSET_BOOL bool Set custom page offset address depends on ADVANCED_OPTIONS @@ -1034,21 +1038,6 @@ config PIN_TLB endmenu if PPC64 -config RELOCATABLE - bool Build a relocatable kernel - depends on !COMPILE_TEST - select NONSTATIC_KERNEL - help - This builds a kernel image that is capable of running anywhere - in the RMA (real memory area) at any 16k-aligned base address. - The kernel is linked as a position-independent executable (PIE) - and contains dynamic relocations which are processed early - in the bootup process. - - One use is for the kexec on panic case where the recovery kernel - must live at a different physical address than the primary - kernel. - # This value must have zeroes in the bottom 60 bits otherwise lots will break config PAGE_OFFSET hex -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 1/3] powerpc: introduce PPC_HAS_LOCK_OWNER
On a system with shared processors (a physical processor is multiplexed between several virtual processors), we encode the lock owner into the lock token in order to avoid unnecessarily spinning on a lock if the lock holder isn't currently scheduled on a physical processor. In the current kernel, we unconditionally encode the lock owner into the lock token for all the ppc64 platforms no matter it is a shared processor or not. This introduces a new kernel option to distinguish the platforms which need this hack. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/Kconfig | 3 +++ arch/powerpc/include/asm/spinlock.h| 12 arch/powerpc/lib/locks.c | 4 ++-- arch/powerpc/platforms/pseries/Kconfig | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 9b780e0d2c18..6949d6099d4c 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -303,6 +303,9 @@ config PGTABLE_LEVELS default 3 if PPC_64K_PAGES default 4 +config PPC_HAS_LOCK_OWNER + bool + source init/Kconfig source kernel/Kconfig.freezer diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h index 4dbe072eecbe..38f40ea63a8c 100644 --- a/arch/powerpc/include/asm/spinlock.h +++ b/arch/powerpc/include/asm/spinlock.h @@ -30,7 +30,7 @@ #define smp_mb__after_unlock_lock()smp_mb() /* Full ordering for lock. */ -#ifdef CONFIG_PPC64 +#ifdef CONFIG_PPC_HAS_LOCK_OWNER /* use 0x80yy when locked, where yy == CPU number */ #ifdef __BIG_ENDIAN__ #define LOCK_TOKEN (*(u32 *)(get_paca()-lock_token)) @@ -109,7 +109,7 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock) * value. */ -#if defined(CONFIG_PPC_SPLPAR) +#if defined(CONFIG_PPC_HAS_LOCK_OWNER) /* We only yield to the hypervisor if we are in shared processor mode */ #define SHARED_PROCESSOR (lppaca_shared_proc(local_paca-lppaca_ptr)) extern void __spin_yield(arch_spinlock_t *lock); @@ -164,7 +164,7 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) lock-slock = 0; } -#ifdef CONFIG_PPC64 +#ifdef CONFIG_PPC_HAS_LOCK_OWNER extern void arch_spin_unlock_wait(arch_spinlock_t *lock); #else #define arch_spin_unlock_wait(lock) \ @@ -187,9 +187,13 @@ extern void arch_spin_unlock_wait(arch_spinlock_t *lock); #ifdef CONFIG_PPC64 #define __DO_SIGN_EXTEND extsw %0,%0\n -#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */ #else #define __DO_SIGN_EXTEND +#endif + +#ifdef CONFIG_PPC_HAS_LOCK_OWNER +#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */ +#else #define WRLOCK_TOKEN (-1) #endif diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c index 170a0346f756..66513b3e9b0e 100644 --- a/arch/powerpc/lib/locks.c +++ b/arch/powerpc/lib/locks.c @@ -19,7 +19,7 @@ #include linux/smp.h /* waiting for a spinlock... */ -#if defined(CONFIG_PPC_SPLPAR) +#if defined(CONFIG_PPC_HAS_LOCK_OWNER) #include asm/hvcall.h #include asm/smp.h @@ -66,7 +66,6 @@ void __rw_yield(arch_rwlock_t *rw) plpar_hcall_norets(H_CONFER, get_hard_smp_processor_id(holder_cpu), yield_count); } -#endif void arch_spin_unlock_wait(arch_spinlock_t *lock) { @@ -83,3 +82,4 @@ void arch_spin_unlock_wait(arch_spinlock_t *lock) } EXPORT_SYMBOL(arch_spin_unlock_wait); +#endif diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index a758a9c3bbba..5402fcc30c3e 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig @@ -27,6 +27,7 @@ config PPC_PSERIES config PPC_SPLPAR depends on PPC_PSERIES bool Support for shared-processor logical partitions + select PPC_HAS_LOCK_OWNER default n help Enabling this option will make the kernel run more efficiently -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 2/3] powerpc: spinlock: refactor codes wrapped by PPC_HAS_LOCK_OWNER
Move all of them to one place. No function change. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/include/asm/spinlock.h | 71 - 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h index 38f40ea63a8c..cbc9511df409 100644 --- a/arch/powerpc/include/asm/spinlock.h +++ b/arch/powerpc/include/asm/spinlock.h @@ -30,6 +30,20 @@ #define smp_mb__after_unlock_lock()smp_mb() /* Full ordering for lock. */ +/* + * On a system with shared processors (that is, where a physical + * processor is multiplexed between several virtual processors), + * there is no point spinning on a lock if the holder of the lock + * isn't currently scheduled on a physical processor. Instead + * we detect this situation and ask the hypervisor to give the + * rest of our timeslice to the lock holder. + * + * So that we can tell which virtual processor is holding a lock, + * we put 0x8000 | smp_processor_id() in the lock when it is + * held. Conveniently, we have a word in the paca that holds this + * value. + */ + #ifdef CONFIG_PPC_HAS_LOCK_OWNER /* use 0x80yy when locked, where yy == CPU number */ #ifdef __BIG_ENDIAN__ @@ -37,9 +51,22 @@ #else #define LOCK_TOKEN (*(u32 *)(get_paca()-paca_index)) #endif -#else -#define LOCK_TOKEN 1 -#endif +#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */ + +/* We only yield to the hypervisor if we are in shared processor mode */ +#define SHARED_PROCESSOR (lppaca_shared_proc(local_paca-lppaca_ptr)) +extern void __spin_yield(arch_spinlock_t *lock); +extern void __rw_yield(arch_rwlock_t *lock); +extern void arch_spin_unlock_wait(arch_spinlock_t *lock); +#else /* CONFIG_PPC_HAS_LOCK_OWNER */ +#define LOCK_TOKEN 1 +#define WRLOCK_TOKEN (-1) +#define SHARED_PROCESSOR 0 +#define __spin_yield(x)barrier() +#define __rw_yield(x) barrier() +#define arch_spin_unlock_wait(lock) \ + do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0) +#endif /* CONFIG_PPC_HAS_LOCK_OWNER */ #if defined(CONFIG_PPC64) defined(CONFIG_SMP) #define CLEAR_IO_SYNC (get_paca()-io_sync = 0) @@ -95,31 +122,6 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock) return __arch_spin_trylock(lock) == 0; } -/* - * On a system with shared processors (that is, where a physical - * processor is multiplexed between several virtual processors), - * there is no point spinning on a lock if the holder of the lock - * isn't currently scheduled on a physical processor. Instead - * we detect this situation and ask the hypervisor to give the - * rest of our timeslice to the lock holder. - * - * So that we can tell which virtual processor is holding a lock, - * we put 0x8000 | smp_processor_id() in the lock when it is - * held. Conveniently, we have a word in the paca that holds this - * value. - */ - -#if defined(CONFIG_PPC_HAS_LOCK_OWNER) -/* We only yield to the hypervisor if we are in shared processor mode */ -#define SHARED_PROCESSOR (lppaca_shared_proc(local_paca-lppaca_ptr)) -extern void __spin_yield(arch_spinlock_t *lock); -extern void __rw_yield(arch_rwlock_t *lock); -#else /* SPLPAR */ -#define __spin_yield(x)barrier() -#define __rw_yield(x) barrier() -#define SHARED_PROCESSOR 0 -#endif - static inline void arch_spin_lock(arch_spinlock_t *lock) { CLEAR_IO_SYNC; @@ -164,13 +166,6 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock) lock-slock = 0; } -#ifdef CONFIG_PPC_HAS_LOCK_OWNER -extern void arch_spin_unlock_wait(arch_spinlock_t *lock); -#else -#define arch_spin_unlock_wait(lock) \ - do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0) -#endif - /* * Read-write spinlocks, allowing multiple readers * but only one writer. @@ -191,12 +186,6 @@ extern void arch_spin_unlock_wait(arch_spinlock_t *lock); #define __DO_SIGN_EXTEND #endif -#ifdef CONFIG_PPC_HAS_LOCK_OWNER -#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */ -#else -#define WRLOCK_TOKEN (-1) -#endif - /* * This returns the old value in the lock + 1, * so we got a read lock if the return value is 0. -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC] powerpc: use ticket spin lock for !CONFIG_PPC_SPLPAR
On Thu, Mar 12, 2015 at 04:24:10PM +0100, Torsten Duwe wrote: But generally, which platforms would benefit most from this change? In theory, the more cpus the platform has, the more serious the thundering herd problem is. So the latest platforms which has more cpus would benefit most. Thanks, Keivn pgpZ__cPBVSxG.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC] powerpc: use ticket spin lock for !CONFIG_PPC_SPLPAR
On Thu, Mar 12, 2015 at 10:13:27PM +1100, Benjamin Herrenschmidt wrote: I would do the ifdef'ing differently, something like CONFIG_PPC_HAS_LOCK_OWNER CONFIG_PPC_TICKET_LOCKS depends on !PPC_HAS_LOCK_OWNER and use these two in the code... with SPLPAR select'ing HAS_LOCK_OWNER OK, will do. Thanks, Kevin pgpsjL2rrngq5.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC] powerpc: use ticket spin lock for !CONFIG_PPC_SPLPAR
I know Torsten Duwe has tried to add the ticket spinlock for powerpc one year ago [1]. But it make no progress due to the conflict between PPC_SPLPAR and lockref. We still don't find a better way to handle this. But instead of waiting forever for a perfect solution, can't we just use the ticket spinlock for the !CONFIG_PPC_SPLPAR? This is a very rough patch based on arm64 codes. I want to make sure that this is acceptable before going step further. This just passed build and boot test on a fsl t4240rdb board. I have done a simple performance benchmark by running the following command ten times before and after applying this patch: ./perf bench sched messaging BeforeAfter Averaged total time [sec]: 0.403 0.367 So we can see a ~9% performance enhancing. This patch depends on this one [2]. [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2014-February/115195.html [2] http://patchwork.ozlabs.org/patch/447563/ Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/include/asm/spinlock.h | 79 ++- arch/powerpc/include/asm/spinlock_types.h | 16 +++ arch/powerpc/lib/locks.c | 2 +- 3 files changed, 95 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h index d303cdad2519..3faf2507abe9 100644 --- a/arch/powerpc/include/asm/spinlock.h +++ b/arch/powerpc/include/asm/spinlock.h @@ -54,6 +54,7 @@ #define SYNC_IO #endif +#ifdef CONFIG_PPC_SPLPAR static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock) { return lock.slock == 0; @@ -89,6 +90,40 @@ static inline unsigned long __arch_spin_trylock(arch_spinlock_t *lock) return tmp; } +#else +static inline int arch_spin_value_unlocked(arch_spinlock_t lock) +{ + return lock.owner == lock.next; +} + +static inline int arch_spin_is_locked(arch_spinlock_t *lock) +{ + return !arch_spin_value_unlocked(READ_ONCE(*lock)); +} + +static inline unsigned long __arch_spin_trylock(arch_spinlock_t *lock) +{ + unsigned int tmp; + arch_spinlock_t lockval; + + __asm__ __volatile__ ( +1: PPC_LWARX(%0,0,%2,1) \n\ + rotlwi %1,%0,16\n\ + xor.%1,%1,%0\n\ + bne-2f\n\ + add %0,%0,%3\n\ + stwcx. %0,0,%2\n\ + bne-1b\n + PPC_ACQUIRE_BARRIER +2: + : =r (lockval), =r (tmp) + : r (lock), r (1 TICKET_SHIFT) + : cr0, memory); + + return tmp; +} +#endif + static inline int arch_spin_trylock(arch_spinlock_t *lock) { CLEAR_IO_SYNC; @@ -120,6 +155,7 @@ extern void __rw_yield(arch_rwlock_t *lock); #define SHARED_PROCESSOR 0 #endif +#ifdef CONFIG_PPC_SPLPAR static inline void arch_spin_lock(arch_spinlock_t *lock) { CLEAR_IO_SYNC; @@ -155,16 +191,57 @@ void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags) local_irq_restore(flags_dis); } } +#else +#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock) + +static inline int arch_spin_is_contended(arch_spinlock_t *lock) +{ + arch_spinlock_t lockval = READ_ONCE(*lock); + return (lockval.next - lockval.owner) 1; +} +#define arch_spin_is_contended arch_spin_is_contended + +static inline void arch_spin_lock(arch_spinlock_t *lock) +{ + unsigned int tmp; + arch_spinlock_t lockval; + + CLEAR_IO_SYNC; + __asm__ __volatile__ ( +1: PPC_LWARX(%0,0,%2,1) \n\ + add %1,%0,%4\n\ + stwcx. %1,0,%2\n\ + bne-1b\n\ + rotlwi %1,%0,16\n\ + cmpw%1,%0\n\ + beq 3f\n\ + rlwinm %0,%0,16,16,31\n\ +2: or 1,1,1\n\ + lhz %1,0(%3)\n\ + cmpw%1,%0\n\ + bne 2b\n\ + or 2,2,2\n\ +3: + PPC_ACQUIRE_BARRIER + : =r (lockval), =r (tmp) + : r(lock), r (lock-owner), r (1 TICKET_SHIFT) + : cr0, memory); +} +#endif static inline void arch_spin_unlock(arch_spinlock_t *lock) { SYNC_IO; __asm__ __volatile__(# arch_spin_unlock\n\t PPC_RELEASE_BARRIER: : :memory); +#ifdef CONFIG_PPC_SPLPAR lock-slock = 0; +#else + lock-owner++; +#endif } -#ifdef CONFIG_PPC64 +#ifdef CONFIG_PPC_SPLPAR extern void arch_spin_unlock_wait(arch_spinlock_t *lock); #else #define arch_spin_unlock_wait(lock) \ diff --git a/arch/powerpc/include/asm/spinlock_types.h b/arch/powerpc/include/asm/spinlock_types.h index 2351adc4fdc4..1af94f290363 100644 --- a/arch/powerpc/include/asm/spinlock_types.h +++ b/arch/powerpc/include/asm/spinlock_types.h @@ -5,11 +5,27 @@ # error please don't include this file directly #endif +#ifdef CONFIG_PPC_SPLPAR typedef struct { volatile unsigned int slock; } arch_spinlock_t
[PATCH v3 0/9] powerpc: kill PPC_OF
Hi Michael, Finally I got all the acks for these patches. The following two patches in v2 were merged into next now. 213dce3c17a6 (tty: kconfig: remove the superfluous dependency on PPC_OF) f4e074f20cad (mmc: kconfig: replace PPC_OF with PPC) So we may have dependency issue if we put this series into 4.1. v3: No codes change, just add the acks from Ben and Tomi. Kevin Hao (9): sata_svw: remove the dependency on PPC_OF fbdev: aty128fb: replace PPC_OF with PPC fbdev: radeon: replace PPC_OF with PPC fbdev: imsttfb: remove the dependency on PPC_OF fbdev: nvidia: remove the dependency on PPC_OF fbdev: riva: remove the dependency on PPC_OF fbdev: remove the unnecessary includes of ppc specific header files fbdev: kconfig: replace PPC_OF with PPC powerpc: kill PPC_OF arch/powerpc/Kconfig | 3 --- arch/powerpc/Kconfig.debug | 2 +- arch/powerpc/kernel/Makefile | 4 ++-- drivers/ata/sata_svw.c | 11 +-- drivers/video/fbdev/Kconfig | 4 ++-- drivers/video/fbdev/aty/aty128fb.c | 4 ++-- drivers/video/fbdev/aty/radeon_base.c| 24 drivers/video/fbdev/aty/radeon_monitor.c | 20 ++-- drivers/video/fbdev/aty/radeon_pm.c | 16 drivers/video/fbdev/aty/radeonfb.h | 4 ++-- drivers/video/fbdev/core/fbmon.c | 4 drivers/video/fbdev/imsttfb.c| 6 +- drivers/video/fbdev/nvidia/Makefile | 3 +-- drivers/video/fbdev/nvidia/nv_of.c | 3 --- drivers/video/fbdev/nvidia/nv_proto.h| 8 drivers/video/fbdev/nvidia/nvidia.c | 4 drivers/video/fbdev/riva/fbdev.c | 17 +++-- 17 files changed, 49 insertions(+), 88 deletions(-) -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 1/9] sata_svw: remove the dependency on PPC_OF
The OF functionality has moved to a common place and be used by many archs. So we don't need to include the ppc arch specific header files and depend on PPC_OF option any more. This is a preparation for killing PPC_OF. Signed-off-by: Kevin Hao haoke...@gmail.com Acked-by: Tejun Heo t...@kernel.org Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org --- drivers/ata/sata_svw.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c index c630fa812624..4c06f6281d74 100644 --- a/drivers/ata/sata_svw.c +++ b/drivers/ata/sata_svw.c @@ -47,11 +47,7 @@ #include scsi/scsi_cmnd.h #include scsi/scsi.h #include linux/libata.h - -#ifdef CONFIG_PPC_OF -#include asm/prom.h -#include asm/pci-bridge.h -#endif /* CONFIG_PPC_OF */ +#include linux/of.h #define DRV_NAME sata_svw #define DRV_VERSION2.3 @@ -320,7 +316,6 @@ static u8 k2_stat_check_status(struct ata_port *ap) return readl(ap-ioaddr.status_addr); } -#ifdef CONFIG_PPC_OF static int k2_sata_show_info(struct seq_file *m, struct Scsi_Host *shost) { struct ata_port *ap; @@ -350,14 +345,10 @@ static int k2_sata_show_info(struct seq_file *m, struct Scsi_Host *shost) } return 0; } -#endif /* CONFIG_PPC_OF */ - static struct scsi_host_template k2_sata_sht = { ATA_BMDMA_SHT(DRV_NAME), -#ifdef CONFIG_PPC_OF .show_info = k2_sata_show_info, -#endif }; -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 2/9] fbdev: aty128fb: replace PPC_OF with PPC
The PPC_OF is a ppc specific option which is used to mean that the firmware device tree access functions are available. Since all the ppc platforms have a device tree, it is aways set to 'y' for ppc. So it makes no sense to keep a such option in the current kernel. Replace it with PPC. Signed-off-by: Kevin Hao haoke...@gmail.com Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org Acked-by: Tomi Valkeinen tomi.valkei...@ti.com --- drivers/video/fbdev/aty/aty128fb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c index aedf2fbf9bf6..0156954bf340 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -965,7 +965,7 @@ static void __iomem *aty128_find_mem_vbios(struct aty128fb_par *par) /* fill in known card constants if pll_block is not available */ static void aty128_timings(struct aty128fb_par *par) { -#ifdef CONFIG_PPC_OF +#ifdef CONFIG_PPC /* instead of a table lookup, assume OF has properly * setup the PLL registers and use their values * to set the XCLK values and reference divider values */ @@ -979,7 +979,7 @@ static void aty128_timings(struct aty128fb_par *par) if (!par-constants.ref_clk) par-constants.ref_clk = 2950; -#ifdef CONFIG_PPC_OF +#ifdef CONFIG_PPC x_mpll_ref_fb_div = aty_ld_pll(X_MPLL_REF_FB_DIV); xclk_cntl = aty_ld_pll(XCLK_CNTL) 0x7; Nx = (x_mpll_ref_fb_div 0x00ff00) 8; -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 3/9] fbdev: radeon: replace PPC_OF with PPC
The PPC_OF is a ppc specific option which is used to mean that the firmware device tree access functions are available. Since all the ppc platforms have a device tree, it is aways set to 'y' for ppc. So it makes no sense to keep a such option in the current kernel. Replace it with PPC. Signed-off-by: Kevin Hao haoke...@gmail.com Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org Acked-by: Tomi Valkeinen tomi.valkei...@ti.com --- drivers/video/fbdev/Kconfig | 2 +- drivers/video/fbdev/aty/radeon_base.c| 24 drivers/video/fbdev/aty/radeon_monitor.c | 20 ++-- drivers/video/fbdev/aty/radeon_pm.c | 16 drivers/video/fbdev/aty/radeonfb.h | 4 ++-- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index b3dd417b4719..3b818d7a0983 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -1333,7 +1333,7 @@ config FB_RADEON select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT - select FB_MACMODES if PPC_OF + select FB_MACMODES if PPC help Choose this option if you want to use an ATI Radeon graphics card as a framebuffer device. There are both PCI and AGP versions. You diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c index 26d80a4486fb..01237c8fcdc6 100644 --- a/drivers/video/fbdev/aty/radeon_base.c +++ b/drivers/video/fbdev/aty/radeon_base.c @@ -74,7 +74,7 @@ #include asm/io.h #include linux/uaccess.h -#ifdef CONFIG_PPC_OF +#ifdef CONFIG_PPC #include asm/pci-bridge.h #include ../macmodes.h @@ -83,7 +83,7 @@ #include asm/btext.h #endif -#endif /* CONFIG_PPC_OF */ +#endif /* CONFIG_PPC */ #ifdef CONFIG_MTRR #include asm/mtrr.h @@ -418,7 +418,7 @@ static int radeon_find_mem_vbios(struct radeonfb_info *rinfo) } #endif -#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC) +#if defined(CONFIG_PPC) || defined(CONFIG_SPARC) /* * Read XTAL (ref clock), SCLK and MCLK from Open Firmware device * tree. Hopefully, ATI OF driver is kind enough to fill these @@ -448,7 +448,7 @@ static int radeon_read_xtal_OF(struct radeonfb_info *rinfo) return 0; } -#endif /* CONFIG_PPC_OF || CONFIG_SPARC */ +#endif /* CONFIG_PPC || CONFIG_SPARC */ /* * Read PLL infos from chip registers @@ -653,7 +653,7 @@ static void radeon_get_pllinfo(struct radeonfb_info *rinfo) rinfo-pll.ref_div = INPLL(PPLL_REF_DIV) PPLL_REF_DIV_MASK; -#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC) +#if defined(CONFIG_PPC) || defined(CONFIG_SPARC) /* * Retrieve PLL infos from Open Firmware first */ @@ -661,7 +661,7 @@ static void radeon_get_pllinfo(struct radeonfb_info *rinfo) printk(KERN_INFO radeonfb: Retrieved PLL infos from Open Firmware\n); goto found; } -#endif /* CONFIG_PPC_OF || CONFIG_SPARC */ +#endif /* CONFIG_PPC || CONFIG_SPARC */ /* * Check out if we have an X86 which gave us some PLL informations @@ -1910,7 +1910,7 @@ static int radeon_set_fbinfo(struct radeonfb_info *rinfo) * I put the card's memory at 0 in card space and AGP at some random high * local (0xe000 for now) that will be changed by XFree/DRI anyway */ -#ifdef CONFIG_PPC_OF +#ifdef CONFIG_PPC #undef SET_MC_FB_FROM_APERTURE static void fixup_memory_mappings(struct radeonfb_info *rinfo) { @@ -1984,7 +1984,7 @@ static void fixup_memory_mappings(struct radeonfb_info *rinfo) ((aper_base + aper_size - 1) 0x) | (aper_base 16), 0x | (agp_base 16)); } -#endif /* CONFIG_PPC_OF */ +#endif /* CONFIG_PPC */ static void radeon_identify_vram(struct radeonfb_info *rinfo) @@ -2236,7 +2236,7 @@ static int radeonfb_pci_register(struct pci_dev *pdev, rinfo-family == CHIP_FAMILY_RS200) rinfo-errata |= CHIP_ERRATA_PLL_DELAY; -#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC) +#if defined(CONFIG_PPC) || defined(CONFIG_SPARC) /* On PPC, we obtain the OF device-node pointer to the firmware * data for this chip */ @@ -2245,14 +2245,14 @@ static int radeonfb_pci_register(struct pci_dev *pdev, printk(KERN_WARNING radeonfb (%s): Cannot match card to OF node !\n, pci_name(rinfo-pdev)); -#endif /* CONFIG_PPC_OF || CONFIG_SPARC */ -#ifdef CONFIG_PPC_OF +#endif /* CONFIG_PPC || CONFIG_SPARC */ +#ifdef CONFIG_PPC /* On PPC, the firmware sets up a memory mapping that tends * to cause lockups when enabling the engine. We reconfigure * the card internal memory mappings properly */ fixup_memory_mappings(rinfo); -#endif /* CONFIG_PPC_OF */ +#endif /* CONFIG_PPC */ /* Get VRAM size and type */ radeon_identify_vram(rinfo); diff --git
[PATCH v3 4/9] fbdev: imsttfb: remove the dependency on PPC_OF
The OF functionality has moved to a common place and be used by many archs. So we don't need to depend on PPC_OF option any more. This is a preparation for killing PPC_OF. Signed-off-by: Kevin Hao haoke...@gmail.com Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org Acked-by: Tomi Valkeinen tomi.valkei...@ti.com --- drivers/video/fbdev/imsttfb.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c index aae10ce74f14..9b167f7ef6c6 100644 --- a/drivers/video/fbdev/imsttfb.c +++ b/drivers/video/fbdev/imsttfb.c @@ -1470,15 +1470,13 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) unsigned long addr, size; struct imstt_par *par; struct fb_info *info; -#ifdef CONFIG_PPC_OF struct device_node *dp; dp = pci_device_to_OF_node(pdev); if(dp) printk(KERN_INFO %s: OF name %s\n,__func__, dp-name); - else + else if (IS_ENABLED(CONFIG_OF)) printk(KERN_ERR imsttfb: no OF node for pci device\n); -#endif /* CONFIG_PPC_OF */ info = framebuffer_alloc(sizeof(struct imstt_par), pdev-dev); @@ -1501,11 +1499,9 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) switch (pdev-device) { case PCI_DEVICE_ID_IMS_TT128: /* IMS,tt128mbA */ par-ramdac = IBM; -#ifdef CONFIG_PPC_OF if (dp ((strcmp(dp-name, IMS,tt128mb8) == 0) || (strcmp(dp-name, IMS,tt128mb8A) == 0))) par-ramdac = TVP; -#endif /* CONFIG_PPC_OF */ break; case PCI_DEVICE_ID_IMS_TT3D: /* IMS,tt3d */ par-ramdac = TVP; -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 5/9] fbdev: nvidia: remove the dependency on PPC_OF
The OF functionality has moved to a common place and be used by many archs. So we don't need to include the ppc arch specific header files and depend on PPC_OF option any more. This is a preparation for killing PPC_OF. Signed-off-by: Kevin Hao haoke...@gmail.com Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org Acked-by: Tomi Valkeinen tomi.valkei...@ti.com --- drivers/video/fbdev/nvidia/Makefile | 3 +-- drivers/video/fbdev/nvidia/nv_of.c| 3 --- drivers/video/fbdev/nvidia/nv_proto.h | 8 drivers/video/fbdev/nvidia/nvidia.c | 4 4 files changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/video/fbdev/nvidia/Makefile b/drivers/video/fbdev/nvidia/Makefile index ca47432113e0..917d3eb05feb 100644 --- a/drivers/video/fbdev/nvidia/Makefile +++ b/drivers/video/fbdev/nvidia/Makefile @@ -5,9 +5,8 @@ obj-$(CONFIG_FB_NVIDIA) += nvidiafb.o nvidiafb-y := nvidia.o nv_hw.o nv_setup.o \ - nv_accel.o + nv_accel.o nv_of.o nvidiafb-$(CONFIG_FB_NVIDIA_I2C) += nv_i2c.o nvidiafb-$(CONFIG_FB_NVIDIA_BACKLIGHT) += nv_backlight.o -nvidiafb-$(CONFIG_PPC_OF) += nv_of.o nvidiafb-objs:= $(nvidiafb-y) diff --git a/drivers/video/fbdev/nvidia/nv_of.c b/drivers/video/fbdev/nvidia/nv_of.c index 3bc13df4b120..5f3e5179c25a 100644 --- a/drivers/video/fbdev/nvidia/nv_of.c +++ b/drivers/video/fbdev/nvidia/nv_of.c @@ -19,9 +19,6 @@ #include asm/io.h -#include asm/prom.h -#include asm/pci-bridge.h - #include nv_type.h #include nv_local.h #include nv_proto.h diff --git a/drivers/video/fbdev/nvidia/nv_proto.h b/drivers/video/fbdev/nvidia/nv_proto.h index ff5c410355ea..878a5ce02299 100644 --- a/drivers/video/fbdev/nvidia/nv_proto.h +++ b/drivers/video/fbdev/nvidia/nv_proto.h @@ -42,16 +42,8 @@ int nvidia_probe_i2c_connector(struct fb_info *info, int conn, #define nvidia_probe_i2c_connector(p, c, edid) (-1) #endif -#ifdef CONFIG_PPC_OF int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 ** out_edid); -#else -static inline int nvidia_probe_of_connector(struct fb_info *info, int conn, - u8 ** out_edid) -{ - return -1; -} -#endif /* in nv_accel.c */ extern void NVResetGraphics(struct fb_info *info); diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c index def041204676..4273c6ee8cf6 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c @@ -24,10 +24,6 @@ #ifdef CONFIG_MTRR #include asm/mtrr.h #endif -#ifdef CONFIG_PPC_OF -#include asm/prom.h -#include asm/pci-bridge.h -#endif #ifdef CONFIG_BOOTX_TEXT #include asm/btext.h #endif -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 6/9] fbdev: riva: remove the dependency on PPC_OF
The OF functionality has moved to a common place and be used by many archs. So we don't need to include the ppc arch specific header files and depend on PPC_OF option any more. This is a preparation for killing PPC_OF. Signed-off-by: Kevin Hao haoke...@gmail.com Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org Acked-by: Tomi Valkeinen tomi.valkei...@ti.com --- drivers/video/fbdev/riva/fbdev.c | 17 +++-- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index be73727c7227..294a80908c8c 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -44,10 +44,6 @@ #ifdef CONFIG_MTRR #include asm/mtrr.h #endif -#ifdef CONFIG_PPC_OF -#include asm/prom.h -#include asm/pci-bridge.h -#endif #ifdef CONFIG_PMAC_BACKLIGHT #include asm/machdep.h #include asm/backlight.h @@ -1735,7 +1731,6 @@ static int riva_set_fbinfo(struct fb_info *info) return (rivafb_check_var(info-var, info)); } -#ifdef CONFIG_PPC_OF static int riva_get_EDID_OF(struct fb_info *info, struct pci_dev *pd) { struct riva_par *par = info-par; @@ -1766,9 +1761,8 @@ static int riva_get_EDID_OF(struct fb_info *info, struct pci_dev *pd) NVTRACE_LEAVE(); return 0; } -#endif /* CONFIG_PPC_OF */ -#if defined(CONFIG_FB_RIVA_I2C) !defined(CONFIG_PPC_OF) +#if defined(CONFIG_FB_RIVA_I2C) static int riva_get_EDID_i2c(struct fb_info *info) { struct riva_par *par = info-par; @@ -1828,10 +1822,13 @@ static void riva_update_default_var(struct fb_var_screeninfo *var, static void riva_get_EDID(struct fb_info *info, struct pci_dev *pdev) { NVTRACE_ENTER(); -#ifdef CONFIG_PPC_OF - if (!riva_get_EDID_OF(info, pdev)) + if (riva_get_EDID_OF(info, pdev)) { + NVTRACE_LEAVE(); + return; + } + if (IS_ENABLED(CONFIG_OF)) printk(PFX could not retrieve EDID from OF\n); -#elif defined(CONFIG_FB_RIVA_I2C) +#if defined(CONFIG_FB_RIVA_I2C) if (!riva_get_EDID_i2c(info)) printk(PFX could not retrieve EDID from DDC/I2C\n); #endif -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 7/9] fbdev: remove the unnecessary includes of ppc specific header files
In the current kernel, we don't need to include these arch specific header files for ppc. Signed-off-by: Kevin Hao haoke...@gmail.com Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org Acked-by: Tomi Valkeinen tomi.valkei...@ti.com --- drivers/video/fbdev/core/fbmon.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c index 868facdec638..01ef1b953390 100644 --- a/drivers/video/fbdev/core/fbmon.c +++ b/drivers/video/fbdev/core/fbmon.c @@ -33,10 +33,6 @@ #include video/edid.h #include video/of_videomode.h #include video/videomode.h -#ifdef CONFIG_PPC_OF -#include asm/prom.h -#include asm/pci-bridge.h -#endif #include ../edid.h /* -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 8/9] fbdev: kconfig: replace PPC_OF with PPC
The PPC_OF is a ppc specific option which is used to mean that the firmware device tree access functions are available. Since all the ppc platforms have a device tree, it is aways set to 'y' for ppc. So it makes no sense to keep a such option in the current kernel. Replace it with PPC. Signed-off-by: Kevin Hao haoke...@gmail.com Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org Acked-by: Tomi Valkeinen tomi.valkei...@ti.com --- drivers/video/fbdev/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 3b818d7a0983..109462303087 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -479,7 +479,7 @@ config FB_ATARI config FB_OF bool Open Firmware frame buffer device support - depends on (FB = y) (PPC64 || PPC_OF) (!PPC_PSERIES || PCI) + depends on (FB = y) PPC (!PPC_PSERIES || PCI) select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v3 9/9] powerpc: kill PPC_OF
We have set CONFIG_PPC_OF to always 'y' in commit 0a498d96a332 (powerpc: set CONFIG_PPC_OF=y always for ARCH=powerpc) nine years ago. And the arch/ppc also has gone away for many years. The OF functionality was also moved to a common place and be used by many archs. So it does make no sense to keep such a option in the current kernel. Just kill it. Signed-off-by: Kevin Hao haoke...@gmail.com Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org --- arch/powerpc/Kconfig | 3 --- arch/powerpc/Kconfig.debug | 2 +- arch/powerpc/kernel/Makefile | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 9b780e0d2c18..fb48a2e2f0b3 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -189,9 +189,6 @@ config ARCH_MAY_HAVE_PC_FDC bool default PCI -config PPC_OF - def_bool y - config PPC_UDBG_16550 bool default n diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug index ec2e40f2cc11..bfd823abff93 100644 --- a/arch/powerpc/Kconfig.debug +++ b/arch/powerpc/Kconfig.debug @@ -117,7 +117,7 @@ config BDI_SWITCH config BOOTX_TEXT bool Support for early boot text console (BootX or OpenFirmware only) - depends on PPC_OF PPC_BOOK3S + depends on PPC_BOOK3S help Say Y here to see progress messages from the boot firmware in text mode. Requires either BootX or Open Firmware. diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 502cf69b6c89..c1ebbdaac28f 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -33,7 +33,8 @@ obj-y := cputable.o ptrace.o syscalls.o \ signal.o sysfs.o cacheinfo.o time.o \ prom.o traps.o setup-common.o \ udbg.o misc.o io.o dma.o \ - misc_$(CONFIG_WORD_SIZE).o vdso32/ + misc_$(CONFIG_WORD_SIZE).o vdso32/ \ + of_platform.o prom_parse.o obj-$(CONFIG_PPC64)+= setup_64.o sys_ppc32.o \ signal_64.o ptrace32.o \ paca.o nvram_64.o firmware.o @@ -47,7 +48,6 @@ obj-$(CONFIG_PPC64) += vdso64/ obj-$(CONFIG_ALTIVEC) += vecemu.o obj-$(CONFIG_PPC_970_NAP) += idle_power4.o obj-$(CONFIG_PPC_P7_NAP) += idle_power7.o -obj-$(CONFIG_PPC_OF) += of_platform.o prom_parse.o procfs-y := proc_powerpc.o obj-$(CONFIG_PROC_FS) += $(procfs-y) rtaspci-$(CONFIG_PPC64)-$(CONFIG_PCI) := rtas_pci.o -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: book3e_64: fix the align size for paca_struct
On Mon, Mar 09, 2015 at 06:31:25PM +1100, Benjamin Herrenschmidt wrote: On Mon, 2015-03-09 at 09:13 +0800, Kevin Hao wrote: On Sun, Mar 08, 2015 at 08:13:26PM +1100, Benjamin Herrenschmidt wrote: On Sat, 2015-03-07 at 19:14 +0800, Kevin Hao wrote: All the cache line size of the current book3e 64bit SoCs are 64 bytes. So we should use this size to align the member of paca_struct. With this change we save 192 bytes. Also change it to __aligned(size) since it is preferred over __attribute__((aligned(size))). Why should we favor the book3e CPUs over the book3s ones ? Why do you think so? This only change the align size of the paca_struct's members which are private to book3e CPUs, and should not have any effect to book3s ones. Did I miss something? No, your explanation was lacking that important detail :-) Sorry for the confusion, I will add this information in the commit log. Thanks, Kevin pgpNhzA4BHwp3.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2] powerpc: book3e_64: fix the align size for paca_struct
All the cache line size of the current book3e 64bit SoCs are 64 bytes. So we should use this size to align the member of paca_struct. This only change the paca_struct's members which are private to book3e CPUs, and should not have any effect to book3s ones. With this, we save 192 bytes. Also change it to __aligned(size) since it is preferred over __attribute__((aligned(size))). Before: /* size: 1920, cachelines: 30, members: 46 */ /* sum members: 1667, holes: 6, sum holes: 141 */ /* padding: 112 */ After: /* size: 1728, cachelines: 27, members: 46 */ /* sum members: 1667, holes: 4, sum holes: 13 */ /* padding: 48 */ Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: Only update the commit log. arch/powerpc/include/asm/paca.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h index e5f22c6c4bf9..70bd4381f8e6 100644 --- a/arch/powerpc/include/asm/paca.h +++ b/arch/powerpc/include/asm/paca.h @@ -106,9 +106,9 @@ struct paca_struct { #endif /* CONFIG_PPC_STD_MMU_64 */ #ifdef CONFIG_PPC_BOOK3E - u64 exgen[8] __attribute__((aligned(0x80))); + u64 exgen[8] __aligned(0x40); /* Keep pgd in the same cacheline as the start of extlb */ - pgd_t *pgd __attribute__((aligned(0x80))); /* Current PGD */ + pgd_t *pgd __aligned(0x40); /* Current PGD */ pgd_t *kernel_pgd; /* Kernel PGD */ /* Shared by all threads of a core -- points to tcd of first thread */ -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc64: use fixed lock token for !CONFIG_PPC_SPLPAR
On Tue, Mar 10, 2015 at 11:15:18AM +1100, Michael Ellerman wrote: On Mon, 2015-03-09 at 17:53 +1100, Benjamin Herrenschmidt wrote: On Sat, 2015-03-07 at 19:19 +0800, Kevin Hao wrote: It makes no sense to use a variant lock token on a platform which doesn't support for shared-processor logical partitions. Actually we can eliminate a memory load by using a fixed lock token on these platforms. Does this provide an actual measurable benefit ? I found that the lock token was quite handy for debugging ... Yeah. It can be very useful to know which cpu holds a lock when you get into a dead lock. Unless you can show this is a performance boost I'm inclined to leave it as-is. I am not sure if there is more suitable benchmark for spinlock. I tried the perf locking benchmark got from here [1]. The test was running on a t4240rdb board with xfs rootfs. I have run the following commands four times before and after applying this patch. ./perf record ./perf bench locking vfs; ./perf report Before: 3.06% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock 3.04% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock 3.03% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock 3.00% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock After: 3.05% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock 2.97% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock 2.96% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock 2.97% locking-vfs [kernel.kallsyms] [k] ._raw_spin_lock [1] http://lkml.iu.edu/hypermail/linux/kernel/1412.1/01419.html Thanks, Kevin pgpsAPyXngmuG.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 03/15] fbdev: aty128fb: replace PPC_OF with PPC
On Tue, Mar 10, 2015 at 02:23:12PM +0200, Tomi Valkeinen wrote: I just sent out a v2 [1] a few hours earlier with some minor updates. We plan to merge this patch series via the powerpc tree in 4.1 cycle if I can collect all the acks from the corresponding driver maintainers. Fbdev changes look ok to me. Hi Tomi, I assume that I can add a Acked-by: Tomi Valkeinen tomi.valkei...@ti.com for all the following patches, right? http://patchwork.ozlabs.org/patch/443890/ http://patchwork.ozlabs.org/patch/443891/ http://patchwork.ozlabs.org/patch/443892/ http://patchwork.ozlabs.org/patch/443893/ http://patchwork.ozlabs.org/patch/443894/ http://patchwork.ozlabs.org/patch/443895/ http://patchwork.ozlabs.org/patch/443897/ Thanks, Kevin pgpfCYL10pVvd.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: book3e_64: fix the align size for paca_struct
On Sun, Mar 08, 2015 at 08:13:26PM +1100, Benjamin Herrenschmidt wrote: On Sat, 2015-03-07 at 19:14 +0800, Kevin Hao wrote: All the cache line size of the current book3e 64bit SoCs are 64 bytes. So we should use this size to align the member of paca_struct. With this change we save 192 bytes. Also change it to __aligned(size) since it is preferred over __attribute__((aligned(size))). Why should we favor the book3e CPUs over the book3s ones ? Why do you think so? This only change the align size of the paca_struct's members which are private to book3e CPUs, and should not have any effect to book3s ones. Did I miss something? Thanks, Kevin pgpx9Vdlqxujn.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] powerpc64: use fixed lock token for !CONFIG_PPC_SPLPAR
It makes no sense to use a variant lock token on a platform which doesn't support for shared-processor logical partitions. Actually we can eliminate a memory load by using a fixed lock token on these platforms. Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/include/asm/spinlock.h | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h index 4dbe072eecbe..d303cdad2519 100644 --- a/arch/powerpc/include/asm/spinlock.h +++ b/arch/powerpc/include/asm/spinlock.h @@ -30,7 +30,7 @@ #define smp_mb__after_unlock_lock()smp_mb() /* Full ordering for lock. */ -#ifdef CONFIG_PPC64 +#ifdef CONFIG_PPC_SPLPAR /* use 0x80yy when locked, where yy == CPU number */ #ifdef __BIG_ENDIAN__ #define LOCK_TOKEN (*(u32 *)(get_paca()-lock_token)) @@ -187,9 +187,13 @@ extern void arch_spin_unlock_wait(arch_spinlock_t *lock); #ifdef CONFIG_PPC64 #define __DO_SIGN_EXTEND extsw %0,%0\n -#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */ #else #define __DO_SIGN_EXTEND +#endif + +#ifdef CONFIG_PPC_SPLPAR +#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */ +#else #define WRLOCK_TOKEN (-1) #endif -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] powerpc: book3e_64: fix the align size for paca_struct
All the cache line size of the current book3e 64bit SoCs are 64 bytes. So we should use this size to align the member of paca_struct. With this change we save 192 bytes. Also change it to __aligned(size) since it is preferred over __attribute__((aligned(size))). Before: /* size: 1920, cachelines: 30, members: 46 */ /* sum members: 1667, holes: 6, sum holes: 141 */ /* padding: 112 */ After: /* size: 1728, cachelines: 27, members: 46 */ /* sum members: 1667, holes: 4, sum holes: 13 */ /* padding: 48 */ Signed-off-by: Kevin Hao haoke...@gmail.com --- arch/powerpc/include/asm/paca.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h index e5f22c6c4bf9..70bd4381f8e6 100644 --- a/arch/powerpc/include/asm/paca.h +++ b/arch/powerpc/include/asm/paca.h @@ -106,9 +106,9 @@ struct paca_struct { #endif /* CONFIG_PPC_STD_MMU_64 */ #ifdef CONFIG_PPC_BOOK3E - u64 exgen[8] __attribute__((aligned(0x80))); + u64 exgen[8] __aligned(0x40); /* Keep pgd in the same cacheline as the start of extlb */ - pgd_t *pgd __attribute__((aligned(0x80))); /* Current PGD */ + pgd_t *pgd __aligned(0x40); /* Current PGD */ pgd_t *kernel_pgd; /* Kernel PGD */ /* Shared by all threads of a core -- points to tcd of first thread */ -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 00/11] powerpc: kill PPC_OF
Hi, v2: - Drop the following patches which were already merged. be802bf955a1 (mtd: kconfig: replace PPC_OF with PPC) 0a4a3529df40 (gpio: kconfig: replace PPC_OF with PPC) c31316cb6c5a (usb: kconfig: replace PPC_OF with PPC) f0b66a2cf68e (PCI: Add pci_device_to_OF_node() stub for !CONFIG_OF) - Add the ack in v1 cycle. - Resolve the comments in v1 cycle. We plan to merge this patch series via the powerpc tree in 4.1 cycle. So please ack the corresponding patches if you are OK with these changes. Kevin Hao (11): sata_svw: remove the dependency on PPC_OF fbdev: aty128fb: replace PPC_OF with PPC fbdev: radeon: replace PPC_OF with PPC fbdev: imsttfb: remove the dependency on PPC_OF fbdev: nvidia: remove the dependency on PPC_OF fbdev: riva: remove the dependency on PPC_OF fbdev: remove the unnecessary includes of ppc specific header files fbdev: kconfig: replace PPC_OF with PPC mmc: kconfig: replace PPC_OF with PPC tty: kconfig: remove the superfluous dependency on PPC_OF powerpc: kill PPC_OF arch/powerpc/Kconfig | 3 --- arch/powerpc/Kconfig.debug | 2 +- arch/powerpc/kernel/Makefile | 4 ++-- drivers/ata/sata_svw.c | 11 +-- drivers/mmc/host/Kconfig | 4 ++-- drivers/tty/serial/Kconfig | 4 ++-- drivers/video/fbdev/Kconfig | 4 ++-- drivers/video/fbdev/aty/aty128fb.c | 4 ++-- drivers/video/fbdev/aty/radeon_base.c| 24 drivers/video/fbdev/aty/radeon_monitor.c | 20 ++-- drivers/video/fbdev/aty/radeon_pm.c | 16 drivers/video/fbdev/aty/radeonfb.h | 4 ++-- drivers/video/fbdev/core/fbmon.c | 4 drivers/video/fbdev/imsttfb.c| 6 +- drivers/video/fbdev/nvidia/Makefile | 3 +-- drivers/video/fbdev/nvidia/nv_of.c | 3 --- drivers/video/fbdev/nvidia/nv_proto.h| 8 drivers/video/fbdev/nvidia/nvidia.c | 4 drivers/video/fbdev/riva/fbdev.c | 17 +++-- 19 files changed, 53 insertions(+), 92 deletions(-) -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 01/11] sata_svw: remove the dependency on PPC_OF
The OF functionality has moved to a common place and be used by many archs. So we don't need to include the ppc arch specific header files and depend on PPC_OF option any more. This is a preparation for killing PPC_OF. Signed-off-by: Kevin Hao haoke...@gmail.com Acked-by: Tejun Heo t...@kernel.org --- v2: Add the ack from Tejun Heo. drivers/ata/sata_svw.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c index c630fa812624..4c06f6281d74 100644 --- a/drivers/ata/sata_svw.c +++ b/drivers/ata/sata_svw.c @@ -47,11 +47,7 @@ #include scsi/scsi_cmnd.h #include scsi/scsi.h #include linux/libata.h - -#ifdef CONFIG_PPC_OF -#include asm/prom.h -#include asm/pci-bridge.h -#endif /* CONFIG_PPC_OF */ +#include linux/of.h #define DRV_NAME sata_svw #define DRV_VERSION2.3 @@ -320,7 +316,6 @@ static u8 k2_stat_check_status(struct ata_port *ap) return readl(ap-ioaddr.status_addr); } -#ifdef CONFIG_PPC_OF static int k2_sata_show_info(struct seq_file *m, struct Scsi_Host *shost) { struct ata_port *ap; @@ -350,14 +345,10 @@ static int k2_sata_show_info(struct seq_file *m, struct Scsi_Host *shost) } return 0; } -#endif /* CONFIG_PPC_OF */ - static struct scsi_host_template k2_sata_sht = { ATA_BMDMA_SHT(DRV_NAME), -#ifdef CONFIG_PPC_OF .show_info = k2_sata_show_info, -#endif }; -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 02/11] fbdev: aty128fb: replace PPC_OF with PPC
The PPC_OF is a ppc specific option which is used to mean that the firmware device tree access functions are available. Since all the ppc platforms have a device tree, it is aways set to 'y' for ppc. So it makes no sense to keep a such option in the current kernel. Replace it with PPC. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. drivers/video/fbdev/aty/aty128fb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c index aedf2fbf9bf6..0156954bf340 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -965,7 +965,7 @@ static void __iomem *aty128_find_mem_vbios(struct aty128fb_par *par) /* fill in known card constants if pll_block is not available */ static void aty128_timings(struct aty128fb_par *par) { -#ifdef CONFIG_PPC_OF +#ifdef CONFIG_PPC /* instead of a table lookup, assume OF has properly * setup the PLL registers and use their values * to set the XCLK values and reference divider values */ @@ -979,7 +979,7 @@ static void aty128_timings(struct aty128fb_par *par) if (!par-constants.ref_clk) par-constants.ref_clk = 2950; -#ifdef CONFIG_PPC_OF +#ifdef CONFIG_PPC x_mpll_ref_fb_div = aty_ld_pll(X_MPLL_REF_FB_DIV); xclk_cntl = aty_ld_pll(XCLK_CNTL) 0x7; Nx = (x_mpll_ref_fb_div 0x00ff00) 8; -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 03/11] fbdev: radeon: replace PPC_OF with PPC
The PPC_OF is a ppc specific option which is used to mean that the firmware device tree access functions are available. Since all the ppc platforms have a device tree, it is aways set to 'y' for ppc. So it makes no sense to keep a such option in the current kernel. Replace it with PPC. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. drivers/video/fbdev/Kconfig | 2 +- drivers/video/fbdev/aty/radeon_base.c| 24 drivers/video/fbdev/aty/radeon_monitor.c | 20 ++-- drivers/video/fbdev/aty/radeon_pm.c | 16 drivers/video/fbdev/aty/radeonfb.h | 4 ++-- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index b3dd417b4719..3b818d7a0983 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -1333,7 +1333,7 @@ config FB_RADEON select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT - select FB_MACMODES if PPC_OF + select FB_MACMODES if PPC help Choose this option if you want to use an ATI Radeon graphics card as a framebuffer device. There are both PCI and AGP versions. You diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c index 26d80a4486fb..01237c8fcdc6 100644 --- a/drivers/video/fbdev/aty/radeon_base.c +++ b/drivers/video/fbdev/aty/radeon_base.c @@ -74,7 +74,7 @@ #include asm/io.h #include linux/uaccess.h -#ifdef CONFIG_PPC_OF +#ifdef CONFIG_PPC #include asm/pci-bridge.h #include ../macmodes.h @@ -83,7 +83,7 @@ #include asm/btext.h #endif -#endif /* CONFIG_PPC_OF */ +#endif /* CONFIG_PPC */ #ifdef CONFIG_MTRR #include asm/mtrr.h @@ -418,7 +418,7 @@ static int radeon_find_mem_vbios(struct radeonfb_info *rinfo) } #endif -#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC) +#if defined(CONFIG_PPC) || defined(CONFIG_SPARC) /* * Read XTAL (ref clock), SCLK and MCLK from Open Firmware device * tree. Hopefully, ATI OF driver is kind enough to fill these @@ -448,7 +448,7 @@ static int radeon_read_xtal_OF(struct radeonfb_info *rinfo) return 0; } -#endif /* CONFIG_PPC_OF || CONFIG_SPARC */ +#endif /* CONFIG_PPC || CONFIG_SPARC */ /* * Read PLL infos from chip registers @@ -653,7 +653,7 @@ static void radeon_get_pllinfo(struct radeonfb_info *rinfo) rinfo-pll.ref_div = INPLL(PPLL_REF_DIV) PPLL_REF_DIV_MASK; -#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC) +#if defined(CONFIG_PPC) || defined(CONFIG_SPARC) /* * Retrieve PLL infos from Open Firmware first */ @@ -661,7 +661,7 @@ static void radeon_get_pllinfo(struct radeonfb_info *rinfo) printk(KERN_INFO radeonfb: Retrieved PLL infos from Open Firmware\n); goto found; } -#endif /* CONFIG_PPC_OF || CONFIG_SPARC */ +#endif /* CONFIG_PPC || CONFIG_SPARC */ /* * Check out if we have an X86 which gave us some PLL informations @@ -1910,7 +1910,7 @@ static int radeon_set_fbinfo(struct radeonfb_info *rinfo) * I put the card's memory at 0 in card space and AGP at some random high * local (0xe000 for now) that will be changed by XFree/DRI anyway */ -#ifdef CONFIG_PPC_OF +#ifdef CONFIG_PPC #undef SET_MC_FB_FROM_APERTURE static void fixup_memory_mappings(struct radeonfb_info *rinfo) { @@ -1984,7 +1984,7 @@ static void fixup_memory_mappings(struct radeonfb_info *rinfo) ((aper_base + aper_size - 1) 0x) | (aper_base 16), 0x | (agp_base 16)); } -#endif /* CONFIG_PPC_OF */ +#endif /* CONFIG_PPC */ static void radeon_identify_vram(struct radeonfb_info *rinfo) @@ -2236,7 +2236,7 @@ static int radeonfb_pci_register(struct pci_dev *pdev, rinfo-family == CHIP_FAMILY_RS200) rinfo-errata |= CHIP_ERRATA_PLL_DELAY; -#if defined(CONFIG_PPC_OF) || defined(CONFIG_SPARC) +#if defined(CONFIG_PPC) || defined(CONFIG_SPARC) /* On PPC, we obtain the OF device-node pointer to the firmware * data for this chip */ @@ -2245,14 +2245,14 @@ static int radeonfb_pci_register(struct pci_dev *pdev, printk(KERN_WARNING radeonfb (%s): Cannot match card to OF node !\n, pci_name(rinfo-pdev)); -#endif /* CONFIG_PPC_OF || CONFIG_SPARC */ -#ifdef CONFIG_PPC_OF +#endif /* CONFIG_PPC || CONFIG_SPARC */ +#ifdef CONFIG_PPC /* On PPC, the firmware sets up a memory mapping that tends * to cause lockups when enabling the engine. We reconfigure * the card internal memory mappings properly */ fixup_memory_mappings(rinfo); -#endif /* CONFIG_PPC_OF */ +#endif /* CONFIG_PPC */ /* Get VRAM size and type */ radeon_identify_vram(rinfo); diff --git a/drivers/video/fbdev/aty/radeon_monitor.c b/drivers/video/fbdev/aty/radeon_monitor.c index
[PATCH v2 04/11] fbdev: imsttfb: remove the dependency on PPC_OF
The OF functionality has moved to a common place and be used by many archs. So we don't need to depend on PPC_OF option any more. This is a preparation for killing PPC_OF. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: Only print the error log when CONFIG_OF is enabled. drivers/video/fbdev/imsttfb.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c index aae10ce74f14..9b167f7ef6c6 100644 --- a/drivers/video/fbdev/imsttfb.c +++ b/drivers/video/fbdev/imsttfb.c @@ -1470,15 +1470,13 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) unsigned long addr, size; struct imstt_par *par; struct fb_info *info; -#ifdef CONFIG_PPC_OF struct device_node *dp; dp = pci_device_to_OF_node(pdev); if(dp) printk(KERN_INFO %s: OF name %s\n,__func__, dp-name); - else + else if (IS_ENABLED(CONFIG_OF)) printk(KERN_ERR imsttfb: no OF node for pci device\n); -#endif /* CONFIG_PPC_OF */ info = framebuffer_alloc(sizeof(struct imstt_par), pdev-dev); @@ -1501,11 +1499,9 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) switch (pdev-device) { case PCI_DEVICE_ID_IMS_TT128: /* IMS,tt128mbA */ par-ramdac = IBM; -#ifdef CONFIG_PPC_OF if (dp ((strcmp(dp-name, IMS,tt128mb8) == 0) || (strcmp(dp-name, IMS,tt128mb8A) == 0))) par-ramdac = TVP; -#endif /* CONFIG_PPC_OF */ break; case PCI_DEVICE_ID_IMS_TT3D: /* IMS,tt3d */ par-ramdac = TVP; -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 05/11] fbdev: nvidia: remove the dependency on PPC_OF
The OF functionality has moved to a common place and be used by many archs. So we don't need to include the ppc arch specific header files and depend on PPC_OF option any more. This is a preparation for killing PPC_OF. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. drivers/video/fbdev/nvidia/Makefile | 3 +-- drivers/video/fbdev/nvidia/nv_of.c| 3 --- drivers/video/fbdev/nvidia/nv_proto.h | 8 drivers/video/fbdev/nvidia/nvidia.c | 4 4 files changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/video/fbdev/nvidia/Makefile b/drivers/video/fbdev/nvidia/Makefile index ca47432113e0..917d3eb05feb 100644 --- a/drivers/video/fbdev/nvidia/Makefile +++ b/drivers/video/fbdev/nvidia/Makefile @@ -5,9 +5,8 @@ obj-$(CONFIG_FB_NVIDIA) += nvidiafb.o nvidiafb-y := nvidia.o nv_hw.o nv_setup.o \ - nv_accel.o + nv_accel.o nv_of.o nvidiafb-$(CONFIG_FB_NVIDIA_I2C) += nv_i2c.o nvidiafb-$(CONFIG_FB_NVIDIA_BACKLIGHT) += nv_backlight.o -nvidiafb-$(CONFIG_PPC_OF) += nv_of.o nvidiafb-objs:= $(nvidiafb-y) diff --git a/drivers/video/fbdev/nvidia/nv_of.c b/drivers/video/fbdev/nvidia/nv_of.c index 3bc13df4b120..5f3e5179c25a 100644 --- a/drivers/video/fbdev/nvidia/nv_of.c +++ b/drivers/video/fbdev/nvidia/nv_of.c @@ -19,9 +19,6 @@ #include asm/io.h -#include asm/prom.h -#include asm/pci-bridge.h - #include nv_type.h #include nv_local.h #include nv_proto.h diff --git a/drivers/video/fbdev/nvidia/nv_proto.h b/drivers/video/fbdev/nvidia/nv_proto.h index ff5c410355ea..878a5ce02299 100644 --- a/drivers/video/fbdev/nvidia/nv_proto.h +++ b/drivers/video/fbdev/nvidia/nv_proto.h @@ -42,16 +42,8 @@ int nvidia_probe_i2c_connector(struct fb_info *info, int conn, #define nvidia_probe_i2c_connector(p, c, edid) (-1) #endif -#ifdef CONFIG_PPC_OF int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 ** out_edid); -#else -static inline int nvidia_probe_of_connector(struct fb_info *info, int conn, - u8 ** out_edid) -{ - return -1; -} -#endif /* in nv_accel.c */ extern void NVResetGraphics(struct fb_info *info); diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c index def041204676..4273c6ee8cf6 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c @@ -24,10 +24,6 @@ #ifdef CONFIG_MTRR #include asm/mtrr.h #endif -#ifdef CONFIG_PPC_OF -#include asm/prom.h -#include asm/pci-bridge.h -#endif #ifdef CONFIG_BOOTX_TEXT #include asm/btext.h #endif -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 06/11] fbdev: riva: remove the dependency on PPC_OF
The OF functionality has moved to a common place and be used by many archs. So we don't need to include the ppc arch specific header files and depend on PPC_OF option any more. This is a preparation for killing PPC_OF. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. drivers/video/fbdev/riva/fbdev.c | 17 +++-- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index be73727c7227..294a80908c8c 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -44,10 +44,6 @@ #ifdef CONFIG_MTRR #include asm/mtrr.h #endif -#ifdef CONFIG_PPC_OF -#include asm/prom.h -#include asm/pci-bridge.h -#endif #ifdef CONFIG_PMAC_BACKLIGHT #include asm/machdep.h #include asm/backlight.h @@ -1735,7 +1731,6 @@ static int riva_set_fbinfo(struct fb_info *info) return (rivafb_check_var(info-var, info)); } -#ifdef CONFIG_PPC_OF static int riva_get_EDID_OF(struct fb_info *info, struct pci_dev *pd) { struct riva_par *par = info-par; @@ -1766,9 +1761,8 @@ static int riva_get_EDID_OF(struct fb_info *info, struct pci_dev *pd) NVTRACE_LEAVE(); return 0; } -#endif /* CONFIG_PPC_OF */ -#if defined(CONFIG_FB_RIVA_I2C) !defined(CONFIG_PPC_OF) +#if defined(CONFIG_FB_RIVA_I2C) static int riva_get_EDID_i2c(struct fb_info *info) { struct riva_par *par = info-par; @@ -1828,10 +1822,13 @@ static void riva_update_default_var(struct fb_var_screeninfo *var, static void riva_get_EDID(struct fb_info *info, struct pci_dev *pdev) { NVTRACE_ENTER(); -#ifdef CONFIG_PPC_OF - if (!riva_get_EDID_OF(info, pdev)) + if (riva_get_EDID_OF(info, pdev)) { + NVTRACE_LEAVE(); + return; + } + if (IS_ENABLED(CONFIG_OF)) printk(PFX could not retrieve EDID from OF\n); -#elif defined(CONFIG_FB_RIVA_I2C) +#if defined(CONFIG_FB_RIVA_I2C) if (!riva_get_EDID_i2c(info)) printk(PFX could not retrieve EDID from DDC/I2C\n); #endif -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 07/11] fbdev: remove the unnecessary includes of ppc specific header files
In the current kernel, we don't need to include these arch specific header files for ppc. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. drivers/video/fbdev/core/fbmon.c | 4 1 file changed, 4 deletions(-) diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c index 95338593ebf4..3ae868c58cef 100644 --- a/drivers/video/fbdev/core/fbmon.c +++ b/drivers/video/fbdev/core/fbmon.c @@ -33,10 +33,6 @@ #include video/edid.h #include video/of_videomode.h #include video/videomode.h -#ifdef CONFIG_PPC_OF -#include asm/prom.h -#include asm/pci-bridge.h -#endif #include ../edid.h /* -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 08/11] fbdev: kconfig: replace PPC_OF with PPC
The PPC_OF is a ppc specific option which is used to mean that the firmware device tree access functions are available. Since all the ppc platforms have a device tree, it is aways set to 'y' for ppc. So it makes no sense to keep a such option in the current kernel. Replace it with PPC. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. drivers/video/fbdev/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 3b818d7a0983..109462303087 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -479,7 +479,7 @@ config FB_ATARI config FB_OF bool Open Firmware frame buffer device support - depends on (FB = y) (PPC64 || PPC_OF) (!PPC_PSERIES || PCI) + depends on (FB = y) PPC (!PPC_PSERIES || PCI) select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 09/11] mmc: kconfig: replace PPC_OF with PPC
The PPC_OF is a ppc specific option which is used to mean that the firmware device tree access functions are available. Since all the ppc platforms have a device tree, it is aways set to 'y' for ppc. So it makes no sense to keep a such option in the current kernel. Replace it with PPC. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. drivers/mmc/host/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 61ac63a3776a..7858d7a52818 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -132,7 +132,7 @@ config MMC_SDHCI_OF_ARASAN config MMC_SDHCI_OF_ESDHC tristate SDHCI OF support for the Freescale eSDHC controller depends on MMC_SDHCI_PLTFM - depends on PPC_OF + depends on PPC select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER help This selects the Freescale eSDHC controller support. @@ -144,7 +144,7 @@ config MMC_SDHCI_OF_ESDHC config MMC_SDHCI_OF_HLWD tristate SDHCI OF support for the Nintendo Wii SDHCI controllers depends on MMC_SDHCI_PLTFM - depends on PPC_OF + depends on PPC select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER help This selects the Secure Digital Host Controller Interface (SDHCI) -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 10/11] tty: kconfig: remove the superfluous dependency on PPC_OF
In the current kernel, the CONFIG_PPC_OF is always 'y' for the ppc arch. So we don't need to check it with other ppc specific options. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. drivers/tty/serial/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index d2501f01cd03..77471d3db8d3 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -835,7 +835,7 @@ config SERIAL_MCF_CONSOLE config SERIAL_PMACZILOG tristate Mac or PowerMac z85c30 ESCC support - depends on (M68K MAC) || (PPC_OF PPC_PMAC) + depends on (M68K MAC) || PPC_PMAC select SERIAL_CORE help This driver supports the Zilog z85C30 serial ports found on @@ -1153,7 +1153,7 @@ config SERIAL_OMAP_CONSOLE config SERIAL_OF_PLATFORM_NWPSERIAL tristate NWP serial port driver - depends on PPC_OF PPC_DCR + depends on PPC_DCR select SERIAL_OF_PLATFORM select SERIAL_CORE_CONSOLE select SERIAL_CORE -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 11/11] powerpc: kill PPC_OF
We have set CONFIG_PPC_OF to always 'y' in commit 0a498d96a332 (powerpc: set CONFIG_PPC_OF=y always for ARCH=powerpc) nine years ago. And the arch/ppc also has gone away for many years. The OF functionality was also moved to a common place and be used by many archs. So it does make no sense to keep such a option in the current kernel. Just kill it. Signed-off-by: Kevin Hao haoke...@gmail.com --- v2: No change. arch/powerpc/Kconfig | 3 --- arch/powerpc/Kconfig.debug | 2 +- arch/powerpc/kernel/Makefile | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 5084bdcc6046..1734f8a338eb 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -189,9 +189,6 @@ config ARCH_MAY_HAVE_PC_FDC bool default PCI -config PPC_OF - def_bool y - config PPC_UDBG_16550 bool default n diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug index ec2e40f2cc11..bfd823abff93 100644 --- a/arch/powerpc/Kconfig.debug +++ b/arch/powerpc/Kconfig.debug @@ -117,7 +117,7 @@ config BDI_SWITCH config BOOTX_TEXT bool Support for early boot text console (BootX or OpenFirmware only) - depends on PPC_OF PPC_BOOK3S + depends on PPC_BOOK3S help Say Y here to see progress messages from the boot firmware in text mode. Requires either BootX or Open Firmware. diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 502cf69b6c89..c1ebbdaac28f 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -33,7 +33,8 @@ obj-y := cputable.o ptrace.o syscalls.o \ signal.o sysfs.o cacheinfo.o time.o \ prom.o traps.o setup-common.o \ udbg.o misc.o io.o dma.o \ - misc_$(CONFIG_WORD_SIZE).o vdso32/ + misc_$(CONFIG_WORD_SIZE).o vdso32/ \ + of_platform.o prom_parse.o obj-$(CONFIG_PPC64)+= setup_64.o sys_ppc32.o \ signal_64.o ptrace32.o \ paca.o nvram_64.o firmware.o @@ -47,7 +48,6 @@ obj-$(CONFIG_PPC64) += vdso64/ obj-$(CONFIG_ALTIVEC) += vecemu.o obj-$(CONFIG_PPC_970_NAP) += idle_power4.o obj-$(CONFIG_PPC_P7_NAP) += idle_power7.o -obj-$(CONFIG_PPC_OF) += of_platform.o prom_parse.o procfs-y := proc_powerpc.o obj-$(CONFIG_PROC_FS) += $(procfs-y) rtaspci-$(CONFIG_PPC64)-$(CONFIG_PCI) := rtas_pci.o -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 03/15] fbdev: aty128fb: replace PPC_OF with PPC
On Fri, Feb 27, 2015 at 11:11:15AM +1100, Benjamin Herrenschmidt wrote: On Sat, 2015-01-31 at 21:47 +0800, Kevin Hao wrote: The PPC_OF is a ppc specific option which is used to mean that the firmware device tree access functions are available. Since all the ppc platforms have a device tree, it is aways set to 'y' for ppc. So it makes no sense to keep a such option in the current kernel. Replace it with PPC. Signed-off-by: Kevin Hao haoke...@gmail.com For this and generally the whole series, Acked-by: Benjamin Herrenschmidt b...@kernel.crashing.org Thanks Ben. Which tree do we expect this to go through ? I just sent out a v2 [1] a few hours earlier with some minor updates. We plan to merge this patch series via the powerpc tree in 4.1 cycle if I can collect all the acks from the corresponding driver maintainers. [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-February/125331.html Thanks, Kevin pgpGAzIqKrvcR.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/3] powerpc/dma: Always configure ZONE_DMA32 correctly
On Sun, Feb 22, 2015 at 09:23:51AM +1100, Benjamin Herrenschmidt wrote: No it won't, or am I missing something ? Ie, limit_zone_pfn() will only reduce the size of the window, never increase it. Yes, you are right. Just overlook this. Sorry for the noise. Thanks, Kevin pgpH0IxyneZ4n.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/3] powerpc/dma: Always configure ZONE_DMA32 correctly
On Fri, Feb 20, 2015 at 07:35:25PM +1100, Benjamin Herrenschmidt wrote: We do this for consistency and also in order to support the use of a consistent mask smaller than the dma mask in subsequent patches. Signed-off-by: Benjamin Herrenschmidt b...@kernel.crashing.org --- arch/powerpc/kernel/dma-swiotlb.c | 3 --- arch/powerpc/mm/mem.c | 6 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index 7359797..cb92f94 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -110,9 +110,6 @@ void __init swiotlb_detect_4g(void) { if ((memblock_end_of_DRAM() - 1) 0x) { ppc_swiotlb_enable = 1; -#ifdef CONFIG_ZONE_DMA32 - limit_zone_pfn(ZONE_DMA32, (1ULL 32) PAGE_SHIFT); -#endif } } diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index b7285a5..f146ef0 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -307,6 +307,12 @@ void __init paging_init(void) printk(KERN_DEBUG Memory hole size: %ldMB\n, (long int)((top_of_ram - total_ram) 20)); +#ifdef CONFIG_ZONE_DMA32 + /* Default limit for ZONE_DMA32, platform might limit it + * further due to PCI bridge addressing limitations + */ + limit_zone_pfn(ZONE_DMA32, (1ULL 32) PAGE_SHIFT); +#endif #ifdef CONFIG_HIGHMEM Hmm, won't this break the PCI on the fsl SoCs? The ZONE_DMA32 is set to 2GB due to the PCI inbound window limitation on fsl SoCs. This will override that unconditionally. Please see the commit 84f44cc56c09 (powerpc/fsl-pci: Limit ZONE_DMA32 to 2GiB on 64-bit platforms) for more detail. Thanks, Kevin pgpeiQEYOxi6o.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] mmc: sdhci-pltfm: remove the unneeded check of disabled device
Since commit cd1e65044d44 (of/device: Don't register disabled devices), the disabled device will not be registered at all. So we don't need to do the check again in the platform device driver. And the check in the current code is useless even if we really run into a disabled device. In this case, it just doesn't parse the dtb for the infos such as quirks or clock, but it will continue to try to init the disabled device after that check. So just remove it. Signed-off-by: Kevin Hao haoke...@gmail.com --- drivers/mmc/host/sdhci-pltfm.c | 54 -- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c index c5b01d6bb85d..b609c03a9ef8 100644 --- a/drivers/mmc/host/sdhci-pltfm.c +++ b/drivers/mmc/host/sdhci-pltfm.c @@ -75,43 +75,41 @@ void sdhci_get_of_property(struct platform_device *pdev) u32 bus_width; int size; - if (of_device_is_available(np)) { - if (of_get_property(np, sdhci,auto-cmd12, NULL)) - host-quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12; + if (of_get_property(np, sdhci,auto-cmd12, NULL)) + host-quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12; - if (of_get_property(np, sdhci,1-bit-only, NULL) || - (of_property_read_u32(np, bus-width, bus_width) == 0 - bus_width == 1)) - host-quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA; + if (of_get_property(np, sdhci,1-bit-only, NULL) || + (of_property_read_u32(np, bus-width, bus_width) == 0 + bus_width == 1)) + host-quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA; - if (sdhci_of_wp_inverted(np)) - host-quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT; + if (sdhci_of_wp_inverted(np)) + host-quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT; - if (of_get_property(np, broken-cd, NULL)) - host-quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; + if (of_get_property(np, broken-cd, NULL)) + host-quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; - if (of_get_property(np, no-1-8-v, NULL)) - host-quirks2 |= SDHCI_QUIRK2_NO_1_8_V; + if (of_get_property(np, no-1-8-v, NULL)) + host-quirks2 |= SDHCI_QUIRK2_NO_1_8_V; - if (of_device_is_compatible(np, fsl,p2020-rev1-esdhc)) - host-quirks |= SDHCI_QUIRK_BROKEN_DMA; + if (of_device_is_compatible(np, fsl,p2020-rev1-esdhc)) + host-quirks |= SDHCI_QUIRK_BROKEN_DMA; - if (of_device_is_compatible(np, fsl,p2020-esdhc) || - of_device_is_compatible(np, fsl,p1010-esdhc) || - of_device_is_compatible(np, fsl,t4240-esdhc) || - of_device_is_compatible(np, fsl,mpc8536-esdhc)) - host-quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; + if (of_device_is_compatible(np, fsl,p2020-esdhc) || + of_device_is_compatible(np, fsl,p1010-esdhc) || + of_device_is_compatible(np, fsl,t4240-esdhc) || + of_device_is_compatible(np, fsl,mpc8536-esdhc)) + host-quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; - clk = of_get_property(np, clock-frequency, size); - if (clk size == sizeof(*clk) *clk) - pltfm_host-clock = be32_to_cpup(clk); + clk = of_get_property(np, clock-frequency, size); + if (clk size == sizeof(*clk) *clk) + pltfm_host-clock = be32_to_cpup(clk); - if (of_find_property(np, keep-power-in-suspend, NULL)) - host-mmc-pm_caps |= MMC_PM_KEEP_POWER; + if (of_find_property(np, keep-power-in-suspend, NULL)) + host-mmc-pm_caps |= MMC_PM_KEEP_POWER; - if (of_find_property(np, enable-sdio-wakeup, NULL)) - host-mmc-pm_caps |= MMC_PM_WAKE_SDIO_IRQ; - } + if (of_find_property(np, enable-sdio-wakeup, NULL)) + host-mmc-pm_caps |= MMC_PM_WAKE_SDIO_IRQ; } #else void sdhci_get_of_property(struct platform_device *pdev) {} -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev