* [PATCH v5 00/39] drm/atomic: Get rid of existing states (not really)
@ 2025-09-30 10:59 Maxime Ripard
2025-09-30 10:59 ` [PATCH v5 11/39] drm/ingenic: ipu: Switch to drm_atomic_get_new_crtc_state() Maxime Ripard
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Maxime Ripard @ 2025-09-30 10:59 UTC (permalink / raw)
To: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, Maxime Ripard, Luca Ceresoli, Dmitry Baryshkov,
Ville Syrjälä, Louis Chauvet, Haneen Mohammed,
Melissa Wen, Jyri Sarha, Tomi Valkeinen, Paul Cercueil,
linux-mips, Liviu Dudau, Russell King, Manikandan Muralidharan,
Dharma Balasubiramani, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, linux-arm-kernel, Inki Dae, Seung-Woo Kim,
Kyungmin Park, Krzysztof Kozlowski, Alim Akhtar,
linux-samsung-soc, Liu Ying, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, imx, Laurentiu Palcu,
Lucas Stach, Philipp Zabel, Anitha Chrisanthus, Edmund Dea,
Paul Kocialkowski, Sui Jingfeng, Chun-Kuang Hu, Matthias Brugger,
AngeloGioacchino Del Regno, linux-mediatek, linux-kernel,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, linux-arm-msm, freedreno, Sandy Huang,
Heiko Stübner, Andy Yan, linux-rockchip, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, linux-sunxi, Thierry Reding,
Mikko Perttunen, Jonathan Hunter, linux-tegra, Hans de Goede,
Dave Stevenson, Maíra Canal, Raspberry Pi Kernel Maintenance
Hi,
Here's a series to get rid of the drm_atomic_helper_get_existing_*_state
accessors.
The initial intent was to remove the __drm_*_state->state pointer to
only rely on old and new states, but we still need it now to know which
of the two we need to free: if a state has not been committed (either
dropped or checked only), then we need to free the new one, if it has
been committed we need to free the old state.
Thus, the state pointer is kept (and documented) only to point to the
state we should free eventually.
All users have been converted to the relevant old or new state
accessors.
This was tested on tidss.
Let me know what you think,
Maxime
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
Changes in v5:
- Added some more documentation on state teardown
- Link to v4: https://lore.kernel.org/r/20250917-drm-no-more-existing-state-v4-0-5d4b9889c3c8@kernel.org
Changes in v4:
- Fix ingenic
- Rebased on latest drm-misc-next tag
- Link to v3: https://lore.kernel.org/r/20250909-drm-no-more-existing-state-v3-0-1c7a7d960c33@kernel.org
Changes in v3:
- Added an armada rework patch
- Added an ingenic fix
- Collected tags
- Rebased on latest drm-misc-next tag
- Link to v2: https://lore.kernel.org/r/20250902-drm-no-more-existing-state-v2-0-de98fc5f6d66@kernel.org
Changes in v2:
- Dropped the first and second patches
- Reworked the recipient list to be nicer with SMTPs
- Link to v1: https://lore.kernel.org/r/20250825-drm-no-more-existing-state-v1-0-f08ccd9f85c9@kernel.org
---
Maxime Ripard (39):
drm/atomic: Convert drm_atomic_get_connector_state() to use new connector state
drm/atomic: Remove unused drm_atomic_get_existing_connector_state()
drm/atomic: Document __drm_connectors_state state pointer
drm/atomic: Convert __drm_atomic_get_current_plane_state() to modern accessor
drm/atomic: Convert drm_atomic_get_plane_state() to use new plane state
drm/vkms: Convert vkms_crtc_atomic_check() to use new plane state
drm/tilcdc: crtc: Use drm_atomic_helper_check_crtc_primary_plane()
drm/atomic: Remove unused drm_atomic_get_existing_plane_state()
drm/atomic: Document __drm_planes_state state pointer
drm/atomic: Convert drm_atomic_get_crtc_state() to use new connector state
drm/ingenic: ipu: Switch to drm_atomic_get_new_crtc_state()
drm/arm/malidp: Switch to drm_atomic_get_new_crtc_state()
drm/armada: Drop always true condition in atomic_check
drm/armada: Switch to drm_atomic_get_new_crtc_state()
drm/atmel-hlcdc: Switch to drm_atomic_get_new_crtc_state()
drm/exynos: Switch to drm_atomic_get_new_crtc_state()
drm/imx-dc: Switch to drm_atomic_get_new_crtc_state()
drm/imx-dcss: Switch to drm_atomic_get_new_crtc_state()
drm/imx-ipuv3: Switch to drm_atomic_get_new_crtc_state()
drm/ingenic: Switch to drm_atomic_get_new_crtc_state()
drm/kmb: Switch to drm_atomic_get_new_crtc_state()
drm/logicvc: Switch to drm_atomic_get_new_crtc_state()
drm/loongson: Switch to drm_atomic_get_new_crtc_state()
drm/mediatek: Switch to drm_atomic_get_new_crtc_state()
drm/msm/mdp5: Switch to drm_atomic_get_new_crtc_state()
drm/omap: Switch to drm_atomic_get_new_crtc_state()
drm/rockchip: Switch to drm_atomic_get_new_crtc_state()
drm/sun4i: Switch to drm_atomic_get_new_crtc_state()
drm/tegra: Switch to drm_atomic_get_new_crtc_state()
drm/tilcdc: Switch to drm_atomic_get_new_crtc_state()
drm/vboxvideo: Switch to drm_atomic_get_new_crtc_state()
drm/vc4: Switch to drm_atomic_get_new_crtc_state()
drm/atomic: Switch to drm_atomic_get_new_crtc_state()
drm/framebuffer: Switch to drm_atomic_get_new_crtc_state()
drm/atomic: Remove unused drm_atomic_get_existing_crtc_state()
drm/atomic: Document __drm_crtcs_state state pointer
drm/ingenic: crtc: Switch to ingenic_drm_get_new_priv_state()
drm/atomic: Convert drm_atomic_get_private_obj_state() to use new plane state
drm/atomic: Document __drm_private_objs_state state pointer
drivers/gpu/drm/arm/malidp_planes.c | 2 +-
drivers/gpu/drm/armada/armada_plane.c | 7 +-
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 2 +-
drivers/gpu/drm/drm_atomic.c | 21 ++--
drivers/gpu/drm/drm_framebuffer.c | 2 +-
drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 +-
drivers/gpu/drm/imx/dc/dc-plane.c | 2 +-
drivers/gpu/drm/imx/dcss/dcss-plane.c | 4 +-
drivers/gpu/drm/imx/ipuv3/ipuv3-plane.c | 3 +-
drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 13 +-
drivers/gpu/drm/ingenic/ingenic-ipu.c | 4 +-
drivers/gpu/drm/kmb/kmb_plane.c | 3 +-
drivers/gpu/drm/logicvc/logicvc_layer.c | 4 +-
drivers/gpu/drm/loongson/lsdc_plane.c | 2 +-
drivers/gpu/drm/mediatek/mtk_plane.c | 3 +-
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c | 7 +-
drivers/gpu/drm/omapdrm/omap_plane.c | 2 +-
drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 6 +-
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 2 +-
drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 3 +-
drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 3 +-
drivers/gpu/drm/tegra/dc.c | 2 +-
drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 9 +-
drivers/gpu/drm/tilcdc/tilcdc_plane.c | 3 +-
drivers/gpu/drm/vboxvideo/vbox_mode.c | 8 +-
drivers/gpu/drm/vc4/vc4_plane.c | 6 +-
drivers/gpu/drm/vkms/vkms_crtc.c | 4 +-
include/drm/drm_atomic.h | 152 +++++++++++++-----------
28 files changed, 140 insertions(+), 141 deletions(-)
---
base-commit: 91494dee1091a14d91da6bcb39e12a907765c793
change-id: 20250825-drm-no-more-existing-state-9b3252c1a33b
Best regards,
--
Maxime Ripard <mripard@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v5 11/39] drm/ingenic: ipu: Switch to drm_atomic_get_new_crtc_state()
2025-09-30 10:59 [PATCH v5 00/39] drm/atomic: Get rid of existing states (not really) Maxime Ripard
@ 2025-09-30 10:59 ` Maxime Ripard
2025-09-30 10:59 ` [PATCH v5 20/39] drm/ingenic: " Maxime Ripard
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2025-09-30 10:59 UTC (permalink / raw)
To: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, Maxime Ripard, Paul Cercueil, Ville Syrjälä,
linux-mips
The ingenic IPU atomic_set_property implementation uses the deprecated
drm_atomic_get_existing_crtc_state() helper.
This hook is called during the state building process, before
atomic_check, and thus before the states are swapped. The existing state
thus points to the new state, and we can use
drm_atomic_get_new_crtc_state() instead.
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Tested-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
To: Paul Cercueil <paul@crapouillou.net>
Cc: linux-mips@vger.kernel.org
---
drivers/gpu/drm/ingenic/ingenic-ipu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ingenic/ingenic-ipu.c b/drivers/gpu/drm/ingenic/ingenic-ipu.c
index 26ebf424d63ec21ccee80221745c3e8bcc6b3d7f..2574a4b4d40a2c27cb212114117829d9f6ab3ddb 100644
--- a/drivers/gpu/drm/ingenic/ingenic-ipu.c
+++ b/drivers/gpu/drm/ingenic/ingenic-ipu.c
@@ -703,11 +703,11 @@ ingenic_ipu_plane_atomic_set_property(struct drm_plane *plane,
mode_changed = val != ipu->sharpness;
ipu->sharpness = val;
if (state->crtc) {
- crtc_state = drm_atomic_get_existing_crtc_state(state->state, state->crtc);
+ crtc_state = drm_atomic_get_new_crtc_state(state->state, state->crtc);
if (WARN_ON(!crtc_state))
return -EINVAL;
crtc_state->mode_changed |= mode_changed;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v5 20/39] drm/ingenic: Switch to drm_atomic_get_new_crtc_state()
2025-09-30 10:59 [PATCH v5 00/39] drm/atomic: Get rid of existing states (not really) Maxime Ripard
2025-09-30 10:59 ` [PATCH v5 11/39] drm/ingenic: ipu: Switch to drm_atomic_get_new_crtc_state() Maxime Ripard
@ 2025-09-30 10:59 ` Maxime Ripard
2025-09-30 10:59 ` [PATCH v5 37/39] drm/ingenic: crtc: Switch to ingenic_drm_get_new_priv_state() Maxime Ripard
2025-10-06 12:02 ` [PATCH v5 00/39] drm/atomic: Get rid of existing states (not really) Maxime Ripard
3 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2025-09-30 10:59 UTC (permalink / raw)
To: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, Maxime Ripard, Paul Cercueil, Ville Syrjälä,
linux-mips
The ingenic atomic_check implementation uses the deprecated
drm_atomic_get_existing_crtc_state() helper.
This hook is called as part of the global atomic_check, thus before the
states are swapped. The existing state thus points to the new state, and
we can use drm_atomic_get_new_crtc_state() instead.
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Tested-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
To: Paul Cercueil <paul@crapouillou.net>
Cc: linux-mips@vger.kernel.org
---
drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 3 +--
drivers/gpu/drm/ingenic/ingenic-ipu.c | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index 9db1ceaed5188a4ef0897280dc72108eb3815b5f..05faed933e5619c796f2a4fa1906e0eaa029ac68 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -469,12 +469,11 @@ static int ingenic_drm_plane_atomic_check(struct drm_plane *plane,
return 0;
if (priv->soc_info->plane_f0_not_working && plane == &priv->f0)
return -EINVAL;
- crtc_state = drm_atomic_get_existing_crtc_state(state,
- crtc);
+ crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
if (WARN_ON(!crtc_state))
return -EINVAL;
priv_state = ingenic_drm_get_priv_state(priv, state);
if (IS_ERR(priv_state))
diff --git a/drivers/gpu/drm/ingenic/ingenic-ipu.c b/drivers/gpu/drm/ingenic/ingenic-ipu.c
index 2574a4b4d40a2c27cb212114117829d9f6ab3ddb..32638a713241abbd4eaed09f0aaec2b790650cc9 100644
--- a/drivers/gpu/drm/ingenic/ingenic-ipu.c
+++ b/drivers/gpu/drm/ingenic/ingenic-ipu.c
@@ -578,11 +578,11 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,
struct ingenic_ipu_private_state *ipu_state;
if (!crtc)
return 0;
- crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
+ crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
if (WARN_ON(!crtc_state))
return -EINVAL;
ipu_state = ingenic_ipu_get_priv_state(ipu, state);
if (IS_ERR(ipu_state))
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v5 37/39] drm/ingenic: crtc: Switch to ingenic_drm_get_new_priv_state()
2025-09-30 10:59 [PATCH v5 00/39] drm/atomic: Get rid of existing states (not really) Maxime Ripard
2025-09-30 10:59 ` [PATCH v5 11/39] drm/ingenic: ipu: Switch to drm_atomic_get_new_crtc_state() Maxime Ripard
2025-09-30 10:59 ` [PATCH v5 20/39] drm/ingenic: " Maxime Ripard
@ 2025-09-30 10:59 ` Maxime Ripard
2025-10-06 12:02 ` [PATCH v5 00/39] drm/atomic: Get rid of existing states (not really) Maxime Ripard
3 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2025-09-30 10:59 UTC (permalink / raw)
To: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, Maxime Ripard, Dmitry Baryshkov,
Ville Syrjälä, Paul Cercueil, linux-mips
The ingenic CRTC atomic_enable() implementation will indirectly call
drm_atomic_get_private_obj_state() through ingenic_drm_get_priv_state().
drm_atomic_get_private_obj_state() will either return the new state for
the object in the global state if it exists, or will allocate a new one
and add it to the global state.
atomic_enable() however isn't allowed to modify the global state. So
what the implementation should use is the
drm_atomic_get_new_private_obj_state() helper to get the new state for
the CRTC, without performing an extra allocation.
We still need to make sure the private state will be part of the global
state by the time atomic_enable runs, so we still need to call
ingenic_drm_get_priv_state() in atomic_check. We can then call
ingenic_drm_get_new_priv_state() in atomic_enable, which is a wrapper
around drm_atomic_get_new_private_obj_state().
Reported-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
To: Paul Cercueil <paul@crapouillou.net>
Cc: linux-mips@vger.kernel.org
---
drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index 05faed933e5619c796f2a4fa1906e0eaa029ac68..d3213fbf22be14b177fc1b7100c5b721d5f17924 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -245,12 +245,12 @@ static void ingenic_drm_crtc_atomic_enable(struct drm_crtc *crtc,
{
struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
struct ingenic_drm_private_state *priv_state;
unsigned int next_id;
- priv_state = ingenic_drm_get_priv_state(priv, state);
- if (WARN_ON(IS_ERR(priv_state)))
+ priv_state = ingenic_drm_get_new_priv_state(priv, state);
+ if (WARN_ON(!priv_state))
return;
/* Set addresses of our DMA descriptor chains */
next_id = priv_state->use_palette ? HWDESC_PALETTE : 0;
regmap_write(priv->map, JZ_REG_LCD_DA0, dma_hwdesc_addr(priv, next_id));
@@ -338,17 +338,23 @@ static int ingenic_drm_crtc_atomic_check(struct drm_crtc *crtc,
{
struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
crtc);
struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
struct drm_plane_state *f1_state, *f0_state, *ipu_state = NULL;
+ struct ingenic_drm_private_state *priv_state;
if (crtc_state->gamma_lut &&
drm_color_lut_size(crtc_state->gamma_lut) != ARRAY_SIZE(priv->dma_hwdescs->palette)) {
dev_dbg(priv->dev, "Invalid palette size\n");
return -EINVAL;
}
+ /* We will need the state in atomic_enable, so let's make sure it's part of the state */
+ priv_state = ingenic_drm_get_priv_state(priv, state);
+ if (IS_ERR(priv_state))
+ return PTR_ERR(priv_state);
+
if (drm_atomic_crtc_needs_modeset(crtc_state) && priv->soc_info->has_osd) {
f1_state = drm_atomic_get_plane_state(crtc_state->state,
&priv->f1);
if (IS_ERR(f1_state))
return PTR_ERR(f1_state);
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v5 00/39] drm/atomic: Get rid of existing states (not really)
2025-09-30 10:59 [PATCH v5 00/39] drm/atomic: Get rid of existing states (not really) Maxime Ripard
` (2 preceding siblings ...)
2025-09-30 10:59 ` [PATCH v5 37/39] drm/ingenic: crtc: Switch to ingenic_drm_get_new_priv_state() Maxime Ripard
@ 2025-10-06 12:02 ` Maxime Ripard
3 siblings, 0 replies; 5+ messages in thread
From: Maxime Ripard @ 2025-10-06 12:02 UTC (permalink / raw)
To: Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
Maxime Ripard
Cc: dri-devel, Luca Ceresoli, Dmitry Baryshkov,
Ville Syrjälä, Louis Chauvet, Haneen Mohammed,
Melissa Wen, Jyri Sarha, Tomi Valkeinen, Paul Cercueil,
linux-mips, Liviu Dudau, Russell King, Manikandan Muralidharan,
Dharma Balasubiramani, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, linux-arm-kernel, Inki Dae, Seung-Woo Kim,
Kyungmin Park, Krzysztof Kozlowski, Alim Akhtar,
linux-samsung-soc, Liu Ying, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, imx, Laurentiu Palcu,
Lucas Stach, Philipp Zabel, Anitha Chrisanthus, Edmund Dea,
Paul Kocialkowski, Sui Jingfeng, Chun-Kuang Hu, Matthias Brugger,
AngeloGioacchino Del Regno, linux-mediatek, linux-kernel,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, linux-arm-msm, freedreno, Sandy Huang,
Heiko Stübner, Andy Yan, linux-rockchip, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, linux-sunxi, Thierry Reding,
Mikko Perttunen, Jonathan Hunter, linux-tegra, Hans de Goede,
Dave Stevenson, Maíra Canal, Raspberry Pi Kernel Maintenance
On Tue, 30 Sep 2025 12:59:15 +0200, Maxime Ripard wrote:
> Here's a series to get rid of the drm_atomic_helper_get_existing_*_state
> accessors.
>
> The initial intent was to remove the __drm_*_state->state pointer to
> only rely on old and new states, but we still need it now to know which
> of the two we need to free: if a state has not been committed (either
> dropped or checked only), then we need to free the new one, if it has
> been committed we need to free the old state.
>
> [...]
Applied to misc/kernel.git (drm-misc-next).
Thanks!
Maxime
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-06 12:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-30 10:59 [PATCH v5 00/39] drm/atomic: Get rid of existing states (not really) Maxime Ripard
2025-09-30 10:59 ` [PATCH v5 11/39] drm/ingenic: ipu: Switch to drm_atomic_get_new_crtc_state() Maxime Ripard
2025-09-30 10:59 ` [PATCH v5 20/39] drm/ingenic: " Maxime Ripard
2025-09-30 10:59 ` [PATCH v5 37/39] drm/ingenic: crtc: Switch to ingenic_drm_get_new_priv_state() Maxime Ripard
2025-10-06 12:02 ` [PATCH v5 00/39] drm/atomic: Get rid of existing states (not really) Maxime Ripard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).