On Thu, Apr 11, 2019 at 07:47:30PM +0100, Tom Murphy via iommu wrote: > The iommu ops .map function (or the iommu_map function which calls it) > was always supposed to be sleepable (according to Joerg's comment in > this thread: https://lore.kernel.org/patchwork/patch/977520/ ) and so > should probably have had a "might_sleep()" since it was written. However > currently the dma-iommu api can call iommu_map in an atomic context, > which it shouldn't do. This doesn't cause any problems because any iommu > driver which uses the dma-iommu api uses gfp_atomic in it's iommu_ops > .map function. But doing this wastes the memory allocators atomic pools. > > Add a new function iommu_map_atomic, use it in the dma-iommu api and add > “might_sleep()” to the iommu_map function. > > After this change all drivers which use the dma-iommu api need to > implement the new iommu ops .map_atomic function. For the moment just > reuse the driver's iommus ops .map function for .map_atomic. Instead of duplicating the callchain shouldn't we just pass down a flag to indicate if the context can sleep or not? Especially as all the existing arm drivers already implement the atomic behavior, which is a majority of struct iommu_ops based iommu drivers.