linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hibernation:stop resume screen during hibernation
@ 2021-06-22 12:45 pingshuo
  2021-06-22 13:06 ` Rafael J. Wysocki
  2021-06-22 13:19 ` Greg KH
  0 siblings, 2 replies; 7+ messages in thread
From: pingshuo @ 2021-06-22 12:45 UTC (permalink / raw)
  To: rjw, len.brown, pavel, gregkh, linux-pm; +Cc: linux-kernel, pingshuo

The display will be woken up during hibernation.
if the computer equipment is poor, it will cause the screen to flicker.
Skip to reusme the display devices in "thaw".

Signed-off-by: pingshuo <pingshuo@uniontech.com>
---
 drivers/base/power/main.c | 43 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index f893c3c5af07..f3e92ac7b4b3 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -35,11 +35,14 @@
 #include <linux/cpuidle.h>
 #include <linux/devfreq.h>
 #include <linux/timer.h>
+#include <linux/pci.h>
 
 #include "../base.h"
 #include "power.h"
 
 typedef int (*pm_callback_t)(struct device *);
+#define VIDEO_PCI_CLASS 0x030000
+#define VIDEO_PCI_CLASS_VALID 0xff0000
 
 #define list_for_each_entry_rcu_locked(pos, head, member) \
 	list_for_each_entry_rcu(pos, head, member, \
@@ -693,6 +696,40 @@ static void async_resume_noirq(void *data, async_cookie_t cookie)
 	put_device(dev);
 }
 
