From: Daniel Vetter <daniel@ffwll.ch>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Maira Canal <mairacanal@riseup.net>,
Arthur Grillo <arthurgrillo@riseup.net>,
Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>,
Melissa Wen <melissa.srw@gmail.com>,
Haneen Mohammed <hamohammed.sa@gmail.com>,
Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@gmail.com>,
DRI <dri-devel@lists.freedesktop.org>,
syzkaller@googlegroups.com, LKML <linux-kernel@vger.kernel.org>,
Hillf Danton <hdanton@sina.com>,
Sanan Hasanov <Sanan.Hasanov@ucf.edu>,
Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: drm/vkms: deadlock between dev->event_lock and timer
Date: Thu, 14 Sep 2023 10:12:35 +0200 [thread overview]
Message-ID: <ZQLAc/Fwkv/GiVoK@phenom.ffwll.local> (raw)
In-Reply-To: <167ee2ad-6a7e-876c-f5c9-f0a227070a78@I-love.SAKURA.ne.jp>
On Thu, Sep 14, 2023 at 03:33:41PM +0900, Tetsuo Handa wrote:
> On 2023/09/14 6:08, Thomas Gleixner wrote:
> > Maybe the VKMS people need to understand locking in the first place. The
> > first thing I saw in this code is:
> >
> > static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer)
> > {
> > ...
> > mutex_unlock(&output->enabled_lock);
> >
> > What?
> >
> > Unlocking a mutex in the context of a hrtimer callback is simply
> > violating all mutex locking rules.
> >
> > How has this code ever survived lock debugging without triggering a big
> > fat warning?
>
> Commit a0e6a017ab56936c ("drm/vkms: Fix race-condition between the hrtimer
> and the atomic commit") in 6.6-rc1 replaced spinlock with mutex. So we haven't
> tested with the lock debugging yet...
Yeah that needs an immediate revert, there's not much that looks legit in
that patch. I'll chat with Maira.
Also yes how that landed without anyone running lockdep is ... not good. I
guess we need a lockdep enabled drm ci target that runs vkms tests asap
:-)
> Maíra and Arthur, mutex_unlock() from interrupt context is not permitted.
> Please revert that patch immediately.
> I guess that a semaphore (down()/up()) could be used instead of a mutex.
From a quick look this smells like a classic "try to use locking when you
want synchronization primitives", so semaphore here doesn't look any
better. The vkms_set_composer() function was originally for crc
generation, where it's userspace's job to make sure they wait for all the
crc they need to be generated before they shut it down again. But for
writeback the kernel must guarantee that the compositiona actually
happens, and the current function just doesn't make any such guarantees.
Cheers, Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2023-09-14 8:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230913110709.6684-1-hdanton@sina.com>
2023-09-13 14:21 ` drm/vkms: deadlock between dev->event_lock and timer Tetsuo Handa
2023-09-13 16:47 ` Linus Torvalds
2023-09-13 21:08 ` Thomas Gleixner
2023-09-14 6:33 ` Tetsuo Handa
2023-09-14 8:12 ` Daniel Vetter [this message]
2023-09-18 22:02 ` Helen Koike
2023-09-19 6:38 ` Daniel Stone
2023-09-13 14:30 ` BUG: soft lockup in smp_call_function Tetsuo Handa
[not found] ` <20230914122134.6783-1-hdanton@sina.com>
2023-09-14 13:13 ` Tetsuo Handa
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=ZQLAc/Fwkv/GiVoK@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=Sanan.Hasanov@ucf.edu \
--cc=airlied@gmail.com \
--cc=arthurgrillo@riseup.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=hamohammed.sa@gmail.com \
--cc=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mairacanal@riseup.net \
--cc=melissa.srw@gmail.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=rodrigosiqueiramelo@gmail.com \
--cc=syzkaller@googlegroups.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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