From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Icenowy Zheng <zhengxingda@iscas.ac.cn>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Sam Ravnborg <sam@ravnborg.org>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Icenowy Zheng <uwu@icenowy.me>,
stable@vger.kernel.org
Subject: Re: [PATCH] drm/client: check whether CRTC is active before waiting for vblank
Date: Fri, 22 May 2026 16:13:15 +0300 [thread overview]
Message-ID: <ahBWayIcQUHuAt4i@intel.com> (raw)
In-Reply-To: <ee86cb43-e5df-4946-a957-931a73dde752@suse.de>
On Fri, May 22, 2026 at 01:55:59PM +0200, Thomas Zimmermann wrote:
> Hi
>
> Am 19.05.26 um 11:24 schrieb Icenowy Zheng:
> > Currently the implementaion of drm_client_modeset_wait_for_vblank()
> > assumes drm_vblank_get() will fail when the CRTC isn't active. However
> > it seems that this is not true, and running fbcon on a device with the
> > first CRTC inactive will lead to kernel warning in some cases (which
> > could be reproduced with the loongson driver).
> >
> > Change the implementation to add a check for the active state (atomic) /
> > enabled state (non-atomic) before calling drm_vblank_get(). As the
> > assumption of drm_vblank_get() failing for inactive CRTC isn't met, the
> > error status of drm_vblank_get() can now be exported too.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: d8c4bddcd8bc ("drm/fb-helper: Synchronize dirty worker with vblank")
> > Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> > ---
> > drivers/gpu/drm/drm_client_modeset.c | 13 +++++++++++--
> > 1 file changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
> > index bb49b8361271a..1b03bf351256e 100644
> > --- a/drivers/gpu/drm/drm_client_modeset.c
> > +++ b/drivers/gpu/drm/drm_client_modeset.c
> > @@ -1310,7 +1310,7 @@ int drm_client_modeset_wait_for_vblank(struct drm_client_dev *client, unsigned i
> > {
> > struct drm_device *dev = client->dev;
> > struct drm_crtc *crtc;
> > - int ret;
> > + int ret = 0;
> >
> > /*
> > * Rate-limit update frequency to vblank. If there's a DRM master
> > @@ -1326,15 +1326,24 @@ int drm_client_modeset_wait_for_vblank(struct drm_client_dev *client, unsigned i
> > * Only wait for a vblank event if the CRTC is enabled, otherwise
> > * just don't do anything, not even report an error.
> > */
> > + if (drm_drv_uses_atomic_modeset(dev)) {
> > + if (!crtc->state || !crtc->state->active)
> > + goto out;
> > + } else {
> > + if (!crtc->enabled)
> > + goto out;
> > + }
> > +
>
> This part is good.
Locking is missing.
>
> > ret = drm_crtc_vblank_get(crtc);
> > if (!ret) {
> > drm_crtc_wait_one_vblank(crtc);
> > drm_crtc_vblank_put(crtc);
> > }
> >
> > +out:
> > drm_master_internal_release(dev);
> >
> > - return 0;
> > + return ret;
>
> But this isn't. There can be CRTCs without any vblank at all. We still
> want to fail silently for them. So we still have to return 0 here.
>
> Having set this, fixing this helper is only partially what you want.
> Since your device has vblanking, the emulation should check on the
> correct CRTC. IOW you need to pass the right CRTC index at
>
> https://elixir.bootlin.com/linux/v7.1-rc1/source/drivers/gpu/drm/drm_fb_helper.c#L237
> https://elixir.bootlin.com/linux/v7.1-rc1/source/drivers/gpu/drm/drm_fb_helper.c#L920
>
> I'm not quite sure how to support this. The CRTC is under
> fb_helper->client.modesets.crtc. You'd have to figure out which is the
> relevant one and use that. But that's also not so great, as fbdev ioctls
> only support CRTC 0. Doing internal re-mappings only complicates matters.
>
> But why does your HW use CRTC 1 in the first place.
Could be eg. the enabled outputs can't be driven with CRTC 0.
I guess what you want to do is pick the first crtc from modesets[]
which is enabled. Or perhaps even "pick the Nth enabled crtc from
modesets[] based on the ioctl argument".
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2026-05-22 13:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 9:24 [PATCH] drm/client: check whether CRTC is active before waiting for vblank Icenowy Zheng
2026-05-19 9:41 ` Jani Nikula
2026-05-19 11:29 ` Icenowy Zheng
2026-05-22 9:23 ` Maarten Lankhorst
2026-05-22 9:48 ` Icenowy Zheng
2026-05-22 11:55 ` Thomas Zimmermann
2026-05-22 13:13 ` Ville Syrjälä [this message]
2026-05-22 13:24 ` Thomas Zimmermann
2026-05-22 13:28 ` Ville Syrjälä
2026-05-22 13:43 ` Thomas Zimmermann
2026-05-22 14:01 ` Icenowy Zheng
2026-05-22 14:09 ` Thomas Zimmermann
2026-05-22 19:39 ` Ville Syrjälä
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=ahBWayIcQUHuAt4i@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=sam@ravnborg.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=tzimmermann@suse.de \
--cc=uwu@icenowy.me \
--cc=zhengxingda@iscas.ac.cn \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox