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>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"clg@redhat.com" <clg@redhat.com>,
	"yanghliu@redhat.com" <yanghliu@redhat.com>,
	"alex.williamson@redhat.com" <alex.williamson@redhat.com>
Subject: Re: [PATCH 4/7] HostIOMMUDevice: Introduce get_page_size_mask() callback
Date: Thu, 27 Jun 2024 10:59:34 +0200	[thread overview]
Message-ID: <ca01fa7e-4218-48b5-8c85-e8f7e9e353c9@redhat.com> (raw)
In-Reply-To: <SJ0PR11MB6744E5DF82073F17F2FC31D192D72@SJ0PR11MB6744.namprd11.prod.outlook.com>

Hi Zhenzhong,

On 6/27/24 05:06, Duan, Zhenzhong wrote:
> Hi Eric,
>
>> -----Original Message-----
>> From: Eric Auger <eric.auger@redhat.com>
>> Subject: [PATCH 4/7] HostIOMMUDevice: Introduce get_page_size_mask()
>> callback
>>
>> This callback will be used to retrieve the page size mask supported
>> along a given Host IOMMU device.
>>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> ---
>> include/hw/vfio/vfio-container-base.h |  7 +++++++
>> include/sysemu/host_iommu_device.h    |  8 ++++++++
>> hw/vfio/container.c                   | 10 ++++++++++
>> hw/vfio/iommufd.c                     | 11 +++++++++++
>> 4 files changed, 36 insertions(+)
>>
>> diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-
>> container-base.h
>> index 45d7c40fce..62a8b60d87 100644
>> --- a/include/hw/vfio/vfio-container-base.h
>> +++ b/include/hw/vfio/vfio-container-base.h
>> @@ -88,6 +88,13 @@ int vfio_container_query_dirty_bitmap(const
>> VFIOContainerBase *bcontainer,
>>
>> GList *vfio_container_get_iova_ranges(const VFIOContainerBase
>> *bcontainer);
>>
>> +static inline uint64_t
>> +vfio_container_get_page_size_mask(const VFIOContainerBase *bcontainer)
>> +{
>> +    assert(bcontainer);
>> +    return bcontainer->pgsizes;
>> +}
>> +
>> #define TYPE_VFIO_IOMMU "vfio-iommu"
>> #define TYPE_VFIO_IOMMU_LEGACY TYPE_VFIO_IOMMU "-legacy"
>> #define TYPE_VFIO_IOMMU_SPAPR TYPE_VFIO_IOMMU "-spapr"
>> diff --git a/include/sysemu/host_iommu_device.h
>> b/include/sysemu/host_iommu_device.h
>> index 05c7324a0d..c1bf74ae2c 100644
>> --- a/include/sysemu/host_iommu_device.h
>> +++ b/include/sysemu/host_iommu_device.h
>> @@ -89,6 +89,14 @@ struct HostIOMMUDeviceClass {
>>      * @hiod: handle to the host IOMMU device
>>      */
>>     GList* (*get_iova_ranges)(HostIOMMUDevice *hiod);
>> +    /**
>> +     *
>> +     * @get_page_size_mask: Return the page size mask supported along
>> this
>> +     * @hiod Host IOMMU device
>> +     *
>> +     * @hiod: handle to the host IOMMU device
>> +     */
>> +    uint64_t (*get_page_size_mask)(HostIOMMUDevice *hiod);
> Not sure if it's simpler to utilize existing .get_cap() to get pgsizes.
I chose to introduce a new callback because the page_mask can be U64_MAX
and get_cap is likely to return a negative value. So we could not
distinguish between an error and a full mask.

Thanks

Eric

>
> Thanks
> Zhenzhong
>
>> };
>>
>> /*
>> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
>> index adeab1ac89..b5ce559a0d 100644
>> --- a/hw/vfio/container.c
>> +++ b/hw/vfio/container.c
>> @@ -1174,6 +1174,15 @@
>> hiod_legacy_vfio_get_iova_ranges(HostIOMMUDevice *hiod)
>>     return vfio_container_get_iova_ranges(vdev->bcontainer);
>> }
>>
>> +static uint64_t
>> +hiod_legacy_vfio_get_page_size_mask(HostIOMMUDevice *hiod)
>> +{
>> +    VFIODevice *vdev = hiod->agent;
>> +
>> +    g_assert(vdev);
>> +    return vfio_container_get_page_size_mask(vdev->bcontainer);
>> +}
>> +
>> static void vfio_iommu_legacy_instance_init(Object *obj)
>> {
>>     VFIOContainer *container = VFIO_IOMMU_LEGACY(obj);
>> @@ -1188,6 +1197,7 @@ static void
>> hiod_legacy_vfio_class_init(ObjectClass *oc, void *data)
>>     hioc->realize = hiod_legacy_vfio_realize;
>>     hioc->get_cap = hiod_legacy_vfio_get_cap;
>>     hioc->get_iova_ranges = hiod_legacy_vfio_get_iova_ranges;
>> +    hioc->get_page_size_mask = hiod_legacy_vfio_get_page_size_mask;
>> };
>>
>> static const TypeInfo types[] = {
>> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
>> index 211e7223f1..7b5f87a148 100644
>> --- a/hw/vfio/iommufd.c
>> +++ b/hw/vfio/iommufd.c
>> @@ -652,12 +652,23 @@
>> hiod_iommufd_vfio_get_iova_ranges(HostIOMMUDevice *hiod)
>>     return vfio_container_get_iova_ranges(vdev->bcontainer);
>> }
>>
>> +static uint64_t
>> +hiod_iommufd_vfio_get_page_size_mask(HostIOMMUDevice *hiod)
>> +{
>> +    VFIODevice *vdev = hiod->agent;
>> +
>> +    g_assert(vdev);
>> +    return vfio_container_get_page_size_mask(vdev->bcontainer);
>> +}
>> +
>> +
>> 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;
>> +    hiodc->get_page_size_mask = hiod_iommufd_vfio_get_page_size_mask;
>> };
>>
>> static const TypeInfo types[] = {
>> --
>> 2.41.0



  reply	other threads:[~2024-06-27  9:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-26  8:26 [PATCH 0/7] VIRTIO-IOMMU/HostIOMMUDevice: Fixes and page size mask rework Eric Auger
2024-06-26  8:26 ` [PATCH 1/7] virtio-iommu: Fix error handling in virtio_iommu_set_host_iova_ranges() Eric Auger
2024-06-26 10:39   ` Cédric Le Goater
2024-06-26  8:26 ` [PATCH 2/7] vfio-container-base: Introduce vfio_container_get_iova_ranges() helper Eric Auger
2024-06-26 12:42   ` Cédric Le Goater
2024-06-26  8:26 ` [PATCH 3/7] HostIOMMUDevice : remove Error handle from get_iova_ranges callback Eric Auger
2024-06-26 12:43   ` Cédric Le Goater
2024-06-26  8:26 ` [PATCH 4/7] HostIOMMUDevice: Introduce get_page_size_mask() callback Eric Auger
2024-06-26 12:44   ` Cédric Le Goater
2024-06-27  3:06   ` Duan, Zhenzhong
2024-06-27  8:59     ` Eric Auger [this message]
2024-06-27 11:25       ` Duan, Zhenzhong
2024-06-26  8:26 ` [PATCH 5/7] virtio-iommu : Retrieve page size mask on virtio_iommu_set_iommu_device() Eric Auger
2024-06-27 11:32   ` Duan, Zhenzhong
2024-06-27 13:57     ` Eric Auger
2024-06-26  8:26 ` [PATCH 6/7] memory: remove IOMMU MR iommu_set_page_size_mask() callback Eric Auger
2024-06-26 16:56   ` Cédric Le Goater
2024-06-26  8:26 ` [PATCH 7/7] virtio-iommu: Revert transient enablement of IOMMU MR in bypass mode Eric Auger
2024-06-26 17:10   ` Cédric Le Goater
2024-07-01 20:07 ` [PATCH 0/7] VIRTIO-IOMMU/HostIOMMUDevice: Fixes and page size mask rework Michael S. Tsirkin

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=ca01fa7e-4218-48b5-8c85-e8f7e9e353c9@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=clg@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=jean-philippe@linaro.org \
    --cc=mst@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).