Re: [RFC v1 3/4] swiotlb: Allow dynamic allocation of bounce buffers

From: Christoph Hellwig
Date: Fri Apr 07 2023 - 01:57:11 EST


On Tue, Mar 28, 2023 at 02:43:03PM +0200, Petr Tesarik wrote:
> Oh, wait! I can do at least something for devices which do not use
> swiotlb at all.
>
> If a device does not use bounce buffers, it cannot pass an address
> that belongs to the swiotlb. Consequently, the potentially
> expensive check can be skipped. This avoids the dynamic lookup
> penalty for devices which do not need the swiotlb.
>
> Note that the counter always remains zero if dma_io_tlb_mem is
> NULL, so the NULL check is not required.

Hmm, that's yet another atomic for each map/unmap, and bloats
struct device.

(Btw, in case anyone is interested, we really need to get started
on moving the dma fields out of struct device into a sub-struct
only allocated for DMA capable busses)