public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Anders Roxell <anders.roxell@linaro.org>
Cc: Feiyang Chen <chenfeiyang@loongson.cn>,
	bhelgaas@google.com, rafael.j.wysocki@intel.com,
	mika.westerberg@linux.intel.com, helgaas@kernel.org,
	linux-pci@vger.kernel.org, linux-pm@vger.kernel.org,
	guyinggang@loongson.cn, siyanteng@loongson.cn,
	chenhuacai@loongson.cn, loongson-kernel@lists.loongnix.cn,
	chris.chenfeiyang@gmail.com
Subject: Re: [PATCH v2] PCI/PM: Only read PCI_PM_CTRL register when available
Date: Tue, 22 Aug 2023 16:17:32 +0300 (EEST)	[thread overview]
Message-ID: <5077577-baf2-39a1-d28e-e022bcd96039@linux.intel.com> (raw)
In-Reply-To: <CADYN=9L-RS1NPZqogi4M9oLEB8Tod31pn2+D6sk1Am++b8LE9g@mail.gmail.com>

On Tue, 22 Aug 2023, Anders Roxell wrote:

> On Tue, 22 Aug 2023 at 13:55, Feiyang Chen <chenfeiyang@loongson.cn> wrote:
> >
> > When the current state is already PCI_D0, pci_power_up() will return
> > 0 even though dev->pm_cap is not set. In that case, we should not
> > read the PCI_PM_CTRL register in pci_set_full_power_state().
> >
> > Fixes: e200904b275c ("PCI/PM: Split pci_power_up()")
> > Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
> > ---
> >  drivers/pci/pci.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > index 60230da957e0..7e90ab7b47a1 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -1242,9 +1242,6 @@ int pci_power_up(struct pci_dev *dev)
> >                 else
> >                         dev->current_state = state;
> >
> > -               if (state == PCI_D0)
> > -                       return 0;
> > -
> >                 return -EIO;
> >         }
> >
> > @@ -1302,8 +1299,12 @@ static int pci_set_full_power_state(struct pci_dev *dev)
> >         int ret;
> >
> >         ret = pci_power_up(dev);
> > -       if (ret < 0)
> > +       if (ret < 0) {
> > +               if (dev->current_state == PCI_D0)
> > +                       return 0;
> > +
> >                 return ret;
> > +       }
> >
> >         pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
> >         dev->current_state = pmcsr & PCI_PM_CTRL_STATE_MASK;
> 
> In fuction pci_power_up() there's another if-statement
> if (state == PCI_D0)
>         goto end;
>
> That also will return 0 if need_restore isn't true.
> What will happen then?

That case is only after pci_power_up() has returned because of 
!dev->pm_cap. As such, it looks unrelated to the case this patch is fixing 
which is the read from PCI_PM_CTRL when dev->pm_cap is not there.

> Would this work?
> 
>         ret = pci_power_up(dev);
> -       if (ret < 0)
> +       if (ret <= 0)
>                  return ret;


-- 
 i.


  reply	other threads:[~2023-08-22 13:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-22 11:55 [PATCH v2] PCI/PM: Only read PCI_PM_CTRL register when available Feiyang Chen
2023-08-22 13:06 ` Anders Roxell
2023-08-22 13:17   ` Ilpo Järvinen [this message]
2023-08-22 13:24 ` Ilpo Järvinen
2023-08-22 14:24   ` Rafael J. Wysocki
2023-08-23  7:28     ` Ilpo Järvinen
2023-08-23 12:46       ` Rafael J. Wysocki
2023-08-23 20:50         ` Bjorn Helgaas
2023-08-24  1:27           ` Feiyang Chen
2023-08-22 18:54 ` Rafael J. Wysocki

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=5077577-baf2-39a1-d28e-e022bcd96039@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=anders.roxell@linaro.org \
    --cc=bhelgaas@google.com \
    --cc=chenfeiyang@loongson.cn \
    --cc=chenhuacai@loongson.cn \
    --cc=chris.chenfeiyang@gmail.com \
    --cc=guyinggang@loongson.cn \
    --cc=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=loongson-kernel@lists.loongnix.cn \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=siyanteng@loongson.cn \
    /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