Skip to content

Commit 2c681e6

Browse files
committed
x86/pci: Set default irq domain in pcibios_add_device()
Now that interrupt remapping sets the irqdomain pointer when a PCI device is added it's possible to store the default irq domain in the device struct in pcibios_add_device(). If the bus to which a device is connected has an irq domain associated then this domain is used otherwise the default domain (PCI/MSI native or XEN PCI/MSI) is used. Using the bus domain ensures that special MSI bus domains like VMD work. This makes XEN and the non-remapped native case work solely based on the irq domain pointer in struct device for PCI/MSI and allows to remove the arch fallback and make most of the x86_msi ops private to XEN in the next steps. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20200826112333.900423047@linutronix.de
1 parent 2b2c6aa commit 2c681e6

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

arch/x86/include/asm/irqdomain.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ extern int mp_irqdomain_ioapic_idx(struct irq_domain *domain);
5353
#ifdef CONFIG_PCI_MSI
5454
void x86_create_pci_msi_domain(void);
5555
struct irq_domain *native_create_pci_msi_domain(void);
56+
extern struct irq_domain *x86_pci_msi_default_domain;
5657
#else
5758
static inline void x86_create_pci_msi_domain(void) { }
5859
#define native_create_pci_msi_domain NULL
60+
#define x86_pci_msi_default_domain NULL
5961
#endif
6062

6163
#endif

arch/x86/kernel/apic/msi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <asm/apic.h>
2222
#include <asm/irq_remapping.h>
2323

24-
static struct irq_domain *x86_pci_msi_default_domain __ro_after_init;
24+
struct irq_domain *x86_pci_msi_default_domain __ro_after_init;
2525

2626
static void __irq_msi_compose_msg(struct irq_cfg *cfg, struct msi_msg *msg)
2727
{

arch/x86/pci/common.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <asm/smp.h>
2020
#include <asm/pci_x86.h>
2121
#include <asm/setup.h>
22+
#include <asm/irqdomain.h>
2223

2324
unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
2425
PCI_PROBE_MMCONF;
@@ -633,8 +634,9 @@ static void set_dev_domain_options(struct pci_dev *pdev)
633634

634635
int pcibios_add_device(struct pci_dev *dev)
635636
{
636-
struct setup_data *data;
637637
struct pci_setup_rom *rom;
638+
struct irq_domain *msidom;
639+
struct setup_data *data;
638640
u64 pa_data;
639641

640642
pa_data = boot_params.hdr.setup_data;
@@ -661,6 +663,20 @@ int pcibios_add_device(struct pci_dev *dev)
661663
memunmap(data);
662664
}
663665
set_dev_domain_options(dev);
666+
667+
/*
668+
* Setup the initial MSI domain of the device. If the underlying
669+
* bus has a PCI/MSI irqdomain associated use the bus domain,
670+
* otherwise set the default domain. This ensures that special irq
671+
* domains e.g. VMD are preserved. The default ensures initial
672+
* operation if irq remapping is not active. If irq remapping is
673+
* active it will overwrite the domain pointer when the device is
674+
* associated to a remapping domain.
675+
*/
676+
msidom = dev_get_msi_domain(&dev->bus->dev);
677+
if (!msidom)
678+
msidom = x86_pci_msi_default_domain;
679+
dev_set_msi_domain(&dev->dev, msidom);
664680
return 0;
665681
}
666682

0 commit comments

Comments
 (0)