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@xxxxxxxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html