RE: [PATCH v5 2/4] iommufd: Add iommufd_access_replace() API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Nicolin Chen <nicolinc@xxxxxxxxxx>
> Sent: Thursday, March 23, 2023 4:33 PM
> 
> +int iommufd_access_replace(struct iommufd_access *access, u32 ioas_id)
> +{
> +	struct iommufd_ioas *new_ioas;
> +
> +	mutex_lock(&access->ioas_lock);
> +	if (!access->ioas) {
>  		mutex_unlock(&access->ioas_lock);
> -		iommufd_put_object(obj);
> -		return rc;
> +		return -ENOENT;
> +	}
> +	if (access->ioas->obj.id == ioas_id) {
> +		mutex_unlock(&access->ioas_lock);
> +		return 0;
>  	}
> -	iommufd_ref_to_users(obj);
> 
> +	new_ioas = iommufd_access_change_pt(access, ioas_id);
> +	if (IS_ERR(new_ioas)) {
> +		mutex_unlock(&access->ioas_lock);
> +		return PTR_ERR(new_ioas);
> +	}
> +	__iommufd_access_detach(access);
>  	access->ioas = new_ioas;
>  	access->ioas_unpin = new_ioas;

Above three lines can be moved into iommufd_access_change_pt():

	If (access->ioas)
		__iommufd_access_detach(access);
	access->ioas = new_ioas;
	access->ioas_unpin = new_ioas;

Then both attach/replace can end by calling the common function.




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux