Patchwork [Karmic] SRU: pci: Ensure we re-enable devices on resume

login
register
mail settings
Submitter Alex Chiang
Date April 27, 2010, 3:27 a.m.
Message ID <20100427032746.GB8140@canonical.com>
Download mbox | patch
Permalink /patch/51030/
State Accepted
Delegated to: Stefan Bader
Headers show

Comments

Alex Chiang - April 27, 2010, 3:27 a.m.
BugLink: http://bugs.launchpad.net/bugs/566149

SRU justification:
The original patch which added the check in pci_set_power_state was a
minor thinko, and prevented platform resume code from running. This patch
removes the incorrect check, allowing platform resume code to run, thus
re-enabling devices such as USB ports.

Backport of upstream commit:

commit cc2893b6af5265baa1d68b17b136cffca9e40cfa
Author: Matthew Garrett <mjg@redhat.com>
Date:   Thu Apr 22 09:30:51 2010 -0400

    PCI: Ensure we re-enable devices on resume
    
    If the firmware puts a device back into D0 state at resume time, we'll
    update its state in resume_noirq and thus skip the platform resume code.
    Calling that code twice should be safe and we ought to avoid getting to
    that point anyway, so remove the check and also allow the platform pci
    code to be called for D0.
    
    Fixes USB not being powered after resume on recent Lenovo machines.
    
    Acked-by: Alex Chiang <achiang@canonical.com>
    Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
    Signed-off-by: Matthew Garrett <mjg@redhat.com>
    Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

