All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Maxime Ripard <mripard@kernel.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 01/13] drm/crtc: Introduce hw_reset helper hook
Date: Wed, 2 Sep 2026 09:05:12 +0200	[thread overview]
Message-ID: <09f547df-576a-4445-830c-e4dac6a309a8@suse.de> (raw)
In-Reply-To: <20260831-drm-no-more-crtc-reset-v2-1-4500d49a337f@kernel.org>

Hi Maxime

Am 31.08.26 um 17:34 schrieb Maxime Ripard:
> The CRTC reset hook conflates initial software state allocation with
> hardware reset. The atomic_create_state hook addresses the software
> state side, but drivers may still need to reset hardware to a known good
> state during drm_mode_config_reset(), for example during suspend/resume.
>
> Separating hardware reset from state allocation is also useful for the
> pending atomic state readout and userspace atomic reset flag series,
> which need to create pristine software state without affecting the
> hardware.
>
> Introduce a hw_reset hook in struct drm_crtc_helper_funcs that only
> resets the hardware, without touching the software state at all. Call it
> from drm_mode_config_crtc_reset_with_create_state() after the state has
> been successfully created.
>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

with comments below.

> ---
>   drivers/gpu/drm/drm_mode_config.c        | 13 ++++++++++++-
>   include/drm/drm_modeset_helper_vtables.h | 14 ++++++++++++++
>   2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 366f6d821242..bb2efc274323 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -28,10 +28,11 @@
>   #include <drm/drm_encoder.h>
>   #include <drm/drm_file.h>
>   #include <drm/drm_framebuffer.h>
>   #include <drm/drm_managed.h>
>   #include <drm/drm_mode_config.h>
> +#include <drm/drm_modeset_helper_vtables.h>
>   #include <drm/drm_print.h>
>   #include <drm/drm_colorop.h>
>   #include <linux/dma-resv.h>
>   
>   #include "drm_crtc_internal.h"
> @@ -228,16 +229,26 @@ static int drm_mode_config_crtc_create_state(struct drm_crtc *crtc)
>   	return 0;
>   }
>   
>   static int drm_mode_config_crtc_reset_with_create_state(struct drm_crtc *crtc)
>   {
> +	const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;

Please see the Sahsiko comment about this being NULL. And I suggest to 
call the variable 'helpers' because 'funcs' sounds like regular 
drm_crtc_funcs. But that's really just nitpicking.

Best regards
Thomas

> +	int ret;
> +
>   	if (crtc->state) {
>   		crtc->funcs->atomic_destroy_state(crtc, crtc->state);
>   		crtc->state = NULL;
>   	}
>   
> -	return drm_mode_config_crtc_create_state(crtc);
> +	ret = drm_mode_config_crtc_create_state(crtc);
> +	if (ret)
> +		return ret;
> +
> +	if (crtc_funcs->hw_reset)
> +		crtc_funcs->hw_reset(crtc);
> +
> +	return 0;
>   }
>   
>   static int drm_mode_config_connector_create_state(struct drm_connector *connector)
>   {
>   	struct drm_connector_state *conn_state;
> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> index ca6268945c28..4965356a6314 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -279,10 +279,24 @@ struct drm_crtc_helper_funcs {
>   	 * drivers still using legacy CRTC helpers, which is different from the
>   	 * rules under atomic.
>   	 */
>   	void (*disable)(struct drm_crtc *crtc);
>   
> +	/**
> +	 * @hw_reset:
> +	 *
> +	 * Optional hook for CRTC hardware reset.
> +	 *
> +	 * Unlike @drm_crtc_funcs.reset, which both resets hardware and
> +	 * creates new software state, this hook only resets the
> +	 * hardware to a known good state without touching the software
> +	 * state at all.
> +	 *
> +	 * This hook is called by drm_mode_config_reset().
> +	 */
> +	void (*hw_reset)(struct drm_crtc *crtc);
> +
>   	/**
>   	 * @atomic_check:
>   	 *
>   	 * Drivers should check plane-update related CRTC constraints in this
>   	 * hook. They can also check mode related limitations but need to be
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)



  parent reply	other threads:[~2026-09-02  7:05 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 15:34 [PATCH v2 00/13] drm/crtc: Convert all drivers to atomic_create_state and remove reset Maxime Ripard
2026-08-31 15:34 ` [PATCH v2 01/13] drm/crtc: Introduce hw_reset helper hook Maxime Ripard
2026-08-31 18:34   ` sashiko-bot
2026-09-02  7:05   ` Thomas Zimmermann [this message]
2026-08-31 15:34 ` [PATCH v2 02/13] drm/amdgpu: vkms: Switch to drm_atomic_helper_crtc_create_state Maxime Ripard
2026-08-31 15:34 ` [PATCH v2 03/13] drm/logicvc: " Maxime Ripard
2026-08-31 15:34 ` [PATCH v2 04/13] drm/tilcdc: Move hardware reset to CRTC creation Maxime Ripard
2026-08-31 19:11   ` sashiko-bot
2026-09-02  7:07   ` Thomas Zimmermann
2026-08-31 15:34 ` [PATCH v2 05/13] drm/tilcdc: Switch to drm_atomic_helper_crtc_create_state Maxime Ripard
2026-08-31 19:46   ` sashiko-bot
2026-08-31 15:34 ` [PATCH v2 06/13] drm/atomic-helper: Remove drm_atomic_helper_crtc_reset Maxime Ripard
2026-08-31 15:34 ` [PATCH v2 07/13] drm/amdgpu: dm: Convert to atomic_create_state Maxime Ripard
2026-08-31 20:02   ` sashiko-bot
2026-08-31 15:34 ` [PATCH v2 08/13] drm/loongson: Move hardware reset to CRTC creation Maxime Ripard
2026-08-31 16:08   ` Icenowy Zheng
2026-08-31 20:13   ` sashiko-bot
2026-09-02  7:10   ` Thomas Zimmermann
2026-09-04  1:47     ` wuqianhai
2026-08-31 15:34 ` [PATCH v2 09/13] drm/loongson: Convert to atomic_create_state Maxime Ripard
2026-08-31 15:34 ` [PATCH v2 10/13] drm/mediatek: " Maxime Ripard
2026-08-31 15:34 ` [PATCH v2 11/13] drm/sitronix: st7920: " Maxime Ripard
2026-08-31 20:40   ` sashiko-bot
2026-09-01 11:05   ` Iker Pedrosa
2026-08-31 15:34 ` [PATCH v2 12/13] drm/atomic-helper: Remove __drm_atomic_helper_crtc_reset Maxime Ripard
2026-08-31 15:34 ` [PATCH v2 13/13] drm/crtc: Remove reset Maxime Ripard
2026-08-31 21:09   ` sashiko-bot
2026-09-02  7:11 ` [PATCH v2 00/13] drm/crtc: Convert all drivers to atomic_create_state and remove reset Thomas Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=09f547df-576a-4445-830c-e4dac6a309a8@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.