From df456aa08b15fd65d5bdb62d5487b46b49423324 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Fri, 4 Sep 2026 11:07:26 +0200 Subject: [PATCH] drm/loongson: Move hardware reset to hw_reset hook The loongson crtc reset hook performs both atomic state initialization using __drm_atomic_helper_crtc_reset() and hardware-level register writes to reset the CRTC. The hardware reset is not related to atomic state initialization, and the reset hook is being converted to atomic_create_state which only deals with state allocation. Move the hardware reset to the hw_reset helper hook instead. Reviewed-by: Thomas Zimmermann Reviewed-by: Javier Martinez Canillas Link: https://lore.kernel.org/r/20260904-drm-no-more-crtc-reset-v3-8-27d9891512ce@kernel.org Signed-off-by: Maxime Ripard --- drivers/gpu/drm/loongson/lsdc_crtc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c b/drivers/gpu/drm/loongson/lsdc_crtc.c index 16b8f36a4071..7cca574e3b6a 100644 --- a/drivers/gpu/drm/loongson/lsdc_crtc.c +++ b/drivers/gpu/drm/loongson/lsdc_crtc.c @@ -390,8 +390,6 @@ static const struct lsdc_crtc_hw_ops ls7a2000_crtc_hw_ops[2] = { static void lsdc_crtc_reset(struct drm_crtc *crtc) { - struct lsdc_crtc *lcrtc = to_lsdc_crtc(crtc); - const struct lsdc_crtc_hw_ops *ops = lcrtc->hw_ops; struct lsdc_crtc_state *priv_crtc_state; if (crtc->state) @@ -403,9 +401,6 @@ static void lsdc_crtc_reset(struct drm_crtc *crtc) __drm_atomic_helper_crtc_reset(crtc, NULL); else __drm_atomic_helper_crtc_reset(crtc, &priv_crtc_state->base); - - /* Reset the CRTC hardware, this is required for S3 support */ - ops->reset(lcrtc); } static void lsdc_crtc_atomic_destroy_state(struct drm_crtc *crtc, @@ -937,6 +932,15 @@ static bool lsdc_crtc_get_scanout_position(struct drm_crtc *crtc, return true; } +static void lsdc_crtc_hw_reset(struct drm_crtc *crtc) +{ + struct lsdc_crtc *lcrtc = to_lsdc_crtc(crtc); + + /* Reset the CRTC hardware, this is required for S3 support */ + if (lcrtc->hw_ops->reset) + lcrtc->hw_ops->reset(lcrtc); +} + static const struct drm_crtc_helper_funcs lsdc_crtc_helper_funcs = { .mode_valid = lsdc_crtc_mode_valid, .mode_set_nofb = lsdc_crtc_mode_set_nofb, @@ -945,6 +949,7 @@ static const struct drm_crtc_helper_funcs lsdc_crtc_helper_funcs = { .atomic_check = lsdc_crtc_helper_atomic_check, .atomic_flush = lsdc_crtc_atomic_flush, .get_scanout_position = lsdc_crtc_get_scanout_position, + .hw_reset = lsdc_crtc_hw_reset, }; int ls7a1000_crtc_init(struct drm_device *ddev,