Re: [PATCH v4 02/17] iommu: Add device-centric DMA ownership interfaces

Jason Gunthorpe
2022-11-14T16:44:42Z

On Fri, Nov 11, 2022 at 05:37:36AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@nvidia.com>
> > Sent: Tuesday, November 8, 2022 8:49 AM
> > +static int __iommu_take_dma_ownership(struct iommu_group *group, void
> > *owner)
> > +{
> > + int ret;
> > +
> > + if (WARN_ON(!owner))
> > + return -EINVAL;
>
> move to iommu_device_claim_dma_owner(). just like how it's checked
> in the group version.

Ok, like this:

@@ -3112,9 +3112,6 @@ static int __iommu_take_dma_ownership(struct iommu_group *group, void *owner)
{
int ret;

- if (WARN_ON(!owner))
- return -EINVAL;
-
if ((group->domain && group->domain != group->default_domain) ||
!xa_empty(&group->pasid_array))
return -EBUSY;
@@ -3177,6 +3174,8 @@ int iommu_device_claim_dma_owner(struct device *dev, void *owner)

if (!group)
return -ENODEV;
+ if (WARN_ON(!owner))
+ return -EINVAL;

mutex_lock(&group->mutex);
if (group->owner_cnt) {

> > + if ((group->domain && group->domain != group->default_domain) ||
> > + !xa_empty(&group->pasid_array))
> > + return -EBUSY;
>
> the check of pasid_array is a new addition in this version. it's probably
> worthy a comment here.

It is just the merge resolution with the SVA series, the entire if is
being copied from someplace else

Thanks,
Jason