diff mbox

[-v4,1/6] PCI,pciehp: avoid add a device already exist before suspend during resume

Message ID 1375362389-26096-2-git-send-email-wangyijing@huawei.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yijing Wang Aug. 1, 2013, 1:06 p.m. UTC
Currently, pciehp_resume() try to hot add device if the slot adapter
status return true. But if there are already some devices exist,
namely list_empty(bus->devices) return false. We should not add the device
again, because the device add action will fail. Also print some uncomfortable
messages like this:
	pciehp 0000:00:1c.1:pcie04: Device 0000:03:00.0 already exists at 0000:03:00, cannot hot-add
	pciehp 0000:00:1c.1:pcie04: Cannot add device at 0000:03:00

Tested-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Cc: Paul Bolle <pebolle@tiscali.nl>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Oliver Neukum <oneukum@suse.de>
Cc: Gu Zheng <guz.fnst@cn.fujitsu.com>
Cc: linux-pci@vger.kernel.org
---
 drivers/pci/hotplug/pciehp_core.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

Comments

Paul Bolle Aug. 2, 2013, 6:52 p.m. UTC | #1
Yijing,

On Thu, 2013-08-01 at 21:06 +0800, Yijing Wang wrote:
> Currently, pciehp_resume() try to hot add device if the slot adapter
> status return true. But if there are already some devices exist,
> namely list_empty(bus->devices) return false. We should not add the device
> again, because the device add action will fail. Also print some uncomfortable
> messages like this:
> 	pciehp 0000:00:1c.1:pcie04: Device 0000:03:00.0 already exists at 0000:03:00, cannot hot-add
> 	pciehp 0000:00:1c.1:pcie04: Cannot add device at 0000:03:00
> 
> Tested-by: Paul Bolle <pebolle@tiscali.nl>
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> Cc: Paul Bolle <pebolle@tiscali.nl>
> Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
> Cc: Oliver Neukum <oneukum@suse.de>
> Cc: Gu Zheng <guz.fnst@cn.fujitsu.com>
> Cc: linux-pci@vger.kernel.org

0) There's no 0/6 in my mailbox, so I reply to this message.

1) This series applies cleanly on top of v3.10.5-rc1 (except for some
odd problem in 6/6, which I mentioned in my reply to 6/6).

2) However, this series doesn't appear to work on v3.10.5-rc1. After the
first resume the wireless connection appears to be gone (in Gnome 3).
iwl4965 is still loaded, but I can't reconnect. That should happen
automagically.

3) And the second resume apparently hangs the system. Not sure how it
hangs exactly, but I have to manually shutdown the laptop by pressing
the power button for a few seconds.

4) I guess I'll have to respin v3.10.5-rc1 without this series to
determine if v3.10.5-rc1 or this series causes these issues. But feel
free to prod me for further tests.


Paul Bolle

--
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
Paul Bolle Aug. 2, 2013, 9:43 p.m. UTC | #2
On Fri, 2013-08-02 at 20:52 +0200, Paul Bolle wrote:
> 2) However, this series doesn't appear to work on v3.10.5-rc1. After the
> first resume the wireless connection appears to be gone (in Gnome 3).
> iwl4965 is still loaded, but I can't reconnect. That should happen
> automagically.
> 
> 3) And the second resume apparently hangs the system. Not sure how it
> hangs exactly, but I have to manually shutdown the laptop by pressing
> the power button for a few seconds.
> 
> 4) I guess I'll have to respin v3.10.5-rc1 without this series to
> determine if v3.10.5-rc1 or this series causes these issues. But feel
> free to prod me for further tests.

Well, v3.10.5-rc1 without this series resumes fine. (But, of course, I
now again see the pciehp errors at resume.) Is this series actually
expected to work on v3.10.y?


Paul Bolle

--
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
Yijing Wang Aug. 5, 2013, 3:12 a.m. UTC | #3
> 
> 0) There's no 0/6 in my mailbox, so I reply to this message.
>

Sorry, I forgot adding your cc into patch 0.

> 1) This series applies cleanly on top of v3.10.5-rc1 (except for some
> odd problem in 6/6, which I mentioned in my reply to 6/6).
> 
> 2) However, this series doesn't appear to work on v3.10.5-rc1. After the
> first resume the wireless connection appears to be gone (in Gnome 3).
> iwl4965 is still loaded, but I can't reconnect. That should happen
> automagically.

I found some mistakes in my patch 6/6, I'm very sorry about that.
Will be more careful next time, I will refresh this patch, can your help
to test it again? I will update this patch and resend it soon.

> 
> 3) And the second resume apparently hangs the system. Not sure how it
> hangs exactly, but I have to manually shutdown the laptop by pressing
> the power button for a few seconds.
> 
> 4) I guess I'll have to respin v3.10.5-rc1 without this series to
> determine if v3.10.5-rc1 or this series causes these issues. But feel
> free to prod me for further tests.

Thanks!
Yijing.
diff mbox

Patch

diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 7d72c5e..7fe9dbd 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -300,6 +300,7 @@  static int pciehp_resume (struct pcie_device *dev)
 {
 	struct controller *ctrl;
 	struct slot *slot;
+	struct pci_bus *pbus = dev->port->subordinate;
 	u8 status;
 
 	ctrl = get_service_data(dev);
@@ -311,10 +312,13 @@  static int pciehp_resume (struct pcie_device *dev)
 
 	/* Check if slot is occupied */
 	pciehp_get_adapter_status(slot, &status);
-	if (status)
-		pciehp_enable_slot(slot);
-	else
+	if (status) {
+		if (list_empty(&pbus->devices))
+			pciehp_enable_slot(slot);
+	} else if (!list_empty(&pbus->devices)) {
 		pciehp_disable_slot(slot);
+	}
+
 	return 0;
 }
 #endif /* PM */