On Sat, Apr 18, 2020 at 02:42:05PM +0200, Joerg Roedel wrote: > Hi Christoph, > > On Tue, Apr 14, 2020 at 02:25:05PM +0200, Christoph Hellwig wrote: > > +static inline bool dma_map_direct(struct device *dev, > > + const struct dma_map_ops *ops) > > +{ > > + if (likely(!ops)) > > + return true; > > + if (!dev->dma_ops_bypass) > > + return false; > > + > > + return min_not_zero(*dev->dma_mask, dev->bus_dma_limit) >= > > + dma_direct_get_required_mask(dev); > > Why is the dma-mask check done here? The dma-direct code handles memory > outside of the devices dma-mask with swiotlb, no? > > I also don't quite get what the difference between setting the > dma_ops_bypass flag non-zero and setting ops to NULL is.
The difference is that NULL ops mean imply the direct mapping is always used, dma_ops_bypass means a direct mapping is used if no bounce buffering using swiotlb is needed, which should also answer your first question. The idea is to consolidate code in the core to use an opportunistic direct mapping instead of the dynamic iommu mapping. I though the cover letter and commit log explained this well enough, but maybe I need to do a better job.