OSDN Git Service

drm/vc4: vec: Switch to DRM-managed connector initialization
authorMaxime Ripard <maxime@cerno.tech>
Mon, 11 Jul 2022 17:39:29 +0000 (19:39 +0200)
committerMaxime Ripard <maxime@cerno.tech>
Wed, 13 Jul 2022 08:46:12 +0000 (10:46 +0200)
The current code will call drm_connector_unregister() and
drm_connector_cleanup() when the device is unbound. However, by then, there
might still be some references held to that connector, 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-60-maxime@cerno.tech
drivers/gpu/drm/vc4/vc4_vec.c

index 518b66b..4b843b1 100644 (file)
@@ -309,7 +309,6 @@ static int vc4_vec_connector_get_modes(struct drm_connector *connector)
 static const struct drm_connector_funcs vc4_vec_connector_funcs = {
        .detect = vc4_vec_connector_detect,
        .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,
@@ -322,12 +321,15 @@ static const struct drm_connector_helper_funcs vc4_vec_connector_helper_funcs =
 static int vc4_vec_connector_init(struct drm_device *dev, struct vc4_vec *vec)
 {
        struct drm_connector *connector = &vec->connector;
+       int ret;
 
        connector->interlace_allowed = true;
 
+       ret = drmm_connector_init(dev, connector, &vc4_vec_connector_funcs,
+                                DRM_MODE_CONNECTOR_Composite, NULL);
+       if (ret)
+               return ret;
 
-       drm_connector_init(dev, connector, &vc4_vec_connector_funcs,
-                          DRM_MODE_CONNECTOR_Composite);
        drm_connector_helper_add(connector, &vc4_vec_connector_helper_funcs);
 
        drm_object_attach_property(&connector->base,
@@ -556,9 +558,6 @@ err_put_runtime_pm:
 static void vc4_vec_unbind(struct device *dev, struct device *master,
                           void *data)
 {
-       struct vc4_vec *vec = dev_get_drvdata(dev);
-
-       drm_connector_cleanup(&vec->connector);
        pm_runtime_disable(dev);
 }