linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: pingshuo <pingshuo@uniontech.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] hibernation:stop resume screen during hibernation
Date: Tue, 22 Jun 2021 15:06:31 +0200	[thread overview]
Message-ID: <CAJZ5v0gnYHmbWANVkoG+6XrUNzBB4__uM0Ladrpn5=L0KEiefA@mail.gmail.com> (raw)
In-Reply-To: <20210622124547.28317-1-pingshuo@uniontech.com>

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

  reply	other threads:[~2021-06-22 13:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 12:45 [PATCH] hibernation:stop resume screen during hibernation pingshuo
2021-06-22 13:06 ` Rafael J. Wysocki [this message]
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

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='CAJZ5v0gnYHmbWANVkoG+6XrUNzBB4__uM0Ladrpn5=L0KEiefA@mail.gmail.com' \
    --to=rafael@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=pingshuo@uniontech.com \
    --cc=rjw@rjwysocki.net \
    /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).