All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 08/13] drm/loongson: Move hardware reset to CRTC creation
Date: Mon, 31 Aug 2026 20:13:10 +0000	[thread overview]
Message-ID: <20260831201310.CCB831F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831-drm-no-more-crtc-reset-v2-8-4500d49a337f@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] `lsdc_crtc1_soft_reset` calls `msleep(20)`, which can sleep, but it is reachable from the CRTC atomic enable callback (`lsdc_crtc_atomic_enable`), which runs in atomic context.
--

commit 4cb085e0fbbbf2cb0c2550f2c69cc0175ba5ecf8
Author: Maxime Ripard <mripard@kernel.org>

drm/loongson: Move hardware reset to CRTC creation

This patch moves the hardware-level CRTC reset from the atomic state
initialization hook to the CRTC creation path. It adds a new hw_reset
callback to handle the register writes independently.

> diff --git a/drivers/gpu/drm/loongson/lsdc_crtc.c b/drivers/gpu/drm/loongson/lsdc_crtc.c
> index 16b8f36a40710..7cca574e3b6af 100644
> --- a/drivers/gpu/drm/loongson/lsdc_crtc.c
> +++ b/drivers/gpu/drm/loongson/lsdc_crtc.c

[ ... ]

> @@ -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);
> +}
> +

While reviewing the hardware reset paths in this file, I noticed a pre-existing
issue nearby:

drivers/gpu/drm/loongson/lsdc_crtc.c:
> static void lsdc_crtc1_soft_reset(struct lsdc_crtc *lcrtc)
> {
[ ... ]
> 	/* Wait about a vblank time */
> 	msleep(20);
> }

[Severity: High]
This isn't a bug introduced by this patch, but can this msleep() be called
during atomic context?

The DRM core calls the CRTC .atomic_enable callback, which executes in atomic
context:

lsdc_crtc_atomic_enable()
  lcrtc->hw_ops->enable(lcrtc) // resolves to lsdc_crtc1_enable()

If a hardware stall is detected, it attempts error recovery:

lsdc_crtc1_enable() {
    ...
    if (val & CRTC_ANCHORED) {
        drm_warn(&ldev->base, "%s stall\n", lcrtc->base.name);
        return lsdc_crtc1_soft_reset(lcrtc);
    }
}

This calls lsdc_crtc1_soft_reset(), which erroneously calls msleep(20).

Sleeping in atomic context violates core kernel locking rules. This triggers
might_sleep() warnings and can lead to deadlocks or panics. (Note that
lsdc_crtc0_soft_reset() correctly uses mdelay(20) instead).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260831-drm-no-more-crtc-reset-v2-0-4500d49a337f@kernel.org?part=8

  parent reply	other threads:[~2026-08-31 20:13 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
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 [this message]
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=20260831201310.CCB831F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mripard@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.