[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 03/20] vfio/iommufd: Implement the iommufd backend
From: |
Nicolin Chen |
Subject: |
Re: [PATCH v5 03/20] vfio/iommufd: Implement the iommufd backend |
Date: |
Sat, 11 Nov 2023 09:47:17 -0800 |
On Thu, Nov 09, 2023 at 07:45:12PM +0800, Zhenzhong Duan wrote:
> +static int iommufd_cdev_attach_ioas_hwpt(VFIODevice *vbasedev, bool is_ioas,
> + uint32_t id, Error **errp)
> +{
> + int ret, iommufd = vbasedev->iommufd->fd;
> + struct vfio_device_attach_iommufd_pt attach_data = {
> + .argsz = sizeof(attach_data),
> + .flags = 0,
> + .pt_id = id,
> + };
> + const char *str = is_ioas ? "ioas" : "hwpt";
> +
> + /* Attach device to an IOAS or hwpt within iommufd */
> + ret = ioctl(vbasedev->fd, VFIO_DEVICE_ATTACH_IOMMUFD_PT, &attach_data);
> + if (ret) {
> + error_setg_errno(errp, errno,
> + "[iommufd=%d] error attach %s (%d) to %s_id=%d",
> + iommufd, vbasedev->name, vbasedev->fd, str, id);
> + } else {
> + trace_iommufd_cdev_attach_ioas_hwpt(iommufd, vbasedev->name,
> + vbasedev->fd, str, id);
> + }
> + return ret;
> +}
> +
> +static int iommufd_cdev_detach_ioas_hwpt(VFIODevice *vbasedev, bool is_ioas,
> + uint32_t id, Error **errp)
> +{
> + int ret, iommufd = vbasedev->iommufd->fd;
> + struct vfio_device_detach_iommufd_pt detach_data = {
> + .argsz = sizeof(detach_data),
> + .flags = 0,
> + };
> + const char *str = is_ioas ? "ioas" : "hwpt";
> +
> + ret = ioctl(vbasedev->fd, VFIO_DEVICE_DETACH_IOMMUFD_PT, &detach_data);
> + if (ret) {
> + error_setg_errno(errp, errno, "detach %s from %s failed",
> + vbasedev->name, str);
> + } else {
> + trace_iommufd_cdev_detach_ioas_hwpt(iommufd, vbasedev->name, str,
> id);
> + }
> + return ret;
> +}
Being a bit late to the game, I might have missed some review
history here, yet any reason why we changed the attach/detach
APIs to specify is_ioas? The attach kernel uAPI generically
handles this without requiring an is_ioas input, and it could
be interpreted to attaching both ioas and hwpt (auto). On the
hand, the detach uAPI doesn't even care about id. So, I don't
see a value of the is_ioas except the trace logs..
If we have such a hard requirement somewhere, shall we create
an IOMMUFDPtObject structure that holds the type (ioas/hwpt)?
Thanks
Nic
[PATCH v5 04/20] vfio/iommufd: Relax assert check for iommufd backend, Zhenzhong Duan, 2023/11/09
[PATCH v5 05/20] vfio/iommufd: Add support for iova_ranges and pgsizes, Zhenzhong Duan, 2023/11/09
[PATCH v5 06/20] vfio/pci: Extract out a helper vfio_pci_get_pci_hot_reset_info, Zhenzhong Duan, 2023/11/09
[PATCH v5 07/20] vfio/pci: Introduce a vfio pci hot reset interface, Zhenzhong Duan, 2023/11/09
[PATCH v5 08/20] vfio/iommufd: Enable pci hot reset through iommufd cdev interface, Zhenzhong Duan, 2023/11/09
[PATCH v5 09/20] vfio/pci: Allow the selection of a given iommu backend, Zhenzhong Duan, 2023/11/09