| Message ID | 20261105-drm-no-more-config-reset-v1-47-1f58d1e33380@kernel.org (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-27257-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 32B201C41A4 for <noreply@patchwork.local>; Thu, 5 Nov 2026 16:40:53 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=kernel.org; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27257-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-27257-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id D578139EB7 for <noreply@patchwork.local>; Thu, 5 Nov 2026 15:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793892785; b=HIDGtgeIh15rLN4TfBW5gmyuUi/qKLiTgXG+bkyf3/zXJUHo2JllSsoPqBYn5C8U6ubQ PynZeBuV6q+dgZRS3RCEO+rlzwVEsKVDxilNK3B4Q92KIDe0DCSP5/LXPuszTNjm5Rr3H yYduqBHBH7i2OZRGo60zL7f0zlhLmJa0njxYIS50jQQX+WVmcnIPBPpfWM5Kl6CEL7b2T Gb0gi7mpMOQE9Pyn6yXG55ZpwomJ8R1JjrA48aIyfwhjutaXSOzxGtwCINvEy+Qrb6/5e 6wlGyN/QS3JbDD3M0/yC8j7Vr4BWwiZnvzWUSEVb5UP5I7ZxCLZvqy3krAZaMIx+lYg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793892785; h=X-Original-To:Received:Received:DKIM-Signature:From:Date:Subject: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=VYcSzDYe2cCmMS9VwuuEsQBYsAyzZgoeL8e35MmNwKw=; b=qZ+m6MvZsw4DV7Y8j/Zg/d78E7m7ZTpQ7EvkUu8F+pHocZihf8FF9p4tvuXAO11bBmIN r6xZe9Fcxf3dyGSywJ/EJEjKBbQa5VwwFkiJMUBFkxOEFAumFR23Gt2a6qnYCLXO/YvQU +AWDS51N9QR+4pt1dJ5ahp3eP3UqTwM6jwgAYOIctTzrBaAtTnN8iEDx02tg7loG2G1E5 f/18Qh11yu6n+44XLKIuH1pMQvfd47BVfQL6aXUs0/F7fNyO6YjRwG26sauwZfdcdA2s+ x4gEKJnWdNE4DyEAosghLFb3B+2W9novmarngFhklonvyRxbzL1E9TuC42dmM3ieQ/w== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gOUjQXS9; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2068606D808; Thu, 5 Nov 2026 15:33:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gOUjQXS9 X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793892784; b=paMbkTftycXt2XQ19D0rKzwAn8FI7bUpEoWBTlfLgidGUzhslxNXbn4Qo2tX08FBuTHi XS0O3MfYETcRNeRUtavz2clWt7kf1vhneePhgkxJ+BG3ShglDx+Ta+zkI9Y4px1MomaAH 31v99B0Dh/Uq0PPMy5Oo2IggjZWCbeepexLz1yth0YjiF5x5vm7IQfDdzEdmjv/Ws7tNG 76NyjuHwEmViyUx2X71GWs7fxhCXOlGZ1FvhwCcJJ40o3S85jbSlpYoTWVLE3XEisPvFU S5I6odS3HtlCA/De0vLA4GSWE/jhssjL0JlCHI/Kq+3ak++z5B8ICfWgnUdd8e7cudQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793892784; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=VYcSzDYe2cCmMS9VwuuEsQBYsAyzZgoeL8e35MmNwKw=; b=Jc/bQlPYcHOmfTyv7fAs9VnIcZQ0Dyq2bBwopI07qPJmKFegPRmz+p1OCVEztAODHhA/ +dfOBbnJX8WRBJoVkJUYKPfRr1Gm83LEyeOYg4FSYnC9wJqJ/Q6h89hvH/MXmi8jGsHaT hINp1OcgNJohQrqfK5IvyrGA7YeQTqCrtaRjqU1Y+T/As3WRlSn5RWpLrhrOnE5LUZH0f JQTt70WTdCJ2FUnU2YLu0m1Y74Mj5mEhbOoIJDfO8QU/fVbo14mQ65+zDwzdKdZupmG3F uHqQUoLLXCzXT2Flv3kualBmcT+IIJF2BZcg8ipz1Z+nR9Y+tBBo9oyOLGPKkxNGhTA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gOUjQXS9; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82FDC606A331 for <linux-sunxi@lists.linux.dev>; Thu, 5 Nov 2026 15:33:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 987C01F00A02; Thu, 5 Nov 2026 15:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793892784; bh=VYcSzDYe2cCmMS9VwuuEsQBYsAyzZgoeL8e35MmNwKw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=gOUjQXS9KJDLxlgEOrKHWcqdUTsEUC2QAcNp4sEJwNnf97Ce8rMkhoUj/aj9d7R36 WZgXRY8odHnwQvzVqQeevnxWbhbnw8zJotxbFq77VtR/UMxbymA9gKLvSdF5ATWnsZ Rh3TEwO/JHgyRNSO3prT/6oP7/vstHM3Ghek886lxnIquuuLWxZkgUbMB6BNxJENGc KDU91gW40DVDnKzfAOGzfxWARgz/7ps0Z9YIGcTdqiJ3ChvGLqd7YpKi8Ph/mNXG6s 5Ug5D3J7w6mgaSNXMAAf6LmeTcz+nTgxK5WcHVLs64uCPmfg+6wIhlih0nxsKHEeXN nJtZQ4blQeDiQ== From: Maxime Ripard <mripard@kernel.org> Date: Thu, 05 Nov 2026 16:29:56 +0100 Subject: [PATCH RESEND 47/83] drm/sun4i: Switch to drm_mode_config_create_initial_state X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Post: <mailto:linux-sunxi@lists.linux.dev> List-Help: <mailto:linux-sunxi+help@lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> List-Owner: <mailto:linux-sunxi+owner@lists.linux.dev> Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261105-drm-no-more-config-reset-v1-47-1f58d1e33380@kernel.org> References: <20261105-drm-no-more-config-reset-v1-0-1f58d1e33380@kernel.org> In-Reply-To: <20261105-drm-no-more-config-reset-v1-0-1f58d1e33380@kernel.org> To: David Airlie <airlied@gmail.com>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Simona Vetter <simona@ffwll.ch>, Thomas Zimmermann <tzimmermann@suse.de> Cc: Maxime Ripard <mripard@kernel.org>, dri-devel@lists.freedesktop.org, Chen-Yu Tsai <wens@kernel.org>, Samuel Holland <samuel@sholland.org>, linux-sunxi@lists.linux.dev X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1466; i=mripard@kernel.org; h=from:subject:message-id; bh=JVsRSfyjg+pxKH6555O56doMPhroT6uX2Lmd+IGrVQU=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDFlvFnziNjsXOUVFyUcsVje3VdLbxEGGNVrotgzn3XPZi TvmtRR2TGVhEOZkkBVTZHkiE3Z6efviKgf7lT9g5rAygQxh4OIUgInE5DDWex/J598sNbdmtcbF iR/1jm4xMgroPHvhdtHDB1dL5VZ9k7m/pOfLlqTz9tt3Fb6crMb/l7Gh/Rin2M2GD/OetO7o0Ht 6NODUg6euHnuqHXeuuv/Vibe5KNg4yFSYb1oD4+KprYvnqu0CAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [1.81 / 15.00]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; RCVD_COUNT_FIVE(0.00)[5]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_NEQ_ENVFROM(0.00)[mripard@kernel.org,linux-sunxi@lists.linux.dev]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20260515]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2]; TAGGED_FROM(0.00)[bounces-27257-noreply=patchwork.local]; FROM_HAS_DN(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns,linux.dev:email]; FORGED_SENDER_MAILLIST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; DKIM_TRACE(0.00)[kernel.org:+]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.103.45.18:received,100.77.114.92:received]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; DMARC_POLICY_ALLOW(0.00)[kernel.org,quarantine]; FREEMAIL_TO(0.00)[gmail.com,linux.intel.com,ffwll.ch,suse.de]; RCPT_COUNT_SEVEN(0.00)[9]; MIME_TRACE(0.00)[0:+]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from] X-Rspamd-Queue-Id: 32B201C41A4 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX |
| Series |
drm: Switch drivers to drm_mode_config_create_initial_state
|
|
Commit Message
Maxime Ripard
Nov. 5, 2026, 3:29 p.m. UTC
drm_mode_config_reset() has a dual role: it creates the initial KMS
state at probe time, and resets hardware and software state during
suspend/resume cycles.
Since the two roles need different behaviors (notably for objects like
drm_private_obj that must persist across suspend/resume),
drm_mode_config_create_initial_state() was introduced to handle only
the initial state creation at probe time.
Switch to drm_mode_config_create_initial_state().
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
Cc: Chen-Yu Tsai <wens@kernel.org>
Cc: Samuel Holland <samuel@sholland.org>
Cc: linux-sunxi@lists.linux.dev
---
drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Thu, Nov 5, 2026 at 11:33 PM Maxime Ripard <mripard@kernel.org> wrote: > > drm_mode_config_reset() has a dual role: it creates the initial KMS > state at probe time, and resets hardware and software state during > suspend/resume cycles. > > Since the two roles need different behaviors (notably for objects like > drm_private_obj that must persist across suspend/resume), > drm_mode_config_create_initial_state() was introduced to handle only > the initial state creation at probe time. > > Switch to drm_mode_config_create_initial_state(). > > Signed-off-by: Maxime Ripard <mripard@kernel.org> Acked-by: Chen-Yu Tsai <wens@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] drm/sun4i: sun4i_framebuffer_init() ignores state creation failure -- commit 9bfddf90d8dccabe2d26ebb9b512f7adbc95c198 Author: Maxime Ripard <mripard@kernel.org> drm/sun4i: Switch to drm_mode_config_create_initial_state This commit replaces the probe-time drm_mode_config_reset() call in sun4i_framebuffer_init() with drm_mode_config_create_initial_state() to create the initial KMS state. > diff --git a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c > index fc822bc2c62b5..0ce3691dedade 100644 > --- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c > +++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c > @@ -10,6 +10,7 @@ > #include <drm/drm_atomic_helper.h> > #include <drm/drm_blend.h> > #include <drm/drm_gem_framebuffer_helper.h> > +#include <drm/drm_print.h> > > #include "sun4i_drv.h" > #include "sun4i_framebuffer.h" > @@ -26,7 +27,8 @@ static const struct drm_mode_config_helper_funcs sun4i_de_mode_config_helpers = > > void sun4i_framebuffer_init(struct drm_device *drm) > { > - drm_mode_config_reset(drm); > + drm_WARN(drm, drm_mode_config_create_initial_state(drm), > + "Failed to create state\n"); [Severity: High] Should sun4i_framebuffer_init() return an int and propagate errors from drm_mode_config_create_initial_state(drm) back to sun4i_drv_bind()? When drm_mode_config_create_initial_state(drm) fails to allocate state for a private object, colorop, plane, CRTC, or connector, it returns early with a negative errno, leaving that object and all subsequent KMS objects with a NULL state pointer. Because sun4i_framebuffer_init() only warns and returns void, its caller sun4i_drv_bind() in drivers/gpu/drm/sun4i/sun4i_drv.c continues execution: sun4i_framebuffer_init(drm); /* Enable connectors polling */ drm_kms_helper_poll_init(drm); ret = drm_dev_register(drm, 0); if (ret) goto finish_poll; drm_client_setup(drm, NULL); When drm_client_setup(), a userspace atomic commit, or drm_atomic_helper_shutdown() duplicates plane state via sun4i_backend_layer_duplicate_state() in drivers/gpu/drm/sun4i/sun4i_layer.c, plane->state is dereferenced without a NULL check: struct sun4i_layer_state *orig = state_to_sun4i_layer_state(plane->state); struct sun4i_layer_state *copy; copy = kzalloc_obj(*copy); if (!copy) return NULL; __drm_atomic_helper_plane_duplicate_state(plane, ©->state); copy->uses_frontend = orig->uses_frontend; Could this cause a NULL pointer dereference in __drm_atomic_helper_plane_duplicate_state(), orig->uses_frontend, or during userspace property queries via drm_atomic_get_property() if sun4i_drv_bind() does not abort and jump to unbind_all on state creation failure?
diff --git a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c index fc822bc2c62b..0ce3691dedad 100644 --- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c +++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c @@ -11,4 +11,5 @@ #include <drm/drm_blend.h> #include <drm/drm_gem_framebuffer_helper.h> +#include <drm/drm_print.h> #include "sun4i_drv.h" @@ -27,5 +28,6 @@ static const struct drm_mode_config_helper_funcs sun4i_de_mode_config_helpers = void sun4i_framebuffer_init(struct drm_device *drm) { - drm_mode_config_reset(drm); + drm_WARN(drm, drm_mode_config_create_initial_state(drm), + "Failed to create state\n"); drm->mode_config.max_width = 8192;