Skip to contentSkip to conversation

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

PATCH Superseded Louis Chauvet 3 participants 11 messages Oct 10, 2024 – Oct 28, 2024

Subsystems (3)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Louis Chauvet

author maintainer
#0 lore raw

v4 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. This series depends on
[2] (for some code cleanup, which conflict with 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

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

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

[3]:https://lore.kernel.org/all/[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    |  31 ++---
 drivers/gpu/drm/vkms/vkms_writeback.c |  13 +-
 include/drm/drm_writeback.h           |  10 ++
 7 files changed, 238 insertions(+), 67 deletions(-)

---
base-commit: 33c255312660653cf54f8019896b5dca28e3c580
change-id: 20240521-google-vkms-managed-4aec99461a77
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: 920c23497fc5bd2fdf1dded06ce198c227ea0ef9

Best regards,

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

PATCH v4 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 | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/gpu/drm/vkms/vkms_output.c +7 -12
index 5128aa3b2eb6..8f7a05b73e1d 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,
@@ -70,17 +70,17 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 			if (IS_ERR(overlay)) {
 				DRM_DEV_ERROR(dev->dev, "Failed to init vkms plane\n");
 				ret = PTR_ERR(overlay);
-				goto err_crtc;
+				goto err_connector;
 			}
 			overlay->base.possible_crtcs = drm_crtc_mask(crtc);
 		}
 	}
 
-	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");
-		goto err_crtc;
+		goto err_connector;
 	}
 
 	drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
@@ -89,7 +89,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);
 
@@ -111,12 +111,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 
 err_attach:
 	drm_encoder_cleanup(encoder);
-
-err_encoder:
-	drm_connector_cleanup(connector);
-
-err_crtc:
+err_connector:
 	drm_crtc_cleanup(crtc);
-
 	return ret;
 }
Signature · 1 line
2.46.2
#2 lore raw

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

Hi Louis,

Quoted 27 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.

---
  drivers/gpu/drm/vkms/vkms_output.c | 19 +++++++------------
  1 file changed, 7 insertions(+), 12 deletions(-)
drivers/gpu/drm/vkms/vkms_output.c +1 -1
index 5128aa3b2eb6..8f7a05b73e1d 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,

drivers/gpu/drm/vkms/vkms_output.c int vkms_output_init(struct vkms_device *vkmsdev) · line 73

Quoted 5 lines
drivers/gpu/drm/vkms/vkms_output.c +1 -1
@@ -70,17 +70,17 @@ int vkms_output_init(struct vkms_device *vkmsdev)
  			if (IS_ERR(overlay)) {
  				DRM_DEV_ERROR(dev->dev, "Failed to init vkms plane\n");
  				ret = PTR_ERR(overlay);
-				goto err_crtc;
+				goto err_connector;

Why did you renamed err_crtc to err_connector? I think err_crtc looks correct.

Best Regards,
- Maíra

Quoted 40 lines
drivers/gpu/drm/vkms/vkms_output.c +5 -10
  			}
  			overlay->base.possible_crtcs = drm_crtc_mask(crtc);
  		}
  	}
 
-	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");
-		goto err_crtc;
+		goto err_connector;
  	}
 
  	drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
@@ -89,7 +89,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);
 
@@ -111,12 +111,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 
  err_attach:
  	drm_encoder_cleanup(encoder);
-
-err_encoder:
-	drm_connector_cleanup(connector);
-
-err_crtc:
+err_connector:
  	drm_crtc_cleanup(crtc);
-
  	return ret;
  }
author maintainer
#3 lore raw

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

Quoted 29 lines · Maíra Canal

Hi Louis,

Quoted 26 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.

---
  drivers/gpu/drm/vkms/vkms_output.c | 19 +++++++------------
  1 file changed, 7 insertions(+), 12 deletions(-)
drivers/gpu/drm/vkms/vkms_output.c +1 -1
index 5128aa3b2eb6..8f7a05b73e1d 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,
@@ -70,17 +70,17 @@ int vkms_output_init(struct vkms_device *vkmsdev)
Quoted 8 lines

drivers/gpu/drm/vkms/vkms_output.c int vkms_output_init(struct vkms_device *vkmsdev) · line 73

Quoted 5 lines
drivers/gpu/drm/vkms/vkms_output.c +1 -1
  			if (IS_ERR(overlay)) {
  				DRM_DEV_ERROR(dev->dev, "Failed to init vkms plane\n");
  				ret = PTR_ERR(overlay);
-				goto err_crtc;
+				goto err_connector;

Why did you renamed err_crtc to err_connector? I think err_crtc looks correct.

I rename it many times during my work, it was never clear for me if "err_crtc" is about an error during the CRTC initialization or a label to clean the crtc.

If for you err_crtc is correct (ie err_<thing> means "cleanup <thing>"), I will switch to this pattern.

Thanks,
Louis Chauvet

Quoted 39 lines

Best Regards,
- Maíra

Quoted 36 lines
drivers/gpu/drm/vkms/vkms_output.c +5 -10
  			}
  			overlay->base.possible_crtcs = drm_crtc_mask(crtc);
  		}
  	}
