Skip to contentSkip to conversation

drm/virtio: Open-code drm_simple_encoder_init()

PATCH New Sebastian von Arx 2 participants 5 messages Sep 20

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover drm/virtio: Open-code drm_simple_encoder_init()

Replace drm_simple_encoder_init() in the virtio GPU driver with drm_encoder_init() and propagate initialization errors to the caller.

Sebastian von Arx (2):
drm/virtio: Open-code drm_simple_encoder_init()
drm/virtio: Propagate drm_encoder_init() errors

 drivers/gpu/drm/virtio/virtgpu_display.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

base-commit: 5dd1818b15d98d4a20806cd00b1b40320b06004f

Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/2 drm/virtio: Open-code drm_simple_encoder_init()

drm_simple_encoder_init() only wraps drm_encoder_init() with a cleanup callback. Open-code the helper in preparation for removing drm_simple_encoder_init().

Assisted-by LLM
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +5 -1
index a1a875a0c..b01178027 100644
@@ -271,6 +271,10 @@ static const struct drm_connector_funcs virtio_gpu_connector_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
+static const struct drm_encoder_funcs virtio_gpu_encoder_funcs = {
+	.destroy = drm_encoder_cleanup,
+};
+
 static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
 {
 	struct drm_device *dev = vgdev->ddev;
@@ -306,7 +310,7 @@ 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;
 
Signature · 1 line
2.55.0
#2 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines

drm_simple_encoder_init() only wraps drm_encoder_init() with a cleanup callback. Open-code the helper in preparation for removing drm_simple_encoder_init().

Assisted-by LLM

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

PATCH 2/2 drm/virtio: Propagate drm_encoder_init() errors

In reply to Sebastian von Arx

vgdev_output_init() ignores errors from drm_encoder_init(), so output setup continues even when encoder initialization fails, for example because of an allocation failure.

Check the return value and propagate the error to the caller.

Assisted-by LLM
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/virtio/virtgpu_display.c +5 -1
index b01178027..1c790d6a6 100644
@@ -310,7 +310,11 @@ static int vgdev_output_init(struct virtio_gpu_device *vgdev, int index)
 	if (vgdev->has_edid)
 		drm_connector_attach_edid_property(connector);
 
-	drm_encoder_init(dev, encoder, &virtio_gpu_encoder_funcs, DRM_MODE_ENCODER_VIRTUAL, NULL);
+	ret = drm_encoder_init(dev, encoder, &virtio_gpu_encoder_funcs,
+			       DRM_MODE_ENCODER_VIRTUAL, NULL);
+	if (ret)
+		return ret;
+
 	drm_encoder_helper_add(encoder, &virtio_gpu_enc_helper_funcs);
 	encoder->possible_crtcs = 1 << index;
 
Signature · 1 line
2.55.0
#4 lore raw

Re: [PATCH 2/2] drm/virtio: Propagate drm_encoder_init() errors

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines

vgdev_output_init() ignores errors from drm_encoder_init(), so output setup continues even when encoder initialization fails, for example because of an allocation failure.

Check the return value and propagate the error to the caller.

Assisted-by LLM

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2