Re: [PATCH v3 04/18] driver core: platform: Add driver dma ownership management

From: Jason Gunthorpe
Date: Tue Dec 07 2021 - 08:16:34 EST


On Tue, Dec 07, 2021 at 10:57:25AM +0800, Lu Baolu wrote:
> On 12/6/21 11:06 PM, Jason Gunthorpe wrote:
> > On Mon, Dec 06, 2021 at 06:36:27AM -0800, Christoph Hellwig wrote:
> > > I really hate the amount of boilerplate code that having this in each
> > > bus type causes.
> > +1
> >
> > I liked the first version of this series better with the code near
> > really_probe().
> >
> > Can we go back to that with some device_configure_dma() wrapper
> > condtionally called by really_probe as we discussed?
> >
>
> Are you talking about below change?
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 68ea1f949daa..368f9e530515 100644
> +++ b/drivers/base/dd.c
> @@ -577,7 +577,13 @@ static int really_probe(struct device *dev, struct
> device_driver *drv)
> if (dev->bus->dma_configure) {
> ret = dev->bus->dma_configure(dev);
> if (ret)
> - goto probe_failed;
> + goto pinctrl_bind_failed;
> +
> + if (!drv->no_kernel_dma) {
> + ret = iommu_device_set_dma_owner(dev, DMA_OWNER_DMA_API, NULL);
> + if (ret)
> + goto pinctrl_bind_failed;
> + }
> }

Yes, the suggestion was to put everything that 'if' inside a function
and then of course a matching undo function.

Jason