mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature
@ 2025-04-02 17:45 Sergio Lopez
  2025-04-02 17:46 ` [PATCH v2 1/2] " Sergio Lopez
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Sergio Lopez @ 2025-04-02 17:45 UTC (permalink / raw)
  To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Gurchetan Singh, Rob Clark, Dmitry Osipenko
  Cc: dri-devel, virtualization, linux-kernel, Sergio Lopez

There's an incresing number of machines supporting multiple page sizes
and on these machines the host and a guest can be running, each one,
with a different page size.

For what pertains to virtio-gpu, this is not a problem if the page size
of the guest happens to be bigger or equal than the host, but will
potentially lead to failures in memory allocations and/or mappings
otherwise.

To improve this situation, we introduce here the HOST_PAGE_SIZE feature.
This feature indicates that the host has an extended virtio_gpu_config
structure that include it's own page size a new field.

On the second commit, we also add a new 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.

There has been a discussion in virtio-comments about whether the
information about alignment restrictions must be shared in a generic or
in a device-specific way, favoring the latter:

https://lore.kernel.org/virtio-comment/CY8PR12MB7195B5E575099CD9CA1F2F39DCAF2@CY8PR12MB7195.namprd12.prod.outlook.com/T/#t

v2:
 - Rebase on top of current upstream.
 - Make a reference in the cover to the discussion about how device
   page alignment restrictions should be shared with the driver.

Signed-off-by: Sergio Lopez <slp@redhat.com>
---
Sergio Lopez (2):
      drm/virtio: introduce the HOST_PAGE_SIZE feature
      drm/virtio: add VIRTGPU_PARAM_HOST_PAGE_SIZE to params

 drivers/gpu/drm/virtio/virtgpu_drv.c   |  1 +
 drivers/gpu/drm/virtio/virtgpu_drv.h   |  2 ++
 drivers/gpu/drm/virtio/virtgpu_ioctl.c |  5 +++++
 drivers/gpu/drm/virtio/virtgpu_kms.c   | 13 ++++++++++---
 include/uapi/drm/virtgpu_drm.h         |  1 +
 include/uapi/linux/virtio_gpu.h        |  5 +++++
 6 files changed, 24 insertions(+), 3 deletions(-)
---
base-commit: acc4d5ff0b61eb1715c498b6536c38c1feb7f3c1
change-id: 20250402-virtio-gpu-host-page-size-282c99dfe44c

Best regards,
-- 
Sergio Lopez <slp@redhat.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] drm/virtio: introduce the HOST_PAGE_SIZE feature
  2025-04-02 17:45 [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature Sergio Lopez
@ 2025-04-02 17:46 ` Sergio Lopez
  2025-04-02 17:55   ` Dmitry Osipenko
  2025-04-02 17:46 ` [PATCH v2 2/2] drm/virtio: add VIRTGPU_PARAM_HOST_PAGE_SIZE to params Sergio Lopez
  2025-10-24  4:03 ` [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature Dmitry Osipenko
  2 siblings, 1 reply; 8+ messages in thread
From: Sergio Lopez @ 2025-04-02 17:46 UTC (permalink / raw)
  To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Gurchetan Singh, Rob Clark, Dmitry Osipenko
  Cc: dri-devel, virtualization, linux-kernel, Sergio Lopez

Introduce a new feature, HOST_PAGE_SIZE, that indicates the host
provides its page size as a value in virtio_gpu_config.

Signed-off-by: Sergio Lopez <slp@redhat.com>
---
 drivers/gpu/drm/virtio/virtgpu_drv.c |  1 +
 drivers/gpu/drm/virtio/virtgpu_drv.h |  2 ++
 drivers/gpu/drm/virtio/virtgpu_kms.c | 13 ++++++++++---
 include/uapi/linux/virtio_gpu.h      |  5 +++++
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
index 2d88e390feb468bf8783f13d90d0c4759dff0dcf..2e81aeaffdc6924dd88fb0778edef22084526866 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -154,6 +154,7 @@ static unsigned int features[] = {
 	VIRTIO_GPU_F_RESOURCE_UUID,
 	VIRTIO_GPU_F_RESOURCE_BLOB,
 	VIRTIO_GPU_F_CONTEXT_INIT,
+	VIRTIO_GPU_F_HOST_PAGE_SIZE,
 };
 static struct virtio_driver virtio_gpu_driver = {
 	.feature_table = features,
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index f17660a71a3e7a22b5d4fefa6b754c227a294037..439223b5f7cf8c9a120a28b7b7d57516928112e7 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -257,6 +257,7 @@ struct virtio_gpu_device {
 	bool has_resource_blob;
 	bool has_host_visible;
 	bool has_context_init;
+	bool has_host_page_size;
 	struct virtio_shm_region host_visible_region;
 	struct drm_mm host_visible_mm;
 
@@ -270,6 +271,7 @@ struct virtio_gpu_device {
 	uint32_t num_capsets;
 	uint64_t capset_id_mask;
 	struct list_head cap_cache;
+	uint32_t host_page_size;
 
 	/* protects uuid state when exporting */
 	spinlock_t resource_export_lock;
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index 7dfb2006c561ca13b15d979ddb8bf2d753e35dad..4ab95712434615c2cc35f2ff80d33b40c4212cfb 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -123,7 +123,7 @@ int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev)
 	struct virtio_gpu_device *vgdev;
 	/* this will expand later */
 	struct virtqueue *vqs[2];
-	u32 num_scanouts, num_capsets;
+	u32 num_scanouts, num_capsets, host_page_size;
 	int ret = 0;
 
 	if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1))
@@ -196,6 +196,12 @@ int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev)
 	if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_CONTEXT_INIT)) {
 		vgdev->has_context_init = true;
 	}
+	if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_HOST_PAGE_SIZE)) {
+		vgdev->has_host_page_size = true;
+		virtio_cread_le(vgdev->vdev, struct virtio_gpu_config,
+				host_page_size, &host_page_size);
+		vgdev->host_page_size = host_page_size;
+	}
 
 	DRM_INFO("features: %cvirgl %cedid %cresource_blob %chost_visible",
 		 vgdev->has_virgl_3d    ? '+' : '-',
@@ -203,8 +209,9 @@ int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev)
 		 vgdev->has_resource_blob ? '+' : '-',
 		 vgdev->has_host_visible ? '+' : '-');
 
-	DRM_INFO("features: %ccontext_init\n",
-		 vgdev->has_context_init ? '+' : '-');
+	DRM_INFO("features: %ccontext_init %chost_page_size\n",
+		 vgdev->has_context_init ? '+' : '-',
+		 vgdev->has_host_page_size ? '+' : '-');
 
 	ret = virtio_find_vqs(vgdev->vdev, 2, vqs, vqs_info, NULL);
 	if (ret) {
diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h
index bf2c9cabd20793e3851e749baadf210341445501..adc264df4e458e9c754936c3015c069e5ee6b899 100644
--- a/include/uapi/linux/virtio_gpu.h
+++ b/include/uapi/linux/virtio_gpu.h
@@ -64,6 +64,10 @@
  * context_init and multiple timelines
  */
 #define VIRTIO_GPU_F_CONTEXT_INIT        4
+/*
+ * Config struct contains host page size
+ */
+#define VIRTIO_GPU_F_HOST_PAGE_SIZE      5
 
 enum virtio_gpu_ctrl_type {
 	VIRTIO_GPU_UNDEFINED = 0,
@@ -364,6 +368,7 @@ struct virtio_gpu_config {
 	__le32 events_clear;
 	__le32 num_scanouts;
 	__le32 num_capsets;
+	__le32 host_page_size;
 };
 
 /* simple formats for fbcon/X use */

-- 
2.48.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] drm/virtio: add VIRTGPU_PARAM_HOST_PAGE_SIZE to params
  2025-04-02 17:45 [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature Sergio Lopez
  2025-04-02 17:46 ` [PATCH v2 1/2] " Sergio Lopez
