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

From: Christoph Hellwig
Date: Mon Apr 24 2023 - 02:05:28 EST


On Fri, Apr 21, 2023 at 05:09:34PM +0200, Petr Tesařík wrote:
> > > A. Only grouping those fields in their own struct?
> > > B. Or move the definition to another include file (cf. MAINTAINERS)?
> > > C. Or store a pointer in struct device?
> >
> > dev->dma_parms is already this, and IIRC still has some very old
> > comments somewhere about consolidating the other DMA-related fields in
> > there.
>
> Thank you for the hint! I have actually seen dma_parms, but since it
> can be NULL and was initialized from various drivers, it did not occur
> to me that NULL simply means not DMA-capable.

Yes, dma_parms are still optional. A much better hint is the dma_mask
itself, which for historic reasons is implemented in a completely
awfull way as a pointer to something stored in the containing struture,
which all kinds of platform devices or minor buses doing nasty hacks
there.