Skip to content

Commit 85a8dfc

Browse files
committed
iommm/vt-d: Store irq domain in struct device
As a first step to make X86 utilize the direct MSI irq domain operations store the irq domain pointer in the device struct when a device is probed. This is done from dmar_pci_bus_add_dev() because it has to work even when DMA remapping is disabled. It only overrides the irqdomain of devices which are handled by a regular PCI/MSI irq domain which protects PCI devices behind special busses like VMD which have their own irq domain. No functional change. It just avoids the redirection through arch_*_msi_irqs() and allows the PCI/MSI core to directly invoke the irq domain alloc/free functions instead of having to look up the irq domain for every single MSI interupt. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Joerg Roedel <jroedel@suse.de> Link: https://lore.kernel.org/r/20200826112333.714566121@linutronix.de
1 parent 2e4386e commit 85a8dfc

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

drivers/iommu/intel/dmar.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ static int dmar_pci_bus_add_dev(struct dmar_pci_notify_info *info)
316316
if (ret < 0 && dmar_dev_scope_status == 0)
317317
dmar_dev_scope_status = ret;
318318

319+
if (ret >= 0)
320+
intel_irq_remap_add_device(info);
321+
319322
return ret;
320323
}
321324

drivers/iommu/intel/irq_remapping.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,22 @@ static int reenable_irq_remapping(int eim)
10921092
return -1;
10931093
}
10941094

1095+
/*
1096+
* Store the MSI remapping domain pointer in the device if enabled.
1097+
*
1098+
* This is called from dmar_pci_bus_add_dev() so it works even when DMA
1099+
* remapping is disabled. Only update the pointer if the device is not
1100+
* already handled by a non default PCI/MSI interrupt domain. This protects
1101+
* e.g. VMD devices.
1102+
*/
1103+
void intel_irq_remap_add_device(struct dmar_pci_notify_info *info)
1104+
{
1105+
if (!irq_remapping_enabled || pci_dev_has_special_msi_domain(info->dev))
1106+
return;
1107+
1108+
dev_set_msi_domain(&info->dev->dev, map_dev_to_ir(info->dev));
1109+
}
1110+
10951111
static void prepare_irte(struct irte *irte, int vector, unsigned int dest)
10961112
{
10971113
memset(irte, 0, sizeof(*irte));

include/linux/intel-iommu.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ struct q_inval {
425425
int free_cnt;
426426
};
427427

428+
struct dmar_pci_notify_info;
429+
428430
#ifdef CONFIG_IRQ_REMAP
429431
/* 1MB - maximum possible interrupt remapping table size */
430432
#define INTR_REMAP_PAGE_ORDER 8
@@ -439,6 +441,11 @@ struct ir_table {
439441
struct irte *base;
440442
unsigned long *bitmap;
441443
};
444+
445+
void intel_irq_remap_add_device(struct dmar_pci_notify_info *info);
446+
#else
447+
static inline void
448+
intel_irq_remap_add_device(struct dmar_pci_notify_info *info) { }
442449
#endif
443450

444451
struct iommu_flush {

0 commit comments

Comments
 (0)