From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Pavel Machek <pavel@suse.cz>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
pm list <linux-pm@lists.linux-foundation.org>,
Jesse Barnes <jbarnes@virtuousgeek.org>
Subject: Re: [linux-pm] [PATCH 2/2] PCI PM: Introduce pci_preferred_state
Date: Wed, 7 May 2008 20:32:57 +0200 [thread overview]
Message-ID: <200805072032.58472.rjw@sisk.pl> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0805071139020.3701-100000@iolanthe.rowland.org>
On Wednesday, 7 of May 2008, Alan Stern wrote:
> On Wed, 7 May 2008, Rafael J. Wysocki wrote:
>
> > On Wednesday, 7 of May 2008, Pavel Machek wrote:
> > > Hi!
> > >
> > > > From: Rafael J. Wysocki <rjw@sisk.pl>
> > > >
> > > > The new suspend and hibernation callbacks introduced with
> > > > 'struct pm_ops' and 'struct pm_ext_ops' do not take a
> > > > pm_message_t argument, so the drivers using them will not be able
> > > > to use pci_choose_state() in its present form. For this reason,
> > > > introduce the new function pci_preferred_state() playing the role
> > > > of pci_choose_state(), but taking only a pointer to the device
> > > > object.
> > > >
> > > > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> > > > ---
> > > > drivers/pci/pci.c | 33 ++++++++++++++++++++++++++++++++-
> > > > include/linux/pci.h | 1 +
> > > > include/linux/pm.h | 10 ++++++++++
> > > > 3 files changed, 43 insertions(+), 1 deletion(-)
> > > >
> > > > Index: linux-2.6/drivers/pci/pci.c
> > > > ===================================================================
> > > > --- linux-2.6.orig/drivers/pci/pci.c
> > > > +++ linux-2.6/drivers/pci/pci.c
> > > > @@ -509,7 +509,38 @@ pci_set_power_state(struct pci_dev *dev,
> > > > }
> > > >
> > > > pci_power_t (*platform_pci_choose_state)(struct pci_dev *dev);
> > > > -
> > > > +
> > > > +/**
> > > > + * pci_preferred_state - Choose the preferred power state of a PCI device
> > > > + * @dev: PCI device to be put into the low power state
> > > > + * @sp: Information aboutabout what the driver would prefer to do with
> > > > + * the device if there were no platform-implemeted policy.
> > > > + *
> > > > + * Returns PCI power state suitable for given device and given suspend policy.
> > > > + * The policy, however, is only used if platform_pci_choose_state() fails or is
> > > > + * not present. Otherwise, it is assumed that platform_pci_choose_state()
> > > > + * implements the right policy.
> > > > + */
> > > > +
> > > > +pci_power_t pci_preferred_state(struct pci_dev *dev, enum suspend_policy sp)
> > > > +{
> > > > + pci_power_t ret;
> > > > +
> > > > + if (!pci_find_capability(dev, PCI_CAP_ID_PM))
> > > > + return PCI_D0;
> > > > +
> > > > + ret = (sp == SP_TURN_OFF) ? PCI_D3hot : PCI_D0;
> > > > + if (platform_pci_choose_state) {
> > > > + pci_power_t platform_ret = platform_pci_choose_state(dev);
> > > > +
> > > > + if (platform_ret != PCI_POWER_ERROR)
> > > > + ret = platform_ret;
> > > > + }
> > > > + return ret;
> > > > +}
> > > > +
> > > > +EXPORT_SYMBOL(pci_preferred_state);
> > >
> > > I don't get it. How is driver supposed to use this? How does the
> > > driver decide between SP_TURN_OFF and SP_TURN_ON?
> > >
> > > ...and it seems to be clearer to just inline this in the driver... or
> > > pass PCI_D3hot/PCI_D0 to it, instead of inventing yet another
> > > define...
> >
> > I thought about that too. I'd like to know what the other people think,
> > though.
>
> The point of this isn't at all clear.
>
> Is this routine meant to be called during a hibernation
> transition?
Yes, it is.
> Or is it just for suspend?
>
> And why would the return value ever be anything other than D3_hot? (Or
> why would the driver ever want to put a device in a different state?)
In principle, the driver may want to put the device into a state having shorter
wake up latency than D3_hot.
> AFAICS, the only reason would be because platform_pci_choose_state()
> suggested something else. In which case there's no need for the
> "policy" argument.
There is a need in two cases:
- if platform_pci_choose_state() is not defined (it only is defined for ACPI
systems at the moment),
- if platform_pci_choose_state() returns PCI_POWER_ERROR meaning that it cannot
handle the device.
I agree with Pavel that the driver could pass a "fallback state" as a second
argument to be used in case the platform cannot provide it with one.
Thanks,
Rafael
next prev parent reply other threads:[~2008-05-07 18:32 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-06 21:42 [PATCH 0/2] Patches for 2.6.27, dependent on the other trees Rafael J. Wysocki
2008-05-06 21:44 ` [PATCH 1/2] ACPI PM: Add suspend sequence workaround Rafael J. Wysocki
2008-05-06 21:57 ` Carlos Corbacho
2008-05-06 22:09 ` Rafael J. Wysocki
2008-05-07 9:29 ` Pavel Machek
2008-05-07 12:21 ` Rafael J. Wysocki
2008-05-09 17:20 ` Rafael J. Wysocki
2008-05-09 17:21 ` [RFC][PATCH 1/2] ACPI PM: Remove obsolete Toshiba workaround Rafael J. Wysocki
2008-05-12 7:18 ` Pavel Machek
2008-05-09 17:23 ` [RFC][PATCH 2/2] ACPI PM: Add possibility to change suspend sequence Rafael J. Wysocki
2008-05-12 7:23 ` Pavel Machek
2008-05-12 22:34 ` Rafael J. Wysocki
2008-05-12 23:03 ` Rafael J. Wysocki
2008-05-19 22:36 ` Pavel Machek
2008-05-06 21:49 ` [PATCH 2/2] PCI PM: Introduce pci_preferred_state Rafael J. Wysocki
2008-05-07 9:33 ` Pavel Machek
2008-05-07 12:22 ` Rafael J. Wysocki
2008-05-07 15:45 ` [linux-pm] " Alan Stern
2008-05-07 18:32 ` Rafael J. Wysocki [this message]
2008-05-09 15:44 ` Rafael J. Wysocki
2008-05-09 16:47 ` Jesse Barnes
2008-05-09 17:13 ` [linux-pm] " Rafael J. Wysocki
2008-05-09 17:24 ` Jesse Barnes
2008-05-09 17:34 ` [linux-pm] " Rafael J. Wysocki
2008-05-09 17:37 ` Jesse Barnes
2008-05-09 21:44 ` Rafael J. Wysocki
2008-05-09 22:13 ` Jesse Barnes
2008-05-09 22:57 ` Rafael J. Wysocki
2008-05-10 18:28 ` Rafael J. Wysocki
2008-05-12 14:00 ` Pavel Machek
2008-05-12 14:52 ` 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=200805072032.58472.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=pavel@suse.cz \
--cc=stern@rowland.harvard.edu \
/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