Skip to contentSkip to conversation

check for pci bar restore completion and retry

PATCH RESEND Applied Allen Kay 2 participants 3 messages Jan 26, 2012 – Feb 7, 2012 PCI

lore
Share & tools
lore

Allen Kay

author
#0 lore raw

PATCH RESEND 1/1 check for pci bar restore completion and retry

On some OEM systems, pci_restore_state() is called while FLR has not yet completed. As a result, PCI BAR register restore is not successful. This fix reads back the restored value and compares it with saved value and re-tries 10 times before giving up.

---
 drivers/pci/pci.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/pci/pci.c +6 -1
index af295bb..0549050 100644
@@ -959,6 +959,7 @@ void pci_restore_state(struct pci_dev *dev)
 {
 	int i;
 	u32 val;
+	int tries;
 
 	if (!dev->state_saved)
 		return;
@@ -973,12 +974,16 @@ void pci_restore_state(struct pci_dev *dev)
 	 */
 	for (i = 15; i >= 0; i--) {
 		pci_read_config_dword(dev, i * 4, &val);
-		if (val != dev->saved_config_space[i]) {
+		tries = 10;		
+		while (tries && val != dev->saved_config_space[i]) {
 			dev_dbg(&dev->dev, "restoring config "
 				"space at offset %#x (was %#x, writing %#x)\n",
 				i, val, (int)dev->saved_config_space[i]);
 			pci_write_config_dword(dev,i * 4,
 				dev->saved_config_space[i]);
+			pci_read_config_dword(dev, i * 4, &val);
+			mdelay(10);
+			tries--;
 		}
 	}
 	pci_restore_pcix_state(dev);
Signature · 1 line
1.6.0.6
Applied
#1 lore raw
Quoted 4 lines · Allen M

On some OEM systems, pci_restore_state() is called while FLR has not yet completed. As a result, PCI BAR register restore is not successful. This fix reads back the restored value and compares it with saved value and re-tries 10 times before giving up.

Applied, but I don't think I got an answer as to why we don't do this delay/check when we perform the FLR in the first place?

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#2 lore raw

Sorry Jesse, I did not see this until now. There is some problem with my email I was not aware of - many emails did not go into my inbox.

Given there are many reset methods, checking for actual BAR restore is more reliable and less testing for a various reset methods. We can potentially add checks for completion in pcie_flr() since that's easy to do.

Eric/Jean, do you have other comments?

Allen

-----Original Message-----
From: Jesse Barnes [mailto:[email protected]]
Sent: Friday, January 27, 2012 11:44 AM
To: Kay, Allen M
Cc: [email protected]; Barnes, Jesse; Wilcox, Matthew R; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/1][resend] check for pci bar restore completion and retry

Quoted 4 lines · Allen M

On some OEM systems, pci_restore_state() is called while FLR has not yet completed. As a result, PCI BAR register restore is not successful. This fix reads back the restored value and compares it with saved value and re-tries 10 times before giving up.

Applied, but I don't think I got an answer as to why we don't do this delay/check when we perform the FLR in the first place?

--
Jesse Barnes, Intel Open Source Technology Center