Skip to content

Commit 59fa126

Browse files
committed
parisc: Improve cache flushing for PCXL in arch_sync_dma_for_cpu()
Add comment in arch_sync_dma_for_device() and handle the direction flag in arch_sync_dma_for_cpu(). When receiving data from the device (DMA_FROM_DEVICE) unconditionally purge the data cache in arch_sync_dma_for_cpu(). Signed-off-by: Helge Deller <[email protected]>
1 parent 44c026a commit 59fa126

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

arch/parisc/kernel/pci-dma.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,27 @@ void arch_dma_free(struct device *dev, size_t size, void *vaddr,
446446
void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
447447
enum dma_data_direction dir)
448448
{
449+
/*
450+
* fdc: The data cache line is written back to memory, if and only if
451+
* it is dirty, and then invalidated from the data cache.
452+
*/
449453
flush_kernel_dcache_range((unsigned long)phys_to_virt(paddr), size);
450454
}
451455

452456
void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
453457
enum dma_data_direction dir)
454458
{
455-
flush_kernel_dcache_range((unsigned long)phys_to_virt(paddr), size);
459+
unsigned long addr = (unsigned long) phys_to_virt(paddr);
460+
461+
switch (dir) {
462+
case DMA_TO_DEVICE:
463+
case DMA_BIDIRECTIONAL:
464+
flush_kernel_dcache_range(addr, size);
465+
return;
466+
case DMA_FROM_DEVICE:
467+
purge_kernel_dcache_range_asm(addr, addr + size);
468+
return;
469+
default:
470+
BUG();
471+
}
456472
}

0 commit comments

Comments
 (0)