drm/vkms: Switch all vkms object to DRM managed objects
Louis Chauvet
maintainerv3 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
[1] (for writeback connector) and [2] (for cleaning code).
PATCH 1/4: Migrate connector managment to drmm PATCH 2/4: Migrate encoder managment to drmm PATCH 3/4: Migrate connector management to drm PATCH 4/4: Migrate writeback connector management to drm
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[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 (4):
drm/vkms: Switch to managed for connector drm/vkms: Switch to managed for encoder drm/vkms: Switch to managed for crtc drm/vkms: Switch to managed for writeback connector
drivers/gpu/drm/vkms/vkms_crtc.c | 14 ++++++++++++++ drivers/gpu/drm/vkms/vkms_drv.c | 9 --------- drivers/gpu/drm/vkms/vkms_output.c | 25 +++++++------------------ drivers/gpu/drm/vkms/vkms_writeback.c | 13 ++++++------- 4 files changed, 27 insertions(+), 34 deletions(-)
---
base-commit: d2194256049910d286cd6c308c2689df521d8842
change-id: 20240521-google-vkms-managed-4aec99461a77
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: 93bfa5c36385932ea291789faa7356639d9e4bfc
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: 130816a16434cafa13b7a2b629398a20782be3a6
Best regards,
Signature · 1 line
Louis Chauvet <[email protected]>
Louis Chauvet
maintainerPATCH v3 1/4 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 | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/vkms/vkms_output.c +4 -9
@@ -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,
@@ -66,8 +66,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" ); goto err_connector;
@@ -79,7 +79,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);
@@ -101,12 +101,7 @@ int vkms_output_init(struct vkms_device *vkmsdev) err_attach:drm_encoder_cleanup (encoder); - -err_encoder: -drm_connector_cleanup (connector); - err_connector:drm_crtc_cleanup (crtc); -return ret; }
Signature · 1 line
2.44.2
Louis Chauvet
maintainerPATCH v3 2/4 drm/vkms: Switch to managed for encoder
In reply to Louis ChauvetThe 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
@@ -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;
@@ -75,18 +71,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) {
@@ -99,8 +95,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.44.2
Louis Chauvet
maintainerPATCH v3 3/4 drm/vkms: Switch to managed for crtc
In reply to Louis ChauvetThe 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
@@ -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"
@@ -272,6 +273,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) {
@@ -297,5 +306,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
@@ -53,14 +53,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 ,
Signature · 1 line
2.44.2
Louis Chauvet
maintainerPATCH v3 4/4 drm/vkms: Switch to managed for writeback connector
In reply to Louis ChauvetThe 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
@@ -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.44.2
v3 cover drm/vkms: Switch all vkms object to DRM managed objects
In reply to Louis ChauvetHi Louis,
Thanks for making this change even more atomic.
Quoted 12 lines
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
[1] (for writeback connector) and [2] (for cleaning code).PATCH 1/4: Migrate connector managment to drmm PATCH 2/4: Migrate encoder managment to drmm PATCH 3/4: Migrate connector management to drm PATCH 4/4: Migrate writeback connector management to drm
Quoted 4 lines
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/Signed-off-by Louis Chauvet <[email protected]>
The 4 patches:
Quoted 18 lines
---
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 renamevkms_output->vkms_crtcto avoid useless changes in
the last commit
- Extract the renameto_vkms_crtc_stateto
drm_crtc_state_to_vkms_crtc_stateto avoid useless changes in last
commit
- Extract thedrm_mode_crtc_set_gamma_sizeresult check in its own commit
- Rebased on drm-misc/drm-misc-next
- Link to v1: https://lore.kernel.org/r/[email protected]>
Louis Chauvet
maintainerQuoted 16 lines · José Expósito
Hi Louis,
Thanks for making this change even more atomic.
Quoted 12 lines
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
[1] (for writeback connector) and [2] (for cleaning code).PATCH 1/4: Migrate connector managment to drmm PATCH 2/4: Migrate encoder managment to drmm PATCH 3/4: Migrate connector management to drm PATCH 4/4: Migrate writeback connector management to drm
Quoted 7 lines
Quoted 4 lines
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/Signed-off-by Louis Chauvet <[email protected]>The 4 patches:
Reviewed-by José Expósito <[email protected]>
Thanks!
Louis Chauvet
Quoted 18 lines
Quoted 18 lines
---
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 renamevkms_output->vkms_crtcto avoid useless changes in
the last commit
- Extract the renameto_vkms_crtc_stateto
drm_crtc_state_to_vkms_crtc_stateto avoid useless changes in last
commit
- Extract thedrm_mode_crtc_set_gamma_sizeresult check in its own commit
- Rebased on drm-misc/drm-misc-next
- Link to v1: https://lore.kernel.org/r/[email protected]>