Skip to content

Commit 2619c62

Browse files
committed
Merge tag 'x86-irq-2026-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 irq updates from Thomas Gleixner: "Trivial cleanups for the posted MSI interrupt handling" * tag 'x86-irq-2026-02-09' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/irq_remapping: Sanitize posted_msi_supported() x86/irq: Cleanup posted MSI code
2 parents f1c538c + d441e38 commit 2619c62

3 files changed

Lines changed: 18 additions & 22 deletions

File tree

arch/x86/include/asm/irq_remapping.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ static inline struct irq_domain *arch_get_ir_parent_domain(void)
6767

6868
extern bool enable_posted_msi;
6969

70-
static inline bool posted_msi_supported(void)
70+
static inline bool posted_msi_enabled(void)
7171
{
72-
return enable_posted_msi && irq_remapping_cap(IRQ_POSTING_CAP);
72+
return IS_ENABLED(CONFIG_X86_POSTED_MSI) &&
73+
enable_posted_msi && irq_remapping_cap(IRQ_POSTING_CAP);
7374
}
7475

7576
#else /* CONFIG_IRQ_REMAP */

arch/x86/kernel/irq.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,9 @@ static DEFINE_PER_CPU_CACHE_HOT(bool, posted_msi_handler_active);
420420

421421
void intel_posted_msi_init(void)
422422
{
423-
u32 destination;
424-
u32 apic_id;
423+
u32 destination, apic_id;
425424

426425
this_cpu_write(posted_msi_pi_desc.nv, POSTED_MSI_NOTIFICATION_VECTOR);
427-
428426
/*
429427
* APIC destination ID is stored in bit 8:15 while in XAPIC mode.
430428
* VT-d spec. CH 9.11
@@ -468,8 +466,8 @@ static __always_inline bool handle_pending_pir(unsigned long *pir, struct pt_reg
468466
}
469467

470468
/*
471-
* Performance data shows that 3 is good enough to harvest 90+% of the benefit
472-
* on high IRQ rate workload.
469+
* Performance data shows that 3 is good enough to harvest 90+% of the
470+
* benefit on high interrupt rate workloads.
473471
*/
474472
#define MAX_POSTED_MSI_COALESCING_LOOP 3
475473

@@ -479,37 +477,34 @@ static __always_inline bool handle_pending_pir(unsigned long *pir, struct pt_reg
479477
*/
480478
DEFINE_IDTENTRY_SYSVEC(sysvec_posted_msi_notification)
481479
{
480+
struct pi_desc *pid = this_cpu_ptr(&posted_msi_pi_desc);
482481
struct pt_regs *old_regs = set_irq_regs(regs);
483-
struct pi_desc *pid;
484-
int i = 0;
485-
486-
pid = this_cpu_ptr(&posted_msi_pi_desc);
487482

488483
/* Mark the handler active for intel_ack_posted_msi_irq() */
489484
__this_cpu_write(posted_msi_handler_active, true);
490485
inc_irq_stat(posted_msi_notification_count);
491486
irq_enter();
492487

493488
/*
494-
* Max coalescing count includes the extra round of handle_pending_pir
495-
* after clearing the outstanding notification bit. Hence, at most
496-
* MAX_POSTED_MSI_COALESCING_LOOP - 1 loops are executed here.
489+
* Loop only MAX_POSTED_MSI_COALESCING_LOOP - 1 times here to take
490+
* the final handle_pending_pir() invocation after clearing the
491+
* outstanding notification bit into account.
497492
*/
498-
while (++i < MAX_POSTED_MSI_COALESCING_LOOP) {
493+
for (int i = 1; i < MAX_POSTED_MSI_COALESCING_LOOP; i++) {
499494
if (!handle_pending_pir(pid->pir, regs))
500495
break;
501496
}
502497

503498
/*
504-
* Clear outstanding notification bit to allow new IRQ notifications,
505-
* do this last to maximize the window of interrupt coalescing.
499+
* Clear the outstanding notification bit to rearm the notification
500+
* mechanism.
506501
*/
507502
pi_clear_on(pid);
508503

509504
/*
510-
* There could be a race of PI notification and the clearing of ON bit,
511-
* process PIR bits one last time such that handling the new interrupts
512-
* are not delayed until the next IRQ.
505+
* Clearing the ON bit can race with a notification. Process the
506+
* PIR bits one last time so that handling the new interrupts is
507+
* not delayed until the next notification happens.
513508
*/
514509
handle_pending_pir(pid->pir, regs);
515510

drivers/iommu/intel/irq_remapping.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ static void intel_irq_remapping_prepare_irte(struct intel_ir_data *data,
13681368
break;
13691369
case X86_IRQ_ALLOC_TYPE_PCI_MSI:
13701370
case X86_IRQ_ALLOC_TYPE_PCI_MSIX:
1371-
if (posted_msi_supported()) {
1371+
if (posted_msi_enabled()) {
13721372
prepare_irte_posted(irte);
13731373
data->irq_2_iommu.posted_msi = 1;
13741374
}
@@ -1460,7 +1460,7 @@ static int intel_irq_remapping_alloc(struct irq_domain *domain,
14601460

14611461
irq_data->hwirq = (index << 16) + i;
14621462
irq_data->chip_data = ird;
1463-
if (posted_msi_supported() &&
1463+
if (posted_msi_enabled() &&
14641464
((info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI) ||
14651465
(info->type == X86_IRQ_ALLOC_TYPE_PCI_MSIX)))
14661466
irq_data->chip = &intel_ir_chip_post_msi;

0 commit comments

Comments
 (0)