+/**
+ * dpm_resume_skip_display_devices - Skip to reusme the display devices.
+ * @dev: Device to handle.
+ * @state: PM transition of the system being carried out.
+ *
+ * Delete the display devices from the wake-up list during the "thaw".
+ */
+static int dpm_resume_skip_display_devices(struct device *dev, pm_message_t state)
+{
+	struct pci_dev *pci_test = to_pci_dev(dev);
+
+	if (state.event == PM_EVENT_THAW) {
+		/*
+		 * Filter out the display devices
+		 */
+		if ((pci_test && ((pci_test->class & VIDEO_PCI_CLASS_VALID) == VIDEO_PCI_CLASS)) ||
+			(dev->driver && dev->driver->name &&
+			strncmp(dev->driver->name, "video", 6) == 0)) {
+
+			pr_info("Skip the display devices during the thaw.");
+			/*
+			 * Remove the display devices from the resume stage
+			 */
+			list_del(&dev->power.entry);
+			/*
+			 * Remove the display devices from the power down stage
+			 */
+			list_del(&dev->kobj.entry);
+			return 1;
+		}
+	}
+	return 0;
+}
+
 static void dpm_noirq_resume_devices(pm_message_t state)
 {
 	struct device *dev;
@@ -713,6 +750,10 @@ static void dpm_noirq_resume_devices(pm_message_t state)
 	while (!list_empty(&dpm_noirq_list)) {
 		dev = to_device(dpm_noirq_list.next);
 		get_device(dev);
+
+		if (dpm_resume_skip_display_devices(dev, state))
+			continue;
+
 		list_move_tail(&dev->power.entry, &dpm_late_early_list);
 		mutex_unlock(&dpm_list_mtx);
 
@@ -737,6 +778,8 @@ static void dpm_noirq_resume_devices(pm_message_t state)
 	trace_suspend_resume(TPS("dpm_resume_noirq"), state.event, false);
 }
 
+
+
 /**
  * dpm_resume_noirq - Execute "noirq resume" callbacks for all devices.
  * @state: PM transition of the system being carried out.
-- 
2.20.1




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

* Re: [PATCH] hibernation:stop resume screen during hibernation
  2021-06-22 12:45 [PATCH] hibernation:stop resume screen during hibernation pingshuo
@ 2021-06-22 13:06 ` Rafael J. Wysocki
  2021-06-22 13:47   ` Pavel Machek
  2021-06-22 13:19 ` Greg KH
  1 sibling, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2021-06-22 13:06 UTC (permalink / raw)
  To: pingshuo
  Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
	Linux PM, Linux Kernel Mailing List

On Tue, Jun 22, 2021 at 2:46 PM pingshuo <pingshuo@uniontech.com> wrote:
>
> The display will be woken up during hibernation.

That actually depends on its driver.

> if the computer equipment is poor, it will cause the screen to flicker.
> Skip to reusme the display devices in "thaw".

But this patch looks like a proof of concept rather than a proper solution.

This needs to be done more carefully.

> Signed-off-by: pingshuo <pingshuo@uniontech.com>
> ---
>  drivers/base/power/main.c | 43 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
>
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index f893c3c5af07..f3e92ac7b4b3 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -35,11 +35,14 @@
>  #include <linux/cpuidle.h>
>  #include <linux/devfreq.h>
>  #include <linux/timer.h>
> +#include <linux/pci.h>
>
>  #include "../base.h"
>  #include "power.h"
>
>  typedef int (*pm_callback_t)(struct device *);
> +#define VIDEO_PCI_CLASS 0x030000
> +#define VIDEO_PCI_CLASS_VALID 0xff0000
>
>  #define list_for_each_entry_rcu_locked(pos, head, member) \
>         list_for_each_entry_rcu(pos, head, member, \
> @@ -693,6 +696,40 @@ static void async_resume_noirq(void *data, async_cookie_t cookie)
>         put_device(dev);
>  }
>
> +/**
> + * dpm_resume_skip_display_devices - Skip to reusme the display devices.
> + * @dev: Device to handle.
> + * @state: PM transition of the system being carried out.
> + *
> + * Delete the display devices from the wake-up list during the "thaw".
> + */
> +static int dpm_resume_skip_display_devices(struct device *dev, pm_message_t state)
> +{
> +       struct pci_dev *pci_test = to_pci_dev(dev);

If you want to deal with PCI devices, that needs to happen at the PCI
bus type level in the first place.

> +
> +       if (state.event == PM_EVENT_THAW) {
> +               /*
> +                * Filter out the display devices
> +                */
> +               if ((pci_test && ((pci_test->class & VIDEO_PCI_CLASS_VALID) == VIDEO_PCI_CLASS)) ||
> +                       (dev->driver && dev->driver->name &&
> +                       strncmp(dev->driver->name, "video", 6) == 0)) {
> +
> +                       pr_info("Skip the display devices during the thaw.");
> +                       /*
> +                        * Remove the display devices from the resume stage
> +                        */
> +                       list_del(&dev->power.entry);
> +                       /*
> +                        * Remove the display devices from the power down stage
> +                        */
> +                       list_del(&dev->kobj.entry);
> +                       return 1;
> +               }
> +       }
> +       return 0;
> +}
> +
>  static void dpm_noirq_resume_devices(pm_message_t state)
>  {
>         struct device *dev;
> @@ -713,6 +750,10 @@ static void dpm_noirq_resume_devices(pm_message_t state)
>         while (!list_empty(&dpm_noirq_list)) {
>                 dev = to_device(dpm_noirq_list.next);
>                 get_device(dev);
> +
> +               if (dpm_resume_skip_display_devices(dev, state))
> +                       continue;
> +
>                 list_move_tail(&dev->power.entry, &dpm_late_early_list);
>                 mutex_unlock(&dpm_list_mtx);
>
> @@ -737,6 +778,8 @@ static void dpm_noirq_resume_devices(pm_message_t state)
>         trace_suspend_resume(TPS("dpm_resume_noirq"), state.event, false);
>  }
>
> +
> +
>  /**
>   * dpm_resume_noirq - Execute "noirq resume" callbacks for all devices.
>   * @state: PM transition of the system being carried out.
> --

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

* Re: [PATCH] hibernation:stop resume screen during hibernation
  2021-06-22 12:45 [PATCH] hibernation:stop resume screen during hibernation pingshuo
  2021-06-22 13:06 ` Rafael J. Wysocki
@ 2021-06-22 13:19 ` Greg KH
  1 sibling, 0 replies; 7+ messages in thread
From: Greg KH @ 2021-06-22 13:19 UTC (permalink / raw)
  To: pingshuo; +Cc: rjw, len.brown, pavel, linux-pm, linux-kernel

On Tue, Jun 22, 2021 at 08:45:47PM +0800, pingshuo wrote:
> The display will be woken up during hibernation.
> if the computer equipment is poor, it will cause the screen to flicker.
> Skip to reusme the display devices in "thaw".
> 
> Signed-off-by: pingshuo <pingshuo@uniontech.com>
> ---
>  drivers/base/power/main.c | 43 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index f893c3c5af07..f3e92ac7b4b3 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -35,11 +35,14 @@
>  #include <linux/cpuidle.h>
>  #include <linux/devfreq.h>
>  #include <linux/timer.h>
> +#include <linux/pci.h>

That right there is a clue that perhaps this is not the place to be
making this change.

Please do this in the driver for the specific device, you do not want to
do this in the driver core for every individual device type.

Also be more careful, your change here:

> @@ -737,6 +778,8 @@ static void dpm_noirq_resume_devices(pm_message_t state)
>  	trace_suspend_resume(TPS("dpm_resume_noirq"), state.event, false);
>  }
>  
> +
> +
>  /**
>   * dpm_resume_noirq - Execute "noirq resume" callbacks for all devices.
>   * @state: PM transition of the system being carried out.

Was not needed at all.

thanks,

greg k-h

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

* Re: [PATCH] hibernation:stop resume screen during hibernation
  2021-06-22 13:06 ` Rafael J. Wysocki
@ 2021-06-22 13:47   ` Pavel Machek
  2021-06-24  2:06     ` pingshuo
  0 siblings, 1 reply; 7+ messages in thread
From: Pavel Machek @ 2021-06-22 13:47 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: pingshuo, Rafael J. Wysocki, Len Brown, Greg Kroah-Hartman,
	Linux PM, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 535 bytes --]

Hi!

> > The display will be woken up during hibernation.
> 
> That actually depends on its driver.
> 
> > if the computer equipment is poor, it will cause the screen to flicker.
> > Skip to reusme the display devices in "thaw".
> 
> But this patch looks like a proof of concept rather than a proper solution.
> 
> This needs to be done more carefully.

And because it depends on the driver, I believe we should aim for
per-driver solutions.

BR,
								Pavel
								
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* Re: [PATCH] hibernation:stop resume screen during hibernation
  2021-06-22 13:47   ` Pavel Machek
@ 2021-06-24  2:06     ` pingshuo
  0 siblings, 0 replies; 7+ messages in thread
From: pingshuo @ 2021-06-24  2:06 UTC (permalink / raw)
  To: Pavel Machek, Rafael J. Wysocki, Rafael J. Wysocki
  Cc: Len Brown, Greg Kroah-Hartman, Linux PM, Linux Kernel Mailing List



>> The display will be woken up during hibernation.
>
> That actually depends on its driver.
>
>> if the computer equipment is poor, it will cause the screen to flicker.
>> Skip to resume the display devices in "thaw".

> But this patch looks like a proof of concept rather than a proper solution.

>This needs to be done more carefully.

When entering hibernation, the display screen will be off first, then 
will be on (the image data is written to the disk at this time), and 
finally the display screen will be off again.

> If you want to deal with PCI devices, that needs to happen at the PCI
bus type level in the first place

what is the "PCI bus type level" mean ? Do you mean to modify it in 
dev->bus or dev-> bus -> pm?


  We tested different graphics cards,like amdgpu, radeon,i915,nvidia, 
this issue occurs during entering hibernation.
Based on the above test, several graphics cards will be resumed and the 
screen is on, so we add code here.
Did you have any idea  if these code is added in here ?




Please answer a question for me.

Resuming device is to write the image to the disk. Is it necessary to 
wake up all devices? Why not just wake up the devices related to writing 
image?

Anticipate your response.

thanks,
                                                               pingshuo



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

* Re: [PATCH] hibernation:stop resume screen during hibernation
  2021-06-22  8:38 pingshuo
@ 2021-06-22 10:22 ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2021-06-22 10:22 UTC (permalink / raw)
  To: pingshuo; +Cc: rjw, len.brown, pavel, linux-pm, linux-kernel

On Tue, Jun 22, 2021 at 04:38:44PM +0800, pingshuo wrote:
> The display will be woken up during hibernation,
> if the computer equipment is poor, it will cause the screen to flicker.
> Skip to reusme the display devices in "thaw".
> 
> Signed-off-by: pingshuo <pingshuo@uniontech.com>
> ---
>  drivers/base/power/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index c7f51c94969d..376b2eca65c7 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -707,7 +707,7 @@ static int dpm_resume_skip_display_devices(struct device *dev, pm_message_t stat
>  {
>      struct pci_dev *pci_test = to_pci_dev(dev);
>      if (state.event == PM_EVENT_THAW) {
> -        /*
> +	/*
>          *Filter out the display devices
>          */
>          if((pci_test && ((pci_test->class&DISPLAY_PCI_CLASS_VALID_BIT) == DISPLAY_PCI_CLASS))||(dev->driver&&dev->driver->name&&strncmp(dev->driver->name,"video",6)==0))
> -- 
> 2.20.1
> 
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch contains warnings and/or errors noticed by the
  scripts/checkpatch.pl tool.

- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
  and can not be applied.  Please read the file,
  Documentation/email-clients.txt in order to fix this.

- You did not specify a description of why the patch is needed, or
  possibly, any description at all, in the email body.  Please read the
  section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what is needed in order to
  properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg,
  and everyone else, to know what this patch is all about.  Please read
  the section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what a proper Subject: line should
  look like.

- The patch does not do what your description says it does, at all.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

* [PATCH] hibernation:stop resume screen during hibernation
@ 2021-06-22  8:38 pingshuo
  2021-06-22 10:22 ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: pingshuo @ 2021-06-22  8:38 UTC (permalink / raw)
  To: rjw; +Cc: len.brown, pavel, gregkh, linux-pm, linux-kernel, pingshuo

The display will be woken up during hibernation,
if the computer equipment is poor, it will cause the screen to flicker.
Skip to reusme the display devices in "thaw".

Signed-off-by: pingshuo <pingshuo@uniontech.com>
---
 drivers/base/power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index c7f51c94969d..376b2eca65c7 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -707,7 +707,7 @@ static int dpm_resume_skip_display_devices(struct device *dev, pm_message_t stat
 {
     struct pci_dev *pci_test = to_pci_dev(dev);
     if (state.event == PM_EVENT_THAW) {
-        /*
+	/*
         *Filter out the display devices
         */
         if((pci_test && ((pci_test->class&DISPLAY_PCI_CLASS_VALID_BIT) == DISPLAY_PCI_CLASS))||(dev->driver&&dev->driver->name&&strncmp(dev->driver->name,"video",6)==0))
-- 
2.20.1




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

end of thread, other threads:[~2021-06-24  2:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 12:45 [PATCH] hibernation:stop resume screen during hibernation pingshuo
2021-06-22 13:06 ` Rafael J. Wysocki
2021-06-22 13:47   ` Pavel Machek
2021-06-24  2:06     ` pingshuo
2021-06-22 13:19 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2021-06-22  8:38 pingshuo
2021-06-22 10:22 ` Greg KH

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