Skip to content

Commit 01b9d4e

Browse files
committed
iommu/vt-d: Use dev_iommu_priv_get/set()
Remove the use of dev->archdata.iommu and use the private per-device pointer provided by IOMMU core code instead. Signed-off-by: Joerg Roedel <[email protected]> Reviewed-by: Jerry Snitselaar <[email protected]> Reviewed-by: Lu Baolu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0f45b04 commit 01b9d4e

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

drivers/gpu/drm/i915/selftests/mock_gem_device.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <linux/pm_domain.h>
2626
#include <linux/pm_runtime.h>
27+
#include <linux/iommu.h>
2728

2829
#include <drm/drm_managed.h>
2930

@@ -118,6 +119,9 @@ struct drm_i915_private *mock_gem_device(void)
118119
{
119120
struct drm_i915_private *i915;
120121
struct pci_dev *pdev;
122+
#if IS_ENABLED(CONFIG_IOMMU_API) && defined(CONFIG_INTEL_IOMMU)
123+
struct dev_iommu iommu;
124+
#endif
121125
int err;
122126

123127
pdev = kzalloc(sizeof(*pdev), GFP_KERNEL);
@@ -136,8 +140,10 @@ struct drm_i915_private *mock_gem_device(void)
136140
dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
137141

138142
#if IS_ENABLED(CONFIG_IOMMU_API) && defined(CONFIG_INTEL_IOMMU)
139-
/* hack to disable iommu for the fake device; force identity mapping */
140-
pdev->dev.archdata.iommu = (void *)-1;
143+
/* HACK HACK HACK to disable iommu for the fake device; force identity mapping */
144+
memset(&iommu, 0, sizeof(iommu));
145+
iommu.priv = (void *)-1;
146+
pdev->dev.iommu = &iommu;
141147
#endif
142148

143149
pci_set_drvdata(pdev, i915);

drivers/iommu/intel/iommu.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ struct device_domain_info *get_domain_info(struct device *dev)
372372
if (!dev)
373373
return NULL;
374374

375-
info = dev->archdata.iommu;
375+
info = dev_iommu_priv_get(dev);
376376
if (unlikely(info == DUMMY_DEVICE_DOMAIN_INFO ||
377377
info == DEFER_DEVICE_DOMAIN_INFO))
378378
return NULL;
@@ -743,12 +743,12 @@ struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus,
743743

744744
static int iommu_dummy(struct device *dev)
745745
{
746-
return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
746+
return dev_iommu_priv_get(dev) == DUMMY_DEVICE_DOMAIN_INFO;
747747
}
748748

749749
static bool attach_deferred(struct device *dev)
750750
{
751-
return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO;
751+
return dev_iommu_priv_get(dev) == DEFER_DEVICE_DOMAIN_INFO;
752752
}
753753

754754
/**
@@ -2420,7 +2420,7 @@ static inline void unlink_domain_info(struct device_domain_info *info)
24202420
list_del(&info->link);
24212421
list_del(&info->global);
24222422
if (info->dev)
2423-
info->dev->archdata.iommu = NULL;
2423+
dev_iommu_priv_set(info->dev, NULL);
24242424
}
24252425

24262426
static void domain_remove_dev_info(struct dmar_domain *domain)
@@ -2453,7 +2453,7 @@ static void do_deferred_attach(struct device *dev)
24532453
{
24542454
struct iommu_domain *domain;
24552455

2456-
dev->archdata.iommu = NULL;
2456+
dev_iommu_priv_set(dev, NULL);
24572457
domain = iommu_get_domain_for_dev(dev);
24582458
if (domain)
24592459
intel_iommu_attach_device(domain, dev);
@@ -2599,7 +2599,7 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu,
25992599
list_add(&info->link, &domain->devices);
26002600
list_add(&info->global, &device_domain_list);
26012601
if (dev)
2602-
dev->archdata.iommu = info;
2602+
dev_iommu_priv_set(dev, info);
26032603
spin_unlock_irqrestore(&device_domain_lock, flags);
26042604

26052605
/* PASID table is mandatory for a PCI device in scalable mode. */
@@ -4004,7 +4004,7 @@ static void quirk_ioat_snb_local_iommu(struct pci_dev *pdev)
40044004
if (!drhd || drhd->reg_base_addr - vtbar != 0xa000) {
40054005
pr_warn_once(FW_BUG "BIOS assigned incorrect VT-d unit for Intel(R) QuickData Technology device\n");
40064006
add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);
4007-
pdev->dev.archdata.iommu = DUMMY_DEVICE_DOMAIN_INFO;
4007+
dev_iommu_priv_set(&pdev->dev, DUMMY_DEVICE_DOMAIN_INFO);
40084008
}
40094009
}
40104010
DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB, quirk_ioat_snb_local_iommu);
@@ -4043,7 +4043,7 @@ static void __init init_no_remapping_devices(void)
40434043
drhd->ignored = 1;
40444044
for_each_active_dev_scope(drhd->devices,
40454045
drhd->devices_cnt, i, dev)
4046-
dev->archdata.iommu = DUMMY_DEVICE_DOMAIN_INFO;
4046+
dev_iommu_priv_set(dev, DUMMY_DEVICE_DOMAIN_INFO);
40474047
}
40484048
}
40494049
}
@@ -5665,7 +5665,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
56655665
return ERR_PTR(-ENODEV);
56665666

56675667
if (translation_pre_enabled(iommu))
5668-
dev->archdata.iommu = DEFER_DEVICE_DOMAIN_INFO;
5668+
dev_iommu_priv_set(dev, DEFER_DEVICE_DOMAIN_INFO);
56695669

56705670
return &iommu->iommu;
56715671
}

0 commit comments

Comments
 (0)