From nobody Thu Dec 18 12:11:44 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 37C582147FC for ; Mon, 31 Mar 2025 16:17:02 +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=1743437824; cv=none; b=GLN3pb6waAMhzcrwhUqggeu6o1sW7kvdFjMWwK0KBSxsCJDOC7sWuJtlRsEeOHYWlMdJaI6tTqosdMWNWYNJT3q2eDGZQDF+1m7sboJKOKThUhsP+Qau1gloQqNCBzSNbm+50uExIjBUG05z6yrs48Ft6ywH9cr2quEmRmUlxDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743437824; c=relaxed/simple; bh=dGFdiEEIoKrBY0CHQmQoP3dS1mlW8dQMT7u1cDNngOs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CgX7MV/eTYE5a/BkKEqbF8sxoN1bSPZH3v78pRBKaOmm2n1A78Kkbg0ng+7w3JFj4wY3/yx00IMk+ArI9dcmey8wCxdXXPkn5LctERwYbwVuXnu+NnYzuLXMZFfX+J0icjFdOjzOHoWsfaaFg+5xRrzflNVXqBvocEQXD2uA7Dc= 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=NntawUBT; 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="NntawUBT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743437822; 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=rc18XBScOjqMIv9eqwD1pgYcY8jfVOClLYYKTh2GFcQ=; b=NntawUBTIE0fE12R7zP+2bNTqeZ3B7sngHB/oiDWE8yjuXCDpbHbackYBbxfBq0Se41d8C 65eGImW6NUb+gOvaEDizSMya1GcLrufGzHxtTCBIpSkuYl5ATRLMw3DsM+c6pDtLfoI5xy uzl3rTbFWFf3JT1DL28o/fLC6QVKkFo= 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-433-ANJ93_-OOuSO9gkjg_HSTg-1; Mon, 31 Mar 2025 12:16:59 -0400 X-MC-Unique: ANJ93_-OOuSO9gkjg_HSTg-1 X-Mimecast-MFC-AGG-ID: ANJ93_-OOuSO9gkjg_HSTg_1743437817 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 03CB9195608B; Mon, 31 Mar 2025 16:16:57 +0000 (UTC) Received: from asrivats-na.rmtustx.csb (unknown [10.2.16.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9E7D119541A5; Mon, 31 Mar 2025 16:16:54 +0000 (UTC) From: Anusha Srivatsa Date: Mon, 31 Mar 2025 11:15:25 -0400 Subject: [PATCH v4 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: <20250331-b4-panel-refcounting-v4-1-dad50c60c6c9@redhat.com> References: <20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@redhat.com> In-Reply-To: <20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@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=1743434129; l=3414; i=asrivats@redhat.com; s=20250122; h=from:subject:message-id; bh=dGFdiEEIoKrBY0CHQmQoP3dS1mlW8dQMT7u1cDNngOs=; b=46v732Jvdko2Hi0ojuCGWwTcK3VysH+7AHOIiL4pc4l6mcyvhTsLQPkb4cEaby0m/QjVCdJ7n SGCf8ULoqgMD4GBEcK8fApAY8TCZstshnWjk7SsgtkRkMfBM9XFqw6m X-Developer-Key: i=asrivats@redhat.com; a=ed25519; pk=brnIHkBsUZEhyW6Zyn0U92AeIZ1psws/q8VFbIkf1AU= X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 --- v4: Remove documentation about refcounting in this patch, it is not used yet. 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 | 22 ++++++++++++++++++++++ 2 files changed, 47 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..415e85e8b76a15679f59c944ea1= 52367dc3e0488 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -268,6 +268,28 @@ 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. + * + * @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 Thu Dec 18 12:11:44 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 16676213236 for ; Mon, 31 Mar 2025 16:17:06 +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=1743437828; cv=none; b=kRgLrZ5gv6+WhGjKJ9lLoXdunwhQSD3I8HMYBCNaIQNKJnZpfKEXuiL3USus4AGsqNxHcD0NLqjuui5LAeUJxK+BUYgPkzLaQ7vVjJbydw7yL01NlsUH4fvcg/jQdDJFduJRzF+hKCR0IBlyE/MB6wVZa0qdrU8wUzdnqdUsdg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743437828; c=relaxed/simple; bh=QM4iAmDIhurPmjM7YRlhOnrKKefrpRcYPjipT7rVs7w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N7Z4BchK5iBOIliuuqNZfw3JPr8R9KGLHshlfufxwUkEbKi2+c9sXFutRguHg6viy8JNCrH0CJ5cy20k5fpc5a1tr7ZGUjKeyLdw+58TdAZiqkYOmDur76+/xgyAcSrgbLoWiPnFDSbCvKYY0Oxwf8NvTaboUYRT/23TBoK650M= 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=Y/Eg7z/q; 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="Y/Eg7z/q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743437825; 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=FfSVdAOWlV4aJ+zq8+1n6bx9TILsqQtAD2XqEIHNteo=; b=Y/Eg7z/q7unqjWCYiwKFCBuXWuxMd7DQ0FhF9WylM13jj2DXy5XrlhRUVfZ80cEJKdWE+0 zQWIv1Yy7XkZUintI+2pNt3Zc2EXb09+MgQ/Q0qd89l1Re0A5pbEqnqz6OKfFKkhfg5nFp 9Fc+yrQ6K2Wla1b6N6WwvIJFztbPQoU= Received: from mx-prod-mc-04.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-318-QsNJ_JmbMm6xy1crUlQkXw-1; Mon, 31 Mar 2025 12:17:01 -0400 X-MC-Unique: QsNJ_JmbMm6xy1crUlQkXw-1 X-Mimecast-MFC-AGG-ID: QsNJ_JmbMm6xy1crUlQkXw_1743437820 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DF5881955D82; Mon, 31 Mar 2025 16:16:59 +0000 (UTC) Received: from asrivats-na.rmtustx.csb (unknown [10.2.16.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5871E19541A5; Mon, 31 Mar 2025 16:16:57 +0000 (UTC) From: Anusha Srivatsa Date: Mon, 31 Mar 2025 11:15:26 -0400 Subject: [PATCH v4 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: <20250331-b4-panel-refcounting-v4-2-dad50c60c6c9@redhat.com> References: <20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@redhat.com> In-Reply-To: <20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@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=1743434129; l=5083; i=asrivats@redhat.com; s=20250122; h=from:subject:message-id; bh=QM4iAmDIhurPmjM7YRlhOnrKKefrpRcYPjipT7rVs7w=; b=OLb2iv4ClD0a5eueKA8xUwVdeNaViZ/nTYL8r+F2k+ZBET0++T6epaHC48PV12IpPMG7azjOX GJuK37VkImsChWhQrRv0e926VV0FxSJHZJMmUebo9qGROjyL5jEVcuF X-Developer-Key: i=asrivats@redhat.com; a=ed25519; pk=brnIHkBsUZEhyW6Zyn0U92AeIZ1psws/q8VFbIkf1AU= X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 --- v4: Add refcounting documentation in this patch (Maxime) 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 | 19 ++++++++++++++ 2 files changed, 82 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 415e85e8b76a15679f59c944ea152367dc3e0488..31d84f901c514c93ab6cbc09f44= 5853ef897bc95 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, @@ -282,6 +294,10 @@ void *__devm_drm_panel_alloc(struct device *dev, size_= t size, size_t offset, * @connector_type: the connector type (DRM_MODE_CONNECTOR_*) correspondin= g to * the panel interface * + * The reference count of the returned panel is initialized to 1. This + * reference will be automatically dropped via devm (by calling + * drm_panel_put()) when @dev is removed. + * * Returns: * Pointer to container structure embedding the panel, ERR_PTR on failure. */ @@ -294,6 +310,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 Thu Dec 18 12:11:44 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 D457D2AF10 for ; Mon, 31 Mar 2025 16:17:08 +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=1743437830; cv=none; b=PIh6NulIYuO5rIsbC5DbRI/eeah7sg0WqquJPz7RvGOhvywmvpWqcIbdYgYYOJn309t7EZHR/E9sKOtoHslAHInXymCP8EC0XS5ANtT3qpJl+vGi+KXfSAcEizAQ1bPSGTbyWpNxARAvrLUZ2baJ1Rlyetix9CX/I+Ss0tlRPt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743437830; c=relaxed/simple; bh=lScma3WC78BAb8OJv/MHz+La2UQ8ibAnbgwMH2uJn9Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ttLj/xkwiv0jBAC/tQof5BvzV/Z1W0fPpbvh4xfhFI/CNbVkQytu6BIAigrnfnkMp4pZz2mLOO05D8r9rljCaxTMuVkUbx4Csmo0+z9aqOH09a65RjZZPjllJcZcRghqhFGVgWx0FyB8F8dNyS5N+K+W8zTeag4nIJfnuIPBlzo= 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=jWThbAH+; 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="jWThbAH+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743437827; 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=e3bGbAmmjU2Q7nMUr6I9h6/rTkXSzTezZzF8OLBQQIw=; b=jWThbAH+GVglTDmvVzXPJwnzV8bbe6i/09BPi8/GwbTOhceAShfQYG6P2GPC9b9SOYIHbK +KXh2TT6xS6pOnqEMENg4YFNoCz4TM7ZzvBZWvt36w9CBZDj1Q9jXIcbakToA9pUI9Kljn q6A8scyzr6t1J/chYebwpKWad7DzDT0= 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-644-JV226XT9MwKY4Ex-eTrjGg-1; Mon, 31 Mar 2025 12:17:04 -0400 X-MC-Unique: JV226XT9MwKY4Ex-eTrjGg-1 X-Mimecast-MFC-AGG-ID: JV226XT9MwKY4Ex-eTrjGg_1743437822 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 7B7471809CA3; Mon, 31 Mar 2025 16:17:02 +0000 (UTC) Received: from asrivats-na.rmtustx.csb (unknown [10.2.16.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 69E1819560AD; Mon, 31 Mar 2025 16:17:00 +0000 (UTC) From: Anusha Srivatsa Date: Mon, 31 Mar 2025 11:15:27 -0400 Subject: [PATCH v4 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: <20250331-b4-panel-refcounting-v4-3-dad50c60c6c9@redhat.com> References: <20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@redhat.com> In-Reply-To: <20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@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=1743434129; l=1187; i=asrivats@redhat.com; s=20250122; h=from:subject:message-id; bh=lScma3WC78BAb8OJv/MHz+La2UQ8ibAnbgwMH2uJn9Y=; b=ByBbgmWB86JZYt/bHu1LZ7RyJZP2Ae45qmWc32Tke83AF2YH8w5l26zp0EjpXPk6MyrJuZ/s6 jljX5aUN49JA9JWtIRQ21+uuk8IH5dotY/Rnm0WxDR1zxbCUTZ5MTb7 X-Developer-Key: i=asrivats@redhat.com; a=ed25519; pk=brnIHkBsUZEhyW6Zyn0U92AeIZ1psws/q8VFbIkf1AU= X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 --- v4: none. 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 Thu Dec 18 12:11:44 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 38460214815 for ; Mon, 31 Mar 2025 16:17:10 +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=1743437833; cv=none; b=t4/gP90wNC4+p0fCarn5hxkVvBirBsYJEetuywPkLzVQsEgu1Ng2hKyEhYpA2O9rr6roUDr0e+ES2FS3yUuxW2Ls08iVl7VQnq3FGX49G1+IR20OUvkJj/8o5taiXW2Xu1iJAXuy2I7gXxBKEMlAAnPdaBwgrddm2Jq1z8SnPSU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743437833; c=relaxed/simple; bh=Z5nYVXi/n0DZaKeP9EMIATjTYHSvhfc6wg0Q/NsaJ9s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dTq0dfzr1AlBd7Z6D3gHH1bcv5BR3zDg8htP6x7iI47E+CSyuEKiB8H0SLJqYmBBDyoHJtV/QA07XfFGtzLd2BFU/+qC0CxEO6eqFfwWXaj/eFaYXsbnPuM/relSyo4aZYfREDJ/DdLBUVIiALqH96w1c6yv8SjR45s49F5gDEQ= 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=Gy4+AsuU; 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="Gy4+AsuU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743437830; 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=hXGoc6eNWHgPyvL59/knt6bfbN2WAIb4QRVcgXHCRwY=; b=Gy4+AsuUJ+RGdPEe/psVs42v3zQOz0fdYQxLsVLEUQUW9Dmx2j1bvDrlSOQjSYz1X0CU50 eVf2Aoie/VHWHZw9EOxxFXLgrTEJijWvI/r2vzAMr/0ebIBZHX0Plgth4fvhmEU+FTC+bL qBO/Wydzyhe7XLZwygVb077ay0L4Ea4= Received: from mx-prod-mc-04.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-501-nX5MjEheOYmm7nWRuTQKLQ-1; Mon, 31 Mar 2025 12:17:06 -0400 X-MC-Unique: nX5MjEheOYmm7nWRuTQKLQ-1 X-Mimecast-MFC-AGG-ID: nX5MjEheOYmm7nWRuTQKLQ_1743437825 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DE9EA19560BB; Mon, 31 Mar 2025 16:17:04 +0000 (UTC) Received: from asrivats-na.rmtustx.csb (unknown [10.2.16.30]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C6F1E19560AD; Mon, 31 Mar 2025 16:17:02 +0000 (UTC) From: Anusha Srivatsa Date: Mon, 31 Mar 2025 11:15:28 -0400 Subject: [PATCH v4 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: <20250331-b4-panel-refcounting-v4-4-dad50c60c6c9@redhat.com> References: <20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@redhat.com> In-Reply-To: <20250331-b4-panel-refcounting-v4-0-dad50c60c6c9@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=1743434129; l=1504; i=asrivats@redhat.com; s=20250122; h=from:subject:message-id; bh=Z5nYVXi/n0DZaKeP9EMIATjTYHSvhfc6wg0Q/NsaJ9s=; b=VRKcVruy50ncSpHKM4ig1iTQg0vWl8QIuHkau4lEzcxxdqiCLEj6OPMPTCYHGB9RgcY2PIZMF zTtsLhMiwiuD1NjNEan1qQr4jAX1oS6Incx4X4dS0SiQmk24zt8/QRp X-Developer-Key: i=asrivats@redhat.com; a=ed25519; pk=brnIHkBsUZEhyW6Zyn0U92AeIZ1psws/q8VFbIkf1AU= X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 --- v4: none. 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