]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/apic: Wrap APIC ID validation into an inline
authorThomas Gleixner <tglx@linutronix.de>
Tue, 8 Aug 2023 22:04:09 +0000 (15:04 -0700)
committerDave Hansen <dave.hansen@linux.intel.com>
Wed, 9 Aug 2023 18:58:30 +0000 (11:58 -0700)
Prepare for removing the callback and making this as simple comparison to
an upper limit, which is the obvious solution to do for limit checks...

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Tested-by: Juergen Gross <jgross@suse.com> # Xen PV (dom0 and unpriv. guest)
arch/x86/include/asm/apic.h
arch/x86/kernel/acpi/boot.c
arch/x86/kernel/apic/vector.c
arch/x86/kernel/smpboot.c
arch/x86/mm/srat.c

index 49b6c7ed2747f85e84987bfc49e3adcdd8065a0e..5a01d51a2970669b99aaad7a5246c0eb94063855 100644 (file)
@@ -372,6 +372,11 @@ static inline u32 safe_apic_wait_icr_idle(void)
        return apic->safe_wait_icr_idle ? apic->safe_wait_icr_idle() : 0;
 }
 
+static inline bool apic_id_valid(u32 apic_id)
+{
+       return apic->apic_id_valid(apic_id);
+}
+
 extern void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v));
 
 #else /* CONFIG_X86_LOCAL_APIC */
index cca1a07096054ef0ed791dc30a8c75434da6685b..7f5b257aaee36d9b63f6da1719067fbc3630b3ca 100644 (file)
@@ -235,7 +235,7 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
         * to not preallocating memory for all NR_CPUS
         * when we use CPU hotplug.
         */
-       if (!apic->apic_id_valid(apic_id)) {
+       if (!apic_id_valid(apic_id)) {
                if (enabled)
                        pr_warn("x2apic entry ignored\n");
                return 0;
index 71feae718a87f5a771d5a701cf879851ff48608c..2ee3f5a20f3da3dd52e22fbc7f15013ffeb37eb7 100644 (file)
@@ -691,7 +691,7 @@ static int x86_vector_select(struct irq_domain *d, struct irq_fwspec *fwspec,
         * if IRQ remapping is enabled. APIC IDs above 15 bits are
         * only permitted if IRQ remapping is enabled, so check that.
         */
-       if (apic->apic_id_valid(32768))
+       if (apic_id_valid(32768))
                return 0;
 
        return x86_fwspec_is_ioapic(fwspec) || x86_fwspec_is_hpet(fwspec);
index df1c5f01411b20926a5c0c8796978a9c2bc4ab91..7349974812383cc442ba059c496274b03b8e6483 100644 (file)
@@ -1064,9 +1064,8 @@ int native_kick_ap(unsigned int cpu, struct task_struct *tidle)
 
        pr_debug("++++++++++++++++++++=_---CPU UP  %u\n", cpu);
 
-       if (apicid == BAD_APICID ||
-           !physid_isset(apicid, phys_cpu_present_map) ||
-           !apic->apic_id_valid(apicid)) {
+       if (apicid == BAD_APICID || !physid_isset(apicid, phys_cpu_present_map) ||
+           !apic_id_valid(apicid)) {
                pr_err("%s: bad cpu %d\n", __func__, cpu);
                return -EINVAL;
        }
index dac07e4f5834ea458f96aab1f6651732965155fb..9c52a95937adecc29f8d85f2469ff72600414ed7 100644 (file)
@@ -40,9 +40,8 @@ acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
                return;
        pxm = pa->proximity_domain;
        apic_id = pa->apic_id;
-       if (!apic->apic_id_valid(apic_id)) {
-               printk(KERN_INFO "SRAT: PXM %u -> X2APIC 0x%04x ignored\n",
-                        pxm, apic_id);
+       if (!apic_id_valid(apic_id)) {
+               pr_info("SRAT: PXM %u -> X2APIC 0x%04x ignored\n", pxm, apic_id);
                return;
        }
        node = acpi_map_pxm_to_node(pxm);