Skip to content

Commit 89cfdb1

Browse files
wildea01Russell King
authored andcommitted
ARM: 8289/1: dma-mapping: use to_dma_iommu_mapping instead of accessing archdata
When using the IOMMU-backed DMA ops for a device, we store a pointer to the dma_iommu_mapping structure (used to keep track of the address space) in the archdata.mapping field of the struct device. Rather than access this field directly, use the to_dma_iommu_mapping helper in dma-mapping, so that we don't really care where the mapping information is held. Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 1b4bd60 commit 89cfdb1

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

arch/arm/mm/dma-mapping.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ __iommu_alloc_remap(struct page **pages, size_t size, gfp_t gfp, pgprot_t prot,
12211221
static dma_addr_t
12221222
__iommu_create_mapping(struct device *dev, struct page **pages, size_t size)
12231223
{
1224-
struct dma_iommu_mapping *mapping = dev->archdata.mapping;
1224+
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
12251225
unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT;
12261226
dma_addr_t dma_addr, iova;
12271227
int i, ret = DMA_ERROR_CODE;
@@ -1257,7 +1257,7 @@ __iommu_create_mapping(struct device *dev, struct page **pages, size_t size)
12571257

12581258
static int __iommu_remove_mapping(struct device *dev, dma_addr_t iova, size_t size)
12591259
{
1260-
struct dma_iommu_mapping *mapping = dev->archdata.mapping;
1260+
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
12611261

12621262
/*
12631263
* add optional in-page offset from iova to size and align
@@ -1472,7 +1472,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg,
14721472
enum dma_data_direction dir, struct dma_attrs *attrs,
14731473
bool is_coherent)
14741474
{
1475-
struct dma_iommu_mapping *mapping = dev->archdata.mapping;
1475+
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
14761476
dma_addr_t iova, iova_base;
14771477
int ret = 0;
14781478
unsigned int count;
@@ -1693,7 +1693,7 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p
16931693
unsigned long offset, size_t size, enum dma_data_direction dir,
16941694
struct dma_attrs *attrs)
16951695
{
1696-
struct dma_iommu_mapping *mapping = dev->archdata.mapping;
1696+
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
16971697
dma_addr_t dma_addr;
16981698
int ret, prot, len = PAGE_ALIGN(size + offset);
16991699

@@ -1746,7 +1746,7 @@ static void arm_coherent_iommu_unmap_page(struct device *dev, dma_addr_t handle,
17461746
size_t size, enum dma_data_direction dir,
17471747
struct dma_attrs *attrs)
17481748
{
1749-
struct dma_iommu_mapping *mapping = dev->archdata.mapping;
1749+
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
17501750
dma_addr_t iova = handle & PAGE_MASK;
17511751
int offset = handle & ~PAGE_MASK;
17521752
int len = PAGE_ALIGN(size + offset);
@@ -1771,7 +1771,7 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle,
17711771
size_t size, enum dma_data_direction dir,
17721772
struct dma_attrs *attrs)
17731773
{
1774-
struct dma_iommu_mapping *mapping = dev->archdata.mapping;
1774+
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
17751775
dma_addr_t iova = handle & PAGE_MASK;
17761776
struct page *page = phys_to_page(iommu_iova_to_phys(mapping->domain, iova));
17771777
int offset = handle & ~PAGE_MASK;
@@ -1790,7 +1790,7 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle,
17901790
static void arm_iommu_sync_single_for_cpu(struct device *dev,
17911791
dma_addr_t handle, size_t size, enum dma_data_direction dir)
17921792
{
1793-
struct dma_iommu_mapping *mapping = dev->archdata.mapping;
1793+
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
17941794
dma_addr_t iova = handle & PAGE_MASK;
17951795
struct page *page = phys_to_page(iommu_iova_to_phys(mapping->domain, iova));
17961796
unsigned int offset = handle & ~PAGE_MASK;
@@ -1804,7 +1804,7 @@ static void arm_iommu_sync_single_for_cpu(struct device *dev,
18041804
static void arm_iommu_sync_single_for_device(struct device *dev,
18051805
dma_addr_t handle, size_t size, enum dma_data_direction dir)
18061806
{
1807-
struct dma_iommu_mapping *mapping = dev->archdata.mapping;
1807+
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
18081808
dma_addr_t iova = handle & PAGE_MASK;
18091809
struct page *page = phys_to_page(iommu_iova_to_phys(mapping->domain, iova));
18101810
unsigned int offset = handle & ~PAGE_MASK;
@@ -1965,7 +1965,7 @@ static int __arm_iommu_attach_device(struct device *dev,
19651965
return err;
19661966

19671967
kref_get(&mapping->kref);
1968-
dev->archdata.mapping = mapping;
1968+
to_dma_iommu_mapping(dev) = mapping;
19691969

19701970
pr_debug("Attached IOMMU controller to %s device.\n", dev_name(dev));
19711971
return 0;
@@ -2010,7 +2010,7 @@ static void __arm_iommu_detach_device(struct device *dev)
20102010

20112011
iommu_detach_device(mapping->domain, dev);
20122012
kref_put(&mapping->kref, release_iommu_mapping);
2013-
dev->archdata.mapping = NULL;
2013+
to_dma_iommu_mapping(dev) = NULL;
20142014

20152015
pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev));
20162016
}
@@ -2061,7 +2061,7 @@ static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
20612061

20622062
static void arm_teardown_iommu_dma_ops(struct device *dev)
20632063
{
2064-
struct dma_iommu_mapping *mapping = dev->archdata.mapping;
2064+
struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
20652065

20662066
if (!mapping)
20672067
return;

0 commit comments

Comments
 (0)