[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1f9a86a5-97d6-41d5-9a30-0422fc9ec137@collabora.com>
Date: Thu, 20 Feb 2025 06:20:13 +0300
From: Dmitry Osipenko <dmitry.osipenko@...labora.com>
To: Sergio Lopez <slp@...hat.com>, "Michael S. Tsirkin" <mst@...hat.com>,
Daniel Verkamp <dverkamp@...omium.org>, Jason Wang <jasowang@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>, Eugenio PĂ©rez
<eperezma@...hat.com>, David Airlie <airlied@...hat.com>,
Gerd Hoffmann <kraxel@...hat.com>,
Gurchetan Singh <gurchetansingh@...omium.org>, Chia-I Wu
<olvaffe@...il.com>, Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
Simona Vetter <simona@...ll.ch>, Rob Clark <robdclark@...il.com>,
fnkl.kernel@...il.com
Cc: virtualization@...ts.linux.dev, linux-kernel@...r.kernel.org,
dri-devel@...ts.freedesktop.org
Subject: Re: [PATCH RFC v2 4/5] virtio-mmio: read shm region page size
On 2/14/25 18:16, Sergio Lopez wrote:
> Use the newly introduced SHM_PAGE_SHIFT register to read the page shift
> for the shared memory region, derive the page size from it and store the
> resulting value into virtio_shm_region.
>
> Signed-off-by: Sergio Lopez <slp@...hat.com>
> ---
> drivers/virtio/virtio_mmio.c | 11 ++++++++++-
> include/uapi/linux/virtio_mmio.h | 3 +++
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index 1f594b626d7a7734e8ec58766737a118c26bad94..0f892770739ea84b3e7be5615332773049b10ab1 100644
> --- a/drivers/virtio/virtio_mmio.c
> +++ b/drivers/virtio/virtio_mmio.c
> @@ -537,6 +537,7 @@ static bool vm_get_shm_region(struct virtio_device *vdev,
> struct virtio_shm_region *region, u8 id)
> {
> struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> + u8 page_shift = 0;
> u64 len, addr;
>
> /* Select the region we're interested in */
> @@ -560,7 +561,15 @@ static bool vm_get_shm_region(struct virtio_device *vdev,
>
> region->addr = addr;
>
> - region->page_size = 4096;
> + /* If supported by the device transport, read the region page size.
> + * The page_shift variable is initialized to zero above, so if this
> + * feature isn't supported it will result in a page_size of 4096, a
> + * default safe value.
> + */
> + if (__virtio_test_bit(vdev, VIRTIO_F_SHM_PAGE_SIZE))
> + page_shift = (u8) readl(vm_dev->base + VIRTIO_MMIO_SHM_PAGE_SHIFT);
> +
> + region->page_size = 1 << (page_shift + 12);
>
> return true;
> }
> diff --git a/include/uapi/linux/virtio_mmio.h b/include/uapi/linux/virtio_mmio.h
> index 0650f91bea6c70f935764070d825d181a2379afb..43348be30eff90ee228b6490b9d3c35ba4c50aa5 100644
> --- a/include/uapi/linux/virtio_mmio.h
> +++ b/include/uapi/linux/virtio_mmio.h
> @@ -133,6 +133,9 @@
> #define VIRTIO_MMIO_SHM_BASE_LOW 0x0b8
> #define VIRTIO_MMIO_SHM_BASE_HIGH 0x0bc
>
> +/* Shared memory region page shift */
> +#define VIRTIO_MMIO_SHM_PAGE_SHIFT 0x0c4
What's the logic behind choosing 0x0c4, why not 0x0c0?
--
Best regards,
Dmitry
Powered by blists - more mailing lists