linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com>,
	linux-pci@vger.kernel.org
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Yinghai Lu <yhlu.kernel@gmail.com>
Subject: Re: [PATCH] PCI: Set device power state to PCI_D0 for device without native PM support
Date: Tue, 13 Dec 2011 10:53:27 -0800	[thread overview]
Message-ID: <20111213105327.55c6e098@jbarnes-desktop> (raw)
In-Reply-To: <4EE5BAF8.4000303@oracle.com>

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

Ok I applied this to for-linus, but git am didn't like it so I had to
merge it by hand.  Please check it out and make sure it still works for
you.

Thanks,
jesse

On Mon, 12 Dec 2011 13:57:36 +0530
Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com> wrote:

> Hi Jesse,
> 
> Have following query, please point me to correct person if I am asking 
> this to wrong person:
> Any particular reason, why this is not checked in yet? Is something 
> missing here?
> 
> Thanks,
> Ajay
> 
> -------- Original Message --------
> Subject: 	Re: [PATCH] PCI: Set device power state to PCI_D0 for device 
> without native PM support
> Date: 	Fri, 28 Oct 2011 17:36:43 +0530
> From: 	Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com>
> To: 	Jesse Barnes <jbarnes@virtuousgeek.org>, 
> "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>, 
> "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
> CC: 	Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Yinghai Lu 
> <yhlu.kernel@gmail.com>
> 
> 
> 
> On 10/27/2011 08:31 PM, Stefano Stabellini wrote:
> >  On Thu, 27 Oct 2011, Ajaykumar Hotchandani wrote:
> >>>  BTW I am OK with your patch.
> >>  Should we revert 47e9037ac16637cd7f12b8790ea7ce6680e42168 (your changes
> >>  in register_slot() )
> >>  I think, after this change, it's not needed. Or, am I missing some scenario?
> >>
> >  I think you are right, 47e9037ac16637cd7f12b8790ea7ce6680e42168 is not
> >  needed anymore, so I am OK with reverting it.
> 
> Thanks, following is updated patch.
> 
> [PATCH -v2] PCI: Set device power state to PCI_D0 for device without
> native PM support
> 
> During test of one IB card with guest VM, found that, msi is not
> initialized properly.
> 
> It turns out __write_msi_msg will do nothing if device current_state is
> not PCI_D0.
> And, that pci device does not have pm_cap in guest VM.
> 
> There is an error in setting of power state to PCI_D0 in
> pci_enable_device(), but error is not returned for this.
> Following is code flow:
> pci_enable_device() -->   __pci_enable_device_flags() -->
> do_pci_enable_device() -->   pci_set_power_state() -->
> __pci_start_power_transition()
> We have following condition inside __pci_start_power_transition():
>          if (platform_pci_power_manageable(dev)) {
>                  error = platform_pci_set_power_state(dev, state);
>                  if (!error)
>                          pci_update_current_state(dev, state);
>          } else {
>                  error = -ENODEV;
>                  /* Fall back to PCI_D0 if native PM is not supported */
>                  if (!dev->pm_cap)
>                          dev->current_state = PCI_D0;
>          }
> 
> Here, from platform_pci_set_power_state(), acpi_pci_set_power_state() is
> getting called and that is failing with ENODEV because of following
> condition:
>          if (!handle || ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0",&tmp)))
>                  return -ENODEV;
> 
> Because of that, pci_update_current_state() is not getting called.
> 
> With this patch, if device power state can not be set via
> platform_pci_set_power_state and that device does not have native pm
> support, then PCI device power state will be set to PCI_D0.
> 
> -v2: This also reverts 47e9037ac16637cd7f12b8790ea7ce6680e42168, as it's
> not needed after this change.
> 
> Signed-off-by: Ajaykumar Hotchandani<ajaykumar.hotchandani@oracle.com>
> Signed-off-by: Yinghai Lu<yinghai.lu@oracle.com>
> ---
>   drivers/pci/hotplug/acpiphp_glue.c |    1 -
>   drivers/pci/pci.c                  |    3 +++
>   2 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/acpiphp_glue.c
> b/drivers/pci/hotplug/acpiphp_glue.c
> index 2202857..11431c1 100644
> --- a/drivers/pci/hotplug/acpiphp_glue.c
> +++ b/drivers/pci/hotplug/acpiphp_glue.c
> @@ -212,7 +212,6 @@ register_slot(acpi_handle handle, u32 lvl, void
> *context, void **rv)
> 
>          pdev = pci_get_slot(pbus, PCI_DEVFN(device, function));
>          if (pdev) {
> -               pdev->current_state = PCI_D0;
>                  slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON);
>                  pci_dev_put(pdev);
>          }
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index e9651f0..6866937 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -664,6 +664,9 @@ static int pci_platform_power_transition(struct
> pci_dev *dev, pci_power_t state)
>                  error = platform_pci_set_power_state(dev, state);
>                  if (!error)
>                          pci_update_current_state(dev, state);
> +               /* Fall back to PCI_D0 if native PM is not supported */
> +               if (!dev->pm_cap)
> +                       dev->current_state = PCI_D0;
>          } else {
>                  error = -ENODEV;
>                  /* Fall back to PCI_D0 if native PM is not supported */


-- 
Jesse Barnes, Intel Open Source Technology Center

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

           reply	other threads:[~2011-12-13 18:53 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <4EE5BAF8.4000303@oracle.com>]

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=20111213105327.55c6e098@jbarnes-desktop \
    --to=jbarnes@virtuousgeek.org \
    --cc=ajaykumar.hotchandani@oracle.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=yhlu.kernel@gmail.com \
    /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).