x86/apic: Drop vestigial pieces (Intel VFM cleanup)
cover x86/apic: Drop vestigial pieces (Intel VFM cleanup)
Found while doing the Intel VFM cleanup. This diffstat seems preforable to simply dropping the x86_ prefixes on the field name.
Andrew Cooper (2):
x86/apic: Get rid of get_physical_broadcast()
x86/apic: Drop sync_Arb_IDs()
xen/arch/x86/apic.c | 40 --------------------------------- xen/arch/x86/include/asm/apic.h | 3 --- xen/arch/x86/io_apic.c | 18 +++++++-------- 3 files changed, 9 insertions(+), 52 deletions(-)
Signature · 1 line
2.39.5
PATCH 1/2 x86/apic: Get rid of get_physical_broadcast()
This is a port of Linux commit 517234446c1a ("x86/apic: Get rid of get_physical_broadcast()") to Xen. Thomas Gleixner notes:
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.
In Linux, users of get_physical_broadcast() have already been hidden behind CONFIG_X86_32 suggesting we can drop all of this, but that's a task for some other time.
In Xen as with Linux, setup_ioapic_ids_from_mpc() and io_apic_get_unique_id() are only called in pre-xAPIC cases, so can use a broadcast ID of 0xf. The only other user is __print_IO_APIC() for diagnostics, which can simply drop the check.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
add/remove: 0/1 grow/shrink: 0/3 up/down: 0/-165 (-165)
Function old new delta __print_IO_APIC 980 975 -5 setup_IO_APIC 3018 2992 -26 io_apic_get_unique_id 719 686 -33 get_physical_broadcast 101 - -101 --- xen/arch/x86/apic.c | 8 -------- xen/arch/x86/include/asm/apic.h | 2 -- xen/arch/x86/io_apic.c | 16 ++++++++-------- 3 files changed, 8 insertions(+), 18 deletions(-)
xen/arch/x86/apic.c +0 -8
@@ -133,14 +133,6 @@ static bool __read_mostly using_apic_timer;static bool __read_mostly enabled_via_apicbase; -int get_physical_broadcast (void ) -{ -if (modern_apic ()) -return 0xff ; -else -return 0xf ; -} -int get_maxlvt (void ) {unsigned int v =apic_read (APIC_LVR );
xen/arch/x86/include/asm/apic.h +0 -2
@@ -153,8 +153,6 @@ static inline u32 get_apic_id(void)void apic_wait_icr_idle (void ); -int get_physical_broadcast (void ); -static inline void ack_APIC_irq (void ) {/* Docs say use 0 for future compatibility */
xen/arch/x86/io_apic.c +8 -8
@@ -1217,8 +1217,6 @@ static void /*__init*/ __print_IO_APIC(bool boot)printk (KERN_DEBUG "....... : physical APIC id: %02X\n" , reg_00.bits.ID);printk (KERN_DEBUG "....... : Delivery Type: %X\n" , reg_00.bits.delivery_type);printk (KERN_DEBUG "....... : LTS : %X\n" , reg_00.bits.LTS); -if (reg_00.bits.ID >=get_physical_broadcast ()) -UNEXPECTED_IO_APIC ();if (reg_00.bits.__reserved_1 || reg_00.bits.__reserved_2)UNEXPECTED_IO_APIC ();
@@ -1475,6 +1473,7 @@ static void __init setup_ioapic_ids_from_mpc(void)int i;unsigned char old_id;unsigned long flags; +const uint32_t broadcast_id =0xf ;/* * Don't check I/O APIC IDs for xAPIC systems. They have
@@ -1504,7 +1503,7 @@ static void __init setup_ioapic_ids_from_mpc(void) old_id = mp_ioapics[apic].mpc_apicid; -if (mp_ioapics[apic].mpc_apicid >=get_physical_broadcast ()) { +if (mp_ioapics[apic].mpc_apicid >= broadcast_id) {printk (KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n" , apic, mp_ioapics[apic].mpc_apicid); printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
@@ -1521,10 +1520,10 @@ static void __init setup_ioapic_ids_from_mpc(void) {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++) +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);
@@ -2223,6 +2222,7 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id)static physid_mask_t __initdata apic_id_map =PHYSID_MASK_NONE ;unsigned long flags;int i =0 ; +const uint32_t broadcast_id =0xf ;/* * The P4 platform supports up to 256 APIC IDs on two separate APIC
@@ -2240,7 +2240,7 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id) reg_00.raw =io_apic_read (ioapic,0 );spin_unlock_irqrestore (&ioapic_lock, flags); -if (apic_id >=get_physical_broadcast ()) { +if (apic_id >= broadcast_id) {printk (KERN_WARNING "IOAPIC[%d]: Invalid apic_id %d, trying " "%d\n" , ioapic, apic_id, reg_00.bits.ID); apic_id = reg_00.bits.ID;
@@ -2253,12 +2253,12 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id)if (physid_isset (apic_id, apic_id_map) ) { -for (i =0 ; i <get_physical_broadcast (); i++) { +for (i =0 ; i < broadcast_id; i++) {if ( !physid_isset (i, apic_id_map) )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, "
Signature · 1 line
2.39.5
Re: [PATCH 1/2] x86/apic: Get rid of get_physical_broadcast()
Quoted 6 lines · Andrew Cooper
This is a port of Linux commit
517234446c1a("x86/apic: Get rid ofget_physical_broadcast()") to Xen. Thomas Gleixner notes: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.
Quoted 8 lines
In Linux, users of
get_physical_broadcast()have already been hidden behindCONFIG_X86_32suggesting we can drop all of this, but that's a task for some other time.In Xen as with Linux,
setup_ioapic_ids_from_mpc()andio_apic_get_unique_id()are only called in pre-xAPIC cases, so can use a broadcast ID of0xf. The only other user is__print_IO_APIC()for diagnostics, which can simply drop the check.
For setup_ioapic_ids_from_mpc() in Linux that's partly because it gained an Intel && !APIC_XAPIC() check which we don't have. Without that extra bit of data it's not quite obvious, as the check right now is solely "!acpi_ioapic". (Which iirc we said we would want to get rid of as well.)
The non-Intel pre-xAPIC case is left somewhat unclear there, though.
Quoted 4 lines
No functional change.
Irrespective of the above:
Jan
Re: [PATCH 1/2] x86/apic: Get rid of get_physical_broadcast()
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Andrew Cooper
This is a port of Linux commit
517234446c1a("x86/apic: Get rid ofget_physical_broadcast()") to Xen. Thomas Gleixner notes: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.In Linux, users of
get_physical_broadcast()have already been hidden behindCONFIG_X86_32suggesting we can drop all of this, but that's a task for some other time.
Quoted 6 lines
Quoted 4 lines
In Xen as with Linux,
setup_ioapic_ids_from_mpc()andio_apic_get_unique_id()are only called in pre-xAPIC cases, so can use a broadcast ID of0xf. The only other user is__print_IO_APIC()for diagnostics, which can simply drop the check.For
setup_ioapic_ids_from_mpc()in Linux that's partly because it gained an Intel && !APIC_XAPIC() check which we don't have.
In Xen, setup_ioapic_ids_from_mpc() has a comment and an xAPIC check at the start of the function.
We're lacking Linux commit a38c5380ef9f "x86: io_apic: Split setup_ioapic_ids_from_mpc()" which moved the check to the caller.
Perhaps I should s/called/used/ in the commit message?
~Andrew
Re: [PATCH 1/2] x86/apic: Get rid of get_physical_broadcast()
Quoted 19 lines · Andrew Cooper
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Andrew Cooper
This is a port of Linux commit
517234446c1a("x86/apic: Get rid ofget_physical_broadcast()") to Xen. Thomas Gleixner notes: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.In Linux, users of
get_physical_broadcast()have already been hidden behindCONFIG_X86_32suggesting we can drop all of this, but that's a task for some other time.Quoted 6 lines
Quoted 4 lines
In Xen as with Linux,
setup_ioapic_ids_from_mpc()andio_apic_get_unique_id()are only called in pre-xAPIC cases, so can use a broadcast ID of0xf. The only other user is__print_IO_APIC()for diagnostics, which can simply drop the check.For
setup_ioapic_ids_from_mpc()in Linux that's partly because it gained an Intel && !APIC_XAPIC() check which we don't have.
Quoted 7 lines
In Xen,
setup_ioapic_ids_from_mpc()has a comment and an xAPIC check at the start of the function.We're lacking Linux commit
a38c5380ef9f"x86:io_apic: Splitsetup_ioapic_ids_from_mpc()" which moved the check to the caller.Perhaps I should s/called/used/ in the commit message?
Maybe, but I wouldn't insist.
Jan
PATCH 2/2 x86/apic: Drop sync_Arb_IDs()
In reply to Andrew CooperIt is not obvious at first glance, but this is dead logic.
On Intel, xAPIC (which is what modern_apic() is really checking for) predates 64bit support, while the Family 0xf check on AMD is the K8 processor.
Simply drop the logic, rather than trying to adjust vendor/family logic.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-166 (-166)
Function old new delta
setup_IO_APIC 2992 2987 -5
sync_Arb_IDs 161 - -161
--- xen/arch/x86/apic.c | 32 -------------------------------- xen/arch/x86/include/asm/apic.h | 1 - xen/arch/x86/io_apic.c | 2 +- 3 files changed, 1 insertion(+), 34 deletions(-)
xen/arch/x86/apic.c +0 -32
@@ -91,23 +91,6 @@ static enum apic_mode apic_boot_mode = APIC_MODE_INVALID;bool __read_mostly x2apic_enabled;bool __read_mostly directed_eoi_enabled; -static int modern_apic (void ) -{ -unsigned int lvr, version; -/* AMD systems use old APIC versions, so check the CPU */ -if (boot_cpu_data.x86_vendor ==X86_VENDOR_AMD && - boot_cpu_data.x86 >=0xf ) -return 1 ; - -/* Hygon systems use modern APIC */ -if (boot_cpu_data.x86_vendor ==X86_VENDOR_HYGON ) -return 1 ; - - lvr =apic_read (APIC_LVR ); - version =GET_APIC_VERSION (lvr); -return version >=0x14 ; -} -/* * 'what should we do if we get a hw irq event on an illegal vector'. * each architecture has to answer this themselves.
@@ -396,21 +379,6 @@ int __init verify_local_APIC(void)return 1 ; } -void __init sync_Arb_IDs (void ) -{ -/* Unsupported on P4 - see Intel Dev. Manual Vol. 3, Ch. 8.6.1 -And not needed on AMD */ -if (modern_apic ()) -return ; -/* -* Wait for idle. -*/ -apic_wait_icr_idle (); - -apic_printk (APIC_DEBUG ,"Synchronizing Arb IDs.\n" ); -apic_write (APIC_ICR ,APIC_DEST_ALLINC |APIC_INT_LEVELTRIG |APIC_DM_INIT ); -} -/* * An initial setup of the virtual wire mode. */
xen/arch/x86/include/asm/apic.h +0 -1
@@ -166,7 +166,6 @@ extern void disconnect_bsp_APIC (int virt_wire_setup);extern void disable_local_APIC (void );extern int verify_local_APIC (void );extern void cache_APIC_registers (void ); -extern void sync_Arb_IDs (void );extern void init_bsp_APIC (void );extern void setup_local_APIC (bool bsp);extern void init_apic_mappings (void );
xen/arch/x86/io_apic.c +1 -1
@@ -2163,7 +2163,7 @@ void __init setup_IO_APIC(void)*/ if (!acpi_ioapic)setup_ioapic_ids_from_mpc (); -sync_Arb_IDs (); +setup_IO_APIC_irqs ();init_IO_APIC_traps ();check_timer ();
Signature · 1 line
2.39.5
Re: [PATCH 2/2] x86/apic: Drop sync_Arb_IDs()
Quoted 8 lines · Andrew Cooper
It is not obvious at first glance, but this is dead logic.
On Intel, xAPIC (which is what
modern_apic()is really checking for) predates 64bit support, while the Family0xfcheck on AMD is the K8 processor.Simply drop the logic, rather than trying to adjust vendor/family logic.
Signed-off-by Andrew Cooper <[email protected]>