Skip to content

Commit 05a0542

Browse files
committed
iommu/amd: Store dev_data as device iommu private data
Do not use dev->archdata.iommu anymore and switch to using the private per-device pointer provided by the IOMMU core code. Signed-off-by: Joerg Roedel <[email protected]> Reviewed-by: Suravee Suthikulpanit <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 786dfe4 commit 05a0542

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,6 @@ static struct iommu_dev_data *find_dev_data(u16 devid)
279279
return dev_data;
280280
}
281281

282-
static struct iommu_dev_data *get_dev_data(struct device *dev)
283-
{
284-
return dev->archdata.iommu;
285-
}
286-
287282
/*
288283
* Find or create an IOMMU group for a acpihid device.
289284
*/
@@ -334,7 +329,7 @@ static bool pdev_pri_erratum(struct pci_dev *pdev, u32 erratum)
334329
{
335330
struct iommu_dev_data *dev_data;
336331

337-
dev_data = get_dev_data(&pdev->dev);
332+
dev_data = dev_iommu_priv_get(&pdev->dev);
338333

339334
return dev_data->errata & (1 << erratum) ? true : false;
340335
}
@@ -369,7 +364,7 @@ static int iommu_init_device(struct device *dev)
369364
struct iommu_dev_data *dev_data;
370365
int devid;
371366

372-
if (dev->archdata.iommu)
367+
if (dev_iommu_priv_get(dev))
373368
return 0;
374369

375370
devid = get_device_id(dev);
@@ -396,7 +391,7 @@ static int iommu_init_device(struct device *dev)
396391
dev_data->iommu_v2 = iommu->is_iommu_v2;
397392
}
398393

399-
dev->archdata.iommu = dev_data;
394+
dev_iommu_priv_set(dev, dev_data);
400395

401396
return 0;
402397
}
@@ -431,6 +426,8 @@ static void amd_iommu_uninit_device(struct device *dev)
431426
if (dev_data->domain)
432427
detach_device(dev);
433428