@ 2025-04-02 17:46 ` Sergio Lopez
  2025-04-02 17:55   ` Dmitry Osipenko
  2025-10-24  4:03 ` [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature Dmitry Osipenko
  2 siblings, 1 reply; 8+ messages in thread
From: Sergio Lopez @ 2025-04-02 17:46 UTC (permalink / raw)
  To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Gurchetan Singh, Rob Clark, Dmitry Osipenko
  Cc: dri-devel, virtualization, linux-kernel, Sergio Lopez

Add VIRTGPU_PARAM_HOST_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..405203b3c3847a8b318a7118aa34356c839d249e 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_PAGE_SIZE:
+		if (!vgdev->has_host_page_size)
+			return -EINVAL;
+		value = vgdev->host_page_size;
+		break;
 	default:
 		return -EINVAL;
 	}
diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h
index c2ce71987e9bb816d13a300679336cb756f1cbcf..505f87263a15f55302d7134335bebd91ff4cdae3 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_PAGE_SIZE 9 /* Host's page size */
 
 struct drm_virtgpu_getparam {
 	__u64 param;

-- 
2.48.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] drm/virtio: introduce the HOST_PAGE_SIZE feature
  2025-04-02 17:46 ` [PATCH v2 1/2] " Sergio Lopez
@ 2025-04-02 17:55   ` Dmitry Osipenko
  2025-04-03 16:49     ` Dmitry Osipenko
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Osipenko @ 2025-04-02 17:55 UTC (permalink / raw)
  To: Sergio Lopez, David Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Rob Clark
  Cc: dri-devel, virtualization, linux-kernel

