From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
Jani Nikula <jani.nikula@linux.intel.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Louis Chauvet <louis.chauvet@bootlin.com>
Subject: [PATCH RESEND v3 4/4] drm/connector: warn when cleaning up a refcounted connector
Date: Mon, 16 Dec 2024 17:40:51 +0100 [thread overview]
Message-ID: <20241216-drm-small-improvements-v3-4-78bbc95ac776@bootlin.com> (raw)
In-Reply-To: <20241216-drm-small-improvements-v3-0-78bbc95ac776@bootlin.com>
Calling drm_connector_cleanup() should only be done via the free_cb =>
.destroy path, which cleans up the struct drm_connector only when the
refcount drops to zero.
A cleanup done with a refcount higher than 0 can result from buggy code,
e.g. by doing cleanup directly in the drivers teardown code. Serious
trouble can happen if this happens, so warn about it.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/drm_connector.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index fc35f47e2849ed6786d6223ac9c69e1c359fc648..e0bf9c490af43055de4caaee1580a4befbd608c5 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -624,6 +624,12 @@ void drm_connector_cleanup(struct drm_connector *connector)
struct drm_device *dev = connector->dev;
struct drm_display_mode *mode, *t;
+ /*
+ * Cleanup must happen when the last ref is put, via the
+ * drm_connector_free() callback.
+ */
+ WARN_ON(drm_mode_object_read_refcount(&connector->base) != 0);
+
/* The connector should have been removed from userspace long before
* it is finally destroyed.
*/
--
2.34.1
next prev parent reply other threads:[~2024-12-16 16:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 16:40 [PATCH RESEND v3 0/4] DRM: small improvements Luca Ceresoli
2024-12-16 16:40 ` [PATCH RESEND v3 1/4] drm/drm_mode_object: fix typo in kerneldoc Luca Ceresoli
2024-12-16 16:50 ` Louis Chauvet
2024-12-16 16:40 ` [PATCH RESEND v3 2/4] drm/atomic-helper: improve CRTC enabled/connectors mismatch logging message Luca Ceresoli
2024-12-16 16:50 ` Louis Chauvet
2024-12-16 16:40 ` [PATCH RESEND v3 3/4] drm/mode_object: add drm_mode_object_read_refcount() Luca Ceresoli
2024-12-16 16:47 ` Louis Chauvet
2024-12-16 16:40 ` Luca Ceresoli [this message]
2024-12-16 16:50 ` [PATCH RESEND v3 4/4] drm/connector: warn when cleaning up a refcounted connector Louis Chauvet
2024-12-25 15:15 ` kerne test robot
2024-12-30 15:16 ` Luca Ceresoli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241216-drm-small-improvements-v3-4-78bbc95ac776@bootlin.com \
--to=luca.ceresoli@bootlin.com \
--cc=airlied@gmail.com \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=louis.chauvet@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=thomas.petazzoni@bootlin.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®