[tip: x86/apic] x86/apic: Allow apic::safe_wait_icr_idle() to be NULL

From: tip-bot2 for Thomas Gleixner
Date: Wed Aug 09 2023 - 12:49:44 EST


The following commit has been merged into the x86/apic branch of tip:

Commit-ID: 3080c4e39719539801c233b949afd3d2fe2cb448
Gitweb: https://git.kernel.org/tip/3080c4e39719539801c233b949afd3d2fe2cb448
Author: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
AuthorDate: Tue, 08 Aug 2023 15:04:05 -07:00
Committer: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
CommitterDate: Wed, 09 Aug 2023 08:10:12 -07:00

x86/apic: Allow apic::safe_wait_icr_idle() to be NULL

Remove tons of NOOP callbacks by making the invocation of
safe_wait_icr_idle() conditional in the inline wrapper.

Will be replaced by a static_call_cond() later.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
arch/x86/include/asm/apic.h | 8 +-------
arch/x86/kernel/apic/apic_noop.c | 6 ------
arch/x86/kernel/apic/apic_numachip.c | 8 --------
arch/x86/kernel/apic/x2apic_cluster.c | 1 -
arch/x86/kernel/apic/x2apic_phys.c | 1 -
arch/x86/kernel/apic/x2apic_uv_x.c | 1 -
arch/x86/xen/apic.c | 6 ------
7 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 397cd5f..dd0a05d 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -206,12 +206,6 @@ static inline u32 native_apic_msr_read(u32 reg)
return (u32)msr;
}

-static inline u32 native_safe_x2apic_wait_icr_idle(void)
-{
- /* no need to wait for icr idle in x2apic */
- return 0;
-}
-
static inline void native_x2apic_icr_write(u32 low, u32 id)
{
wrmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), ((__u64) id) << 32 | low);
@@ -376,7 +370,7 @@ static inline void apic_wait_icr_idle(void)

static inline u32 safe_apic_wait_icr_idle(void)
{
- return apic->safe_wait_icr_idle();
+ return apic->safe_wait_icr_idle ? apic->safe_wait_icr_idle() : 0;
}

extern void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v));
diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
index ef31a2e..36c1e28 100644
--- a/arch/x86/kernel/apic/apic_noop.c
+++ b/arch/x86/kernel/apic/apic_noop.c
@@ -27,11 +27,6 @@ static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
return -1;
}

-static u32 noop_safe_apic_wait_icr_idle(void)
-{
- return 0;
-}
-
static u64 noop_apic_icr_read(void)
{
return 0;
@@ -104,5 +99,4 @@ struct apic apic_noop __ro_after_init = {
.eoi_write = noop_apic_write,
.icr_read = noop_apic_icr_read,
.icr_write = noop_apic_icr_write,
- .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle,
};
diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c
index 647ed77..e879dbb 100644
--- a/arch/x86/kernel/apic/apic_numachip.c
+++ b/arch/x86/kernel/apic/apic_numachip.c
@@ -223,12 +223,6 @@ static int numachip2_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
return 1;
}

-/* APIC NMI IPIs are queued */
-static u32 numachip_safe_apic_wait_icr_idle(void)
-{
- return 0;
-}
-
static const struct apic apic_numachip1 __refconst = {
.name = "NumaConnect system",
.probe = numachip1_probe,
@@ -264,7 +258,6 @@ static const struct apic apic_numachip1 __refconst = {
.eoi_write = native_apic_mem_write,
.icr_read = native_apic_icr_read,
.icr_write = native_apic_icr_write,
- .safe_wait_icr_idle = numachip_safe_apic_wait_icr_idle,
};

apic_driver(apic_numachip1);
@@ -304,7 +297,6 @@ static const struct apic apic_numachip2 __refconst = {
.eoi_write = native_apic_mem_write,
.icr_read = native_apic_icr_read,
.icr_write = native_apic_icr_write,
- .safe_wait_icr_idle = numachip_safe_apic_wait_icr_idle,
};

apic_driver(apic_numachip2);
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
index 7ceef70..355da47 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -266,7 +266,6 @@ static struct apic apic_x2apic_cluster __ro_after_init = {
.eoi_write = native_apic_msr_eoi_write,
.icr_read = native_x2apic_icr_read,
.icr_write = native_x2apic_icr_write,
- .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle,
};

apic_driver(apic_x2apic_cluster);
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
index c1ab678..2c9a884 100644
--- a/arch/x86/kernel/apic/x2apic_phys.c
+++ b/arch/x86/kernel/apic/x2apic_phys.c
@@ -180,7 +180,6 @@ static struct apic apic_x2apic_phys __ro_after_init = {
.eoi_write = native_apic_msr_eoi_write,
.icr_read = native_x2apic_icr_read,
.icr_write = native_x2apic_icr_write,
- .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle,
};

apic_driver(apic_x2apic_phys);
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index 5cb68f6..f532c58 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -854,7 +854,6 @@ static struct apic apic_x2apic_uv_x __ro_after_init = {
.eoi_write = native_apic_msr_eoi_write,
.icr_read = native_x2apic_icr_read,
.icr_write = native_x2apic_icr_write,
- .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle,
};

#define UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_LENGTH 3
diff --git a/arch/x86/xen/apic.c b/arch/x86/xen/apic.c
index e709bf0..0f71b2e 100644
--- a/arch/x86/xen/apic.c
+++ b/arch/x86/xen/apic.c
@@ -92,11 +92,6 @@ static void xen_apic_icr_write(u32 low, u32 id)
WARN_ON(1);
}

-static u32 xen_safe_apic_wait_icr_idle(void)
-{
- return 0;
-}
-
static int xen_apic_probe_pv(void)
{
if (xen_pv_domain())
@@ -161,7 +156,6 @@ static struct apic xen_pv_apic = {

.icr_read = xen_apic_icr_read,
.icr_write = xen_apic_icr_write,
- .safe_wait_icr_idle = xen_safe_apic_wait_icr_idle,
};

static void __init xen_apic_check(void)