Skip to contentSkip to conversation

drm/vkms: Switch all vkms object to DRM managed objects

PATCH Superseded Louis Chauvet 3 participants 13 messages Nov 22, 2024 – Nov 25, 2024

Subsystems (3)

v5 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Louis Chauvet

author maintainer
#0 lore raw

v5 cover drm/vkms: Switch all vkms object to DRM managed objects

To simplify the memory managment this series replace all manual drm object managment by drm-managed one. This way the VKMS code don't have to manage it directly and the DRM core will handle the object destruction.

No functional changes are intended in this series.

PATCH 1/5: Migrate connector managment to drmm PATCH 2/5: Migrate encoder managment to drmm PATCH 3/5: Migrate connector management to drm PATCH 4/5: Introduce drmm_writeback helpers PATCH 5/5: Migrate writeback connector management to drm

For the drmm_writeback helpers, you can find some discussions here [3].

[3]:https://lore.kernel.org/all/[email protected]/

---
Changes in v5:
- Rebased on drm-misc-next
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- No changes for the managed part
- Add the patch to introduce drmm_writeback helpers
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- As suggested by Maxime, split the managed and the dynamic allocation
parts in different series
- To reduce the diff in this series, extract the "remove crtc index" part,
see https://lore.kernel.org/all/[email protected]/
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Applied comments from José
- Extract the rename vkms_output -> vkms_crtc to avoid useless changes in
the last commit
- Extract the rename to_vkms_crtc_state to
drm_crtc_state_to_vkms_crtc_state to avoid useless changes in last
commit
- Extract the drm_mode_crtc_set_gamma_size result check in its own commit
- Rebased on drm-misc/drm-misc-next
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Louis Chauvet (5):
drm/vkms: Switch to managed for connector drm/vkms: Switch to managed for encoder drm/vkms: Switch to managed for crtc
drm: writeback: Introduce drm managed helpers drm/vkms: Switch to managed for writeback connector

 drivers/gpu/drm/drm_connector.c       |   4 +
 drivers/gpu/drm/drm_writeback.c       | 224 +++++++++++++++++++++++++++++-----
 drivers/gpu/drm/vkms/vkms_crtc.c      |  14 +++
 drivers/gpu/drm/vkms/vkms_drv.c       |   9 --
 drivers/gpu/drm/vkms/vkms_output.c    |  24 ++--
 drivers/gpu/drm/vkms/vkms_writeback.c |  13 +-
 include/drm/drm_writeback.h           |  10 ++
 7 files changed, 235 insertions(+), 63 deletions(-)

---
base-commit: 98efdd02e220fea84c1491012d7292749a71faeb
change-id: 20240521-google-vkms-managed-4aec99461a77

Best regards,

Signature · 1 line
Louis Chauvet <[email protected]>
author maintainer
#1 lore raw

PATCH v5 1/5 drm/vkms: Switch to managed for connector

The current VKMS driver uses non-managed function to create connectors. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers.

---
 drivers/gpu/drm/vkms/vkms_output.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/vkms/vkms_output.c +4 -8
index 8f4bd5aef087b459d37d0cbbf90fe0145090917a..570823ecb28f589e6323036590ec05a2f633bc9b 100644
@@ -3,11 +3,11 @@
 #include "vkms_drv.h"
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_managed.h>
 #include <drm/drm_probe_helper.h>
 
 static const struct drm_connector_funcs vkms_connector_funcs = {
 	.fill_modes = drm_helper_probe_single_connector_modes,
-	.destroy = drm_connector_cleanup,
 	.reset = drm_atomic_helper_connector_reset,
 	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
@@ -75,8 +75,8 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 		}
 	}
 
