From: Daniel Vetter <daniel@ffwll.ch>
To: Yunxiang Li <Yunxiang.Li@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm: get lock before accessing vblank refcount
Date: Tue, 6 Sep 2022 21:20:09 +0200 [thread overview]
Message-ID: <YxedadEMAfWHON8P@phenom.ffwll.local> (raw)
In-Reply-To: <20220722215234.129793-2-Yunxiang.Li@amd.com>
On Fri, Jul 22, 2022 at 05:52:34PM -0400, Yunxiang Li wrote:
> Acquire vbl_lock before accessing vblank refcount in drm_vblank_put,
> just like everywhere else that access the refcount.
>
> Signed-off-by: Yunxiang Li <Yunxiang.Li@amd.com>
The entire point of using atomic for the refcount is that we can check it
lockless, so I'm not sure what you're trying to fix here?
For the first patch I think it's clear that the bug needs to be fixed in
amdgpu dc code already.
-Daniel
> ---
> drivers/gpu/drm/drm_vblank.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index 159d13b5d97b..77b8c40fc7ba 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -1203,15 +1203,22 @@ EXPORT_SYMBOL(drm_crtc_vblank_get);
> void drm_vblank_put(struct drm_device *dev, unsigned int pipe)
> {
> struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
> + unsigned long irqflags;
> + int ret;
>
> if (drm_WARN_ON(dev, pipe >= dev->num_crtcs))
> return;
>
> - if (drm_WARN_ON(dev, atomic_read(&vblank->refcount) == 0))
> + spin_lock_irqsave(&dev->vbl_lock, irqflags);
> + if (drm_WARN_ON(dev, atomic_read(&vblank->refcount) == 0)) {
> + spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
> return;
> + }
>
> /* Last user schedules interrupt disable */
> - if (atomic_dec_and_test(&vblank->refcount)) {
> + ret = atomic_dec_and_test(&vblank->refcount);
> + spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
> + if (ret) {
> if (drm_vblank_offdelay == 0)
> return;
> else if (drm_vblank_offdelay < 0)
> --
> 2.37.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2022-09-06 19:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 21:52 [PATCH 1/2] drm: Fix vblank refcount during modeset Yunxiang Li
2022-07-22 21:52 ` [PATCH 2/2] drm: get lock before accessing vblank refcount Yunxiang Li
2022-09-06 19:20 ` Daniel Vetter [this message]
2022-09-06 20:18 ` Li, Yunxiang (Teddy)
2022-09-06 21:58 ` Daniel Vetter
2022-08-02 14:51 ` [PATCH 1/2] drm: Fix vblank refcount during modeset Li, Yunxiang (Teddy)
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=YxedadEMAfWHON8P@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=Yunxiang.Li@amd.com \
--cc=dri-devel@lists.freedesktop.org \
/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;
as well as URLs for NNTP newsgroup(s).