Skip to content

Commit fef05a0

Browse files
Jacob PanKAGA-KOKO
authored andcommitted
x86/irq: Factor out common code for checking pending interrupts
Use a common function for checking pending interrupt vector in APIC IRR instead of duplicated open coding them. Additional checks for posted MSI vectors can then be contained in this function. Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20240423174114.526704-10-jacob.jun.pan@linux.intel.com
1 parent 1b03d82 commit fef05a0

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

arch/x86/include/asm/apic.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,17 @@ static inline bool lapic_vector_set_in_irr(unsigned int vector)
500500
return !!(irr & (1U << (vector % 32)));
501501
}
502502

503+
static inline bool is_vector_pending(unsigned int vector)
504+
{
505+
unsigned int irr;
506+
507+
irr = apic_read(APIC_IRR + (vector / 32 * 0x10));
508+
if (irr & (1 << (vector % 32)))
509+
return true;
510+
511+
return false;
512+
}
513+
503514
/*
504515
* Warm reset vector position:
505516
*/

arch/x86/kernel/apic/vector.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ static void __vector_cleanup(struct vector_cleanup *cl, bool check_irr)
965965
lockdep_assert_held(&vector_lock);
966966

967967
hlist_for_each_entry_safe(apicd, tmp, &cl->head, clist) {
968-
unsigned int irr, vector = apicd->prev_vector;
968+
unsigned int vector = apicd->prev_vector;
969969

970970
/*
971971
* Paranoia: Check if the vector that needs to be cleaned
@@ -979,8 +979,7 @@ static void __vector_cleanup(struct vector_cleanup *cl, bool check_irr)
979979
* fixup_irqs() was just called to scan IRR for set bits and
980980
* forward them to new destination CPUs via IPIs.
981981
*/
982-
irr = check_irr ? apic_read(APIC_IRR + (vector / 32 * 0x10)) : 0;
983-
if (irr & (1U << (vector % 32))) {
982+
if (check_irr && is_vector_pending(vector)) {
984983
pr_warn_once("Moved interrupt pending in old target APIC %u\n", apicd->irq);
985984
rearm = true;
986985
continue;

arch/x86/kernel/irq.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_posted_msi_notification)
484484
/* A cpu has been removed from cpu_online_mask. Reset irq affinities. */
485485
void fixup_irqs(void)
486486
{
487-
unsigned int irr, vector;
487+
unsigned int vector;
488488
struct irq_desc *desc;
489489
struct irq_data *data;
490490
struct irq_chip *chip;
@@ -511,8 +511,7 @@ void fixup_irqs(void)
511511
if (IS_ERR_OR_NULL(__this_cpu_read(vector_irq[vector])))
512512
continue;
513513

514-
irr = apic_read(APIC_IRR + (vector / 32 * 0x10));
515-
if (irr & (1 << (vector % 32))) {
514+
if (is_vector_pending(vector)) {
516515
desc = __this_cpu_read(vector_irq[vector]);
517516

518517
raw_spin_lock(&desc->lock);

0 commit comments

Comments
 (0)