429+
dev_iommu_priv_set(dev, NULL);
430+
434431
/*
435432
* We keep dev_data around for unplugged devices and reuse it when the
436433
* device is re-plugged - not doing so would introduce a ton of races.
@@ -493,7 +490,7 @@ static void amd_iommu_report_page_fault(u16 devid, u16 domain_id,
493490
pdev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(devid),
494491
devid & 0xff);
495492
if (pdev)
496-
dev_data = get_dev_data(&pdev->dev);
493+
dev_data = dev_iommu_priv_get(&pdev->dev);
497494

498495
if (dev_data && __ratelimit(&dev_data->rs)) {
499496
pci_err(pdev, "Event logged [IO_PAGE_FAULT domain=0x%04x address=0x%llx flags=0x%04x]\n",
@@ -2033,7 +2030,7 @@ static int attach_device(struct device *dev,
20332030

20342031
spin_lock_irqsave(&domain->lock, flags);
20352032

2036-
dev_data = get_dev_data(dev);
2033+
dev_data = dev_iommu_priv_get(dev);
20372034

20382035
spin_lock(&dev_data->lock);
20392036

@@ -2097,7 +2094,7 @@ static void detach_device(struct device *dev)
20972094
struct iommu_dev_data *dev_data;
20982095
unsigned long flags;
20992096

2100-
dev_data = get_dev_data(dev);
2097+
dev_data = dev_iommu_priv_get(dev);
21012098
domain = dev_data->domain;
21022099

21032100
spin_lock_irqsave(&domain->lock, flags);
@@ -2146,7 +2143,7 @@ static struct iommu_device *amd_iommu_probe_device(struct device *dev)
21462143

21472144
iommu = amd_iommu_rlookup_table[devid];
21482145

2149-
if (get_dev_data(dev))
2146+
if (dev_iommu_priv_get(dev))
21502147
return &iommu->iommu;
21512148

21522149
ret = iommu_init_device(dev);
@@ -2435,7 +2432,7 @@ static void amd_iommu_domain_free(struct iommu_domain *dom)
24352432
static void amd_iommu_detach_device(struct iommu_domain *dom,
24362433
struct device *dev)
24372434
{
2438-
struct iommu_dev_data *dev_data = dev->archdata.iommu;
2435+
struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev);
24392436
struct amd_iommu *iommu;
24402437
int devid;
24412438

@@ -2473,7 +2470,7 @@ static int amd_iommu_attach_device(struct iommu_domain *dom,
24732470
if (!check_device(dev))
24742471
return -EINVAL;
24752472

2476-
dev_data = dev->archdata.iommu;
2473+
dev_data = dev_iommu_priv_get(dev);
24772474
dev_data->defer_attach = false;
24782475

24792476
iommu = amd_iommu_rlookup_table[dev_data->devid];
@@ -2632,7 +2629,7 @@ static void amd_iommu_get_resv_regions(struct device *dev,
26322629
bool amd_iommu_is_attach_deferred(struct iommu_domain *domain,
26332630
struct device *dev)
26342631
{
2635-
struct iommu_dev_data *dev_data = dev->archdata.iommu;
2632+
struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev);
26362633

26372634
return dev_data->defer_attach;
26382635
}
@@ -2659,7 +2656,7 @@ static int amd_iommu_def_domain_type(struct device *dev)
26592656
{
26602657
struct iommu_dev_data *dev_data;
26612658

2662-
dev_data = get_dev_data(dev);
2659+
dev_data = dev_iommu_priv_get(dev);
26632660
if (!dev_data)
26642661
return 0;
26652662

@@ -2992,7 +2989,7 @@ int amd_iommu_complete_ppr(struct pci_dev *pdev, int pasid,
29922989
struct amd_iommu *iommu;
29932990
struct iommu_cmd cmd;
29942991

2995-
dev_data = get_dev_data(&pdev->dev);
2992+
dev_data = dev_iommu_priv_get(&pdev->dev);
29962993
iommu = amd_iommu_rlookup_table[dev_data->devid];
29972994

29982995
build_complete_ppr(&cmd, dev_data->devid, pasid, status,
@@ -3005,16 +3002,19 @@ EXPORT_SYMBOL(amd_iommu_complete_ppr);
30053002
struct iommu_domain *amd_iommu_get_v2_domain(struct pci_dev *pdev)
30063003
{
30073004
struct protection_domain *pdomain;
3008-
struct iommu_domain *io_domain;
3005+
struct iommu_dev_data *dev_data;
30093006
struct device *dev = &pdev->dev;
3007+
struct iommu_domain *io_domain;
30103008

30113009
if (!check_device(dev))
30123010
return NULL;
30133011

3014-
pdomain = get_dev_data(dev)->domain;
3012+
dev_data = dev_iommu_priv_get(&pdev->dev);
3013+
pdomain = dev_data->domain;
30153014
io_domain = iommu_get_domain_for_dev(dev);
3016-
if (pdomain == NULL && get_dev_data(dev)->defer_attach) {
3017-
get_dev_data(dev)->defer_attach = false;
3015+
3016+
if (pdomain == NULL && dev_data->defer_attach) {
3017+
dev_data->defer_attach = false;
30183018
pdomain = to_pdomain(io_domain);
30193019
attach_device(dev, pdomain);
30203020
}
@@ -3040,7 +3040,7 @@ void amd_iommu_enable_device_erratum(struct pci_dev *pdev, u32 erratum)
30403040
if (!amd_iommu_v2_supported())
30413041
return;
30423042

3043-
dev_data = get_dev_data(&pdev->dev);
3043+
dev_data = dev_iommu_priv_get(&pdev->dev);
30443044
dev_data->errata |= (1 << erratum);
30453045
}
30463046
EXPORT_SYMBOL(amd_iommu_enable_device_erratum);

0 commit comments

Comments
 (0)