From nobody Fri Dec 19 19:56:48 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 27E6F14A60F for ; Mon, 31 Mar 2025 03:25:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743391555; cv=none; b=eoOHDsWNrccRk1PSs5pgGQ3a1upvwe5FAF91gEmw0srh0NxlQBXKuZ79gpjWMlK2iSCssK5PxdYHxpRsucgJD9xc7jFxOCfbd/FE60cZ65AAwyAoz8QTqy7FdhD/4x48GZ+lJAnFamqgFVX2SfE0PqP0FD+XyN1BjUtrFUfsgrw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743391555; c=relaxed/simple; bh=ztdkY1ss/9PtHD6IzZCu1QbinWII/RS9hI8sz/8L6pM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EVDoW0Vn9rCoK61U5leXPtPJyEpfwOIdXxFJnc7GiUURIBt+tj106vYDwPVRAYBiVaW3N3GRZGqXybI1ilbdkET/yyhT5njMp7YpK5yGl1z9lCCORxmtr0mVFRGZEGyYYxuaSJS/pI0Qq8RGgDwQ03L+ETyf7FRo6n+jLIT6eTs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TBN0G/2M; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TBN0G/2M" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743391552; 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=o27B54Im+dw43JYOHAsgw1pUKwXO0ARViylQUoAlBYg=; b=TBN0G/2MiYhLGEX2L/eLO5uTMUF4kWPS4axrZOF2+rHMC/fk08U3mFharRSSH0OMLQFfNq GfNcar6BMMEGA8q3uiNHpk4L+E5twu1zpFMtT0rntkPI8sHCykq89d8HUiSIDtOO3Pd3I/ BiUu+8LODHkqPfWdyo0nGwiQaKvLSK8= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-149-3-We4BRZPDSn-IlR196uGA-1; Sun, 30 Mar 2025 23:25:45 -0400 X-MC-Unique: 3-We4BRZPDSn-IlR196uGA-1 X-Mimecast-MFC-AGG-ID: 3-We4BRZPDSn-IlR196uGA_1743391544 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E945B18007E1; Mon, 31 Mar 2025 03:25:43 +0000 (UTC) Received: from asrivats-na.rmtustx.csb (unknown [10.2.16.30]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9E33C180176A; Mon, 31 Mar 2025 03:25:41 +0000 (UTC) From: Anusha Srivatsa Date: Sun, 30 Mar 2025 22:24:12 -0400 Subject: [PATCH v3 1/4] drm/panel: Add new helpers for refcounted panel allocatons 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: <20250330-b4-panel-refcounting-v3-1-0e0d4e4641eb@redhat.com> References: <20250330-b4-panel-refcounting-v3-0-0e0d4e4641eb@redhat.com> In-Reply-To: <20250330-b4-panel-refcounting-v3-0-0e0d4e4641eb@redhat.com> To: Neil Armstrong , Jessica Zhang , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Anusha Srivatsa X-Developer-Signature: v=1; a=ed25519-sha256; t=1743387855; l=3433; i=asrivats@redhat.com; s=20250122; h=from:subject:message-id; bh=ztdkY1ss/9PtHD6IzZCu1QbinWII/RS9hI8sz/8L6pM=; b=quVFYg6YD9mAWAODi7cFoEzm6BSHnkWFrpAr1TFJNsQ6UXVuc/HoRxm9uAGvP+ObO6fyeIghc NsIl8tCm7pNCykbm4QhpGx+6Tb81XXnXHljABpVwZwp+XbZOazI0wzS X-Developer-Key: i=asrivats@redhat.com; a=ed25519; pk=brnIHkBsUZEhyW6Zyn0U92AeIZ1psws/q8VFbIkf1AU= X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Introduce reference counted allocations for panels to avoid use-after-free. The patch adds the macro devm_drm_bridge_alloc() to allocate a new refcounted panel. Followed the documentation for drmm_encoder_alloc() and devm_drm_dev_alloc and other similar implementations for this purpose. Reviewed-by: Maxime Ripard Signed-off-by: Anusha Srivatsa Suggested-by: Maxime Ripard --- v3: Remove include. Fix typos. Code style corrections (Luca) - Move the documentation to the main helper instead of in returns (Maxime) v2: Better documentation for connector_type field - follow drm_panel_init documentation. (Luca) - Clarify the refcount initialisation in comments.(Maxime) - Correct the documentation of the return type (Maxime) --- drivers/gpu/drm/drm_panel.c | 25 +++++++++++++++++++++++++ include/drm/drm_panel.h | 24 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index c627e42a7ce70459f50eb5095fffc806ca45dabf..bdeab5710ee324dc1742fbc7758= 2250960556308 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -355,6 +355,31 @@ struct drm_panel *of_drm_find_panel(const struct devic= e_node *np) } EXPORT_SYMBOL(of_drm_find_panel); =20 +void *__devm_drm_panel_alloc(struct device *dev, size_t size, size_t offse= t, + const struct drm_panel_funcs *funcs, + int connector_type) +{ + void *container; + struct drm_panel *panel; + + if (!funcs) { + dev_warn(dev, "Missing funcs pointer\n"); + return ERR_PTR(-EINVAL); + } + + container =3D devm_kzalloc(dev, size, GFP_KERNEL); + if (!container) + return ERR_PTR(-ENOMEM); + + panel =3D container + offset; + panel->funcs =3D funcs; + + drm_panel_init(panel, dev, funcs, connector_type); + + return container; +} +EXPORT_SYMBOL(__devm_drm_panel_alloc); + /** * of_drm_get_panel_orientation - look up the orientation of the panel thr= ough * the "rotation" binding from a device tree node diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index a9c042c8dea1a82ef979c7a68204e0b55483fc28..97a5457b64fbbe9c91c6a4f41b8= e1fbfe4fa604e 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -268,6 +268,30 @@ struct drm_panel { bool enabled; }; =20 +void *__devm_drm_panel_alloc(struct device *dev, size_t size, size_t offse= t, + const struct drm_panel_funcs *funcs, + int connector_type); + +/** + * devm_drm_panel_alloc - Allocate and initialize a refcounted panel. + * The reference count is initialised to 1 and is automatically given back + * by devm action. + * + * @dev: struct device of the panel device + * @type: the type of the struct which contains struct &drm_panel + * @member: the name of the &drm_panel within @type + * @funcs: callbacks for this panel + * @connector_type: the connector type (DRM_MODE_CONNECTOR_*) correspondin= g to + * the panel interface + * + * Returns: + * Pointer to container structure embedding the panel, ERR_PTR on failure. + */ +#define devm_drm_panel_alloc(dev, type, member, funcs, connector_type) \ + ((type *)__devm_drm_panel_alloc(dev, sizeof(type), \ + offsetof(type, member), funcs, \ + connector_type)) + void drm_panel_init(struct drm_panel *panel, struct device *dev, const struct drm_panel_funcs *funcs, int connector_type); --=20 2.48.1 From nobody Fri Dec 19 19:56:48 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 064D1F9CB for ; Mon, 31 Mar 2025 03:25:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743391554; cv=none; b=s3wi6zjECdJQ1FV/jLez1WLAHnBAsvctfbZq1r0cx3//Iel0zNFGGPR6Z1EiKluA+EGYlL/oSSC4ae0kf22auV3oSyw6oB/ej/9ocLqLyHHwfooRjK0GKtE4M0ab03G2FtLZGLcNzHsKkor+Z7KIPIIseYNAoSYrkL5bvwef/F0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743391554; c=relaxed/simple; bh=DoR5/VZXVBzYD8Bh9VJZWzLpSoYgFBcfigl+6Gt4zx4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JvTmX2q39A0q/vXwU5Vq3XGcpTm2zJ06BDqBIy8US5RzBsVKT4wscVyxmyEbw464KI3TogbKYwaf5cPY8y6kFrJKwhOXrKazTgJVLqFMSJZN5iABAstGjDztQMEsSMq9Rmv/m5XoIgyW/VZEkK2OIZXujyDFscOYTdu2R1jqAFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OBMbapTe; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OBMbapTe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743391551; 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=5T/7FftKdPKD3W/7jWlPs9qhLB+6a9D8aoiBDQmOjYo=; b=OBMbapTezzxNxrNT89fK0kIobvLGYYrwpQbvfjctVjFJzFxvADFgPiexzAXdULkwVuo4Fb XWX/z1ZQUIxan7b4zwoIrmN7wnw/wHbl0diKQa4SY5g4eACyIZNSzHBjlUswFuVpJqF+Eb dZcB67BadveZ256/R4fjn1kdq3zSkCo= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-S2nStVIvNkqmhWULI7WxbA-1; Sun, 30 Mar 2025 23:25:48 -0400 X-MC-Unique: S2nStVIvNkqmhWULI7WxbA-1 X-Mimecast-MFC-AGG-ID: S2nStVIvNkqmhWULI7WxbA_1743391546 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B349C1933B49; Mon, 31 Mar 2025 03:25:46 +0000 (UTC) Received: from asrivats-na.rmtustx.csb (unknown [10.2.16.30]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4774A180174E; Mon, 31 Mar 2025 03:25:44 +0000 (UTC) From: Anusha Srivatsa Date: Sun, 30 Mar 2025 22:24:13 -0400 Subject: [PATCH v3 2/4] drm/panel: Add refcount support 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: <20250330-b4-panel-refcounting-v3-2-0e0d4e4641eb@redhat.com> References: <20250330-b4-panel-refcounting-v3-0-0e0d4e4641eb@redhat.com> In-Reply-To: <20250330-b4-panel-refcounting-v3-0-0e0d4e4641eb@redhat.com> To: Neil Armstrong , Jessica Zhang , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Anusha Srivatsa X-Developer-Signature: v=1; a=ed25519-sha256; t=1743387855; l=4525; i=asrivats@redhat.com; s=20250122; h=from:subject:message-id; bh=DoR5/VZXVBzYD8Bh9VJZWzLpSoYgFBcfigl+6Gt4zx4=; b=4CAI971VEyiUDlrEtz01eKkDBl51GU09h8i8iBx/+HRNuGtU7iFqbFoo9zK0LVoRPwCxw0WY0 8ZoBs4vg5gXBGX6AAHv7871kpUDNB4qtg29xjZCl8CEBtlpnxnJsHFW X-Developer-Key: i=asrivats@redhat.com; a=ed25519; pk=brnIHkBsUZEhyW6Zyn0U92AeIZ1psws/q8VFbIkf1AU= X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Allocate panel via reference counting. Add _get() and _put() helper functions to ensure panel allocations are refcounted. Avoid use after free by ensuring panel pointer is valid and can be usable till the last reference is put. Reviewed-by: Luca Ceresoli Reviewed-by: Maxime Ripard Signed-off-by: Anusha Srivatsa Suggested-by: Maxime Ripard --- v3: Add include in this patch (Luca) v2: Export drm_panel_put/get() (Maxime) - Change commit log with better workding (Luca, Maxime) - Change drm_panel_put() to return void (Luca) - Code Cleanups - add return in documentation, replace bridge to panel (Luca) --- drivers/gpu/drm/drm_panel.c | 64 +++++++++++++++++++++++++++++++++++++++++= +++- include/drm/drm_panel.h | 15 +++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index bdeab5710ee324dc1742fbc77582250960556308..7b17531d85a4dc3031709919564= d2e4d8332f748 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -355,24 +355,86 @@ struct drm_panel *of_drm_find_panel(const struct devi= ce_node *np) } EXPORT_SYMBOL(of_drm_find_panel); =20 +static void __drm_panel_free(struct kref *kref) +{ + struct drm_panel *panel =3D container_of(kref, struct drm_panel, refcount= ); + + kfree(panel->container); +} + +/** + * drm_panel_get - Acquire a panel reference + * @panel: DRM panel + * + * This function increments the panel's refcount. + * Returns: + * Pointer to @panel + */ +struct drm_panel *drm_panel_get(struct drm_panel *panel) +{ + if (!panel) + return panel; + + kref_get(&panel->refcount); + + return panel; +} +EXPORT_SYMBOL(drm_panel_get); + +/** + * drm_panel_put - Release a panel reference + * @panel: DRM panel + * + * This function decrements the panel's reference count and frees the + * object if the reference count drops to zero. + */ +void drm_panel_put(struct drm_panel *panel) +{ + if (panel) + kref_put(&panel->refcount, __drm_panel_free); +} +EXPORT_SYMBOL(drm_panel_put); + +/** + * drm_panel_put_void - wrapper to drm_panel_put() taking a void pointer + * + * @data: pointer to @struct drm_panel, cast to a void pointer + * + * Wrapper of drm_panel_put() to be used when a function taking a void + * pointer is needed, for example as a devm action. + */ +static void drm_panel_put_void(void *data) +{ + struct drm_panel *panel =3D (struct drm_panel *)data; + + drm_panel_put(panel); +} + void *__devm_drm_panel_alloc(struct device *dev, size_t size, size_t offse= t, const struct drm_panel_funcs *funcs, int connector_type) { void *container; struct drm_panel *panel; + int err; =20 if (!funcs) { dev_warn(dev, "Missing funcs pointer\n"); return ERR_PTR(-EINVAL); } =20 - container =3D devm_kzalloc(dev, size, GFP_KERNEL); + container =3D kzalloc(size, GFP_KERNEL); if (!container) return ERR_PTR(-ENOMEM); =20 panel =3D container + offset; + panel->container =3D container; panel->funcs =3D funcs; + kref_init(&panel->refcount); + + err =3D devm_add_action_or_reset(dev, drm_panel_put_void, panel); + if (err) + return ERR_PTR(err); =20 drm_panel_init(panel, dev, funcs, connector_type); =20 diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 97a5457b64fbbe9c91c6a4f41b8e1fbfe4fa604e..095e03c6e660d838b227e7a5cf8= ca9b88c4bdc3d 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -28,6 +28,7 @@ #include #include #include +#include =20 struct backlight_device; struct dentry; @@ -266,6 +267,17 @@ struct drm_panel { * If true then the panel has been enabled. */ bool enabled; + + /** + * @container: Pointer to the private driver struct embedding this + * @struct drm_panel. + */ + void *container; + + /** + * @refcount: reference count of users referencing this panel. + */ + struct kref refcount; }; =20 void *__devm_drm_panel_alloc(struct device *dev, size_t size, size_t offse= t, @@ -296,6 +308,9 @@ void drm_panel_init(struct drm_panel *panel, struct dev= ice *dev, const struct drm_panel_funcs *funcs, int connector_type); =20 +struct drm_panel *drm_panel_get(struct drm_panel *panel); +void drm_panel_put(struct drm_panel *panel); + void drm_panel_add(struct drm_panel *panel); void drm_panel_remove(struct drm_panel *panel); =20 --=20 2.48.1 From nobody Fri Dec 19 19:56:48 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 5A6D81531DB for ; Mon, 31 Mar 2025 03:25:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743391557; cv=none; b=Zsxh+WoGuww7DL25YHrTS3NP6xMYa+Dzkcnc9C/SHBWtam3eIvOGLJTDYxGr1lzT3WjOFjAQSzdIDU88zQsEM3IMvtBF5i4Y4GJ2QcWckkufGo13pibAwOBmzPAKm95SWUZZacJKfDCuvouRUgwvBQKWEr/RiUl7graJ10fJuTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743391557; c=relaxed/simple; bh=Twe1CysgUNTNxjLGPaIExyaLHYsOasZCKyjWS8eMjhA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZtorSOzIyt0tjqZ82gSbvG829qdUC78KrFqv1Qa7jMwGrusHoLMNTf5qfeFJmgTXpBO3cDqxcVIVuhfFSsXWH/Eyp0S1kTWWHjLDHLcg/gX9Q1kTIWQJhUV7blsdFYxcmZc3KsZtBljncO8F6oibFwoLrl2dRFDo15YsXSSYlxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SvF2wLuM; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SvF2wLuM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743391555; 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=EhpkmaQVIlApTG41YTRyXQK7jdbH/Wt/GFmqtV6AMfA=; b=SvF2wLuM2Adp655FSZXMgGs099EFVA7VNukkjgQ+ZZkCvCNtY5zSpRgerju6H68nONeV/n UmHfm3EIFoulyGUmNDaPYePtn+SRXLyERLpVUki/XpUWsDFKqq3Q192tP+WAKbw63iPybZ to0653ehh3Faz34CW5wB0EQbZTYm46E= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-482-2ryQG2YgO6qSpCCVuJHKUw-1; Sun, 30 Mar 2025 23:25:51 -0400 X-MC-Unique: 2ryQG2YgO6qSpCCVuJHKUw-1 X-Mimecast-MFC-AGG-ID: 2ryQG2YgO6qSpCCVuJHKUw_1743391549 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C508180AF69; Mon, 31 Mar 2025 03:25:49 +0000 (UTC) Received: from asrivats-na.rmtustx.csb (unknown [10.2.16.30]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DDE99180174E; Mon, 31 Mar 2025 03:25:46 +0000 (UTC) From: Anusha Srivatsa Date: Sun, 30 Mar 2025 22:24:14 -0400 Subject: [PATCH v3 3/4] drm/panel: deprecate old-style panel allocation 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: <20250330-b4-panel-refcounting-v3-3-0e0d4e4641eb@redhat.com> References: <20250330-b4-panel-refcounting-v3-0-0e0d4e4641eb@redhat.com> In-Reply-To: <20250330-b4-panel-refcounting-v3-0-0e0d4e4641eb@redhat.com> To: Neil Armstrong , Jessica Zhang , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Anusha Srivatsa X-Developer-Signature: v=1; a=ed25519-sha256; t=1743387855; l=1175; i=asrivats@redhat.com; s=20250122; h=from:subject:message-id; bh=Twe1CysgUNTNxjLGPaIExyaLHYsOasZCKyjWS8eMjhA=; b=qPYwBUSgg0/FV4MK0h42rjCekrEsvS/zH6bc8ugbOnDVh6oEkGewYpYksG9LqvTAJnCne1AO/ JaY6xXQXikCAM5NS8iXo9DIGebCxN5vAU2yzgaW5x8t0Vc9Pte4LtUN X-Developer-Key: i=asrivats@redhat.com; a=ed25519; pk=brnIHkBsUZEhyW6Zyn0U92AeIZ1psws/q8VFbIkf1AU= X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Start moving to the new refcounted allocations using the new API devm_drm_panel_alloc(). Deprecate any other allocation. Reviewed-by: Luca Ceresoli Reviewed-by: Maxime Ripard Signed-off-by: Anusha Srivatsa Suggested-by: Maxime Ripard --- v3: none v2: make the documentation changes in v1 more precise (Maxime) --- drivers/gpu/drm/drm_panel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 7b17531d85a4dc3031709919564d2e4d8332f748..870bf8d471ee9c5fe65d88acc13= 661cacd883b9b 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -74,8 +74,9 @@ EXPORT_SYMBOL(drm_panel_init); * drm_panel_add - add a panel to the global registry * @panel: panel to add * - * Add a panel to the global registry so that it can be looked up by displ= ay - * drivers. + * Add a panel to the global registry so that it can be looked + * up by display drivers. The panel to be added must have been + * allocated by devm_drm_panel_alloc(). */ void drm_panel_add(struct drm_panel *panel) { --=20 2.48.1 From nobody Fri Dec 19 19:56:48 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 BD092155725 for ; Mon, 31 Mar 2025 03:25:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743391559; cv=none; b=Wa8QhC1h8TnOOycppyiFvhmJG1QeZMEKEHOc5wyzRQiOy/1BnQurxR16E60Mgjiof+udbd5dw/PlJ/sQ2kqO601fKLZVe39HD+ccwNZIw0XaOHCGH6vphXV59x0PM9Fuyl/aF9C7CrG0P/UGHdm8jMR2YCclsnSYnmh+aauAKnQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743391559; c=relaxed/simple; bh=1RmX9btvC0nrxtXfEOn96R8eo8jQJomf59RfizwYlhU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pmnTcZB2DAHGhxoRq1AyB+YYJPl+NyCUjfmUBL3L6XRv4xF49DUYQIsLf8uinUmp0W2OR56gQRcVBn6+2OSUHuMvsBUH/kgogfv8WFvlc4AZO3YRXUXVa3pVe5nm7FsyKgGz8eADNxanbNXAWZpOBawBnVAkRqAngSQtW+Fghg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=al8tgib8; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="al8tgib8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743391556; 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=Dp5hDKc9ocj3PapOSfucBXLZObsSVMAvb4l+1lFut9g=; b=al8tgib86E+cYzOnkuwNqKVJDzokgnrstmi9WwJSKJSZy84xFTvCrP5biEj9iyt4/nD7bn 9YZMKKKUfmZ7zCzNuv3mN1k7CzTieELNsEdGPEaEy+rV+gUoD8zpa0I8ay9ftO7Bk9JThp 8q4R97a79a2OP3FhLy2gmJ65eyLAI6Y= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-467-zvVDH3_gP5KFGotVKCR3Hg-1; Sun, 30 Mar 2025 23:25:53 -0400 X-MC-Unique: zvVDH3_gP5KFGotVKCR3Hg-1 X-Mimecast-MFC-AGG-ID: zvVDH3_gP5KFGotVKCR3Hg_1743391551 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B64D71809CA6; Mon, 31 Mar 2025 03:25:51 +0000 (UTC) Received: from asrivats-na.rmtustx.csb (unknown [10.2.16.30]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AEBFA1801750; Mon, 31 Mar 2025 03:25:49 +0000 (UTC) From: Anusha Srivatsa Date: Sun, 30 Mar 2025 22:24:15 -0400 Subject: [PATCH v3 4/4] drm/panel/panel-simple: Use the new allocation in place of devm_kzalloc() 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: <20250330-b4-panel-refcounting-v3-4-0e0d4e4641eb@redhat.com> References: <20250330-b4-panel-refcounting-v3-0-0e0d4e4641eb@redhat.com> In-Reply-To: <20250330-b4-panel-refcounting-v3-0-0e0d4e4641eb@redhat.com> To: Neil Armstrong , Jessica Zhang , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Anusha Srivatsa X-Developer-Signature: v=1; a=ed25519-sha256; t=1743387855; l=1493; i=asrivats@redhat.com; s=20250122; h=from:subject:message-id; bh=1RmX9btvC0nrxtXfEOn96R8eo8jQJomf59RfizwYlhU=; b=aGlaH7CQI0rCXfb+GZf33QE8HKvJKdW3rTkPYluP3K2B6mzYl/xbhfprl/tcOblu/OuDenzg1 R1Vioa/JrRyCcw/LrrPwT8WjFBMBEx7XwF20RVj3SMkvo9iDA4MiNs/ X-Developer-Key: i=asrivats@redhat.com; a=ed25519; pk=brnIHkBsUZEhyW6Zyn0U92AeIZ1psws/q8VFbIkf1AU= X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Start using the new helper that does the refcounted allocations. Reviewed-by: Luca Ceresoli Reviewed-by: Maxime Ripard Signed-off-by: Anusha Srivatsa Suggested-by: Maxime Ripard --- v3: none. v2: check error condition (Luca) --- drivers/gpu/drm/panel/panel-simple.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/p= anel-simple.c index 6ba600f97aa4c8daae577823fcf17ef31b0eb46f..df718c4a86cb7dc0cd126e807d3= 3306e5a21d8a0 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -579,9 +579,10 @@ static int panel_simple_probe(struct device *dev, cons= t struct panel_desc *desc) u32 bus_flags; int err; =20 - panel =3D devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL); - if (!panel) - return -ENOMEM; + panel =3D devm_drm_panel_alloc(dev, struct panel_simple, base, + &panel_simple_funcs, desc->connector_type); + if (IS_ERR(panel)) + return PTR_ERR(panel); =20 panel->desc =3D desc; =20 @@ -694,8 +695,6 @@ static int panel_simple_probe(struct device *dev, const= struct panel_desc *desc) pm_runtime_set_autosuspend_delay(dev, 1000); pm_runtime_use_autosuspend(dev); =20 - drm_panel_init(&panel->base, dev, &panel_simple_funcs, connector_type); - err =3D drm_panel_of_backlight(&panel->base); if (err) { dev_err_probe(dev, err, "Could not find backlight\n"); --=20 2.48.1