[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/21] vfio/platform: Use vfio_[attach/detach]_device
|
From: |
Cédric Le Goater |
|
Subject: |
[PULL 14/21] vfio/platform: Use vfio_[attach/detach]_device |
|
Date: |
Fri, 6 Oct 2023 08:19:58 +0200 |
From: Eric Auger <eric.auger@redhat.com>
Let the vfio-platform device use vfio_attach_device() and
vfio_detach_device(), hence hiding the details of the used
IOMMU backend.
Drop the trace event for vfio-platform as we have similar
one in vfio_attach_device.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/platform.c | 43 +++----------------------------------------
hw/vfio/trace-events | 1 -
2 files changed, 3 insertions(+), 41 deletions(-)
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index
5af73f928766c16cd36010ca0d07c65ae5c5eb16..8e3d4ac45824ec69afb523f8f0e668327122cd02
100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -529,12 +529,7 @@ static VFIODeviceOps vfio_platform_ops = {
*/
static int vfio_base_device_init(VFIODevice *vbasedev, Error **errp)
{
- VFIOGroup *group;
- VFIODevice *vbasedev_iter;
- char *tmp, group_path[PATH_MAX], *group_name;
- ssize_t len;
struct stat st;
- int groupid;
int ret;
/* @sysfsdev takes precedence over @host */
@@ -557,47 +552,15 @@ static int vfio_base_device_init(VFIODevice *vbasedev,
Error **errp)
return -errno;
}
- tmp = g_strdup_printf("%s/iommu_group", vbasedev->sysfsdev);
- len = readlink(tmp, group_path, sizeof(group_path));
- g_free(tmp);
-
- if (len < 0 || len >= sizeof(group_path)) {
- ret = len < 0 ? -errno : -ENAMETOOLONG;
- error_setg_errno(errp, -ret, "no iommu_group found");
- return ret;
- }
-
- group_path[len] = 0;
-
- group_name = basename(group_path);
- if (sscanf(group_name, "%d", &groupid) != 1) {
- error_setg_errno(errp, errno, "failed to read %s", group_path);
- return -errno;
- }
-
- trace_vfio_platform_base_device_init(vbasedev->name, groupid);
-
- group = vfio_get_group(groupid, &address_space_memory, errp);
- if (!group) {
- return -ENOENT;
- }
-
- QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
- if (strcmp(vbasedev_iter->name, vbasedev->name) == 0) {
- error_setg(errp, "device is already attached");
- vfio_put_group(group);
- return -EBUSY;
- }
- }
- ret = vfio_get_device(group, vbasedev->name, vbasedev, errp);
+ ret = vfio_attach_device(vbasedev->name, vbasedev,
+ &address_space_memory, errp);
if (ret) {
- vfio_put_group(group);
return ret;
}
ret = vfio_populate_device(vbasedev, errp);
if (ret) {
- vfio_put_group(group);
+ vfio_detach_device(vbasedev);
}
return ret;
diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events
index
8ac13eb106db68c4f547b1b3819f96272309a124..0eb2387cf24c920b0904ec4012b0fcd3f2e8b3cf
100644
--- a/hw/vfio/trace-events
+++ b/hw/vfio/trace-events
@@ -121,7 +121,6 @@ vfio_get_dirty_bitmap(int fd, uint64_t iova, uint64_t size,
uint64_t bitmap_size
vfio_iommu_map_dirty_notify(uint64_t iova_start, uint64_t iova_end) "iommu
dirty @ 0x%"PRIx64" - 0x%"PRIx64
# platform.c
-vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group
#%d"
vfio_platform_realize(char *name, char *compat) "vfio device %s, compat = %s"
vfio_platform_eoi(int pin, int fd) "EOI IRQ pin %d (fd=%d)"
vfio_platform_intp_mmap_enable(int pin) "IRQ #%d still active, stay in slow
path"
--
2.41.0
- [PULL 02/21] vfio/pci: rename vfio_put_device to vfio_pci_put_device, (continued)
- [PULL 02/21] vfio/pci: rename vfio_put_device to vfio_pci_put_device, Cédric Le Goater, 2023/10/06
- [PULL 06/21] vfio/pci: enable MSI-X in interrupt restoring on dynamic allocation, Cédric Le Goater, 2023/10/06
- [PULL 07/21] scripts/update-linux-headers: Add iommufd.h, Cédric Le Goater, 2023/10/06
- [PULL 05/21] vfio/pci: use an invalid fd to enable MSI-X, Cédric Le Goater, 2023/10/06
- [PULL 08/21] linux-headers: Add iommufd.h, Cédric Le Goater, 2023/10/06
- [PULL 09/21] vfio/common: Move IOMMU agnostic helpers to a separate file, Cédric Le Goater, 2023/10/06
- [PULL 10/21] vfio/common: Propagate KVM_SET_DEVICE_ATTR error if any, Cédric Le Goater, 2023/10/06
- [PULL 11/21] vfio/common: Introduce vfio_container_add|del_section_window(), Cédric Le Goater, 2023/10/06
- [PULL 12/21] vfio/common: Extract out vfio_kvm_device_[add/del]_fd, Cédric Le Goater, 2023/10/06
- [PULL 15/21] vfio/ap: Use vfio_[attach/detach]_device, Cédric Le Goater, 2023/10/06
- [PULL 14/21] vfio/platform: Use vfio_[attach/detach]_device,
Cédric Le Goater <=
- [PULL 13/21] vfio/pci: Introduce vfio_[attach/detach]_device, Cédric Le Goater, 2023/10/06
- [PULL 18/21] vfio/common: Introduce a per container device list, Cédric Le Goater, 2023/10/06
- [PULL 16/21] vfio/ccw: Use vfio_[attach/detach]_device, Cédric Le Goater, 2023/10/06
- [PULL 21/21] vfio/common: Move legacy VFIO backend code into separate container.c, Cédric Le Goater, 2023/10/06
- [PULL 17/21] vfio/common: Move VFIO reset handler registration to a group agnostic function, Cédric Le Goater, 2023/10/06
- [PULL 20/21] vfio/common: Introduce a global VFIODevice list, Cédric Le Goater, 2023/10/06
- [PULL 19/21] vfio/common: Store the parent container in VFIODevice, Cédric Le Goater, 2023/10/06
- Re: [PULL 00/21] vfio queue, Cédric Le Goater, 2023/10/06