| Message ID | 20260814-drm-no-more-plane-reset-v2-32-82d2963dd134@kernel.org (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-25170-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 BE3C11C1EDA for <noreply@patchwork.local>; Fri, 14 Aug 2026 16:58:59 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=kernel.org; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-25170-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-25170-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 3F5A3300D44C for <noreply@patchwork.local>; Fri, 14 Aug 2026 14:58:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0867A3D16F8; Fri, 14 Aug 2026 14:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HxjqhX8m" X-Original-To: linux-sunxi@lists.linux.dev Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 7DA7E46D57E for <linux-sunxi@lists.linux.dev>; Fri, 14 Aug 2026 14:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786719536; cv=none; b=HCVPVP8OtQ34DII5NF97cV2+G9bE8pfLZ8FJUFUmozxqvcGYAKVt7oz0OM1wvy/yFeR1TRFifZvPM0PWqcIZriL+bMJT8SH2uXXXlG7CsqtKYngNyBlwa5XNyvGK+idRN9QCa22wt+hM32AoVT+8lw2fWQWlqOnspM4K39xB6Kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786719536; c=relaxed/simple; bh=Ks6TPY6U1oA1Li+JEGmjvECyXoNPZ4SqfDUkLHsYcdo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IvBLEJEDCNU46Yuysn7WkR1faYE7hGQvr5hTpkgbw7YyZ+41NYQnZ16zXVEl/xgWMYHtRed8bEc61SMtPwV7SGHUMujS1WW7j8x74EORowvlTS6xI6aBf7VxgbPUvT0Nzla/WLJsmCZFrOfnO+XG7WD4CgqvHdcSlR7Ge+hAQss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HxjqhX8m; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B067D1F000E9; Fri, 14 Aug 2026 14:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786719535; bh=7VwMp9xDZHM8Ao1QCNczmSlCSzwYkjg7GoiIf6xXp3g=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=HxjqhX8mZmMgOfBml70KX+De9Y/3omIb8Wt0OvYPyKhpTkV8Xipfb56cydxyxd17r kxXjs040O+35KFA3bSWancd6vnblskCghbXBk9xYEq4OY1/7GsBa/K4gBzPIsA+5hf acnTckN7R9NAg7F1SCDZTOBDZSRL2Vg2Xg4I6DpH81yfhCuwg3GmAsE7omGLuZrOde d6dKZw/xYoA1rU4dt6zZm5ekDCwJpJ5p4u98V+Sd5Ev5dLa/ULMGQ3Aff7F/ikhhwT xC+EVN6mLOkc7MnKXgx5OFROABijnD5LA42Y1SxGQkqjHoxWv8r4cVpwdHNwQOj4D1 J4AYv4CFrhoBA== From: Maxime Ripard <mripard@kernel.org> Date: Fri, 14 Aug 2026 16:57:21 +0200 Subject: [PATCH v2 32/61] drm/sun4i: sun8i: Convert to atomic_create_state Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260814-drm-no-more-plane-reset-v2-32-82d2963dd134@kernel.org> References: <20260814-drm-no-more-plane-reset-v2-0-82d2963dd134@kernel.org> In-Reply-To: <20260814-drm-no-more-plane-reset-v2-0-82d2963dd134@kernel.org> To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch> Cc: dri-devel@lists.freedesktop.org, Maxime Ripard <mripard@kernel.org>, linux-sunxi@lists.linux.dev, samuel@sholland.org, wens@kernel.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6932; i=mripard@kernel.org; h=from:subject:message-id; bh=Ks6TPY6U1oA1Li+JEGmjvECyXoNPZ4SqfDUkLHsYcdo=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDFn1OpeMOescLrGz8X47k5z4vPSKdoBP58K/8dolfctfJ 6cKHWDomMrCIMzJICumyPJEJuz08vbFVQ72K3/AzGFlAhnCwMUpABOpV2Ss08p0PryzJDyRR5KP RWChtPbxs59yTrfzFc7NX1pwUkGR8XvmtgDLjD3xt1bo33Xe+s6Jsd7j8e/FWYeqmi007j05uvD PwVKh2keb9vBummHywayA/8HdGq5TN7zv6F5hXjUvOZP/pyQA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= |
| Series |
drm/plane: Convert all drivers to atomic_create_state and remove reset
|
|
Commit Message
Maxime Ripard
Aug. 14, 2026, 2:57 p.m. UTC
The plane only initializes a pristine state in its reset hook
using drm_atomic_helper_plane_reset(), which is equivalent to what
atomic_create_state expects. Convert to it.
The conversion was done using the following Coccinelle semantic patch:
@@
identifier funcs;
symbol drm_atomic_helper_plane_reset;
symbol drm_atomic_helper_plane_create_state;
@@
struct drm_plane_funcs funcs = {
...,
- .reset = drm_atomic_helper_plane_reset,
+ .atomic_create_state = drm_atomic_helper_plane_create_state,
...,
};
@match_struct_reset@
identifier funcs, reset_func;
@@
struct drm_plane_funcs funcs = {
...,
.reset = reset_func,
...,
};
@reset_uses_helpers depends on match_struct_reset@
identifier match_struct_reset.reset_func;
@@
void reset_func(...)
{
<+...
(
__drm_atomic_helper_plane_reset(...);
|
__drm_gem_reset_shadow_plane(...);
)
...+>
}
@match_struct_destroy@
identifier funcs, destroy_func;
@@
struct drm_plane_funcs funcs = {
...,
.atomic_destroy_state = destroy_func,
...,
};
@script:python renamed_func@
old_name << match_struct_reset.reset_func;
new_name;
@@
if old_name.endswith("_reset"):
coccinelle.new_name = old_name.replace("_reset", "_create_state")
else:
coccinelle.new_name = old_name
@update_struct depends on match_struct_reset && reset_uses_helpers@
identifier match_struct_reset.funcs, match_struct_reset.reset_func;
identifier renamed_func.new_name;
@@
struct drm_plane_funcs funcs = {
...,
- .reset = reset_func,
+ .atomic_create_state = new_name,
...,
};
@drop_destroy depends on update_struct && match_struct_destroy@
identifier match_struct_reset.reset_func;
identifier match_struct_destroy.destroy_func;
identifier container_func;
identifier P;
symbol drm_atomic_helper_plane_destroy_state;
symbol __drm_atomic_helper_plane_destroy_state;
@@
void reset_func(struct drm_plane *P)
{
...
(
- if (P->state) {
- <+...
(
- drm_atomic_helper_plane_destroy_state(P, P->state);
|
- __drm_atomic_helper_plane_destroy_state(P->state);
|
- P->funcs->atomic_destroy_state(P, P->state);
|
- destroy_func(P, P->state);
)
- ...+>
- }
|
- drm_WARN_ON_ONCE(P->dev, P->state);
|
- WARN_ON(P->state);
)
...
(
- kfree(P->state);
|
- kfree(container_func(P->state));
|
// kfree is optional
)
(
- P->state = NULL;
|
// plane->state clearing is optional
)
...
}
@drop_destroy_mtk depends on update_struct@
identifier P;
symbol __drm_atomic_helper_plane_destroy_state;
symbol to_mtk_plane_state;
@@
void mtk_plane_reset(struct drm_plane *P)
{
...
- if (P->state) {
- __drm_atomic_helper_plane_destroy_state(P->state);
- ...
- } else {
...
- }
...
}
@transform_nv50_wndw depends on update_struct@
identifier S;
@@
void nv50_wndw_reset(...)
{
...
- if (WARN_ON(!(S = kzalloc_obj(*S))))
+ S = kzalloc_obj(*S);
+ if (WARN_ON(!S))
return;
...
}
@transform_kzalloc depends on update_struct@
identifier match_struct_reset.reset_func;
identifier P, S;
statement ST;
statement list STL;
@@
void reset_func(struct drm_plane *P)
{
<...
S = kzalloc_obj(*S);
(
- if (S)
- {
- STL
- }
+ if (!S) return;
+
+ STL
|
- if (S) ST
+ if (!S) return;
+
+ ST
)
...>
}
@transform_body depends on update_struct@
identifier match_struct_reset.reset_func;
identifier renamed_func.new_name;
identifier S, P;
expression PS;
@@
- void reset_func(struct drm_plane *P)
+ struct drm_plane_state *new_name(struct drm_plane *P)
{
...
S = kzalloc_obj(*S);
...
(
if (!S) {
...
- return;
+ return ERR_PTR(-ENOMEM);
}
|
if (WARN_ON(!S)) {
...
- return;
+ return ERR_PTR(-ENOMEM);
}
|
if (S == NULL) {
...
- return;
+ return ERR_PTR(-ENOMEM);
}
)
...
(
- __drm_atomic_helper_plane_reset(P, PS);
+ __drm_atomic_helper_plane_state_init(PS, P);
|
- __drm_gem_reset_shadow_plane(P, PS);
+ __drm_gem_shadow_plane_state_init(P, PS);
)
...
}
@update_early_return depends on update_struct@
identifier match_struct_reset.reset_func;
identifier renamed_func.new_name;
identifier P;
expression PS;
@@
struct drm_plane_state *new_name(struct drm_plane *P)
{
<+...
- return;
+ return ERR_PTR(-EINVAL);
...+>
}
@update_return_plane depends on update_struct@
identifier match_struct_reset.reset_func;
identifier renamed_func.new_name;
identifier P;
expression PS;
@@
struct drm_plane_state *new_name(struct drm_plane *P)
{
...
__drm_atomic_helper_plane_state_init(PS, P);
...
+
+ return PS;
}
@update_return_shadow depends on update_struct@
identifier renamed_func.new_name;
identifier P;
expression PS;
@@
struct drm_plane_state *new_name(struct drm_plane *P)
{
...
__drm_gem_shadow_plane_state_init(P, PS);
...
+
+ return &PS->base;
}
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
Cc: linux-sunxi@lists.linux.dev
Cc: samuel@sholland.org
Cc: wens@kernel.org
---
drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 2 +-
drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Comments
On Fri, Aug 14, 2026 at 10:58 PM Maxime Ripard <mripard@kernel.org> wrote: > > The plane only initializes a pristine state in its reset hook > using drm_atomic_helper_plane_reset(), which is equivalent to what > atomic_create_state expects. Convert to it. > > The conversion was done using the following Coccinelle semantic patch: > > @@ > identifier funcs; > symbol drm_atomic_helper_plane_reset; > symbol drm_atomic_helper_plane_create_state; > @@ > > struct drm_plane_funcs funcs = { > ..., > - .reset = drm_atomic_helper_plane_reset, > + .atomic_create_state = drm_atomic_helper_plane_create_state, > ..., > }; > > @match_struct_reset@ > identifier funcs, reset_func; > @@ > struct drm_plane_funcs funcs = { > ..., > .reset = reset_func, > ..., > }; > > @reset_uses_helpers depends on match_struct_reset@ > identifier match_struct_reset.reset_func; > @@ > > void reset_func(...) > { > <+... > ( > __drm_atomic_helper_plane_reset(...); > | > __drm_gem_reset_shadow_plane(...); > ) > ...+> > } > > @match_struct_destroy@ > identifier funcs, destroy_func; > @@ > struct drm_plane_funcs funcs = { > ..., > .atomic_destroy_state = destroy_func, > ..., > }; > > @script:python renamed_func@ > old_name << match_struct_reset.reset_func; > new_name; > @@ > if old_name.endswith("_reset"): > coccinelle.new_name = old_name.replace("_reset", "_create_state") > else: > coccinelle.new_name = old_name > > @update_struct depends on match_struct_reset && reset_uses_helpers@ > identifier match_struct_reset.funcs, match_struct_reset.reset_func; > identifier renamed_func.new_name; > @@ > struct drm_plane_funcs funcs = { > ..., > - .reset = reset_func, > + .atomic_create_state = new_name, > ..., > }; > > @drop_destroy depends on update_struct && match_struct_destroy@ > identifier match_struct_reset.reset_func; > identifier match_struct_destroy.destroy_func; > identifier container_func; > identifier P; > symbol drm_atomic_helper_plane_destroy_state; > symbol __drm_atomic_helper_plane_destroy_state; > @@ > > void reset_func(struct drm_plane *P) > { > ... > ( > - if (P->state) { > - <+... > ( > - drm_atomic_helper_plane_destroy_state(P, P->state); > | > - __drm_atomic_helper_plane_destroy_state(P->state); > | > - P->funcs->atomic_destroy_state(P, P->state); > | > - destroy_func(P, P->state); > ) > - ...+> > - } > | > - drm_WARN_ON_ONCE(P->dev, P->state); > | > - WARN_ON(P->state); > ) > ... > ( > - kfree(P->state); > | > - kfree(container_func(P->state)); > | > // kfree is optional > ) > ( > - P->state = NULL; > | > // plane->state clearing is optional > ) > ... > } > > @drop_destroy_mtk depends on update_struct@ > identifier P; > symbol __drm_atomic_helper_plane_destroy_state; > symbol to_mtk_plane_state; > @@ > > void mtk_plane_reset(struct drm_plane *P) > { > ... > - if (P->state) { > - __drm_atomic_helper_plane_destroy_state(P->state); > - ... > - } else { > ... > - } > ... > } > > @transform_nv50_wndw depends on update_struct@ > identifier S; > @@ > > void nv50_wndw_reset(...) > { > ... > - if (WARN_ON(!(S = kzalloc_obj(*S)))) > + S = kzalloc_obj(*S); > + if (WARN_ON(!S)) > return; > ... > } > > @transform_kzalloc depends on update_struct@ > identifier match_struct_reset.reset_func; > identifier P, S; > statement ST; > statement list STL; > @@ > > void reset_func(struct drm_plane *P) > { > <... > S = kzalloc_obj(*S); > ( > - if (S) > - { > - STL > - } > + if (!S) return; > + > + STL > | > - if (S) ST > + if (!S) return; > + > + ST > ) > ...> > } > > @transform_body depends on update_struct@ > identifier match_struct_reset.reset_func; > identifier renamed_func.new_name; > identifier S, P; > expression PS; > @@ > - void reset_func(struct drm_plane *P) > + struct drm_plane_state *new_name(struct drm_plane *P) > { > ... > S = kzalloc_obj(*S); > ... > ( > if (!S) { > ... > - return; > + return ERR_PTR(-ENOMEM); > } > | > if (WARN_ON(!S)) { > ... > - return; > + return ERR_PTR(-ENOMEM); > } > | > if (S == NULL) { > ... > - return; > + return ERR_PTR(-ENOMEM); > } > ) > ... > ( > - __drm_atomic_helper_plane_reset(P, PS); > + __drm_atomic_helper_plane_state_init(PS, P); > | > - __drm_gem_reset_shadow_plane(P, PS); > + __drm_gem_shadow_plane_state_init(P, PS); > ) > ... > } > > @update_early_return depends on update_struct@ > identifier match_struct_reset.reset_func; > identifier renamed_func.new_name; > identifier P; > expression PS; > @@ > struct drm_plane_state *new_name(struct drm_plane *P) > { > <+... > - return; > + return ERR_PTR(-EINVAL); > ...+> > } > > @update_return_plane depends on update_struct@ > identifier match_struct_reset.reset_func; > identifier renamed_func.new_name; > identifier P; > expression PS; > @@ > struct drm_plane_state *new_name(struct drm_plane *P) > { > ... > __drm_atomic_helper_plane_state_init(PS, P); > ... > + > + return PS; > } > > @update_return_shadow depends on update_struct@ > identifier renamed_func.new_name; > identifier P; > expression PS; > @@ > struct drm_plane_state *new_name(struct drm_plane *P) > { > ... > __drm_gem_shadow_plane_state_init(P, PS); > ... > + > + return &PS->base; > } > > Signed-off-by: Maxime Ripard <mripard@kernel.org> > --- > Cc: linux-sunxi@lists.linux.dev > Cc: samuel@sholland.org > Cc: wens@kernel.org > --- > drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 2 +- > drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c > index 00756ab78b4e..bad102134726 100644 > --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c > +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c > @@ -211,11 +211,11 @@ static const struct drm_plane_helper_funcs sun8i_ui_layer_helper_funcs = { > static const struct drm_plane_funcs sun8i_ui_layer_funcs = { > .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, > .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, > .destroy = drm_plane_cleanup, > .disable_plane = drm_atomic_helper_disable_plane, > - .reset = drm_atomic_helper_plane_reset, > + .atomic_create_state = drm_atomic_helper_plane_create_state, > .update_plane = drm_atomic_helper_update_plane, > }; > > static const u32 sun8i_ui_layer_formats[] = { > DRM_FORMAT_ABGR1555, > diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c > index 09f668c8af24..2e9cda45c04e 100644 > --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c > +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c > @@ -291,11 +291,11 @@ static const struct drm_plane_helper_funcs sun8i_vi_layer_helper_funcs = { > static const struct drm_plane_funcs sun8i_vi_layer_funcs = { > .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, > .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, > .destroy = drm_plane_cleanup, > .disable_plane = drm_atomic_helper_disable_plane, > - .reset = drm_atomic_helper_plane_reset, > + .atomic_create_state = drm_atomic_helper_plane_create_state, Looks like a pretty standard replacement. Acked-by: Chen-Yu Tsai <wens@kernel.org> > .update_plane = drm_atomic_helper_update_plane, > }; > > /* > * While DE2 VI layer supports same RGB formats as UI layer, alpha > > -- > 2.55.0 >
diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c index 00756ab78b4e..bad102134726 100644 --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c @@ -211,11 +211,11 @@ static const struct drm_plane_helper_funcs sun8i_ui_layer_helper_funcs = { static const struct drm_plane_funcs sun8i_ui_layer_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .destroy = drm_plane_cleanup, .disable_plane = drm_atomic_helper_disable_plane, - .reset = drm_atomic_helper_plane_reset, + .atomic_create_state = drm_atomic_helper_plane_create_state, .update_plane = drm_atomic_helper_update_plane, }; static const u32 sun8i_ui_layer_formats[] = { DRM_FORMAT_ABGR1555, diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c index 09f668c8af24..2e9cda45c04e 100644 --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c @@ -291,11 +291,11 @@ static const struct drm_plane_helper_funcs sun8i_vi_layer_helper_funcs = { static const struct drm_plane_funcs sun8i_vi_layer_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, .destroy = drm_plane_cleanup, .disable_plane = drm_atomic_helper_disable_plane, - .reset = drm_atomic_helper_plane_reset, + .atomic_create_state = drm_atomic_helper_plane_create_state, .update_plane = drm_atomic_helper_update_plane, }; /* * While DE2 VI layer supports same RGB formats as UI layer, alpha