All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/virtio: Replace deprecated drm_simple_encoder_init()
@ 2026-09-09  7:34 Davide Bonatto
  2026-09-09  7:44 ` sashiko-bot
  2026-09-09  7:52 ` Thomas Zimmermann
  0 siblings, 2 replies; 3+ messages in thread
From: Davide Bonatto @ 2026-09-09  7:34 UTC (permalink / raw)
  To: David Airlie, Gerd Hoffmann, Dmitry Osipenko, Thomas Zimmermann
  Cc: Gurchetan Singh, Chia-I Wu, dri-devel, virtualization,
	linux-kernel, Davide Bonatto

drm_simple_encoder_init() is deprecated as it introduces an unnecessary
intermediate layer between atomic modesetting and DRM drivers.

Inline the helper call in virtgpu_display by defining
virtio_gpu_encoder_funcs with the default drm_encoder_cleanup callback,
and migrate directly to drm_encoder_init()

Signed-off-by: Davide Bonatto <bonatto.davide@gmail.com>
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index a1a875a0c706..85986578001f 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -67,6 +67,10 @@ static const struct drm_framebuffer_funcs virtio_gpu_fb_funcs = {
 	.dirty = drm_atomic_helper_dirtyfb,
 };
 
+static const struct drm_encoder_funcs virtio_gpu_encoder_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
 static int
 virtio_gpu_framebuffer_init(struct drm_device *dev,
 			    struct virtio_gpu_framebuffer *vgfb,
@@ -306,7 +310,9 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
 	if (vgdev->has_edid)
 		drm_connector_attach_edid_property(connector);
 
-	drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_VIRTUAL);
+	drm_encoder_init(dev, encoder, &virtio_gpu_encoder_funcs,
+		DRM_MODE_ENCODER_VIRTUAL, NULL);
+
 	drm_encoder_helper_add(encoder, &virtio_gpu_enc_helper_funcs);
 	encoder->possible_crtcs = 1 << index;
 
-- 
2.43.0


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

* Re: [PATCH] drm/virtio: Replace deprecated drm_simple_encoder_init()
  2026-09-09  7:34 [PATCH] drm/virtio: Replace deprecated drm_simple_encoder_init() Davide Bonatto
@ 2026-09-09  7:44 ` sashiko-bot
  2026-09-09  7:52 ` Thomas Zimmermann
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-09-09  7:44 UTC (permalink / raw)
  To: Davide Bonatto
  Cc: Eugenio Perez, virtualization, dri-devel, Michael S. Tsirkin

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing error check for drm_encoder_init return value.
--

commit 731688e34b570f6cb070588f1d74f9b42481123c
Author: Davide Bonatto <bonatto.davide@gmail.com>

drm/virtio: Replace deprecated drm_simple_encoder_init()

This patch replaces the deprecated drm_simple_encoder_init() with a direct
call to drm_encoder_init(), defining a default cleanup callback directly in 
virtio_gpu_encoder_funcs.

> diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
> index a1a875a0c706a..85986578001fe 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_display.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_display.c

[ ... ]

> @@ -306,7 +310,9 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
>  	if (vgdev->has_edid)
>  		drm_connector_attach_edid_property(connector);
>  
> -	drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_VIRTUAL);
> +	drm_encoder_init(dev, encoder, &virtio_gpu_encoder_funcs,
> +		DRM_MODE_ENCODER_VIRTUAL, NULL);

[Severity: Medium]
Does this code need to check the return value of drm_encoder_init()?

If drm_encoder_init() fails (for example, due to a memory allocation failure 
for the encoder name), it returns a negative error code like -ENOMEM and 
cleans up the partially initialized object.

Since this return value is not validated in vgdev_output_init(), the function 
will proceed to use the uninitialized encoder, attaching it to a connector and 
registering the connector with userspace. Could this lead to a NULL pointer 
dereference or corrupted state when the DRM subsystem interacts with it?

> +
>  	drm_encoder_helper_add(encoder, &virtio_gpu_enc_helper_funcs);
>  	encoder->possible_crtcs = 1 << index;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260909073440.52641-1-bonatto.davide@gmail.com?part=1

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

* Re: [PATCH] drm/virtio: Replace deprecated drm_simple_encoder_init()
  2026-09-09  7:34 [PATCH] drm/virtio: Replace deprecated drm_simple_encoder_init() Davide Bonatto
  2026-09-09  7:44 ` sashiko-bot
@ 2026-09-09  7:52 ` Thomas Zimmermann
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2026-09-09  7:52 UTC (permalink / raw)
  To: Davide Bonatto, David Airlie, Gerd Hoffmann, Dmitry Osipenko
  Cc: Gurchetan Singh, Chia-I Wu, dri-devel, virtualization,
	linux-kernel

Hi

Am 09.09.26 um 09:34 schrieb Davide Bonatto:
> drm_simple_encoder_init() is deprecated as it introduces an unnecessary
> intermediate layer between atomic modesetting and DRM drivers.

This helper has meanwhile been removed entirely.

Best regards
Thomas

>
> Inline the helper call in virtgpu_display by defining
> virtio_gpu_encoder_funcs with the default drm_encoder_cleanup callback,
> and migrate directly to drm_encoder_init()
>
> Signed-off-by: Davide Bonatto <bonatto.davide@gmail.com>
> ---
>   drivers/gpu/drm/virtio/virtgpu_display.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
> index a1a875a0c706..85986578001f 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_display.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_display.c
> @@ -67,6 +67,10 @@ static const struct drm_framebuffer_funcs virtio_gpu_fb_funcs = {
>   	.dirty = drm_atomic_helper_dirtyfb,
>   };
>   
> +static const struct drm_encoder_funcs virtio_gpu_encoder_funcs = {
> +	.destroy = drm_encoder_cleanup,
> +};
> +
>   static int
>   virtio_gpu_framebuffer_init(struct drm_device *dev,
>   			    struct virtio_gpu_framebuffer *vgfb,
> @@ -306,7 +310,9 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
>   	if (vgdev->has_edid)
>   		drm_connector_attach_edid_property(connector);
>   
> -	drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_VIRTUAL);
> +	drm_encoder_init(dev, encoder, &virtio_gpu_encoder_funcs,
> +		DRM_MODE_ENCODER_VIRTUAL, NULL);
> +
>   	drm_encoder_helper_add(encoder, &virtio_gpu_enc_helper_funcs);
>   	encoder->possible_crtcs = 1 << index;
>   

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)



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

end of thread, other threads:[~2026-09-09  7:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09  7:34 [PATCH] drm/virtio: Replace deprecated drm_simple_encoder_init() Davide Bonatto
2026-09-09  7:44 ` sashiko-bot
2026-09-09  7:52 ` Thomas Zimmermann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.