diff options
| author | Will Deacon <will.deacon@arm.com> | 2015-01-16 12:02:15 -0500 |
|---|---|---|
| committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-03-18 06:15:53 -0400 |
| commit | 89cfdb19a88872088a8cf69621e55d41c379f02f (patch) | |
| tree | d8296ed5147f8b6f2ba6b0aafa42c0b248d43fa2 | |
| parent | 1b4bd608763e063ea87e20030e05db005e70177f (diff) | |
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>
| -rw-r--r-- | arch/arm/mm/dma-mapping.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 713761643e38..b8fe72080108 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
| @@ -1221,7 +1221,7 @@ __iommu_alloc_remap(struct page **pages, size_t size, gfp_t gfp, pgprot_t prot, | |||
| 1221 | static dma_addr_t | 1221 | static dma_addr_t |
| 1222 | __iommu_create_mapping(struct device *dev, struct page **pages, size_t size) | 1222 | __iommu_create_mapping(struct device *dev, struct page **pages, size_t size) |
| 1223 | { | 1223 | { |
| 1224 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; | 1224 | struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); |
| 1225 | unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; | 1225 | unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; |
| 1226 | dma_addr_t dma_addr, iova; | 1226 | dma_addr_t dma_addr, iova; |
| 1227 | int i, ret = DMA_ERROR_CODE; | 1227 | int i, ret = DMA_ERROR_CODE; |
| @@ -1257,7 +1257,7 @@ fail: | |||
| 1257 | 1257 | ||
| 1258 | static int __iommu_remove_mapping(struct device *dev, dma_addr_t iova, size_t size) | 1258 | static int __iommu_remove_mapping(struct device *dev, dma_addr_t iova, size_t size) |
| 1259 | { | 1259 | { |
| 1260 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; | 1260 | struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); |
| 1261 | 1261 | ||
| 1262 | /* | 1262 | /* |
| 1263 | * add optional in-page offset from iova to size and align | 1263 | * 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, | |||
| 1472 | enum dma_data_direction dir, struct dma_attrs *attrs, | 1472 | enum dma_data_direction dir, struct dma_attrs *attrs, |
| 1473 | bool is_coherent) | 1473 | bool is_coherent) |
| 1474 | { | 1474 | { |
| 1475 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; | 1475 | struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); |
| 1476 | dma_addr_t iova, iova_base; | 1476 | dma_addr_t iova, iova_base; |
| 1477 | int ret = 0; | 1477 | int ret = 0; |
| 1478 | unsigned int count; | 1478 | unsigned int count; |
| @@ -1693,7 +1693,7 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p | |||
| 1693 | unsigned long offset, size_t size, enum dma_data_direction dir, | 1693 | unsigned long offset, size_t size, enum dma_data_direction dir, |
| 1694 | struct dma_attrs *attrs) | 1694 | struct dma_attrs *attrs) |
| 1695 | { | 1695 | { |
| 1696 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; | 1696 | struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); |
| 1697 | dma_addr_t dma_addr; | 1697 | dma_addr_t dma_addr; |
| 1698 | int ret, prot, len = PAGE_ALIGN(size + offset); | 1698 | int ret, prot, len = PAGE_ALIGN(size + offset); |
| 1699 | 1699 | ||
| @@ -1746,7 +1746,7 @@ static void arm_coherent_iommu_unmap_page(struct device *dev, dma_addr_t handle, | |||
| 1746 | size_t size, enum dma_data_direction dir, | 1746 | size_t size, enum dma_data_direction dir, |
| 1747 | struct dma_attrs *attrs) | 1747 | struct dma_attrs *attrs) |
| 1748 | { | 1748 | { |
| 1749 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; | 1749 | struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); |
| 1750 | dma_addr_t iova = handle & PAGE_MASK; | 1750 | dma_addr_t iova = handle & PAGE_MASK; |
| 1751 | int offset = handle & ~PAGE_MASK; | 1751 | int offset = handle & ~PAGE_MASK; |
| 1752 | int len = PAGE_ALIGN(size + offset); | 1752 | int len = PAGE_ALIGN(size + offset); |
| @@ -1771,7 +1771,7 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle, | |||
| 1771 | size_t size, enum dma_data_direction dir, | 1771 | size_t size, enum dma_data_direction dir, |
| 1772 | struct dma_attrs *attrs) | 1772 | struct dma_attrs *attrs) |
| 1773 | { | 1773 | { |
| 1774 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; | 1774 | struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); |
| 1775 | dma_addr_t iova = handle & PAGE_MASK; | 1775 | dma_addr_t iova = handle & PAGE_MASK; |
| 1776 | struct page *page = phys_to_page(iommu_iova_to_phys(mapping->domain, iova)); | 1776 | struct page *page = phys_to_page(iommu_iova_to_phys(mapping->domain, iova)); |
| 1777 | int offset = handle & ~PAGE_MASK; | 1777 | int offset = handle & ~PAGE_MASK; |
| @@ -1790,7 +1790,7 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle, | |||
| 1790 | static void arm_iommu_sync_single_for_cpu(struct device *dev, | 1790 | static void arm_iommu_sync_single_for_cpu(struct device *dev, |
| 1791 | dma_addr_t handle, size_t size, enum dma_data_direction dir) | 1791 | dma_addr_t handle, size_t size, enum dma_data_direction dir) |
| 1792 | { | 1792 | { |
| 1793 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; | 1793 | struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); |
| 1794 | dma_addr_t iova = handle & PAGE_MASK; | 1794 | dma_addr_t iova = handle & PAGE_MASK; |
| 1795 | struct page *page = phys_to_page(iommu_iova_to_phys(mapping->domain, iova)); | 1795 | struct page *page = phys_to_page(iommu_iova_to_phys(mapping->domain, iova)); |
| 1796 | unsigned int offset = handle & ~PAGE_MASK; | 1796 | unsigned int offset = handle & ~PAGE_MASK; |
| @@ -1804,7 +1804,7 @@ static void arm_iommu_sync_single_for_cpu(struct device *dev, | |||
| 1804 | static void arm_iommu_sync_single_for_device(struct device *dev, | 1804 | static void arm_iommu_sync_single_for_device(struct device *dev, |
| 1805 | dma_addr_t handle, size_t size, enum dma_data_direction dir) | 1805 | dma_addr_t handle, size_t size, enum dma_data_direction dir) |
| 1806 | { | 1806 | { |
| 1807 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; | 1807 | struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); |
| 1808 | dma_addr_t iova = handle & PAGE_MASK; | 1808 | dma_addr_t iova = handle & PAGE_MASK; |
| 1809 | struct page *page = phys_to_page(iommu_iova_to_phys(mapping->domain, iova)); | 1809 | struct page *page = phys_to_page(iommu_iova_to_phys(mapping->domain, iova)); |
| 1810 | unsigned int offset = handle & ~PAGE_MASK; | 1810 | unsigned int offset = handle & ~PAGE_MASK; |
| @@ -1965,7 +1965,7 @@ static int __arm_iommu_attach_device(struct device *dev, | |||
| 1965 | return err; | 1965 | return err; |
| 1966 | 1966 | ||
| 1967 | kref_get(&mapping->kref); | 1967 | kref_get(&mapping->kref); |
| 1968 | dev->archdata.mapping = mapping; | 1968 | to_dma_iommu_mapping(dev) = mapping; |
| 1969 | 1969 | ||
| 1970 | pr_debug("Attached IOMMU controller to %s device.\n", dev_name(dev)); | 1970 | pr_debug("Attached IOMMU controller to %s device.\n", dev_name(dev)); |
| 1971 | return 0; | 1971 | return 0; |
| @@ -2010,7 +2010,7 @@ static void __arm_iommu_detach_device(struct device *dev) | |||
| 2010 | 2010 | ||
| 2011 | iommu_detach_device(mapping->domain, dev); | 2011 | iommu_detach_device(mapping->domain, dev); |
| 2012 | kref_put(&mapping->kref, release_iommu_mapping); | 2012 | kref_put(&mapping->kref, release_iommu_mapping); |
| 2013 | dev->archdata.mapping = NULL; | 2013 | to_dma_iommu_mapping(dev) = NULL; |
| 2014 | 2014 | ||
| 2015 | pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev)); | 2015 | pr_debug("Detached IOMMU controller from %s device.\n", dev_name(dev)); |
| 2016 | } | 2016 | } |
| @@ -2061,7 +2061,7 @@ static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size, | |||
| 2061 | 2061 | ||
| 2062 | static void arm_teardown_iommu_dma_ops(struct device *dev) | 2062 | static void arm_teardown_iommu_dma_ops(struct device *dev) |
| 2063 | { | 2063 | { |
| 2064 | struct dma_iommu_mapping *mapping = dev->archdata.mapping; | 2064 | struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); |
| 2065 | 2065 | ||
| 2066 | if (!mapping) | 2066 | if (!mapping) |
| 2067 | return; | 2067 | return; |
