From nobody Sun Nov 24 09:56:27 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63AAD1DE2DA for ; Wed, 6 Nov 2024 10:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730890129; cv=none; b=Uivlh1/2fqN5zGs6A9kONF/VVZ7uMAEJgGkVfYgYL/qIGbhq+3CUP3zN0M6gf0AXYSv+8ERmFEbokLE7fxs8QticiUV9XHoM76Y+f4DCvi0+H/gDLXV4dJfQ/4azpbuKRKpgcst48jdTfGRRSaMV0cAYqfvqjWMiTYNt+eM8mdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730890129; c=relaxed/simple; bh=fL0FJMCi1hScPIlgpGJ/cgIhxfwzaCsKDP4Y+fgJtX0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h30WKhjA557eFZam7NKu5nnPAGdVUTgjAhVG1jyYTMsVODq/HoyfKcMTJaAdWehaMP4jseCt5LbesXKAMbV505WW0OrKsARwWVS+S5yru15Uz/akMNlcLWTLDEMHTwOgQ0nNFT0CZzrc3/jolNgLtUTSCbG3A09UD0Qsew3LmgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=h181rJVJ; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="h181rJVJ" Received: by mail.gandi.net (Postfix) with ESMTPSA id 21B026000B; Wed, 6 Nov 2024 10:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730890122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lEuh5s/boyvsj4t0oSTEvebQYcCGEo5tXwMo58H8NSk=; b=h181rJVJmgDXRgMEtKz1LRVCXHTYXIm4vQUmedPRaXj6vPKK90exzlyq2L8/A/iYHe9wHT XTQr0WSW/vlhd9bhOdYzc3dZQLbQGo0Wv5TqOPIVIdXQmLNPF75eZQGg3VkKu/U/TKRQse CFesmiaELt1plh0h5GPMqWTmr9uaqSn5YEahI+4xNFf0p9RbXPLrINWYaLQ36JD3MwKZPS /6crV0FVEFQF8P2t/cd8HIo36INu1NmrGMN4zTWVx9AX9tV8EMME7cuDFNqqjGgcfwbw6x FOy7KfaKETOfmrVwpsnE13SllWiCQ4g9yNRq/wZQj7ePoz3iDZt11nZLmv7tmg== From: Luca Ceresoli Date: Wed, 06 Nov 2024 11:48:24 +0100 Subject: [PATCH v2 1/4] drm/drm_mode_object: fix typo in kerneldoc Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241106-drm-small-improvements-v2-1-f6e2aef86719@bootlin.com> References: <20241106-drm-small-improvements-v2-0-f6e2aef86719@bootlin.com> In-Reply-To: <20241106-drm-small-improvements-v2-0-f6e2aef86719@bootlin.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-GND-Sasl: luca.ceresoli@bootlin.com Remove unintended extra word. Reviewed-by: Dmitry Baryshkov Signed-off-by: Luca Ceresoli --- include/drm/drm_mode_object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h index 08d7a7f0188fea79e2d8ad5ee6cc5044300f1a26..c68edbd126d04d51221f50aa2b4= 166475543b59f 100644 --- a/include/drm/drm_mode_object.h +++ b/include/drm/drm_mode_object.h @@ -35,7 +35,7 @@ struct drm_file; * @id: userspace visible identifier * @type: type of the object, one of DRM_MODE_OBJECT\_\* * @properties: properties attached to this object, including values - * @refcount: reference count for objects which with dynamic lifetime + * @refcount: reference count for objects with dynamic lifetime * @free_cb: free function callback, only set for objects with dynamic lif= etime * * Base structure for modeset objects visible to userspace. Objects can be --=20 2.34.1 From nobody Sun Nov 24 09:56:27 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63BA61DED75 for ; Wed, 6 Nov 2024 10:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730890130; cv=none; b=KoKHhvAAvWWKd2Fisful5XKS8U79QWfsRptwcztqNAVlEH0SYfX4ixkhJt7qsBf/uLm/bdWrNCKnm/drClvIkNH203lio8AjFDFkKVrhrUTB7tVjB2PbQrEl7QlE21D6xUhQ3a6UyOH3ZNwdT4JUIZoYiva0+B3togcwe4Gi/5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730890130; c=relaxed/simple; bh=Ar5XcHYjGMdPKGP6HDRcTQA2Or08PdX9Ib9xsuXrf8M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o1Ay4tA4c9fjA2VWhYQVNVhpyfK7wIDnejOe8QM5luSyMt6saqmW3uZ0uULcfNNm/4JK4fokuHQI9yREe4MW3FdS+N6eiGXh7WxxZ3DbN4UO1kazeOOxrzwazic4346P0Jp6XRj4tNU8rlX9eCo2aXEcLxp5qct+8HfncHzZYfk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=iwmaAYVc; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="iwmaAYVc" Received: by mail.gandi.net (Postfix) with ESMTPSA id EB5D560004; Wed, 6 Nov 2024 10:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730890123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BCLa0tO35kgSJnAc+IEReJ7llWiZ9cXdN6mBzaWALkE=; b=iwmaAYVcgo+NHt/egv/3PkjhMCjvpztcz+EeVbCapBLbwFRLH5OqjT5Mzck1Y4H40/HLn+ fpfr3r9+z4vLBtlm58VyKfv+PDXdiJk+gyFZ9npIM4jpZXbgM7bZ93d4wAmG3Lpp8yyM4O 70zcbYFYoFL1LFWWLNWf3Cj/63Sd0AsTmVQg9rCdadKkkJ91ZKBVf5Q7yMfq9B/8cbVKjg SYDc90FGwNBWEuz6yAEcFSYt5l2huPNwLlZm5VlrrpXaIJbFL87vItKN/mrOZVW6bRnCOR QU6IcbukSn9avYdZ/YpOeBfDn2yjml+3yg8y440KeAxG8E9OBBmspsthqC7kjg== From: Luca Ceresoli Date: Wed, 06 Nov 2024 11:48:25 +0100 Subject: [PATCH v2 2/4] drm/atomic-helper: improve CRTC enabled/connectors mismatch logging message Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241106-drm-small-improvements-v2-2-f6e2aef86719@bootlin.com> References: <20241106-drm-small-improvements-v2-0-f6e2aef86719@bootlin.com> In-Reply-To: <20241106-drm-small-improvements-v2-0-f6e2aef86719@bootlin.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-Sasl: luca.ceresoli@bootlin.com This message reports a mismatch between new_crtc_state->enable and has_connectors, which should be either both true or both false. However it does not mention which one is true and which is false, which can be useful for debugging. Add the value of both avriables to the log message. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_atomic_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atom= ic_helper.c index 43cdf39019a44537794cc5a519d139b0cb77073c..3c3bdef9bcf3c4ffcd861744f66= 07f317ab0c041 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -666,8 +666,9 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, } =20 if (new_crtc_state->enable !=3D has_connectors) { - drm_dbg_atomic(dev, "[CRTC:%d:%s] enabled/connectors mismatch\n", - crtc->base.id, crtc->name); + drm_dbg_atomic(dev, "[CRTC:%d:%s] enabled/connectors mismatch (%d/%d)\n= ", + crtc->base.id, crtc->name, + new_crtc_state->enable, has_connectors); =20 return -EINVAL; } --=20 2.34.1 From nobody Sun Nov 24 09:56:27 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63A1B1D278C for ; Wed, 6 Nov 2024 10:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730890128; cv=none; b=nQHZcGp3rWstURUjOksjLUr4UfAhu8v4tFUMkz620PqULf/EfRilLaU8NFK/t+riDDv2iqL5uMpI6cMSrvDbb4AqfzVUlCYcn07emigmM2cfisRSJ4Fwfzwdz8EbLvoX2UxA1vu0jTtOb9R875lEroXURpOrLF4T90TV7sYUW2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730890128; c=relaxed/simple; bh=4binOEGfu3XAPZLpw+QDubNdxl5QHjAjAsV26Hkdbos=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fccBmJS8iVV2mOr+piGkBYKbhUS0+bFKEaNuh5Ap5VjhaO0ASPu20j/5c3iDaHejE94OTlPGATS6bYLwiMIF75FvGIDiZG596RVERWSXij2uLPUKqp5wOR6JyuH/qvANbgnj3g48uPWW2n1hBDn8vLy9tJhx9ESFLXXpLzpiewc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Fl1PBQ8v; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Fl1PBQ8v" Received: by mail.gandi.net (Postfix) with ESMTPSA id B00336000E; Wed, 6 Nov 2024 10:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730890124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6pRM5jscZII9GohdxbWbdZ5ZoYRQpxbmot/dqfyy/mM=; b=Fl1PBQ8vf8xbrbvYM3xWTxSpEI3DdCvhNIBTbOYp6R+eDrsVaCDOKt0Jox0oPfimU1B9YA pHfLSpEqovaIxofsgJhE/kStmQesRRrZ0t/Pkptx6G3Uw4xLiTPe0CXzwD4C7H0dsR7/Y6 qi89zz5Y3iHIs+mDjaicJW1eeYQeGDzVj7hbBvDspF6VZg5nuR5TEksv97XYsCvG7n3yXd qTicJU3CcnPNi6EO8gP0kxj9vMtjnTdTJ/YtBcGqYe8jJTyMdO+/L/d71J8lmwKWod57eL ANYApORKl9n8h07Ab2yZpYzTsbZBgcDUvkwCqzdpiYbM9ClTo6iBsepwJHBi4Q== From: Luca Ceresoli Date: Wed, 06 Nov 2024 11:48:26 +0100 Subject: [PATCH v2 3/4] drm/mode_object: add drm_mode_object_read_refcount() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241106-drm-small-improvements-v2-3-f6e2aef86719@bootlin.com> References: <20241106-drm-small-improvements-v2-0-f6e2aef86719@bootlin.com> In-Reply-To: <20241106-drm-small-improvements-v2-0-f6e2aef86719@bootlin.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-Sasl: luca.ceresoli@bootlin.com Add a wrapper to kref_read() just like the ones already in place for kref_get() and kref_put(). This will be used for sanity checks on object lifetime. Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/drm_mode_object.c | 20 ++++++++++++++++++++ include/drm/drm_mode_object.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_o= bject.c index df4cc0e8e263d5887a799cf1a61d998234be7158..f990cc7e9b5d3bda34531235933= 14fa1ea2bf923 100644 --- a/drivers/gpu/drm/drm_mode_object.c +++ b/drivers/gpu/drm/drm_mode_object.c @@ -217,6 +217,26 @@ void drm_mode_object_get(struct drm_mode_object *obj) } EXPORT_SYMBOL(drm_mode_object_get); =20 +/** + * drm_mode_object_get - read the refcount for a mode object + * @obj: DRM mode object + * + * This function returns the current object's refcount if it is a + * refcounted modeset object, or 0 on any other object. + */ +unsigned int drm_mode_object_read_refcount(struct drm_mode_object *obj) +{ + unsigned int refcount =3D 0; + + if (obj->free_cb) { + refcount =3D kref_read(&obj->refcount); + DRM_DEBUG("OBJ ID: %d (%d)\n", obj->id, refcount); + } + + return refcount; +} +EXPORT_SYMBOL(drm_mode_object_read_refcount); + /** * drm_object_attach_property - attach a property to a modeset object * @obj: drm modeset object diff --git a/include/drm/drm_mode_object.h b/include/drm/drm_mode_object.h index c68edbd126d04d51221f50aa2b4166475543b59f..3d2c739e703888bf4520c61594d= 480f128d50e56 100644 --- a/include/drm/drm_mode_object.h +++ b/include/drm/drm_mode_object.h @@ -123,6 +123,7 @@ struct drm_mode_object *drm_mode_object_find(struct drm= _device *dev, uint32_t id, uint32_t type); void drm_mode_object_get(struct drm_mode_object *obj); void drm_mode_object_put(struct drm_mode_object *obj); +unsigned int drm_mode_object_read_refcount(struct drm_mode_object *obj); =20 int drm_object_property_set_value(struct drm_mode_object *obj, struct drm_property *property, --=20 2.34.1 From nobody Sun Nov 24 09:56:27 2024 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0D6F1DED76 for ; Wed, 6 Nov 2024 10:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730890129; cv=none; b=nEJ1t5Y39SvEjN2X2O0sBYQ+m+dwNUTqMbbqPhGQCZSRoa4P/E/BJ2ItXQ69O23midaNI+76O/86qkDo6t6VTAbD/OfPjpT6ojYbDEhsk0Fj/t7aK66w6MH+dLDBuU67sU9eP93o9CzOVTyeHyfGnPS4LwHhvI71XMSmVaR9HiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730890129; c=relaxed/simple; bh=pudTfM36kFQMq2RWVOPHfAT6VK0+RurGw7EGVRZsQII=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mm+FQ/e5ToXtbMl23BnifW3mUNfJCepEj9f38LFAxEDzKfVlsLsfhrUf+uE181AJQxcad7fQNTJjz18W3ceKk/h/cgVPkJnfcknoSXHfl6buoYq4BP9NtjdvsZ3YipQHwgk4WyfBHInWcv9+ic88I1fYn5PRXMzsmOcdiNotX0I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=kaUmYTxC; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="kaUmYTxC" Received: by mail.gandi.net (Postfix) with ESMTPSA id 6DAC160003; Wed, 6 Nov 2024 10:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730890125; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZWsYONnEgvEeIa9tipWPBTuf84MWmW0KPLgHIvkZDok=; b=kaUmYTxCnAY2Yaz8+lF+h/n9rzbIibLHfOtbjYi0RxCWz7kJHEgqIzosrye/v3wAiLSPLW gO9t/5T1tl6xNTSs2mPVzehbbookhUgglKSomQsH7cMyi+oTmW7jhhYhmKo8xYKRGsT7vQ lM81A82fyV1da9oFru9YDUO9/fIIOVB1h++XisPbFFxHmc9O7c78qxbpzwbYSCYbVD2/kV 3yUPLJw07eInHnS1s2gLJ8F2QK8kmW01qB5Gwy/2GOIb6wVy9EB0EzHSXbB4/F5kwkSvTO rAdLAmsK2Beluk6zyorHqG8v54mwsNjHmEUwfihpS+VpYxgbzWfK5mVI2gC+Tg== From: Luca Ceresoli Date: Wed, 06 Nov 2024 11:48:27 +0100 Subject: [PATCH v2 4/4] drm/connector: warn when cleaning up a refcounted connector Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241106-drm-small-improvements-v2-4-f6e2aef86719@bootlin.com> References: <20241106-drm-small-improvements-v2-0-f6e2aef86719@bootlin.com> In-Reply-To: <20241106-drm-small-improvements-v2-0-f6e2aef86719@bootlin.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.14.2 X-GND-Sasl: luca.ceresoli@bootlin.com Calling drm_connector_cleanup() should only be done via the free_cb =3D> .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. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Baryshkov --- 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_connecto= r.c index fc35f47e2849ed6786d6223ac9c69e1c359fc648..e0bf9c490af43055de4caaee158= 0a4befbd608c5 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 *conne= ctor) struct drm_device *dev =3D connector->dev; struct drm_display_mode *mode, *t; =20 + /* + * Cleanup must happen when the last ref is put, via the + * drm_connector_free() callback. + */ + WARN_ON(drm_mode_object_read_refcount(&connector->base) !=3D 0); + /* The connector should have been removed from userspace long before * it is finally destroyed. */ --=20 2.34.1