linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: pciehp: Fix the problem that the present bit is not cleared though slot is empty
@ 2014-02-03  7:07 Taku Izumi
  2014-02-12  0:49 ` Bjorn Helgaas
  0 siblings, 1 reply; 16+ messages in thread
From: Taku Izumi @ 2014-02-03  7:07 UTC (permalink / raw)
  To: linux-pci, bhelgaas, yinghai


I found the problem that the present bit does not be cleared
though the slot is empty.

 Step to reproduce:

  # cd /sys/bus/pci/slots/66
  # cat adapter
  0
  --- (insert PCIe card on slot#66) ---
  # cat adapter
  1
  # echo 1 > power
  # echo 0 > power
  --- (eject PCIe card on slot#66) ---
  # cat adapter
  1
    ==> should be 0.

According to git-bisect this is caused by:
    2debd9289997fc5d1c0043b41201a8b40d5e11d0
       PCI: pciehp: Disable/enable link during slot power off/on
    is the first bad commit

By reverting the above patch, this bug can be solved.
And I also found this can be fixed by changing the timing of link-disable
during power off the slot.
So, this patch changes the timing of link-disable during power off.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
---
 drivers/pci/hotplug/pciehp_hpc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 14acfcc..163f0b4 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -508,7 +508,12 @@ void pciehp_power_off_slot(struct slot * slot)
 {
 	struct controller *ctrl = slot->ctrl;
 
-	/* Disable the link at first */
+	pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_OFF, PCI_EXP_SLTCTL_PCC);
+	ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
+		 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
+		 PCI_EXP_SLTCTL_PWR_OFF);
+
+	/* Disable the link */
 	pciehp_link_disable(ctrl);
 	/* wait the link is down */
 	if (ctrl->link_active_reporting)
@@ -516,10 +521,6 @@ void pciehp_power_off_slot(struct slot * slot)
 	else
 		msleep(1000);
 
-	pcie_write_cmd(ctrl, PCI_EXP_SLTCTL_PWR_OFF, PCI_EXP_SLTCTL_PCC);
-	ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", __func__,
-		 pci_pcie_cap(ctrl->pcie->port) + PCI_EXP_SLTCTL,
-		 PCI_EXP_SLTCTL_PWR_OFF);
 }
 
 static irqreturn_t pcie_isr(int irq, void *dev_id)
-- 
1.8.3.1


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

end of thread, other threads:[~2014-02-25  3:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-03  7:07 [PATCH] PCI: pciehp: Fix the problem that the present bit is not cleared though slot is empty Taku Izumi
2014-02-12  0:49 ` Bjorn Helgaas
2014-02-12  8:00   ` Izumi, Taku
2014-02-12 16:56     ` Bjorn Helgaas
2014-02-12 18:11       ` Rajat Jain
2014-02-13  8:00         ` Izumi, Taku
2014-02-13 16:03           ` Rajat Jain
2014-02-13 16:37             ` Takashi Iwai
2014-02-13 17:56               ` Rajat Jain
2014-02-14  7:21             ` Izumi, Taku
2014-02-14  7:26               ` Rajat Jain
2014-02-14 17:31               ` Bjorn Helgaas
2014-02-14 19:39                 ` Rajat Jain
2014-02-18 23:02                   ` Bjorn Helgaas
2014-02-19  2:54                     ` Rajat Jain
2014-02-25  3:02                   ` Rajat Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).