2021-09-03 13:06:16

by Christophe Leroy

[permalink] [raw]
Subject: [RFC PATCH v1 00/11] powerpc/machdep: Remove dust and convert to static calls

The purpose of this series is to convert machine dependent
functions in structure ppc_md into static calls.

First part of the series remove some dust in and around machdep.h

Then some helpers are defined to abstract the access to ppc_md. structure.

Then all plateforms are converted to using those helpers instead of
accessing ppc_md structure directly.

The last patch rewrites the new helpers to use static calls.

Christophe Leroy (11):
powerpc/time: Remove generic_suspend_{dis/en}able_irqs()
powerpc/machdep: Remove stale functions from ppc_md structure
powerpc/machdep: Remove CONFIG_PPC_HAS_FEATURE_CALLS
powerpc/machdep: Make probe_machine() static
powerpc/machdep: Move sys_ctrler_t definition into pmac.h
powerpc/machdep: Add helpers to use ppc_md. functions
powerpc/mpc86xx_hpcn: Remove obsolete statement
powerpc/corenet: Change criteria to set MPIC_ENABLE_COREINT
powerpc/platforms: Use ppc_md. helpers
powerpc/platforms: Use ppc_md_update() instead of define_machine()
powerpc/machdep: Convert ppc_md to static calls

arch/powerpc/include/asm/archrandom.h | 4 +-
arch/powerpc/include/asm/iommu.h | 9 +-
arch/powerpc/include/asm/kexec.h | 1 -
arch/powerpc/include/asm/machdep.h | 136 +++++++++----
arch/powerpc/include/asm/pci.h | 4 +-
arch/powerpc/include/asm/pmac_feature.h | 4 +-
arch/powerpc/kernel/dawr.c | 4 +-
arch/powerpc/kernel/dma-mask.c | 3 +-
arch/powerpc/kernel/epapr_paravirt.c | 2 +-
arch/powerpc/kernel/idle.c | 6 +-
arch/powerpc/kernel/irq.c | 5 +-
arch/powerpc/kernel/mce.c | 7 +-
arch/powerpc/kernel/mce_power.c | 4 +-
arch/powerpc/kernel/nvram_64.c | 18 +-
arch/powerpc/kernel/of_platform.c | 4 +-
arch/powerpc/kernel/pci-common.c | 41 ++--
arch/powerpc/kernel/pci_32.c | 6 +-
arch/powerpc/kernel/pci_64.c | 5 +-
arch/powerpc/kernel/process.c | 4 +-
arch/powerpc/kernel/setup-common.c | 33 ++--
arch/powerpc/kernel/setup_32.c | 12 +-
arch/powerpc/kernel/setup_64.c | 4 +-
arch/powerpc/kernel/swsusp_64.c | 5 -
arch/powerpc/kernel/swsusp_asm64.S | 1 -
arch/powerpc/kernel/sysfs.c | 11 +-
arch/powerpc/kernel/time.c | 50 ++---
arch/powerpc/kernel/traps.c | 11 +-
arch/powerpc/kexec/core.c | 17 +-
arch/powerpc/kexec/core_32.c | 2 +-
arch/powerpc/kexec/core_64.c | 11 +-
arch/powerpc/kexec/crash.c | 6 +-
arch/powerpc/kvm/book3s_hv_ras.c | 3 +-
arch/powerpc/mm/book3s32/mmu.c | 10 +-
arch/powerpc/mm/book3s64/radix_pgtable.c | 2 +-
arch/powerpc/mm/init_32.c | 12 +-
arch/powerpc/mm/mem.c | 6 +-
arch/powerpc/platforms/40x/ppc40x_simple.c | 20 +-
arch/powerpc/platforms/44x/canyonlands.c | 21 +-
arch/powerpc/platforms/44x/ebony.c | 11 +-
arch/powerpc/platforms/44x/fsp2.c | 11 +-
arch/powerpc/platforms/44x/idle.c | 4 +-
arch/powerpc/platforms/44x/iss4xx.c | 15 +-
arch/powerpc/platforms/44x/ppc44x_simple.c | 11 +-
arch/powerpc/platforms/44x/ppc476.c | 28 +--
arch/powerpc/platforms/44x/sam440ep.c | 11 +-
arch/powerpc/platforms/44x/warp.c | 11 +-
arch/powerpc/platforms/4xx/cpm.c | 2 +-
arch/powerpc/platforms/512x/mpc5121_ads.c | 15 +-
arch/powerpc/platforms/512x/mpc512x_generic.c | 13 +-
arch/powerpc/platforms/512x/pdm360ng.c | 13 +-
arch/powerpc/platforms/52xx/efika.c | 36 ++--
arch/powerpc/platforms/52xx/lite5200.c | 23 ++-
arch/powerpc/platforms/52xx/media5200.c | 23 ++-
arch/powerpc/platforms/52xx/mpc5200_simple.c | 23 ++-
arch/powerpc/platforms/52xx/mpc52xx_pci.c | 10 +-
arch/powerpc/platforms/82xx/ep8248e.c | 24 +--
arch/powerpc/platforms/82xx/km82xx.c | 24 +--
arch/powerpc/platforms/82xx/mpc8272_ads.c | 26 +--
arch/powerpc/platforms/82xx/pq2.c | 2 +-
arch/powerpc/platforms/82xx/pq2fads.c | 26 +--
arch/powerpc/platforms/83xx/asp834x.c | 22 ++-
arch/powerpc/platforms/83xx/km83xx.c | 22 ++-
arch/powerpc/platforms/83xx/misc.c | 3 +-
arch/powerpc/platforms/83xx/mpc830x_rdb.c | 22 ++-
arch/powerpc/platforms/83xx/mpc831x_rdb.c | 22 ++-
arch/powerpc/platforms/83xx/mpc832x_mds.c | 14 +-
arch/powerpc/platforms/83xx/mpc832x_rdb.c | 22 ++-
arch/powerpc/platforms/83xx/mpc834x_itx.c | 22 ++-
arch/powerpc/platforms/83xx/mpc834x_mds.c | 22 ++-
arch/powerpc/platforms/83xx/mpc836x_mds.c | 22 ++-
arch/powerpc/platforms/83xx/mpc836x_rdk.c | 22 ++-
arch/powerpc/platforms/83xx/mpc837x_mds.c | 22 ++-
arch/powerpc/platforms/83xx/mpc837x_rdb.c | 22 ++-
arch/powerpc/platforms/85xx/bsc913x_qds.c | 25 +--
arch/powerpc/platforms/85xx/bsc913x_rdb.c | 19 +-
arch/powerpc/platforms/85xx/c293pcie.c | 21 +-
arch/powerpc/platforms/85xx/corenet_generic.c | 68 ++++---
arch/powerpc/platforms/85xx/ge_imp3a.c | 29 +--
arch/powerpc/platforms/85xx/ksi8560.c | 21 +-
arch/powerpc/platforms/85xx/mpc8536_ds.c | 27 +--
arch/powerpc/platforms/85xx/mpc85xx_ads.c | 21 +-
arch/powerpc/platforms/85xx/mpc85xx_cds.c | 37 ++--
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 77 ++++----
arch/powerpc/platforms/85xx/mpc85xx_mds.c | 74 ++++---
arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 184 +++++++-----------
arch/powerpc/platforms/85xx/mvme2500.c | 27 +--
arch/powerpc/platforms/85xx/p1010rdb.c | 32 +--
arch/powerpc/platforms/85xx/p1022_ds.c | 27 +--
arch/powerpc/platforms/85xx/p1022_rdk.c | 27 +--
arch/powerpc/platforms/85xx/p1023_rdb.c | 26 +--
arch/powerpc/platforms/85xx/ppa8548.c | 21 +-
arch/powerpc/platforms/85xx/qemu_e500.c | 26 +--
arch/powerpc/platforms/85xx/sgy_cts1000.c | 4 +-
arch/powerpc/platforms/85xx/smp.c | 7 +-
arch/powerpc/platforms/85xx/socrates.c | 20 +-
arch/powerpc/platforms/85xx/stx_gp3.c | 21 +-
arch/powerpc/platforms/85xx/tqm85xx.c | 21 +-
arch/powerpc/platforms/85xx/twr_p102x.c | 25 +--
arch/powerpc/platforms/85xx/xes_mpc85xx.c | 61 +++---
arch/powerpc/platforms/86xx/gef_ppc9a.c | 27 +--
arch/powerpc/platforms/86xx/gef_sbc310.c | 27 +--
arch/powerpc/platforms/86xx/gef_sbc610.c | 27 +--
arch/powerpc/platforms/86xx/mpc8610_hpcd.c | 28 +--
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 38 ++--
arch/powerpc/platforms/86xx/mvme7100.c | 27 +--
arch/powerpc/platforms/8xx/adder875.c | 18 +-
arch/powerpc/platforms/8xx/ep88xc.c | 18 +-
arch/powerpc/platforms/8xx/mpc86xads_setup.c | 22 ++-
arch/powerpc/platforms/8xx/mpc885ads_setup.c | 18 +-
arch/powerpc/platforms/8xx/tqm8xx_setup.c | 22 ++-
arch/powerpc/platforms/amigaone/setup.c | 47 +++--
arch/powerpc/platforms/cell/interrupt.c | 2 +-
arch/powerpc/platforms/cell/pervasive.c | 4 +-
arch/powerpc/platforms/cell/ras.c | 2 +-
arch/powerpc/platforms/cell/setup.c | 23 +--
arch/powerpc/platforms/chrp/nvram.c | 6 +-
arch/powerpc/platforms/chrp/setup.c | 48 ++---
arch/powerpc/platforms/embedded6xx/gamecube.c | 15 +-
arch/powerpc/platforms/embedded6xx/holly.c | 28 +--
.../platforms/embedded6xx/linkstation.c | 17 +-
.../platforms/embedded6xx/mpc7448_hpc2.c | 29 +--
arch/powerpc/platforms/embedded6xx/mvme5100.c | 25 +--
.../platforms/embedded6xx/storcenter.c | 18 +-
arch/powerpc/platforms/embedded6xx/wii.c | 20 +-
arch/powerpc/platforms/maple/pci.c | 2 +-
arch/powerpc/platforms/maple/setup.c | 33 ++--
arch/powerpc/platforms/microwatt/rng.c | 2 +-
arch/powerpc/platforms/microwatt/setup.c | 12 +-
arch/powerpc/platforms/pasemi/idle.c | 4 +-
arch/powerpc/platforms/pasemi/setup.c | 19 +-
arch/powerpc/platforms/powermac/nvram.c | 44 ++---
arch/powerpc/platforms/powermac/pci.c | 2 +-
arch/powerpc/platforms/powermac/pic.c | 4 +-
arch/powerpc/platforms/powermac/pmac.h | 12 ++
arch/powerpc/platforms/powermac/setup.c | 47 ++---
arch/powerpc/platforms/powermac/smp.c | 18 +-
arch/powerpc/platforms/powernv/eeh-powernv.c | 2 +-
arch/powerpc/platforms/powernv/idle.c | 4 +-
arch/powerpc/platforms/powernv/opal-nvram.c | 6 +-
arch/powerpc/platforms/powernv/pci-ioda.c | 12 +-
arch/powerpc/platforms/powernv/rng.c | 4 +-
arch/powerpc/platforms/powernv/setup.c | 109 ++++++-----
arch/powerpc/platforms/powernv/smp.c | 2 +-
arch/powerpc/platforms/ps3/interrupt.c | 2 +-
arch/powerpc/platforms/ps3/setup.c | 55 +++---
arch/powerpc/platforms/pseries/eeh_pseries.c | 2 +-
arch/powerpc/platforms/pseries/hotplug-cpu.c | 4 +-
arch/powerpc/platforms/pseries/msi.c | 4 +-
arch/powerpc/platforms/pseries/nvram.c | 8 +-
arch/powerpc/platforms/pseries/pci.c | 4 +-
arch/powerpc/platforms/pseries/rng.c | 2 +-
arch/powerpc/platforms/pseries/setup.c | 80 ++++----
arch/powerpc/sysdev/dart_iommu.c | 2 +-
arch/powerpc/sysdev/fsl_pci.c | 6 +-
arch/powerpc/sysdev/indirect_pci.c | 8 +-
arch/powerpc/sysdev/mmio_nvram.c | 10 +-
arch/powerpc/sysdev/mpic.c | 6 +-
arch/powerpc/sysdev/tsi108_pci.c | 8 +-
arch/powerpc/sysdev/xics/xics-common.c | 2 +-
arch/powerpc/sysdev/xive/common.c | 2 +-
arch/powerpc/xmon/xmon.c | 4 +-
drivers/ata/pata_macio.c | 10 +-
drivers/char/nvram.c | 4 +-
drivers/macintosh/via-pmu.c | 4 +-
include/linux/nvram.h | 19 +-
sound/ppc/pmac.c | 3 +-
166 files changed, 1685 insertions(+), 1531 deletions(-)

