public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: Set device power state to PCI_D0 for device without native PM support
@ 2011-10-05 11:34 Ajaykumar Hotchandani
  2011-10-05 19:41 ` Rafael J. Wysocki
  2011-10-06 10:39 ` Stefano Stabellini
  0 siblings, 2 replies; 14+ messages in thread
From: Ajaykumar Hotchandani @ 2011-10-05 11:34 UTC (permalink / raw)
  To: Jesse Barnes, linux-pci, linux-kernel

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.

Signed-off-by: Ajaykumar Hotchandani<ajaykumar.hotchandani@oracle.com>
Signed-off-by: Yinghai Lu<yinghai.lu@oracle.com>
---
  drivers/pci/pci.c |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e9651f0..ca8c82d 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 */
+               else if (!dev->pm_cap)
+                       dev->current_state = PCI_D0;
         } else {
                 error = -ENODEV;
                 /* Fall back to PCI_D0 if native PM is not supported */
-- 
1.7.5.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-10-28 12:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-05 11:34 [PATCH] PCI: Set device power state to PCI_D0 for device without native PM support Ajaykumar Hotchandani
2011-10-05 19:41 ` Rafael J. Wysocki
2011-10-06 16:10   ` Yinghai Lu
2011-10-06 17:20     ` Rafael J. Wysocki
2011-10-06 10:39 ` Stefano Stabellini
2011-10-06 16:05   ` Yinghai Lu
2011-10-06 16:17     ` Stefano Stabellini
2011-10-10 12:02       ` Ajaykumar Hotchandani
2011-10-13 14:30         ` Stefano Stabellini
2011-10-18 13:52           ` Ajaykumar Hotchandani
2011-10-27 13:14             ` Stefano Stabellini
2011-10-27 14:34               ` Ajaykumar Hotchandani
2011-10-27 15:01                 ` Stefano Stabellini
2011-10-28 12:06                   ` Ajaykumar Hotchandani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox