[PATCH v4 4/7] iommu: Pass in old domain to attach_dev callback functions

Nicolin Chen nicolinc at nvidia.com
Fri Sep 19 15:56:38 PDT 2025


On Sun, Aug 31, 2025 at 04:31:56PM -0700, Nicolin Chen wrote:
> @@ -2347,7 +2352,8 @@ static int __iommu_group_set_domain_internal(struct iommu_group *group,
>  	 */
>  	result = 0;
>  	for_each_group_device(group, gdev) {
> -		ret = __iommu_device_set_domain(group, gdev, new_domain, flags);
> +		ret = __iommu_device_set_domain(group, gdev, new_domain,
> +						group->domain, flags);
>  		if (ret) {
>  			result = ret;
>  			/*
> @@ -2379,7 +2385,7 @@ static int __iommu_group_set_domain_internal(struct iommu_group *group,
>  		 */
>  		if (group->domain)
>  			WARN_ON(__iommu_device_set_domain(
> -				group, gdev, group->domain,
> +				group, gdev, group->domain, new_domain,
>  				IOMMU_SET_DOMAIN_MUST_SUCCEED));
>  		if (gdev == last_gdev)
>  			break;

This last_gdev is the device failing __iommu_device_set_domain()
previously, so it should not be reverted from the new_domain to
the group->domain, as it has never left the group->domain.

This isn't a problem without this patch, because the revert will
be simply a re-attach (from group->domain to group->domain).

I'm adding a new patch to the top of the series in v5, though it
doesn't worth being a bug fix IMHO.

Thanks
Nicolin



More information about the linux-riscv mailing list