dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/fb-helper: Add locking to sysrq handling
@ 2020-10-07 13:30 Daniel Vetter
  2020-10-08  9:22 ` Thomas Zimmermann
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Vetter @ 2020-10-07 13:30 UTC (permalink / raw)
  To: DRI Development
  Cc: David Airlie, Daniel Vetter, Intel Graphics Development,
	Thomas Zimmermann, Daniel Vetter

We didn't take the kernel_fb_helper_lock mutex, which protects that
code. While at it, simplify the code
- inline the function (originally shared with kgdb I think)
- drop the error tracking and all the complications
- drop the pointless early out, it served nothing

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
---
 drivers/gpu/drm/drm_fb_helper.c | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 8697554ccd41..c2f72bb6afb1 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -281,18 +281,12 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)
 EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked);
 
 #ifdef CONFIG_MAGIC_SYSRQ
-/*
- * restore fbcon display for all kms driver's using this helper, used for sysrq
- * and panic handling.
- */
-static bool drm_fb_helper_force_kernel_mode(void)
+/* emergency restore, don't bother with error reporting */
+static void drm_fb_helper_restore_work_fn(struct work_struct *ignored)
 {
-	bool ret, error = false;
 	struct drm_fb_helper *helper;
 
-	if (list_empty(&kernel_fb_helper_list))
-		return false;
-
+	mutex_lock(&kernel_fb_helper_lock);
 	list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) {
 		struct drm_device *dev = helper->dev;
 
@@ -300,22 +294,12 @@ static bool drm_fb_helper_force_kernel_mode(void)
 			continue;
 
 		mutex_lock(&helper->lock);
-		ret = drm_client_modeset_commit_locked(&helper->client);
-		if (ret)
-			error = true;
+		drm_client_modeset_commit_locked(&helper->client);
 		mutex_unlock(&helper->lock);
 	}
-	return error;
+	mutex_unlock(&kernel_fb_helper_lock);
 }
 
-static void drm_fb_helper_restore_work_fn(struct work_struct *ignored)
-{
-	bool ret;
-
-	ret = drm_fb_helper_force_kernel_mode();
-	if (ret == true)
-		DRM_ERROR("Failed to restore crtc configuration\n");
-}
 static DECLARE_WORK(drm_fb_helper_restore_work, drm_fb_helper_restore_work_fn);
 
 static void drm_fb_helper_sysrq(int dummy1)
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/fb-helper: Add locking to sysrq handling
  2020-10-07 13:30 [PATCH] drm/fb-helper: Add locking to sysrq handling Daniel Vetter
@ 2020-10-08  9:22 ` Thomas Zimmermann
  2020-10-08  9:29   ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Zimmermann @ 2020-10-08  9:22 UTC (permalink / raw)
  To: Daniel Vetter, DRI Development
  Cc: David Airlie, Intel Graphics Development, Daniel Vetter


[-- Attachment #1.1.1: Type: text/plain, Size: 3019 bytes --]

Hi

Am 07.10.20 um 15:30 schrieb Daniel Vetter:
> We didn't take the kernel_fb_helper_lock mutex, which protects that
> code. While at it, simplify the code
> - inline the function (originally shared with kgdb I think)
> - drop the error tracking and all the complications
> - drop the pointless early out, it served nothing
> 
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> ---
>  drivers/gpu/drm/drm_fb_helper.c | 26 +++++---------------------
>  1 file changed, 5 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 8697554ccd41..c2f72bb6afb1 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -281,18 +281,12 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)
>  EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked);
>  
>  #ifdef CONFIG_MAGIC_SYSRQ
> -/*
> - * restore fbcon display for all kms driver's using this helper, used for sysrq
> - * and panic handling.
> - */
> -static bool drm_fb_helper_force_kernel_mode(void)
> +/* emergency restore, don't bother with error reporting */
> +static void drm_fb_helper_restore_work_fn(struct work_struct *ignored)
>  {
> -	bool ret, error = false;
>  	struct drm_fb_helper *helper;
>  
> -	if (list_empty(&kernel_fb_helper_list))
> -		return false;
> -
> +	mutex_lock(&kernel_fb_helper_lock);
>  	list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) {
>  		struct drm_device *dev = helper->dev;
>  
> @@ -300,22 +294,12 @@ static bool drm_fb_helper_force_kernel_mode(void)
>  			continue;
>  
>  		mutex_lock(&helper->lock);
> -		ret = drm_client_modeset_commit_locked(&helper->client);
> -		if (ret)
> -			error = true;
> +		drm_client_modeset_commit_locked(&helper->client);
>  		mutex_unlock(&helper->lock);
>  	}
> -	return error;
> +	mutex_unlock(&kernel_fb_helper_lock);
>  }
>  
> -static void drm_fb_helper_restore_work_fn(struct work_struct *ignored)
> -{
> -	bool ret;
> -
> -	ret = drm_fb_helper_force_kernel_mode();
> -	if (ret == true)
> -		DRM_ERROR("Failed to restore crtc configuration\n");

Is there a specific reason for removing that warning? Even if it doesn't
show up on screen, is it not helpful in the kernel's log?

In any case, the rest looks good.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>

Best regards
Thomas

> -}
>  static DECLARE_WORK(drm_fb_helper_restore_work, drm_fb_helper_restore_work_fn);
>  
>  static void drm_fb_helper_sysrq(int dummy1)
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 516 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/fb-helper: Add locking to sysrq handling
  2020-10-08  9:22 ` Thomas Zimmermann
@ 2020-10-08  9:29   ` Daniel Vetter
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2020-10-08  9:29 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: David Airlie, Intel Graphics Development, DRI Development, Daniel Vetter

On Thu, Oct 8, 2020 at 11:22 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Hi
>
> Am 07.10.20 um 15:30 schrieb Daniel Vetter:
> > We didn't take the kernel_fb_helper_lock mutex, which protects that
> > code. While at it, simplify the code
> > - inline the function (originally shared with kgdb I think)
> > - drop the error tracking and all the complications
> > - drop the pointless early out, it served nothing
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Cc: Maxime Ripard <mripard@kernel.org>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: David Airlie <airlied@linux.ie>
> > Cc: Daniel Vetter <daniel@ffwll.ch>
> > ---
> >  drivers/gpu/drm/drm_fb_helper.c | 26 +++++---------------------
> >  1 file changed, 5 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> > index 8697554ccd41..c2f72bb6afb1 100644
> > --- a/drivers/gpu/drm/drm_fb_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_helper.c
> > @@ -281,18 +281,12 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)
> >  EXPORT_SYMBOL(drm_fb_helper_restore_fbdev_mode_unlocked);
> >
> >  #ifdef CONFIG_MAGIC_SYSRQ
> > -/*
> > - * restore fbcon display for all kms driver's using this helper, used for sysrq
> > - * and panic handling.
> > - */
> > -static bool drm_fb_helper_force_kernel_mode(void)
> > +/* emergency restore, don't bother with error reporting */
> > +static void drm_fb_helper_restore_work_fn(struct work_struct *ignored)
> >  {
> > -     bool ret, error = false;
> >       struct drm_fb_helper *helper;
> >
> > -     if (list_empty(&kernel_fb_helper_list))
> > -             return false;
> > -
> > +     mutex_lock(&kernel_fb_helper_lock);
> >       list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) {
> >               struct drm_device *dev = helper->dev;
> >
> > @@ -300,22 +294,12 @@ static bool drm_fb_helper_force_kernel_mode(void)
> >                       continue;
> >
> >               mutex_lock(&helper->lock);
> > -             ret = drm_client_modeset_commit_locked(&helper->client);
> > -             if (ret)
> > -                     error = true;
> > +             drm_client_modeset_commit_locked(&helper->client);
> >               mutex_unlock(&helper->lock);
> >       }
> > -     return error;
> > +     mutex_unlock(&kernel_fb_helper_lock);
> >  }
> >
> > -static void drm_fb_helper_restore_work_fn(struct work_struct *ignored)
> > -{
> > -     bool ret;
> > -
> > -     ret = drm_fb_helper_force_kernel_mode();
> > -     if (ret == true)
> > -             DRM_ERROR("Failed to restore crtc configuration\n");
>
> Is there a specific reason for removing that warning? Even if it doesn't
> show up on screen, is it not helpful in the kernel's log?

I just found it really unhelpful, if you're trying to force-show
fbcon, what's the point if it doesn't work out? The user will notice.
Also, if we're really in a dire situation where you want this, in my
experience there's a bunch of random other reasons why this can fail,
mostly when the work we have to schedule for locking reasons never
runs. So it's also unreliable.

> In any case, the rest looks good.
>
> Acked-by: Thomas Zimmermann <tzimmermann@suse.de>

Thanks for taking a look, I'll apply it.
-Daniel

>
> Best regards
> Thomas
>
> > -}
> >  static DECLARE_WORK(drm_fb_helper_restore_work, drm_fb_helper_restore_work_fn);
> >
> >  static void drm_fb_helper_sysrq(int dummy1)
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 Nürnberg, Germany
> (HRB 36809, AG Nürnberg)
> Geschäftsführer: Felix Imendörffer
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-08  9:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 13:30 [PATCH] drm/fb-helper: Add locking to sysrq handling Daniel Vetter
2020-10-08  9:22 ` Thomas Zimmermann
2020-10-08  9:29   ` Daniel Vetter

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).