Re: Machine crashes right *after* ~successful resume

From: Yinghai Lu
Date: Fri Oct 31 2014 - 19:19:00 EST


On Fri, Oct 31, 2014 at 2:22 PM, Yinghai Lu <yinghai@xxxxxxxxxx> wrote:
> On Fri, Oct 31, 2014 at 2:13 PM, Wilmer van der Gaast <wilmer@xxxxxxxxx> wrote:
>> On 31-10-14 16:11, Yinghai Lu wrote:
>>>
>>>
>>> Good. Please check if attached one on top of 3.17 only would work too.
>>>
>> No luck, sadly. :-( Unsuccessful third resume.

Please try attached two patches separately on top of 3.17.
---
drivers/pci/pci.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

Index: linux-2.6/drivers/pci/pci.c
===================================================================
--- linux-2.6.orig/drivers/pci/pci.c
+++ linux-2.6/drivers/pci/pci.c
@@ -1265,6 +1265,24 @@ static void pci_enable_bridge(struct pci
pci_set_master(dev);
}

+static void pci_enable_ite(struct pci_dev *dev)
+{
+ /*
+ * FW enable the bridge already, so call pci_enable_bridge()
+ * to keep enable_cnt consistent, then later we can go through
+ * pci_pm_resume/pci_pm_reenable_device to enable it again.
+ * --- for pci bridge without driver case.
+ */
+ if (!pci_is_enabled(dev)) {
+ u16 cmd;
+
+ pci_read_config_word(dev, PCI_COMMAND, &cmd);
+ if ((cmd & (PCI_COMMAND_IO || PCI_COMMAND_MEMORY)) &&
+ pci_enable_bridge(dev);
+ }
+}
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ITE, 0x8892, pci_enable_ite);
+
static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
{
struct pci_dev *bridge;
---
drivers/pci/pci-driver.c | 9 +++++++++
1 file changed, 9 insertions(+)

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
@@ -519,8 +519,17 @@ static void pci_pm_set_unknown_state(str
*/
static int pci_pm_reenable_device(struct pci_dev *pci_dev)
{
+ u16 cmd;
int retval;

+ /* update enable_cnt according to cmd register */
+ pci_read_config_word(pci_dev, PCI_COMMAND, &cmd);
+ if (!pci_dev->is_busmaster && (cmd & PCI_COMMAND_MASTER))
+ pci_dev->is_busmaster = true;
+ if (!pci_is_enabled(pci_dev) &&
+ (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)))
+ atomic_inc(&pci_dev->enable_cnt);
+
/* if the device was enabled before suspend, reenable */
retval = pci_reenable_device(pci_dev);
/*