On 4/2/25 20:46, Sergio Lopez wrote:
> diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h
> index bf2c9cabd20793e3851e749baadf210341445501..adc264df4e458e9c754936c3015c069e5ee6b899 100644
> --- a/include/uapi/linux/virtio_gpu.h
> +++ b/include/uapi/linux/virtio_gpu.h
> @@ -64,6 +64,10 @@
>   * context_init and multiple timelines
>   */
>  #define VIRTIO_GPU_F_CONTEXT_INIT        4
> +/*
> + * Config struct contains host page size
> + */
> +#define VIRTIO_GPU_F_HOST_PAGE_SIZE      5
>  
>  enum virtio_gpu_ctrl_type {
>  	VIRTIO_GPU_UNDEFINED = 0,
> @@ -364,6 +368,7 @@ struct virtio_gpu_config {
>  	__le32 events_clear;
>  	__le32 num_scanouts;
>  	__le32 num_capsets;
> +	__le32 host_page_size;
>  };

Hi, this is still a spec change and the virtio-gpu spec update is need.
Please send the spec patch, I'd want to see that it won't have new
objections before merging the kernel patches.

-- 
Best regards,
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] drm/virtio: add VIRTGPU_PARAM_HOST_PAGE_SIZE to params
  2025-04-02 17:46 ` [PATCH v2 2/2] drm/virtio: add VIRTGPU_PARAM_HOST_PAGE_SIZE to params Sergio Lopez
@ 2025-04-02 17:55   ` Dmitry Osipenko
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Osipenko @ 2025-04-02 17:55 UTC (permalink / raw)
  To: Sergio Lopez, David Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Rob Clark
  Cc: dri-devel, virtualization, linux-kernel

On 4/2/25 20:46, Sergio Lopez wrote:
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index c33c057365f85a2ace536f91655c903036827312..405203b3c3847a8b318a7118aa34356c839d249e 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_PAGE_SIZE:
> +		if (!vgdev->has_host_page_size)
> +			return -EINVAL;

ENOENT

-- 
Best regards,
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] drm/virtio: introduce the HOST_PAGE_SIZE feature
  2025-04-02 17:55   ` Dmitry Osipenko
@ 2025-04-03 16:49     ` Dmitry Osipenko
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Osipenko @ 2025-04-03 16:49 UTC (permalink / raw)
  To: Sergio Lopez, David Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Rob Clark
  Cc: dri-devel, virtualization, linux-kernel

