lkml.org 
[lkml]   [2019]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 4/4] csky: Add dma_inv_range for DMA_FROM_DEVICE
Thx Arnd,

On Tue, Jul 30, 2019 at 11:22 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Tue, Jul 30, 2019 at 5:11 PM Guo Ren <guoren@kernel.org> wrote:
> > > > diff --git a/arch/csky/mm/dma-mapping.c b/arch/csky/mm/dma-mapping.c
> > > > cache_op(paddr, size, dma_wb_range);
> > > > break;
> > > > case DMA_FROM_DEVICE:
> > > > + cache_op(paddr, size, dma_inv_range);
> > > > + break;
> > > > case DMA_BIDIRECTIONAL:
> > > > cache_op(paddr, size, dma_wbinv_range);
> > > > break;
> > >
> > > When syncing 'for_cpu', you should not need to write back, because
> > > there won't be any dirty cache lines.
> >
> > I just follow the dma_data_direction param, seems dir param and
> > function are a little bit duplicated. And our cpu won't clear clean
> > cache line into memory, so dma_wb_page won't cause problem.
> > Seems arch_sync_dma_for_cpu with dir=DMA_TO_DEVICE is
> > self-contradictory.
>
> Right, you generally don't need to do cache management for that
> combination.
>
> There might be other things to do here though, e.g. with a strict
> iommu implementation one could tear down the i/o page table
> entry to prevent the device from accessing a buffer while that is
> owned by the cpu.
Tear down i/o page table shouldn't be put here and it's for map/unmap().
And I think arch_sync_dma_for_cpu/device should only do cache issues.

--
Best Regards
Guo Ren

ML: https://lore.kernel.org/linux-csky/

\
 
 \ /
  Last update: 2019-07-30 17:49    [W:0.044 / U:1.556 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site