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]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux