qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: "Duan, Zhenzhong" <zhenzhong.duan@intel.com>,
	"eric.auger.pro@gmail.com" <eric.auger.pro@gmail.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
	"mst@redhat.com" <mst@redhat.com>,
	"jean-philippe@linaro.org" <jean-philippe@linaro.org>,
	"imammedo@redhat.com" <imammedo@redhat.com>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"clg@redhat.com" <clg@redhat.com>,
	"yanghliu@redhat.com" <yanghliu@redhat.com>
Cc: "alex.williamson@redhat.com" <alex.williamson@redhat.com>,
	"jasowang@redhat.com" <jasowang@redhat.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"berrange@redhat.com" <berrange@redhat.com>
Subject: Re: [RFC v2 3/7] HostIOMMUDevice: Introduce get_iova_ranges callback
Date: Thu, 13 Jun 2024 10:19:48 +0200	[thread overview]
Message-ID: <29c1416f-48b7-445b-b41d-850223a725d1@redhat.com> (raw)
In-Reply-To: <SJ0PR11MB67446074AA4133BDE258C40392C72@SJ0PR11MB6744.namprd11.prod.outlook.com>

Hi,

On 6/11/24 05:24, Duan, Zhenzhong wrote:
>
>> -----Original Message-----
>> From: Eric Auger <eric.auger@redhat.com>
>> Subject: [RFC v2 3/7] HostIOMMUDevice: Introduce get_iova_ranges
>> callback
>>
>> Introduce a new HostIOMMUDevice callback that allows to
>> retrieve the usable IOVA ranges.
>>
>> Implement this callback in the legacy VFIO and IOMMUFD VFIO
>> host iommu devices. This relies on the VFIODevice agent's
>> base container iova_ranges resource.
>>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> ---
>> include/sysemu/host_iommu_device.h |  8 ++++++++
>> hw/vfio/container.c                | 14 ++++++++++++++
>> hw/vfio/iommufd.c                  | 14 ++++++++++++++
>> 3 files changed, 36 insertions(+)
>>
>> diff --git a/include/sysemu/host_iommu_device.h
>> b/include/sysemu/host_iommu_device.h
>> index 3e5f058e7b..40e0fa13ef 100644
>> --- a/include/sysemu/host_iommu_device.h
>> +++ b/include/sysemu/host_iommu_device.h
>> @@ -80,6 +80,14 @@ struct HostIOMMUDeviceClass {
>>      * i.e., HOST_IOMMU_DEVICE_CAP_AW_BITS.
>>      */
>>     int (*get_cap)(HostIOMMUDevice *hiod, int cap, Error **errp);
>> +    /**
>> +     * @get_iova_ranges: Return the list of usable iova_ranges along with
>> +     * @hiod Host IOMMU device
>> +     *
>> +     * @hiod: handle to the host IOMMU device
>> +     * @errp: error handle
>> +     */
>> +    GList* (*get_iova_ranges)(HostIOMMUDevice *hiod, Error **errp);
> Previous I thought expose iova_ranges directly in HostIOMMUDevice::caps.iova_ranges,
> But a new callback looks better for a Glist pointer.
OK so we are aligned.
>
>> };
>>
>> /*
>> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
>> index b728b978a2..edd0df6262 100644
>> --- a/hw/vfio/container.c
>> +++ b/hw/vfio/container.c
>> @@ -1164,12 +1164,26 @@ static int
>> hiod_legacy_vfio_get_cap(HostIOMMUDevice *hiod, int cap,
>>     }
>> }
>>
>> +static GList *
>> +hiod_legacy_vfio_get_iova_ranges(HostIOMMUDevice *hiod, Error **errp)
>> +{
>> +    VFIODevice *vdev = hiod->agent;
>> +    GList *l = NULL;
> g_assert(vdev)?
yes
>
>> +
>> +    if (vdev && vdev->bcontainer) {
>> +        l = g_list_copy(vdev->bcontainer->iova_ranges);
>> +    }
>> +
>> +    return l;
>> +}
>> +
>> static void hiod_legacy_vfio_class_init(ObjectClass *oc, void *data)
>> {
>>     HostIOMMUDeviceClass *hioc = HOST_IOMMU_DEVICE_CLASS(oc);
>>
>>     hioc->realize = hiod_legacy_vfio_realize;
>>     hioc->get_cap = hiod_legacy_vfio_get_cap;
>> +    hioc->get_iova_ranges = hiod_legacy_vfio_get_iova_ranges;
>> };
>>
>> static const TypeInfo types[] = {
>> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
>> index dbdae1adbb..1706784063 100644
>> --- a/hw/vfio/iommufd.c
>> +++ b/hw/vfio/iommufd.c
>> @@ -645,11 +645,25 @@ static bool
>> hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
>>     return true;
>> }
>>
>> +static GList *
>> +hiod_iommufd_vfio_get_iova_ranges(HostIOMMUDevice *hiod, Error
>> **errp)
>> +{
>> +    VFIODevice *vdev = hiod->agent;
>> +    GList *l = NULL;
>> +
> Same here.
yes

Thanks

Eric
>
> Thanks
> Zhenzhong
>
>> +    if (vdev && vdev->bcontainer) {
>> +        l = g_list_copy(vdev->bcontainer->iova_ranges);
>> +    }
>> +
>> +    return l;
>> +}
>> +
>> static void hiod_iommufd_vfio_class_init(ObjectClass *oc, void *data)
>> {
>>     HostIOMMUDeviceClass *hiodc = HOST_IOMMU_DEVICE_CLASS(oc);
>>
>>     hiodc->realize = hiod_iommufd_vfio_realize;
>> +    hiodc->get_iova_ranges = hiod_iommufd_vfio_get_iova_ranges;
>> };
>>
>> static const TypeInfo types[] = {
>> --
>> 2.41.0



  reply	other threads:[~2024-06-13  8:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-07 14:37 [RFC v2 0/7] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices Eric Auger
2024-06-07 14:37 ` [RFC v2 1/7] HostIOMMUDevice: Store the VFIO/VDPA agent Eric Auger
2024-06-11  3:22   ` Duan, Zhenzhong
2024-06-07 14:37 ` [RFC v2 2/7] virtio-iommu: Implement set|unset]_iommu_device() callbacks Eric Auger
2024-06-11  2:38   ` Duan, Zhenzhong
2024-06-13  8:13     ` Eric Auger
2024-06-07 14:37 ` [RFC v2 3/7] HostIOMMUDevice: Introduce get_iova_ranges callback Eric Auger
2024-06-11  3:24   ` Duan, Zhenzhong
2024-06-13  8:19     ` Eric Auger [this message]
2024-06-07 14:37 ` [RFC v2 4/7] virtio-iommu: Compute host reserved regions Eric Auger
2024-06-11  3:25   ` Duan, Zhenzhong
2024-06-13  9:01     ` Eric Auger
2024-06-13  9:52       ` Duan, Zhenzhong
2024-06-07 14:37 ` [RFC v2 5/7] virtio-iommu: Remove the implementation of iommu_set_iova_range Eric Auger
2024-06-11  3:22   ` Duan, Zhenzhong
2024-06-07 14:37 ` [RFC v2 6/7] hw/vfio: Remove memory_region_iommu_set_iova_ranges() call Eric Auger
2024-06-11  3:23   ` Duan, Zhenzhong
2024-06-07 14:37 ` [RFC v2 7/7] memory: Remove IOMMU MR iommu_set_iova_range API Eric Auger
2024-06-11  3:23   ` Duan, Zhenzhong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=29c1416f-48b7-445b-b41d-850223a725d1@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=berrange@redhat.com \
    --cc=clg@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=imammedo@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jean-philippe@linaro.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=yanghliu@redhat.com \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).