Re: [PATCH v1 0/3] Converting m68k WD33C93 drivers to DMA API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Arnd,

On 29/06/22 20:20, Arnd Bergmann wrote:

To clarify, the dma-mapping API has two ways of dealing with this:

- the streaming API (dma_map/unmap_...) uses explicit cache flushes

- the coherent API (dma_alloc_coherent etc) uses page protections
   to prevent caching.

These three drivers use the streaming API because they operate on
data passed in from the outside, so the non-cacheable protection bits
are not used here.
I had feared you'd say something along these lines ...

Now that throws up a possible problem for the gvp11 driver: due to the
need to first map an allocated chunk, then possibly discard that and try
another allocation strategy, copying of data to the bounce buffer is
deferred until after the final mapping has been successful. This means
for writes, we have done the cache flushing before we have actually
written any data to the buffer.

I don't think it is safe to omit the explicit cache flush for writes in
this case.
I think it's fine as long as you do things in the correct order: the
copy into the bounce buffer has to be done before the
dma_map_single() here, and conversely, the copy out of the
bounce buffer must happen after the dma_unmap_single().

Ah - I had missed the latter (due to dma_setup previously doing all cache management, and I had expected dma_map_single to do the same, i.e. invalidate the affected cache lines at time of mapping). Will fix.

The former is possible to do, but may incur an extra memcpy on gvp11 (filling a bounce buffer that we may then discard because dma_map_single() returns a DMA handle outside our DMA range). The driver does switch to only allocating bounce buffers from chip RAM once a kmalloc allocation failed to yield DMA-able RAM, so the performance impact ought to be minimal.

Regarding the amiga_chip_alloc(), I don't know what this means
for caching. If chip memory is cache-coherent (either uncached
or by snooping), then there should not be any
dma_map()/dma_unmap() for that case, but instead the
amiga_chip_alloc() function should return both the pointer
and the dma_addr_t token.

amiga_chip_alloc() is used in many places around the kernel, I'd rather not change all that (or more precisely. I'd rather Geert does change amiga_chip_alloc() if need be).

I'll drop use of dma_map_single() on chip RAM and will rely on that having been mapped non-cacheable.

Cheers,

    Michael


          Arnd



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux