RE: [PATCH v4 13/17] iommufd: Add kAPI toward external drivers for kernel access

Tian, Kevin
2022-11-14T08:25:50Z

> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Tuesday, November 8, 2022 8:49 AM
>
> Callers must provide a callback that immediately unpins any IOVA being
> used within a range. This happens if userspace unmaps the IOVA under the
> pin.

with 'must' then let's add a check in iommufd_access_create() on the
unmap callback.

> +struct iommufd_access *
> +iommufd_access_create(struct iommufd_ctx *ictx, u32 ioas_id,
> + const struct iommufd_access_ops *ops, void *data)
> +{
> + struct iommufd_access *access;
> + struct iommufd_object *obj;
> + int rc;
> +
> + /*
> + * There is no uAPI for the access object, but to keep things
> symmetric
> + * use the object infrastructure anyhow.
> + */
> + access = iommufd_object_alloc(ictx, access, IOMMUFD_OBJ_ACCESS);
> + if (IS_ERR(access))
> + return access;
> +
> + access->data = data;
> + access->ops = ops;
> + access->ictx = ictx;

I didn't see other places referencing access->ictx before this func
succeeds. But just to be robust it's always cleaner to put this line
together with iommufd_ctx_get().

The rest looks good to me:

Reviewed-by: Kevin Tian <kevin.tian@intel.com>