Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/irq: Set up per host CPU posted interrupt descriptors

To support posted MSIs, create a posted interrupt descriptor (PID) for each
host CPU. Later on, when setting up interrupt affinity, the IOMMU's
interrupt remapping table entry (IRTE) will point to the physical address
of the matching CPU's PID.

Each PID is initialized with the owner CPU's physical APICID as the
destination.

Originally-by: Thomas Gleixner <tglx@linutronix.de>
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-7-jacob.jun.pan@linux.intel.com

authored by

Jacob Pan and committed by
Thomas Gleixner
43650dcf f5a3562e

+35
+3
arch/x86/include/asm/hardirq.h
··· 48 48 49 49 DECLARE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat); 50 50 51 + #ifdef CONFIG_X86_POSTED_MSI 52 + DECLARE_PER_CPU_ALIGNED(struct pi_desc, posted_msi_pi_desc); 53 + #endif 51 54 #define __ARCH_IRQ_STAT 52 55 53 56 #define inc_irq_stat(member) this_cpu_inc(irq_stat.member)
+6
arch/x86/include/asm/posted_intr.h
··· 91 91 pi_desc->notifications &= ~BIT(POSTED_INTR_SN); 92 92 } 93 93 94 + #ifdef CONFIG_X86_POSTED_MSI 95 + extern void intel_posted_msi_init(void); 96 + #else 97 + static inline void intel_posted_msi_init(void) {}; 98 + #endif /* X86_POSTED_MSI */ 99 + 94 100 #endif /* _X86_POSTED_INTR_H */
+3
arch/x86/kernel/cpu/common.c
··· 68 68 #include <asm/traps.h> 69 69 #include <asm/sev.h> 70 70 #include <asm/tdx.h> 71 + #include <asm/posted_intr.h> 71 72 72 73 #include "cpu.h" 73 74 ··· 2228 2227 barrier(); 2229 2228 2230 2229 x2apic_setup(); 2230 + 2231 + intel_posted_msi_init(); 2231 2232 } 2232 2233 2233 2234 mmgrab(&init_mm);
+23
arch/x86/kernel/irq.c
··· 22 22 #include <asm/desc.h> 23 23 #include <asm/traps.h> 24 24 #include <asm/thermal.h> 25 + #include <asm/posted_intr.h> 26 + #include <asm/irq_remapping.h> 25 27 26 28 #define CREATE_TRACE_POINTS 27 29 #include <asm/trace/irq_vectors.h> ··· 336 334 } 337 335 #endif 338 336 337 + #ifdef CONFIG_X86_POSTED_MSI 338 + 339 + /* Posted Interrupt Descriptors for coalesced MSIs to be posted */ 340 + DEFINE_PER_CPU_ALIGNED(struct pi_desc, posted_msi_pi_desc); 341 + 342 + void intel_posted_msi_init(void) 343 + { 344 + u32 destination; 345 + u32 apic_id; 346 + 347 + this_cpu_write(posted_msi_pi_desc.nv, POSTED_MSI_NOTIFICATION_VECTOR); 348 + 349 + /* 350 + * APIC destination ID is stored in bit 8:15 while in XAPIC mode. 351 + * VT-d spec. CH 9.11 352 + */ 353 + apic_id = this_cpu_read(x86_cpu_to_apicid); 354 + destination = x2apic_enabled() ? apic_id : apic_id << 8; 355 + this_cpu_write(posted_msi_pi_desc.ndst, destination); 356 + } 357 + #endif /* X86_POSTED_MSI */ 339 358 340 359 #ifdef CONFIG_HOTPLUG_CPU 341 360 /* A cpu has been removed from cpu_online_mask. Reset irq affinities. */