From nobody Sat Nov 23 20:40:57 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 06E6B14F9E2 for ; Mon, 11 Nov 2024 12:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731328590; cv=none; b=VZuwIKGsLugXFCuaJ8prwe5zGgFBejn0EhCKTxY9fcxRf90uPLW2Hck05WqbKjhjO4LL+8qv0vgTBq7+y3YGTsfOxCdgF6UYNadu3wA9hVpgTWTLUaEEbRNHjTew7HnHzuCvCgpnLCu85Bx43AMjFyJfcMtE3AidlMVqMSkuPkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731328590; c=relaxed/simple; bh=fL0FJMCi1hScPIlgpGJ/cgIhxfwzaCsKDP4Y+fgJtX0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p4DZSofsxlokWmzlagx6FWoxF5oP4xBP6UuGke5hjk4IGIA3K/enrELv1a7K7Xh3xTfchTgnBjhnzDlwVPYdDSWSiSjCsGPMpz7+yPYca1X8R5iKYkTJVRohFyA//05eD7YXHHmC6kSMi8mbynfNBhXyS824RCelYq1aaxrSTCw= 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=c+gEJNaP; arc=none smtp.client-ip=217.70.183.201 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="c+gEJNaP" Received: by mail.gandi.net (Postfix) with ESMTPSA id 1291A1BF205; Mon, 11 Nov 2024 12:36:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731328586; 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=c+gEJNaPPByhBM/jbh1R2MB577WMJS78OPLv4pyQ3UKT52lBNxOwIscQTFD6MrVLj63IA4 E4m/nOff1S39jBi8g52TmEVu0XITVsfbBhFrIyydAH7iZ6zAK18Hbdl91DBnD6MH8f0uOK fX/BFT7VhWUYtnmrlJ+JT6GqGajZDlfkOPI9ZlSXajQESpPWEQ/8cRfOxzYvtLUn/jnEK6 TFRyOAX2HLYJLPhHCwycEIhGGSdnPB79lWuZNiD0ZA2Q71QNRtPJKGqUc58b5PXYfUZYe2 TH8Hkt2rmB3L715b2H3F78gWfypjYkWiyfjzOb/aVAHVI5NNzxQz1wKCouaFfw== From: Luca Ceresoli Date: Mon, 11 Nov 2024 13:36:20 +0100 Subject: [PATCH v3 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: <20241111-drm-small-improvements-v3-1-a9f576111b41@bootlin.com> References: <20241111-drm-small-improvements-v3-0-a9f576111b41@bootlin.com> In-Reply-To: <20241111-drm-small-improvements-v3-0-a9f576111b41@bootlin.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Dmitry Baryshkov , Jani Nikula , 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 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 Sat Nov 23 20:40:57 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 06891158DC8 for ; Mon, 11 Nov 2024 12:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731328591; cv=none; b=Zvnk9CYf3QPvi6/jD5DtX+Onbc8keWPlyw4qm4qJDHYATdZ6c4HNSJby9F8jalzFQs0VgQ8t5S7miqrfXgg0jfeBfgGDA6sUs9Gh7pglE1TXc3WXp8OQn+AK5RxOejlut3O+NqweDeJPgsQiXNqWQCGW7ptWJYtPxVcaPUdsls8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731328591; c=relaxed/simple; bh=kSdWZv45BDDhUC24J4bi6/wPp6QjTa1J8EaAUgQHctE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sWWBLoFU5C9EOLVV4d88AgTpVuw8Vb4vVyzIRYwTJGNQ/jPMAYfJpCIpk2EXJuyTXh5lg8W6R6vNxPRTq2/rIdVMcAWGzOCin4XaKZ50Ufb8ZQXoD9xStjgDoMOYugWQsnUPktFieNY5TqGELGwmoki04MmdOF8Gqm1m6xXvJrU= 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=Uq6BOQts; arc=none smtp.client-ip=217.70.183.201 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="Uq6BOQts" Received: by mail.gandi.net (Postfix) with ESMTPSA id 998591BF203; Mon, 11 Nov 2024 12:36:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731328587; 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=Gr5nT2Jnw+/2OVk2gGwP/gOTe4r8NyAUC5u+F+sceZw=; b=Uq6BOQtsHDIpjZ9LkBuzskd99TUcAEiOpsOoOXabdCdqVuSs0jba+kLLwlYzoI4As921Qc G1zRVfYyWJqtp5ebcCmTbVSJ9COqlpLfqlK1e8DA61uHhgNVFMozglBSY+BhwtPDgrwp68 RRPp1X+xOvAydUXvDfDXt1iM7gJCY0eX2L5jbaNJ1nyPrtx2PL4mxlRLzjOF8QwuNQuN/L Kbd3zo5BfaxzcLMCZ9SaZmdYizBlwXklp0Q3ZhbKcfg5fDAw/IY05N6fDT1zSt7fVrDMEh 3fX1gAkvKKGfwVjMiL4/S51jRIkpMt7WLUpSycSByRVKiT5feYBTGF41NUBg5A== From: Luca Ceresoli Date: Mon, 11 Nov 2024 13:36:21 +0100 Subject: [PATCH v3 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: <20241111-drm-small-improvements-v3-2-a9f576111b41@bootlin.com> References: <20241111-drm-small-improvements-v3-0-a9f576111b41@bootlin.com> In-Reply-To: <20241111-drm-small-improvements-v3-0-a9f576111b41@bootlin.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Dmitry Baryshkov , Jani Nikula , 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. Reviewed-by: Dmitry Baryshkov Signed-off-by: Luca Ceresoli --- 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 Sat Nov 23 20:40:57 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 0AD21199938 for ; Mon, 11 Nov 2024 12:36:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731328591; cv=none; b=ABNGsDc3wbPPXLQ3a41VEQa9D7dEKD7eSa7jLIOo4+BXQGEGPisgp3x8envlA7nULatTO4+ng1h6ADKGq9gRFO8Qj8Op71brFJVCWGgGWJwiI+ka7P4zsIWLHTlvvd8xN0luk4qR/AA+Yu3kXih2ajVUyovmD6udBXsXPC0y1Lo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731328591; c=relaxed/simple; bh=0SJMUdIo0vcYqeGqB8sU7dxtzNBNywrmH0+lcVQv05E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IGwutuSSzPxRdxxoASOv4CWnd9JW8qRWhr+eVLFzhjsbTdfXRw3sR/GnsjbyqiKlBnpWiXHTSCp6NqRIayB1aqN8Lc5TRM0yubxoZqHvNREeaUbPaWM+iim1tGb/DFbHUL5rDXybQ6EpgoZ06vgSyVW2jIfBIkXLeMBzA7vgRUM= 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=ik/UjZ5k; arc=none smtp.client-ip=217.70.183.201 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="ik/UjZ5k" Received: by mail.gandi.net (Postfix) with ESMTPSA id 7BCFD1BF206; Mon, 11 Nov 2024 12:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731328588; 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=J90J1NyXaKoXccZe2X72ycchhXTtGFZ2PH6GpQkBJsQ=; b=ik/UjZ5kr0Ad8hjStoOIneAgh2ZLiENJBEpnLMi+S8NqjvfpY0KieoBs+OZnU1Zk5hJ0C5 VYH1y8+uGfLFccje9VR5csfmr8SU5+rrE4Kx4IqVhcdDqhWh+C2Lyuvye5K2zBf8ffNYQa rNXGKsWsDEN8qvCUFa0eHQrvbatX31gPKYcVMIkJelOKnNZwiKDh/Hp742tv51ApX3cJuZ +GWZuOKU4/RvIqDCCNiZkfuHmimrd4RHvtUSMS+W9NjKmMyd4ikKgEIjhZez/W1bVFZ4zb bAObfeKbIPuXoPPIGSV0PcaDl5NdOPApsGonT+Spe5vy4zwen7pn/YYQcur54g== From: Luca Ceresoli Date: Mon, 11 Nov 2024 13:36:22 +0100 Subject: [PATCH v3 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: <20241111-drm-small-improvements-v3-3-a9f576111b41@bootlin.com> References: <20241111-drm-small-improvements-v3-0-a9f576111b41@bootlin.com> In-Reply-To: <20241111-drm-small-improvements-v3-0-a9f576111b41@bootlin.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Dmitry Baryshkov , Jani Nikula , 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 --- Changed in v3: * use conventions for 'Returns' doc syntax * ditch DRM_DEBUG() and as a consequence rework and simplify the entire function * fix function name in kerneldoc --- drivers/gpu/drm/drm_mode_object.c | 17 +++++++++++++++++ include/drm/drm_mode_object.h | 1 + 2 files changed, 18 insertions(+) diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_o= bject.c index df4cc0e8e263d5887a799cf1a61d998234be7158..b9a16aceb926782eb033434eb69= 67ce9fd2e94f7 100644 --- a/drivers/gpu/drm/drm_mode_object.c +++ b/drivers/gpu/drm/drm_mode_object.c @@ -217,6 +217,23 @@ void drm_mode_object_get(struct drm_mode_object *obj) } EXPORT_SYMBOL(drm_mode_object_get); =20 +/** + * drm_mode_object_read_refcount - read the refcount for a mode object + * @obj: DRM mode object + * + * Returns: + * The current object refcount if it is a refcounted modeset object, or 0 + * for any other object. + */ +unsigned int drm_mode_object_read_refcount(struct drm_mode_object *obj) +{ + if (obj->free_cb) + return kref_read(&obj->refcount); + + return 0; +} +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 Sat Nov 23 20:40:57 2024 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 C052F19CC3C for ; Mon, 11 Nov 2024 12:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731328592; cv=none; b=FKL9y7kVNEJjvaaxzE1uUQrGAmkQIV7hoOk8vYRU4M8SXFl14ipI8Rf9rvvuGpHUuCeNtvLXeha10n7/mogbM1YkYXivEARiyzcYHZ1YyD/UPO7RKAkbw9OOQXZhRY/SOPfZhsUEfkAyrn3QDfAVTXB5xrRHCrcaAaKDXLtMdrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731328592; c=relaxed/simple; bh=H0MySrUxWDCqvEAcb0pedeQRSOE3Bds2iksJxEoUuwM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f9iFupOpd8V8vSo+LAwMY7YHxSdb6YK1UA4JG+Gqq3oEotBxzVw/3lDEHZsUsu/g85rTbubKkL1DS9h3jdadMYBAt0+kTlR3gRJf6Y3lQzNTtpybnJve/MelKqZVPPddlLTMql0pPwqpIyQf+Rzs9Tjxy8j7wLyVombPpPu5SBI= 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=LDGfpUG3; arc=none smtp.client-ip=217.70.183.201 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="LDGfpUG3" Received: by mail.gandi.net (Postfix) with ESMTPSA id 5BBA01BF209; Mon, 11 Nov 2024 12:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1731328589; 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=qW3wdr4EeYIZ0MLaRPPuH3cK65j246cHF8/ZPxNc2Bo=; b=LDGfpUG3r6SAvyB0iHpIkXFrP9CQ12QOeFNpf5UcYXU+t6/9WL1alKBVgF+NqLVOzt5HkI RJGaFAVgeOIrLylJ7JwiznbRhkMNuvvocphw1ONk+1dThmEvpatSqBARiAb25/GwZ4a1GR YrfybiCo/WwijUlYAx1GtV9kqRV5SKTESGb8JvTzm0iKsz8DKnl6/1rfwc3+I+zI7XgXfl I7Qo4HPnnGUrvbtY96L33pXfpABVFDglcVRP4l1bm7I8061+PnNU4oo6E//UVFw9KhHZpN 0PwWzNw0s3X0htqCFXO6GvAL7MY/qW08qiShxEX04p93lqO2wA0c1TyWBsKdkg== From: Luca Ceresoli Date: Mon, 11 Nov 2024 13:36:23 +0100 Subject: [PATCH v3 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: <20241111-drm-small-improvements-v3-4-a9f576111b41@bootlin.com> References: <20241111-drm-small-improvements-v3-0-a9f576111b41@bootlin.com> In-Reply-To: <20241111-drm-small-improvements-v3-0-a9f576111b41@bootlin.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Dmitry Baryshkov , Jani Nikula , 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. Reviewed-by: Dmitry Baryshkov Signed-off-by: Luca Ceresoli --- 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