Skip to contentSkip to conversation

Untangle mach-generic/

PATCH In review Andrew Cooper 2 participants 16 messages Nov 8, 2024 – Nov 11, 2024

lore
Share & tools
lore
#0 lore raw

cover Untangle mach-generic/

There's only one header file left. More than half of it is totally useless, and the rest has better places to live in the tree.

This lets us drop a compiler include path.

Andrew Cooper (10):
VT-d: Drop includes of mach_apic.h
x86: Drop includes of mach_apic.h
x86/mach-apic: Move generic_*_probe() declarations into genapic.h x86/mach-apic: Drop apic_id_registered() x86/mach-apic: Drop ioapic_phys_id_map() x86/mach-apic: Drop check_apicid_used()
x86/mach-apic: Drop check_apicid_present() x86/mach-apic: Drop set_apicid()
x86/mach-apic: Move the genapic wrappers to genapic.h
x86: Delete mach_apic.h

 xen/arch/x86/acpi/boot.c                      |  2 +-
 xen/arch/x86/apic.c                           |  7 +-
 xen/arch/x86/arch.mk                          |  1 -
 xen/arch/x86/cpu/common.c                     |  1 -
 xen/arch/x86/cpu/intel.c                      |  2 -
 xen/arch/x86/genapic/delivery.c               |  3 +-
 xen/arch/x86/hpet.c                           |  3 +-
 xen/arch/x86/include/asm/genapic.h            | 20 +++++
 .../x86/include/asm/mach-generic/mach_apic.h  | 77 -------------------
 xen/arch/x86/io_apic.c                        | 32 ++++----
 xen/arch/x86/irq.c                            |  6 +-
 xen/arch/x86/mpparse.c                        |  7 +-
 xen/arch/x86/msi.c                            |  6 +-
 xen/arch/x86/setup.c                          |  3 +-
 xen/arch/x86/smp.c                            |  4 +-
 xen/arch/x86/smpboot.c                        |  6 +-
 xen/arch/x86/x86_64/acpi_mmcfg.c              |  1 -
 xen/drivers/passthrough/vtd/iommu.c           |  5 +-
 xen/drivers/passthrough/vtd/quirks.c          |  4 +-
 19 files changed, 72 insertions(+), 118 deletions(-)
 delete mode 100644 xen/arch/x86/include/asm/mach-generic/mach_apic.h
Signature · 1 line
2.39.5
#1 lore raw

PATCH 1/10 VT-d: Drop includes of mach_apic.h

Neither iommu.c nor quirks.c use any functionality. iommu.c only uses it to transitively include apic.h and io_apic.h, while quirks.c is only depending on the ACLINUX wrapping of strtoul() which we spell simple_strtoul() everywhere else in Xen.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/drivers/passthrough/vtd/iommu.c  | 5 ++++-
 xen/drivers/passthrough/vtd/quirks.c | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)
xen/drivers/passthrough/vtd/iommu.c +4 -1
index e13be244c130..27a4d1640189 100644
@@ -31,12 +31,15 @@
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
 #include <xen/keyhandler.h>
+
+#include <asm/apic.h>
+#include <asm/io_apic.h>
 #include <asm/msi.h>
 #include <asm/nops.h>
 #include <asm/irq.h>
 #include <asm/hvm/vmx/vmx.h>
 #include <asm/p2m.h>
-#include <mach_apic.h>
+
 #include "iommu.h"
 #include "dmar.h"
 #include "extern.h"
xen/drivers/passthrough/vtd/quirks.c +2 -2
index 950dcd56ef8a..dc3dac749ce6 100644
@@ -32,7 +32,7 @@
 #include <asm/msi.h>
 #include <asm/irq.h>
 #include <asm/pci.h>
-#include <mach_apic.h>
+
 #include "iommu.h"
 #include "dmar.h"
 #include "extern.h"
@@ -321,7 +321,7 @@ static int __init cf_check parse_snb_timeout(const char *s)
         else if ( strcmp(s, "cap") == 0 )
             t = SNB_IGD_TIMEOUT;
         else
-            t = strtoul(s, &q, 0);
+            t = simple_strtoul(s, &q, 0);
     }
     else
         t = t ? SNB_IGD_TIMEOUT_LEGACY : 0;
Signature · 1 line
2.39.5
#2 lore raw

PATCH 2/10 x86: Drop includes of mach_apic.h

In reply to Andrew Cooper

A number of files don't need mach_apic.h at all, or only need transitive dependenices. Drop the includes.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/cpu/common.c        | 1 -
 xen/arch/x86/cpu/intel.c         | 2 --
 xen/arch/x86/genapic/delivery.c  | 3 ++-
 xen/arch/x86/hpet.c              | 3 ++-
 xen/arch/x86/smp.c               | 4 +++-
 xen/arch/x86/x86_64/acpi_mmcfg.c | 1 -
 6 files changed, 7 insertions(+), 7 deletions(-)
xen/arch/x86/cpu/common.c +0 -1
index ff4cd2289797..067d855badf0 100644
@@ -18,7 +18,6 @@
 #include <asm/random.h>
 #include <asm/setup.h>
 #include <asm/shstk.h>
-#include <mach_apic.h>
 #include <public/sysctl.h> /* for XEN_INVALID_{SOCKET,CORE}_ID */
 
 #include "cpu.h"
xen/arch/x86/cpu/intel.c +0 -2
index 807b708217e9..6a7347968ba2 100644
@@ -14,8 +14,6 @@
 #include <asm/i387.h>
 #include <asm/trampoline.h>
 
-#include <mach_apic.h>
-
 #include "cpu.h"
 
 /*
xen/arch/x86/genapic/delivery.c +2 -1
index 3def78f380d3..7bb7bd658650 100644
@@ -1,9 +1,10 @@
 #include <xen/irq.h>
 #include <xen/sched.h>
+
+#include <asm/apic.h>
 #include <asm/current.h>
 #include <asm/smp.h>
 #include <asm/hardirq.h>
-#include <mach_apic.h>
 
 /*
  * LOGICAL FLAT DELIVERY MODE (multicast via bitmask to <= 8 logical APIC IDs).
xen/arch/x86/hpet.c +2 -1
index 2f54d3188966..51ff7f12f5c0 100644
@@ -13,11 +13,12 @@
 #include <xen/numa.h>
 #include <xen/param.h>
 #include <xen/sched.h>
+
+#include <asm/apic.h>
 #include <asm/fixmap.h>
 #include <asm/div64.h>
 #include <asm/hpet.h>
 #include <asm/msi.h>
-#include <mach_apic.h>
 #include <xen/cpuidle.h>
 
 #define MAX_DELTA_NS MILLISECS(10*1000)
xen/arch/x86/smp.c +3 -1
index 04c6a0572319..bd337e548c5a 100644
@@ -14,7 +14,10 @@
 #include <xen/delay.h>
 #include <xen/perfc.h>
 #include <xen/spinlock.h>
+
+#include <asm/apic.h>
 #include <asm/current.h>
+#include <asm/genapic.h>
 #include <asm/guest.h>
 #include <asm/smp.h>
 #include <asm/mc146818rtc.h>
@@ -23,7 +26,6 @@
 #include <asm/hpet.h>
 #include <asm/setup.h>
 #include <irq_vectors.h>
-#include <mach_apic.h>
 
 /* Helper functions to prepare APIC register values. */
 static unsigned int prepare_ICR(unsigned int shortcut, int vector)
xen/arch/x86/x86_64/acpi_mmcfg.c +0 -1
index 7b0904622931..7fe5663c5984 100644
@@ -37,7 +37,6 @@
 #include <asm/io.h>
 #include <asm/mpspec.h>
 #include <asm/processor.h>
-#include <mach_apic.h>
 
 #include "mmconfig.h"
 
Signature · 1 line
2.39.5
#3 lore raw

PATCH 3/10 x86/mach-apic: Move generic_*_probe() declarations into genapic.h

In reply to Andrew Cooper

... as the implementations are in genapic/probe.c

This covers the only functions that both setup.c and boot.c were including mach_apic.h for, although setup.c was depending on io_apic.h transitively too.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/acpi/boot.c                          | 2 +-
 xen/arch/x86/include/asm/genapic.h                | 3 +++
 xen/arch/x86/include/asm/mach-generic/mach_apic.h | 3 ---
 xen/arch/x86/setup.c                              | 3 ++-
 4 files changed, 6 insertions(+), 5 deletions(-)
xen/arch/x86/acpi/boot.c +1 -1
index 170f9783c55e..3901f9d9825b 100644
@@ -38,7 +38,7 @@
 #include <asm/mpspec.h>
 #include <asm/processor.h>
 #include <asm/hpet.h> /* for hpet_address */
-#include <mach_apic.h>
+#include <asm/genapic.h>
 
 #define PREFIX			"ACPI: "
 
xen/arch/x86/include/asm/genapic.h +3 -0
index 4d39fb9a244b..6c8845d17d27 100644
@@ -51,4 +51,7 @@ unsigned int cf_check cpu_mask_to_apicid_phys(const cpumask_t *cpumask);
 void cf_check send_IPI_mask_phys(const cpumask_t *mask, int vector);
 const cpumask_t *cf_check vector_allocation_cpumask_phys(int cpu);
 
+void generic_apic_probe(void);
+void generic_bigsmp_probe(void);
+
 #endif
xen/arch/x86/include/asm/mach-generic/mach_apic.h +0 -3
index c0d8b232c9eb..50f39b72ccfb 100644
@@ -39,9 +39,6 @@ static inline int multi_timer_check(int apic, int irq)
 	return 0;
 }
 
-extern void generic_apic_probe(void);
-extern void generic_bigsmp_probe(void);
-
 /*
  * The following functions based around phys_cpu_present_map are disabled in
  * some i386 Linux subarchitectures, and in x86_64 'cluster' genapic mode. I'm
xen/arch/x86/setup.c +2 -1
index eac8488c4ca5..4feef9f2e05a 100644
@@ -46,7 +46,8 @@
 #include <xsm/xsm.h>
 #include <asm/tboot.h>
 #include <asm/bzimage.h> /* for bzimage_headroom */
-#include <asm/mach-generic/mach_apic.h> /* for generic_apic_probe */
+#include <asm/genapic.h>
+#include <asm/io_apic.h>
 #include <asm/setup.h>
 #include <xen/cpu.h>
 #include <xen/cpuidle.h>
Signature · 1 line
2.39.5
#4 lore raw

PATCH 4/10 x86/mach-apic: Drop apic_id_registered()

In reply to Andrew Cooper

It's an unnecessary wrapper.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/apic.c                               | 3 +--
 xen/arch/x86/include/asm/mach-generic/mach_apic.h | 6 ------
 2 files changed, 1 insertion(+), 8 deletions(-)
xen/arch/x86/apic.c +1 -2
index 254ab5d388dc..9f3a374e9581 100644
@@ -495,8 +495,7 @@ void setup_local_APIC(bool bsp)
     /*
      * Double-check whether this APIC is really registered.
      */
-    if (!apic_id_registered())
-        BUG();
+    BUG_ON(!physid_isset(get_apic_id(), phys_cpu_present_map));
 
     /*
      * Intel recommends to set DFR, LDR and TPR before enabling
xen/arch/x86/include/asm/mach-generic/mach_apic.h +0 -6
index 50f39b72ccfb..3cf58d5f6b90 100644
@@ -45,12 +45,6 @@ static inline int multi_timer_check(int apic, int irq)
  * really not sure why, since all local APICs should have distinct physical
  * IDs, and we need to know what they are.
  */
-static inline int apic_id_registered(void)
-{
-	return physid_isset(get_apic_id(),
-			    phys_cpu_present_map);
-}
-
 static inline void ioapic_phys_id_map(physid_mask_t *map)
 {
 	*map = phys_cpu_present_map;
Signature · 1 line
2.39.5
#5 lore raw

PATCH 5/10 x86/mach-apic: Drop ioapic_phys_id_map()

In reply to Andrew Cooper

It's an unnecessary wrapper.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/include/asm/mach-generic/mach_apic.h | 5 -----
 xen/arch/x86/io_apic.c                            | 4 ++--
 2 files changed, 2 insertions(+), 7 deletions(-)
xen/arch/x86/include/asm/mach-generic/mach_apic.h +0 -5
index 3cf58d5f6b90..b3e9ea6600ef 100644
@@ -45,11 +45,6 @@ static inline int multi_timer_check(int apic, int irq)
  * really not sure why, since all local APICs should have distinct physical
  * IDs, and we need to know what they are.
  */
-static inline void ioapic_phys_id_map(physid_mask_t *map)
-{
-	*map = phys_cpu_present_map;
-}
-
 static inline int check_apicid_used(const physid_mask_t *map, int apicid)
 {
 	return physid_isset(apicid, *map);
xen/arch/x86/io_apic.c +2 -2
index 11b74d3eaf8a..0123edab649b 100644
@@ -1491,7 +1491,7 @@ static void __init setup_ioapic_ids_from_mpc(void)
      * This is broken; anything with a real cpu count has to
      * circumvent this idiocy regardless.
      */
-    ioapic_phys_id_map(&phys_id_present_map);
+    phys_id_present_map = phys_cpu_present_map;
 
     /*
      * Set the IOAPIC ID to the value stored in the MPC table.
@@ -2237,7 +2237,7 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id)
      */
 
     if (physids_empty(apic_id_map))
-        ioapic_phys_id_map(&apic_id_map);
+        apic_id_map = phys_cpu_present_map;
 
     spin_lock_irqsave(&ioapic_lock, flags);
     reg_00.raw = io_apic_read(ioapic, 0);
Signature · 1 line
2.39.5
#6 lore raw

PATCH 6/10 x86/mach-apic: Drop check_apicid_used()

In reply to Andrew Cooper

It's an unnecessary wrapper, and is longer than the operation it wraps.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/include/asm/mach-generic/mach_apic.h | 5 -----
 xen/arch/x86/io_apic.c                            | 9 +++++----
 2 files changed, 5 insertions(+), 9 deletions(-)
xen/arch/x86/include/asm/mach-generic/mach_apic.h +0 -5
index b3e9ea6600ef..c8e0637f4424 100644
@@ -45,11 +45,6 @@ static inline int multi_timer_check(int apic, int irq)
  * really not sure why, since all local APICs should have distinct physical
  * IDs, and we need to know what they are.
  */
-static inline int check_apicid_used(const physid_mask_t *map, int apicid)
-{
-	return physid_isset(apicid, *map);
-}
-
 static inline int check_apicid_present(int apicid)
 {
 	return physid_isset(apicid, phys_cpu_present_map);
xen/arch/x86/io_apic.c +5 -4
index 0123edab649b..5a4d8597e07a 100644
@@ -1520,8 +1520,8 @@ static void __init setup_ioapic_ids_from_mpc(void)
          * system must have a unique ID or we get lots of nice
          * 'stuck on smp_invalidate_needed IPI wait' messages.
          */
-        if (check_apicid_used(&phys_id_present_map,
-                              mp_ioapics[apic].mpc_apicid)) {
+        if ( physid_isset(mp_ioapics[apic].mpc_apicid, phys_id_present_map) )
+        {
             printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
                    apic, mp_ioapics[apic].mpc_apicid);
             for (i = 0; i < get_physical_broadcast(); i++)
@@ -2253,10 +2253,11 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id)
      * Every APIC in a system must have a unique ID or we get lots of nice 
      * 'stuck on smp_invalidate_needed IPI wait' messages.
      */
-    if (check_apicid_used(&apic_id_map, apic_id)) {
+    if ( physid_isset(apic_id, apic_id_map) )
+    {
 
         for (i = 0; i < get_physical_broadcast(); i++) {
-            if (!check_apicid_used(&apic_id_map, i))
+            if ( !physid_isset(i, apic_id_map) )
                 break;
         }
 
Signature · 1 line
2.39.5
#7 lore raw

PATCH 7/10 x86/mach-apic: Drop check_apicid_present()

In reply to Andrew Cooper

It's an unnecessary wrapper.

It's also the only reason that smpboot.c includes mach_apic.h, other than for transitive dependencies.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/include/asm/mach-generic/mach_apic.h | 5 -----
 xen/arch/x86/smpboot.c                            | 6 ++++--
 2 files changed, 4 insertions(+), 7 deletions(-)
xen/arch/x86/include/asm/mach-generic/mach_apic.h +0 -5
index c8e0637f4424..7940c0234cb9 100644
@@ -45,11 +45,6 @@ static inline int multi_timer_check(int apic, int irq)
  * really not sure why, since all local APICs should have distinct physical
  * IDs, and we need to know what they are.
  */
-static inline int check_apicid_present(int apicid)
-{
-	return physid_isset(apicid, phys_cpu_present_map);
-}
-
 static inline void set_apicid(int phys_apicid, physid_mask_t *map)
 {
 	physid_set(phys_apicid, *map);
xen/arch/x86/smpboot.c +4 -2
index 9e79c1a6d6e6..42272a9844fa 100644
@@ -20,6 +20,9 @@
 #include <xen/serial.h>
 #include <xen/numa.h>
 #include <xen/cpu.h>
+
+#include <asm/apic.h>
+#include <asm/io_apic.h>
 #include <asm/cpuidle.h>
 #include <asm/current.h>
 #include <asm/mc146818rtc.h>
@@ -37,7 +40,6 @@
 #include <asm/tboot.h>
 #include <asm/trampoline.h>
 #include <irq_vectors.h>
-#include <mach_apic.h>
 
 unsigned long __read_mostly trampoline_phys;
 enum ap_boot_method __read_mostly ap_boot_method = AP_BOOT_NORMAL;
@@ -1193,7 +1195,7 @@ void __init smp_prepare_cpus(void)
      * CPU too, but we do it for the sake of robustness anyway.
      * Makes no sense to do this check in clustered apic mode, so skip it
      */
-    if ( !check_apicid_present(boot_cpu_physical_apicid) )
+    if ( !physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map) )
     {
         printk("weird, boot CPU (#%d) not listed by the BIOS.\n",
                boot_cpu_physical_apicid);
Signature · 1 line
2.39.5
#8 lore raw

PATCH 8/10 x86/mach-apic: Drop set_apicid()

In reply to Andrew Cooper

It's an unnecessary wrapper, and longer than the operation it wraps.

It's also the only reason that mpparse.c includes mach_apic.h, other than for transitive dependencies.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/include/asm/mach-generic/mach_apic.h | 11 -----------
 xen/arch/x86/io_apic.c                            |  4 ++--
 xen/arch/x86/mpparse.c                            |  7 ++++---
 3 files changed, 6 insertions(+), 16 deletions(-)
xen/arch/x86/include/asm/mach-generic/mach_apic.h +0 -11
index 7940c0234cb9..b4a2f0a0b068 100644
@@ -39,15 +39,4 @@ static inline int multi_timer_check(int apic, int irq)
 	return 0;
 }
 
-/*
- * The following functions based around phys_cpu_present_map are disabled in
- * some i386 Linux subarchitectures, and in x86_64 'cluster' genapic mode. I'm
- * really not sure why, since all local APICs should have distinct physical
- * IDs, and we need to know what they are.
- */
-static inline void set_apicid(int phys_apicid, physid_mask_t *map)
-{
-	physid_set(phys_apicid, *map);
-}
-
 #endif /* __ASM_MACH_APIC_H */
xen/arch/x86/io_apic.c +2 -2
index 5a4d8597e07a..2774cd45c091 100644
@@ -1537,7 +1537,7 @@ static void __init setup_ioapic_ids_from_mpc(void)
                         "phys_id_present_map\n",
                         mp_ioapics[apic].mpc_apicid);
         }
-        set_apicid(mp_ioapics[apic].mpc_apicid, &phys_id_present_map);
+        physid_set(mp_ioapics[apic].mpc_apicid, phys_id_present_map);
 
         /*
          * We need to adjust the IRQ routing table
@@ -2270,7 +2270,7 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id)
         apic_id = i;
     } 
 
-    set_apicid(apic_id, &apic_id_map);
+    physid_set(apic_id, apic_id_map);
 
     if (reg_00.bits.ID != apic_id) {
         reg_00.bits.ID = apic_id;
xen/arch/x86/mpparse.c +4 -3
index e13b83bbe9dd..b16c105b18bf 100644
@@ -20,8 +20,10 @@
 #include <xen/delay.h>
 #include <xen/efi.h>
 #include <xen/sched.h>
-
 #include <xen/bitops.h>
+
+#include <asm/apic.h>
+#include <asm/genapic.h>
 #include <asm/smp.h>
 #include <asm/acpi.h>
 #include <asm/mtrr.h>
@@ -29,7 +31,6 @@
 #include <asm/io_apic.h>
 #include <asm/setup.h>
 
-#include <mach_apic.h>
 #include <bios_ebda.h>
 
 /* Have we found an MP table */
@@ -161,7 +162,7 @@ static int MP_processor_info_x(struct mpc_config_processor *m,
 	}
 	apic_version[apicid] = ver;
 
-	set_apicid(apicid, &phys_cpu_present_map);
+	physid_set(apicid, phys_cpu_present_map);
 
 	if (num_processors >= nr_cpu_ids) {
 		printk_once(XENLOG_WARNING
Signature · 1 line
2.39.5
#9 lore raw

PATCH 9/10 x86/mach-apic: Move the genapic wrappers to genapic.h

In reply to Andrew Cooper

This a better place for them to live.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/include/asm/genapic.h             | 17 +++++++++++++++++
 .../x86/include/asm/mach-generic/mach_apic.h   | 18 ------------------
 xen/arch/x86/irq.c                             |  6 +++++-
 xen/arch/x86/msi.c                             |  6 +++++-
 4 files changed, 27 insertions(+), 20 deletions(-)
xen/arch/x86/include/asm/genapic.h +17 -0
index 6c8845d17d27..cf36d48f3b07 100644
@@ -37,6 +37,23 @@ struct genapic {
 	.name = aname, \
 	.probe = aprobe
 
+#define INT_DELIVERY_MODE (genapic.int_delivery_mode)
+#define INT_DEST_MODE (genapic.int_dest_mode)
+#define TARGET_CPUS ((const typeof(cpu_online_map) *)&cpu_online_map)
+#define init_apic_ldr() alternative_vcall(genapic.init_apic_ldr)
+#define cpu_mask_to_apicid(mask) ({ \
+	/* \
+	 * There are a number of places where the address of a local variable \
+	 * gets passed here. The use of ?: in alternative_call<N>() triggers an \
+	 * "address of ... is always true" warning in such a case with at least \
+	 * gcc 7 and 8. Hence the seemingly pointless local variable here. \
+	 */ \
+	const cpumask_t *m_ = (mask); \
+	alternative_call(genapic.cpu_mask_to_apicid, m_); \
+})
+#define vector_allocation_cpumask(cpu) \
+	alternative_call(genapic.vector_allocation_cpumask, cpu)
+
 extern struct genapic genapic;
 extern const struct genapic apic_default;
 extern const struct genapic apic_bigsmp;
xen/arch/x86/include/asm/mach-generic/mach_apic.h +0 -18
index b4a2f0a0b068..3e17c271d9ac 100644
@@ -6,24 +6,6 @@
 #include <asm/genapic.h>
 #include <asm/smp.h>
 
-/* The following are dependent on APIC delivery mode (logical vs. physical). */
-#define INT_DELIVERY_MODE (genapic.int_delivery_mode)
-#define INT_DEST_MODE (genapic.int_dest_mode)
-#define TARGET_CPUS ((const typeof(cpu_online_map) *)&cpu_online_map)
-#define init_apic_ldr() alternative_vcall(genapic.init_apic_ldr)
-#define cpu_mask_to_apicid(mask) ({ \
-	/* \
-	 * There are a number of places where the address of a local variable \
-	 * gets passed here. The use of ?: in alternative_call<N>() triggers an \
-	 * "address of ... is always true" warning in such a case with at least \
-	 * gcc 7 and 8. Hence the seemingly pointless local variable here. \
-	 */ \
-	const cpumask_t *m_ = (mask); \
-	alternative_call(genapic.cpu_mask_to_apicid, m_); \
-})
-#define vector_allocation_cpumask(cpu) \
-	alternative_call(genapic.vector_allocation_cpumask, cpu)
-
 static inline void enable_apic_mode(void)
 {
 	/* Not needed for modern ES7000 which boot in Virtual Wire mode. */
xen/arch/x86/irq.c +5 -1
index 0001e93ba8ac..6340cd6dd73d 100644
@@ -21,10 +21,14 @@
 #include <xen/trace.h>
 #include <xen/softirq.h>
 #include <xsm/xsm.h>
+
+#include <asm/apic.h>
+#include <asm/genapic.h>
+#include <asm/io_apic.h>
 #include <asm/msi.h>
 #include <asm/current.h>
 #include <asm/flushtlb.h>
-#include <asm/mach-generic/mach_apic.h>
+
 #include <irq_vectors.h>
 #include <public/physdev.h>
 
xen/arch/x86/msi.c +5 -1
index 677fd83218d4..68d6e25178a9 100644
@@ -21,13 +21,17 @@
 #include <xen/iocap.h>
 #include <xen/keyhandler.h>
 #include <xen/pfn.h>
+
+#include <asm/apic.h>
+#include <asm/genapic.h>
 #include <asm/io.h>
+#include <asm/io_apic.h>
 #include <asm/smp.h>
 #include <asm/desc.h>
 #include <asm/msi.h>
 #include <asm/fixmap.h>
 #include <asm/p2m.h>
-#include <mach_apic.h>
+
 #include <io_ports.h>
 #include <irq_vectors.h>
 #include <public/physdev.h>
Signature · 1 line
2.39.5
#10 lore raw

PATCH 10/10 x86: Delete mach_apic.h

In reply to Andrew Cooper

All useful content has been moved elsewhere.

Clean up the dregs, and remove the entire mach-generic include path.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/apic.c                           |  4 ++--
 xen/arch/x86/arch.mk                          |  1 -
 .../x86/include/asm/mach-generic/mach_apic.h  | 24 -------------------
 xen/arch/x86/io_apic.c                        | 15 +++++-------
 4 files changed, 8 insertions(+), 36 deletions(-)
 delete mode 100644 xen/arch/x86/include/asm/mach-generic/mach_apic.h
xen/arch/x86/apic.c +2 -2
index 9f3a374e9581..8f192f80b852 100644
@@ -35,7 +35,8 @@
 #include <asm/hardirq.h>
 #include <asm/apic.h>
 #include <asm/io_apic.h>
-#include <mach_apic.h>
+#include <asm/genapic.h>
+
 #include <io_ports.h>
 #include <irq_vectors.h>
 #include <xen/kexec.h>
@@ -230,7 +231,6 @@ void __init connect_bsp_APIC(void)
     }
 
     printk("Enabling APIC mode.  Using %d I/O APICs\n", nr_ioapics);
-    enable_apic_mode();
 }
 
 void disconnect_bsp_APIC(int virt_wire_setup)
xen/arch/x86/arch.mk +0 -1
index 1460ecf30b9a..8f8aeda679d8 100644
@@ -3,7 +3,6 @@
 
 export XEN_IMG_OFFSET := 0x200000
 
-CFLAGS += -I$(srctree)/arch/x86/include/asm/mach-generic
 CFLAGS += -I$(srctree)/arch/x86/include/asm/mach-default
 CFLAGS += -DXEN_IMG_OFFSET=$(XEN_IMG_OFFSET)
 
xen/arch/x86/include/asm/mach-generic/mach_apic.h deleted +0 -24
deleted file mode 100644
index 3e17c271d9ac..000000000000
@@ -1,24 +0,0 @@
-#ifndef __ASM_MACH_APIC_H
-#define __ASM_MACH_APIC_H
-
-#include <asm/apic.h>
-#include <asm/io_apic.h>
-#include <asm/genapic.h>
-#include <asm/smp.h>
-
-static inline void enable_apic_mode(void)
-{
-	/* Not needed for modern ES7000 which boot in Virtual Wire mode. */
-	/*es7000_sw_apic();*/
-}
-
-#define apicid_to_node(apicid) ((int)apicid_to_node[(u32)apicid])
-
-extern u32 bios_cpu_apicid[];
-
-static inline int multi_timer_check(int apic, int irq)
-{
-	return 0;
-}
-
-#endif /* __ASM_MACH_APIC_H */
xen/arch/x86/io_apic.c +6 -9
index 2774cd45c091..13daebc10a97 100644
@@ -31,13 +31,16 @@
 #include <xen/softirq.h>
 #include <xen/xvmalloc.h>
 
+#include <asm/apic.h>
+#include <asm/genapic.h>
 #include <asm/hpet.h>
+#include <asm/io_apic.h>
 #include <asm/mc146818rtc.h>
 #include <asm/smp.h>
 #include <asm/desc.h>
 #include <asm/msi.h>
 #include <asm/setup.h>
-#include <mach_apic.h>
+
 #include <io_ports.h>
 #include <irq_vectors.h>
 #include <public/physdev.h>
@@ -1104,14 +1107,8 @@ static void __init setup_IO_APIC_irqs(void)
             }
 
             irq = pin_2_irq(idx, apic, pin);
-            /*
-             * skip adding the timer int on secondary nodes, which causes
-             * a small but painful rift in the time-space continuum
-             */
-            if (multi_timer_check(apic, irq))
-                continue;
-            else
-                add_pin_to_irq(irq, apic, pin);
+
+            add_pin_to_irq(irq, apic, pin);
 
             if (!IO_APIC_IRQ(irq))
                 continue;
Signature · 1 line
2.39.5
Reviewed-by on v1 10/10
#11 lore raw

Re: [PATCH 10/10] x86: Delete mach_apic.h

Quoted 3 lines · Andrew Cooper

All useful content has been moved elsewhere.

Clean up the dregs, and remove the entire mach-generic include path.

What's "dregs" here?

Quoted 10 lines
xen/arch/x86/include/asm/mach-generic/mach_apic.h deleted +0 -7
@@ -1,24 +0,0 @@
-#ifndef __ASM_MACH_APIC_H
-#define __ASM_MACH_APIC_H
-
-#include <asm/apic.h>
-#include <asm/io_apic.h>
-#include <asm/genapic.h>
-#include <asm/smp.h>

xen/arch/x86/include/asm/mach-generic/mach_apic.h line 17

Quoted 10 lines
xen/arch/x86/include/asm/mach-generic/mach_apic.h deleted +0 -10
-
-static inline void enable_apic_mode(void)
-{
-	/* Not needed for modern ES7000 which boot in Virtual Wire mode. */
-	/*es7000_sw_apic();*/
-}
-
-#define apicid_to_node(apicid) ((int)apicid_to_node[(u32)apicid])
-
-extern u32 bios_cpu_apicid[];

For these two, isn't there some Misra aspect? They're both unused, and Misra generally dislikes unused stuff. Whereas ...

xen/arch/x86/include/asm/mach-generic/mach_apic.h line 22

Quoted 4 lines
xen/arch/x86/include/asm/mach-generic/mach_apic.h deleted +0 -4
-static inline int multi_timer_check(int apic, int irq)
-{
-	return 0;
-}

... this and the other inline function further up clearly have their sole users removed here, so are fine without any further text in the description.

Preferably with the description amended / clarified:

Jan

#12 lore raw

Re: [PATCH 10/10] x86: Delete mach_apic.h

Quoted 5 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper

All useful content has been moved elsewhere.

Clean up the dregs, and remove the entire mach-generic include path.

What's "dregs" here?

Oh.  "The leftovers".

Surprisingly (to me at least), it's not slang.  It is most common used to refer to what remains in the cup when you've drunk a coffee/tea/etc.

Quoted 15 lines
Quoted 15 lines
xen/arch/x86/include/asm/mach-generic/mach_apic.h deleted +0 -11
@@ -1,24 +0,0 @@
-#ifndef __ASM_MACH_APIC_H
-#define __ASM_MACH_APIC_H
-
-#include <asm/apic.h>
-#include <asm/io_apic.h>
-#include <asm/genapic.h>
-#include <asm/smp.h>
-
-static inline void enable_apic_mode(void)
-{
-	/* Not needed for modern ES7000 which boot in Virtual Wire mode. */
Quoted 8 lines

xen/arch/x86/include/asm/mach-generic/mach_apic.h line 17

Quoted 6 lines
xen/arch/x86/include/asm/mach-generic/mach_apic.h deleted +0 -6
-	/*es7000_sw_apic();*/
-}
-
-#define apicid_to_node(apicid) ((int)apicid_to_node[(u32)apicid])
-
-extern u32 bios_cpu_apicid[];

For these two, isn't there some Misra aspect? They're both unused, and Misra generally dislikes unused stuff.

Eclair won't complain about either, I don't think.

The macro will just disappear after preprocessing, whereas we've explicitly deviated Rule 8.6 because of how we use dead-code-elimination to reduce ifdefary.

Quoted 11 lines

Whereas ...

xen/arch/x86/include/asm/mach-generic/mach_apic.h line 22

Quoted 4 lines
xen/arch/x86/include/asm/mach-generic/mach_apic.h deleted +0 -4
-static inline int multi_timer_check(int apic, int irq)
-{
-	return 0;
-}

... this and the other inline function further up clearly have their sole users removed here, so are fine without any further text in the description.

Preferably with the description amended / clarified:

Lemme have another go.

~Andrew

#13 lore raw

PATCH v2 10/10 x86: Delete mach_apic.h

In reply to Andrew Cooper

All useful content has been moved elsewhere.

enable_apic_mode() and multi_timer_check() are empty stubs. Remove their sole callers and drop them.

apicid_to_node() and bios_cpu_apicid[] are entirely unused.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

v2:
* Adjust commit message.

---
 xen/arch/x86/apic.c                           |  4 ++--
 xen/arch/x86/arch.mk                          |  1 -
 .../x86/include/asm/mach-generic/mach_apic.h  | 24 -------------------
 xen/arch/x86/io_apic.c                        | 15 +++++-------
 4 files changed, 8 insertions(+), 36 deletions(-)
 delete mode 100644 xen/arch/x86/include/asm/mach-generic/mach_apic.h
xen/arch/x86/apic.c +2 -2
index 9f3a374e9581..8f192f80b852 100644
@@ -35,7 +35,8 @@
 #include <asm/hardirq.h>
 #include <asm/apic.h>
 #include <asm/io_apic.h>
-#include <mach_apic.h>
+#include <asm/genapic.h>
+
 #include <io_ports.h>
 #include <irq_vectors.h>
 #include <xen/kexec.h>
@@ -230,7 +231,6 @@ void __init connect_bsp_APIC(void)
     }
 
     printk("Enabling APIC mode.  Using %d I/O APICs\n", nr_ioapics);
-    enable_apic_mode();
 }
 
 void disconnect_bsp_APIC(int virt_wire_setup)
xen/arch/x86/arch.mk +0 -1
index 1460ecf30b9a..8f8aeda679d8 100644
@@ -3,7 +3,6 @@
 
 export XEN_IMG_OFFSET := 0x200000
 
-CFLAGS += -I$(srctree)/arch/x86/include/asm/mach-generic
 CFLAGS += -I$(srctree)/arch/x86/include/asm/mach-default
 CFLAGS += -DXEN_IMG_OFFSET=$(XEN_IMG_OFFSET)
 
xen/arch/x86/include/asm/mach-generic/mach_apic.h deleted +0 -24
deleted file mode 100644
index 3e17c271d9ac..000000000000
@@ -1,24 +0,0 @@
-#ifndef __ASM_MACH_APIC_H
-#define __ASM_MACH_APIC_H
-
-#include <asm/apic.h>
-#include <asm/io_apic.h>
-#include <asm/genapic.h>
-#include <asm/smp.h>
-
-static inline void enable_apic_mode(void)
-{
-	/* Not needed for modern ES7000 which boot in Virtual Wire mode. */
-	/*es7000_sw_apic();*/
-}
-
-#define apicid_to_node(apicid) ((int)apicid_to_node[(u32)apicid])
-
-extern u32 bios_cpu_apicid[];
-
-static inline int multi_timer_check(int apic, int irq)
-{
-	return 0;
-}
-
-#endif /* __ASM_MACH_APIC_H */
xen/arch/x86/io_apic.c +6 -9
index 2774cd45c091..13daebc10a97 100644
@@ -31,13 +31,16 @@
 #include <xen/softirq.h>
 #include <xen/xvmalloc.h>
 
+#include <asm/apic.h>
+#include <asm/genapic.h>
 #include <asm/hpet.h>
+#include <asm/io_apic.h>
 #include <asm/mc146818rtc.h>
 #include <asm/smp.h>
 #include <asm/desc.h>
 #include <asm/msi.h>
 #include <asm/setup.h>
-#include <mach_apic.h>
+
 #include <io_ports.h>
 #include <irq_vectors.h>
 #include <public/physdev.h>
@@ -1104,14 +1107,8 @@ static void __init setup_IO_APIC_irqs(void)
             }
 
             irq = pin_2_irq(idx, apic, pin);
-            /*
-             * skip adding the timer int on secondary nodes, which causes
-             * a small but painful rift in the time-space continuum
-             */
-            if (multi_timer_check(apic, irq))
-                continue;
-            else
-                add_pin_to_irq(irq, apic, pin);
+
+            add_pin_to_irq(irq, apic, pin);
 
             if (!IO_APIC_IRQ(irq))
                 continue;
Signature · 1 line
2.39.5
Reviewed-by on v2 10/10
#14 lore raw

Re: [PATCH v2 10/10] x86: Delete mach_apic.h

Quoted 8 lines · Andrew Cooper

All useful content has been moved elsewhere.

enable_apic_mode() and multi_timer_check() are empty stubs. Remove their sole callers and drop them.

apicid_to_node() and bios_cpu_apicid[] are entirely unused.

Acked-by on the v1 series
#15 lore raw
In reply to Andrew Cooper
Quoted 5 lines · Andrew Cooper

There's only one header file left. More than half of it is totally useless, and the rest has better places to live in the tree.

This lets us drop a compiler include path.

Quoted 10 lines

Andrew Cooper (10):
VT-d: Drop includes of mach_apic.h
x86: Drop includes of mach_apic.h
x86/mach-apic: Move generic_*_probe() declarations into genapic.h x86/mach-apic: Drop apic_id_registered() x86/mach-apic: Drop ioapic_phys_id_map() x86/mach-apic: Drop check_apicid_used()
x86/mach-apic: Drop check_apicid_present() x86/mach-apic: Drop set_apicid()
x86/mach-apic: Move the genapic wrappers to genapic.h

Up to here:

Quoted 1 line

x86: Delete mach_apic.h

I'll comment on this one separately.

Jan