All of lore.kernel.org
 help / color / mirror / Atom feed
* [Resend][PATCH 1/2] PCI: Clear saved_state after the state has been restored
@ 2009-09-09 21:49 Rafael J. Wysocki
  2009-09-09 21:51 ` [Resend][PATCH 2/2] PCI PM: Return error codes from pci_pm_resume() Rafael J. Wysocki
  2009-09-09 21:51 ` Rafael J. Wysocki
  0 siblings, 2 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2009-09-09 21:49 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: Linux PCI, LKML, pm list

From: Rafael J. Wysocki <rjw@sisk.pl>

Some PCI devices fail if their standard configuration registers are
restored twice in a row.  Prevent this from happening by making
pci_restore_state() clear the saved_state flag of the device right
after the device's standard configuration registers have been
populated with the previously saved values.

Simplify PCI PM callbacks by removing the direct clearing of
state_saved from them, as it shouldn't be necessary any more (except
in pci_pm_thaw(), where it has to be cleared, so that the values saved
during the "freeze" phase of hibernation are not used later by mistake).

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/pci/pci-driver.c |   11 ++---------
 drivers/pci/pci.c        |    3 +++
 drivers/pci/probe.c      |    3 +++
 3 files changed, 8 insertions(+), 9 deletions(-)

Index: linux-2.6/drivers/pci/pci-driver.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-driver.c
+++ linux-2.6/drivers/pci/pci-driver.c
@@ -417,8 +417,6 @@ static int pci_legacy_suspend(struct dev
 	struct pci_dev * pci_dev = to_pci_dev(dev);
 	struct pci_driver * drv = pci_dev->driver;
 
-	pci_dev->state_saved = false;
-
 	if (drv && drv->suspend) {
 		pci_power_t prev = pci_dev->current_state;
 		int error;
@@ -514,7 +512,6 @@ static int pci_restore_standard_config(s
 static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
 {
 	pci_restore_standard_config(pci_dev);
-	pci_dev->state_saved = false;
 	pci_fixup_device(pci_fixup_resume_early, pci_dev);
 }
 
@@ -580,8 +577,6 @@ static int pci_pm_suspend(struct device 
 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_suspend(dev, PMSG_SUSPEND);
 
-	pci_dev->state_saved = false;
-
 	if (!pm) {
 		pci_pm_default_suspend(pci_dev);
 		goto Fixup;
@@ -716,8 +711,6 @@ static int pci_pm_freeze(struct device *
 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_suspend(dev, PMSG_FREEZE);
 
-	pci_dev->state_saved = false;
-
 	if (!pm) {
 		pci_pm_default_suspend(pci_dev);
 		return 0;
@@ -793,6 +786,8 @@ static int pci_pm_thaw(struct device *de
 		pci_pm_reenable_device(pci_dev);
 	}
 
+	pci_dev->state_saved = false;
+
 	return error;
 }
 
@@ -804,8 +799,6 @@ static int pci_pm_poweroff(struct device
 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_suspend(dev, PMSG_HIBERNATE);
 
-	pci_dev->state_saved = false;
-
 	if (!pm) {
 		pci_pm_default_suspend(pci_dev);
 		goto Fixup;
Index: linux-2.6/drivers/pci/pci.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci.c
+++ linux-2.6/drivers/pci/pci.c
@@ -852,6 +852,7 @@ pci_restore_state(struct pci_dev *dev)
 
 	if (!dev->state_saved)
 		return 0;
+
 	/* PCI Express register must be restored first */
 	pci_restore_pcie_state(dev);
 
@@ -873,6 +874,8 @@ pci_restore_state(struct pci_dev *dev)
 	pci_restore_msi_state(dev);
 	pci_restore_iov_state(dev);
 
+	dev->state_saved = false;
+
 	return 0;
 }
 
Index: linux-2.6/drivers/pci/probe.c
===================================================================
--- linux-2.6.orig/drivers/pci/probe.c
+++ linux-2.6/drivers/pci/probe.c
@@ -1009,6 +1009,9 @@ void pci_device_add(struct pci_dev *dev,
 	/* Fix up broken headers */
 	pci_fixup_device(pci_fixup_header, dev);
 
+	/* Clear the state_saved flag. */
+	dev->state_saved = false;
+
 	/* Initialize various capabilities */
 	pci_init_capabilities(dev);
 

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

* [Resend][PATCH 2/2] PCI PM: Return error codes from pci_pm_resume()
  2009-09-09 21:49 [Resend][PATCH 1/2] PCI: Clear saved_state after the state has been restored Rafael J. Wysocki
  2009-09-09 21:51 ` [Resend][PATCH 2/2] PCI PM: Return error codes from pci_pm_resume() Rafael J. Wysocki
@ 2009-09-09 21:51 ` Rafael J. Wysocki
  2009-09-14 20:42   ` Jesse Barnes
  2009-09-14 20:42   ` Jesse Barnes
  1 sibling, 2 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2009-09-09 21:51 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: Linux PCI, LKML, pm list

From: Rafael J. Wysocki <rjw@sisk.pl>

Currently pci_pm_resume() always returns 0, which makes the error
variable defined in there a bit pointless.  Make pci_pm_resume()
return error codes obtained from drivers' callbacks.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/pci/pci-driver.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/drivers/pci/pci-driver.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-driver.c
+++ linux-2.6/drivers/pci/pci-driver.c
@@ -689,7 +689,7 @@ static int pci_pm_resume(struct device *
 		pci_pm_reenable_device(pci_dev);
 	}
 
-	return 0;
+	return error;
 }
 
 #else /* !CONFIG_SUSPEND */

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

* [Resend][PATCH 2/2] PCI PM: Return error codes from pci_pm_resume()
  2009-09-09 21:49 [Resend][PATCH 1/2] PCI: Clear saved_state after the state has been restored Rafael J. Wysocki
@ 2009-09-09 21:51 ` Rafael J. Wysocki
  2009-09-09 21:51 ` Rafael J. Wysocki
  1 sibling, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2009-09-09 21:51 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: Linux PCI, pm list, LKML

From: Rafael J. Wysocki <rjw@sisk.pl>

Currently pci_pm_resume() always returns 0, which makes the error
variable defined in there a bit pointless.  Make pci_pm_resume()
return error codes obtained from drivers' callbacks.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/pci/pci-driver.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/drivers/pci/pci-driver.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-driver.c
+++ linux-2.6/drivers/pci/pci-driver.c
@@ -689,7 +689,7 @@ static int pci_pm_resume(struct device *
 		pci_pm_reenable_device(pci_dev);
 	}
 
-	return 0;
+	return error;
 }
 
 #else /* !CONFIG_SUSPEND */

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

* Re: [Resend][PATCH 2/2] PCI PM: Return error codes from pci_pm_resume()
  2009-09-09 21:51 ` Rafael J. Wysocki
  2009-09-14 20:42   ` Jesse Barnes
@ 2009-09-14 20:42   ` Jesse Barnes
  1 sibling, 0 replies; 6+ messages in thread
From: Jesse Barnes @ 2009-09-14 20:42 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux PCI, LKML, pm list

On Wed, 9 Sep 2009 23:51:27 +0200
"Rafael J. Wysocki" <rjw@sisk.pl> wrote:

> From: Rafael J. Wysocki <rjw@sisk.pl>
> 
> Currently pci_pm_resume() always returns 0, which makes the error
> variable defined in there a bit pointless.  Make pci_pm_resume()
> return error codes obtained from drivers' callbacks.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---
>  drivers/pci/pci-driver.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: linux-2.6/drivers/pci/pci-driver.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/pci-driver.c
> +++ linux-2.6/drivers/pci/pci-driver.c
> @@ -689,7 +689,7 @@ static int pci_pm_resume(struct device *
>  		pci_pm_reenable_device(pci_dev);
>  	}
>  
> -	return 0;
> +	return error;
>  }
>  
>  #else /* !CONFIG_SUSPEND */
> 

Applied these two, thanks.

-- 
Jesse Barnes, Intel Open Source Technology Center

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

* Re: [Resend][PATCH 2/2] PCI PM: Return error codes from pci_pm_resume()
  2009-09-09 21:51 ` Rafael J. Wysocki
@ 2009-09-14 20:42   ` Jesse Barnes
  2009-09-14 20:42   ` Jesse Barnes
  1 sibling, 0 replies; 6+ messages in thread
From: Jesse Barnes @ 2009-09-14 20:42 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux PCI, pm list, LKML

On Wed, 9 Sep 2009 23:51:27 +0200
"Rafael J. Wysocki" <rjw@sisk.pl> wrote:

> From: Rafael J. Wysocki <rjw@sisk.pl>
> 
> Currently pci_pm_resume() always returns 0, which makes the error
> variable defined in there a bit pointless.  Make pci_pm_resume()
> return error codes obtained from drivers' callbacks.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---
>  drivers/pci/pci-driver.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: linux-2.6/drivers/pci/pci-driver.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/pci-driver.c
> +++ linux-2.6/drivers/pci/pci-driver.c
> @@ -689,7 +689,7 @@ static int pci_pm_resume(struct device *
>  		pci_pm_reenable_device(pci_dev);
>  	}
>  
> -	return 0;
> +	return error;
>  }
>  
>  #else /* !CONFIG_SUSPEND */
> 

Applied these two, thanks.

-- 
Jesse Barnes, Intel Open Source Technology Center

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

* [Resend][PATCH 1/2] PCI: Clear saved_state after the state has been restored
@ 2009-09-09 21:49 Rafael J. Wysocki
  0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2009-09-09 21:49 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: Linux PCI, pm list, LKML

From: Rafael J. Wysocki <rjw@sisk.pl>

Some PCI devices fail if their standard configuration registers are
restored twice in a row.  Prevent this from happening by making
pci_restore_state() clear the saved_state flag of the device right
after the device's standard configuration registers have been
populated with the previously saved values.

Simplify PCI PM callbacks by removing the direct clearing of
state_saved from them, as it shouldn't be necessary any more (except
in pci_pm_thaw(), where it has to be cleared, so that the values saved
during the "freeze" phase of hibernation are not used later by mistake).

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/pci/pci-driver.c |   11 ++---------
 drivers/pci/pci.c        |    3 +++
 drivers/pci/probe.c      |    3 +++
 3 files changed, 8 insertions(+), 9 deletions(-)

Index: linux-2.6/drivers/pci/pci-driver.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci-driver.c
+++ linux-2.6/drivers/pci/pci-driver.c
@@ -417,8 +417,6 @@ static int pci_legacy_suspend(struct dev
 	struct pci_dev * pci_dev = to_pci_dev(dev);
 	struct pci_driver * drv = pci_dev->driver;
 
-	pci_dev->state_saved = false;
-
 	if (drv && drv->suspend) {
 		pci_power_t prev = pci_dev->current_state;
 		int error;
@@ -514,7 +512,6 @@ static int pci_restore_standard_config(s
 static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
 {
 	pci_restore_standard_config(pci_dev);
-	pci_dev->state_saved = false;
 	pci_fixup_device(pci_fixup_resume_early, pci_dev);
 }
 
@@ -580,8 +577,6 @@ static int pci_pm_suspend(struct device 
 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_suspend(dev, PMSG_SUSPEND);
 
-	pci_dev->state_saved = false;
-
 	if (!pm) {
 		pci_pm_default_suspend(pci_dev);
 		goto Fixup;
@@ -716,8 +711,6 @@ static int pci_pm_freeze(struct device *
 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_suspend(dev, PMSG_FREEZE);
 
-	pci_dev->state_saved = false;
-
 	if (!pm) {
 		pci_pm_default_suspend(pci_dev);
 		return 0;
@@ -793,6 +786,8 @@ static int pci_pm_thaw(struct device *de
 		pci_pm_reenable_device(pci_dev);
 	}
 
+	pci_dev->state_saved = false;
+
 	return error;
 }
 
@@ -804,8 +799,6 @@ static int pci_pm_poweroff(struct device
 	if (pci_has_legacy_pm_support(pci_dev))
 		return pci_legacy_suspend(dev, PMSG_HIBERNATE);
 
-	pci_dev->state_saved = false;
-
 	if (!pm) {
 		pci_pm_default_suspend(pci_dev);
 		goto Fixup;
Index: linux-2.6/drivers/pci/pci.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci.c
+++ linux-2.6/drivers/pci/pci.c
@@ -852,6 +852,7 @@ pci_restore_state(struct pci_dev *dev)
 
 	if (!dev->state_saved)
 		return 0;
+
 	/* PCI Express register must be restored first */
 	pci_restore_pcie_state(dev);
 
@@ -873,6 +874,8 @@ pci_restore_state(struct pci_dev *dev)
 	pci_restore_msi_state(dev);
 	pci_restore_iov_state(dev);
 
+	dev->state_saved = false;
+
 	return 0;
 }
 
Index: linux-2.6/drivers/pci/probe.c
===================================================================
--- linux-2.6.orig/drivers/pci/probe.c
+++ linux-2.6/drivers/pci/probe.c
@@ -1009,6 +1009,9 @@ void pci_device_add(struct pci_dev *dev,
 	/* Fix up broken headers */
 	pci_fixup_device(pci_fixup_header, dev);
 
+	/* Clear the state_saved flag. */
+	dev->state_saved = false;
+
 	/* Initialize various capabilities */
 	pci_init_capabilities(dev);
 

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

end of thread, other threads:[~2009-09-14 20:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-09 21:49 [Resend][PATCH 1/2] PCI: Clear saved_state after the state has been restored Rafael J. Wysocki
2009-09-09 21:51 ` [Resend][PATCH 2/2] PCI PM: Return error codes from pci_pm_resume() Rafael J. Wysocki
2009-09-09 21:51 ` Rafael J. Wysocki
2009-09-14 20:42   ` Jesse Barnes
2009-09-14 20:42   ` Jesse Barnes
2009-09-09 21:49 [Resend][PATCH 1/2] PCI: Clear saved_state after the state has been restored Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.