From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
To: "Sergio Lopez Pascual" <slp@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Daniel Verkamp" <dverkamp@chromium.org>,
"Jason Wang" <jasowang@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"David Airlie" <airlied@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Gurchetan Singh" <gurchetansingh@chromium.org>,
"Chia-I Wu" <olvaffe@gmail.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Simona Vetter" <simona@ffwll.ch>,
"Rob Clark" <robdclark@gmail.com>,
fnkl.kernel@gmail.com
Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH RFC v2 4/5] virtio-mmio: read shm region page size
Date: Thu, 20 Feb 2025 16:31:14 +0300 [thread overview]
Message-ID: <ca0dfb6d-4fc6-4963-a092-f4c0b3afb7a4@collabora.com> (raw)
In-Reply-To: <CAAiTLFXihV_DUpd25Mc-OcgsNJ5tVJx7XYsETgxh+7cFuicuHA@mail.gmail.com>
On 2/20/25 13:24, Sergio Lopez Pascual wrote:
> Dmitry Osipenko <dmitry.osipenko@collabora.com> writes:
>
>> 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@redhat.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?
>
> It seems like Linux doesn't support it yet, but in the specs 0x0c0 is
> already reserved for QueueReset.
See QueueReset in the spec now, thanks.
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
--
Best regards,
Dmitry
next prev parent reply other threads:[~2025-02-20 13:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 15:16 [RFC PATCH v2 0/5] virtio: obtain SHM page size from device Sergio Lopez
2025-02-14 15:16 ` [PATCH RFC v2 1/5] virtio_config: add page_size field to virtio_shm_region Sergio Lopez
2025-02-20 3:07 ` Dmitry Osipenko
2025-02-14 15:16 ` [PATCH RFC v2 2/5] virtio: introduce VIRTIO_F_SHM_PAGE_SIZE Sergio Lopez
2025-02-20 3:08 ` Dmitry Osipenko
2025-02-14 15:16 ` [PATCH RFC v2 3/5] virtio-pci: extend virtio_pci_cap with page_shift Sergio Lopez
2025-02-20 3:14 ` Dmitry Osipenko
2025-02-14 15:16 ` [PATCH RFC v2 4/5] virtio-mmio: read shm region page size Sergio Lopez
2025-02-20 3:20 ` Dmitry Osipenko
2025-02-20 10:24 ` Sergio Lopez Pascual
2025-02-20 13:31 ` Dmitry Osipenko [this message]
2025-02-14 15:16 ` [PATCH RFC v2 5/5] drm/virtio: add VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE to params Sergio Lopez
2025-02-14 17:13 ` Dmitry Osipenko
2025-02-17 7:19 ` Sergio Lopez Pascual
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=ca0dfb6d-4fc6-4963-a092-f4c0b3afb7a4@collabora.com \
--to=dmitry.osipenko@collabora.com \
--cc=airlied@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=dverkamp@chromium.org \
--cc=eperezma@redhat.com \
--cc=fnkl.kernel@gmail.com \
--cc=gurchetansingh@chromium.org \
--cc=jasowang@redhat.com \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=mst@redhat.com \
--cc=olvaffe@gmail.com \
--cc=robdclark@gmail.com \
--cc=simona@ffwll.ch \
--cc=slp@redhat.com \
--cc=tzimmermann@suse.de \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.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
all inboxes | Powered by JetHome®