summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Ripard <maxime@cerno.tech>2022-07-11 19:39:28 +0200
committerMaxime Ripard <maxime@cerno.tech>2022-07-13 10:46:12 +0200
commitc62f432f2ed97305f96d393c5e3756ca1cd3c1de (patch)
treefbb358db4a82de0422e0dd7b825a56e74a1b7295
parentcd2444a7953972ed495b8c0e8f6202d6ad11fb0d (diff)
downloadlinux-c62f432f2ed97305f96d393c5e3756ca1cd3c1de.tar.bz2
drm/vc4: vec: Switch to DRM-managed encoder initialization
The current code will call drm_encoder_cleanup() when the device is unbound. However, by then, there might still be some references held to that encoder, including by the userspace that might still have the DRM device open. Let's switch to a DRM-managed initialization to clean up after ourselves only once the DRM device has been last closed. Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20220711173939.1132294-59-maxime@cerno.tech
-rw-r--r--drivers/gpu/drm/vc4/vc4_vec.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c
index 2e9dc09fc6f0..518b66bcc0b5 100644
--- a/drivers/gpu/drm/vc4/vc4_vec.c
+++ b/drivers/gpu/drm/vc4/vc4_vec.c
@@ -528,12 +528,18 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data)
pm_runtime_enable(dev);
- drm_simple_encoder_init(drm, &vec->encoder.base, DRM_MODE_ENCODER_TVDAC);
+ ret = drmm_encoder_init(drm, &vec->encoder.base,
+ NULL,
+ DRM_MODE_ENCODER_TVDAC,
+ NULL);
+ if (ret)
+ goto err_put_runtime_pm;
+
drm_encoder_helper_add(&vec->encoder.base, &vc4_vec_encoder_helper_funcs);
ret = vc4_vec_connector_init(drm, vec);
if (ret)
- goto err_destroy_encoder;
+ goto err_put_runtime_pm;
dev_set_drvdata(dev, vec);
@@ -541,8 +547,7 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data)
return 0;
-err_destroy_encoder:
- drm_encoder_cleanup(&vec->encoder.base);
+err_put_runtime_pm:
pm_runtime_disable(dev);
return ret;
@@ -554,7 +559,6 @@ static void vc4_vec_unbind(struct device *dev, struct device *master,
struct vc4_vec *vec = dev_get_drvdata(dev);
drm_connector_cleanup(&vec->connector);
- drm_encoder_cleanup(&vec->encoder.base);
pm_runtime_disable(dev);
}