[PATCH v2 10/22] iommufd/viommmu: Add IOMMUFD_CMD_VCMDQ_ALLOC ioctl
Baolu Lu
baolu.lu at linux.intel.com
Sun Apr 27 18:32:04 PDT 2025
On 4/26/25 13:58, Nicolin Chen wrote:
> diff --git a/drivers/iommu/iommufd/viommu.c b/drivers/iommu/iommufd/viommu.c
> index a65153458a26..02a111710ffe 100644
> --- a/drivers/iommu/iommufd/viommu.c
> +++ b/drivers/iommu/iommufd/viommu.c
> @@ -170,3 +170,97 @@ int iommufd_vdevice_alloc_ioctl(struct iommufd_ucmd *ucmd)
> iommufd_put_object(ucmd->ictx, &viommu->obj);
> return rc;
> }
> +
> +void iommufd_vcmdq_destroy(struct iommufd_object *obj)
> +{
> + struct iommufd_vcmdq *vcmdq =
> + container_of(obj, struct iommufd_vcmdq, obj);
> + struct iommufd_viommu *viommu = vcmdq->viommu;
> +
> + if (viommu->ops->vcmdq_destroy)
> + viommu->ops->vcmdq_destroy(vcmdq);
> + iopt_unpin_pages(&viommu->hwpt->ioas->iopt, vcmdq->addr, vcmdq->length);
> + refcount_dec(&viommu->obj.users);
> +}
> +
> +int iommufd_vcmdq_alloc_ioctl(struct iommufd_ucmd *ucmd)
> +{
> + struct iommu_vcmdq_alloc *cmd = ucmd->cmd;
> + struct iommufd_viommu *viommu;
> + struct iommufd_vcmdq *vcmdq;
> + struct page **pages;
> + int max_npages, i;
> + dma_addr_t end;
> + int rc;
> +
> + if (cmd->flags || cmd->type == IOMMU_VCMDQ_TYPE_DEFAULT)
I don't follow the check of 'cmd->type == IOMMU_VCMDQ_TYPE_DEFAULT'
here. My understanding is that it states that "other values of type are
not supported". If so, shouldn't it be,
if (cmd->flags || cmd->type != IOMMU_VCMDQ_TYPE_DEFAULT)
?
> + return -EOPNOTSUPP;
> + if (!cmd->addr || !cmd->length)
> + return -EINVAL;
> + if (check_add_overflow(cmd->addr, cmd->length - 1, &end))
> + return -EOVERFLOW;
Thanks,
baolu
More information about the linux-arm-kernel
mailing list