Skip to content

Commit a8eb92d

Browse files
author
Christoph Hellwig
committed
arc: fix arc_dma_{map,unmap}_page
These functions should perform the same cache synchronoization as calling arc_dma_sync_single_for_{cpu,device} in addition to doing any required address translation or mapping [1]. Ensure they actually do that by calling arc_dma_sync_single_for_{cpu,device} instead of passing the dir argument along to _dma_cache_sync. The now unused _dma_cache_sync function is removed as well. [1] in fact various drivers rely on that by passing DMA_ATTR_SKIP_CPU_SYNC to the map/unmap routines and doing the cache synchronization manually. Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Alexey Brodkin <abrodkin@synopsys.com> Acked-by: Vineet Gupta <vgupta@synopsys.com>
1 parent b591741 commit a8eb92d

1 file changed

Lines changed: 2 additions & 25 deletions

File tree

‎arch/arc/mm/dma.c‎

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -130,29 +130,6 @@ static int arc_dma_mmap(struct device *dev, struct vm_area_struct *vma,
130130
return ret;
131131
}
132132

133-
/*
134-
* streaming DMA Mapping API...
135-
* CPU accesses page via normal paddr, thus needs to explicitly made
136-
* consistent before each use
137-
*/
138-
static void _dma_cache_sync(phys_addr_t paddr, size_t size,
139-
enum dma_data_direction dir)
140-
{
141-
switch (dir) {
142-
case DMA_FROM_DEVICE:
143-
dma_cache_inv(paddr, size);
144-
break;
145-
case DMA_TO_DEVICE:
146-
dma_cache_wback(paddr, size);
147-
break;
148-
case DMA_BIDIRECTIONAL:
149-
dma_cache_wback_inv(paddr, size);
150-
break;
151-
default:
152-
pr_err("Invalid DMA dir [%d] for OP @ %pa[p]\n", dir, &paddr);
153-
}
154-
}
155-
156133
static void arc_dma_sync_single_for_device(struct device *dev,
157134
dma_addr_t dma_handle, size_t size, enum dma_data_direction dir)
158135
{
@@ -185,7 +162,7 @@ static dma_addr_t arc_dma_map_page(struct device *dev, struct page *page,
185162
phys_addr_t paddr = page_to_phys(page) + offset;
186163

187164
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
188-
_dma_cache_sync(paddr, size, dir);
165+
arc_dma_sync_single_for_device(dev, paddr, size, dir);
189166

190167
return paddr;
191168
}
@@ -205,7 +182,7 @@ static void arc_dma_unmap_page(struct device *dev, dma_addr_t handle,
205182
phys_addr_t paddr = handle;
206183

207184
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
208-
_dma_cache_sync(paddr, size, dir);
185+
arc_dma_sync_single_for_cpu(dev, paddr, size, dir);
209186
}
210187

211188
static int arc_dma_map_sg(struct device *dev, struct scatterlist *sg,

0 commit comments

Comments
 (0)