Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

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

 



On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote:
> +static struct iommufd_hwpt_nested *
> +iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx,
> +			  struct iommufd_hwpt_paging *parent,
> +			  struct iommufd_device *idev, u32 flags,
> +			  const struct iommu_user_data *user_data)
> +{
> +	const struct iommu_ops *ops = dev_iommu_ops(idev->dev);
> +	struct iommufd_hwpt_nested *hwpt_nested;
> +	struct iommufd_hw_pagetable *hwpt;
> +	int rc;
> +
> +	if (flags != 0)
> +		return ERR_PTR(-EOPNOTSUPP);
> +	if (!user_data)
> +		return ERR_PTR(-EINVAL);

user_data is never NULL now, I removed this

> +	if (user_data->type == IOMMU_HWPT_DATA_NONE)
> +		return ERR_PTR(-EINVAL);
> +	if (parent->auto_domain)
> +		return ERR_PTR(-EINVAL);
> +	if (!parent->nest_parent)
> +		return ERR_PTR(-EINVAL);

And put these all together

	if (flags || user_data->type == IOMMU_HWPT_DATA_NONE ||
	    !ops->domain_alloc_user)
		return ERR_PTR(-EOPNOTSUPP);
	if (parent->auto_domain || !parent->nest_parent)
		return ERR_PTR(-EINVAL);


> +
> +	if (!ops->domain_alloc_user)
> +		return ERR_PTR(-EOPNOTSUPP);
> +
> +	hwpt_nested = __iommufd_object_alloc(ictx, hwpt_nested,
> +					     IOMMUFD_OBJ_HWPT_NESTED,
> +					     common.obj);
> +	if (IS_ERR(hwpt_nested))
> +		return ERR_CAST(hwpt_nested);
> +	hwpt = &hwpt_nested->common;
> +
> +	refcount_inc(&parent->common.obj.users);
> +	hwpt_nested->parent = parent;
> +
> +	hwpt->domain = ops->domain_alloc_user(idev->dev, 0,

And we may as well pass flags here even though we know it is 0 today.

Jason



[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