Skip to content

Commit 0aeba2d

Browse files
Christoph Hellwigmpe
authored andcommitted
powerpc/dma: properly wire up the unmap_page and unmap_sg methods
The unmap methods need to transfer memory ownership back from the device to the cpu by identical means as dma_sync_*_to_cpu. I'm not sure powerpc needs to do any work in this transfer direction, but given that it does invalidate the caches in dma_sync_*_to_cpu already we should make sure we also do so on unmapping. Signed-off-by: Christoph Hellwig <hch@lst.de> [mpe: s/dir/direction in dma_nommu_unmap_page()] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 9286356 commit 0aeba2d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎arch/powerpc/kernel/dma.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,15 @@ static int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl,
210210
return nents;
211211
}
212212

213-
static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sg,
213+
static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sgl,
214214
int nents, enum dma_data_direction direction,
215215
unsigned long attrs)
216216
{
217+
struct scatterlist *sg;
218+
int i;
219+
220+
for_each_sg(sgl, sg, nents, i)
221+
__dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
217222
}
218223

219224
static u64 dma_nommu_get_required_mask(struct device *dev)
@@ -247,6 +252,8 @@ static inline void dma_nommu_unmap_page(struct device *dev,
247252
enum dma_data_direction direction,
248253
unsigned long attrs)
249254
{
255+
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
256+
__dma_sync(bus_to_virt(dma_address), size, direction);
250257
}
251258

252259
#ifdef CONFIG_NOT_COHERENT_CACHE

0 commit comments

Comments
 (0)