x86/apic: Get rid of get_physical_broadcast()
authorThomas Gleixner <tglx@linutronix.de>
Tue, 13 Feb 2024 21:04:56 +0000 (22:04 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 15 Feb 2024 21:07:39 +0000 (22:07 +0100)
There is no point for this function. The only case where this is used is
when there is no XAPIC available, which means the broadcast address is 0xF.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Link: https://lore.kernel.org/r/20240212154639.057209154@linutronix.de
arch/x86/kernel/apic/apic.c
arch/x86/kernel/apic/io_apic.c

index 4667bc4b00ab8ae2a6b53f49337baefa397b37a7..814e15c8b8cd5e5a8936bcbe61e9af3f082e1bed 100644 (file)
@@ -261,16 +261,6 @@ u64 native_apic_icr_read(void)
        return icr1 | ((u64)icr2 << 32);
 }
 
-#ifdef CONFIG_X86_32
-/**
- * get_physical_broadcast - Get number of physical broadcast IDs
- */
-int get_physical_broadcast(void)
-{
-       return modern_apic() ? 0xff : 0xf;
-}
-#endif
-
 /**
  * lapic_get_maxlvt - get the maximum number of local vector table entries
  */
index b62c7ee0e6c58dce8a5f4a2dd93c7faaa5f83c2a..a4219b9c0f91bd52489701ef0ec488b915a669d2 100644 (file)
@@ -1460,12 +1460,12 @@ void restore_boot_irq_mode(void)
  */
 static void __init setup_ioapic_ids_from_mpc_nocheck(void)
 {
-       union IO_APIC_reg_00 reg_00;
        physid_mask_t phys_id_present_map;
-       int ioapic_idx;
-       int i;
+       const u32 broadcast_id = 0xF;
+       union IO_APIC_reg_00 reg_00;
        unsigned char old_id;
        unsigned long flags;
+       int ioapic_idx, i;
 
        /*
         * This is broken; anything with a real cpu count has to
@@ -1484,11 +1484,10 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void)
 
                old_id = mpc_ioapic_id(ioapic_idx);
 
-               if (mpc_ioapic_id(ioapic_idx) >= get_physical_broadcast()) {
-                       printk(KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n",
-                               ioapic_idx, mpc_ioapic_id(ioapic_idx));
-                       printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
-                               reg_00.bits.ID);
+               if (mpc_ioapic_id(ioapic_idx) >= broadcast_id) {
+                       pr_err(FW_BUG "IO-APIC#%d ID is %d in the MPC table!...\n",
+                              ioapic_idx, mpc_ioapic_id(ioapic_idx));
+                       pr_err("... fixing up to %d. (tell your hw vendor)\n", reg_00.bits.ID);
                        ioapics[ioapic_idx].mp_config.apicid = reg_00.bits.ID;
                }
 
@@ -1499,15 +1498,14 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void)
                 */
                if (apic->check_apicid_used(&phys_id_present_map,
                                            mpc_ioapic_id(ioapic_idx))) {
-                       printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
-                               ioapic_idx, mpc_ioapic_id(ioapic_idx));
-                       for (i = 0; i < get_physical_broadcast(); i++)
+                       pr_err(FW_BUG "IO-APIC#%d ID %d is already used!...\n",
+                              ioapic_idx, mpc_ioapic_id(ioapic_idx));
+                       for (i = 0; i < broadcast_id; i++)
                                if (!physid_isset(i, phys_id_present_map))
                                        break;
-                       if (i >= get_physical_broadcast())
+                       if (i >= broadcast_id)
                                panic("Max APIC ID exceeded!\n");
-                       printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
-                               i);
+                       pr_err("... fixing up to %d. (tell your hw vendor)\n", i);
                        physid_set(i, phys_id_present_map);
                        ioapics[ioapic_idx].mp_config.apicid = i;
                } else {
@@ -2209,7 +2207,7 @@ static inline void __init check_timer(void)
         * 8259A.
         */
        if (pin1 == -1) {
-               panic_if_irq_remap("BIOS bug: timer not connected to IO-APIC");
+               panic_if_irq_remap(FW_BUG "Timer not connected to IO-APIC");
                pin1 = pin2;
                apic1 = apic2;
                no_pin1 = 1;
@@ -2495,6 +2493,7 @@ unsigned int arch_dynirq_lower_bound(unsigned int from)
 static int io_apic_get_unique_id(int ioapic, int apic_id)
 {
        static physid_mask_t apic_id_map = PHYSID_MASK_NONE;
+       const u32 broadcast_id = 0xF;
        union IO_APIC_reg_00 reg_00;
        unsigned long flags;
        int i = 0;
@@ -2515,9 +2514,9 @@ static int io_apic_get_unique_id(int ioapic, int apic_id)
        reg_00.raw = io_apic_read(ioapic, 0);
        raw_spin_unlock_irqrestore(&ioapic_lock, flags);
 
-       if (apic_id >= get_physical_broadcast()) {
-               printk(KERN_WARNING "IOAPIC[%d]: Invalid apic_id %d, trying "
-                       "%d\n", ioapic, apic_id, reg_00.bits.ID);
+       if (apic_id >= broadcast_id) {
+               pr_warn("IOAPIC[%d]: Invalid apic_id %d, trying %d\n",
+                       ioapic, apic_id, reg_00.bits.ID);
                apic_id = reg_00.bits.ID;
        }
 
@@ -2527,17 +2526,15 @@ static int io_apic_get_unique_id(int ioapic, int apic_id)
         */
        if (apic->check_apicid_used(&apic_id_map, apic_id)) {
 
-               for (i = 0; i < get_physical_broadcast(); i++) {
+               for (i = 0; i < broadcast_id; i++) {
                        if (!apic->check_apicid_used(&apic_id_map, i))
                                break;
                }
 
-               if (i == get_physical_broadcast())
+               if (i == broadcast_id)
                        panic("Max apic_id exceeded!\n");
 
-               printk(KERN_WARNING "IOAPIC[%d]: apic_id %d already used, "
-                       "trying %d\n", ioapic, apic_id, i);
-
+               pr_warn("IOAPIC[%d]: apic_id %d already used, trying %d\n", ioapic, apic_id, i);
                apic_id = i;
        }
 
@@ -2567,11 +2564,9 @@ static int io_apic_get_unique_id(int ioapic, int apic_id)
 
 static u8 io_apic_unique_id(int idx, u8 id)
 {
-       if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
-           !APIC_XAPIC(boot_cpu_apic_version))
+       if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && !APIC_XAPIC(boot_cpu_apic_version))
                return io_apic_get_unique_id(idx, id);
-       else
-               return id;
+       return id;
 }
 #else
 static u8 io_apic_unique_id(int idx, u8 id)