Re: [PATCH v3 01/18] iommu: Add device dma ownership set/release interfaces

From: Christoph Hellwig
Date: Mon Dec 06 2021 - 09:30:10 EST


On Mon, Dec 06, 2021 at 02:35:55PM +0100, Joerg Roedel wrote:
> > enum iommu_dma_owner type, void *owner_cookie);
> > void iommu_device_release_dma_owner(struct device *dev,
> > enum iommu_dma_owner type);
>
> It the owner is a group-wide setting, it should be called with the group
> instead of the device. I have seen the group-specific funcitons are
> added later, but that leaves the question why the device-specific ones
> are needed at all.

They aren't really. A lot of bus drivers need helpers to set/release
the dma API domain if there is an iommu group, but tegra which actually
sets a non-default value would be much better off with just open coding
them.

> > @@ -621,6 +624,7 @@ struct iommu_group *iommu_group_alloc(void)
> > INIT_LIST_HEAD(&group->devices);
> > INIT_LIST_HEAD(&group->entry);
> > BLOCKING_INIT_NOTIFIER_HEAD(&group->notifier);
> > + group->dma_owner = DMA_OWNER_NONE;
>
>
> DMA_OWNER_NONE is also questionable. All devices are always in one
> domain, and the default domain is always the one used for DMA-API, so
> why isn't the initial value DMA_OWNER_DMA_API?

The interesting part is the suppress_auto_claim_dma_owner flag, but it
might make more sense to release the dma API ownership for that rather
than requesting it if it is not set.