* [PATCH RFC v2 1/5] virtio_config: add page_size field to virtio_shm_region
2025-02-14 15:16 [RFC PATCH v2 0/5] virtio: obtain SHM page size from device Sergio Lopez
@ 2025-02-14 15:16 ` 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
` (3 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Sergio Lopez @ 2025-02-14 15:16 UTC (permalink / raw)
To: Michael S. Tsirkin, Daniel Verkamp, Jason Wang, Xuan Zhuo,
Eugenio Pérez, David Airlie, Gerd Hoffmann, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter, Rob Clark, Dmitry Osipenko, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel, Sergio Lopez
Add a page_size field to virtio_shm_region to store page size supported
by the device. This is required to support running VMs with a page size
smaller than the host, among other potential scenarios.
Signed-off-by: Sergio Lopez <slp@redhat.com>
---
drivers/virtio/virtio_mmio.c | 2 ++
drivers/virtio/virtio_pci_modern.c | 1 +
include/linux/virtio_config.h | 1 +
3 files changed, 4 insertions(+)
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 5d78c2d572abfcfe2b84cdd82df622320fe97d5d..1f594b626d7a7734e8ec58766737a118c26bad94 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -560,6 +560,8 @@ static bool vm_get_shm_region(struct virtio_device *vdev,
region->addr = addr;
+ region->page_size = 4096;
+
return true;
}
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index 5eaade7578606e4b02af0d66447417ad6aa11064..d7aeb2e50a3c499dfb68d58cb89b829ea2e50454 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -862,6 +862,7 @@ static bool vp_get_shm_region(struct virtio_device *vdev,
region->len = len;
region->addr = (u64) phys_addr + offset;
+ region->page_size = 4096;
return true;
}
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 169c7d367facb36dcabf9596068580ea8b8516c7..c1b2ce71ea55e81978e18db05494deab193fa4fb 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -14,6 +14,7 @@ struct irq_affinity;
struct virtio_shm_region {
u64 addr;
u64 len;
+ u32 page_size;
};
typedef void vq_callback_t(struct virtqueue *);
--
2.48.1
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH RFC v2 1/5] virtio_config: add page_size field to virtio_shm_region
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
0 siblings, 0 replies; 14+ messages in thread
From: Dmitry Osipenko @ 2025-02-20 3:07 UTC (permalink / raw)
To: Sergio Lopez, Michael S. Tsirkin, Daniel Verkamp, Jason Wang,
Xuan Zhuo, Eugenio Pérez, David Airlie, Gerd Hoffmann,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, Simona Vetter, Rob Clark, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel
On 2/14/25 18:16, Sergio Lopez wrote:
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index 5d78c2d572abfcfe2b84cdd82df622320fe97d5d..1f594b626d7a7734e8ec58766737a118c26bad94 100644
> --- a/drivers/virtio/virtio_mmio.c
> +++ b/drivers/virtio/virtio_mmio.c
> @@ -560,6 +560,8 @@ static bool vm_get_shm_region(struct virtio_device *vdev,
>
> region->addr = addr;
>
> + region->page_size = 4096;
> +
> return true;
> }
>
> diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
> index 5eaade7578606e4b02af0d66447417ad6aa11064..d7aeb2e50a3c499dfb68d58cb89b829ea2e50454 100644
> --- a/drivers/virtio/virtio_pci_modern.c
> +++ b/drivers/virtio/virtio_pci_modern.c
> @@ -862,6 +862,7 @@ static bool vp_get_shm_region(struct virtio_device *vdev,
>
> region->len = len;
> region->addr = (u64) phys_addr + offset;
> + region->page_size = 4096;
>
> return true;
> }
> diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
> index 169c7d367facb36dcabf9596068580ea8b8516c7..c1b2ce71ea55e81978e18db05494deab193fa4fb 100644
> --- a/include/linux/virtio_config.h
> +++ b/include/linux/virtio_config.h
> @@ -14,6 +14,7 @@ struct irq_affinity;
> struct virtio_shm_region {
> u64 addr;
> u64 len;
> + u32 page_size;
> };
Nit: I'd squash this into patches #3/4, to not add code that is changed
by a next patch.
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH RFC v2 2/5] virtio: introduce VIRTIO_F_SHM_PAGE_SIZE
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-14 15:16 ` 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
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Sergio Lopez @ 2025-02-14 15:16 UTC (permalink / raw)
To: Michael S. Tsirkin, Daniel Verkamp, Jason Wang, Xuan Zhuo,
Eugenio Pérez, David Airlie, Gerd Hoffmann, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter, Rob Clark, Dmitry Osipenko, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel, Sergio Lopez
Introduce VIRTIO_F_SHM_PAGE_SIZE, a feature bit which indicates that the
transport provides the page size for SHM regions.
Signed-off-by: Sergio Lopez <slp@redhat.com>
---
drivers/virtio/virtio_pci_modern.c | 3 +++
drivers/virtio/virtio_ring.c | 2 ++
include/uapi/linux/virtio_config.h | 7 ++++++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index d7aeb2e50a3c499dfb68d58cb89b829ea2e50454..ab0e1d9148057c431676bfacfe5f68cc97eebb12 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -367,6 +367,9 @@ static void vp_transport_features(struct virtio_device *vdev, u64 features)
if (features & BIT_ULL(VIRTIO_F_ADMIN_VQ))
__virtio_set_bit(vdev, VIRTIO_F_ADMIN_VQ);
+
+ if (features & BIT_ULL(VIRTIO_F_SHM_PAGE_SIZE))
+ __virtio_set_bit(vdev, VIRTIO_F_SHM_PAGE_SIZE);
}
static int __vp_check_common_size_one_feature(struct virtio_device *vdev, u32 fbit,
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index fdd2d2b07b5a2aca864bc917306536685afb66a6..d853d5cf7e553be8bbe0ff461dc7312b258c6e58 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -2983,6 +2983,8 @@ void vring_transport_features(struct virtio_device *vdev)
break;
case VIRTIO_F_NOTIFICATION_DATA:
break;
+ case VIRTIO_F_SHM_PAGE_SIZE:
+ break;
default:
/* We don't understand this bit. */
__virtio_clear_bit(vdev, i);
diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h
index 2445f365bce74b4e926c6929322b269252ab6830..3171e3792263c2cd472ac09da18e593ab400751d 100644
--- a/include/uapi/linux/virtio_config.h
+++ b/include/uapi/linux/virtio_config.h
@@ -52,7 +52,7 @@
* rest are per-device feature bits.
*/
#define VIRTIO_TRANSPORT_F_START 28
-#define VIRTIO_TRANSPORT_F_END 42
+#define VIRTIO_TRANSPORT_F_END 43
#ifndef VIRTIO_CONFIG_NO_LEGACY
/* Do we get callbacks when the ring is completely used, even if we've
@@ -120,4 +120,9 @@
*/
#define VIRTIO_F_ADMIN_VQ 41
+/*
+ * This feature indicates that the transport provides the SHM page size.
+ */
+#define VIRTIO_F_SHM_PAGE_SIZE 42
+
#endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */
--
2.48.1
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH RFC v2 2/5] virtio: introduce VIRTIO_F_SHM_PAGE_SIZE
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
0 siblings, 0 replies; 14+ messages in thread
From: Dmitry Osipenko @ 2025-02-20 3:08 UTC (permalink / raw)
To: Sergio Lopez, Michael S. Tsirkin, Daniel Verkamp, Jason Wang,
Xuan Zhuo, Eugenio Pérez, David Airlie, Gerd Hoffmann,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, Simona Vetter, Rob Clark, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel
On 2/14/25 18:16, Sergio Lopez wrote:
> Introduce VIRTIO_F_SHM_PAGE_SIZE, a feature bit which indicates that the
> transport provides the page size for SHM regions.
>
> Signed-off-by: Sergio Lopez <slp@redhat.com>
> ---
> drivers/virtio/virtio_pci_modern.c | 3 +++
> drivers/virtio/virtio_ring.c | 2 ++
> include/uapi/linux/virtio_config.h | 7 ++++++-
> 3 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
> index d7aeb2e50a3c499dfb68d58cb89b829ea2e50454..ab0e1d9148057c431676bfacfe5f68cc97eebb12 100644
> --- a/drivers/virtio/virtio_pci_modern.c
> +++ b/drivers/virtio/virtio_pci_modern.c
> @@ -367,6 +367,9 @@ static void vp_transport_features(struct virtio_device *vdev, u64 features)
>
> if (features & BIT_ULL(VIRTIO_F_ADMIN_VQ))
> __virtio_set_bit(vdev, VIRTIO_F_ADMIN_VQ);
> +
> + if (features & BIT_ULL(VIRTIO_F_SHM_PAGE_SIZE))
> + __virtio_set_bit(vdev, VIRTIO_F_SHM_PAGE_SIZE);
> }
>
> static int __vp_check_common_size_one_feature(struct virtio_device *vdev, u32 fbit,
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index fdd2d2b07b5a2aca864bc917306536685afb66a6..d853d5cf7e553be8bbe0ff461dc7312b258c6e58 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -2983,6 +2983,8 @@ void vring_transport_features(struct virtio_device *vdev)
> break;
> case VIRTIO_F_NOTIFICATION_DATA:
> break;
> + case VIRTIO_F_SHM_PAGE_SIZE:
> + break;
> default:
> /* We don't understand this bit. */
> __virtio_clear_bit(vdev, i);
> diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h
> index 2445f365bce74b4e926c6929322b269252ab6830..3171e3792263c2cd472ac09da18e593ab400751d 100644
> --- a/include/uapi/linux/virtio_config.h
> +++ b/include/uapi/linux/virtio_config.h
> @@ -52,7 +52,7 @@
> * rest are per-device feature bits.
> */
> #define VIRTIO_TRANSPORT_F_START 28
> -#define VIRTIO_TRANSPORT_F_END 42
> +#define VIRTIO_TRANSPORT_F_END 43
>
> #ifndef VIRTIO_CONFIG_NO_LEGACY
> /* Do we get callbacks when the ring is completely used, even if we've
> @@ -120,4 +120,9 @@
> */
> #define VIRTIO_F_ADMIN_VQ 41
>
> +/*
> + * This feature indicates that the transport provides the SHM page size.
> + */
> +#define VIRTIO_F_SHM_PAGE_SIZE 42
> +
> #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */
>
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH RFC v2 3/5] virtio-pci: extend virtio_pci_cap with page_shift
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-14 15:16 ` [PATCH RFC v2 2/5] virtio: introduce VIRTIO_F_SHM_PAGE_SIZE Sergio Lopez
@ 2025-02-14 15:16 ` 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-14 15:16 ` [PATCH RFC v2 5/5] drm/virtio: add VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE to params Sergio Lopez
4 siblings, 1 reply; 14+ messages in thread
From: Sergio Lopez @ 2025-02-14 15:16 UTC (permalink / raw)
To: Michael S. Tsirkin, Daniel Verkamp, Jason Wang, Xuan Zhuo,
Eugenio Pérez, David Airlie, Gerd Hoffmann, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter, Rob Clark, Dmitry Osipenko, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel, Sergio Lopez
If VIRTIO_F_SHM_PAGE_SIZE has been negotiated and cfg_type is
VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, the driver must read the page_shift
field, derive the supported page size from it, and honor it when
requesting the map of memory into the shared memory region to the
device.
Extend virtio_pci_cap to hold that field, and use it to feed
virtio_shm_region with the corresponding page size.
Signed-off-by: Sergio Lopez <slp@redhat.com>
---
drivers/virtio/virtio_pci_modern.c | 22 +++++++++++++++++-----
include/uapi/linux/virtio_pci.h | 3 ++-
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index ab0e1d9148057c431676bfacfe5f68cc97eebb12..562a8e1c2bfe6876cffabe26f02cd61ad7fea2cd 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -770,14 +770,15 @@ static void del_vq(struct virtio_pci_vq_info *info)
vring_del_virtqueue(vq);
}
-static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id,
- u8 *bar, u64 *offset, u64 *len)
+static int virtio_pci_find_shm_cap(struct virtio_device *vdev, struct pci_dev *dev,
+ u8 required_id, u8 *bar, u64 *offset, u64 *len,
+ u32 *page_size)
{
int pos;
for (pos = pci_find_capability(dev, PCI_CAP_ID_VNDR); pos > 0;
pos = pci_find_next_capability(dev, pos, PCI_CAP_ID_VNDR)) {
- u8 type, cap_len, id, res_bar;
+ u8 type, cap_len, id, res_bar, page_shift = 0;
u32 tmp32;
u64 res_offset, res_length;
@@ -808,6 +809,15 @@ static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id,
* Looks good.
*/
+ /* Read the page shift if supported. 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)) {
+ pci_read_config_byte(dev, pos + offsetof(struct virtio_pci_cap,
+ page_shift), &page_shift);
+ }
+
/* Read the lower 32bit of length and offset */
pci_read_config_dword(dev, pos + offsetof(struct virtio_pci_cap,
offset), &tmp32);
@@ -829,6 +839,7 @@ static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id,
*bar = res_bar;
*offset = res_offset;
*len = res_length;
+ *page_size = 1 << (page_shift + 12);
return pos;
}
@@ -841,11 +852,12 @@ static bool vp_get_shm_region(struct virtio_device *vdev,
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
struct pci_dev *pci_dev = vp_dev->pci_dev;
u8 bar;
+ u32 page_size;
u64 offset, len;
phys_addr_t phys_addr;
size_t bar_len;
- if (!virtio_pci_find_shm_cap(pci_dev, id, &bar, &offset, &len))
+ if (!virtio_pci_find_shm_cap(vdev, pci_dev, id, &bar, &offset, &len, &page_size))
return false;
phys_addr = pci_resource_start(pci_dev, bar);
@@ -865,7 +877,7 @@ static bool vp_get_shm_region(struct virtio_device *vdev,
region->len = len;
region->addr = (u64) phys_addr + offset;
- region->page_size = 4096;
+ region->page_size = page_size;
return true;
}
diff --git a/include/uapi/linux/virtio_pci.h b/include/uapi/linux/virtio_pci.h
index 8549d4571257142ac6c9dad5c01369923791a85a..1a76df52b4eccf548df78a8ee7d3a04591f55522 100644
--- a/include/uapi/linux/virtio_pci.h
+++ b/include/uapi/linux/virtio_pci.h
@@ -127,7 +127,8 @@ struct virtio_pci_cap {
__u8 cfg_type; /* Identifies the structure. */
__u8 bar; /* Where to find it. */
__u8 id; /* Multiple capabilities of the same type */
- __u8 padding[2]; /* Pad to full dword. */
+ __u8 page_shift; /* Page shift for VIRTIO_PCI_CAP_SHARED_MEMORY_CFG. */
+ __u8 padding[1]; /* Pad to full dword. */
__le32 offset; /* Offset within bar. */
__le32 length; /* Length of the structure, in bytes. */
};
--
2.48.1
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH RFC v2 3/5] virtio-pci: extend virtio_pci_cap with page_shift
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
0 siblings, 0 replies; 14+ messages in thread
From: Dmitry Osipenko @ 2025-02-20 3:14 UTC (permalink / raw)
To: Sergio Lopez, Michael S. Tsirkin, Daniel Verkamp, Jason Wang,
Xuan Zhuo, Eugenio Pérez, David Airlie, Gerd Hoffmann,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, Simona Vetter, Rob Clark, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel
On 2/14/25 18:16, Sergio Lopez wrote:
> If VIRTIO_F_SHM_PAGE_SIZE has been negotiated and cfg_type is
> VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, the driver must read the page_shift
> field, derive the supported page size from it, and honor it when
> requesting the map of memory into the shared memory region to the
> device.
>
> Extend virtio_pci_cap to hold that field, and use it to feed
> virtio_shm_region with the corresponding page size.
>
> Signed-off-by: Sergio Lopez <slp@redhat.com>
> ---
> drivers/virtio/virtio_pci_modern.c | 22 +++++++++++++++++-----
> include/uapi/linux/virtio_pci.h | 3 ++-
> 2 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
> index ab0e1d9148057c431676bfacfe5f68cc97eebb12..562a8e1c2bfe6876cffabe26f02cd61ad7fea2cd 100644
> --- a/drivers/virtio/virtio_pci_modern.c
> +++ b/drivers/virtio/virtio_pci_modern.c
> @@ -770,14 +770,15 @@ static void del_vq(struct virtio_pci_vq_info *info)
> vring_del_virtqueue(vq);
> }
>
> -static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id,
> - u8 *bar, u64 *offset, u64 *len)
> +static int virtio_pci_find_shm_cap(struct virtio_device *vdev, struct pci_dev *dev,
> + u8 required_id, u8 *bar, u64 *offset, u64 *len,
> + u32 *page_size)
> {
> int pos;
>
> for (pos = pci_find_capability(dev, PCI_CAP_ID_VNDR); pos > 0;
> pos = pci_find_next_capability(dev, pos, PCI_CAP_ID_VNDR)) {
> - u8 type, cap_len, id, res_bar;
> + u8 type, cap_len, id, res_bar, page_shift = 0;
> u32 tmp32;
> u64 res_offset, res_length;
>
> @@ -808,6 +809,15 @@ static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id,
> * Looks good.
> */
>
> + /* Read the page shift if supported. 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)) {
> + pci_read_config_byte(dev, pos + offsetof(struct virtio_pci_cap,
> + page_shift), &page_shift);
> + }
> +
> /* Read the lower 32bit of length and offset */
> pci_read_config_dword(dev, pos + offsetof(struct virtio_pci_cap,
> offset), &tmp32);
> @@ -829,6 +839,7 @@ static int virtio_pci_find_shm_cap(struct pci_dev *dev, u8 required_id,
> *bar = res_bar;
> *offset = res_offset;
> *len = res_length;
> + *page_size = 1 << (page_shift + 12);
>
> return pos;
> }
> @@ -841,11 +852,12 @@ static bool vp_get_shm_region(struct virtio_device *vdev,
> struct virtio_pci_device *vp_dev = to_vp_device(vdev);
> struct pci_dev *pci_dev = vp_dev->pci_dev;
> u8 bar;
> + u32 page_size;
> u64 offset, len;
> phys_addr_t phys_addr;
> size_t bar_len;
>
> - if (!virtio_pci_find_shm_cap(pci_dev, id, &bar, &offset, &len))
> + if (!virtio_pci_find_shm_cap(vdev, pci_dev, id, &bar, &offset, &len, &page_size))
> return false;
>
> phys_addr = pci_resource_start(pci_dev, bar);
> @@ -865,7 +877,7 @@ static bool vp_get_shm_region(struct virtio_device *vdev,
>
> region->len = len;
> region->addr = (u64) phys_addr + offset;
> - region->page_size = 4096;
> + region->page_size = page_size;
>
> return true;
> }
> diff --git a/include/uapi/linux/virtio_pci.h b/include/uapi/linux/virtio_pci.h
> index 8549d4571257142ac6c9dad5c01369923791a85a..1a76df52b4eccf548df78a8ee7d3a04591f55522 100644
> --- a/include/uapi/linux/virtio_pci.h
> +++ b/include/uapi/linux/virtio_pci.h
> @@ -127,7 +127,8 @@ struct virtio_pci_cap {
> __u8 cfg_type; /* Identifies the structure. */
> __u8 bar; /* Where to find it. */
> __u8 id; /* Multiple capabilities of the same type */
> - __u8 padding[2]; /* Pad to full dword. */
> + __u8 page_shift; /* Page shift for VIRTIO_PCI_CAP_SHARED_MEMORY_CFG. */
> + __u8 padding[1]; /* Pad to full dword. */
> __le32 offset; /* Offset within bar. */
> __le32 length; /* Length of the structure, in bytes. */
> };
>
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH RFC v2 4/5] virtio-mmio: read shm region page size
2025-02-14 15:16 [RFC PATCH v2 0/5] virtio: obtain SHM page size from device Sergio Lopez
` (2 preceding siblings ...)
2025-02-14 15:16 ` [PATCH RFC v2 3/5] virtio-pci: extend virtio_pci_cap with page_shift Sergio Lopez
@ 2025-02-14 15:16 ` Sergio Lopez
2025-02-20 3:20 ` Dmitry Osipenko
2025-02-14 15:16 ` [PATCH RFC v2 5/5] drm/virtio: add VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE to params Sergio Lopez
4 siblings, 1 reply; 14+ messages in thread
From: Sergio Lopez @ 2025-02-14 15:16 UTC (permalink / raw)
To: Michael S. Tsirkin, Daniel Verkamp, Jason Wang, Xuan Zhuo,
Eugenio Pérez, David Airlie, Gerd Hoffmann, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter, Rob Clark, Dmitry Osipenko, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel, Sergio Lopez
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
+
/* Configuration atomicity value */
#define VIRTIO_MMIO_CONFIG_GENERATION 0x0fc
--
2.48.1
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH RFC v2 4/5] virtio-mmio: read shm region page size
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
0 siblings, 1 reply; 14+ messages in thread
From: Dmitry Osipenko @ 2025-02-20 3:20 UTC (permalink / raw)
To: Sergio Lopez, Michael S. Tsirkin, Daniel Verkamp, Jason Wang,
Xuan Zhuo, Eugenio Pérez, David Airlie, Gerd Hoffmann,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, Simona Vetter, Rob Clark, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel
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?
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH RFC v2 4/5] virtio-mmio: read shm region page size
2025-02-20 3:20 ` Dmitry Osipenko
@ 2025-02-20 10:24 ` Sergio Lopez Pascual
2025-02-20 13:31 ` Dmitry Osipenko
0 siblings, 1 reply; 14+ messages in thread
From: Sergio Lopez Pascual @ 2025-02-20 10:24 UTC (permalink / raw)
To: Dmitry Osipenko, Michael S. Tsirkin, Daniel Verkamp, Jason Wang,
Xuan Zhuo, Eugenio Pérez, David Airlie, Gerd Hoffmann,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, Simona Vetter, Rob Clark, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel
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.
Sergio.
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH RFC v2 4/5] virtio-mmio: read shm region page size
2025-02-20 10:24 ` Sergio Lopez Pascual
@ 2025-02-20 13:31 ` Dmitry Osipenko
0 siblings, 0 replies; 14+ messages in thread
From: Dmitry Osipenko @ 2025-02-20 13:31 UTC (permalink / raw)
To: Sergio Lopez Pascual, Michael S. Tsirkin, Daniel Verkamp,
Jason Wang, Xuan Zhuo, Eugenio Pérez, David Airlie,
Gerd Hoffmann, Gurchetan Singh, Chia-I Wu, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Simona Vetter, Rob Clark,
fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH RFC v2 5/5] drm/virtio: add VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE to params
2025-02-14 15:16 [RFC PATCH v2 0/5] virtio: obtain SHM page size from device Sergio Lopez
` (3 preceding siblings ...)
2025-02-14 15:16 ` [PATCH RFC v2 4/5] virtio-mmio: read shm region page size Sergio Lopez
@ 2025-02-14 15:16 ` Sergio Lopez
2025-02-14 17:13 ` Dmitry Osipenko
4 siblings, 1 reply; 14+ messages in thread
From: Sergio Lopez @ 2025-02-14 15:16 UTC (permalink / raw)
To: Michael S. Tsirkin, Daniel Verkamp, Jason Wang, Xuan Zhuo,
Eugenio Pérez, David Airlie, Gerd Hoffmann, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter, Rob Clark, Dmitry Osipenko, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel, Sergio Lopez
Add VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE as a param that can be read with
VIRTGPU_GETPARAM by userspace applications running in the guest to
obtain the host's page size and find out the right alignment to be used
in shared memory allocations.
Signed-off-by: Sergio Lopez <slp@redhat.com>
---
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 5 +++++
include/uapi/drm/virtgpu_drm.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index c33c057365f85a2ace536f91655c903036827312..4b49635b4fe1d4256f219823341cef8e5fa8f029 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -117,6 +117,11 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data,
case VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME:
value = vgdev->has_context_init ? 1 : 0;
break;
+ case VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE:
+ if (!vgdev->has_host_visible)
+ return -EINVAL;
+ value = vgdev->host_visible_region.page_size;
+ break;
default:
return -EINVAL;
}
diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h
index c2ce71987e9bb816d13a300679336cb756f1cbcf..72db6b3339e0dcaf550acbf5ac4381a6e5c2216d 100644
--- a/include/uapi/drm/virtgpu_drm.h
+++ b/include/uapi/drm/virtgpu_drm.h
@@ -98,6 +98,7 @@ struct drm_virtgpu_execbuffer {
#define VIRTGPU_PARAM_CONTEXT_INIT 6 /* DRM_VIRTGPU_CONTEXT_INIT */
#define VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs 7 /* Bitmask of supported capability set ids */
#define VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME 8 /* Ability to set debug name from userspace */
+#define VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE 9 /* Host SHM page size, with format PAGE_SIZE >> 12 */
struct drm_virtgpu_getparam {
__u64 param;
--
2.48.1
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH RFC v2 5/5] drm/virtio: add VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE to params
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
0 siblings, 1 reply; 14+ messages in thread
From: Dmitry Osipenko @ 2025-02-14 17:13 UTC (permalink / raw)
To: Sergio Lopez, Michael S. Tsirkin, Daniel Verkamp, Jason Wang,
Xuan Zhuo, Eugenio Pérez, David Airlie, Gerd Hoffmann,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, Simona Vetter, Rob Clark, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel
On 2/14/25 18:16, Sergio Lopez wrote:
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index c33c057365f85a2ace536f91655c903036827312..4b49635b4fe1d4256f219823341cef8e5fa8f029 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> @@ -117,6 +117,11 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data,
> case VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME:
> value = vgdev->has_context_init ? 1 : 0;
> break;
> + case VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE:
> + if (!vgdev->has_host_visible)
> + return -EINVAL;
Nit: virtio_gpu_getparam_ioctl() returns EINVAL for unsupported params.
While this is a supported param, but there is no hostmem available.
Hence, should a different error code, maybe ENOENT or ENXIO.
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH RFC v2 5/5] drm/virtio: add VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE to params
2025-02-14 17:13 ` Dmitry Osipenko
@ 2025-02-17 7:19 ` Sergio Lopez Pascual
0 siblings, 0 replies; 14+ messages in thread
From: Sergio Lopez Pascual @ 2025-02-17 7:19 UTC (permalink / raw)
To: Dmitry Osipenko, Michael S. Tsirkin, Daniel Verkamp, Jason Wang,
Xuan Zhuo, Eugenio Pérez, David Airlie, Gerd Hoffmann,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, Simona Vetter, Rob Clark, fnkl.kernel
Cc: virtualization, linux-kernel, dri-devel
Dmitry Osipenko <dmitry.osipenko@collabora.com> writes:
> On 2/14/25 18:16, Sergio Lopez wrote:
>> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
>> index c33c057365f85a2ace536f91655c903036827312..4b49635b4fe1d4256f219823341cef8e5fa8f029 100644
>> --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
>> +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
>> @@ -117,6 +117,11 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data,
>> case VIRTGPU_PARAM_EXPLICIT_DEBUG_NAME:
>> value = vgdev->has_context_init ? 1 : 0;
>> break;
>> + case VIRTGPU_PARAM_HOST_SHM_PAGE_SIZE:
>> + if (!vgdev->has_host_visible)
>> + return -EINVAL;
>
> Nit: virtio_gpu_getparam_ioctl() returns EINVAL for unsupported params.
> While this is a supported param, but there is no hostmem available.
> Hence, should a different error code, maybe ENOENT or ENXIO.
Good point. I'll update it to return ENOENT in v3.
Thanks,
Sergio.
^ permalink raw reply [flat|nested] 14+ messages in thread