-	ret = drm_connector_init(dev, connector, &vkms_connector_funcs,
-				 DRM_MODE_CONNECTOR_VIRTUAL);
+	ret = drmm_connector_init(dev, connector, &vkms_connector_funcs,
+				  DRM_MODE_CONNECTOR_VIRTUAL, NULL);
 	if (ret) {
 		DRM_ERROR("Failed to init connector\n");
 		return ret;
@@ -88,7 +88,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 			       DRM_MODE_ENCODER_VIRTUAL, NULL);
 	if (ret) {
 		DRM_ERROR("Failed to init encoder\n");
-		goto err_encoder;
+		return ret;
 	}
 	encoder->possible_crtcs = drm_crtc_mask(crtc);
 
@@ -110,9 +110,5 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 
 err_attach:
 	drm_encoder_cleanup(encoder);
-
-err_encoder:
-	drm_connector_cleanup(connector);
-
 	return ret;
 }
Signature · 1 line
2.47.0
maintainer Reviewed-by on v5 1/5
#2 lore raw

Re: [PATCH v5 1/5] drm/vkms: Switch to managed for connector

Quoted 7 lines · Louis Chauvet

The current VKMS driver uses non-managed function to create connectors. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers.

[ ... ]

Thanks!
Maxime

Reviewed-by on v5 1/5
#3 lore raw

Re: [PATCH v5 1/5] drm/vkms: Switch to managed for connector

In reply to Louis Chauvet

Hi Louis,

Quoted 5 lines · Louis Chauvet

The current VKMS driver uses non-managed function to create connectors. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers.

Best Regards,
- Maíra

Quoted 52 lines
---
  drivers/gpu/drm/vkms/vkms_output.c | 12 ++++--------
  1 file changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/vkms/vkms_output.c +4 -8
index 8f4bd5aef087b459d37d0cbbf90fe0145090917a..570823ecb28f589e6323036590ec05a2f633bc9b 100644
@@ -3,11 +3,11 @@
  #include "vkms_drv.h"
  #include <drm/drm_atomic_helper.h>
  #include <drm/drm_edid.h>
+#include <drm/drm_managed.h>
  #include <drm/drm_probe_helper.h>
 
  static const struct drm_connector_funcs vkms_connector_funcs = {
  	.fill_modes = drm_helper_probe_single_connector_modes,
-	.destroy = drm_connector_cleanup,
  	.reset = drm_atomic_helper_connector_reset,
  	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
@@ -75,8 +75,8 @@ int vkms_output_init(struct vkms_device *vkmsdev)
  		}
  	}
 
-	ret = drm_connector_init(dev, connector, &vkms_connector_funcs,
-				 DRM_MODE_CONNECTOR_VIRTUAL);
+	ret = drmm_connector_init(dev, connector, &vkms_connector_funcs,
+				  DRM_MODE_CONNECTOR_VIRTUAL, NULL);
  	if (ret) {
  		DRM_ERROR("Failed to init connector\n");
  		return ret;
@@ -88,7 +88,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
  			       DRM_MODE_ENCODER_VIRTUAL, NULL);
  	if (ret) {
  		DRM_ERROR("Failed to init encoder\n");
-		goto err_encoder;
+		return ret;
  	}
  	encoder->possible_crtcs = drm_crtc_mask(crtc);
 
@@ -110,9 +110,5 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 
  err_attach:
  	drm_encoder_cleanup(encoder);
-
-err_encoder:
-	drm_connector_cleanup(connector);
-
  	return ret;
  }
author maintainer
#4 lore raw

PATCH v5 2/5 drm/vkms: Switch to managed for encoder

In reply to Louis Chauvet

The current VKMS driver uses non-managed function to create encoders. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers.

---
 drivers/gpu/drm/vkms/vkms_output.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/vkms/vkms_output.c +3 -9
