[PATCH] PCI: pciehp: Fix re-enabling the slot marked for safe removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



During the safe removal procedure, a Data Link Layer State Changed event
may occur after pciehp_power_off_slot(), and it is handled when the slot is
already set to OFF_STATE. This results in re-enabling the device and makes
it impossible to actually safely remove it.

Add a check for a Presence Detect Changed bit to filter out this interrupt.

It is still possible to re-enable the device if it remains in the slot
after pressing the Attention Button by pressing it again.

Signed-off-by: Sergey Miroshnichenko <s.miroshnichenko@xxxxxxxxx>
Cc: Lukas Wunner <lukas@xxxxxxxxx>
---
 drivers/pci/hotplug/pciehp_ctrl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 3f3df4c29f6e..941f77b71df4 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -251,6 +251,14 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events)
 		return;
 	}
 
+	/* Handle the DLLSC from the slot which just has been turned off */
+	if ((events & PCI_EXP_SLTSTA_DLLSC) &&
+	    !(events & PCI_EXP_SLTSTA_PDC) &&
+	    present && !link_active) {
+		mutex_unlock(&ctrl->state_lock);
+		return;
+	}
+
 	switch (ctrl->state) {
 	case BLINKINGON_STATE:
 		cancel_delayed_work(&ctrl->button_work);
-- 
2.20.1




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux