x86/ioapic: Robustness fix and cleanup
Subsystems (3)
cover x86/ioapic: Robustness fix and cleanup
Breno reported a panic during testing with failslab in the IO-APIC code. This is a historical leftover and can be handled gracefully.
While looking at that I stumbled over quite some historical leftovers of debug printks, overly big comments for trivialities and a pile of coding style violations.
So after fixing the failslab problem I just went through and modernized the (IO)APIC code.
The series is also available from git:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/apic
Thanks,
tglx
--- arch/x86/include/asm/apic.h | 33 - arch/x86/kernel/apic/apic.c | 81 +-- arch/x86/kernel/apic/io_apic.c | 749 ++++++++++++++---------------------- arch/x86/kernel/mpparse.c | 12 drivers/iommu/intel/irq_remapping.c | 11 5 files changed, 369 insertions(+), 517 deletions(-)
PATCH 1/15 x86/ioapic: Handle allocation failures gracefully
Breno observed panics when using failslab under certain conditions during runtime:
can not alloc irq_pin_list (-1,0,20)
Kernel panic - not syncing: IO-APIC: failed to add irq-pin. Can not proceed panic+0x4e9/0x590 mp_irqdomain_alloc+0x9ab/0xa80 irq_domain_alloc_irqs_locked+0x25d/0x8d0 __irq_domain_alloc_irqs+0x80/0x110 mp_map_pin_to_irq+0x645/0x890 acpi_register_gsi_ioapic+0xe6/0x150 hpet_open+0x313/0x480
That's a pointless panic which is a leftover of the historic IO/APIC code which panic'ed during early boot when the interrupt allocation failed.
The only place which might justify panic is the PIT/HPET timer_check() code which tries to figure out whether the timer interrupt is delivered through the IO/APIC. But that code does not require to handle interrupt allocation failures. If the interrupt cannot be allocated then timer delivery fails and it either panics due to that or falls back to legacy mode.
Cure this by removing the panic wrapper around __add_pin_to_irq_node() and making mp_irqdomain_alloc() aware of the failure condition and handle it as any other failure in this function gracefully.
--- arch/x86/kernel/apic/io_apic.c | 46 +++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 24 deletions(-)
arch/x86/kernel/apic/io_apic.c +22 -24
@@ -352,27 +352,26 @@ static void ioapic_mask_entry(int apic,* shared ISA-space IRQs, so we have to support them. We are super * fast in the common case, and fast for shared ISA-space IRQs. */ -static int __add_pin_to_irq_node (struct mp_chip_data *data, -int node,int apic,int pin) +static bool add_pin_to_irq_node (struct mp_chip_data *data,int node,int apic,int pin) {struct irq_pin_list *entry; -/* don't allow duplicates */ -for_each_irq_pin (entry, data->irq_2_pin) +/* Don't allow duplicates */ +for_each_irq_pin (entry, data->irq_2_pin) {if (entry->apic == apic && entry->pin == pin) -return 0 ; +return true; + } entry =kzalloc_node (sizeof (struct irq_pin_list ),GFP_ATOMIC , node);if (!entry) { -pr_err ("can not alloc irq_pin_list (%d,%d,%d)\n" , - node, apic, pin); -return -ENOMEM ; +pr_err ("Cannot allocate irq_pin_list (%d,%d,%d)\n" , node, apic, pin); +return false; } + entry->apic = apic; entry->pin = pin;list_add_tail (&entry->list, &data->irq_2_pin); - -return 0 ; +return true; }static void __remove_pin_from_irq (struct mp_chip_data *data,int apic,int pin)
@@ -387,13 +386,6 @@ static void __remove_pin_from_irq(struct } } -static void add_pin_to_irq_node (struct mp_chip_data *data, -int node,int apic,int pin) -{ -if (__add_pin_to_irq_node (data, node, apic, pin)) -panic ("IO-APIC: failed to add irq-pin. Can not proceed\n" ); -} -/* * Reroute an IRQ to a different pin. */
@@ -1002,8 +994,7 @@ static int alloc_isa_irq_from_domain(strif (irq_data && irq_data->parent_data) {if (!mp_check_pin_attr (irq, info))return -EBUSY ; -if (__add_pin_to_irq_node (irq_data->chip_data, node, ioapic, - info->ioapic.pin)) +if (!add_pin_to_irq_node (irq_data->chip_data, node, ioapic, info->ioapic.pin))return -ENOMEM ; }else { info->flags |=X86_IRQ_ALLOC_LEGACY ;
@@ -3017,10 +3008,8 @@ int mp_irqdomain_alloc(struct irq_domainreturn -ENOMEM ; ret =irq_domain_alloc_irqs_parent (domain, virq, nr_irqs, info); -if (ret <0 ) { -kfree (data); -return ret; - } +if (ret <0 ) + goto free_data;INIT_LIST_HEAD (&data->irq_2_pin); irq_data->hwirq = info->ioapic.pin;
@@ -3029,7 +3018,10 @@ int mp_irqdomain_alloc(struct irq_domain irq_data->chip_data = data;mp_irqdomain_get_attr (mp_pin_to_gsi (ioapic, pin), data, info); -add_pin_to_irq_node (data,ioapic_alloc_attr_node (info), ioapic, pin); +if (!add_pin_to_irq_node (data,ioapic_alloc_attr_node (info), ioapic, pin)) { + ret = -ENOMEM ; + goto free_irqs; + }mp_preconfigure_entry (data);mp_register_handler (virq, data->is_level);
@@ -3044,6 +3036,12 @@ int mp_irqdomain_alloc(struct irq_domain ioapic,mpc_ioapic_id (ioapic), pin, virq, data->is_level, data->active_low);return 0 ; + +free_irqs: +irq_domain_free_irqs_parent (domain, virq, nr_irqs); +free_data: +kfree (data); +return ret; } void mp_irqdomain_free(struct irq_domain *domain, unsigned int virq,
Re: [patch 01/15] x86/ioapic: Handle allocation failures gracefully
Quoted 23 lines · Thomas Gleixner
Breno observed panics when using failslab under certain conditions during runtime:
can not alloc irq_pin_list (-1,0,20) Kernel panic - not syncing: IO-APIC: failed to add irq-pin. Can not proceed panic+0x4e9/0x590 mp_irqdomain_alloc+0x9ab/0xa80 irq_domain_alloc_irqs_locked+0x25d/0x8d0 __irq_domain_alloc_irqs+0x80/0x110 mp_map_pin_to_irq+0x645/0x890 acpi_register_gsi_ioapic+0xe6/0x150 hpet_open+0x313/0x480That's a pointless panic which is a leftover of the historic IO/APIC code which panic'ed during early boot when the interrupt allocation failed.
The only place which might justify panic is the PIT/HPET
timer_check()code which tries to figure out whether the timer interrupt is delivered through the IO/APIC. But that code does not require to handle interrupt allocation failures. If the interrupt cannot be allocated then timer delivery fails and it either panics due to that or falls back to legacy mode.
Quoted 7 lines
Cure this by removing the panic wrapper around
__add_pin_to_irq_node()and makingmp_irqdomain_alloc()aware of the failure condition and handle it as any other failure in this function gracefully.Reported-by Breno Leitao <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>
Thanks Thomas!
--breno
PATCH 2/15 x86/ioapic: Mark mp_alloc_timer_irq() __init
In reply to Thomas GleixnerOnly invoked from check_timer() which is __init too. Cleanup the variable declaration while at it.
--- arch/x86/kernel/apic/io_apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/apic/io_apic.c +2 -2
@@ -2122,10 +2122,10 @@ static int __init disable_timer_pin_setu }early_param ("disable_timer_pin_1" , disable_timer_pin_setup); -static int mp_alloc_timer_irq (int ioapic,int pin) +static int __init mp_alloc_timer_irq (int ioapic,int pin) { -int irq =-1 ;struct irq_domain *domain =mp_ioapic_irqdomain (ioapic); +int irq =-1 ;if (domain) {struct irq_alloc_info info;
Re: [patch 02/15] x86/ioapic: Mark mp_alloc_timer_irq() __init
Quoted 4 lines · Thomas Gleixner
Only invoked from
check_timer()which is__inittoo. Cleanup the variable declaration while at it.Signed-off-by Thomas Gleixner <[email protected]>
[tip: x86/apic] x86/ioapic: Mark mp_alloc_timer_irq() __init
In reply to Thomas GleixnerThe following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: 6daceb891d5fd8729f9b4453b35d3d47dab10914 Gitweb: https://git.kernel.org/tip/6daceb891d5fd8729f9b4453b35d3d47dab10914 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:36 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:27 +02:00
x86/ioapic: Mark mp_alloc_timer_irq() __init
Only invoked from check_timer() which is __init too. Cleanup the variable declaration while at it.
--- arch/x86/kernel/apic/io_apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/apic/io_apic.c +2 -2
@@ -2122,10 +2122,10 @@ static int __init disable_timer_pin_setup(char *arg) }early_param ("disable_timer_pin_1" , disable_timer_pin_setup); -static int mp_alloc_timer_irq (int ioapic,int pin) +static int __init mp_alloc_timer_irq (int ioapic,int pin) { -int irq =-1 ;struct irq_domain *domain =mp_ioapic_irqdomain (ioapic); +int irq =-1 ;if (domain) {struct irq_alloc_info info;
PATCH 3/15 x86/ioapic: Cleanup structs
In reply to Thomas GleixnerMake them conforming to the TIP coding style guide.
--- arch/x86/kernel/apic/io_apic.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-)
arch/x86/kernel/apic/io_apic.c +14 -18
@@ -86,8 +86,8 @@ static unsigned int ioapic_dynirq_base;static int ioapic_initialized;struct irq_pin_list { -struct list_head list; -int apic, pin; +struct list_head list; +int apic, pin; };struct mp_chip_data {
@@ -96,7 +96,7 @@ struct mp_chip_data {bool is_level;bool active_low;bool isa_irq; -u32 count; +u32 count; };struct mp_ioapic_gsi {
@@ -105,21 +105,17 @@ struct mp_ioapic_gsi { };static struct ioapic { -/* -* # of IRQ routing registers -*/ -int nr_registers; -/* -* Saved state during suspend/resume, or while enabling intr-remap. -*/ -struct IO_APIC_route_entry *saved_registers; +/* # of IRQ routing registers */ +int nr_registers; +/* Saved state during suspend/resume, or while enabling intr-remap. */ +struct IO_APIC_route_entry *saved_registers;/* I/O APIC config */ -struct mpc_ioapic mp_config; +struct mpc_ioapic mp_config;/* IO APIC gsi routing info */ -struct mp_ioapic_gsi gsi_config; -struct ioapic_domain_cfg irqdomain_cfg; -struct irq_domain *irqdomain; -struct resource *iomem_res; +struct mp_ioapic_gsi gsi_config; +struct ioapic_domain_cfg irqdomain_cfg; +struct irq_domain *irqdomain; +struct resource *iomem_res; } ioapics[MAX_IO_APICS ];#define mpc_ioapic_ver (ioapic_idx) ioapics[ioapic_idx].mp_config.apicver
@@ -2431,8 +2427,8 @@ static void ioapic_resume(void) }static struct syscore_ops ioapic_syscore_ops = { - .suspend = save_ioapic_entries, - .resume = ioapic_resume, + .suspend = save_ioapic_entries, + .resume = ioapic_resume, };static int __init ioapic_init_ops (void )
[tip: x86/apic] x86/ioapic: Cleanup structs
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: d8c76d0167a0f20d071c540b1ffba5794eeb83ca Gitweb: https://git.kernel.org/tip/d8c76d0167a0f20d071c540b1ffba5794eeb83ca Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:37 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:27 +02:00
x86/ioapic: Cleanup structs
Make them conforming to the TIP coding style guide.
--- arch/x86/kernel/apic/io_apic.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-)
arch/x86/kernel/apic/io_apic.c +14 -18
@@ -86,8 +86,8 @@ static unsigned int ioapic_dynirq_base;static int ioapic_initialized;struct irq_pin_list { -struct list_head list; -int apic, pin; +struct list_head list; +int apic, pin; };struct mp_chip_data {
@@ -96,7 +96,7 @@ struct mp_chip_data {bool is_level;bool active_low;bool isa_irq; -u32 count; +u32 count; };struct mp_ioapic_gsi {
@@ -105,21 +105,17 @@ struct mp_ioapic_gsi { };static struct ioapic { -/* -* # of IRQ routing registers -*/ -int nr_registers; -/* -* Saved state during suspend/resume, or while enabling intr-remap. -*/ -struct IO_APIC_route_entry *saved_registers; +/* # of IRQ routing registers */ +int nr_registers; +/* Saved state during suspend/resume, or while enabling intr-remap. */ +struct IO_APIC_route_entry *saved_registers;/* I/O APIC config */ -struct mpc_ioapic mp_config; +struct mpc_ioapic mp_config;/* IO APIC gsi routing info */ -struct mp_ioapic_gsi gsi_config; -struct ioapic_domain_cfg irqdomain_cfg; -struct irq_domain *irqdomain; -struct resource *iomem_res; +struct mp_ioapic_gsi gsi_config; +struct ioapic_domain_cfg irqdomain_cfg; +struct irq_domain *irqdomain; +struct resource *iomem_res; } ioapics[MAX_IO_APICS ];#define mpc_ioapic_ver (ioapic_idx) ioapics[ioapic_idx].mp_config.apicver
@@ -2431,8 +2427,8 @@ static void ioapic_resume(void) }static struct syscore_ops ioapic_syscore_ops = { - .suspend = save_ioapic_entries, - .resume = ioapic_resume, + .suspend = save_ioapic_entries, + .resume = ioapic_resume, };static int __init ioapic_init_ops (void )
PATCH 4/15 x86/ioapic: Use guard() for locking where applicable
In reply to Thomas GleixnerKISS rules!
--- arch/x86/kernel/apic/io_apic.c | 192 +++++++++++++---------------------------- 1 file changed, 64 insertions(+), 128 deletions(-)
arch/x86/kernel/apic/io_apic.c +64 -128
@@ -296,14 +296,8 @@ static struct IO_APIC_route_entry __ioapstatic struct IO_APIC_route_entry ioapic_read_entry (int apic,int pin) { -struct IO_APIC_route_entry entry; -unsigned long flags; - -raw_spin_lock_irqsave (&ioapic_lock, flags); - entry =__ioapic_read_entry (apic, pin); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); - -return entry; +guard (raw_spinlock_irqsave)(&ioapic_lock); +return __ioapic_read_entry (apic, pin); }/*
@@ -320,11 +314,8 @@ static void __ioapic_write_entry(int apistatic void ioapic_write_entry (int apic,int pin,struct IO_APIC_route_entry e) { -unsigned long flags; - -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);__ioapic_write_entry (apic, pin, e); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }/*
@@ -335,12 +326,10 @@ static void ioapic_write_entry(int apic,static void ioapic_mask_entry (int apic,int pin) {struct IO_APIC_route_entry e = { .masked = true }; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);io_apic_write (apic,0x10 +2 *pin, e.w1);io_apic_write (apic,0x11 +2 *pin, e.w2); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }/*
@@ -433,11 +422,9 @@ static void io_apic_sync(struct irq_pin_static void mask_ioapic_irq (struct irq_data *irq_data) {struct mp_chip_data *data = irq_data->chip_data; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);io_apic_modify_irq (data, true, &io_apic_sync); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }static void __unmask_ioapic (struct mp_chip_data *data)
@@ -448,11 +435,9 @@ static void __unmask_ioapic(struct mp_chstatic void unmask_ioapic_irq (struct irq_data *irq_data) {struct mp_chip_data *data = irq_data->chip_data; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);__unmask_ioapic (data); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }/*
@@ -497,13 +482,11 @@ static void __eoi_ioapic_pin(int apic, istatic void eoi_ioapic_pin (int vector,struct mp_chip_data *data) { -unsigned long flags;struct irq_pin_list *entry; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);for_each_irq_pin (entry, data->irq_2_pin)__eoi_ioapic_pin (entry->apic, entry->pin, vector); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }static void clear_IO_APIC_pin (unsigned int apic,unsigned int pin)
@@ -526,8 +509,6 @@ static void clear_IO_APIC_pin(unsigned i }if (entry.irr) { -unsigned long flags; -/* * Make sure the trigger mode is set to level. Explicit EOI * doesn't clear the remote-IRR if the trigger mode is not
@@ -537,9 +518,8 @@ static void clear_IO_APIC_pin(unsigned i entry.is_level = true;ioapic_write_entry (apic, pin, entry); } -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);__eoi_ioapic_pin (apic, pin, entry.vector); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }/*
@@ -1033,7 +1013,7 @@ static int mp_map_pin_to_irq(u32 gsi, inreturn -EINVAL ; } -mutex_lock (&ioapic_mutex); +guard (mutex)(&ioapic_mutex);if (!(flags &IOAPIC_MAP_ALLOC )) {if (!legacy) { irq =irq_find_mapping (domain, pin);
@@ -1054,8 +1034,6 @@ static int mp_map_pin_to_irq(u32 gsi, in data->count++; } } -mutex_unlock (&ioapic_mutex); -return irq; }
@@ -1120,10 +1098,9 @@ void mp_unmap_irq(int irq)if (!data || data->isa_irq)return ; -mutex_lock (&ioapic_mutex); +guard (mutex)(&ioapic_mutex);if (--data->count ==0 )irq_domain_free_irqs (irq,1 ); -mutex_unlock (&ioapic_mutex); }/*
@@ -1251,16 +1228,15 @@ static void __init print_IO_APIC(int ioaunion IO_APIC_reg_01 reg_01;union IO_APIC_reg_02 reg_02;union IO_APIC_reg_03 reg_03; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (ioapic_idx,0 ); - reg_01.raw =io_apic_read (ioapic_idx,1 ); -if (reg_01.bits.version >=0x10 ) - reg_02.raw =io_apic_read (ioapic_idx,2 ); -if (reg_01.bits.version >=0x20 ) - reg_03.raw =io_apic_read (ioapic_idx,3 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); + scoped_guard (raw_spinlock_irqsave, &ioapic_lock) { + reg_00.raw =io_apic_read (ioapic_idx,0 ); + reg_01.raw =io_apic_read (ioapic_idx,1 ); +if (reg_01.bits.version >=0x10 ) + reg_02.raw =io_apic_read (ioapic_idx,2 ); +if (reg_01.bits.version >=0x20 ) + reg_03.raw =io_apic_read (ioapic_idx,3 ); + }printk (KERN_DEBUG "IO APIC #%d......\n" ,mpc_ioapic_id (ioapic_idx));printk (KERN_DEBUG ".... register #00: %08X\n" , reg_00.raw);
@@ -1451,7 +1427,6 @@ static void __init setup_ioapic_ids_fromconst u32 broadcast_id =0xF ;union IO_APIC_reg_00 reg_00;unsigned char old_id; -unsigned long flags;int ioapic_idx, i;/*
@@ -1465,9 +1440,8 @@ static void __init setup_ioapic_ids_from*/ for_each_ioapic (ioapic_idx) {/* Read the register 0 value */ -raw_spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (ioapic_idx,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); +scoped_guard (raw_spinlock_irqsave, &ioapic_lock) + reg_00.raw = io_apic_read(ioapic_idx, 0); old_id =mpc_ioapic_id (ioapic_idx);
@@ -1522,16 +1496,11 @@ static void __init setup_ioapic_ids_from mpc_ioapic_id(ioapic_idx)); reg_00.bits.ID =mpc_ioapic_id (ioapic_idx); -raw_spin_lock_irqsave (&ioapic_lock, flags); -io_apic_write (ioapic_idx,0 , reg_00.raw); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); - -/* -* Sanity check -*/ -raw_spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (ioapic_idx,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); + scoped_guard (raw_spinlock_irqsave, &ioapic_lock) { +io_apic_write (ioapic_idx,0 , reg_00.raw); + reg_00.raw =io_apic_read (ioapic_idx,0 ); + } +/* Sanity check */ if (reg_00.bits.ID !=mpc_ioapic_id (ioapic_idx))pr_cont ("could not set ID!\n" );else
@@ -1661,17 +1630,14 @@ static int __init timer_irq_works(void)static unsigned int startup_ioapic_irq (struct irq_data *data) {int was_pending =0 , irq = data->irq; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);if (irq <nr_legacy_irqs ()) { legacy_pic->mask (irq);if (legacy_pic->irq_pending (irq)) was_pending =1 ; }__unmask_ioapic (data->chip_data); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); -return was_pending; }
@@ -1681,9 +1647,8 @@ atomic_t irq_mis_count;static bool io_apic_level_ack_pending (struct mp_chip_data *data) {struct irq_pin_list *entry; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);for_each_irq_pin (entry, data->irq_2_pin) {struct IO_APIC_route_entry e;int pin;
@@ -1691,13 +1656,9 @@ static bool io_apic_level_ack_pending(st pin = entry->pin; e.w1 =io_apic_read (entry->apic,0x10 + pin*2 );/* Is the remote IRR bit set? */ -if (e.irr) { -raw_spin_unlock_irqrestore (&ioapic_lock, flags); +if (e.irr)return true; - } } -raw_spin_unlock_irqrestore (&ioapic_lock, flags); -return false; }
@@ -1898,18 +1859,16 @@ static void ioapic_configure_entry(struc__ioapic_write_entry (entry->apic, entry->pin, mpd->entry); } -static int ioapic_set_affinity (struct irq_data *irq_data, -const struct cpumask *mask,bool force) +static int ioapic_set_affinity (struct irq_data *irq_data,const struct cpumask *mask,bool force) {struct irq_data *parent = irq_data->parent_data; -unsigned long flags;int ret; ret = parent->chip->irq_set_affinity (parent, mask, force); -raw_spin_lock_irqsave (&ioapic_lock, flags); + +guard (raw_spinlock_irqsave)(&ioapic_lock);if (ret >=0 && ret !=IRQ_SET_MASK_OK_DONE )ioapic_configure_entry (irq_data); -raw_spin_unlock_irqrestore (&ioapic_lock, flags);return ret; }
@@ -1928,9 +1887,8 @@ static int ioapic_set_affinity(struct ir* * Verify that the corresponding Remote-IRR bits are clear. */ -static int ioapic_irq_get_chip_state (struct irq_data *irqd, -enum irqchip_irq_state which, -bool *state) +static int ioapic_irq_get_chip_state (struct irq_data *irqd,enum irqchip_irq_state which, +bool *state) {struct mp_chip_data *mcd = irqd->chip_data;struct IO_APIC_route_entry rentry;
@@ -1940,7 +1898,8 @@ static int ioapic_irq_get_chip_state(strreturn -EINVAL ; *state = false; -raw_spin_lock (&ioapic_lock); + +guard (raw_spinlock)(&ioapic_lock);for_each_irq_pin (p, mcd->irq_2_pin) { rentry =__ioapic_read_entry (p->apic, p->pin);/*
@@ -1954,7 +1913,6 @@ static int ioapic_irq_get_chip_state(strbreak ; } } -raw_spin_unlock (&ioapic_lock);return 0 ; }
@@ -2129,9 +2087,8 @@ static int __init mp_alloc_timer_irq(intioapic_set_alloc_attr (&info,NUMA_NO_NODE ,0 ,0 ); info.devid =mpc_ioapic_id (ioapic); info.ioapic.pin = pin; -mutex_lock (&ioapic_mutex); +guard (mutex)(&ioapic_mutex); irq =alloc_isa_irq_from_domain (domain,0 , ioapic, pin, &info); -mutex_unlock (&ioapic_mutex); }return irq;
@@ -2142,8 +2099,6 @@ static int __init mp_alloc_timer_irq(int* a wide range of boards and BIOS bugs. Fortunately only the timer IRQ * is so screwy. Thanks to Brian Perkins for testing/hacking this beast * fanatically on his truly buggy board. -* -* FIXME: really need to revamp this for all platforms. */ static inline void __init check_timer (void ) {
@@ -2404,16 +2359,14 @@ void __init setup_IO_APIC(void)static void resume_ioapic_id (int ioapic_idx) { -unsigned long flags;union IO_APIC_reg_00 reg_00; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock); reg_00.raw =io_apic_read (ioapic_idx,0 );if (reg_00.bits.ID !=mpc_ioapic_id (ioapic_idx)) { reg_00.bits.ID =mpc_ioapic_id (ioapic_idx);io_apic_write (ioapic_idx,0 , reg_00.raw); } -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }static void ioapic_resume (void )
@@ -2443,15 +2396,13 @@ device_initcall(ioapic_init_ops);static int io_apic_get_redir_entries (int ioapic) {union IO_APIC_reg_01 reg_01; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock); reg_01.raw =io_apic_read (ioapic,1 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); -/* The register returns the maximum index redir index -* supported, which is one less than the total number of redir -* entries. +/* +* The register returns the maximum index redir index supported, +* which is one less than the total number of redir entries. */ return reg_01.bits.entries +1 ; }
@@ -2481,16 +2432,14 @@ static int io_apic_get_unique_id(int ioa static DECLARE_BITMAP(apic_id_map, MAX_LOCAL_APIC);const u32 broadcast_id =0xF ;union IO_APIC_reg_00 reg_00; -unsigned long flags;int i =0 ;/* Initialize the ID map */ if (bitmap_empty (apic_id_map,MAX_LOCAL_APIC ))copy_phys_cpu_present_map (apic_id_map); -raw_spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (ioapic,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); +scoped_guard (raw_spinlock_irqsave, &ioapic_lock) + reg_00.raw = io_apic_read(ioapic, 0);if (apic_id >= broadcast_id) { pr_warn("IOAPIC[%d]: Invalid apic_id %d, trying %d\n",
@@ -2517,21 +2466,19 @@ static int io_apic_get_unique_id(int ioaif (reg_00.bits.ID != apic_id) { reg_00.bits.ID = apic_id; -raw_spin_lock_irqsave (&ioapic_lock, flags); -io_apic_write (ioapic,0 , reg_00.raw); - reg_00.raw =io_apic_read (ioapic,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); + scoped_guard (raw_spinlock_irqsave, &ioapic_lock) { +io_apic_write (ioapic,0 , reg_00.raw); + reg_00.raw =io_apic_read (ioapic,0 ); + }/* Sanity check */ if (reg_00.bits.ID != apic_id) { -pr_err ("IOAPIC[%d]: Unable to change apic_id!\n" , - ioapic); +pr_err ("IOAPIC[%d]: Unable to change apic_id!\n" , ioapic);return -1 ; } } -apic_printk (APIC_VERBOSE ,KERN_INFO -"IOAPIC[%d]: Assigned apic_id %d\n" , ioapic, apic_id); +apic_printk (APIC_VERBOSE ,KERN_INFO "IOAPIC[%d]: Assigned apic_id %d\n" , ioapic, apic_id);return apic_id; }
@@ -2547,7 +2494,6 @@ static u8 io_apic_unique_id(int idx, u8 {union IO_APIC_reg_00 reg_00;DECLARE_BITMAP (used,256 ); -unsigned long flags;u8 new_id;int i;
@@ -2563,26 +2509,23 @@ static u8 io_apic_unique_id(int idx, u8* Read the current id from the ioapic and keep it if * available. */ -raw_spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (idx,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); +scoped_guard (raw_spinlock_irqsave, &ioapic_lock) + reg_00.raw = io_apic_read(idx, 0); + new_id = reg_00.bits.ID;if (!test_bit (new_id, used)) { -apic_printk (APIC_VERBOSE ,KERN_INFO -"IOAPIC[%d]: Using reg apic_id %d instead of %d\n" , - idx, new_id, id); +apic_printk (APIC_VERBOSE ,KERN_INFO "IOAPIC[%d]: Using reg apic_id %d instead of %d\n" , + idx, new_id, id);return new_id; } -/* -* Get the next free id and write it to the ioapic. -*/ +/* Get the next free id and write it to the ioapic. */ new_id =find_first_zero_bit (used,256 ); reg_00.bits.ID = new_id; -raw_spin_lock_irqsave (&ioapic_lock, flags); -io_apic_write (idx,0 , reg_00.raw); - reg_00.raw =io_apic_read (idx,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); + scoped_guard (raw_spinlock_irqsave, &ioapic_lock) { +io_apic_write (idx,0 , reg_00.raw); + reg_00.raw =io_apic_read (idx,0 ); + }/* Sanity check */ BUG_ON (reg_00.bits.ID != new_id);
@@ -2592,12 +2535,10 @@ static u8 io_apic_unique_id(int idx, u8static int io_apic_get_version (int ioapic) { -union IO_APIC_reg_01 reg_01; -unsigned long flags; +union IO_APIC_reg_01 reg_01; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock); reg_01.raw =io_apic_read (ioapic,1 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags);return reg_01.bits.version; }
@@ -3050,22 +2991,17 @@ void mp_irqdomain_free(struct irq_domain irq_data =irq_domain_get_irq_data (domain, virq);if (irq_data && irq_data->chip_data) { data = irq_data->chip_data; -__remove_pin_from_irq (data,mp_irqdomain_ioapic_idx (domain), - (int )irq_data->hwirq); +__remove_pin_from_irq (data,mp_irqdomain_ioapic_idx (domain), (int )irq_data->hwirq);WARN_ON (!list_empty (&data->irq_2_pin));kfree (irq_data->chip_data); }irq_domain_free_irqs_top (domain, virq, nr_irqs); } -int mp_irqdomain_activate (struct irq_domain *domain, -struct irq_data *irq_data,bool reserve) +int mp_irqdomain_activate (struct irq_domain *domain,struct irq_data *irq_data,bool reserve) { -unsigned long flags; - -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);ioapic_configure_entry (irq_data); -raw_spin_unlock_irqrestore (&ioapic_lock, flags);return 0 ; }
[tip: x86/apic] x86/ioapic: Use guard() for locking where applicable
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: ed57538b8510a5811ec049659b726cdb24ed6b46 Gitweb: https://git.kernel.org/tip/ed57538b8510a5811ec049659b726cdb24ed6b46 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:38 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:27 +02:00
x86/ioapic: Use guard() for locking where applicable
KISS rules!
--- arch/x86/kernel/apic/io_apic.c | 192 ++++++++++---------------------- 1 file changed, 64 insertions(+), 128 deletions(-)
arch/x86/kernel/apic/io_apic.c +64 -128
@@ -296,14 +296,8 @@ static struct IO_APIC_route_entry __ioapic_read_entry(int apic, int pin)static struct IO_APIC_route_entry ioapic_read_entry (int apic,int pin) { -struct IO_APIC_route_entry entry; -unsigned long flags; - -raw_spin_lock_irqsave (&ioapic_lock, flags); - entry =__ioapic_read_entry (apic, pin); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); - -return entry; +guard (raw_spinlock_irqsave)(&ioapic_lock); +return __ioapic_read_entry (apic, pin); }/*
@@ -320,11 +314,8 @@ static void __ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry estatic void ioapic_write_entry (int apic,int pin,struct IO_APIC_route_entry e) { -unsigned long flags; - -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);__ioapic_write_entry (apic, pin, e); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }/*
@@ -335,12 +326,10 @@ static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)static void ioapic_mask_entry (int apic,int pin) {struct IO_APIC_route_entry e = { .masked = true }; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);io_apic_write (apic,0x10 +2 *pin, e.w1);io_apic_write (apic,0x11 +2 *pin, e.w2); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }/*
@@ -433,11 +422,9 @@ static void io_apic_sync(struct irq_pin_list *entry)static void mask_ioapic_irq (struct irq_data *irq_data) {struct mp_chip_data *data = irq_data->chip_data; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);io_apic_modify_irq (data, true, &io_apic_sync); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }static void __unmask_ioapic (struct mp_chip_data *data)
@@ -448,11 +435,9 @@ static void __unmask_ioapic(struct mp_chip_data *data)static void unmask_ioapic_irq (struct irq_data *irq_data) {struct mp_chip_data *data = irq_data->chip_data; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);__unmask_ioapic (data); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }/*
@@ -497,13 +482,11 @@ static void __eoi_ioapic_pin(int apic, int pin, int vector)static void eoi_ioapic_pin (int vector,struct mp_chip_data *data) { -unsigned long flags;struct irq_pin_list *entry; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);for_each_irq_pin (entry, data->irq_2_pin)__eoi_ioapic_pin (entry->apic, entry->pin, vector); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }static void clear_IO_APIC_pin (unsigned int apic,unsigned int pin)
@@ -526,8 +509,6 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin) }if (entry.irr) { -unsigned long flags; -/* * Make sure the trigger mode is set to level. Explicit EOI * doesn't clear the remote-IRR if the trigger mode is not
@@ -537,9 +518,8 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin) entry.is_level = true;ioapic_write_entry (apic, pin, entry); } -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);__eoi_ioapic_pin (apic, pin, entry.vector); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }/*
@@ -1033,7 +1013,7 @@ static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin,return -EINVAL ; } -mutex_lock (&ioapic_mutex); +guard (mutex)(&ioapic_mutex);if (!(flags &IOAPIC_MAP_ALLOC )) {if (!legacy) { irq =irq_find_mapping (domain, pin);
@@ -1054,8 +1034,6 @@ static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin, data->count++; } } -mutex_unlock (&ioapic_mutex); -return irq; }
@@ -1120,10 +1098,9 @@ void mp_unmap_irq(int irq)if (!data || data->isa_irq)return ; -mutex_lock (&ioapic_mutex); +guard (mutex)(&ioapic_mutex);if (--data->count ==0 )irq_domain_free_irqs (irq,1 ); -mutex_unlock (&ioapic_mutex); }/*
@@ -1251,16 +1228,15 @@ static void __init print_IO_APIC(int ioapic_idx)union IO_APIC_reg_01 reg_01;union IO_APIC_reg_02 reg_02;union IO_APIC_reg_03 reg_03; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (ioapic_idx,0 ); - reg_01.raw =io_apic_read (ioapic_idx,1 ); -if (reg_01.bits.version >=0x10 ) - reg_02.raw =io_apic_read (ioapic_idx,2 ); -if (reg_01.bits.version >=0x20 ) - reg_03.raw =io_apic_read (ioapic_idx,3 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); + scoped_guard (raw_spinlock_irqsave, &ioapic_lock) { + reg_00.raw =io_apic_read (ioapic_idx,0 ); + reg_01.raw =io_apic_read (ioapic_idx,1 ); +if (reg_01.bits.version >=0x10 ) + reg_02.raw =io_apic_read (ioapic_idx,2 ); +if (reg_01.bits.version >=0x20 ) + reg_03.raw =io_apic_read (ioapic_idx,3 ); + }printk (KERN_DEBUG "IO APIC #%d......\n" ,mpc_ioapic_id (ioapic_idx));printk (KERN_DEBUG ".... register #00: %08X\n" , reg_00.raw);
@@ -1451,7 +1427,6 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void)const u32 broadcast_id =0xF ;union IO_APIC_reg_00 reg_00;unsigned char old_id; -unsigned long flags;int ioapic_idx, i;/*
@@ -1465,9 +1440,8 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void)*/ for_each_ioapic (ioapic_idx) {/* Read the register 0 value */ -raw_spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (ioapic_idx,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); +scoped_guard (raw_spinlock_irqsave, &ioapic_lock) + reg_00.raw = io_apic_read(ioapic_idx, 0); old_id =mpc_ioapic_id (ioapic_idx);
@@ -1522,16 +1496,11 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void) mpc_ioapic_id(ioapic_idx)); reg_00.bits.ID =mpc_ioapic_id (ioapic_idx); -raw_spin_lock_irqsave (&ioapic_lock, flags); -io_apic_write (ioapic_idx,0 , reg_00.raw); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); - -/* -* Sanity check -*/ -raw_spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (ioapic_idx,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); + scoped_guard (raw_spinlock_irqsave, &ioapic_lock) { +io_apic_write (ioapic_idx,0 , reg_00.raw); + reg_00.raw =io_apic_read (ioapic_idx,0 ); + } +/* Sanity check */ if (reg_00.bits.ID !=mpc_ioapic_id (ioapic_idx))pr_cont ("could not set ID!\n" );else
@@ -1661,17 +1630,14 @@ static int __init timer_irq_works(void)static unsigned int startup_ioapic_irq (struct irq_data *data) {int was_pending =0 , irq = data->irq; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);if (irq <nr_legacy_irqs ()) { legacy_pic->mask (irq);if (legacy_pic->irq_pending (irq)) was_pending =1 ; }__unmask_ioapic (data->chip_data); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); -return was_pending; }
@@ -1681,9 +1647,8 @@ atomic_t irq_mis_count;static bool io_apic_level_ack_pending (struct mp_chip_data *data) {struct irq_pin_list *entry; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);for_each_irq_pin (entry, data->irq_2_pin) {struct IO_APIC_route_entry e;int pin;
@@ -1691,13 +1656,9 @@ static bool io_apic_level_ack_pending(struct mp_chip_data *data) pin = entry->pin; e.w1 =io_apic_read (entry->apic,0x10 + pin*2 );/* Is the remote IRR bit set? */ -if (e.irr) { -raw_spin_unlock_irqrestore (&ioapic_lock, flags); +if (e.irr)return true; - } } -raw_spin_unlock_irqrestore (&ioapic_lock, flags); -return false; }
@@ -1898,18 +1859,16 @@ static void ioapic_configure_entry(struct irq_data *irqd)__ioapic_write_entry (entry->apic, entry->pin, mpd->entry); } -static int ioapic_set_affinity (struct irq_data *irq_data, -const struct cpumask *mask,bool force) +static int ioapic_set_affinity (struct irq_data *irq_data,const struct cpumask *mask,bool force) {struct irq_data *parent = irq_data->parent_data; -unsigned long flags;int ret; ret = parent->chip->irq_set_affinity (parent, mask, force); -raw_spin_lock_irqsave (&ioapic_lock, flags); + +guard (raw_spinlock_irqsave)(&ioapic_lock);if (ret >=0 && ret !=IRQ_SET_MASK_OK_DONE )ioapic_configure_entry (irq_data); -raw_spin_unlock_irqrestore (&ioapic_lock, flags);return ret; }
@@ -1928,9 +1887,8 @@ static int ioapic_set_affinity(struct irq_data *irq_data,* * Verify that the corresponding Remote-IRR bits are clear. */ -static int ioapic_irq_get_chip_state (struct irq_data *irqd, -enum irqchip_irq_state which, -bool *state) +static int ioapic_irq_get_chip_state (struct irq_data *irqd,enum irqchip_irq_state which, +bool *state) {struct mp_chip_data *mcd = irqd->chip_data;struct IO_APIC_route_entry rentry;
@@ -1940,7 +1898,8 @@ static int ioapic_irq_get_chip_state(struct irq_data *irqd,return -EINVAL ; *state = false; -raw_spin_lock (&ioapic_lock); + +guard (raw_spinlock)(&ioapic_lock);for_each_irq_pin (p, mcd->irq_2_pin) { rentry =__ioapic_read_entry (p->apic, p->pin);/*
@@ -1954,7 +1913,6 @@ static int ioapic_irq_get_chip_state(struct irq_data *irqd,break ; } } -raw_spin_unlock (&ioapic_lock);return 0 ; }
@@ -2129,9 +2087,8 @@ static int __init mp_alloc_timer_irq(int ioapic, int pin)ioapic_set_alloc_attr (&info,NUMA_NO_NODE ,0 ,0 ); info.devid =mpc_ioapic_id (ioapic); info.ioapic.pin = pin; -mutex_lock (&ioapic_mutex); +guard (mutex)(&ioapic_mutex); irq =alloc_isa_irq_from_domain (domain,0 , ioapic, pin, &info); -mutex_unlock (&ioapic_mutex); }return irq;
@@ -2142,8 +2099,6 @@ static int __init mp_alloc_timer_irq(int ioapic, int pin)* a wide range of boards and BIOS bugs. Fortunately only the timer IRQ * is so screwy. Thanks to Brian Perkins for testing/hacking this beast * fanatically on his truly buggy board. -* -* FIXME: really need to revamp this for all platforms. */ static inline void __init check_timer (void ) {
@@ -2404,16 +2359,14 @@ void __init setup_IO_APIC(void)static void resume_ioapic_id (int ioapic_idx) { -unsigned long flags;union IO_APIC_reg_00 reg_00; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock); reg_00.raw =io_apic_read (ioapic_idx,0 );if (reg_00.bits.ID !=mpc_ioapic_id (ioapic_idx)) { reg_00.bits.ID =mpc_ioapic_id (ioapic_idx);io_apic_write (ioapic_idx,0 , reg_00.raw); } -raw_spin_unlock_irqrestore (&ioapic_lock, flags); }static void ioapic_resume (void )
@@ -2443,15 +2396,13 @@ device_initcall(ioapic_init_ops);static int io_apic_get_redir_entries (int ioapic) {union IO_APIC_reg_01 reg_01; -unsigned long flags; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock); reg_01.raw =io_apic_read (ioapic,1 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); -/* The register returns the maximum index redir index -* supported, which is one less than the total number of redir -* entries. +/* +* The register returns the maximum index redir index supported, +* which is one less than the total number of redir entries. */ return reg_01.bits.entries +1 ; }
@@ -2481,16 +2432,14 @@ static int io_apic_get_unique_id(int ioapic, int apic_id) static DECLARE_BITMAP(apic_id_map, MAX_LOCAL_APIC);const u32 broadcast_id =0xF ;union IO_APIC_reg_00 reg_00; -unsigned long flags;int i =0 ;/* Initialize the ID map */ if (bitmap_empty (apic_id_map,MAX_LOCAL_APIC ))copy_phys_cpu_present_map (apic_id_map); -raw_spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (ioapic,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); +scoped_guard (raw_spinlock_irqsave, &ioapic_lock) + reg_00.raw = io_apic_read(ioapic, 0);if (apic_id >= broadcast_id) { pr_warn("IOAPIC[%d]: Invalid apic_id %d, trying %d\n",
@@ -2517,21 +2466,19 @@ static int io_apic_get_unique_id(int ioapic, int apic_id)if (reg_00.bits.ID != apic_id) { reg_00.bits.ID = apic_id; -raw_spin_lock_irqsave (&ioapic_lock, flags); -io_apic_write (ioapic,0 , reg_00.raw); - reg_00.raw =io_apic_read (ioapic,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); + scoped_guard (raw_spinlock_irqsave, &ioapic_lock) { +io_apic_write (ioapic,0 , reg_00.raw); + reg_00.raw =io_apic_read (ioapic,0 ); + }/* Sanity check */ if (reg_00.bits.ID != apic_id) { -pr_err ("IOAPIC[%d]: Unable to change apic_id!\n" , - ioapic); +pr_err ("IOAPIC[%d]: Unable to change apic_id!\n" , ioapic);return -1 ; } } -apic_printk (APIC_VERBOSE ,KERN_INFO -"IOAPIC[%d]: Assigned apic_id %d\n" , ioapic, apic_id); +apic_printk (APIC_VERBOSE ,KERN_INFO "IOAPIC[%d]: Assigned apic_id %d\n" , ioapic, apic_id);return apic_id; }
@@ -2547,7 +2494,6 @@ static u8 io_apic_unique_id(int idx, u8 id) {union IO_APIC_reg_00 reg_00;DECLARE_BITMAP (used,256 ); -unsigned long flags;u8 new_id;int i;
@@ -2563,26 +2509,23 @@ static u8 io_apic_unique_id(int idx, u8 id)* Read the current id from the ioapic and keep it if * available. */ -raw_spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (idx,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); +scoped_guard (raw_spinlock_irqsave, &ioapic_lock) + reg_00.raw = io_apic_read(idx, 0); + new_id = reg_00.bits.ID;if (!test_bit (new_id, used)) { -apic_printk (APIC_VERBOSE ,KERN_INFO -"IOAPIC[%d]: Using reg apic_id %d instead of %d\n" , - idx, new_id, id); +apic_printk (APIC_VERBOSE ,KERN_INFO "IOAPIC[%d]: Using reg apic_id %d instead of %d\n" , + idx, new_id, id);return new_id; } -/* -* Get the next free id and write it to the ioapic. -*/ +/* Get the next free id and write it to the ioapic. */ new_id =find_first_zero_bit (used,256 ); reg_00.bits.ID = new_id; -raw_spin_lock_irqsave (&ioapic_lock, flags); -io_apic_write (idx,0 , reg_00.raw); - reg_00.raw =io_apic_read (idx,0 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags); + scoped_guard (raw_spinlock_irqsave, &ioapic_lock) { +io_apic_write (idx,0 , reg_00.raw); + reg_00.raw =io_apic_read (idx,0 ); + }/* Sanity check */ BUG_ON (reg_00.bits.ID != new_id);
@@ -2592,12 +2535,10 @@ static u8 io_apic_unique_id(int idx, u8 id)static int io_apic_get_version (int ioapic) { -union IO_APIC_reg_01 reg_01; -unsigned long flags; +union IO_APIC_reg_01 reg_01; -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock); reg_01.raw =io_apic_read (ioapic,1 ); -raw_spin_unlock_irqrestore (&ioapic_lock, flags);return reg_01.bits.version; }
@@ -3050,22 +2991,17 @@ void mp_irqdomain_free(struct irq_domain *domain, unsigned int virq, irq_data =irq_domain_get_irq_data (domain, virq);if (irq_data && irq_data->chip_data) { data = irq_data->chip_data; -__remove_pin_from_irq (data,mp_irqdomain_ioapic_idx (domain), - (int )irq_data->hwirq); +__remove_pin_from_irq (data,mp_irqdomain_ioapic_idx (domain), (int )irq_data->hwirq);WARN_ON (!list_empty (&data->irq_2_pin));kfree (irq_data->chip_data); }irq_domain_free_irqs_top (domain, virq, nr_irqs); } -int mp_irqdomain_activate (struct irq_domain *domain, -struct irq_data *irq_data,bool reserve) +int mp_irqdomain_activate (struct irq_domain *domain,struct irq_data *irq_data,bool reserve) { -unsigned long flags; - -raw_spin_lock_irqsave (&ioapic_lock, flags); +guard (raw_spinlock_irqsave)(&ioapic_lock);ioapic_configure_entry (irq_data); -raw_spin_unlock_irqrestore (&ioapic_lock, flags);return 0 ; }
PATCH 5/15 x86/apic: Provide apic_printk() helpers
In reply to Thomas Gleixnerapic_printk() requires the APIC verbosity level and printk level which is tedious and horrible to read. Provide helpers to simplify all of that.
--- arch/x86/include/asm/apic.h | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-)
arch/x86/include/asm/apic.h +19 -14
@@ -18,6 +18,11 @@#define ARCH_APICTIMER_STOPS_ON_C3 1 +/* Macros for apic_extnmi which controls external NMI masking */ +#define APIC_EXTNMI_BSP 0/* Default */ +#define APIC_EXTNMI_ALL 1 +#define APIC_EXTNMI_NONE 2 +/* * Debugging macros */
@@ -25,22 +30,22 @@#define APIC_VERBOSE 1#define APIC_DEBUG 2 -/* Macros for apic_extnmi which controls external NMI masking */ -#define APIC_EXTNMI_BSP 0/* Default */ -#define APIC_EXTNMI_ALL 1 -#define APIC_EXTNMI_NONE 2 -/* -* Define the default level of output to be very little -* This can be turned up by using apic=verbose for more -* information and apic=debug for _lots_ of information. -* apic_verbosity is defined in apic.c +* Define the default level of output to be very little This can be turned +* up by using apic=verbose for more information and apic=debug for _lots_ +* of information. apic_verbosity is defined in apic.c */ -#define apic_printk(v, s, a...) do { \ - if ((v) <= apic_verbosity) \ - printk(s, ##a); \ - } while (0) - +#define apic_printk(v, s, a...) \ +do { \ + if ((v) <= apic_verbosity) \ + printk(s, ##a); \ +} while (0) + +#define apic_pr_verbose(s, a...) apic_printk(APIC_VERBOSE, KERN_INFO s, ##a) +#define apic_pr_debug(s, a...) apic_printk(APIC_DEBUG, KERN_DEBUG s, ##a) +#define apic_pr_debug_cont(s, a...) apic_printk(APIC_DEBUG, KERN_CONT s, ##a) +/* Unconditional debug prints for code which is guarded by apic_verbosity already */ +#define apic_dbg(s, a...) printk(KERN_DEBUG s, ##a)#if defined(CONFIG_X86_LOCAL_APIC ) && defined(CONFIG_X86_32 )extern void x86_32_probe_apic (void );
[tip: x86/apic] x86/apic: Provide apic_printk() helpers
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: d768e3f3e3fb43df2559d4c053b0f68c9649b2c7 Gitweb: https://git.kernel.org/tip/d768e3f3e3fb43df2559d4c053b0f68c9649b2c7 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:39 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:28 +02:00
x86/apic: Provide apic_printk() helpers
apic_printk() requires the APIC verbosity level and printk level which is tedious and horrible to read. Provide helpers to simplify all of that.
--- arch/x86/include/asm/apic.h | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-)
arch/x86/include/asm/apic.h +19 -14
@@ -18,6 +18,11 @@#define ARCH_APICTIMER_STOPS_ON_C3 1 +/* Macros for apic_extnmi which controls external NMI masking */ +#define APIC_EXTNMI_BSP 0/* Default */ +#define APIC_EXTNMI_ALL 1 +#define APIC_EXTNMI_NONE 2 +/* * Debugging macros */
@@ -25,22 +30,22 @@#define APIC_VERBOSE 1#define APIC_DEBUG 2 -/* Macros for apic_extnmi which controls external NMI masking */ -#define APIC_EXTNMI_BSP 0/* Default */ -#define APIC_EXTNMI_ALL 1 -#define APIC_EXTNMI_NONE 2 -/* -* Define the default level of output to be very little -* This can be turned up by using apic=verbose for more -* information and apic=debug for _lots_ of information. -* apic_verbosity is defined in apic.c +* Define the default level of output to be very little This can be turned +* up by using apic=verbose for more information and apic=debug for _lots_ +* of information. apic_verbosity is defined in apic.c */ -#define apic_printk(v, s, a...) do { \ - if ((v) <= apic_verbosity) \ - printk(s, ##a); \ - } while (0) - +#define apic_printk(v, s, a...) \ +do { \ + if ((v) <= apic_verbosity) \ + printk(s, ##a); \ +} while (0) + +#define apic_pr_verbose(s, a...) apic_printk(APIC_VERBOSE, KERN_INFO s, ##a) +#define apic_pr_debug(s, a...) apic_printk(APIC_DEBUG, KERN_DEBUG s, ##a) +#define apic_pr_debug_cont(s, a...) apic_printk(APIC_DEBUG, KERN_CONT s, ##a) +/* Unconditional debug prints for code which is guarded by apic_verbosity already */ +#define apic_dbg(s, a...) printk(KERN_DEBUG s, ##a)#if defined(CONFIG_X86_LOCAL_APIC ) && defined(CONFIG_X86_32 )extern void x86_32_probe_apic (void );
PATCH 6/15 x86/apic: Cleanup apic_printk()s
In reply to Thomas GleixnerUse the new apic_pr_*() helpers and cleanup the apic_printk() maze.
--- arch/x86/kernel/apic/apic.c | 81 +++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 46 deletions(-)
arch/x86/kernel/apic/apic.c +35 -46
@@ -677,7 +677,7 @@ calibrate_by_pmtimer(u32 deltapm, long *return -1 ;#endif -apic_printk (APIC_VERBOSE ,"... PM-Timer delta = %u\n" , deltapm); +apic_pr_verbose ("... PM-Timer delta = %u\n" , deltapm);/* Check, if the PM timer is available */ if (!deltapm)
@@ -687,14 +687,14 @@ calibrate_by_pmtimer(u32 deltapm, long *if (deltapm > (pm_100ms - pm_thresh) && deltapm < (pm_100ms + pm_thresh)) { -apic_printk (APIC_VERBOSE ,"... PM-Timer result ok\n" ); +apic_pr_verbose ("... PM-Timer result ok\n" );return 0 ; } res = (((u64 )deltapm) * mult) >>22 ;do_div (res,1000000 ); -pr_warn ("APIC calibration not consistent " -"with PM-Timer: %ldms instead of 100ms\n" , (long )res); +pr_warn ("APIC calibration not consistent with PM-Timer: %ldms instead of 100ms\n" , + (long )res);/* Correct the lapic counter value */ res = (((u64)(*delta)) * pm_100ms);
@@ -707,9 +707,8 @@ calibrate_by_pmtimer(u32 deltapm, long *if (boot_cpu_has (X86_FEATURE_TSC )) { res = (((u64)(*deltatsc)) * pm_100ms);do_div (res, deltapm); -apic_printk (APIC_VERBOSE ,"TSC delta adjusted to " -"PM-Timer: %lu (%ld)\n" , - (unsigned long )res, *deltatsc); +apic_pr_verbose ("TSC delta adjusted to PM-Timer: %lu (%ld)\n" , + (unsigned long )res, *deltatsc); *deltatsc = (long )res; }
@@ -792,8 +791,7 @@ static int __init calibrate_APIC_clock(v* in the clockevent structure and return. */ if (!lapic_init_clockevent ()) { -apic_printk (APIC_VERBOSE ,"lapic timer already calibrated %d\n" , - lapic_timer_period); +apic_pr_verbose ("lapic timer already calibrated %d\n" , lapic_timer_period);/* * Direct calibration methods must have an always running * local APIC timer, no need for broadcast timer.
@@ -802,8 +800,7 @@ static int __init calibrate_APIC_clock(vreturn 0 ; } -apic_printk (APIC_VERBOSE ,"Using local APIC timer interrupts.\n" -"calibrating APIC timer ...\n" ); +apic_pr_verbose ("Using local APIC timer interrupts. Calibrating APIC timer ...\n" );/* * There are platforms w/o global clockevent devices. Instead of
@@ -866,7 +863,7 @@ static int __init calibrate_APIC_clock(v/* Build delta t1-t2 as apic timer counts down */ delta = lapic_cal_t1 - lapic_cal_t2; -apic_printk (APIC_VERBOSE ,"... lapic delta = %ld\n" , delta); +apic_pr_verbose ("... lapic delta = %ld\n" , delta); deltatsc = (long )(lapic_cal_tsc2 - lapic_cal_tsc1);
@@ -877,22 +874,19 @@ static int __init calibrate_APIC_clock(v lapic_timer_period = (delta *APIC_DIVISOR ) /LAPIC_CAL_LOOPS ;lapic_init_clockevent (); -apic_printk (APIC_VERBOSE ,"..... delta %ld\n" , delta); -apic_printk (APIC_VERBOSE ,"..... mult: %u\n" , lapic_clockevent.mult); -apic_printk (APIC_VERBOSE ,"..... calibration result: %u\n" , - lapic_timer_period); +apic_pr_verbose ("..... delta %ld\n" , delta); +apic_pr_verbose ("..... mult: %u\n" , lapic_clockevent.mult); +apic_pr_verbose ("..... calibration result: %u\n" , lapic_timer_period);if (boot_cpu_has (X86_FEATURE_TSC )) { -apic_printk (APIC_VERBOSE ,"..... CPU clock speed is " -"%ld.%04ld MHz.\n" , - (deltatsc /LAPIC_CAL_LOOPS ) / (1000000 /HZ ), - (deltatsc /LAPIC_CAL_LOOPS ) % (1000000 /HZ )); +apic_pr_verbose ("..... CPU clock speed is %ld.%04ld MHz.\n" , + (deltatsc /LAPIC_CAL_LOOPS ) / (1000000 /HZ ), + (deltatsc /LAPIC_CAL_LOOPS ) % (1000000 /HZ )); } -apic_printk (APIC_VERBOSE ,"..... host bus clock speed is " -"%u.%04u MHz.\n" , - lapic_timer_period / (1000000 /HZ ), - lapic_timer_period % (1000000 /HZ )); +apic_pr_verbose ("..... host bus clock speed is %u.%04u MHz.\n" , + lapic_timer_period / (1000000 /HZ ), + lapic_timer_period % (1000000 /HZ ));/* * Do a sanity check on the APIC calibration result
@@ -911,7 +905,7 @@ static int __init calibrate_APIC_clock(v* available. */ if (!pm_referenced && global_clock_event) { -apic_printk (APIC_VERBOSE ,"... verify APIC timer\n" ); +apic_pr_verbose ("... verify APIC timer\n" );/* * Setup the apic timer manually
@@ -932,11 +926,11 @@ static int __init calibrate_APIC_clock(v/* Jiffies delta */ deltaj = lapic_cal_j2 - lapic_cal_j1; -apic_printk (APIC_VERBOSE ,"... jiffies delta = %lu\n" , deltaj); +apic_pr_verbose ("... jiffies delta = %lu\n" , deltaj);/* Check, if the jiffies result is consistent */ if (deltaj >=LAPIC_CAL_LOOPS -2 && deltaj <=LAPIC_CAL_LOOPS +2 ) -apic_printk (APIC_VERBOSE ,"... jiffies result ok\n" ); +apic_pr_verbose ("... jiffies result ok\n" );else levt->features |=CLOCK_EVT_FEAT_DUMMY ; }
@@ -1221,9 +1215,8 @@ void __init sync_Arb_IDs(void)*/ 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 ); +apic_pr_debug ("Synchronizing Arb IDs.\n" ); +apic_write (APIC_ICR ,APIC_DEST_ALLINC |APIC_INT_LEVELTRIG |APIC_DM_INIT ); }enum apic_intr_mode_id apic_intr_mode__ro_after_init ;
@@ -1409,10 +1402,10 @@ static void lapic_setup_esr(void)if (maxlvt >3 )apic_write (APIC_ESR ,0 ); value =apic_read (APIC_ESR ); -if (value != oldvalue) -apic_printk (APIC_VERBOSE ,"ESR value before enabling " -"vector: 0x%08x after: 0x%08x\n" , - oldvalue, value); +if (value != oldvalue) { +apic_pr_verbose ("ESR value before enabling vector: 0x%08x after: 0x%08x\n" , + oldvalue, value); + } }#define APIC_IR_REGS APIC_ISR_NR
@@ -1599,10 +1592,10 @@ static void setup_local_APIC(void) value =apic_read (APIC_LVT0 ) &APIC_LVT_MASKED ;if (!cpu && (pic_mode || !value || ioapic_is_disabled)) { value =APIC_DM_EXTINT ; -apic_printk (APIC_VERBOSE ,"enabled ExtINT on CPU#%d\n" , cpu); +apic_pr_verbose ("Enabled ExtINT on CPU#%d\n" , cpu); }else { value =APIC_DM_EXTINT |APIC_LVT_MASKED ; -apic_printk (APIC_VERBOSE ,"masked ExtINT on CPU#%d\n" , cpu); +apic_pr_verbose ("Masked ExtINT on CPU#%d\n" , cpu); }apic_write (APIC_LVT0 , value);
@@ -2066,8 +2059,7 @@ static __init void apic_set_fixmap(bool {set_fixmap_nocache (FIX_APIC_BASE , mp_lapic_addr); apic_mmio_base =APIC_BASE ; -apic_printk (APIC_VERBOSE ,"mapped APIC to %16lx (%16lx)\n" , - apic_mmio_base, mp_lapic_addr); +apic_pr_verbose ("Mapped APIC to %16lx (%16lx)\n" , apic_mmio_base, mp_lapic_addr);if (read_apic)apic_read_boot_cpu_id (false); }
@@ -2170,18 +2162,17 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_error_inteapic_eoi ();atomic_inc (&irq_err_count); -apic_printk (APIC_DEBUG ,KERN_DEBUG "APIC error on CPU%d: %02x" , -smp_processor_id (), v); +apic_pr_debug ("APIC error on CPU%d: %02x" ,smp_processor_id (), v); v &=0xff ;while (v) {if (v &0x1 ) -apic_printk (APIC_DEBUG ,KERN_CONT " : %s" , error_interrupt_reason[i]); +apic_pr_debug_cont (" : %s" , error_interrupt_reason[i]); i++; v >>=1 ; } -apic_printk (APIC_DEBUG ,KERN_CONT "\n" ); +apic_pr_debug_cont ("\n" );trace_error_apic_exit (ERROR_APIC_VECTOR ); }
@@ -2201,8 +2192,7 @@ static void __init connect_bsp_APIC(void* PIC mode, enable APIC mode in the IMCR, i.e. connect BSP's * local APIC to INT and NMI lines. */ -apic_printk (APIC_VERBOSE ,"leaving PIC mode, " -"enabling APIC mode.\n" ); +apic_pr_verbose ("Leaving PIC mode, enabling APIC mode.\n" ); imcr_pic_to_apic(); }#endif
@@ -2227,8 +2217,7 @@ void disconnect_bsp_APIC(int virt_wire_s* IPIs, won't work beyond this point! The only exception are * INIT IPIs. */ -apic_printk (APIC_VERBOSE ,"disabling APIC mode, " -"entering PIC mode.\n" ); +apic_pr_verbose ("Disabling APIC mode, entering PIC mode.\n" );imcr_apic_to_pic ();return ; }
[tip: x86/apic] x86/apic: Cleanup apic_printk()s
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: ac1c9fc1b571d5355602daa642f74288ae4b701d Gitweb: https://git.kernel.org/tip/ac1c9fc1b571d5355602daa642f74288ae4b701d Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:41 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:28 +02:00
x86/apic: Cleanup apic_printk()s
Use the new apic_pr_*() helpers and cleanup the apic_printk() maze.
--- arch/x86/kernel/apic/apic.c | 81 +++++++++++++++--------------------- 1 file changed, 35 insertions(+), 46 deletions(-)
arch/x86/kernel/apic/apic.c +35 -46
@@ -677,7 +677,7 @@ calibrate_by_pmtimer(u32 deltapm, long *delta, long *deltatsc)return -1 ;#endif -apic_printk (APIC_VERBOSE ,"... PM-Timer delta = %u\n" , deltapm); +apic_pr_verbose ("... PM-Timer delta = %u\n" , deltapm);/* Check, if the PM timer is available */ if (!deltapm)
@@ -687,14 +687,14 @@ calibrate_by_pmtimer(u32 deltapm, long *delta, long *deltatsc)if (deltapm > (pm_100ms - pm_thresh) && deltapm < (pm_100ms + pm_thresh)) { -apic_printk (APIC_VERBOSE ,"... PM-Timer result ok\n" ); +apic_pr_verbose ("... PM-Timer result ok\n" );return 0 ; } res = (((u64 )deltapm) * mult) >>22 ;do_div (res,1000000 ); -pr_warn ("APIC calibration not consistent " -"with PM-Timer: %ldms instead of 100ms\n" , (long )res); +pr_warn ("APIC calibration not consistent with PM-Timer: %ldms instead of 100ms\n" , + (long )res);/* Correct the lapic counter value */ res = (((u64)(*delta)) * pm_100ms);
@@ -707,9 +707,8 @@ calibrate_by_pmtimer(u32 deltapm, long *delta, long *deltatsc)if (boot_cpu_has (X86_FEATURE_TSC )) { res = (((u64)(*deltatsc)) * pm_100ms);do_div (res, deltapm); -apic_printk (APIC_VERBOSE ,"TSC delta adjusted to " -"PM-Timer: %lu (%ld)\n" , - (unsigned long )res, *deltatsc); +apic_pr_verbose ("TSC delta adjusted to PM-Timer: %lu (%ld)\n" , + (unsigned long )res, *deltatsc); *deltatsc = (long )res; }
@@ -792,8 +791,7 @@ static int __init calibrate_APIC_clock(void)* in the clockevent structure and return. */ if (!lapic_init_clockevent ()) { -apic_printk (APIC_VERBOSE ,"lapic timer already calibrated %d\n" , - lapic_timer_period); +apic_pr_verbose ("lapic timer already calibrated %d\n" , lapic_timer_period);/* * Direct calibration methods must have an always running * local APIC timer, no need for broadcast timer.
@@ -802,8 +800,7 @@ static int __init calibrate_APIC_clock(void)return 0 ; } -apic_printk (APIC_VERBOSE ,"Using local APIC timer interrupts.\n" -"calibrating APIC timer ...\n" ); +apic_pr_verbose ("Using local APIC timer interrupts. Calibrating APIC timer ...\n" );/* * There are platforms w/o global clockevent devices. Instead of
@@ -866,7 +863,7 @@ static int __init calibrate_APIC_clock(void)/* Build delta t1-t2 as apic timer counts down */ delta = lapic_cal_t1 - lapic_cal_t2; -apic_printk (APIC_VERBOSE ,"... lapic delta = %ld\n" , delta); +apic_pr_verbose ("... lapic delta = %ld\n" , delta); deltatsc = (long )(lapic_cal_tsc2 - lapic_cal_tsc1);
@@ -877,22 +874,19 @@ static int __init calibrate_APIC_clock(void) lapic_timer_period = (delta *APIC_DIVISOR ) /LAPIC_CAL_LOOPS ;lapic_init_clockevent (); -apic_printk (APIC_VERBOSE ,"..... delta %ld\n" , delta); -apic_printk (APIC_VERBOSE ,"..... mult: %u\n" , lapic_clockevent.mult); -apic_printk (APIC_VERBOSE ,"..... calibration result: %u\n" , - lapic_timer_period); +apic_pr_verbose ("..... delta %ld\n" , delta); +apic_pr_verbose ("..... mult: %u\n" , lapic_clockevent.mult); +apic_pr_verbose ("..... calibration result: %u\n" , lapic_timer_period);if (boot_cpu_has (X86_FEATURE_TSC )) { -apic_printk (APIC_VERBOSE ,"..... CPU clock speed is " -"%ld.%04ld MHz.\n" , - (deltatsc /LAPIC_CAL_LOOPS ) / (1000000 /HZ ), - (deltatsc /LAPIC_CAL_LOOPS ) % (1000000 /HZ )); +apic_pr_verbose ("..... CPU clock speed is %ld.%04ld MHz.\n" , + (deltatsc /LAPIC_CAL_LOOPS ) / (1000000 /HZ ), + (deltatsc /LAPIC_CAL_LOOPS ) % (1000000 /HZ )); } -apic_printk (APIC_VERBOSE ,"..... host bus clock speed is " -"%u.%04u MHz.\n" , - lapic_timer_period / (1000000 /HZ ), - lapic_timer_period % (1000000 /HZ )); +apic_pr_verbose ("..... host bus clock speed is %u.%04u MHz.\n" , + lapic_timer_period / (1000000 /HZ ), + lapic_timer_period % (1000000 /HZ ));/* * Do a sanity check on the APIC calibration result
@@ -911,7 +905,7 @@ static int __init calibrate_APIC_clock(void)* available. */ if (!pm_referenced && global_clock_event) { -apic_printk (APIC_VERBOSE ,"... verify APIC timer\n" ); +apic_pr_verbose ("... verify APIC timer\n" );/* * Setup the apic timer manually
@@ -932,11 +926,11 @@ static int __init calibrate_APIC_clock(void)/* Jiffies delta */ deltaj = lapic_cal_j2 - lapic_cal_j1; -apic_printk (APIC_VERBOSE ,"... jiffies delta = %lu\n" , deltaj); +apic_pr_verbose ("... jiffies delta = %lu\n" , deltaj);/* Check, if the jiffies result is consistent */ if (deltaj >=LAPIC_CAL_LOOPS -2 && deltaj <=LAPIC_CAL_LOOPS +2 ) -apic_printk (APIC_VERBOSE ,"... jiffies result ok\n" ); +apic_pr_verbose ("... jiffies result ok\n" );else levt->features |=CLOCK_EVT_FEAT_DUMMY ; }
@@ -1221,9 +1215,8 @@ void __init sync_Arb_IDs(void)*/ 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 ); +apic_pr_debug ("Synchronizing Arb IDs.\n" ); +apic_write (APIC_ICR ,APIC_DEST_ALLINC |APIC_INT_LEVELTRIG |APIC_DM_INIT ); }enum apic_intr_mode_id apic_intr_mode__ro_after_init ;
@@ -1409,10 +1402,10 @@ static void lapic_setup_esr(void)if (maxlvt >3 )apic_write (APIC_ESR ,0 ); value =apic_read (APIC_ESR ); -if (value != oldvalue) -apic_printk (APIC_VERBOSE ,"ESR value before enabling " -"vector: 0x%08x after: 0x%08x\n" , - oldvalue, value); +if (value != oldvalue) { +apic_pr_verbose ("ESR value before enabling vector: 0x%08x after: 0x%08x\n" , + oldvalue, value); + } }#define APIC_IR_REGS APIC_ISR_NR
@@ -1599,10 +1592,10 @@ static void setup_local_APIC(void) value =apic_read (APIC_LVT0 ) &APIC_LVT_MASKED ;if (!cpu && (pic_mode || !value || ioapic_is_disabled)) { value =APIC_DM_EXTINT ; -apic_printk (APIC_VERBOSE ,"enabled ExtINT on CPU#%d\n" , cpu); +apic_pr_verbose ("Enabled ExtINT on CPU#%d\n" , cpu); }else { value =APIC_DM_EXTINT |APIC_LVT_MASKED ; -apic_printk (APIC_VERBOSE ,"masked ExtINT on CPU#%d\n" , cpu); +apic_pr_verbose ("Masked ExtINT on CPU#%d\n" , cpu); }apic_write (APIC_LVT0 , value);
@@ -2066,8 +2059,7 @@ static __init void apic_set_fixmap(bool read_apic) {set_fixmap_nocache (FIX_APIC_BASE , mp_lapic_addr); apic_mmio_base =APIC_BASE ; -apic_printk (APIC_VERBOSE ,"mapped APIC to %16lx (%16lx)\n" , - apic_mmio_base, mp_lapic_addr); +apic_pr_verbose ("Mapped APIC to %16lx (%16lx)\n" , apic_mmio_base, mp_lapic_addr);if (read_apic)apic_read_boot_cpu_id (false); }
@@ -2170,18 +2162,17 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_error_interrupt)apic_eoi ();atomic_inc (&irq_err_count); -apic_printk (APIC_DEBUG ,KERN_DEBUG "APIC error on CPU%d: %02x" , -smp_processor_id (), v); +apic_pr_debug ("APIC error on CPU%d: %02x" ,smp_processor_id (), v); v &=0xff ;while (v) {if (v &0x1 ) -apic_printk (APIC_DEBUG ,KERN_CONT " : %s" , error_interrupt_reason[i]); +apic_pr_debug_cont (" : %s" , error_interrupt_reason[i]); i++; v >>=1 ; } -apic_printk (APIC_DEBUG ,KERN_CONT "\n" ); +apic_pr_debug_cont ("\n" );trace_error_apic_exit (ERROR_APIC_VECTOR ); }
@@ -2201,8 +2192,7 @@ static void __init connect_bsp_APIC(void)* PIC mode, enable APIC mode in the IMCR, i.e. connect BSP's * local APIC to INT and NMI lines. */ -apic_printk (APIC_VERBOSE ,"leaving PIC mode, " -"enabling APIC mode.\n" ); +apic_pr_verbose ("Leaving PIC mode, enabling APIC mode.\n" ); imcr_pic_to_apic(); }#endif
@@ -2227,8 +2217,7 @@ void disconnect_bsp_APIC(int virt_wire_setup)* IPIs, won't work beyond this point! The only exception are * INIT IPIs. */ -apic_printk (APIC_VERBOSE ,"disabling APIC mode, " -"entering PIC mode.\n" ); +apic_pr_verbose ("Disabling APIC mode, entering PIC mode.\n" );imcr_apic_to_pic ();return ; }
PATCH 7/15 x86/ioapic: Cleanup apic_printk()s
In reply to Thomas GleixnerReplace apic_printk($LEVEL) with the corresponding apic_pr_*() helpers and use pr_info() for APIC_QUIET as that is always printed so the indirection is pointless noise.
--- arch/x86/kernel/apic/io_apic.c | 176 +++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 103 deletions(-)
arch/x86/kernel/apic/io_apic.c +73 -103
@@ -201,10 +201,9 @@ void mp_save_irq(struct mpc_intsrc *m) {int i; -apic_printk (APIC_VERBOSE ,"Int: type %d, pol %d, trig %d, bus %02x," -" IRQ %02x, APIC ID %x, APIC INT %02x\n" , - m->irqtype, m->irqflag &3 , (m->irqflag >>2 ) &3 , m->srcbus, - m->srcbusirq, m->dstapic, m->dstirq); +apic_pr_verbose ("Int: type %d, pol %d, trig %d, bus %02x, IRQ %02x, APIC ID %x, APIC INT %02x\n" , + m->irqtype, m->irqflag &3 , (m->irqflag >>2 ) &3 , m->srcbus, + m->srcbusirq, m->dstapic, m->dstirq);for (i =0 ; i < mp_irq_entries; i++) {if (!memcmp (&mp_irqs[i], m,sizeof (*m)))
@@ -554,28 +553,23 @@ static int pirq_entries[MAX_PIRQS] = {static int __init ioapic_pirq_setup (char *str) { -int i, max; -int ints[MAX_PIRQS +1 ]; +int i, max, ints[MAX_PIRQS +1 ];get_options (str,ARRAY_SIZE (ints), ints); -apic_printk (APIC_VERBOSE ,KERN_INFO -"PIRQ redirection, working around broken MP-BIOS.\n" ); +apic_pr_verbose ("PIRQ redirection, working around broken MP-BIOS.\n" ); + max =MAX_PIRQS ;if (ints[0 ] <MAX_PIRQS ) max = ints[0 ];for (i =0 ; i < max; i++) { -apic_printk (APIC_VERBOSE ,KERN_DEBUG -"... PIRQ%d -> IRQ %d\n" , i, ints[i+1 ]); -/* -* PIRQs are mapped upside down, usually. -*/ +apic_pr_verbose ("... PIRQ%d -> IRQ %d\n" , i, ints[i +1 ]); +/* PIRQs are mapped upside down, usually */ pirq_entries[MAX_PIRQS -i-1 ] = ints[i+1 ]; }return 1 ; } -__setup ("pirq=" , ioapic_pirq_setup);#endif /* CONFIG_X86_32 */
@@ -737,8 +731,7 @@ static bool EISA_ELCR(unsigned int irq)unsigned int port =PIC_ELCR1 + (irq >>3 );return (inb (port) >> (irq &7 )) &1 ; } -apic_printk (APIC_VERBOSE ,KERN_INFO -"Broken MPtable reports ISA irq %d\n" , irq); +apic_pr_verbose ("Broken MPtable reports ISA irq %d\n" , irq);return false; }
@@ -1052,15 +1045,13 @@ static int pin_2_irq(int idx, int ioapic* PCI IRQ command line redirection. Yes, limits are hardcoded. */ if ((pin >=16 ) && (pin <=23 )) { -if (pirq_entries[pin-16 ] !=-1 ) { -if (!pirq_entries[pin-16 ]) { -apic_printk (APIC_VERBOSE ,KERN_DEBUG -"disabling PIRQ%d\n" , pin-16 ); +if (pirq_entries[pin -16 ] !=-1 ) { +if (!pirq_entries[pin -16 ]) { +apic_pr_verbose ("Disabling PIRQ%d\n" , pin -16 ); }else {int irq = pirq_entries[pin-16 ]; -apic_printk (APIC_VERBOSE ,KERN_DEBUG -"using PIRQ%d -> IRQ %d\n" , - pin-16 , irq); + +apic_pr_verbose ("Using PIRQ%d -> IRQ %d\n" , pin -16 , irq);return irq; } }
@@ -1111,12 +1102,10 @@ int IO_APIC_get_PCI_irq_vector(int bus, {int irq, i, best_ioapic =-1 , best_idx =-1 ; -apic_printk (APIC_DEBUG , -"querying PCI -> IRQ mapping bus:%d, slot:%d, pin:%d.\n" , - bus, slot, pin); +apic_pr_debug ("Querying PCI -> IRQ mapping bus:%d, slot:%d, pin:%d.\n" , + bus, slot, pin);if (test_bit (bus, mp_bus_not_pci)) { -apic_printk (APIC_VERBOSE , -"PCI BIOS passed nonexistent PCI bus %d!\n" , bus); +apic_pr_verbose ("PCI BIOS passed nonexistent PCI bus %d!\n" , bus);return -1 ; }
@@ -1173,17 +1162,16 @@ static void __init setup_IO_APIC_irqs(vounsigned int ioapic, pin;int idx; -apic_printk (APIC_VERBOSE ,KERN_DEBUG "init IO_APIC IRQs\n" ); +apic_pr_verbose ("Init IO_APIC IRQs\n" );for_each_ioapic_pin (ioapic, pin) { idx =find_irq_entry (ioapic, pin, mp_INT); -if (idx <0 ) -apic_printk (APIC_VERBOSE , -KERN_DEBUG " apic %d pin %d not connected\n" , -mpc_ioapic_id (ioapic), pin); -else -pin_2_irq (idx, ioapic, pin, - ioapic ?0 :IOAPIC_MAP_ALLOC ); +if (idx <0 ) { +apic_pr_verbose ("apic %d pin %d not connected\n" , +mpc_ioapic_id (ioapic), pin); + }else { +pin_2_irq (idx, ioapic, pin, ioapic ?0 :IOAPIC_MAP_ALLOC ); + } } }
@@ -1359,29 +1347,24 @@ void __init enable_IO_APIC(void) i8259_apic =find_isa_irq_apic (0 , mp_ExtINT);/* Trust the MP table if nothing is setup in the hardware */ if ((ioapic_i8259.pin ==-1 ) && (i8259_pin >=0 )) { -printk (KERN_WARNING "ExtINT not setup in hardware but reported by MP table\n" ); +pr_warn ("ExtINT not setup in hardware but reported by MP table\n" ); ioapic_i8259.pin = i8259_pin; ioapic_i8259.apic = i8259_apic; }/* Complain if the MP table and the hardware disagree */ if (((ioapic_i8259.apic != i8259_apic) || (ioapic_i8259.pin != i8259_pin)) && - (i8259_pin >=0 ) && (ioapic_i8259.pin >=0 )) - { -printk (KERN_WARNING "ExtINT in hardware and MP table differ\n" ); - } + (i8259_pin >=0 ) && (ioapic_i8259.pin >=0 )) +pr_warn ("ExtINT in hardware and MP table differ\n" ); -/* -* Do not trust the IO-APIC being empty at bootup -*/ +/* Do not trust the IO-APIC being empty at bootup */ clear_IO_APIC (); }void native_restore_boot_irq_mode (void ) {/* -* If the i8259 is routed through an IOAPIC -* Put that IOAPIC in virtual wire mode -* so legacy interrupts can be delivered. +* If the i8259 is routed through an IOAPIC Put that IOAPIC in +* virtual wire mode so legacy interrupts can be delivered. */ if (ioapic_i8259.pin !=-1 ) {struct IO_APIC_route_entry entry;
@@ -1469,8 +1452,8 @@ static void __init setup_ioapic_ids_fromset_bit (i, phys_id_present_map); ioapics[ioapic_idx].mp_config.apicid = i; }else { -apic_printk (APIC_VERBOSE ,"Setting %d in the phys_id_present_map\n" , -mpc_ioapic_id (ioapic_idx)); +apic_pr_verbose ("Setting %d in the phys_id_present_map\n" , +mpc_ioapic_id (ioapic_idx));set_bit (mpc_ioapic_id (ioapic_idx), phys_id_present_map); }
@@ -1491,9 +1474,8 @@ static void __init setup_ioapic_ids_fromif (mpc_ioapic_id (ioapic_idx) == reg_00.bits.ID)continue ; -apic_printk (APIC_VERBOSE ,KERN_INFO -"...changing IO-APIC physical APIC ID to %d ..." , -mpc_ioapic_id (ioapic_idx)); +apic_pr_verbose ("...changing IO-APIC physical APIC ID to %d ..." , +mpc_ioapic_id (ioapic_idx)); reg_00.bits.ID =mpc_ioapic_id (ioapic_idx); scoped_guard (raw_spinlock_irqsave, &ioapic_lock) {
@@ -1504,7 +1486,7 @@ static void __init setup_ioapic_ids_fromif (reg_00.bits.ID !=mpc_ioapic_id (ioapic_idx))pr_cont ("could not set ID!\n" );else -apic_printk (APIC_VERBOSE ," ok.\n" ); +apic_pr_verbose (" ok.\n" ); } }
@@ -2136,9 +2118,8 @@ static inline void __init check_timer(vo pin2 = ioapic_i8259.pin; apic2 = ioapic_i8259.apic; -apic_printk (APIC_QUIET ,KERN_INFO "..TIMER: vector=0x%02X " -"apic1=%d pin1=%d apic2=%d pin2=%d\n" , - cfg->vector, apic1, pin1, apic2, pin2); +pr_info ("..TIMER: vector=0x%02X apic1=%d pin1=%d apic2=%d pin2=%d\n" , + cfg->vector, apic1, pin1, apic2, pin2);/* * Some BIOS writers are clueless and report the ExtINTA
@@ -2182,13 +2163,10 @@ static inline void __init check_timer(vopanic_if_irq_remap ("timer doesn't work through Interrupt-remapped IO-APIC" );clear_IO_APIC_pin (apic1, pin1);if (!no_pin1) -apic_printk (APIC_QUIET ,KERN_ERR "..MP-BIOS bug: " -"8254 timer not connected to IO-APIC\n" ); +pr_err ("..MP-BIOS bug: 8254 timer not connected to IO-APIC\n" ); -apic_printk (APIC_QUIET ,KERN_INFO "...trying to set up timer " -"(IRQ0) through the 8259A ...\n" ); -apic_printk (APIC_QUIET ,KERN_INFO -"..... (found apic %d pin %d) ...\n" , apic2, pin2); +pr_info ("...trying to set up timer (IRQ0) through the 8259A ...\n" ); +pr_info ("..... (found apic %d pin %d) ...\n" , apic2, pin2);/* * legacy devices should be connected to IO APIC #0 */
@@ -2197,7 +2175,7 @@ static inline void __init check_timer(voirq_domain_activate_irq (irq_data, false); legacy_pic->unmask (0 );if (timer_irq_works ()) { -apic_printk (APIC_QUIET ,KERN_INFO "....... works.\n" ); +pr_info ("....... works.\n" ); goto out; }/*
@@ -2205,26 +2183,24 @@ static inline void __init check_timer(vo*/ legacy_pic->mask (0 );clear_IO_APIC_pin (apic2, pin2); -apic_printk (APIC_QUIET ,KERN_INFO "....... failed.\n" ); +pr_info ("....... failed.\n" ); } -apic_printk (APIC_QUIET ,KERN_INFO -"...trying to set up timer as Virtual Wire IRQ...\n" ); +pr_info ("...trying to set up timer as Virtual Wire IRQ...\n" );lapic_register_intr (0 );apic_write (APIC_LVT0 ,APIC_DM_FIXED | cfg->vector);/* Fixed mode */ legacy_pic->unmask (0 );if (timer_irq_works ()) { -apic_printk (APIC_QUIET ,KERN_INFO "..... works.\n" ); +pr_info ("..... works.\n" ); goto out; } legacy_pic->mask (0 );apic_write (APIC_LVT0 ,APIC_LVT_MASKED |APIC_DM_FIXED | cfg->vector); -apic_printk (APIC_QUIET ,KERN_INFO "..... failed.\n" ); +pr_info ("..... failed.\n" ); -apic_printk (APIC_QUIET ,KERN_INFO -"...trying to set up timer as ExtINT IRQ...\n" ); +pr_info ("...trying to set up timer as ExtINT IRQ...\n" ); legacy_pic->init (0 ); legacy_pic->make_irq (0 );
@@ -2234,14 +2210,15 @@ static inline void __init check_timer(vounlock_ExtINT_logic ();if (timer_irq_works ()) { -apic_printk (APIC_QUIET ,KERN_INFO "..... works.\n" ); +pr_info ("..... works.\n" ); goto out; } -apic_printk (APIC_QUIET ,KERN_INFO "..... failed :(.\n" ); -if (apic_is_x2apic_enabled ()) -apic_printk (APIC_QUIET ,KERN_INFO -"Perhaps problem with the pre-enabled x2apic mode\n" -"Try booting with x2apic and interrupt-remapping disabled in the bios.\n" ); + +pr_info ("..... failed :\n" ); +if (apic_is_x2apic_enabled ()) { +pr_info ("Perhaps problem with the pre-enabled x2apic mode\n" +"Try booting with x2apic and interrupt-remapping disabled in the bios.\n" ); + }panic ("IO-APIC + timer doesn't work! Boot with apic=debug and send a " "report. Then try booting with the 'noapic' option.\n" ); out:
@@ -2339,7 +2316,7 @@ void __init setup_IO_APIC(void) io_apic_irqs =nr_legacy_irqs () ? ~PIC_IRQS : ~0UL ; -apic_printk (APIC_VERBOSE ,"ENABLING IO-APIC IRQs\n" ); +apic_pr_verbose ("ENABLING IO-APIC IRQs\n" );for_each_ioapic (ioapic)BUG_ON (mp_irqdomain_create (ioapic));
@@ -2478,7 +2455,7 @@ static int io_apic_get_unique_id(int ioa } } -apic_printk (APIC_VERBOSE ,KERN_INFO "IOAPIC[%d]: Assigned apic_id %d\n" , ioapic, apic_id); +apic_pr_verbose ("IOAPIC[%d]: Assigned apic_id %d\n" , ioapic, apic_id);return apic_id; }
@@ -2514,8 +2491,8 @@ static u8 io_apic_unique_id(int idx, u8 new_id = reg_00.bits.ID;if (!test_bit (new_id, used)) { -apic_printk (APIC_VERBOSE ,KERN_INFO "IOAPIC[%d]: Using reg apic_id %d instead of %d\n" , - idx, new_id, id); +apic_pr_verbose ("IOAPIC[%d]: Using reg apic_id %d instead of %d\n" , + idx, new_id, id);return new_id; }
@@ -2614,9 +2591,7 @@ void __init io_apic_init_mappings(void) ioapic_phys =mpc_ioapic_addr (i);#ifdef CONFIG_X86_32 if (!ioapic_phys) { -printk (KERN_ERR -"WARNING: bogus zero IO-APIC " -"address found in MPTABLE, " +pr_err ("WARNING: bogus zero IO-APIC address found in MPTABLE, " "disabling IO/APIC support!\n" ); smp_found_config =0 ; ioapic_is_disabled = true;
@@ -2635,9 +2610,8 @@ void __init io_apic_init_mappings(void) ioapic_phys =__pa (ioapic_phys); }io_apic_set_fixmap (idx, ioapic_phys); -apic_printk (APIC_VERBOSE ,"mapped IOAPIC to %08lx (%08lx)\n" , -__fix_to_virt (idx) + (ioapic_phys & ~PAGE_MASK ), - ioapic_phys); +apic_pr_verbose ("mapped IOAPIC to %08lx (%08lx)\n" , +__fix_to_virt (idx) + (ioapic_phys & ~PAGE_MASK ), ioapic_phys); idx++; ioapic_res->start = ioapic_phys;
@@ -2648,13 +2622,12 @@ void __init io_apic_init_mappings(void)void __init ioapic_insert_resources (void ) { -int i;struct resource *r = ioapic_resources; +int i;if (!r) {if (nr_ioapics >0 ) -printk (KERN_ERR -"IO APIC resources couldn't be allocated.\n" ); +pr_err ("IO APIC resources couldn't be allocated.\n" );return ; }
@@ -2674,11 +2647,12 @@ int mp_find_ioapic(u32 gsi)/* Find the IOAPIC that manages this GSI. */ for_each_ioapic (i) {struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (i); +if (gsi >= gsi_cfg->gsi_base && gsi <= gsi_cfg->gsi_end)return i; } -printk (KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n" , gsi); +pr_err ("ERROR: Unable to locate IOAPIC for GSI %d\n" , gsi);return -1 ; }
@@ -2745,12 +2719,13 @@ int mp_register_ioapic(int id, u32 addrepr_warn ("Bogus (zero) I/O APIC address found, skipping!\n" );return -EINVAL ; } -for_each_ioapic (ioapic) + +for_each_ioapic (ioapic) {if (ioapics[ioapic].mp_config.apicaddr == address) { -pr_warn ("address 0x%x conflicts with IOAPIC%d\n" , - address, ioapic); +pr_warn ("address 0x%x conflicts with IOAPIC%d\n" , address, ioapic);return -EEXIST ; } + } idx =find_free_ioapic_entry ();if (idx >=MAX_IO_APICS ) {
@@ -2785,8 +2760,7 @@ int mp_register_ioapic(int id, u32 addre (gsi_end >= gsi_cfg->gsi_base && gsi_end <= gsi_cfg->gsi_end)) {pr_warn ("GSI range [%u-%u] for new IOAPIC conflicts with GSI[%u-%u]\n" , - gsi_base, gsi_end, - gsi_cfg->gsi_base, gsi_cfg->gsi_end); + gsi_base, gsi_end, gsi_cfg->gsi_base, gsi_cfg->gsi_end);clear_fixmap (FIX_IO_APIC_BASE_0 + idx);return -ENOSPC ; }
@@ -2820,8 +2794,7 @@ int mp_register_ioapic(int id, u32 addre ioapics[idx].nr_registers = entries;pr_info ("IOAPIC[%d]: apic_id %d, version %d, address 0x%x, GSI %d-%d\n" , - idx,mpc_ioapic_id (idx), -mpc_ioapic_ver (idx),mpc_ioapic_addr (idx), + idx,mpc_ioapic_id (idx),mpc_ioapic_ver (idx),mpc_ioapic_addr (idx), gsi_cfg->gsi_base, gsi_cfg->gsi_end);return 0 ;
@@ -2850,8 +2823,7 @@ int mp_unregister_ioapic(u32 gsi_base)if (irq >=0 ) { data =irq_get_chip_data (irq);if (data && data->count) { -pr_warn ("pin%d on IOAPIC%d is still in use.\n" , - pin, ioapic); +pr_warn ("pin%d on IOAPIC%d is still in use.\n" , pin, ioapic);return -EBUSY ; } }
@@ -2968,10 +2940,8 @@ int mp_irqdomain_alloc(struct irq_domain legacy_pic->mask (virq);local_irq_restore (flags); -apic_printk (APIC_VERBOSE ,KERN_DEBUG -"IOAPIC[%d]: Preconfigured routing entry (%d-%d -> IRQ %d Level:%i ActiveLow:%i)\n" , - ioapic,mpc_ioapic_id (ioapic), pin, virq, - data->is_level, data->active_low); +apic_pr_verbose ("IOAPIC[%d]: Preconfigured routing entry (%d-%d -> IRQ %d Level:%i ActiveLow:%i)\n" , + ioapic,mpc_ioapic_id (ioapic), pin, virq, data->is_level, data->active_low);return 0 ; free_irqs:
[tip: x86/apic] x86/ioapic: Cleanup apic_printk()s
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: f47998da395c1dfa53449bd335db4cf508be5275 Gitweb: https://git.kernel.org/tip/f47998da395c1dfa53449bd335db4cf508be5275 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:42 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:28 +02:00
x86/ioapic: Cleanup apic_printk()s
Replace apic_printk($LEVEL) with the corresponding apic_pr_*() helpers and use pr_info() for APIC_QUIET as that is always printed so the indirection is pointless noise.
--- arch/x86/kernel/apic/io_apic.c | 176 +++++++++++++------------------- 1 file changed, 73 insertions(+), 103 deletions(-)
arch/x86/kernel/apic/io_apic.c +73 -103
@@ -201,10 +201,9 @@ void mp_save_irq(struct mpc_intsrc *m) {int i; -apic_printk (APIC_VERBOSE ,"Int: type %d, pol %d, trig %d, bus %02x," -" IRQ %02x, APIC ID %x, APIC INT %02x\n" , - m->irqtype, m->irqflag &3 , (m->irqflag >>2 ) &3 , m->srcbus, - m->srcbusirq, m->dstapic, m->dstirq); +apic_pr_verbose ("Int: type %d, pol %d, trig %d, bus %02x, IRQ %02x, APIC ID %x, APIC INT %02x\n" , + m->irqtype, m->irqflag &3 , (m->irqflag >>2 ) &3 , m->srcbus, + m->srcbusirq, m->dstapic, m->dstirq);for (i =0 ; i < mp_irq_entries; i++) {if (!memcmp (&mp_irqs[i], m,sizeof (*m)))
@@ -554,28 +553,23 @@ static int pirq_entries[MAX_PIRQS] = {static int __init ioapic_pirq_setup (char *str) { -int i, max; -int ints[MAX_PIRQS +1 ]; +int i, max, ints[MAX_PIRQS +1 ];get_options (str,ARRAY_SIZE (ints), ints); -apic_printk (APIC_VERBOSE ,KERN_INFO -"PIRQ redirection, working around broken MP-BIOS.\n" ); +apic_pr_verbose ("PIRQ redirection, working around broken MP-BIOS.\n" ); + max =MAX_PIRQS ;if (ints[0 ] <MAX_PIRQS ) max = ints[0 ];for (i =0 ; i < max; i++) { -apic_printk (APIC_VERBOSE ,KERN_DEBUG -"... PIRQ%d -> IRQ %d\n" , i, ints[i+1 ]); -/* -* PIRQs are mapped upside down, usually. -*/ +apic_pr_verbose ("... PIRQ%d -> IRQ %d\n" , i, ints[i +1 ]); +/* PIRQs are mapped upside down, usually */ pirq_entries[MAX_PIRQS -i-1 ] = ints[i+1 ]; }return 1 ; } -__setup ("pirq=" , ioapic_pirq_setup);#endif /* CONFIG_X86_32 */
@@ -737,8 +731,7 @@ static bool EISA_ELCR(unsigned int irq)unsigned int port =PIC_ELCR1 + (irq >>3 );return (inb (port) >> (irq &7 )) &1 ; } -apic_printk (APIC_VERBOSE ,KERN_INFO -"Broken MPtable reports ISA irq %d\n" , irq); +apic_pr_verbose ("Broken MPtable reports ISA irq %d\n" , irq);return false; }
@@ -1052,15 +1045,13 @@ static int pin_2_irq(int idx, int ioapic, int pin, unsigned int flags)* PCI IRQ command line redirection. Yes, limits are hardcoded. */ if ((pin >=16 ) && (pin <=23 )) { -if (pirq_entries[pin-16 ] !=-1 ) { -if (!pirq_entries[pin-16 ]) { -apic_printk (APIC_VERBOSE ,KERN_DEBUG -"disabling PIRQ%d\n" , pin-16 ); +if (pirq_entries[pin -16 ] !=-1 ) { +if (!pirq_entries[pin -16 ]) { +apic_pr_verbose ("Disabling PIRQ%d\n" , pin -16 ); }else {int irq = pirq_entries[pin-16 ]; -apic_printk (APIC_VERBOSE ,KERN_DEBUG -"using PIRQ%d -> IRQ %d\n" , - pin-16 , irq); + +apic_pr_verbose ("Using PIRQ%d -> IRQ %d\n" , pin -16 , irq);return irq; } }
@@ -1111,12 +1102,10 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin) {int irq, i, best_ioapic =-1 , best_idx =-1 ; -apic_printk (APIC_DEBUG , -"querying PCI -> IRQ mapping bus:%d, slot:%d, pin:%d.\n" , - bus, slot, pin); +apic_pr_debug ("Querying PCI -> IRQ mapping bus:%d, slot:%d, pin:%d.\n" , + bus, slot, pin);if (test_bit (bus, mp_bus_not_pci)) { -apic_printk (APIC_VERBOSE , -"PCI BIOS passed nonexistent PCI bus %d!\n" , bus); +apic_pr_verbose ("PCI BIOS passed nonexistent PCI bus %d!\n" , bus);return -1 ; }
@@ -1173,17 +1162,16 @@ static void __init setup_IO_APIC_irqs(void)unsigned int ioapic, pin;int idx; -apic_printk (APIC_VERBOSE ,KERN_DEBUG "init IO_APIC IRQs\n" ); +apic_pr_verbose ("Init IO_APIC IRQs\n" );for_each_ioapic_pin (ioapic, pin) { idx =find_irq_entry (ioapic, pin, mp_INT); -if (idx <0 ) -apic_printk (APIC_VERBOSE , -KERN_DEBUG " apic %d pin %d not connected\n" , -mpc_ioapic_id (ioapic), pin); -else -pin_2_irq (idx, ioapic, pin, - ioapic ?0 :IOAPIC_MAP_ALLOC ); +if (idx <0 ) { +apic_pr_verbose ("apic %d pin %d not connected\n" , +mpc_ioapic_id (ioapic), pin); + }else { +pin_2_irq (idx, ioapic, pin, ioapic ?0 :IOAPIC_MAP_ALLOC ); + } } }
@@ -1359,29 +1347,24 @@ void __init enable_IO_APIC(void) i8259_apic =find_isa_irq_apic (0 , mp_ExtINT);/* Trust the MP table if nothing is setup in the hardware */ if ((ioapic_i8259.pin ==-1 ) && (i8259_pin >=0 )) { -printk (KERN_WARNING "ExtINT not setup in hardware but reported by MP table\n" ); +pr_warn ("ExtINT not setup in hardware but reported by MP table\n" ); ioapic_i8259.pin = i8259_pin; ioapic_i8259.apic = i8259_apic; }/* Complain if the MP table and the hardware disagree */ if (((ioapic_i8259.apic != i8259_apic) || (ioapic_i8259.pin != i8259_pin)) && - (i8259_pin >=0 ) && (ioapic_i8259.pin >=0 )) - { -printk (KERN_WARNING "ExtINT in hardware and MP table differ\n" ); - } + (i8259_pin >=0 ) && (ioapic_i8259.pin >=0 )) +pr_warn ("ExtINT in hardware and MP table differ\n" ); -/* -* Do not trust the IO-APIC being empty at bootup -*/ +/* Do not trust the IO-APIC being empty at bootup */ clear_IO_APIC (); }void native_restore_boot_irq_mode (void ) {/* -* If the i8259 is routed through an IOAPIC -* Put that IOAPIC in virtual wire mode -* so legacy interrupts can be delivered. +* If the i8259 is routed through an IOAPIC Put that IOAPIC in +* virtual wire mode so legacy interrupts can be delivered. */ if (ioapic_i8259.pin !=-1 ) {struct IO_APIC_route_entry entry;
@@ -1469,8 +1452,8 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void)set_bit (i, phys_id_present_map); ioapics[ioapic_idx].mp_config.apicid = i; }else { -apic_printk (APIC_VERBOSE ,"Setting %d in the phys_id_present_map\n" , -mpc_ioapic_id (ioapic_idx)); +apic_pr_verbose ("Setting %d in the phys_id_present_map\n" , +mpc_ioapic_id (ioapic_idx));set_bit (mpc_ioapic_id (ioapic_idx), phys_id_present_map); }
@@ -1491,9 +1474,8 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void)if (mpc_ioapic_id (ioapic_idx) == reg_00.bits.ID)continue ; -apic_printk (APIC_VERBOSE ,KERN_INFO -"...changing IO-APIC physical APIC ID to %d ..." , -mpc_ioapic_id (ioapic_idx)); +apic_pr_verbose ("...changing IO-APIC physical APIC ID to %d ..." , +mpc_ioapic_id (ioapic_idx)); reg_00.bits.ID =mpc_ioapic_id (ioapic_idx); scoped_guard (raw_spinlock_irqsave, &ioapic_lock) {
@@ -1504,7 +1486,7 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void)if (reg_00.bits.ID !=mpc_ioapic_id (ioapic_idx))pr_cont ("could not set ID!\n" );else -apic_printk (APIC_VERBOSE ," ok.\n" ); +apic_pr_verbose (" ok.\n" ); } }
@@ -2136,9 +2118,8 @@ static inline void __init check_timer(void) pin2 = ioapic_i8259.pin; apic2 = ioapic_i8259.apic; -apic_printk (APIC_QUIET ,KERN_INFO "..TIMER: vector=0x%02X " -"apic1=%d pin1=%d apic2=%d pin2=%d\n" , - cfg->vector, apic1, pin1, apic2, pin2); +pr_info ("..TIMER: vector=0x%02X apic1=%d pin1=%d apic2=%d pin2=%d\n" , + cfg->vector, apic1, pin1, apic2, pin2);/* * Some BIOS writers are clueless and report the ExtINTA
@@ -2182,13 +2163,10 @@ static inline void __init check_timer(void)panic_if_irq_remap ("timer doesn't work through Interrupt-remapped IO-APIC" );clear_IO_APIC_pin (apic1, pin1);if (!no_pin1) -apic_printk (APIC_QUIET ,KERN_ERR "..MP-BIOS bug: " -"8254 timer not connected to IO-APIC\n" ); +pr_err ("..MP-BIOS bug: 8254 timer not connected to IO-APIC\n" ); -apic_printk (APIC_QUIET ,KERN_INFO "...trying to set up timer " -"(IRQ0) through the 8259A ...\n" ); -apic_printk (APIC_QUIET ,KERN_INFO -"..... (found apic %d pin %d) ...\n" , apic2, pin2); +pr_info ("...trying to set up timer (IRQ0) through the 8259A ...\n" ); +pr_info ("..... (found apic %d pin %d) ...\n" , apic2, pin2);/* * legacy devices should be connected to IO APIC #0 */
@@ -2197,7 +2175,7 @@ static inline void __init check_timer(void)irq_domain_activate_irq (irq_data, false); legacy_pic->unmask (0 );if (timer_irq_works ()) { -apic_printk (APIC_QUIET ,KERN_INFO "....... works.\n" ); +pr_info ("....... works.\n" ); goto out; }/*
@@ -2205,26 +2183,24 @@ static inline void __init check_timer(void)*/ legacy_pic->mask (0 );clear_IO_APIC_pin (apic2, pin2); -apic_printk (APIC_QUIET ,KERN_INFO "....... failed.\n" ); +pr_info ("....... failed.\n" ); } -apic_printk (APIC_QUIET ,KERN_INFO -"...trying to set up timer as Virtual Wire IRQ...\n" ); +pr_info ("...trying to set up timer as Virtual Wire IRQ...\n" );lapic_register_intr (0 );apic_write (APIC_LVT0 ,APIC_DM_FIXED | cfg->vector);/* Fixed mode */ legacy_pic->unmask (0 );if (timer_irq_works ()) { -apic_printk (APIC_QUIET ,KERN_INFO "..... works.\n" ); +pr_info ("..... works.\n" ); goto out; } legacy_pic->mask (0 );apic_write (APIC_LVT0 ,APIC_LVT_MASKED |APIC_DM_FIXED | cfg->vector); -apic_printk (APIC_QUIET ,KERN_INFO "..... failed.\n" ); +pr_info ("..... failed.\n" ); -apic_printk (APIC_QUIET ,KERN_INFO -"...trying to set up timer as ExtINT IRQ...\n" ); +pr_info ("...trying to set up timer as ExtINT IRQ...\n" ); legacy_pic->init (0 ); legacy_pic->make_irq (0 );
@@ -2234,14 +2210,15 @@ static inline void __init check_timer(void)unlock_ExtINT_logic ();if (timer_irq_works ()) { -apic_printk (APIC_QUIET ,KERN_INFO "..... works.\n" ); +pr_info ("..... works.\n" ); goto out; } -apic_printk (APIC_QUIET ,KERN_INFO "..... failed :(.\n" ); -if (apic_is_x2apic_enabled ()) -apic_printk (APIC_QUIET ,KERN_INFO -"Perhaps problem with the pre-enabled x2apic mode\n" -"Try booting with x2apic and interrupt-remapping disabled in the bios.\n" ); + +pr_info ("..... failed :\n" ); +if (apic_is_x2apic_enabled ()) { +pr_info ("Perhaps problem with the pre-enabled x2apic mode\n" +"Try booting with x2apic and interrupt-remapping disabled in the bios.\n" ); + }panic ("IO-APIC + timer doesn't work! Boot with apic=debug and send a " "report. Then try booting with the 'noapic' option.\n" ); out:
@@ -2339,7 +2316,7 @@ void __init setup_IO_APIC(void) io_apic_irqs =nr_legacy_irqs () ? ~PIC_IRQS : ~0UL ; -apic_printk (APIC_VERBOSE ,"ENABLING IO-APIC IRQs\n" ); +apic_pr_verbose ("ENABLING IO-APIC IRQs\n" );for_each_ioapic (ioapic)BUG_ON (mp_irqdomain_create (ioapic));
@@ -2478,7 +2455,7 @@ static int io_apic_get_unique_id(int ioapic, int apic_id) } } -apic_printk (APIC_VERBOSE ,KERN_INFO "IOAPIC[%d]: Assigned apic_id %d\n" , ioapic, apic_id); +apic_pr_verbose ("IOAPIC[%d]: Assigned apic_id %d\n" , ioapic, apic_id);return apic_id; }
@@ -2514,8 +2491,8 @@ static u8 io_apic_unique_id(int idx, u8 id) new_id = reg_00.bits.ID;if (!test_bit (new_id, used)) { -apic_printk (APIC_VERBOSE ,KERN_INFO "IOAPIC[%d]: Using reg apic_id %d instead of %d\n" , - idx, new_id, id); +apic_pr_verbose ("IOAPIC[%d]: Using reg apic_id %d instead of %d\n" , + idx, new_id, id);return new_id; }
@@ -2614,9 +2591,7 @@ void __init io_apic_init_mappings(void) ioapic_phys =mpc_ioapic_addr (i);#ifdef CONFIG_X86_32 if (!ioapic_phys) { -printk (KERN_ERR -"WARNING: bogus zero IO-APIC " -"address found in MPTABLE, " +pr_err ("WARNING: bogus zero IO-APIC address found in MPTABLE, " "disabling IO/APIC support!\n" ); smp_found_config =0 ; ioapic_is_disabled = true;
@@ -2635,9 +2610,8 @@ fake_ioapic_page: ioapic_phys =__pa (ioapic_phys); }io_apic_set_fixmap (idx, ioapic_phys); -apic_printk (APIC_VERBOSE ,"mapped IOAPIC to %08lx (%08lx)\n" , -__fix_to_virt (idx) + (ioapic_phys & ~PAGE_MASK ), - ioapic_phys); +apic_pr_verbose ("mapped IOAPIC to %08lx (%08lx)\n" , +__fix_to_virt (idx) + (ioapic_phys & ~PAGE_MASK ), ioapic_phys); idx++; ioapic_res->start = ioapic_phys;
@@ -2648,13 +2622,12 @@ fake_ioapic_page:void __init ioapic_insert_resources (void ) { -int i;struct resource *r = ioapic_resources; +int i;if (!r) {if (nr_ioapics >0 ) -printk (KERN_ERR -"IO APIC resources couldn't be allocated.\n" ); +pr_err ("IO APIC resources couldn't be allocated.\n" );return ; }
@@ -2674,11 +2647,12 @@ int mp_find_ioapic(u32 gsi)/* Find the IOAPIC that manages this GSI. */ for_each_ioapic (i) {struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (i); +if (gsi >= gsi_cfg->gsi_base && gsi <= gsi_cfg->gsi_end)return i; } -printk (KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n" , gsi); +pr_err ("ERROR: Unable to locate IOAPIC for GSI %d\n" , gsi);return -1 ; }
@@ -2745,12 +2719,13 @@ int mp_register_ioapic(int id, u32 address, u32 gsi_base,pr_warn ("Bogus (zero) I/O APIC address found, skipping!\n" );return -EINVAL ; } -for_each_ioapic (ioapic) + +for_each_ioapic (ioapic) {if (ioapics[ioapic].mp_config.apicaddr == address) { -pr_warn ("address 0x%x conflicts with IOAPIC%d\n" , - address, ioapic); +pr_warn ("address 0x%x conflicts with IOAPIC%d\n" , address, ioapic);return -EEXIST ; } + } idx =find_free_ioapic_entry ();if (idx >=MAX_IO_APICS ) {
@@ -2785,8 +2760,7 @@ int mp_register_ioapic(int id, u32 address, u32 gsi_base, (gsi_end >= gsi_cfg->gsi_base && gsi_end <= gsi_cfg->gsi_end)) {pr_warn ("GSI range [%u-%u] for new IOAPIC conflicts with GSI[%u-%u]\n" , - gsi_base, gsi_end, - gsi_cfg->gsi_base, gsi_cfg->gsi_end); + gsi_base, gsi_end, gsi_cfg->gsi_base, gsi_cfg->gsi_end);clear_fixmap (FIX_IO_APIC_BASE_0 + idx);return -ENOSPC ; }
@@ -2820,8 +2794,7 @@ int mp_register_ioapic(int id, u32 address, u32 gsi_base, ioapics[idx].nr_registers = entries;pr_info ("IOAPIC[%d]: apic_id %d, version %d, address 0x%x, GSI %d-%d\n" , - idx,mpc_ioapic_id (idx), -mpc_ioapic_ver (idx),mpc_ioapic_addr (idx), + idx,mpc_ioapic_id (idx),mpc_ioapic_ver (idx),mpc_ioapic_addr (idx), gsi_cfg->gsi_base, gsi_cfg->gsi_end);return 0 ;
@@ -2850,8 +2823,7 @@ int mp_unregister_ioapic(u32 gsi_base)if (irq >=0 ) { data =irq_get_chip_data (irq);if (data && data->count) { -pr_warn ("pin%d on IOAPIC%d is still in use.\n" , - pin, ioapic); +pr_warn ("pin%d on IOAPIC%d is still in use.\n" , pin, ioapic);return -EBUSY ; } }
@@ -2968,10 +2940,8 @@ int mp_irqdomain_alloc(struct irq_domain *domain, unsigned int virq, legacy_pic->mask (virq);local_irq_restore (flags); -apic_printk (APIC_VERBOSE ,KERN_DEBUG -"IOAPIC[%d]: Preconfigured routing entry (%d-%d -> IRQ %d Level:%i ActiveLow:%i)\n" , - ioapic,mpc_ioapic_id (ioapic), pin, virq, - data->is_level, data->active_low); +apic_pr_verbose ("IOAPIC[%d]: Preconfigured routing entry (%d-%d -> IRQ %d Level:%i ActiveLow:%i)\n" , + ioapic,mpc_ioapic_id (ioapic), pin, virq, data->is_level, data->active_low);return 0 ; free_irqs:
PATCH 8/15 x86/ioapic: Cleanup guarded debug printk()s
In reply to Thomas GleixnerCleanup the APIC printk()s which are inside of a apic verbosity guarded region by using apic_dbg() for the KERN_DEBUG level prints.
--- arch/x86/kernel/apic/io_apic.c | 67 +++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 38 deletions(-)
arch/x86/kernel/apic/io_apic.c +29 -38
@@ -1186,26 +1186,21 @@ static void io_apic_print_entries(unsignchar buf[256 ];int i; -printk (KERN_DEBUG "IOAPIC %d:\n" , apic); +apic_dbg ("IOAPIC %d:\n" , apic);for (i =0 ; i <= nr_entries; i++) { entry =ioapic_read_entry (apic, i); -snprintf (buf,sizeof (buf), -" pin%02x, %s, %s, %s, V(%02X), IRR(%1d), S(%1d)" , - i, - entry.masked ?"disabled" :"enabled " , +snprintf (buf,sizeof (buf)," pin%02x, %s, %s, %s, V(%02X), IRR(%1d), S(%1d)" , + i, entry.masked ?"disabled" :"enabled " , entry.is_level ?"level" :"edge " , entry.active_low ?"low " :"high" , entry.vector, entry.irr, entry.delivery_status);if (entry.ir_format) { -printk (KERN_DEBUG "%s, remapped, I(%04X), Z(%X)\n" , - buf, - (entry.ir_index_15 <<15 ) | entry.ir_index_0_14, - entry.ir_zero); +apic_dbg ("%s, remapped, I(%04X), Z(%X)\n" , buf, + (entry.ir_index_15 <<15 ) | entry.ir_index_0_14, entry.ir_zero); }else { -printk (KERN_DEBUG "%s, %s, D(%02X%02X), M(%1d)\n" , buf, - entry.dest_mode_logical ?"logical " :"physical" , - entry.virt_destid_8_14, entry.destid_0_7, - entry.delivery_mode); +apic_dbg ("%s, %s, D(%02X%02X), M(%1d)\n" , buf, + entry.dest_mode_logical ?"logical " :"physic al" , + entry.virt_destid_8_14, entry.destid_0_7, entry.delivery_mode); } } }
@@ -1226,19 +1221,15 @@ static void __init print_IO_APIC(int ioa reg_03.raw =io_apic_read (ioapic_idx,3 ); } -printk (KERN_DEBUG "IO APIC #%d......\n" ,mpc_ioapic_id (ioapic_idx)); -printk (KERN_DEBUG ".... register #00: %08X\n" , reg_00.raw); -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); - -printk (KERN_DEBUG ".... register #01: %08X\n" , *(int *)®_01); -printk (KERN_DEBUG "....... : max redirection entries: %02X\n" , - reg_01.bits.entries); - -printk (KERN_DEBUG "....... : PRQ implemented: %X\n" , reg_01.bits.PRQ); -printk (KERN_DEBUG "....... : IO APIC version: %02X\n" , - reg_01.bits.version); +apic_dbg ("IO APIC #%d......\n" ,mpc_ioapic_id (ioapic_idx)); +apic_dbg (".... register #00: %08X\n" , reg_00.raw); +apic_dbg ("....... : physical APIC id: %02X\n" , reg_00.bits.ID); +apic_dbg ("....... : Delivery Type: %X\n" , reg_00.bits.delivery_type); +apic_dbg ("....... : LTS : %X\n" , reg_00.bits.LTS); +apic_dbg (".... register #01: %08X\n" , *(int *)®_01); +apic_dbg ("....... : max redirection entries: %02X\n" ,reg_01.bits.entries); +apic_dbg ("....... : PRQ implemented: %X\n" , reg_01.bits.PRQ); +apic_dbg ("....... : IO APIC version: %02X\n" , reg_01.bits.version);/* * Some Intel chipsets with IO APIC VERSION of 0x1? don't have reg_02,
@@ -1246,8 +1237,8 @@ static void __init print_IO_APIC(int ioa* value, so ignore it if reg_02 == reg_01. */ if (reg_01.bits.version >=0x10 && reg_02.raw != reg_01.raw) { -printk (KERN_DEBUG ".... register #02: %08X\n" , reg_02.raw); -printk (KERN_DEBUG "....... : arbitration: %02X\n" , reg_02.bits.arbitration); +apic_dbg (".... register #02: %08X\n" , reg_02.raw); +apic_dbg ("....... : arbitration: %02X\n" , reg_02.bits.arbitration); }/*
@@ -1257,11 +1248,11 @@ static void __init print_IO_APIC(int ioa*/ if (reg_01.bits.version >=0x20 && reg_03.raw != reg_02.raw && reg_03.raw != reg_01.raw) { -printk (KERN_DEBUG ".... register #03: %08X\n" , reg_03.raw); -printk (KERN_DEBUG "....... : Boot DT : %X\n" , reg_03.bits.boot_DT); +apic_dbg (".... register #03: %08X\n" , reg_03.raw); +apic_dbg ("....... : Boot DT : %X\n" , reg_03.bits.boot_DT); } -printk (KERN_DEBUG ".... IRQ redirection table:\n" ); +apic_dbg (".... IRQ redirection table:\n" );io_apic_print_entries (ioapic_idx, reg_01.bits.entries); }
@@ -1270,11 +1261,11 @@ void __init print_IO_APICs(void)int ioapic_idx;unsigned int irq; -printk (KERN_DEBUG "number of MP IRQ sources: %d.\n" , mp_irq_entries); -for_each_ioapic (ioapic_idx) -printk (KERN_DEBUG "number of IO-APIC #%d registers: %d.\n" , -mpc_ioapic_id (ioapic_idx), - ioapics[ioapic_idx].nr_registers); +apic_dbg ("number of MP IRQ sources: %d.\n" , mp_irq_entries); +for_each_ioapic (ioapic_idx) { +apic_dbg ("number of IO-APIC #%d registers: %d.\n" , +mpc_ioapic_id (ioapic_idx), ioapics[ioapic_idx].nr_registers); + }/* * We are a bit conservative about what we expect. We have to
@@ -1285,7 +1276,7 @@ void __init print_IO_APICs(void)for_each_ioapic (ioapic_idx)print_IO_APIC (ioapic_idx); -printk (KERN_DEBUG "IRQ to pin mappings:\n" ); +apic_dbg ("IRQ to pin mappings:\n" );for_each_active_irq (irq) {struct irq_pin_list *entry;struct irq_chip *chip;
@@ -1300,7 +1291,7 @@ void __init print_IO_APICs(void)if (list_empty (&data->irq_2_pin))continue ; -printk (KERN_DEBUG "IRQ%d " , irq); +apic_dbg ("IRQ%d " , irq);for_each_irq_pin (entry, data->irq_2_pin)pr_cont ("-> %d:%d" , entry->apic, entry->pin);pr_cont ("\n" );
Re: [patch 08/15] x86/ioapic: Cleanup guarded debug printk()s
Quoted 18 lines
From: Thomas Gleixner <[email protected]>
To: LKML <[email protected]>
Cc: [email protected]
Subject: [patch 08/15] x86/ioapic: Cleanup guarded debug printk()sCleanup the APIC printk()s which are inside of a apic verbosity guarded region by using
apic_dbg()for theKERN_DEBUGlevel prints.Signed-off-by Thomas Gleixner <[email protected]>--- arch/x86/kernel/apic/io_apic.c | 67 +++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 38 deletions(-)arch/x86/kernel/apic/io_apic.c +0
-0@@ -1186,26 +1186,21 @@ static void io_apic_print_entries(unsignchar buf[256 ];int i;
arch/x86/kernel/apic/io_apic.c static void io_apic_print_entries(unsign · line 1192
Quoted 10 lines
arch/x86/kernel/apic/io_apic.c +2
-5-printk (KERN_DEBUG "IOAPIC %d:\n" , apic); +apic_dbg ("IOAPIC %d:\n" , apic);for (i =0 ; i <= nr_entries; i++) { entry =ioapic_read_entry (apic, i); - snprintf(buf, sizeof(buf), - " pin%02x, %s, %s, %s, V(%02X), IRR(%1d), S(%1d)", - i, - entry.masked ? "disabled" : "enabled ", + snprintf(buf, sizeof(buf)," pin%02x, %s, %s, %s, V(%02X), IRR(%1d), S(%1d)",
Need a space after the 2nd ','.
arch/x86/kernel/apic/io_apic.c static void __init print_IO_APIC(int ioa · line 1230
Quoted 12 lines
arch/x86/kernel/apic/io_apic.c +3
-0+ i, entry.masked ?"disabled" :"enabled " , entry.is_level ? "level" : "edge ",@@ -1226,19 +1221,15 @@ static void __init print_IO_APIC(int ioa reg_03.raw =io_apic_read (ioapic_idx,3 ); } +apic_dbg (".... register #01: %08X\n" , *(int *)®_01); +apic_dbg ("....... : max redirection entries: %02X\n" ,reg_01.bits.entries);
Need a space after ','.
[tip: x86/apic] x86/ioapic: Cleanup guarded debug printk()s
In reply to Thomas GleixnerThe following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: 54cd3795b471057a7e82acaade2b6a22beee1242 Gitweb: https://git.kernel.org/tip/54cd3795b471057a7e82acaade2b6a22beee1242 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:43 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:28 +02:00
x86/ioapic: Cleanup guarded debug printk()s
Cleanup the APIC printk()s which are inside of a apic verbosity guarded region by using apic_dbg() for the KERN_DEBUG level prints.
--- arch/x86/kernel/apic/io_apic.c | 67 ++++++++++++++------------------- 1 file changed, 29 insertions(+), 38 deletions(-)
arch/x86/kernel/apic/io_apic.c +29 -38
@@ -1186,26 +1186,21 @@ static void io_apic_print_entries(unsigned int apic, unsigned int nr_entries)char buf[256 ];int i; -printk (KERN_DEBUG "IOAPIC %d:\n" , apic); +apic_dbg ("IOAPIC %d:\n" , apic);for (i =0 ; i <= nr_entries; i++) { entry =ioapic_read_entry (apic, i); -snprintf (buf,sizeof (buf), -" pin%02x, %s, %s, %s, V(%02X), IRR(%1d), S(%1d)" , - i, - entry.masked ?"disabled" :"enabled " , +snprintf (buf,sizeof (buf)," pin%02x, %s, %s, %s, V(%02X), IRR(%1d), S(%1d)" , + i, entry.masked ?"disabled" :"enabled " , entry.is_level ?"level" :"edge " , entry.active_low ?"low " :"high" , entry.vector, entry.irr, entry.delivery_status);if (entry.ir_format) { -printk (KERN_DEBUG "%s, remapped, I(%04X), Z(%X)\n" , - buf, - (entry.ir_index_15 <<15 ) | entry.ir_index_0_14, - entry.ir_zero); +apic_dbg ("%s, remapped, I(%04X), Z(%X)\n" , buf, + (entry.ir_index_15 <<15 ) | entry.ir_index_0_14, entry.ir_zero); }else { -printk (KERN_DEBUG "%s, %s, D(%02X%02X), M(%1d)\n" , buf, - entry.dest_mode_logical ?"logical " :"physical" , - entry.virt_destid_8_14, entry.destid_0_7, - entry.delivery_mode); +apic_dbg ("%s, %s, D(%02X%02X), M(%1d)\n" , buf, + entry.dest_mode_logical ?"logical " :"physic al" , + entry.virt_destid_8_14, entry.destid_0_7, entry.delivery_mode); } } }
@@ -1226,19 +1221,15 @@ static void __init print_IO_APIC(int ioapic_idx) reg_03.raw =io_apic_read (ioapic_idx,3 ); } -printk (KERN_DEBUG "IO APIC #%d......\n" ,mpc_ioapic_id (ioapic_idx)); -printk (KERN_DEBUG ".... register #00: %08X\n" , reg_00.raw); -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); - -printk (KERN_DEBUG ".... register #01: %08X\n" , *(int *)®_01); -printk (KERN_DEBUG "....... : max redirection entries: %02X\n" , - reg_01.bits.entries); - -printk (KERN_DEBUG "....... : PRQ implemented: %X\n" , reg_01.bits.PRQ); -printk (KERN_DEBUG "....... : IO APIC version: %02X\n" , - reg_01.bits.version); +apic_dbg ("IO APIC #%d......\n" ,mpc_ioapic_id (ioapic_idx)); +apic_dbg (".... register #00: %08X\n" , reg_00.raw); +apic_dbg ("....... : physical APIC id: %02X\n" , reg_00.bits.ID); +apic_dbg ("....... : Delivery Type: %X\n" , reg_00.bits.delivery_type); +apic_dbg ("....... : LTS : %X\n" , reg_00.bits.LTS); +apic_dbg (".... register #01: %08X\n" , *(int *)®_01); +apic_dbg ("....... : max redirection entries: %02X\n" , reg_01.bits.entries); +apic_dbg ("....... : PRQ implemented: %X\n" , reg_01.bits.PRQ); +apic_dbg ("....... : IO APIC version: %02X\n" , reg_01.bits.version);/* * Some Intel chipsets with IO APIC VERSION of 0x1? don't have reg_02,
@@ -1246,8 +1237,8 @@ static void __init print_IO_APIC(int ioapic_idx)* value, so ignore it if reg_02 == reg_01. */ if (reg_01.bits.version >=0x10 && reg_02.raw != reg_01.raw) { -printk (KERN_DEBUG ".... register #02: %08X\n" , reg_02.raw); -printk (KERN_DEBUG "....... : arbitration: %02X\n" , reg_02.bits.arbitration); +apic_dbg (".... register #02: %08X\n" , reg_02.raw); +apic_dbg ("....... : arbitration: %02X\n" , reg_02.bits.arbitration); }/*
@@ -1257,11 +1248,11 @@ static void __init print_IO_APIC(int ioapic_idx)*/ if (reg_01.bits.version >=0x20 && reg_03.raw != reg_02.raw && reg_03.raw != reg_01.raw) { -printk (KERN_DEBUG ".... register #03: %08X\n" , reg_03.raw); -printk (KERN_DEBUG "....... : Boot DT : %X\n" , reg_03.bits.boot_DT); +apic_dbg (".... register #03: %08X\n" , reg_03.raw); +apic_dbg ("....... : Boot DT : %X\n" , reg_03.bits.boot_DT); } -printk (KERN_DEBUG ".... IRQ redirection table:\n" ); +apic_dbg (".... IRQ redirection table:\n" );io_apic_print_entries (ioapic_idx, reg_01.bits.entries); }
@@ -1270,11 +1261,11 @@ void __init print_IO_APICs(void)int ioapic_idx;unsigned int irq; -printk (KERN_DEBUG "number of MP IRQ sources: %d.\n" , mp_irq_entries); -for_each_ioapic (ioapic_idx) -printk (KERN_DEBUG "number of IO-APIC #%d registers: %d.\n" , -mpc_ioapic_id (ioapic_idx), - ioapics[ioapic_idx].nr_registers); +apic_dbg ("number of MP IRQ sources: %d.\n" , mp_irq_entries); +for_each_ioapic (ioapic_idx) { +apic_dbg ("number of IO-APIC #%d registers: %d.\n" , +mpc_ioapic_id (ioapic_idx), ioapics[ioapic_idx].nr_registers); + }/* * We are a bit conservative about what we expect. We have to
@@ -1285,7 +1276,7 @@ void __init print_IO_APICs(void)for_each_ioapic (ioapic_idx)print_IO_APIC (ioapic_idx); -printk (KERN_DEBUG "IRQ to pin mappings:\n" ); +apic_dbg ("IRQ to pin mappings:\n" );for_each_active_irq (irq) {struct irq_pin_list *entry;struct irq_chip *chip;
@@ -1300,7 +1291,7 @@ void __init print_IO_APICs(void)if (list_empty (&data->irq_2_pin))continue ; -printk (KERN_DEBUG "IRQ%d " , irq); +apic_dbg ("IRQ%d " , irq);for_each_irq_pin (entry, data->irq_2_pin)pr_cont ("-> %d:%d" , entry->apic, entry->pin);pr_cont ("\n" );
PATCH 9/15 x86/mpparse: Cleanup apic_printk()s
In reply to Thomas GleixnerUse the new apic_pr_verbose() helper.
--- arch/x86/kernel/mpparse.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/kernel/mpparse.c +6 -6
@@ -68,7 +68,7 @@ static void __init mpc_oem_bus_info(stru {memcpy (str, m->bustype,6 ); str[6 ] =0 ; -apic_printk (APIC_VERBOSE ,"Bus #%d is %s\n" , m->busid, str); +apic_pr_verbose ("Bus #%d is %s\n" , m->busid, str); }static void __init MP_bus_info (struct mpc_bus *m)
@@ -417,7 +417,7 @@ static unsigned long __init get_mpc_size mpc =early_memremap (physptr,PAGE_SIZE ); size = mpc->length;early_memunmap (mpc,PAGE_SIZE ); -apic_printk (APIC_VERBOSE ," mpc: %lx-%lx\n" , physptr, physptr + size); +apic_pr_verbose (" mpc: %lx-%lx\n" , physptr, physptr + size);return size; }
@@ -560,7 +560,7 @@ static int __init smp_scan_config(unsignstruct mpf_intel *mpf;int ret =0 ; -apic_printk (APIC_VERBOSE ,"Scan for SMP in [mem %#010lx-%#010lx]\n" , +apic_pr_verbose ("Scan for SMP in [mem %#010lx-%#010lx]\n" , base, base + length -1 );BUILD_BUG_ON (sizeof (*mpf) !=16 );
@@ -683,13 +683,13 @@ static void __init check_irq_src(struct {int i; -apic_printk (APIC_VERBOSE ,"OLD " ); +apic_pr_verbose ("OLD " );print_mp_irq_info (m); i =get_MP_intsrc_index (m);if (i >0 ) {memcpy (m, &mp_irqs[i],sizeof (*m)); -apic_printk (APIC_VERBOSE ,"NEW " ); +apic_pr_verbose ("NEW " );print_mp_irq_info (&mp_irqs[i]);return ; }
@@ -772,7 +772,7 @@ static int __init replace_intsrc_all(stcontinue ;if (nr_m_spare >0 ) { -apic_printk (APIC_VERBOSE ,"*NEW* found\n" ); +apic_pr_verbose ("*NEW* found\n" ); nr_m_spare--;memcpy (m_spare[nr_m_spare], &mp_irqs[i],sizeof (mp_irqs[i])); m_spare[nr_m_spare] =NULL ;
Re: [patch 09/15] x86/mpparse: Cleanup apic_printk()s
Quoted 14 lines
[...]
Subject: [patch 09/15] x86/mpparse: Cleanup apic_printk()sUse the new
apic_pr_verbose()helper.Signed-off-by Thomas Gleixner <[email protected]>--- arch/x86/kernel/mpparse.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)arch/x86/kernel/mpparse.c +0
-0
arch/x86/kernel/mpparse.c static int __init smp_scan_config(unsign · line 564
Quoted 6 lines
arch/x86/kernel/mpparse.c +1
-1@@ -560,7 +560,7 @@ static int __init smp_scan_config(unsignstruct mpf_intel *mpf;int ret =0 ; -apic_printk (APIC_VERBOSE ,"Scan for SMP in [mem %#010lx-%#010lx]\n" , +apic_pr_verbose ("Scan for SMP in [mem %#010lx-%#010lx]\n" , base, base + length -1 );
Align the open parenthesis.
[tip: x86/apic] x86/mpparse: Cleanup apic_printk()s
In reply to Thomas GleixnerThe following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: 1ee0aa8285c11921ad22336d07b67fc81a0d36cf Gitweb: https://git.kernel.org/tip/1ee0aa8285c11921ad22336d07b67fc81a0d36cf Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:44 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:28 +02:00
x86/mpparse: Cleanup apic_printk()s
Use the new apic_pr_verbose() helper.
--- arch/x86/kernel/mpparse.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
arch/x86/kernel/mpparse.c +6 -7
@@ -68,7 +68,7 @@ static void __init mpc_oem_bus_info(struct mpc_bus *m, char *str) {memcpy (str, m->bustype,6 ); str[6 ] =0 ; -apic_printk (APIC_VERBOSE ,"Bus #%d is %s\n" , m->busid, str); +apic_pr_verbose ("Bus #%d is %s\n" , m->busid, str); }static void __init MP_bus_info (struct mpc_bus *m)
@@ -417,7 +417,7 @@ static unsigned long __init get_mpc_size(unsigned long physptr) mpc =early_memremap (physptr,PAGE_SIZE ); size = mpc->length;early_memunmap (mpc,PAGE_SIZE ); -apic_printk (APIC_VERBOSE ," mpc: %lx-%lx\n" , physptr, physptr + size); +apic_pr_verbose (" mpc: %lx-%lx\n" , physptr, physptr + size);return size; }
@@ -560,8 +560,7 @@ static int __init smp_scan_config(unsigned long base, unsigned long length)struct mpf_intel *mpf;int ret =0 ; -apic_printk (APIC_VERBOSE ,"Scan for SMP in [mem %#010lx-%#010lx]\n" , - base, base + length -1 ); +apic_pr_verbose ("Scan for SMP in [mem %#010lx-%#010lx]\n" , base, base + length -1 );BUILD_BUG_ON (sizeof (*mpf) !=16 );while (length >0 ) {
@@ -683,13 +682,13 @@ static void __init check_irq_src(struct mpc_intsrc *m, int *nr_m_spare) {int i; -apic_printk (APIC_VERBOSE ,"OLD " ); +apic_pr_verbose ("OLD " );print_mp_irq_info (m); i =get_MP_intsrc_index (m);if (i >0 ) {memcpy (m, &mp_irqs[i],sizeof (*m)); -apic_printk (APIC_VERBOSE ,"NEW " ); +apic_pr_verbose ("NEW " );print_mp_irq_info (&mp_irqs[i]);return ; }
@@ -772,7 +771,7 @@ static int __init replace_intsrc_all(struct mpc_table *mpc,continue ;if (nr_m_spare >0 ) { -apic_printk (APIC_VERBOSE ,"*NEW* found\n" ); +apic_pr_verbose ("*NEW* found\n" ); nr_m_spare--;memcpy (m_spare[nr_m_spare], &mp_irqs[i],sizeof (mp_irqs[i])); m_spare[nr_m_spare] =NULL ;
PATCH 10/15 iommu/vt-d: Cleanup apic_printk()
In reply to Thomas GleixnerUse the new apic_pr_verbose() helper.
--- drivers/iommu/intel/irq_remapping.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iommu/intel/irq_remapping.c +5 -6
@@ -1352,12 +1352,11 @@ static void intel_irq_remapping_prepare_case X86_IRQ_ALLOC_TYPE_IOAPIC :/* Set source-id of interrupt request */ set_ioapic_sid (irte, info->devid); -apic_printk (APIC_VERBOSE ,KERN_DEBUG "IOAPIC[%d]: Set IRTE entry (P:%d FPD:%d Dst_Mode:%d Redir_hint:%d Trig_Mode:%d Dlvry_Mode:%X Avail:%X Vector:%02X Dest:%08X SID:%04X SQ:%X SVT:%X)\n" , - info->devid, irte->present, irte->fpd, - irte->dst_mode, irte->redir_hint, - irte->trigger_mode, irte->dlvry_mode, - irte->avail, irte->vector, irte->dest_id, - irte->sid, irte->sq, irte->svt); +apic_pr_verbose ("IOAPIC[%d]: Set IRTE entry (P:%d FPD:%d Dst_Mode:%d Redir_hint:%d Trig_Mode:%d Dlvry_Mode:%X Avail:%X Vector:%02X Dest:%08X SID:%04X SQ:%X SVT:%X)\n" , + info->devid, irte->present, irte->fpd, irte->dst_mode, + irte->redir_hint, irte->trigger_mode, irte->dlvry_mode, + irte->avail, irte->vector, irte->dest_id, irte->sid, + irte->sq, irte->svt); sub_handle = info->ioapic.pin;break ;case X86_IRQ_ALLOC_TYPE_HPET :
[tip: x86/apic] iommu/vt-d: Cleanup apic_printk()
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: 48855a2c92203389cb215c86ee3d2f2df5aa4024 Gitweb: https://git.kernel.org/tip/48855a2c92203389cb215c86ee3d2f2df5aa4024 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:45 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:28 +02:00
iommu/vt-d: Cleanup apic_printk()
Use the new apic_pr_verbose() helper.
--- drivers/iommu/intel/irq_remapping.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iommu/intel/irq_remapping.c +5 -6
@@ -1352,12 +1352,11 @@ static void intel_irq_remapping_prepare_irte(struct intel_ir_data *data,case X86_IRQ_ALLOC_TYPE_IOAPIC :/* Set source-id of interrupt request */ set_ioapic_sid (irte, info->devid); -apic_printk (APIC_VERBOSE ,KERN_DEBUG "IOAPIC[%d]: Set IRTE entry (P:%d FPD:%d Dst_Mode:%d Redir_hint:%d Trig_Mode:%d Dlvry_Mode:%X Avail:%X Vector:%02X Dest:%08X SID:%04X SQ:%X SVT:%X)\n" , - info->devid, irte->present, irte->fpd, - irte->dst_mode, irte->redir_hint, - irte->trigger_mode, irte->dlvry_mode, - irte->avail, irte->vector, irte->dest_id, - irte->sid, irte->sq, irte->svt); +apic_pr_verbose ("IOAPIC[%d]: Set IRTE entry (P:%d FPD:%d Dst_Mode:%d Redir_hint:%d Trig_Mode:%d Dlvry_Mode:%X Avail:%X Vector:%02X Dest:%08X SID:%04X SQ:%X SVT:%X)\n" , + info->devid, irte->present, irte->fpd, irte->dst_mode, + irte->redir_hint, irte->trigger_mode, irte->dlvry_mode, + irte->avail, irte->vector, irte->dest_id, irte->sid, + irte->sq, irte->svt); sub_handle = info->ioapic.pin;break ;case X86_IRQ_ALLOC_TYPE_HPET :
PATCH 11/15 x86/ioapic: Move replace_pin_at_irq_node() to the call site
In reply to Thomas GleixnerIt's only used by check_timer().
--- arch/x86/kernel/apic/io_apic.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)
arch/x86/kernel/apic/io_apic.c +18 -22
@@ -370,28 +370,6 @@ static void __remove_pin_from_irq(struct } } -/* -* Reroute an IRQ to a different pin. -*/ -static void __init replace_pin_at_irq_node (struct mp_chip_data *data,int node, -int oldapic,int oldpin, -int newapic,int newpin) -{ -struct irq_pin_list *entry; - -for_each_irq_pin (entry, data->irq_2_pin) { -if (entry->apic == oldapic && entry->pin == oldpin) { - entry->apic = newapic; - entry->pin = newpin; -/* every one is different, right? */ -return ; - } - } - -/* old apic/pin didn't exist, so just add new ones */ -add_pin_to_irq_node (data, node, newapic, newpin); -} -static void io_apic_modify_irq (struct mp_chip_data *data,bool masked,void (*final)(struct irq_pin_list *entry)) {
@@ -2069,6 +2047,24 @@ static int __init mp_alloc_timer_irq(intreturn irq; } +static void __init replace_pin_at_irq_node (struct mp_chip_data *data,int node, +int oldapic,int oldpin, +int newapic,int newpin) +{ +struct irq_pin_list *entry; + +for_each_irq_pin (entry, data->irq_2_pin) { +if (entry->apic == oldapic && entry->pin == oldpin) { + entry->apic = newapic; + entry->pin = newpin; +return ; + } + } + +/* Old apic/pin didn't exist, so just add a new one */ +add_pin_to_irq_node (data, node, newapic, newpin); +} +/* * This code may look a bit paranoid, but it's supposed to cooperate with * a wide range of boards and BIOS bugs. Fortunately only the timer IRQ
[tip: x86/apic] x86/ioapic: Move replace_pin_at_irq_node() to the call site
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: ee64510fb959991c3afd94e05e468a5b27e77f68 Gitweb: https://git.kernel.org/tip/ee64510fb959991c3afd94e05e468a5b27e77f68 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:47 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:28 +02:00
x86/ioapic: Move replace_pin_at_irq_node() to the call site
It's only used by check_timer().
--- arch/x86/kernel/apic/io_apic.c | 40 ++++++++++++++------------------- 1 file changed, 18 insertions(+), 22 deletions(-)
arch/x86/kernel/apic/io_apic.c +18 -22
@@ -370,28 +370,6 @@ static void __remove_pin_from_irq(struct mp_chip_data *data, int apic, int pin) } } -/* -* Reroute an IRQ to a different pin. -*/ -static void __init replace_pin_at_irq_node (struct mp_chip_data *data,int node, -int oldapic,int oldpin, -int newapic,int newpin) -{ -struct irq_pin_list *entry; - -for_each_irq_pin (entry, data->irq_2_pin) { -if (entry->apic == oldapic && entry->pin == oldpin) { - entry->apic = newapic; - entry->pin = newpin; -/* every one is different, right? */ -return ; - } - } - -/* old apic/pin didn't exist, so just add new ones */ -add_pin_to_irq_node (data, node, newapic, newpin); -} -static void io_apic_modify_irq (struct mp_chip_data *data,bool masked,void (*final)(struct irq_pin_list *entry)) {
@@ -2067,6 +2045,24 @@ static int __init mp_alloc_timer_irq(int ioapic, int pin)return irq; } +static void __init replace_pin_at_irq_node (struct mp_chip_data *data,int node, +int oldapic,int oldpin, +int newapic,int newpin) +{ +struct irq_pin_list *entry; + +for_each_irq_pin (entry, data->irq_2_pin) { +if (entry->apic == oldapic && entry->pin == oldpin) { + entry->apic = newapic; + entry->pin = newpin; +return ; + } + } + +/* Old apic/pin didn't exist, so just add a new one */ +add_pin_to_irq_node (data, node, newapic, newpin); +} +/* * This code may look a bit paranoid, but it's supposed to cooperate with * a wide range of boards and BIOS bugs. Fortunately only the timer IRQ
PATCH 12/15 x86/ioapic: Cleanup comments
In reply to Thomas GleixnerUse proper comment styles and shrink comments to their scope where applicable.
--- arch/x86/kernel/apic/io_apic.c | 86 +++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 49 deletions(-)
arch/x86/kernel/apic/io_apic.c +37 -49
@@ -384,12 +384,12 @@ static void io_apic_modify_irq(struct mp } } +/* +* Synchronize the IO-APIC and the CPU by doing a dummy read from the +* IO-APIC +*/ static void io_apic_sync (struct irq_pin_list *entry) { -/* -* Synchronize the IO-APIC and the CPU by doing -* a dummy read from the IO-APIC -*/ struct io_apic __iomem *io_apic; io_apic =io_apic_base (entry->apic);
@@ -442,17 +442,13 @@ static void __eoi_ioapic_pin(int apic, i entry = entry1 =__ioapic_read_entry (apic, pin); -/* -* Mask the entry and change the trigger mode to edge. -*/ +/* Mask the entry and change the trigger mode to edge. */ entry1.masked = true; entry1.is_level = false;__ioapic_write_entry (apic, pin, entry1); -/* -* Restore the previous level triggered entry. -*/ +/* Restore the previous level triggered entry. */ __ioapic_write_entry (apic, pin, entry); } }
@@ -1012,16 +1008,12 @@ static int pin_2_irq(int idx, int ioapic {u32 gsi =mp_pin_to_gsi (ioapic, pin); -/* -* Debugging check, we are in big trouble if this message pops up! -*/ +/* Debugging check, we are in big trouble if this message pops up! */ if (mp_irqs[idx].dstirq != pin)pr_err ("broken BIOS or MPTABLE parser, ayiee!!\n" );#ifdef CONFIG_X86_32 -/* -* PCI IRQ command line redirection. Yes, limits are hardcoded. -*/ +/* PCI IRQ command line redirection. Yes, limits are hardcoded. */ if ((pin >=16 ) && (pin <=23 )) {if (pirq_entries[pin -16 ] !=-1 ) {if (!pirq_entries[pin -16 ]) {
@@ -1296,8 +1288,9 @@ void __init enable_IO_APIC(void)/* See if any of the pins is in ExtINT mode */ struct IO_APIC_route_entry entry =ioapic_read_entry (apic, pin); -/* If the interrupt line is enabled and in ExtInt mode -* I have found the pin where the i8259 is connected. +/* +* If the interrupt line is enabled and in ExtInt mode I +* have found the pin where the i8259 is connected. */ if (!entry.masked && entry.delivery_mode ==APIC_DELIVERY_MODE_EXTINT ) {
@@ -1307,8 +1300,11 @@ void __init enable_IO_APIC(void) } } found_i8259: -/* Look to see what if the MP table has reported the ExtINT */ -/* If we could not find the appropriate pin by looking at the ioapic + +/* +* Look to see what if the MP table has reported the ExtINT +* +* If we could not find the appropriate pin by looking at the ioapic * the i8259 probably is not connected the ioapic but give the * mptable a chance anyway. */
@@ -1348,9 +1344,7 @@ void native_restore_boot_irq_mode(void) entry.destid_0_7 = apic_id &0xFF ; entry.virt_destid_8_14 = apic_id >>8 ; -/* -* Add it to the IO-APIC irq-routing table: -*/ +/* Add it to the IO-APIC irq-routing table */ ioapic_write_entry (ioapic_i8259.apic, ioapic_i8259.pin, entry); }
@@ -1427,8 +1421,8 @@ static void __init setup_ioapic_ids_from }/* -* We need to adjust the IRQ routing table -* if the ID changed. +* We need to adjust the IRQ routing table if the ID +* changed. */ if (old_id !=mpc_ioapic_id (ioapic_idx))for (i =0 ; i < mp_irq_entries; i++)
@@ -1437,8 +1431,8 @@ static void __init setup_ioapic_ids_from = mpc_ioapic_id(ioapic_idx);/* -* Update the ID register according to the right value -* from the MPC table if they are different. +* Update the ID register according to the right value from +* the MPC table if they are different. */ if (mpc_ioapic_id (ioapic_idx) == reg_00.bits.ID)continue ;
@@ -1562,21 +1556,17 @@ static int __init timer_irq_works(void)* so we 'resend' these IRQs via IPIs, to the same CPU. It's much * better to do it this way as thus we do not have to be aware of * 'pending' interrupts in the IRQ path, except at this point. -*/ -/* -* Edge triggered needs to resend any interrupt -* that was delayed but this is now handled in the device -* independent code. -*/ - -/* -* Starting up a edge-triggered IO-APIC interrupt is -* nasty - we need to make sure that we get the edge. -* If it is already asserted for some reason, we need -* return 1 to indicate that is was pending. * -* This is not complete - we should be able to fake -* an edge even if it isn't on the 8259A... +* +* Edge triggered needs to resend any interrupt that was delayed but this +* is now handled in the device independent code. +* +* Starting up a edge-triggered IO-APIC interrupt is nasty - we need to +* make sure that we get the edge. If it is already asserted for some +* reason, we need return 1 to indicate that is was pending. +* +* This is not complete - we should be able to fake an edge even if it +* isn't on the 8259A... */ static unsigned int startup_ioapic_irq (struct irq_data *data) {
@@ -1627,7 +1617,8 @@ static inline bool ioapic_prepare_move(sstatic inline void ioapic_finish_move (struct irq_data *data,bool moveit) {if (unlikely (moveit)) { -/* Only migrate the irq if the ack has been received. +/* +* Only migrate the irq if the ack has been received. * * On rare occasions the broadcast level triggered ack gets * delayed going to ioapics, and if we reprogram the
@@ -1904,14 +1895,13 @@ static inline void init_IO_APIC_traps(vo cfg =irq_cfg (irq);if (IO_APIC_IRQ (irq) && cfg && !cfg->vector) {/* -* Hmm.. We don't have an entry for this, -* so default to an old-fashioned 8259 -* interrupt if we can.. +* Hmm.. We don't have an entry for this, so +* default to an old-fashioned 8259 interrupt if we +* can. Otherwise set the dummy interrupt chip. */ if (irq <nr_legacy_irqs ()) legacy_pic->make_irq (irq);else -/* Strange. Oh, well.. */ irq_set_chip (irq, &no_irq_chip); } }
@@ -2307,9 +2297,7 @@ void __init setup_IO_APIC(void)for_each_ioapic (ioapic)BUG_ON (mp_irqdomain_create (ioapic)); -/* -* Set up IO-APIC IRQ routing. -*/ +/* Set up IO-APIC IRQ routing. */ x86_init.mpparse.setup_ioapic_ids ();sync_Arb_IDs ();
[tip: x86/apic] x86/ioapic: Cleanup comments
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: 75d449402b125648bf048309c9d22b39262d6fba Gitweb: https://git.kernel.org/tip/75d449402b125648bf048309c9d22b39262d6fba Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:48 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:28 +02:00
x86/ioapic: Cleanup comments
Use proper comment styles and shrink comments to their scope where applicable.
--- arch/x86/kernel/apic/io_apic.c | 86 ++++++++++++++------------------- 1 file changed, 37 insertions(+), 49 deletions(-)
arch/x86/kernel/apic/io_apic.c +37 -49
@@ -384,12 +384,12 @@ static void io_apic_modify_irq(struct mp_chip_data *data, bool masked, } } +/* +* Synchronize the IO-APIC and the CPU by doing a dummy read from the +* IO-APIC +*/ static void io_apic_sync (struct irq_pin_list *entry) { -/* -* Synchronize the IO-APIC and the CPU by doing -* a dummy read from the IO-APIC -*/ struct io_apic __iomem *io_apic; io_apic =io_apic_base (entry->apic);
@@ -442,17 +442,13 @@ static void __eoi_ioapic_pin(int apic, int pin, int vector) entry = entry1 =__ioapic_read_entry (apic, pin); -/* -* Mask the entry and change the trigger mode to edge. -*/ +/* Mask the entry and change the trigger mode to edge. */ entry1.masked = true; entry1.is_level = false;__ioapic_write_entry (apic, pin, entry1); -/* -* Restore the previous level triggered entry. -*/ +/* Restore the previous level triggered entry. */ __ioapic_write_entry (apic, pin, entry); } }
@@ -1012,16 +1008,12 @@ static int pin_2_irq(int idx, int ioapic, int pin, unsigned int flags) {u32 gsi =mp_pin_to_gsi (ioapic, pin); -/* -* Debugging check, we are in big trouble if this message pops up! -*/ +/* Debugging check, we are in big trouble if this message pops up! */ if (mp_irqs[idx].dstirq != pin)pr_err ("broken BIOS or MPTABLE parser, ayiee!!\n" );#ifdef CONFIG_X86_32 -/* -* PCI IRQ command line redirection. Yes, limits are hardcoded. -*/ +/* PCI IRQ command line redirection. Yes, limits are hardcoded. */ if ((pin >=16 ) && (pin <=23 )) {if (pirq_entries[pin -16 ] !=-1 ) {if (!pirq_entries[pin -16 ]) {
@@ -1296,8 +1288,9 @@ void __init enable_IO_APIC(void)/* See if any of the pins is in ExtINT mode */ struct IO_APIC_route_entry entry =ioapic_read_entry (apic, pin); -/* If the interrupt line is enabled and in ExtInt mode -* I have found the pin where the i8259 is connected. +/* +* If the interrupt line is enabled and in ExtInt mode I +* have found the pin where the i8259 is connected. */ if (!entry.masked && entry.delivery_mode ==APIC_DELIVERY_MODE_EXTINT ) {
@@ -1307,8 +1300,11 @@ void __init enable_IO_APIC(void) } } found_i8259: -/* Look to see what if the MP table has reported the ExtINT */ -/* If we could not find the appropriate pin by looking at the ioapic + +/* +* Look to see what if the MP table has reported the ExtINT +* +* If we could not find the appropriate pin by looking at the ioapic * the i8259 probably is not connected the ioapic but give the * mptable a chance anyway. */
@@ -1348,9 +1344,7 @@ void native_restore_boot_irq_mode(void) entry.destid_0_7 = apic_id &0xFF ; entry.virt_destid_8_14 = apic_id >>8 ; -/* -* Add it to the IO-APIC irq-routing table: -*/ +/* Add it to the IO-APIC irq-routing table */ ioapic_write_entry (ioapic_i8259.apic, ioapic_i8259.pin, entry); }
@@ -1427,8 +1421,8 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void) }/* -* We need to adjust the IRQ routing table -* if the ID changed. +* We need to adjust the IRQ routing table if the ID +* changed. */ if (old_id !=mpc_ioapic_id (ioapic_idx))for (i =0 ; i < mp_irq_entries; i++)
@@ -1437,8 +1431,8 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void) = mpc_ioapic_id(ioapic_idx);/* -* Update the ID register according to the right value -* from the MPC table if they are different. +* Update the ID register according to the right value from +* the MPC table if they are different. */ if (mpc_ioapic_id (ioapic_idx) == reg_00.bits.ID)continue ;
@@ -1562,21 +1556,17 @@ static int __init timer_irq_works(void)* so we 'resend' these IRQs via IPIs, to the same CPU. It's much * better to do it this way as thus we do not have to be aware of * 'pending' interrupts in the IRQ path, except at this point. -*/ -/* -* Edge triggered needs to resend any interrupt -* that was delayed but this is now handled in the device -* independent code. -*/ - -/* -* Starting up a edge-triggered IO-APIC interrupt is -* nasty - we need to make sure that we get the edge. -* If it is already asserted for some reason, we need -* return 1 to indicate that is was pending. * -* This is not complete - we should be able to fake -* an edge even if it isn't on the 8259A... +* +* Edge triggered needs to resend any interrupt that was delayed but this +* is now handled in the device independent code. +* +* Starting up a edge-triggered IO-APIC interrupt is nasty - we need to +* make sure that we get the edge. If it is already asserted for some +* reason, we need return 1 to indicate that is was pending. +* +* This is not complete - we should be able to fake an edge even if it +* isn't on the 8259A... */ static unsigned int startup_ioapic_irq (struct irq_data *data) {
@@ -1627,7 +1617,8 @@ static inline bool ioapic_prepare_move(struct irq_data *data)static inline void ioapic_finish_move (struct irq_data *data,bool moveit) {if (unlikely (moveit)) { -/* Only migrate the irq if the ack has been received. +/* +* Only migrate the irq if the ack has been received. * * On rare occasions the broadcast level triggered ack gets * delayed going to ioapics, and if we reprogram the
@@ -1904,14 +1895,13 @@ static inline void init_IO_APIC_traps(void) cfg =irq_cfg (irq);if (IO_APIC_IRQ (irq) && cfg && !cfg->vector) {/* -* Hmm.. We don't have an entry for this, -* so default to an old-fashioned 8259 -* interrupt if we can.. +* Hmm.. We don't have an entry for this, so +* default to an old-fashioned 8259 interrupt if we +* can. Otherwise set the dummy interrupt chip. */ if (irq <nr_legacy_irqs ()) legacy_pic->make_irq (irq);else -/* Strange. Oh, well.. */ irq_set_chip (irq, &no_irq_chip); } }
@@ -2307,9 +2297,7 @@ void __init setup_IO_APIC(void)for_each_ioapic (ioapic)BUG_ON (mp_irqdomain_create (ioapic)); -/* -* Set up IO-APIC IRQ routing. -*/ +/* Set up IO-APIC IRQ routing. */ x86_init.mpparse.setup_ioapic_ids ();sync_Arb_IDs ();
PATCH 13/15 x86/ioapic: Cleanup bracket usage
In reply to Thomas GleixnerAdd brackets around if/for constructs as required by coding style or remove pointless line breaks to make it true single line statements which do not require brackets.
--- arch/x86/kernel/apic/io_apic.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-)
arch/x86/kernel/apic/io_apic.c +18 -16
@@ -362,12 +362,13 @@ static void __remove_pin_from_irq(struct {struct irq_pin_list *tmp, *entry; -list_for_each_entry_safe (entry, tmp, &data->irq_2_pin, list) +list_for_each_entry_safe (entry, tmp, &data->irq_2_pin, list) {if (entry->apic == apic && entry->pin == pin) {list_del (&entry->list);kfree (entry);return ; } + } } static void io_apic_modify_irq(struct mp_chip_data *data, bool masked,
@@ -562,8 +563,7 @@ int save_ioapic_entries(void) }for_each_pin (apic, pin) - ioapics[apic].saved_registers[pin] = -ioapic_read_entry (apic, pin); + ioapics[apic].saved_registers[pin] =ioapic_read_entry (apic, pin); }return err;
@@ -604,8 +604,7 @@ int restore_ioapic_entries(void)continue ;for_each_pin (apic, pin) -ioapic_write_entry (apic, pin, - ioapics[apic].saved_registers[pin]); +ioapic_write_entry (apic, pin, ioapics[apic].saved_registers[pin]); }return 0 ; }
@@ -617,12 +616,13 @@ static int find_irq_entry(int ioapic_idx {int i; -for (i =0 ; i < mp_irq_entries; i++) +for (i =0 ; i < mp_irq_entries; i++) {if (mp_irqs[i].irqtype == type && (mp_irqs[i].dstapic ==mpc_ioapic_id (ioapic_idx) || mp_irqs[i].dstapic ==MP_APIC_ALL ) && mp_irqs[i].dstirq == pin)return i; + }return -1 ; }
@@ -662,9 +662,10 @@ static int __init find_isa_irq_apic(intif (i < mp_irq_entries) {int ioapic_idx; -for_each_ioapic (ioapic_idx) +for_each_ioapic (ioapic_idx) {if (mpc_ioapic_id (ioapic_idx) == mp_irqs[i].dstapic)return ioapic_idx; + } }return -1 ;
@@ -1424,11 +1425,12 @@ static void __init setup_ioapic_ids_from* We need to adjust the IRQ routing table if the ID * changed. */ -if (old_id !=mpc_ioapic_id (ioapic_idx)) -for (i =0 ; i < mp_irq_entries; i++) +if (old_id !=mpc_ioapic_id (ioapic_idx)) { +for (i =0 ; i < mp_irq_entries; i++) {if (mp_irqs[i].dstapic == old_id) - mp_irqs[i].dstapic - =mpc_ioapic_id (ioapic_idx); + mp_irqs[i].dstapic =mpc_ioapic_id (ioapic_idx); + } + }/* * Update the ID register according to the right value from
@@ -2666,12 +2668,10 @@ static int bad_ioapic_register(int idx)static int find_free_ioapic_entry (void ) { -int idx; - -for (idx =0 ; idx <MAX_IO_APICS ; idx++) +for (int idx =0 ; idx <MAX_IO_APICS ; idx++) {if (ioapics[idx].nr_registers ==0 )return idx; - + }return MAX_IO_APICS ; }
@@ -2780,11 +2780,13 @@ int mp_unregister_ioapic(u32 gsi_base)int ioapic, pin;int found =0 ; -for_each_ioapic (ioapic) +for_each_ioapic (ioapic) {if (ioapics[ioapic].gsi_config.gsi_base == gsi_base) { found =1 ;break ; } + } +if (!found) {pr_warn ("can't find IOAPIC for GSI %d\n" , gsi_base);return -ENODEV ;
[tip: x86/apic] x86/ioapic: Cleanup bracket usage
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: 4bcfdf76d7d1976b035ca75776bc8d266a09d6c3 Gitweb: https://git.kernel.org/tip/4bcfdf76d7d1976b035ca75776bc8d266a09d6c3 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:49 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:29 +02:00
x86/ioapic: Cleanup bracket usage
Add brackets around if/for constructs as required by coding style or remove pointless line breaks to make it true single line statements which do not require brackets.
--- arch/x86/kernel/apic/io_apic.c | 34 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-)
arch/x86/kernel/apic/io_apic.c +18 -16
@@ -362,12 +362,13 @@ static void __remove_pin_from_irq(struct mp_chip_data *data, int apic, int pin) {struct irq_pin_list *tmp, *entry; -list_for_each_entry_safe (entry, tmp, &data->irq_2_pin, list) +list_for_each_entry_safe (entry, tmp, &data->irq_2_pin, list) {if (entry->apic == apic && entry->pin == pin) {list_del (&entry->list);kfree (entry);return ; } + } } static void io_apic_modify_irq(struct mp_chip_data *data, bool masked,
@@ -562,8 +563,7 @@ int save_ioapic_entries(void) }for_each_pin (apic, pin) - ioapics[apic].saved_registers[pin] = -ioapic_read_entry (apic, pin); + ioapics[apic].saved_registers[pin] =ioapic_read_entry (apic, pin); }return err;
@@ -604,8 +604,7 @@ int restore_ioapic_entries(void)continue ;for_each_pin (apic, pin) -ioapic_write_entry (apic, pin, - ioapics[apic].saved_registers[pin]); +ioapic_write_entry (apic, pin, ioapics[apic].saved_registers[pin]); }return 0 ; }
@@ -617,12 +616,13 @@ static int find_irq_entry(int ioapic_idx, int pin, int type) {int i; -for (i =0 ; i < mp_irq_entries; i++) +for (i =0 ; i < mp_irq_entries; i++) {if (mp_irqs[i].irqtype == type && (mp_irqs[i].dstapic ==mpc_ioapic_id (ioapic_idx) || mp_irqs[i].dstapic ==MP_APIC_ALL ) && mp_irqs[i].dstirq == pin)return i; + }return -1 ; }
@@ -662,9 +662,10 @@ static int __init find_isa_irq_apic(int irq, int type)if (i < mp_irq_entries) {int ioapic_idx; -for_each_ioapic (ioapic_idx) +for_each_ioapic (ioapic_idx) {if (mpc_ioapic_id (ioapic_idx) == mp_irqs[i].dstapic)return ioapic_idx; + } }return -1 ;
@@ -1424,11 +1425,12 @@ static void __init setup_ioapic_ids_from_mpc_nocheck(void)* We need to adjust the IRQ routing table if the ID * changed. */ -if (old_id !=mpc_ioapic_id (ioapic_idx)) -for (i =0 ; i < mp_irq_entries; i++) +if (old_id !=mpc_ioapic_id (ioapic_idx)) { +for (i =0 ; i < mp_irq_entries; i++) {if (mp_irqs[i].dstapic == old_id) - mp_irqs[i].dstapic - =mpc_ioapic_id (ioapic_idx); + mp_irqs[i].dstapic =mpc_ioapic_id (ioapic_idx); + } + }/* * Update the ID register according to the right value from
@@ -2666,12 +2668,10 @@ static int bad_ioapic_register(int idx)static int find_free_ioapic_entry (void ) { -int idx; - -for (idx =0 ; idx <MAX_IO_APICS ; idx++) +for (int idx =0 ; idx <MAX_IO_APICS ; idx++) {if (ioapics[idx].nr_registers ==0 )return idx; - + }return MAX_IO_APICS ; }
@@ -2780,11 +2780,13 @@ int mp_unregister_ioapic(u32 gsi_base)int ioapic, pin;int found =0 ; -for_each_ioapic (ioapic) +for_each_ioapic (ioapic) {if (ioapics[ioapic].gsi_config.gsi_base == gsi_base) { found =1 ;break ; } + } +if (!found) {pr_warn ("can't find IOAPIC for GSI %d\n" , gsi_base);return -ENODEV ;
PATCH 14/15 x86/ioapic: Cleanup line breaks
In reply to Thomas Gleixner80 character limit is history.
--- arch/x86/kernel/apic/io_apic.c | 55 +++++++++++++---------------------------- 1 file changed, 18 insertions(+), 37 deletions(-)
arch/x86/kernel/apic/io_apic.c +18 -37
@@ -637,10 +637,8 @@ static int __init find_isa_irq_pin(int ifor (i =0 ; i < mp_irq_entries; i++) {int lbus = mp_irqs[i].srcbus; -if (test_bit (lbus, mp_bus_not_pci) && - (mp_irqs[i].irqtype == type) && +if (test_bit (lbus, mp_bus_not_pci) && (mp_irqs[i].irqtype == type) && (mp_irqs[i].srcbusirq == irq)) -return mp_irqs[i].dstirq; }return -1 ;
@@ -653,8 +651,7 @@ static int __init find_isa_irq_apic(intfor (i =0 ; i < mp_irq_entries; i++) {int lbus = mp_irqs[i].srcbus; -if (test_bit (lbus, mp_bus_not_pci) && - (mp_irqs[i].irqtype == type) && +if (test_bit (lbus, mp_bus_not_pci) && (mp_irqs[i].irqtype == type) && (mp_irqs[i].srcbusirq == irq))break ; }
@@ -907,8 +904,7 @@ static int alloc_irq_from_domain(structreturn -1 ; } -return __irq_domain_alloc_irqs (domain, irq,1 , -ioapic_alloc_attr_node (info), +return __irq_domain_alloc_irqs (domain, irq,1 ,ioapic_alloc_attr_node (info), info, legacy,NULL ); }
@@ -922,13 +918,12 @@ static int alloc_irq_from_domain(struct* PIRQs instead of reprogramming the interrupt routing logic. Thus there may be * multiple pins sharing the same legacy IRQ number when ACPI is disabled. */ -static int alloc_isa_irq_from_domain (struct irq_domain *domain, -int irq,int ioapic,int pin, +static int alloc_isa_irq_from_domain (struct irq_domain *domain,int irq,int ioapic,int pin,struct irq_alloc_info *info) { -struct mp_chip_data *data;struct irq_data *irq_data =irq_get_irq_data (irq);int node =ioapic_alloc_attr_node (info); +struct mp_chip_data *data;/* * Legacy ISA IRQ has already been allocated, just add pin to
@@ -942,8 +937,7 @@ static int alloc_isa_irq_from_domain(strreturn -ENOMEM ; }else { info->flags |=X86_IRQ_ALLOC_LEGACY ; - irq =__irq_domain_alloc_irqs (domain, irq,1 , node, info, true, -NULL ); + irq =__irq_domain_alloc_irqs (domain, irq,1 , node, info, true,NULL );if (irq >=0 ) { irq_data =irq_domain_get_irq_data (domain, irq); data = irq_data->chip_data;
@@ -1121,8 +1115,7 @@ int IO_APIC_get_PCI_irq_vector(int bus,return -1 ; out: -return pin_2_irq (best_idx, best_ioapic, mp_irqs[best_idx].dstirq, -IOAPIC_MAP_ALLOC ); +return pin_2_irq (best_idx, best_ioapic, mp_irqs[best_idx].dstirq,IOAPIC_MAP_ALLOC ); }EXPORT_SYMBOL (IO_APIC_get_PCI_irq_vector);
@@ -1293,14 +1286,12 @@ void __init enable_IO_APIC(void)* If the interrupt line is enabled and in ExtInt mode I * have found the pin where the i8259 is connected. */ -if (!entry.masked && - entry.delivery_mode ==APIC_DELIVERY_MODE_EXTINT ) { +if (!entry.masked && entry.delivery_mode ==APIC_DELIVERY_MODE_EXTINT ) { ioapic_i8259.apic = apic; ioapic_i8259.pin = pin; - goto found_i8259; +break ; } } - found_i8259:/* * Look to see what if the MP table has reported the ExtINT
@@ -1496,8 +1487,7 @@ static void __init delay_with_tsc(void)do {rep_nop (); now =rdtsc (); - }while ((now - start) <40000000000ULL /HZ && -time_before_eq (jiffies, end)); + }while ((now - start) <40000000000ULL /HZ &&time_before_eq (jiffies, end)); }static void __init delay_without_tsc (void )
@@ -1912,20 +1902,17 @@ static inline void init_IO_APIC_traps(vo/* * The local APIC irq-chip implementation: */ -static void mask_lapic_irq (struct irq_data *data) { -unsigned long v; +unsigned long v =apic_read (APIC_LVT0 ); - v =apic_read (APIC_LVT0 );apic_write (APIC_LVT0 , v |APIC_LVT_MASKED ); }static void unmask_lapic_irq (struct irq_data *data) { -unsigned long v; +unsigned long v =apic_read (APIC_LVT0 ); - v =apic_read (APIC_LVT0 );apic_write (APIC_LVT0 , v & ~APIC_LVT_MASKED ); }
@@ -1944,8 +1931,7 @@ static struct irq_chip lapic_chip __readstatic void lapic_register_intr (int irq) {irq_clear_status_flags (irq,IRQ_LEVEL ); -irq_set_chip_and_handler_name (irq, &lapic_chip, handle_edge_irq, -"edge" ); +irq_set_chip_and_handler_name (irq, &lapic_chip, handle_edge_irq,"edge" ); }/*
@@ -2265,10 +2251,8 @@ static int mp_irqdomain_create(int ioapireturn -ENOMEM ; } -if (cfg->type ==IOAPIC_DOMAIN_LEGACY || - cfg->type ==IOAPIC_DOMAIN_STRICT ) - ioapic_dynirq_base =max (ioapic_dynirq_base, - gsi_cfg->gsi_end +1 ); +if (cfg->type ==IOAPIC_DOMAIN_LEGACY || cfg->type ==IOAPIC_DOMAIN_STRICT ) + ioapic_dynirq_base =max (ioapic_dynirq_base, gsi_cfg->gsi_end +1 );return 0 ; }
@@ -2682,8 +2666,7 @@ static int find_free_ioapic_entry(void)* @gsi_base: base of GSI associated with the IOAPIC * @cfg: configuration information for the IOAPIC */ -int mp_register_ioapic (int id,u32 address,u32 gsi_base, -struct ioapic_domain_cfg *cfg) +int mp_register_ioapic (int id,u32 address,u32 gsi_base,struct ioapic_domain_cfg *cfg) {bool hotplug = !!ioapic_initialized;struct mp_ioapic_gsi *gsi_cfg;
@@ -2835,8 +2818,7 @@ static void mp_irqdomain_get_attr(u32 gsif (info && info->ioapic.valid) { data->is_level = info->ioapic.is_level; data->active_low = info->ioapic.active_low; - }else if (__acpi_get_override_irq (gsi, &data->is_level, - &data->active_low) <0 ) { + }else if (__acpi_get_override_irq (gsi, &data->is_level, &data->active_low) <0 ) {/* PCI interrupts are always active low level triggered. */ data->is_level = true; data->active_low = true;
@@ -2956,8 +2938,7 @@ void mp_irqdomain_deactivate(struct irq_ struct irq_data *irq_data) {/* It won't be called for IRQ with multiple IOAPIC pins associated */ -ioapic_mask_entry (mp_irqdomain_ioapic_idx (domain), - (int )irq_data->hwirq); +ioapic_mask_entry (mp_irqdomain_ioapic_idx (domain), (int )irq_data->hwirq); }int mp_irqdomain_ioapic_idx (struct irq_domain *domain)
[tip: x86/apic] x86/ioapic: Cleanup line breaks
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: 966e09b1862555267effa1db9032dc3dbc0cc588 Gitweb: https://git.kernel.org/tip/966e09b1862555267effa1db9032dc3dbc0cc588 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:50 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:29 +02:00
x86/ioapic: Cleanup line breaks
80 character limit is history.
--- arch/x86/kernel/apic/io_apic.c | 55 ++++++++++----------------------- 1 file changed, 18 insertions(+), 37 deletions(-)
arch/x86/kernel/apic/io_apic.c +18 -37
@@ -637,10 +637,8 @@ static int __init find_isa_irq_pin(int irq, int type)for (i =0 ; i < mp_irq_entries; i++) {int lbus = mp_irqs[i].srcbus; -if (test_bit (lbus, mp_bus_not_pci) && - (mp_irqs[i].irqtype == type) && +if (test_bit (lbus, mp_bus_not_pci) && (mp_irqs[i].irqtype == type) && (mp_irqs[i].srcbusirq == irq)) -return mp_irqs[i].dstirq; }return -1 ;
@@ -653,8 +651,7 @@ static int __init find_isa_irq_apic(int irq, int type)for (i =0 ; i < mp_irq_entries; i++) {int lbus = mp_irqs[i].srcbus; -if (test_bit (lbus, mp_bus_not_pci) && - (mp_irqs[i].irqtype == type) && +if (test_bit (lbus, mp_bus_not_pci) && (mp_irqs[i].irqtype == type) && (mp_irqs[i].srcbusirq == irq))break ; }
@@ -907,8 +904,7 @@ static int alloc_irq_from_domain(struct irq_domain *domain, int ioapic, u32 gsi,return -1 ; } -return __irq_domain_alloc_irqs (domain, irq,1 , -ioapic_alloc_attr_node (info), +return __irq_domain_alloc_irqs (domain, irq,1 ,ioapic_alloc_attr_node (info), info, legacy,NULL ); }
@@ -922,13 +918,12 @@ static int alloc_irq_from_domain(struct irq_domain *domain, int ioapic, u32 gsi,* PIRQs instead of reprogramming the interrupt routing logic. Thus there may be * multiple pins sharing the same legacy IRQ number when ACPI is disabled. */ -static int alloc_isa_irq_from_domain (struct irq_domain *domain, -int irq,int ioapic,int pin, +static int alloc_isa_irq_from_domain (struct irq_domain *domain,int irq,int ioapic,int pin,struct irq_alloc_info *info) { -struct mp_chip_data *data;struct irq_data *irq_data =irq_get_irq_data (irq);int node =ioapic_alloc_attr_node (info); +struct mp_chip_data *data;/* * Legacy ISA IRQ has already been allocated, just add pin to
@@ -942,8 +937,7 @@ static int alloc_isa_irq_from_domain(struct irq_domain *domain,return -ENOMEM ; }else { info->flags |=X86_IRQ_ALLOC_LEGACY ; - irq =__irq_domain_alloc_irqs (domain, irq,1 , node, info, true, -NULL ); + irq =__irq_domain_alloc_irqs (domain, irq,1 , node, info, true,NULL );if (irq >=0 ) { irq_data =irq_domain_get_irq_data (domain, irq); data = irq_data->chip_data;
@@ -1121,8 +1115,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin)return -1 ; out: -return pin_2_irq (best_idx, best_ioapic, mp_irqs[best_idx].dstirq, -IOAPIC_MAP_ALLOC ); +return pin_2_irq (best_idx, best_ioapic, mp_irqs[best_idx].dstirq,IOAPIC_MAP_ALLOC ); }EXPORT_SYMBOL (IO_APIC_get_PCI_irq_vector);
@@ -1293,14 +1286,12 @@ void __init enable_IO_APIC(void)* If the interrupt line is enabled and in ExtInt mode I * have found the pin where the i8259 is connected. */ -if (!entry.masked && - entry.delivery_mode ==APIC_DELIVERY_MODE_EXTINT ) { +if (!entry.masked && entry.delivery_mode ==APIC_DELIVERY_MODE_EXTINT ) { ioapic_i8259.apic = apic; ioapic_i8259.pin = pin; - goto found_i8259; +break ; } } - found_i8259:/* * Look to see what if the MP table has reported the ExtINT
@@ -1496,8 +1487,7 @@ static void __init delay_with_tsc(void)do {rep_nop (); now =rdtsc (); - }while ((now - start) <40000000000ULL /HZ && -time_before_eq (jiffies, end)); + }while ((now - start) <40000000000ULL /HZ &&time_before_eq (jiffies, end)); }static void __init delay_without_tsc (void )
@@ -1912,20 +1902,17 @@ static inline void init_IO_APIC_traps(void)/* * The local APIC irq-chip implementation: */ -static void mask_lapic_irq (struct irq_data *data) { -unsigned long v; +unsigned long v =apic_read (APIC_LVT0 ); - v =apic_read (APIC_LVT0 );apic_write (APIC_LVT0 , v |APIC_LVT_MASKED ); }static void unmask_lapic_irq (struct irq_data *data) { -unsigned long v; +unsigned long v =apic_read (APIC_LVT0 ); - v =apic_read (APIC_LVT0 );apic_write (APIC_LVT0 , v & ~APIC_LVT_MASKED ); }
@@ -1944,8 +1931,7 @@ static struct irq_chip lapic_chip __read_mostly = {static void lapic_register_intr (int irq) {irq_clear_status_flags (irq,IRQ_LEVEL ); -irq_set_chip_and_handler_name (irq, &lapic_chip, handle_edge_irq, -"edge" ); +irq_set_chip_and_handler_name (irq, &lapic_chip, handle_edge_irq,"edge" ); }/*
@@ -2265,10 +2251,8 @@ static int mp_irqdomain_create(int ioapic)return -ENOMEM ; } -if (cfg->type ==IOAPIC_DOMAIN_LEGACY || - cfg->type ==IOAPIC_DOMAIN_STRICT ) - ioapic_dynirq_base =max (ioapic_dynirq_base, - gsi_cfg->gsi_end +1 ); +if (cfg->type ==IOAPIC_DOMAIN_LEGACY || cfg->type ==IOAPIC_DOMAIN_STRICT ) + ioapic_dynirq_base =max (ioapic_dynirq_base, gsi_cfg->gsi_end +1 );return 0 ; }
@@ -2682,8 +2666,7 @@ static int find_free_ioapic_entry(void)* @gsi_base: base of GSI associated with the IOAPIC * @cfg: configuration information for the IOAPIC */ -int mp_register_ioapic (int id,u32 address,u32 gsi_base, -struct ioapic_domain_cfg *cfg) +int mp_register_ioapic (int id,u32 address,u32 gsi_base,struct ioapic_domain_cfg *cfg) {bool hotplug = !!ioapic_initialized;struct mp_ioapic_gsi *gsi_cfg;
@@ -2835,8 +2818,7 @@ static void mp_irqdomain_get_attr(u32 gsi, struct mp_chip_data *data,if (info && info->ioapic.valid) { data->is_level = info->ioapic.is_level; data->active_low = info->ioapic.active_low; - }else if (__acpi_get_override_irq (gsi, &data->is_level, - &data->active_low) <0 ) { + }else if (__acpi_get_override_irq (gsi, &data->is_level, &data->active_low) <0 ) {/* PCI interrupts are always active low level triggered. */ data->is_level = true; data->active_low = true;
@@ -2956,8 +2938,7 @@ void mp_irqdomain_deactivate(struct irq_domain *domain, struct irq_data *irq_data) {/* It won't be called for IRQ with multiple IOAPIC pins associated */ -ioapic_mask_entry (mp_irqdomain_ioapic_idx (domain), - (int )irq_data->hwirq); +ioapic_mask_entry (mp_irqdomain_ioapic_idx (domain), (int )irq_data->hwirq); }int mp_irqdomain_ioapic_idx (struct irq_domain *domain)
PATCH 15/15 x86/ioapic: Cleanup remaining coding style issues
In reply to Thomas GleixnerAdd missing new lines and reorder variable definitions.
--- arch/x86/kernel/apic/io_apic.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
arch/x86/kernel/apic/io_apic.c +12 -11
@@ -264,12 +264,14 @@ static __attribute_const__ struct io_apistatic inline void io_apic_eoi (unsigned int apic,unsigned int vector) {struct io_apic __iomem *io_apic =io_apic_base (apic); +writel (vector, &io_apic->eoi); }unsigned int native_io_apic_read (unsigned int apic,unsigned int reg) {struct io_apic __iomem *io_apic =io_apic_base (apic); +writel (reg, &io_apic->index);return readl (&io_apic->data); }
@@ -880,9 +882,9 @@ static bool mp_check_pin_attr(int irq, sstatic int alloc_irq_from_domain (struct irq_domain *domain,int ioapic,u32 gsi,struct irq_alloc_info *info) { +int type = ioapics[ioapic].irqdomain_cfg.type;bool legacy = false;int irq =-1 ; -int type = ioapics[ioapic].irqdomain_cfg.type;switch (type) {case IOAPIC_DOMAIN_LEGACY :
@@ -951,11 +953,11 @@ static int alloc_isa_irq_from_domain(strstatic int mp_map_pin_to_irq (u32 gsi,int idx,int ioapic,int pin,unsigned int flags,struct irq_alloc_info *info) { -int irq; -bool legacy = false; +struct irq_domain *domain =mp_ioapic_irqdomain (ioapic);struct irq_alloc_info tmp;struct mp_chip_data *data; -struct irq_domain *domain =mp_ioapic_irqdomain (ioapic); +bool legacy = false; +int irq;if (!domain)return -ENOSYS ;
@@ -1269,8 +1271,7 @@ static struct { int pin, apic; } ioapic_void __init enable_IO_APIC (void ) { -int i8259_apic, i8259_pin; -int apic, pin; +int i8259_apic, i8259_pin, apic, pin;if (ioapic_is_disabled) nr_ioapics =0 ;
@@ -1943,9 +1944,9 @@ static void lapic_register_intr(int irq)*/ static inline void __init unlock_ExtINT_logic (void ) { -int apic, pin, i; -struct IO_APIC_route_entry entry0, entry1;unsigned char save_control, save_freq_select; +struct IO_APIC_route_entry entry0, entry1; +int apic, pin, i;u32 apic_id; pin =find_isa_irq_pin (8 , mp_INT);
@@ -2211,11 +2212,11 @@ static inline void __init check_timer(vostatic int mp_irqdomain_create (int ioapic) { -struct irq_domain *parent; +struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (ioapic);int hwirqs =mp_ioapic_pin_count (ioapic);struct ioapic *ip = &ioapics[ioapic];struct ioapic_domain_cfg *cfg = &ip->irqdomain_cfg; -struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (ioapic); +struct irq_domain *parent;struct fwnode_handle *fn;struct irq_fwspec fwspec;
@@ -2491,8 +2492,8 @@ static struct resource *ioapic_resourcesstatic struct resource *__init ioapic_setup_resources (void ) { -unsigned long n;struct resource *res; +unsigned long n;char *mem;int i;
[tip: x86/apic] x86/ioapic: Cleanup remaining coding style issues
The following commit has been merged into the x86/apic branch of tip:
The following commit has been merged into the x86/apic branch of tip:
Commit-ID: 62e303e346d7f829ff4f52c73176451c7f85f4bc Gitweb: https://git.kernel.org/tip/62e303e346d7f829ff4f52c73176451c7f85f4bc Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 02 Aug 2024 18:15:52 +02:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 07 Aug 2024 18:13:29 +02:00
x86/ioapic: Cleanup remaining coding style issues
Add missing new lines and reorder variable definitions.
--- arch/x86/kernel/apic/io_apic.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
arch/x86/kernel/apic/io_apic.c +12 -11
@@ -264,12 +264,14 @@ static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx)static inline void io_apic_eoi (unsigned int apic,unsigned int vector) {struct io_apic __iomem *io_apic =io_apic_base (apic); +writel (vector, &io_apic->eoi); }unsigned int native_io_apic_read (unsigned int apic,unsigned int reg) {struct io_apic __iomem *io_apic =io_apic_base (apic); +writel (reg, &io_apic->index);return readl (&io_apic->data); }
@@ -880,9 +882,9 @@ static bool mp_check_pin_attr(int irq, struct irq_alloc_info *info)static int alloc_irq_from_domain (struct irq_domain *domain,int ioapic,u32 gsi,struct irq_alloc_info *info) { +int type = ioapics[ioapic].irqdomain_cfg.type;bool legacy = false;int irq =-1 ; -int type = ioapics[ioapic].irqdomain_cfg.type;switch (type) {case IOAPIC_DOMAIN_LEGACY :
@@ -951,11 +953,11 @@ static int alloc_isa_irq_from_domain(struct irq_domain *domain, int irq, int ioastatic int mp_map_pin_to_irq (u32 gsi,int idx,int ioapic,int pin,unsigned int flags,struct irq_alloc_info *info) { -int irq; -bool legacy = false; +struct irq_domain *domain =mp_ioapic_irqdomain (ioapic);struct irq_alloc_info tmp;struct mp_chip_data *data; -struct irq_domain *domain =mp_ioapic_irqdomain (ioapic); +bool legacy = false; +int irq;if (!domain)return -ENOSYS ;
@@ -1269,8 +1271,7 @@ static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };void __init enable_IO_APIC (void ) { -int i8259_apic, i8259_pin; -int apic, pin; +int i8259_apic, i8259_pin, apic, pin;if (ioapic_is_disabled) nr_ioapics =0 ;
@@ -1943,9 +1944,9 @@ static void lapic_register_intr(int irq)*/ static inline void __init unlock_ExtINT_logic (void ) { -int apic, pin, i; -struct IO_APIC_route_entry entry0, entry1;unsigned char save_control, save_freq_select; +struct IO_APIC_route_entry entry0, entry1; +int apic, pin, i;u32 apic_id; pin =find_isa_irq_pin (8 , mp_INT);
@@ -2211,11 +2212,11 @@ out:static int mp_irqdomain_create (int ioapic) { -struct irq_domain *parent; +struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (ioapic);int hwirqs =mp_ioapic_pin_count (ioapic);struct ioapic *ip = &ioapics[ioapic];struct ioapic_domain_cfg *cfg = &ip->irqdomain_cfg; -struct mp_ioapic_gsi *gsi_cfg =mp_ioapic_gsi_routing (ioapic); +struct irq_domain *parent;struct fwnode_handle *fn;struct irq_fwspec fwspec;
@@ -2491,8 +2492,8 @@ static struct resource *ioapic_resources;static struct resource *__init ioapic_setup_resources (void ) { -unsigned long n;struct resource *res; +unsigned long n;char *mem;int i;
Hi Thomas,
Quoted 12 lines
From: Thomas Gleixner <[email protected]>
To: LKML <[email protected]>
Cc: [email protected], Breno Leitao <[email protected]>
Subject: [patch 00/15] x86/ioapic: Robustness fix and cleanupBreno reported a panic during testing with failslab in the IO-APIC code. This is a historical leftover and can be handled gracefully.
While looking at that I stumbled over quite some historical leftovers of debug printks, overly big comments for trivialities and a pile of coding style violations.
Quoted 7 lines
So after fixing the failslab problem I just went through and modernized the (IO)APIC code.
The series is also available from git:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.gitx86/apic
Tested this branch on an Intel Sandy Bridge server and an Ice Lake server. Both servers booted okay and worked well. No regressions were found. If the testing is sufficient, feel free to add:
Thanks!
-Qiuxu
Quoted 7 lines · Thomas Gleixner
Breno reported a panic during testing with failslab in the IO-APIC code. This is a historical leftover and can be handled gracefully.
While looking at that I stumbled over quite some historical leftovers of debug printks, overly big comments for trivialities and a pile of coding style violations.
Quoted 6 lines
So after fixing the failslab problem I just went through and modernized the (IO)APIC code.
The series is also available from git:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.gitx86/apic
I've tested these patches on top of linux-next tree (3608d6aca5e7 (" Merge branch 'dsa-en7581' into main")) and I do see panics anymore.