On Wed, Jun 29, 2022 at 5:48 PM Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote: > > On Wed, Jun 29, 2022 at 10:21 AM Arnd Bergmann <arnd@xxxxxxxxxx> wrote: > > 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. > > Chip RAM is mapped uncached. > Amifb remaps it using ioremap_wt() to get a write-through frame buffer. Ok, so in this case the driver should skip the dma_map_single() cache management and instead keep converting the chipram address to a bus address directly. While the driver does an extra cache flush on the uncached address today, it's clearly not needed and there is probably a performance benefit to not doing it. For simplicity, the normal bounce buffer could similarly use dma_alloc_coherent(), which will also result in an uncached buffer. If I read this correctly, this will also ensure that the buffer is within the DMA mask, so if ZONE_DMA is larger than the mask, it just returns NULL and you have to fall back to the chipram page, rather than checking the address and freeing the buffer. Arnd