--
2.25.0


2021-09-03 13:07:46

by Christophe Leroy

[permalink] [raw]
Subject: [RFC PATCH v1 03/11] powerpc/machdep: Remove CONFIG_PPC_HAS_FEATURE_CALLS

Last user was removed by commit 7bbd827750e6 ("[PATCH] ppc64: very
basic desktop g5 sound support").

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/include/asm/machdep.h | 5 -----
1 file changed, 5 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index a68311077d32..f6f8344f4a0c 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -10,11 +10,6 @@

#include <asm/setup.h>

-/* We export this macro for external modules like Alsa to know if
- * ppc_md.feature_call is implemented or not
- */
-#define CONFIG_PPC_HAS_FEATURE_CALLS
-
struct pt_regs;
struct pci_bus;
struct device_node;
--
2.25.0

2021-09-03 13:07:46

by Christophe Leroy

[permalink] [raw]
Subject: [RFC PATCH v1 01/11] powerpc/time: Remove generic_suspend_{dis/en}able_irqs()

Commit d75d68cfef49 ("powerpc: Clean up obsolete code relating to
decrementer and timebase") made generic_suspend_enable_irqs() and
generic_suspend_disable_irqs() static.

Fold them into their only caller.

Reviewed-by: Daniel Axtens <[email protected]>
Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/kernel/time.c | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 934d8ae66cc6..cae8f03a44fe 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -631,8 +631,12 @@ void timer_broadcast_interrupt(void)
#endif

#ifdef CONFIG_SUSPEND
-static void generic_suspend_disable_irqs(void)
+/* Overrides the weak version in kernel/power/main.c */
+void arch_suspend_disable_irqs(void)
{
+ if (ppc_md.suspend_disable_irqs)
+ ppc_md.suspend_disable_irqs();
+
/* Disable the decrementer, so that it doesn't interfere
* with suspending.
*/
@@ -642,23 +646,11 @@ static void generic_suspend_disable_irqs(void)
set_dec(decrementer_max);
}

-static void generic_suspend_enable_irqs(void)
-{
- local_irq_enable();
-}
-
-/* Overrides the weak version in kernel/power/main.c */
-void arch_suspend_disable_irqs(void)
-{
- if (ppc_md.suspend_disable_irqs)
- ppc_md.suspend_disable_irqs();
- generic_suspend_disable_irqs();
-}
-
/* Overrides the weak version in kernel/power/main.c */
void arch_suspend_enable_irqs(void)
{
- generic_suspend_enable_irqs();
+ local_irq_enable();
+
if (ppc_md.suspend_enable_irqs)
ppc_md.suspend_enable_irqs();
}
--
2.25.0

2021-09-03 13:08:00

by Christophe Leroy

[permalink] [raw]
Subject: [RFC PATCH v1 04/11] powerpc/machdep: Make probe_machine() static

Since commit b1923caa6e64 ("powerpc: Merge 32-bit and 64-bit
setup_arch()") probe_machine has only been called from the
file in which it is defined. So it can be static.

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/include/asm/machdep.h | 2 --
arch/powerpc/kernel/setup-common.c | 2 +-
2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index f6f8344f4a0c..a50aed6170c3 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -230,8 +230,6 @@ extern struct machdep_calls *machine_id;
machine_id == &mach_##name; \
})

-extern void probe_machine(void);
-
#ifdef CONFIG_PPC_PMAC
/*
* Power macintoshes have either a CUDA, PMU or SMU controlling
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 0b7894eed58d..96e88209e605 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -582,7 +582,7 @@ static __init int add_pcspkr(void)
device_initcall(add_pcspkr);
#endif /* CONFIG_PCSPKR_PLATFORM */

-void probe_machine(void)
+static void probe_machine(void)
{
extern struct machdep_calls __machine_desc_start;
extern struct machdep_calls __machine_desc_end;
--
2.25.0

2021-09-03 13:08:00

by Christophe Leroy

[permalink] [raw]
Subject: [RFC PATCH v1 06/11] powerpc/machdep: Add helpers to use ppc_md. functions

As a preparation to converting ppc_md functions to static
calls, add helpers to play with ppc_md. functions.

Signed-off-by: Christophe Leroy <[email protected]>
---
arch/powerpc/include/asm/machdep.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 9f31281095ab..51949ab0abfe 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -203,6 +203,11 @@ struct machdep_calls {
#endif
};

+#define ppc_md_call(func) ppc_md.func
+#define ppc_md_has(func) (ppc_md.func)
+#define ppc_md_call_cond(func) if (ppc_md_has(func)) ppc_md_call(func)
+#define ppc_md_update(func, f) ppc_md.func = f
+
extern void e500_idle(void);
extern void power4_idle(void);
extern void ppc6xx_idle(void);
--
2.25.0

2022-02-16 13:21:38

by Michael Ellerman

[permalink] [raw]
Subject: Re: [RFC PATCH v1 00/11] powerpc/machdep: Remove dust and convert to static calls

On Fri, 3 Sep 2021 11:18:34 +0000 (UTC), Christophe Leroy wrote:
> The purpose of this series is to convert machine dependent
> functions in structure ppc_md into static calls.
>
> First part of the series remove some dust in and around machdep.h
>
> Then some helpers are defined to abstract the access to ppc_md. structure.
>
> [...]

Patches 3, 5, 7 and 8 applied to powerpc/next.

[03/11] powerpc/machdep: Remove CONFIG_PPC_HAS_FEATURE_CALLS
https://git.kernel.org/powerpc/c/d6a6c725a20467f52a41270bdaad9565c66f3b7a
[05/11] powerpc/machdep: Move sys_ctrler_t definition into pmac.h
https://git.kernel.org/powerpc/c/e6d03ac156db84422519aa8628efc210d24bf889
[07/11] powerpc/mpc86xx_hpcn: Remove obsolete statement
https://git.kernel.org/powerpc/c/fae65a9ac8fd2221dbf034019fa18d72b2b0c8e9
[08/11] powerpc/corenet: Change criteria to set MPIC_ENABLE_COREINT
https://git.kernel.org/powerpc/c/66ada2907864cafa4578b92926cb8bc0a4bc8c9c

cheers