Signed-off-by: Alex Chiang <achiang@canonical.com>
---
Tim Gardner - April 27, 2010, 9:51 a.m.
On 04/27/2010 04:27 AM, Alex Chiang wrote:
> BugLink: http://bugs.launchpad.net/bugs/566149
>
> SRU justification:
> The original patch which added the check in pci_set_power_state was a
> minor thinko, and prevented platform resume code from running. This patch
> removes the incorrect check, allowing platform resume code to run, thus
> re-enabling devices such as USB ports.
>
> Backport of upstream commit:
>
> commit cc2893b6af5265baa1d68b17b136cffca9e40cfa
> Author: Matthew Garrett<mjg@redhat.com>
> Date:   Thu Apr 22 09:30:51 2010 -0400
>
>      PCI: Ensure we re-enable devices on resume
>
>      If the firmware puts a device back into D0 state at resume time, we'll
>      update its state in resume_noirq and thus skip the platform resume code.
>      Calling that code twice should be safe and we ought to avoid getting to
>      that point anyway, so remove the check and also allow the platform pci
>      code to be called for D0.
>
>      Fixes USB not being powered after resume on recent Lenovo machines.
>
>      Acked-by: Alex Chiang<achiang@canonical.com>
>      Acked-by: Rafael J. Wysocki<rjw@sisk.pl>
>      Signed-off-by: Matthew Garrett<mjg@redhat.com>
>      Signed-off-by: Jesse Barnes<jbarnes@virtuousgeek.org>
>
> Signed-off-by: Alex Chiang<achiang@canonical.com>
> ---
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index e5f3f1c..579dcf5 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -591,7 +591,7 @@ static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
>    */
>   int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state)
>   {
> -	return state>  PCI_D0 ?
> +	return state>= PCI_D0 ?
>   			pci_platform_power_transition(dev, state) : -EINVAL;
>   }
>   EXPORT_SYMBOL_GPL(__pci_complete_power_transition);
> @@ -628,10 +628,6 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
>   		 */
>   		return 0;
>
> -	/* Check if we're already there */
> -	if (dev->current_state == state)
> -		return 0;
> -
>   	__pci_start_power_transition(dev, state);
>
>   	/* This device is quirked not to be put into D3, so
>

This looks like it is also appropriate for Lucid as well as 
stable@kernel.org, right?

Acked-by: Tim Gardner <tim.gardner@canonical.com>

rtg
Stefan Bader - April 27, 2010, 10:35 a.m.
Tim Gardner wrote:
> On 04/27/2010 04:27 AM, Alex Chiang wrote:
>> BugLink: http://bugs.launchpad.net/bugs/566149
>>
>> SRU justification:
>> The original patch which added the check in pci_set_power_state was a
>> minor thinko, and prevented platform resume code from running. This patch
>> removes the incorrect check, allowing platform resume code to run, thus
>> re-enabling devices such as USB ports.
>>
>> Backport of upstream commit:
>>
>> commit cc2893b6af5265baa1d68b17b136cffca9e40cfa
>> Author: Matthew Garrett<mjg@redhat.com>
>> Date:   Thu Apr 22 09:30:51 2010 -0400
>>
>>      PCI: Ensure we re-enable devices on resume
>>
>>      If the firmware puts a device back into D0 state at resume time, we'll
>>      update its state in resume_noirq and thus skip the platform resume code.
>>      Calling that code twice should be safe and we ought to avoid getting to
>>      that point anyway, so remove the check and also allow the platform pci
>>      code to be called for D0.
>>
>>      Fixes USB not being powered after resume on recent Lenovo machines.
>>
>>      Acked-by: Alex Chiang<achiang@canonical.com>
>>      Acked-by: Rafael J. Wysocki<rjw@sisk.pl>
>>      Signed-off-by: Matthew Garrett<mjg@redhat.com>
>>      Signed-off-by: Jesse Barnes<jbarnes@virtuousgeek.org>
>>
>> Signed-off-by: Alex Chiang<achiang@canonical.com>
>> ---
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index e5f3f1c..579dcf5 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -591,7 +591,7 @@ static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
>>    */
>>   int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state)
>>   {
>> -	return state>  PCI_D0 ?
>> +	return state>= PCI_D0 ?
>>   			pci_platform_power_transition(dev, state) : -EINVAL;
>>   }
>>   EXPORT_SYMBOL_GPL(__pci_complete_power_transition);
>> @@ -628,10 +628,6 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
>>   		 */
>>   		return 0;
>>
>> -	/* Check if we're already there */
>> -	if (dev->current_state == state)
>> -		return 0;
>> -
>>   	__pci_start_power_transition(dev, state);
>>
>>   	/* This device is quirked not to be put into D3, so
>>
> 
> This looks like it is also appropriate for Lucid as well as 
> stable@kernel.org, right?
> 
> Acked-by: Tim Gardner <tim.gardner@canonical.com>
> 
> rtg

If this is part of what was discussed yesterday on irc, this is going upstream
stable and through that to Lucid. Just for Karmic it needed a specific SRU as we
don't pick stable for that anymore.

Acked-by: Stefan Bader <stefan.bader@canonical.com>
Alex Chiang - April 27, 2010, 1:22 p.m.
* Stefan Bader <stefan.bader@canonical.com>:
> Tim Gardner wrote:
> > 
> > This looks like it is also appropriate for Lucid as well as
> > stable@kernel.org, right?
> 
> If this is part of what was discussed yesterday on irc, this is
> going upstream stable and through that to Lucid. Just for
> Karmic it needed a specific SRU as we don't pick stable for
> that anymore.
 
Correct, for Lucid, we'll get it via -stable.

Thanks,
/ac
Stefan Bader - April 30, 2010, 9:30 a.m.
Applied to Karmic master

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e5f3f1c..579dcf5 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -591,7 +591,7 @@  static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
  */
 int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state)
 {
-	return state > PCI_D0 ?
+	return state >= PCI_D0 ?
 			pci_platform_power_transition(dev, state) : -EINVAL;
 }
 EXPORT_SYMBOL_GPL(__pci_complete_power_transition);
@@ -628,10 +628,6 @@  int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
 		 */
 		return 0;
 
-	/* Check if we're already there */
-	if (dev->current_state == state)
-		return 0;
-
 	__pci_start_power_transition(dev, state);
 
 	/* This device is quirked not to be put into D3, so