public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@suse.cz>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	pm list <linux-pm@lists.linux-foundation.org>
Subject: Re: [linux-pm] [PATCH 2/2] PCI PM: Introduce pci_preferred_state
Date: Mon, 12 May 2008 16:00:13 +0200	[thread overview]
Message-ID: <20080512140013.GC1725@elf.ucw.cz> (raw)
In-Reply-To: <200805092344.53713.rjw@sisk.pl>

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 a new function, pci_choose_and_set_state(), playing the
> role of pci_choose_state() combined with pci_set_power_state() and
> allowing the driver to put the device into a power state chosen by
> the platform.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---
>  drivers/pci/pci.c   |   46 +++++++++++++++++++++++++++++++++++++++++++++-
>  include/linux/pci.h |    1 +
>  2 files changed, 46 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,51 @@ pci_set_power_state(struct pci_dev *dev,
>  }
>  
>  pci_power_t (*platform_pci_choose_state)(struct pci_dev *dev);
> - 
> +
> +/**
> + * pci_choose_and_set_state - Choose the power state of a PCI device and put
> + *                            the device into that state.
> + * @dev: PCI device to be put into a low power state
> + * @state: State to put the device into by default
> + *
> + * Use the platform driver to choose the preferred PCI power state of given
> + * device and put the device into that state.  If the target power state of
> + * the device cannot be chosen using the platform driver, the driver-provided
> + * @state is used.
> + *
> + * RETURN VALUE:
> + * -EINVAL if trying to enter a lower state than we're already in.
> + * 0 if we're already in the requested state.
> + * -EIO if device does not support PCI PM.
> + * 0 if we can successfully change the power state.
> + */
> +
> +int pci_choose_and_set_state(struct pci_dev *dev, pci_power_t state)
> +{

> +	if (!pci_find_capability(dev, PCI_CAP_ID_PM))
> +		return -EIO;

Hmm, not sure if this is good idea. First, simple drivers will just
ignore the return value, and second, it returns -EIO even if I'm
asking it to enter state it already has -- like PCI_D0 -- no?


> +	if (platform_pci_choose_state) {
> +		pci_power_t ret = platform_pci_choose_state(dev);
> +
> +		switch (ret) {
> +		case PCI_POWER_ERROR:
> +		case PCI_UNKNOWN:
> +			break;
> +		case PCI_D1:
> +		case PCI_D2:
> +			if (pci_no_d1d2(dev))
> +				break;
> +		default:
> +			state = ret;
> +		}
> +	}
> +
> +	return pci_set_power_state(dev, state);
> +}

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  parent reply	other threads:[~2008-05-12 13:59 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
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 [this message]
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=20080512140013.GC1725@elf.ucw.cz \
    --to=pavel@suse.cz \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=rjw@sisk.pl \
    --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