Re: [PATCH v2 2/2] dma: add IOMMU static calls with clear default ops

From: Leon Romanovsky
Date: Thu Jul 18 2024 - 09:26:57 EST


On Thu, Jul 18, 2024 at 02:30:38PM +0200, Christoph Hellwig wrote:
> On Thu, Jul 18, 2024 at 10:04:06AM +0300, Leon Romanovsky wrote:
> > Whom should I add?
>
> Greg as the device model maintainer.

No problem, I will add him to the next version.

>
> > > The normal style would be to move the ifdefs outside the helper
> > > function.
> >
> > I think you are talking about the style of functions declarations in
> > header files. This function is inside c-file and it is much easier
> > to write it this way.
>
> But also much harder to read, which will happen much more often.

I'll change.

>
> > > > #ifdef CONFIG_DMA_OPS_BYPASS
> > > > + WARN_ON_ONCE(dev->dma_ops_bypass && dma_is_default_iommu(dev));
> > > > if (dev->dma_ops_bypass)
> > >
> > > Let's skip this and think about it if we ever use the bypass for
> > > something that is not powerpc with it's own dma ops.
> >
> > I wanted to catch misconfigurations, but I can remove it. Is this what
> > you are suggesting?
> >
> > 126 static bool dma_go_direct(struct device *dev, dma_addr_t mask,
> > 127 const struct dma_map_ops *ops)
> > 128 {
> > 129 if (likely(!ops && !dma_is_default_iommu(dev)))
> > 130 return true;
> > 131
> > 132 if (dma_is_default_iommu(dev))
> > 133 return false;
>
> I'd go for:
>
> if (use_dma_iommu(dev))
> return false;
> if (likely(!ops))
> return true;
> ...
>

I will change.

Thanks