-	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");
-		goto err_crtc;
+		goto err_connector;
  	}
  	drm_connector_helper_add(connector, &vkms_conn_helper_funcs);
@@ -89,7 +89,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);
@@ -111,12 +111,7 @@ int vkms_output_init(struct vkms_device *vkmsdev)
  err_attach:
  	drm_encoder_cleanup(encoder);
-
-err_encoder:
-	drm_connector_cleanup(connector);
-
-err_crtc:
+err_connector:
  	drm_crtc_cleanup(crtc);
-
  	return ret;
  }
 
author maintainer
#4 lore raw

PATCH v4 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 | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/gpu/drm/vkms/vkms_output.c +4 -10
index 8f7a05b73e1d..c878b2843d05 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;
@@ -85,18 +81,18 @@ 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;
+		goto err_connector;
 	}
 	encoder->possible_crtcs = drm_crtc_mask(crtc);
 
 	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) {
@@ -109,8 +105,6 @@ int vkms_output_init(struct vkms_device *vkmsdev)
 
 	return 0;
 
-err_attach:
-	drm_encoder_cleanup(encoder);
 err_connector:
 	drm_crtc_cleanup(crtc);
 	return ret;
Signature · 1 line
2.46.2
author maintainer
#5 lore raw

PATCH v4 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 a40295c18b48..877877dc0af1 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"
 
@@ -274,6 +275,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)
 {
@@ -304,5 +313,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 0f6805b9fe7b..eede3b8c70ef 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;
@@ -110,7 +102,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.46.2
author maintainer
#6 lore raw

PATCH v4 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 fc35f47e2849..fe4c1967860a 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 17e576c80169..5e5ff8dd9d9d 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.46.2
maintainer
#7 lore raw

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

Hi,

Quoted 31 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.

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 +1 -0
index fc35f47e2849..fe4c1967860a 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

drivers/gpu/drm/drm_connector.c void drm_connector_cleanup(struct drm_connector *connector) · line 637

Quoted 6 lines
drivers/gpu/drm/drm_connector.c +3 -0
@@ -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);
+

So I think it should live in its own patch.

You're doing multiple things here. There's a) the bug that writeback connectors aren't built properly, b) the discussion about how it's best to clean it up, and c) how to make every driver clean up properly.

AFAIU, you're trying to address a and c here.

I think putting that call in drm_connector_cleanup is backward compared to the pattern we're using in the rest of DRM.

drm_connector_cleanup should just clean what was allocated by drm_connector_init, and that's it.

So we should create a drm_writeback_connector_cleanup function to address a). That should be your first patch.

Now, it would indeed be best if drm_writeback_connector_cleanup didn't need to be called at all. That's the second part of your patch, and should be in its own patch as well. It would address b).

And finally, addressing c will require some driver changes, to either a call to drmm_writeback_connector_init_* or by using drm_writeback_connector_cleanup, but we'll have to make that change in every driver.

Maxime

author maintainer
#8 lore raw

PATCH v4 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 bc724cbd5e3a..a948f4598764 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,
@@ -174,10 +173,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.46.2
#9 lore raw
In reply to Louis Chauvet

Hi Louis,

How do you feel about adding the patch [1] to this series? This will avoid issues when reviewing and pushing the series?

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

Best Regards,
- Maíra

Quoted 67 lines · Louis Chauvet

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. This series depends on
[2] (for some code cleanup, which conflict with 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

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

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

[3]:https://lore.kernel.org/all/[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    |  31 ++---
  drivers/gpu/drm/vkms/vkms_writeback.c |  13 +-
  include/drm/drm_writeback.h           |  10 ++
  7 files changed, 238 insertions(+), 67 deletions(-)

---
base-commit: 33c255312660653cf54f8019896b5dca28e3c580
change-id: 20240521-google-vkms-managed-4aec99461a77
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: 920c23497fc5bd2fdf1dded06ce198c227ea0ef9

Best regards,

author maintainer
#10 lore raw
Quoted 4 lines · Maíra Canal

Hi Louis,

How do you feel about adding the patch [1] to this series? This will avoid issues when reviewing and pushing the series?

Ack!

Thanks,
Louis Chauvet

Quoted 74 lines

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

Best Regards,
- Maíra

Quoted 67 lines · Louis Chauvet

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. This series depends on
[2] (for some code cleanup, which conflict with 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

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

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

[3]:https://lore.kernel.org/all/[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    |  31 ++---
  drivers/gpu/drm/vkms/vkms_writeback.c |  13 +-
  include/drm/drm_writeback.h           |  10 ++
  7 files changed, 238 insertions(+), 67 deletions(-)

---
base-commit: 33c255312660653cf54f8019896b5dca28e3c580
change-id: 20240521-google-vkms-managed-4aec99461a77
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: 920c23497fc5bd2fdf1dded06ce198c227ea0ef9

Best regards,