From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH v1 11/11] powerpc/machdep: Convert ppc_md to static calls
Date: Fri, 3 Sep 2021 11:18:46 +0000 (UTC) [thread overview]
Message-ID: <607973ee856b5b144ca7e0506fcd8efbbc14868a.1630667613.git.christophe.leroy@csgroup.eu> (raw)
In-Reply-To: <cover.1630667612.git.christophe.leroy@csgroup.eu>
Static calls are global structures declared with DECLARE_STATIC_CALL()
and defined with DEFINE_STATIC_CALL().
All fonction prototypes are moved out of struct machdep_calls into
struct machdep_calls_ops. That new struct won't be instanciated, it
is only used as a support for carriing fonction prototypes and use
them to declare/define associated static calls.
In order to limit test copies which are error prone, define a macro
called PPC_MD_CALL, which either declare the call or defines it
based on the definition of GENERATING_PPC_MD_STATIC_CALLS_DEFINITIONS
that will be defined in and only in kernel/setup-common.c as a
replacement of ppc_md instance.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/machdep.h | 101 +++++++++++++++++++++++++++--
arch/powerpc/kernel/setup-common.c | 2 +
2 files changed, 98 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index ed5a1b5be7b5..3898c7a770b8 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -7,6 +7,7 @@
#include <linux/init.h>
#include <linux/dma-mapping.h>
#include <linux/export.h>
+#include <linux/static_call.h>
#include <asm/setup.h>
@@ -22,6 +23,10 @@ struct pci_host_bridge;
struct machdep_calls {
char *name;
+ int (*probe)(void);
+};
+
+struct machdep_ops {
#ifdef CONFIG_PPC64
#ifdef CONFIG_PM
void (*iommu_restore)(void);
@@ -33,7 +38,6 @@ struct machdep_calls {
void (*dma_set_mask)(struct device *dev, u64 dma_mask);
- int (*probe)(void);
void (*setup_arch)(void); /* Optional, may be NULL */
/* Optional, may be NULL. */
void (*show_cpuinfo)(struct seq_file *m);
@@ -203,10 +207,97 @@ 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
+#define ppc_md_call(func) static_call(ppc_md_##func)
+#define ppc_md_has(func) static_call_query(ppc_md_##func)
+#define ppc_md_call_cond(func) static_call_cond(ppc_md_##func)
+#define ppc_md_update(func, f) static_call_update(ppc_md_##func, f)
+
+#ifdef GENERATING_PPC_MD_STATIC_CALLS_DEFINITIONS
+#define PPC_MD_CALL(f) DEFINE_STATIC_CALL_NULL(ppc_md_##f, (*((struct machdep_ops *)NULL)->f))
+#else
+#define PPC_MD_CALL(f) DECLARE_STATIC_CALL(ppc_md_##f, (*((struct machdep_ops *)NULL)->f))
+#endif
+
+#ifdef CONFIG_PPC64
+#ifdef CONFIG_PM
+PPC_MD_CALL(iommu_restore);
+#endif
+#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
+PPC_MD_CALL(memory_block_size);
+#endif
+#endif /* CONFIG_PPC64 */
+PPC_MD_CALL(dma_set_mask);
+PPC_MD_CALL(setup_arch);
+PPC_MD_CALL(show_cpuinfo);
+PPC_MD_CALL(get_proc_freq);
+PPC_MD_CALL(init_IRQ);
+PPC_MD_CALL(get_irq);
+PPC_MD_CALL(pcibios_fixup);
+PPC_MD_CALL(pci_irq_fixup);
+PPC_MD_CALL(pcibios_root_bridge_prepare);
+PPC_MD_CALL(discover_phbs);
+PPC_MD_CALL(pci_setup_phb);
+PPC_MD_CALL(restart);
+PPC_MD_CALL(halt);
+PPC_MD_CALL(panic);
+PPC_MD_CALL(time_init);
+PPC_MD_CALL(set_rtc_time);
+PPC_MD_CALL(get_rtc_time);
+PPC_MD_CALL(get_boot_time);
+PPC_MD_CALL(calibrate_decr);
+PPC_MD_CALL(progress);
+PPC_MD_CALL(log_error);
+PPC_MD_CALL(nvram_read_val);
+PPC_MD_CALL(nvram_write_val);
+PPC_MD_CALL(nvram_write);
+PPC_MD_CALL(nvram_read);
+PPC_MD_CALL(nvram_size);
+PPC_MD_CALL(nvram_sync);
+PPC_MD_CALL(system_reset_exception);
+PPC_MD_CALL(machine_check_exception);
+PPC_MD_CALL(handle_hmi_exception);
+PPC_MD_CALL(hmi_exception_early);
+PPC_MD_CALL(machine_check_early);
+PPC_MD_CALL(mce_check_early_recovery);
+PPC_MD_CALL(feature_call);
+PPC_MD_CALL(pci_get_legacy_ide_irq);
+PPC_MD_CALL(phys_mem_access_prot);
+PPC_MD_CALL(power_save);
+PPC_MD_CALL(enable_pmcs);
+PPC_MD_CALL(set_dabr);
+PPC_MD_CALL(set_dawr);
+#ifdef CONFIG_PPC32
+PPC_MD_CALL(init);
+PPC_MD_CALL(pcibios_after_init);
+#endif
+PPC_MD_CALL(pci_exclude_device);
+PPC_MD_CALL(pcibios_fixup_resources);
+PPC_MD_CALL(pcibios_fixup_bus);
+PPC_MD_CALL(pcibios_fixup_phb);
+PPC_MD_CALL(pcibios_bus_add_device);
+PPC_MD_CALL(pcibios_default_alignment);
+#ifdef CONFIG_PCI_IOV
+PPC_MD_CALL(pcibios_fixup_sriov);
+PPC_MD_CALL(pcibios_iov_resource_alignment);
+PPC_MD_CALL(pcibios_sriov_enable);
+PPC_MD_CALL(pcibios_sriov_disable);
+#endif
+PPC_MD_CALL(machine_shutdown);
+#ifdef CONFIG_KEXEC_CORE
+PPC_MD_CALL(kexec_cpu_down);
+PPC_MD_CALL(machine_kexec);
+#endif
+#ifdef CONFIG_SUSPEND
+PPC_MD_CALL(suspend_disable_irqs);
+PPC_MD_CALL(suspend_enable_irqs);
+#endif
+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
+PPC_MD_CALL(cpu_probe);
+PPC_MD_CALL(cpu_release);
+#endif
+#ifdef CONFIG_ARCH_RANDOM
+PPC_MD_CALL(get_random_seed);
+#endif
extern void e500_idle(void);
extern void power4_idle(void);
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 9e2e1c4c6c62..e9acb1186cf5 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -8,6 +8,8 @@
#undef DEBUG
+#define GENERATING_PPC_MD_STATIC_CALLS_DEFINITIONS
+
#include <linux/export.h>
#include <linux/panic_notifier.h>
#include <linux/string.h>
--
2.25.0
next prev parent reply other threads:[~2021-09-03 11:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-03 11:18 [RFC PATCH v1 00/11] powerpc/machdep: Remove dust and convert to static calls Christophe Leroy
2021-09-03 11:18 ` [RFC PATCH v1 01/11] powerpc/time: Remove generic_suspend_{dis/en}able_irqs() Christophe Leroy
2021-09-03 11:18 ` [RFC PATCH v1 02/11] powerpc/machdep: Remove stale functions from ppc_md structure Christophe Leroy
2021-09-03 11:18 ` [RFC PATCH v1 03/11] powerpc/machdep: Remove CONFIG_PPC_HAS_FEATURE_CALLS Christophe Leroy
2021-09-03 11:18 ` [RFC PATCH v1 04/11] powerpc/machdep: Make probe_machine() static Christophe Leroy
2021-09-03 11:18 ` [RFC PATCH v1 05/11] powerpc/machdep: Move sys_ctrler_t definition into pmac.h Christophe Leroy
2022-02-07 11:18 ` Michael Ellerman
2021-09-03 11:18 ` [RFC PATCH v1 06/11] powerpc/machdep: Add helpers to use ppc_md. functions Christophe Leroy
2021-09-03 11:18 ` [RFC PATCH v1 07/11] powerpc/mpc86xx_hpcn: Remove obsolete statement Christophe Leroy
2021-09-03 11:18 ` [RFC PATCH v1 08/11] powerpc/corenet: Change criteria to set MPIC_ENABLE_COREINT Christophe Leroy
2021-09-03 11:18 ` [RFC PATCH v1 09/11] powerpc/platforms: Use ppc_md. helpers Christophe Leroy
2021-09-03 11:18 ` [RFC PATCH v1 10/11] powerpc/platforms: Use ppc_md_update() instead of define_machine() Christophe Leroy
2021-09-03 11:18 ` Christophe Leroy [this message]
2022-02-16 12:25 ` [RFC PATCH v1 00/11] powerpc/machdep: Remove dust and convert to static calls Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=607973ee856b5b144ca7e0506fcd8efbbc14868a.1630667613.git.christophe.leroy@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).