[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH v2 06/10] backends/iommufd: Introduce helper function iommufd
|
From: |
Duan, Zhenzhong |
|
Subject: |
RE: [PATCH v2 06/10] backends/iommufd: Introduce helper function iommufd_backend_get_device_info() |
|
Date: |
Tue, 16 Apr 2024 06:07:30 +0000 |
>-----Original Message-----
>From: Cédric Le Goater <clg@redhat.com>
>Subject: Re: [PATCH v2 06/10] backends/iommufd: Introduce helper
>function iommufd_backend_get_device_info()
>
>On 4/8/24 10:12, Zhenzhong Duan wrote:
>> Introduce a helper function iommufd_backend_get_device_info() to get
>> host IOMMU related information through iommufd uAPI.
>>
>> Signed-off-by: Yi Liu <yi.l.liu@intel.com>
>> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>> ---
>> include/sysemu/iommufd.h | 4 ++++
>> backends/iommufd.c | 23 ++++++++++++++++++++++-
>> 2 files changed, 26 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/sysemu/iommufd.h b/include/sysemu/iommufd.h
>> index 71c53cbb45..fa1a866237 100644
>> --- a/include/sysemu/iommufd.h
>> +++ b/include/sysemu/iommufd.h
>> @@ -4,6 +4,7 @@
>> #include "qom/object.h"
>> #include "exec/hwaddr.h"
>> #include "exec/cpu-common.h"
>> +#include <linux/iommufd.h>
>> #include "sysemu/host_iommu_device.h"
>>
>> #define TYPE_IOMMUFD_BACKEND "iommufd"
>> @@ -34,6 +35,9 @@ int iommufd_backend_map_dma(IOMMUFDBackend
>*be, uint32_t ioas_id, hwaddr iova,
>> ram_addr_t size, void *vaddr, bool readonly);
>> int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t
>ioas_id,
>> hwaddr iova, ram_addr_t size);
>> +int iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t
>devid,
>> + enum iommu_hw_info_type *type,
>> + void *data, uint32_t len, Error **errp);
>>
>> #define TYPE_HIOD_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd"
>> OBJECT_DECLARE_TYPE(HIODIOMMUFD, HIODIOMMUFDClass,
>HIOD_IOMMUFD)
>> diff --git a/backends/iommufd.c b/backends/iommufd.c
>> index ef8b3a808b..559affa9ec 100644
>> --- a/backends/iommufd.c
>> +++ b/backends/iommufd.c
>> @@ -20,7 +20,6 @@
>> #include "monitor/monitor.h"
>> #include "trace.h"
>> #include <sys/ioctl.h>
>> -#include <linux/iommufd.h>
>>
>> static void iommufd_backend_init(Object *obj)
>> {
>> @@ -212,6 +211,28 @@ int
>iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t ioas_id,
>> return ret;
>> }
>>
>> +int iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t
>devid,
>> + enum iommu_hw_info_type *type,
>> + void *data, uint32_t len, Error **errp)
>> +{
>> + struct iommu_hw_info info = {
>> + .size = sizeof(info),
>> + .dev_id = devid,
>> + .data_len = len,
>> + .data_uptr = (uintptr_t)data,
>> + };
>> + int ret;
>> +
>> + ret = ioctl(be->fd, IOMMU_GET_HW_INFO, &info);
>> + if (ret) {
>> + error_setg_errno(errp, errno, "Failed to get hardware info");
>> + } else {
>> + *type = info.out_data_type;
>
>type should not be NULL.
Yes, will add g_assert(type);
Thanks
Zhenzhong
- [PATCH v2 03/10] backends/iommufd: Introduce abstract HIODIOMMUFD device, (continued)
- [PATCH v2 03/10] backends/iommufd: Introduce abstract HIODIOMMUFD device, Zhenzhong Duan, 2024/04/08
- [PATCH v2 04/10] vfio/iommufd: Introduce HIODIOMMUFDVFIO device, Zhenzhong Duan, 2024/04/08
- [PATCH v2 05/10] vfio: Implement get_host_iommu_info() callback, Zhenzhong Duan, 2024/04/08
- [PATCH v2 06/10] backends/iommufd: Introduce helper function iommufd_backend_get_device_info(), Zhenzhong Duan, 2024/04/08
- [PATCH v2 07/10] backends/iommufd: Implement get_host_iommu_info() callback, Zhenzhong Duan, 2024/04/08
- [PATCH v2 08/10] vfio: Create host IOMMU device instance, Zhenzhong Duan, 2024/04/08
- [PATCH v2 10/10] vfio: Pass HostIOMMUDevice to vIOMMU, Zhenzhong Duan, 2024/04/08
- [PATCH v2 09/10] hw/pci: Introduce pci_device_set/unset_iommu_device(), Zhenzhong Duan, 2024/04/08