Skip to content

Commit 4fda230

Browse files
Jon Derrickjoergroedel
authored andcommitted
iommu/vt-d: Allocate domain info for real DMA sub-devices
Sub-devices of a real DMA device might exist on a separate segment than the real DMA device and its IOMMU. These devices should still have a valid device_domain_info, but the current dma alias model won't allocate info for the subdevice. This patch adds a segment member to struct device_domain_info and uses the sub-device's BDF so that these sub-devices won't alias to other devices. Fixes: 2b0140c ("iommu/vt-d: Use pci_real_dma_dev() for mapping") Cc: [email protected] # v5.6+ Signed-off-by: Jon Derrick <[email protected]> Acked-by: Lu Baolu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 8038bdb commit 4fda230

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

drivers/iommu/intel-iommu.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,7 +2463,7 @@ dmar_search_domain_by_dev_info(int segment, int bus, int devfn)
24632463
struct device_domain_info *info;
24642464

24652465
list_for_each_entry(info, &device_domain_list, global)
2466-
if (info->iommu->segment == segment && info->bus == bus &&
2466+
if (info->segment == segment && info->bus == bus &&
24672467
info->devfn == devfn)
24682468
return info;
24692469

@@ -2520,8 +2520,18 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,
25202520
if (!info)
25212521
return NULL;
25222522

2523-
info->bus = bus;
2524-
info->devfn = devfn;
2523+
if (!dev_is_real_dma_subdevice(dev)) {
2524+
info->bus = bus;
2525+
info->devfn = devfn;
2526+
info->segment = iommu->segment;
2527+
} else {
2528+
struct pci_dev *pdev = to_pci_dev(dev);
2529+
2530+
info->bus = pdev->bus->number;
2531+
info->devfn = pdev->devfn;
2532+
info->segment = pci_domain_nr(pdev->bus);
2533+
}
2534+
25252535
info->ats_supported = info->pasid_supported = info->pri_supported = 0;
25262536
info->ats_enabled = info->pasid_enabled = info->pri_enabled = 0;
25272537
info->ats_qdep = 0;
@@ -2561,7 +2571,8 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,
25612571

25622572
if (!found) {
25632573
struct device_domain_info *info2;
2564-
info2 = dmar_search_domain_by_dev_info(iommu->segment, bus, devfn);
2574+
info2 = dmar_search_domain_by_dev_info(info->segment, info->bus,
2575+
info->devfn);
25652576
if (info2) {
25662577
found = info2->domain;
25672578
info2->dev = dev;

include/linux/intel-iommu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ struct device_domain_info {
609609
struct list_head auxiliary_domains; /* auxiliary domains
610610
* attached to this device
611611
*/
612+
u32 segment; /* PCI segment number */
612613
u8 bus; /* PCI bus number */
613614
u8 devfn; /* PCI devfn number */
614615
u16 pfsid; /* SRIOV physical function source ID */

0 commit comments

Comments
 (0)