diff mbox

[v2] pci: check saved state before restore

Message ID 20090808084619.6cb6e63d@dxy.sh.intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Du, Alek Aug. 8, 2009, 12:46 a.m. UTC
Here is the updated one...



From 972c7f371604f837a70cc5e9948749f423cf64eb Mon Sep 17 00:00:00 2001
From: Alek Du <alek.du@intel.com>
Date: Wed, 5 Aug 2009 15:25:26 +0800
Subject: [PATCH] pci: check saved state before restore

Without the check, the config space may be filled with zeros. Though
the driver should try to avoid call restoring before saving, but the
pci layer also should check this.

Also removed the existing check in pci_restore_standard_config.

Signed-off-by: Alek Du <alek.du@intel.com>
---
 drivers/pci/pci-driver.c |    2 +-
 drivers/pci/pci.c        |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)

Comments

Rafael Wysocki Aug. 8, 2009, 12:55 p.m. UTC | #1
On Saturday 08 August 2009, Alek Du wrote:
> Here is the updated one...
> 
> 
> 
> From 972c7f371604f837a70cc5e9948749f423cf64eb Mon Sep 17 00:00:00 2001
> From: Alek Du <alek.du@intel.com>
> Date: Wed, 5 Aug 2009 15:25:26 +0800
> Subject: [PATCH] pci: check saved state before restore
> 
> Without the check, the config space may be filled with zeros. Though
> the driver should try to avoid call restoring before saving, but the
> pci layer also should check this.
> 
> Also removed the existing check in pci_restore_standard_config.
> 
> Signed-off-by: Alek Du <alek.du@intel.com>

Acked-by: Rafael J. Wysocki <rjw@sisk.pl>

> ---
>  drivers/pci/pci-driver.c |    2 +-
>  drivers/pci/pci.c        |    2 ++
>  2 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index d76c4c8..f99bc7f 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -508,7 +508,7 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev)
>  			return error;
>  	}
>  
> -	return pci_dev->state_saved ? pci_restore_state(pci_dev) : 0;
> +	return pci_restore_state(pci_dev);
>  }
>  
>  static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index dbd0f94..7b70312 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -846,6 +846,8 @@ pci_restore_state(struct pci_dev *dev)
>  	int i;
>  	u32 val;
>  
> +	if (!dev->state_saved)
> +		return 0;
>  	/* PCI Express register must be restored first */
>  	pci_restore_pcie_state(dev);
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jesse Barnes Aug. 10, 2009, 4:36 p.m. UTC | #2
On Sat, 8 Aug 2009 08:46:19 +0800
Alek Du <alek.du@intel.com> wrote:

> Here is the updated one...
> 
> 
> 
> From 972c7f371604f837a70cc5e9948749f423cf64eb Mon Sep 17 00:00:00 2001
> From: Alek Du <alek.du@intel.com>
> Date: Wed, 5 Aug 2009 15:25:26 +0800
> Subject: [PATCH] pci: check saved state before restore
> 
> Without the check, the config space may be filled with zeros. Though
> the driver should try to avoid call restoring before saving, but the
> pci layer also should check this.
> 
> Also removed the existing check in pci_restore_standard_config.
> 
> Signed-off-by: Alek Du <alek.du@intel.com>
> ---
>  drivers/pci/pci-driver.c |    2 +-
>  drivers/pci/pci.c        |    2 ++
>  2 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index d76c4c8..f99bc7f 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -508,7 +508,7 @@ static int pci_restore_standard_config(struct
> pci_dev *pci_dev) return error;
>  	}
>  
> -	return pci_dev->state_saved ? pci_restore_state(pci_dev) : 0;
> +	return pci_restore_state(pci_dev);
>  }
>  
>  static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index dbd0f94..7b70312 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -846,6 +846,8 @@ pci_restore_state(struct pci_dev *dev)
>  	int i;
>  	u32 val;
>  
> +	if (!dev->state_saved)
> +		return 0;
>  	/* PCI Express register must be restored first */
>  	pci_restore_pcie_state(dev);
>  

Applied to my linux-next tree.  If you're seeing this bug though we
should probably get it into 2.6.31 and possibly the stable queue.  Are
you?
Du, Alek Aug. 10, 2009, 4:46 p.m. UTC | #3
Hi Jesse,

On Tue, 11 Aug 2009 00:36:26 +0800
"Barnes, Jesse" <jesse.barnes@intel.com> wrote:

> >  
> 
> Applied to my linux-next tree.  If you're seeing this bug though we
> should probably get it into 2.6.31 and possibly the stable queue.  Are
> you?
> 

I guess putting in linux-next is enough, I do not see this bug in current tree.
I found this because a bad driver in our internal tree try to restore PCI state without saving it.


Thanks,
Alek
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index d76c4c8..f99bc7f 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -508,7 +508,7 @@  static int pci_restore_standard_config(struct pci_dev *pci_dev)
 			return error;
 	}
 
-	return pci_dev->state_saved ? pci_restore_state(pci_dev) : 0;
+	return pci_restore_state(pci_dev);
 }
 
 static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index dbd0f94..7b70312 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -846,6 +846,8 @@  pci_restore_state(struct pci_dev *dev)
 	int i;
 	u32 val;
 
+	if (!dev->state_saved)
+		return 0;
 	/* PCI Express register must be restored first */
 	pci_restore_pcie_state(dev);