Re: [PATCH v9 04/11] iommu: Add sva iommu_domain support

From: Baolu Lu
Date: Tue Jun 28 2022 - 07:41:39 EST


On 2022/6/28 16:50, Tian, Kevin wrote:
+
+ mutex_lock(&group->mutex);
+ curr = xa_cmpxchg(&group->pasid_array, pasid, NULL, domain,
GFP_KERNEL);
+ if (curr)
+ goto out_unlock;
Need check xa_is_err(old).
Either

(1) old entry is a valid pointer, or
return -EBUSY in this case

(2) xa_is_err(curr)
return xa_err(cur)

are failure cases. Hence, "curr == NULL" is the only check we need. Did
I miss anything?

But now you always return -EBUSY for all kinds of xa errors.

Fair enough. Updated like below.

curr = xa_cmpxchg(&group->pasid_array, pasid, NULL, domain, GFP_KERNEL);
if (curr) {
ret = xa_err(curr) ? : -EBUSY;
goto out_unlock;
}

Best regards,
baolu