index 570823ecb28f589e6323036590ec05a2f633bc9b..ab9affa75b66ce9f00fe025052439405206144ec 100644
@@ -13,10 +13,6 @@ static const struct drm_connector_funcs vkms_connector_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static const struct drm_encoder_funcs vkms_encoder_funcs = {
-	.destroy = drm_encoder_cleanup,
-};
-
 static int vkms_conn_get_modes(struct drm_connector *connector)
 {
 	int count;
@@ -84,8 +80,8 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 
 	drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
 
-	ret = drm_encoder_init(dev, encoder, &vkms_encoder_funcs,
-			       DRM_MODE_ENCODER_VIRTUAL, NULL);
+	ret = drmm_encoder_init(dev, encoder, NULL,
+				DRM_MODE_ENCODER_VIRTUAL, NULL);
 	if (ret) {
 		DRM_ERROR("Failed to init encoder\n");
 		return ret;
@@ -95,7 +91,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 	ret = drm_connector_attach_encoder(connector, encoder);
 	if (ret) {
 		DRM_ERROR("Failed to attach connector to encoder\n");
-		goto err_attach;
+		return ret;
 	}
 
 	if (vkmsdev->config->writeback) {
@@ -108,7 +104,5 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 
 	return 0;
 
-err_attach:
-	drm_encoder_cleanup(encoder);
 	return ret;
 }
Signature · 1 line
2.47.0
maintainer Reviewed-by on v5 2/5
#5 lore raw

Re: [PATCH v5 2/5] drm/vkms: Switch to managed for encoder

Quoted 7 lines · Louis Chauvet

The current VKMS driver uses non-managed function to create encoders. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers.

[ ... ]

Thanks!
Maxime

Reviewed-by on v5 2/5
#6 lore raw

Re: [PATCH v5 2/5] drm/vkms: Switch to managed for encoder

In reply to Louis Chauvet

Hi Louis,

Quoted 5 lines · Louis Chauvet

The current VKMS driver uses non-managed function to create encoders. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers.

Best Regards,
- Maíra

Quoted 48 lines
---
  drivers/gpu/drm/vkms/vkms_output.c | 12 +++---------
  1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/vkms/vkms_output.c +3 -9
index 570823ecb28f589e6323036590ec05a2f633bc9b..ab9affa75b66ce9f00fe025052439405206144ec 100644
@@ -13,10 +13,6 @@ static const struct drm_connector_funcs vkms_connector_funcs = {
  	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  };
 
-static const struct drm_encoder_funcs vkms_encoder_funcs = {
-	.destroy = drm_encoder_cleanup,
-};
-
  static int vkms_conn_get_modes(struct drm_connector *connector)
  {
  	int count;
@@ -84,8 +80,8 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 
  	drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
 
-	ret = drm_encoder_init(dev, encoder, &vkms_encoder_funcs,
-			       DRM_MODE_ENCODER_VIRTUAL, NULL);
+	ret = drmm_encoder_init(dev, encoder, NULL,
+				DRM_MODE_ENCODER_VIRTUAL, NULL);
  	if (ret) {
  		DRM_ERROR("Failed to init encoder\n");
  		return ret;
@@ -95,7 +91,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
  	ret = drm_connector_attach_encoder(connector, encoder);
  	if (ret) {
  		DRM_ERROR("Failed to attach connector to encoder\n");
-		goto err_attach;
+		return ret;
  	}
 
  	if (vkmsdev->config->writeback) {
@@ -108,7 +104,5 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 
  	return 0;
 
-err_attach:
-	drm_encoder_cleanup(encoder);
  	return ret;
  }
author maintainer
#7 lore raw

PATCH v5 3/5 drm/vkms: Switch to managed for crtc

In reply to Louis Chauvet

The current VKMS driver uses managed function to create crtc, but don't use it to properly clean the crtc workqueue. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers.

---
 drivers/gpu/drm/vkms/vkms_crtc.c | 14 ++++++++++++++
 drivers/gpu/drm/vkms/vkms_drv.c  |  9 ---------
 2 files changed, 14 insertions(+), 9 deletions(-)
drivers/gpu/drm/vkms/vkms_crtc.c +14 -0
index 28a57ae109fcc05af3fe74f94518c462c09119e3..ace8d293f7da611110c1e117b6cf2f3c9e9b4381 100644
@@ -6,6 +6,7 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
+#include <drm/drm_managed.h>
 
 #include "vkms_drv.h"
 
@@ -270,6 +271,14 @@ static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = {
 	.atomic_disable	= vkms_crtc_atomic_disable,
 };
 
+static void vkms_crtc_destroy_workqueue(struct drm_device *dev,
+					void *raw_vkms_out)
+{
+	struct vkms_output *vkms_out = raw_vkms_out;
+
+	destroy_workqueue(vkms_out->composer_workq);
+}
+
 int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
 		   struct drm_plane *primary, struct drm_plane *cursor)
 {
@@ -300,5 +309,10 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
 	if (!vkms_out->composer_workq)
 		return -ENOMEM;
 
+	ret = drmm_add_action_or_reset(dev, vkms_crtc_destroy_workqueue,
+				       vkms_out);
+	if (ret)
+		return ret;
+
 	return ret;
 }
drivers/gpu/drm/vkms/vkms_drv.c +0 -9
index fa3331f612e34e0a48cef34effc169dea46d77df..c54504e590a18ae8af07cc1cc48179c38c4e6c0f 100644
@@ -54,14 +54,6 @@ MODULE_PARM_DESC(enable_overlay, "Enable/Disable overlay support");
 
 DEFINE_DRM_GEM_FOPS(vkms_driver_fops);
 
-static void vkms_release(struct drm_device *dev)
-{
-	struct vkms_device *vkms = drm_device_to_vkms_device(dev);
-
-	if (vkms->output.composer_workq)
-		destroy_workqueue(vkms->output.composer_workq);
-}
-
 static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state)
 {
 	struct drm_device *dev = old_state->dev;
@@ -109,7 +101,6 @@ static const struct drm_debugfs_info vkms_config_debugfs_list[] = {
 
 static const struct drm_driver vkms_driver = {
 	.driver_features	= DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM,
-	.release		= vkms_release,
 	.fops			= &vkms_driver_fops,
 	DRM_GEM_SHMEM_DRIVER_OPS,
 	DRM_FBDEV_SHMEM_DRIVER_OPS,
Signature · 1 line
2.47.0
maintainer Reviewed-by on v5 3/5
#8 lore raw

Re: [PATCH v5 3/5] drm/vkms: Switch to managed for crtc

Quoted 7 lines · Louis Chauvet

The current VKMS driver uses managed function to create crtc, but don't use it to properly clean the crtc workqueue. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers.

[ ... ]

Thanks!
Maxime

Reviewed-by on v5 3/5
#9 lore raw

Re: [PATCH v5 3/5] drm/vkms: Switch to managed for crtc

In reply to Louis Chauvet

Hi Louis,

Quoted 38 lines · Louis Chauvet

The current VKMS driver uses managed function to create crtc, but don't use it to properly clean the crtc workqueue. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers.

---> drivers/gpu/drm/vkms/vkms_crtc.c | 14 ++++++++++++++

  drivers/gpu/drm/vkms/vkms_drv.c  |  9 ---------
  2 files changed, 14 insertions(+), 9 deletions(-)
drivers/gpu/drm/vkms/vkms_crtc.c +9 -0
index 28a57ae109fcc05af3fe74f94518c462c09119e3..ace8d293f7da611110c1e117b6cf2f3c9e9b4381 100644
@@ -6,6 +6,7 @@
  #include <drm/drm_atomic_helper.h>
  #include <drm/drm_probe_helper.h>
  #include <drm/drm_vblank.h>
+#include <drm/drm_managed.h>
 
  #include "vkms_drv.h"
 
@@ -270,6 +271,14 @@ static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = {
  	.atomic_disable	= vkms_crtc_atomic_disable,
  };
 
+static void vkms_crtc_destroy_workqueue(struct drm_device *dev,
+					void *raw_vkms_out)
+{
+	struct vkms_output *vkms_out = raw_vkms_out;
+
+	destroy_workqueue(vkms_out->composer_workq);
+}
+
  int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
  		   struct drm_plane *primary, struct drm_plane *cursor)
  {

drivers/gpu/drm/vkms/vkms_crtc.c int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, · line 316

Quoted 8 lines
drivers/gpu/drm/vkms/vkms_crtc.c +5 -0
@@ -300,5 +309,10 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
  	if (!vkms_out->composer_workq)
  		return -ENOMEM;
 
+	ret = drmm_add_action_or_reset(dev, vkms_crtc_destroy_workqueue,
+				       vkms_out);
+	if (ret)
+		return ret;
+

Small nit: no need for if (ret) here. Anyway,

Best Regards,
- Maíra

Quoted 30 lines
drivers/gpu/drm/vkms/vkms_crtc.c +0 -0
  	return ret;
  }
drivers/gpu/drm/vkms/vkms_drv.c +0 -9
index fa3331f612e34e0a48cef34effc169dea46d77df..c54504e590a18ae8af07cc1cc48179c38c4e6c0f 100644
@@ -54,14 +54,6 @@ MODULE_PARM_DESC(enable_overlay, "Enable/Disable overlay support");
 
  DEFINE_DRM_GEM_FOPS(vkms_driver_fops);
 
-static void vkms_release(struct drm_device *dev)
-{
-	struct vkms_device *vkms = drm_device_to_vkms_device(dev);
-
-	if (vkms->output.composer_workq)
-		destroy_workqueue(vkms->output.composer_workq);
-}
-
  static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state)
  {
  	struct drm_device *dev = old_state->dev;
@@ -109,7 +101,6 @@ static const struct drm_debugfs_info vkms_config_debugfs_list[] = {
 
  static const struct drm_driver vkms_driver = {
  	.driver_features	= DRIVER_MODESET | DRIVER_ATOMIC | DRIVER_GEM,
-	.release		= vkms_release,
  	.fops			= &vkms_driver_fops,
  	DRM_GEM_SHMEM_DRIVER_OPS,
  	DRM_FBDEV_SHMEM_DRIVER_OPS,
author maintainer
#10 lore raw

PATCH v5 4/5 drm: writeback: Introduce drm managed helpers

In reply to Louis Chauvet

Currently drm_writeback_connector are created by drm_writeback_connector_init or drm_writeback_connector_init_with_encoder. Both of the function uses drm_connector_init and drm_encoder_init, but there is no way to properly clean those structure from outside. By using drm managed variants, we can ensure that the writeback connector is properly cleaned.

This patch introduce drmm_writeback_connector_init, an helper to initialize a writeback connector using drm managed helpers. This function allows the caller to use its own encoder.

---
 drivers/gpu/drm/drm_connector.c |   4 +
 drivers/gpu/drm/drm_writeback.c | 224 ++++++++++++++++++++++++++++++++++------
 include/drm/drm_writeback.h     |  10 ++
 3 files changed, 208 insertions(+), 30 deletions(-)
drivers/gpu/drm/drm_connector.c +4 -0
index fc35f47e2849ed6786d6223ac9c69e1c359fc648..fe4c1967860a3f49b92622c96912c59c505a26ab 100644
@@ -613,6 +613,7 @@ static void drm_mode_remove(struct drm_connector *connector,
 	drm_mode_destroy(connector->dev, mode);
 }
 
+void drm_writeback_connector_cleanup(struct drm_device *dev, void *data);
 /**
  * drm_connector_cleanup - cleans up an initialised connector
  * @connector: connector to cleanup
@@ -631,6 +632,9 @@ void drm_connector_cleanup(struct drm_connector *connector)
 		    DRM_CONNECTOR_REGISTERED))
 		drm_connector_unregister(connector);
 
+	if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
+		drm_writeback_connector_cleanup(dev, connector);
+
 	if (connector->privacy_screen) {
 		drm_privacy_screen_put(connector->privacy_screen);
 		connector->privacy_screen = NULL;
drivers/gpu/drm/drm_writeback.c +194 -30

269 lines not on this page · raw message

include/drm/drm_writeback.h +10 -0
index 17e576c80169a820e8d5587b229b2cc2ee369a18..5e5ff8dd9d9d8ab5e46ce028a752062b97e82e0f 100644
@@ -161,6 +161,14 @@ int drm_writeback_connector_init_with_encoder(struct drm_device *dev,
 				const struct drm_connector_funcs *con_funcs, const u32 *formats,
 				int n_formats);
 
+int drmm_writeback_connector_init(struct drm_device *dev,
+				  struct drm_writeback_connector *wb_connector,
+				  const struct drm_connector_funcs *con_funcs,
+				  struct drm_encoder *enc,
+				  const struct drm_encoder_helper_funcs *enc_funcs,
+				  const u32 *formats, int n_formats,
+				  u32 possible_crtcs);
+
 int drm_writeback_set_fb(struct drm_connector_state *conn_state,
 			 struct drm_framebuffer *fb);
 
@@ -175,6 +183,8 @@ void
 drm_writeback_signal_completion(struct drm_writeback_connector *wb_connector,
 				int status);
 
+void drm_writeback_connector_cleanup(struct drm_device *dev, void *data);
+
 struct dma_fence *
 drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector);
 #endif
Signature · 1 line
2.47.0
maintainer
#11 lore raw

Re: [PATCH v5 4/5] drm: writeback: Introduce drm managed helpers

Quoted 7 lines · Louis Chauvet

Currently drm_writeback_connector are created by drm_writeback_connector_init or drm_writeback_connector_init_with_encoder. Both of the function uses drm_connector_init and drm_encoder_init, but there is no way to properly clean those structure from outside. By using drm managed variants, we can ensure that the writeback connector is properly cleaned.

Quoted 5 lines

This patch introduce drmm_writeback_connector_init, an helper to initialize a writeback connector using drm managed helpers. This function allows the caller to use its own encoder.

See https://lore.kernel.org/all/20241024-slim-onyx-emu-3e4869@houat/

Maxime

author maintainer
#12 lore raw

PATCH v5 5/5 drm/vkms: Switch to managed for writeback connector

In reply to Louis Chauvet

The current VKMS driver uses non-managed function to create writeback connectors. It is not an issue yet, but in order to support multiple devices easily, convert this code to use drm and device managed helpers.

---
 drivers/gpu/drm/vkms/vkms_writeback.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/vkms/vkms_writeback.c +6 -7
index 79918b44fedd7ae2451d1d530fc6d5aabf2d99a3..f12417b2d24803a33e4ff56108cc89704a500faf 100644
@@ -24,7 +24,6 @@ static const u32 vkms_wb_formats[] = {
 
 static const struct drm_connector_funcs vkms_wb_connector_funcs = {
 	.fill_modes = drm_helper_probe_single_connector_modes,
-	.destroy = drm_connector_cleanup,
 	.reset = drm_atomic_helper_connector_reset,
 	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
@@ -169,10 +168,10 @@ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev)
 
 	drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs);
 
-	return drm_writeback_connector_init(&vkmsdev->drm, wb,
-					    &vkms_wb_connector_funcs,
-					    NULL,
-					    vkms_wb_formats,
-					    ARRAY_SIZE(vkms_wb_formats),
-					    1);
+	return drmm_writeback_connector_init(&vkmsdev->drm, wb,
+					     &vkms_wb_connector_funcs,
+					     NULL, NULL,
+					     vkms_wb_formats,
+					     ARRAY_SIZE(vkms_wb_formats),
+					     1);
 }
Signature · 1 line
2.47.0