Skip to content

Commit 4a73abb

Browse files
nicolincjoergroedel
authored andcommitted
iommu: Tidy domain for iommu_setup_dma_ops()
This function can only be called on the default_domain. Trivally pass it in. In all three existing cases, the default domain was just attached to the device. This avoids iommu_setup_dma_ops() calling iommu_get_domain_for_dev() that will be used by external callers. Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Tested-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent 5d5388b commit 4a73abb

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

drivers/iommu/dma-iommu.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,10 +2097,8 @@ void dma_iova_destroy(struct device *dev, struct dma_iova_state *state,
20972097
}
20982098
EXPORT_SYMBOL_GPL(dma_iova_destroy);
20992099

2100-
void iommu_setup_dma_ops(struct device *dev)
2100+
void iommu_setup_dma_ops(struct device *dev, struct iommu_domain *domain)
21012101
{
2102-
struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
2103-
21042102
if (dev_is_pci(dev))
21052103
dev->iommu->pci_32bit_workaround = !iommu_dma_forcedac;
21062104

drivers/iommu/dma-iommu.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#ifdef CONFIG_IOMMU_DMA
1111

12-
void iommu_setup_dma_ops(struct device *dev);
12+
void iommu_setup_dma_ops(struct device *dev, struct iommu_domain *domain);
1313

1414
int iommu_get_dma_cookie(struct iommu_domain *domain);
1515
void iommu_put_dma_cookie(struct iommu_domain *domain);
@@ -26,7 +26,8 @@ extern bool iommu_dma_forcedac;
2626

2727
#else /* CONFIG_IOMMU_DMA */
2828

29-
static inline void iommu_setup_dma_ops(struct device *dev)
29+
static inline void iommu_setup_dma_ops(struct device *dev,
30+
struct iommu_domain *domain)
3031
{
3132
}
3233

drivers/iommu/iommu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list
661661
}
662662

663663
if (group->default_domain)
664-
iommu_setup_dma_ops(dev);
664+
iommu_setup_dma_ops(dev, group->default_domain);
665665

666666
mutex_unlock(&group->mutex);
667667

@@ -1949,7 +1949,7 @@ static int bus_iommu_probe(const struct bus_type *bus)
19491949
return ret;
19501950
}
19511951
for_each_group_device(group, gdev)
1952-
iommu_setup_dma_ops(gdev->dev);
1952+
iommu_setup_dma_ops(gdev->dev, group->default_domain);
19531953
mutex_unlock(&group->mutex);
19541954

19551955
/*
@@ -3155,7 +3155,7 @@ static ssize_t iommu_group_store_type(struct iommu_group *group,
31553155

31563156
/* Make sure dma_ops is appropriatley set */
31573157
for_each_group_device(group, gdev)
3158-
iommu_setup_dma_ops(gdev->dev);
3158+
iommu_setup_dma_ops(gdev->dev, group->default_domain);
31593159

31603160
out_unlock:
31613161
mutex_unlock(&group->mutex);

0 commit comments

Comments
 (0)