All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Javier Martinez Canillas <javierm@redhat.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Du Cheng <ducheng2@gmail.com>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Zheyu Ma <zheyuma97@gmail.com>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Claudio Suarez <cssk@net-c.es>,
	Matthew Wilcox <willy@infradead.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Sam Ravnborg <sam@ravnborg.org>, Helge Deller <deller@gmx.de>,
	Guenter Roeck <linux@roeck-us.net>
Subject: Re: [PATCH] fbcon: Fix delayed takeover locking
Date: Wed, 13 Apr 2022 11:21:23 +0200	[thread overview]
Message-ID: <YlaWE+/YBtcrnLHY@phenom.ffwll.local> (raw)
In-Reply-To: <955400a5-a785-57af-92d4-42710c55ce99@redhat.com>

On Wed, Apr 13, 2022 at 11:16:08AM +0200, Javier Martinez Canillas wrote:
> Hello Daniel,
> 
> On 4/13/22 10:21, Daniel Vetter wrote:
> > I messed up the delayed takover path in the locking conversion in
> > 6e7da3af008b ("fbcon: Move console_lock for register/unlink/unregister").
> >
> 
> Maybe a few more words of what the issue is ? Something like the following:
> 
> If CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER is enabled, fbcon take-over
> doesn't take place when calling fbcon_fb_registered(). Instead, is deferred
> using a workqueue and its fbcon_register_existing_fbs() function calls to
> fbcon_fb_registered() again for each registered fbcon fb.
> 
> This leads to the console_lock tried to be held twice, causing a deadlock.

Will add.
>  
> > Fix it by re-extracting the lockless function and using it in the
> > delayed takeover path, where we need to hold the lock already to
> > iterate over the list of already registered fb. Well the current code
> > still is broken in there (since the list is protected by a
> > registration_lock, which we can't take here because it nests the other
> > way round with console_lock), but in the future this will be a list
> > protected by console_lock when this is all sorted out.
> > 
> 
> [snip]
> 
> >  
> > -/* called with console_lock held */
> >  void fbcon_fb_unbind(struct fb_info *info)
> >  {
> >  	int i, new_idx = -1;
> > @@ -2822,7 +2821,6 @@ void fbcon_fb_unbind(struct fb_info *info)
> >  	console_unlock();
> >  }
> >  
> > -/* called with console_lock held */
> >  void fbcon_fb_unregistered(struct fb_info *info)
> >  {
> 
> Removing these comments feels like should be in a separate patch or at least
> mention in the patch description that should had been removed in the commit
> 6e7da3af008b ("fbcon: Move console_lock for register/unlink/unregister"),
> that made these functions to be called without the console_lock being held.

Yeah I forgot to mention that in the commit message - while reviewing all
the locking to figure out the bug I also noticed that I didn't update the
comments, and since it's all issues in the same patch I figured I'll do it
all in one go.

Ok if I explain that and then keep the comment removals?
-Daniel
> 
> The changes themselves look good to me.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> 
> -- 
> Best regards,
> 
> Javier Martinez Canillas
> Linux Engineering
> Red Hat
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Javier Martinez Canillas <javierm@redhat.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Du Cheng <ducheng2@gmail.com>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Zheyu Ma <zheyuma97@gmail.com>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Matthew Wilcox <willy@infradead.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Sam Ravnborg <sam@ravnborg.org>, Helge Deller <deller@gmx.de>,
	Guenter Roeck <linux@roeck-us.net>
Subject: Re: [Intel-gfx] [PATCH] fbcon: Fix delayed takeover locking
Date: Wed, 13 Apr 2022 11:21:23 +0200	[thread overview]
Message-ID: <YlaWE+/YBtcrnLHY@phenom.ffwll.local> (raw)
In-Reply-To: <955400a5-a785-57af-92d4-42710c55ce99@redhat.com>

On Wed, Apr 13, 2022 at 11:16:08AM +0200, Javier Martinez Canillas wrote:
> Hello Daniel,
> 
> On 4/13/22 10:21, Daniel Vetter wrote:
> > I messed up the delayed takover path in the locking conversion in
> > 6e7da3af008b ("fbcon: Move console_lock for register/unlink/unregister").
> >
> 
> Maybe a few more words of what the issue is ? Something like the following:
> 
> If CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER is enabled, fbcon take-over
> doesn't take place when calling fbcon_fb_registered(). Instead, is deferred
> using a workqueue and its fbcon_register_existing_fbs() function calls to
> fbcon_fb_registered() again for each registered fbcon fb.
> 
> This leads to the console_lock tried to be held twice, causing a deadlock.

Will add.
>  
> > Fix it by re-extracting the lockless function and using it in the
> > delayed takeover path, where we need to hold the lock already to
> > iterate over the list of already registered fb. Well the current code
> > still is broken in there (since the list is protected by a
> > registration_lock, which we can't take here because it nests the other
> > way round with console_lock), but in the future this will be a list
> > protected by console_lock when this is all sorted out.
> > 
> 
> [snip]
> 
> >  
> > -/* called with console_lock held */
> >  void fbcon_fb_unbind(struct fb_info *info)
> >  {
> >  	int i, new_idx = -1;
> > @@ -2822,7 +2821,6 @@ void fbcon_fb_unbind(struct fb_info *info)
> >  	console_unlock();
> >  }
> >  
> > -/* called with console_lock held */
> >  void fbcon_fb_unregistered(struct fb_info *info)
> >  {
> 
> Removing these comments feels like should be in a separate patch or at least
> mention in the patch description that should had been removed in the commit
> 6e7da3af008b ("fbcon: Move console_lock for register/unlink/unregister"),
> that made these functions to be called without the console_lock being held.

Yeah I forgot to mention that in the commit message - while reviewing all
the locking to figure out the bug I also noticed that I didn't update the
comments, and since it's all issues in the same patch I figured I'll do it
all in one go.

Ok if I explain that and then keep the comment removals?
-Daniel
> 
> The changes themselves look good to me.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> 
> -- 
> Best regards,
> 
> Javier Martinez Canillas
> Linux Engineering
> Red Hat
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2022-04-13  9:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13  8:21 [PATCH] fbcon: Fix delayed takeover locking Daniel Vetter
2022-04-13  8:21 ` [Intel-gfx] " Daniel Vetter
2022-04-13  9:16 ` Javier Martinez Canillas
2022-04-13  9:16   ` [Intel-gfx] " Javier Martinez Canillas
2022-04-13  9:21   ` Daniel Vetter [this message]
2022-04-13  9:21     ` Daniel Vetter
2022-04-13  9:31     ` Javier Martinez Canillas
2022-04-13  9:31       ` [Intel-gfx] " Javier Martinez Canillas
2022-04-13  9:25 ` Daniel Vetter
2022-04-13  9:25   ` [Intel-gfx] " Daniel Vetter
2022-04-13 15:20   ` Nathan Chancellor
2022-04-13 15:20     ` [Intel-gfx] " Nathan Chancellor
2022-04-13 20:50 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2022-04-13 21:12 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-04-13 23:13 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork

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=YlaWE+/YBtcrnLHY@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=cssk@net-c.es \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ducheng2@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=linux@roeck-us.net \
    --cc=nathan@kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=sam@ravnborg.org \
    --cc=tzimmermann@suse.de \
    --cc=willy@infradead.org \
    --cc=zheyuma97@gmail.com \
    /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.