Unverified Commit 19d094c3 authored by Maxime Ripard's avatar Maxime Ripard
Browse files

drm/vc4: hdmi: Switch to DRM-managed connector initialization



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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220711173939.1132294-41-maxime@cerno.tech
parent 56924791
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -374,7 +374,6 @@ vc4_hdmi_connector_duplicate_state(struct drm_connector *connector)
static const struct drm_connector_funcs vc4_hdmi_connector_funcs = {
	.detect = vc4_hdmi_connector_detect,
	.fill_modes = drm_helper_probe_single_connector_modes,
	.destroy = drm_connector_cleanup,
	.reset = vc4_hdmi_connector_reset,
	.atomic_duplicate_state = vc4_hdmi_connector_duplicate_state,
	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
@@ -392,10 +391,13 @@ static int vc4_hdmi_connector_init(struct drm_device *dev,
	struct drm_encoder *encoder = &vc4_hdmi->encoder.base;
	int ret;

	drm_connector_init_with_ddc(dev, connector,
	ret = drmm_connector_init(dev, connector,
				  &vc4_hdmi_connector_funcs,
				  DRM_MODE_CONNECTOR_HDMIA,
				  vc4_hdmi->ddc);
	if (ret)
		return ret;

	drm_connector_helper_add(connector, &vc4_hdmi_connector_helper_funcs);

	/*
@@ -2999,7 +3001,7 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)

	ret = vc4_hdmi_hotplug_init(vc4_hdmi);
	if (ret)
		goto err_destroy_conn;
		goto err_put_runtime_pm;

	ret = vc4_hdmi_cec_init(vc4_hdmi);
	if (ret)
@@ -3021,8 +3023,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
	vc4_hdmi_cec_exit(vc4_hdmi);
err_free_hotplug:
	vc4_hdmi_hotplug_exit(vc4_hdmi);
err_destroy_conn:
	drm_connector_cleanup(&vc4_hdmi->connector);
err_put_runtime_pm:
	pm_runtime_put_sync(dev);
err_disable_runtime_pm:
@@ -3065,7 +3065,6 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master,
	vc4_hdmi_audio_exit(vc4_hdmi);
	vc4_hdmi_cec_exit(vc4_hdmi);
	vc4_hdmi_hotplug_exit(vc4_hdmi);
	drm_connector_cleanup(&vc4_hdmi->connector);

	pm_runtime_disable(dev);