qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 11/11] backends/iommufd: Introduce helper function iommufd


From: Eric Auger
Subject: Re: [PATCH v1 11/11] backends/iommufd: Introduce helper function iommufd_device_get_info()
Date: Mon, 18 Mar 2024 16:11:29 +0100
User-agent: Mozilla Thunderbird

Hi Joao,

On 3/18/24 16:09, Joao Martins wrote:
> On 18/03/2024 07:54, Eric Auger wrote:
>> Hi Zhenzhong,
>>
>> On 2/28/24 04:59, Zhenzhong Duan wrote:
>>> Introduce a helper function iommufd_device_get_info() to get
>>> host IOMMU related information through iommufd uAPI.
>> Looks strange to have this patch in this series. I Would rather put it
>> in your second series alongs with its user.
>>
> The reason it was here was to use this helper for this patch:
>
> https://lore.kernel.org/qemu-devel/20240212135643.5858-2-joao.m.martins@oracle.com/
>
> Instead of me having my own alternate helper.
>
> Though at the same time, Zhenzhong will also make use of it in his second 
> series.
OK I understand now. Maybe with extra comment in the coverletter then

Thanks

Eric
>
>> Eric
>>> 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 d509ff88ef..518b97bfed 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"
>>> @@ -48,4 +49,7 @@ typedef struct IOMMUFDDevice {
>>>  
>>>  void iommufd_device_init(IOMMUFDDevice *idev,
>>>                           IOMMUFDBackend *iommufd, int devid);
>>> +int iommufd_device_get_info(IOMMUFDDevice *idev,
>>> +                            enum iommu_hw_info_type *type,
>>> +                            uint32_t len, void *data, Error **errp);
>>>  #endif
>>> diff --git a/backends/iommufd.c b/backends/iommufd.c
>>> index 6d280e4aea..69f3f75ea5 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)
>>>  {
>>> @@ -240,3 +239,25 @@ void iommufd_device_init(IOMMUFDDevice *idev,
>>>      idev->iommufd = iommufd;
>>>      idev->devid = devid;
>>>  }
>>> +
>>> +int iommufd_device_get_info(IOMMUFDDevice *idev,
>>> +                            enum iommu_hw_info_type *type,
>>> +                            uint32_t len, void *data, Error **errp)
>>> +{
>>> +    struct iommu_hw_info info = {
>>> +        .size = sizeof(info),
>>> +        .dev_id = idev->devid,
>>> +        .data_len = len,
>>> +        .data_uptr = (uintptr_t)data,
>>> +    };
>>> +    int ret;
>>> +
>>> +    ret = ioctl(idev->iommufd->fd, IOMMU_GET_HW_INFO, &info);
>>> +    if (ret) {
>>> +        error_setg_errno(errp, errno, "Failed to get hardware info");
>>> +    } else {
>>> +        *type = info.out_data_type;
>>> +    }
>>> +
>>> +    return ret;
>>> +}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]