On 4/2/25 20:55, Dmitry Osipenko wrote:
> On 4/2/25 20:46, Sergio Lopez wrote:
>> diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h
>> index bf2c9cabd20793e3851e749baadf210341445501..adc264df4e458e9c754936c3015c069e5ee6b899 100644
>> --- a/include/uapi/linux/virtio_gpu.h
>> +++ b/include/uapi/linux/virtio_gpu.h
>> @@ -64,6 +64,10 @@
>>   * context_init and multiple timelines
>>   */
>>  #define VIRTIO_GPU_F_CONTEXT_INIT        4
>> +/*
>> + * Config struct contains host page size
>> + */
>> +#define VIRTIO_GPU_F_HOST_PAGE_SIZE      5
>>  
>>  enum virtio_gpu_ctrl_type {
>>  	VIRTIO_GPU_UNDEFINED = 0,
>> @@ -364,6 +368,7 @@ struct virtio_gpu_config {
>>  	__le32 events_clear;
>>  	__le32 num_scanouts;
>>  	__le32 num_capsets;
>> +	__le32 host_page_size;
>>  };
> 
> Hi, this is still a spec change and the virtio-gpu spec update is need.
> Please send the spec patch, I'd want to see that it won't have new
> objections before merging the kernel patches.

Noticed the virtio-spec patch now. My bad for missing it a day ago,
thanks for sending it!

-- 
Best regards,
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature
  2025-04-02 17:45 [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature Sergio Lopez
  2025-04-02 17:46 ` [PATCH v2 1/2] " Sergio Lopez
  2025-04-02 17:46 ` [PATCH v2 2/2] drm/virtio: add VIRTGPU_PARAM_HOST_PAGE_SIZE to params Sergio Lopez
@ 2025-10-24  4:03 ` Dmitry Osipenko
  2025-10-24 13:16   ` Sergio Lopez Pascual
  2 siblings, 1 reply; 8+ messages in thread
From: Dmitry Osipenko @ 2025-10-24  4:03 UTC (permalink / raw)
  To: Sergio Lopez, David Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Rob Clark
  Cc: dri-devel, virtualization, linux-kernel

On 4/2/25 20:45, Sergio Lopez wrote:
> There's an incresing number of machines supporting multiple page sizes
> and on these machines the host and a guest can be running, each one,
> with a different page size.
> 
> For what pertains to virtio-gpu, this is not a problem if the page size
> of the guest happens to be bigger or equal than the host, but will
> potentially lead to failures in memory allocations and/or mappings
> otherwise.
> 
> To improve this situation, we introduce here the HOST_PAGE_SIZE feature.
> This feature indicates that the host has an extended virtio_gpu_config
> structure that include it's own page size a new field.
> 
> On the second commit, we also add a new 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.
> 
> There has been a discussion in virtio-comments about whether the
> information about alignment restrictions must be shared in a generic or
> in a device-specific way, favoring the latter:
> 
> https://lore.kernel.org/virtio-comment/CY8PR12MB7195B5E575099CD9CA1F2F39DCAF2@CY8PR12MB7195.namprd12.prod.outlook.com/T/#t
> 
> v2:
>  - Rebase on top of current upstream.
>  - Make a reference in the cover to the discussion about how device
>    page alignment restrictions should be shared with the driver.
> 
> Signed-off-by: Sergio Lopez <slp@redhat.com>
> ---
> Sergio Lopez (2):
>       drm/virtio: introduce the HOST_PAGE_SIZE feature
>       drm/virtio: add VIRTGPU_PARAM_HOST_PAGE_SIZE to params
> 
>  drivers/gpu/drm/virtio/virtgpu_drv.c   |  1 +
>  drivers/gpu/drm/virtio/virtgpu_drv.h   |  2 ++
>  drivers/gpu/drm/virtio/virtgpu_ioctl.c |  5 +++++
>  drivers/gpu/drm/virtio/virtgpu_kms.c   | 13 ++++++++++---
>  include/uapi/drm/virtgpu_drm.h         |  1 +
>  include/uapi/linux/virtio_gpu.h        |  5 +++++
>  6 files changed, 24 insertions(+), 3 deletions(-)
> ---
> base-commit: acc4d5ff0b61eb1715c498b6536c38c1feb7f3c1
> change-id: 20250402-virtio-gpu-host-page-size-282c99dfe44c
> 
> Best regards,

Hi Sergio,

Curious if this feature still wanted. The protocol was updated many
months ago with the VIRTIO_GPU_F_BLOB_ALIGNMENT addition.

-- 
Best regards,
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature
  2025-10-24  4:03 ` [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature Dmitry Osipenko
@ 2025-10-24 13:16   ` Sergio Lopez Pascual
  0 siblings, 0 replies; 8+ messages in thread
From: Sergio Lopez Pascual @ 2025-10-24 13:16 UTC (permalink / raw)
  To: Dmitry Osipenko, David Airlie, Gerd Hoffmann, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Simona Vetter, Michael S. Tsirkin, Jason Wang, Xuan Zhuo,
	Eugenio Pérez, Rob Clark
  Cc: dri-devel, virtualization, linux-kernel

Dmitry Osipenko <dmitry.osipenko@collabora.com> writes:

> On 4/2/25 20:45, Sergio Lopez wrote:
>> There's an incresing number of machines supporting multiple page sizes
>> and on these machines the host and a guest can be running, each one,
>> with a different page size.
>>
>> For what pertains to virtio-gpu, this is not a problem if the page size
>> of the guest happens to be bigger or equal than the host, but will
>> potentially lead to failures in memory allocations and/or mappings
>> otherwise.
>>
>> To improve this situation, we introduce here the HOST_PAGE_SIZE feature.
>> This feature indicates that the host has an extended virtio_gpu_config
>> structure that include it's own page size a new field.
>>
>> On the second commit, we also add a new 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.
>>
>> There has been a discussion in virtio-comments about whether the
>> information about alignment restrictions must be shared in a generic or
>> in a device-specific way, favoring the latter:
>>
>> https://lore.kernel.org/virtio-comment/CY8PR12MB7195B5E575099CD9CA1F2F39DCAF2@CY8PR12MB7195.namprd12.prod.outlook.com/T/#t
>>
>> v2:
>>  - Rebase on top of current upstream.
>>  - Make a reference in the cover to the discussion about how device
>>    page alignment restrictions should be shared with the driver.
>>
>> Signed-off-by: Sergio Lopez <slp@redhat.com>
>> ---
>> Sergio Lopez (2):
>>       drm/virtio: introduce the HOST_PAGE_SIZE feature
>>       drm/virtio: add VIRTGPU_PARAM_HOST_PAGE_SIZE to params
>>
>>  drivers/gpu/drm/virtio/virtgpu_drv.c   |  1 +
>>  drivers/gpu/drm/virtio/virtgpu_drv.h   |  2 ++
>>  drivers/gpu/drm/virtio/virtgpu_ioctl.c |  5 +++++
>>  drivers/gpu/drm/virtio/virtgpu_kms.c   | 13 ++++++++++---
>>  include/uapi/drm/virtgpu_drm.h         |  1 +
>>  include/uapi/linux/virtio_gpu.h        |  5 +++++
>>  6 files changed, 24 insertions(+), 3 deletions(-)
>> ---
>> base-commit: acc4d5ff0b61eb1715c498b6536c38c1feb7f3c1
>> change-id: 20250402-virtio-gpu-host-page-size-282c99dfe44c
>>
>> Best regards,
>
> Hi Sergio,
>
> Curious if this feature still wanted. The protocol was updated many
> months ago with the VIRTIO_GPU_F_BLOB_ALIGNMENT addition.

Yes, we still need it to avoid having to carry downstream patches in
Mesa with a hack to hardcoded the alignment.

I'll prepare a new patch series (referencing this one) next week.

Thanks,
Sergio.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-10-24 13:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-02 17:45 [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature Sergio Lopez
2025-04-02 17:46 ` [PATCH v2 1/2] " Sergio Lopez
2025-04-02 17:55   ` Dmitry Osipenko
2025-04-03 16:49     ` Dmitry Osipenko
2025-04-02 17:46 ` [PATCH v2 2/2] drm/virtio: add VIRTGPU_PARAM_HOST_PAGE_SIZE to params Sergio Lopez
2025-04-02 17:55   ` Dmitry Osipenko
2025-10-24  4:03 ` [PATCH v2 0/2] drm/virtio: introduce the HOST_PAGE_SIZE feature Dmitry Osipenko
2025-10-24 13:16   ` Sergio Lopez Pascual

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®