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

x86/apic: Always provide irq_compose_msi_msg() method for vector domain

This shouldn't be dependent on PCI_MSI. HPET and I/O-APIC can deliver
interrupts through MSI without having any PCI in the system at all.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20201024213535.443185-10-dwmw2@infradead.org

authored by

David Woodhouse and committed by
Thomas Gleixner
f598181a 8c44963b

+41 -42
+3 -5
arch/x86/include/asm/apic.h
··· 520 520 #endif 521 521 522 522 struct msi_msg; 523 + struct irq_cfg; 523 524 524 - #ifdef CONFIG_PCI_MSI 525 - void x86_vector_msi_compose_msg(struct irq_data *data, struct msi_msg *msg); 526 - #else 527 - # define x86_vector_msi_compose_msg NULL 528 - #endif 525 + extern void __irq_msi_compose_msg(struct irq_cfg *cfg, struct msi_msg *msg, 526 + bool dmar); 529 527 530 528 extern void ioapic_zap_locks(void); 531 529
+32
arch/x86/kernel/apic/apic.c
··· 50 50 #include <asm/io_apic.h> 51 51 #include <asm/desc.h> 52 52 #include <asm/hpet.h> 53 + #include <asm/msidef.h> 53 54 #include <asm/mtrr.h> 54 55 #include <asm/time.h> 55 56 #include <asm/smp.h> ··· 2479 2478 int hard_smp_processor_id(void) 2480 2479 { 2481 2480 return read_apic_id(); 2481 + } 2482 + 2483 + void __irq_msi_compose_msg(struct irq_cfg *cfg, struct msi_msg *msg, 2484 + bool dmar) 2485 + { 2486 + msg->address_hi = MSI_ADDR_BASE_HI; 2487 + 2488 + msg->address_lo = 2489 + MSI_ADDR_BASE_LO | 2490 + (apic->dest_mode_logical ? 2491 + MSI_ADDR_DEST_MODE_LOGICAL : 2492 + MSI_ADDR_DEST_MODE_PHYSICAL) | 2493 + MSI_ADDR_REDIRECTION_CPU | 2494 + MSI_ADDR_DEST_ID(cfg->dest_apicid); 2495 + 2496 + msg->data = 2497 + MSI_DATA_TRIGGER_EDGE | 2498 + MSI_DATA_LEVEL_ASSERT | 2499 + MSI_DATA_DELIVERY_FIXED | 2500 + MSI_DATA_VECTOR(cfg->vector); 2501 + 2502 + /* 2503 + * Only the IOMMU itself can use the trick of putting destination 2504 + * APIC ID into the high bits of the address. Anything else would 2505 + * just be writing to memory if it tried that, and needs IR to 2506 + * address higher APIC IDs. 2507 + */ 2508 + if (dmar) 2509 + msg->address_hi |= MSI_ADDR_EXT_DEST_ID(cfg->dest_apicid); 2510 + else 2511 + WARN_ON_ONCE(MSI_ADDR_EXT_DEST_ID(cfg->dest_apicid)); 2482 2512 } 2483 2513 2484 2514 /*
-37
arch/x86/kernel/apic/msi.c
··· 15 15 #include <linux/hpet.h> 16 16 #include <linux/msi.h> 17 17 #include <asm/irqdomain.h> 18 - #include <asm/msidef.h> 19 18 #include <asm/hpet.h> 20 19 #include <asm/hw_irq.h> 21 20 #include <asm/apic.h> 22 21 #include <asm/irq_remapping.h> 23 22 24 23 struct irq_domain *x86_pci_msi_default_domain __ro_after_init; 25 - 26 - static void __irq_msi_compose_msg(struct irq_cfg *cfg, struct msi_msg *msg, 27 - bool dmar) 28 - { 29 - msg->address_hi = MSI_ADDR_BASE_HI; 30 - 31 - msg->address_lo = 32 - MSI_ADDR_BASE_LO | 33 - (apic->dest_mode_logical ? 34 - MSI_ADDR_DEST_MODE_LOGICAL : 35 - MSI_ADDR_DEST_MODE_PHYSICAL) | 36 - MSI_ADDR_REDIRECTION_CPU | 37 - MSI_ADDR_DEST_ID(cfg->dest_apicid); 38 - 39 - msg->data = 40 - MSI_DATA_TRIGGER_EDGE | 41 - MSI_DATA_LEVEL_ASSERT | 42 - MSI_DATA_DELIVERY_FIXED | 43 - MSI_DATA_VECTOR(cfg->vector); 44 - 45 - /* 46 - * Only the IOMMU itself can use the trick of putting destination 47 - * APIC ID into the high bits of the address. Anything else would 48 - * just be writing to memory if it tried that, and needs IR to 49 - * address higher APIC IDs. 50 - */ 51 - if (dmar) 52 - msg->address_hi |= MSI_ADDR_EXT_DEST_ID(cfg->dest_apicid); 53 - else 54 - WARN_ON_ONCE(MSI_ADDR_EXT_DEST_ID(cfg->dest_apicid)); 55 - } 56 - 57 - void x86_vector_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) 58 - { 59 - __irq_msi_compose_msg(irqd_cfg(data), msg, false); 60 - } 61 24 62 25 static void irq_msi_update_msg(struct irq_data *irqd, struct irq_cfg *cfg) 63 26 {
+6
arch/x86/kernel/apic/vector.c
··· 818 818 apic_ack_irq(irqd); 819 819 } 820 820 821 + static void x86_vector_msi_compose_msg(struct irq_data *data, 822 + struct msi_msg *msg) 823 + { 824 + __irq_msi_compose_msg(irqd_cfg(data), msg, false); 825 + } 826 + 821 827 static struct irq_chip lapic_controller = { 822 828 .name = "APIC", 823 829 .irq_ack = apic_ack_edge,