RE: [PATCH v2 04/11] iommufd: Pass parent hwpt and user_data to iommufd_hw_pagetable_alloc()

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

 



> From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
> Sent: Thursday, May 11, 2023 10:39 PM
> @@ -61,6 +63,8 @@ int iommufd_hw_pagetable_enforce_cc(struct
> iommufd_hw_pagetable *hwpt)
>   * @ictx: iommufd context
>   * @ioas: IOAS to associate the domain with
>   * @idev: Device to get an iommu_domain for
> + * @parent: Optional parent HWPT to associate with the domain with

remove the trailing "the domain with"

> @@ -73,14 +77,22 @@ int iommufd_hw_pagetable_enforce_cc(struct
> iommufd_hw_pagetable *hwpt)
>   */
>  struct iommufd_hw_pagetable *
>  iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct
> iommufd_ioas *ioas,
> -			   struct iommufd_device *idev, bool
> immediate_attach)
> +			   struct iommufd_device *idev,
> +			   struct iommufd_hw_pagetable *parent,
> +			   union iommu_domain_user_data *user_data,
> +			   bool immediate_attach)
>  {
>  	const struct iommu_ops *ops = dev_iommu_ops(idev->dev);
> +	struct iommu_domain *parent_domain = NULL;
>  	struct iommufd_hw_pagetable *hwpt;
> +	bool type_unmanaged, type_nested;
>  	int rc;
> 
>  	lockdep_assert_held(&ioas->mutex);
> 
> +	if ((user_data || parent) && !ops->domain_alloc_user)
> +		return ERR_PTR(-EOPNOTSUPP);

Do we allow specifying parent w/o user_data?

> @@ -99,6 +117,15 @@ iommufd_hw_pagetable_alloc(struct iommufd_ctx
> *ictx, struct iommufd_ioas *ioas,
>  		goto out_abort;
>  	}
> 
> +	/* It must be either NESTED or UNMANAGED, depending on
> parent_domain */
> +       type_nested = hwpt->domain->type == IOMMU_DOMAIN_NESTED;
> +       type_unmanaged = hwpt->domain->type ==
> IOMMU_DOMAIN_UNMANAGED;

no need of one-time used variables. Just put the conditions directly
in WARN_ON.

> +       if (WARN_ON((parent_domain && !type_nested) ||
> +                   (!parent_domain && !type_unmanaged))) {
> +		rc = -EINVAL;
> +		goto out_abort;
> +	}
> +

probably just WARN_ON_ONCE() to mark that driver has problem?





[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