Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1739931

[PATCH 6/7] PCI: pciehp: Do not clear Presence Detect Changed during initialization

From Mika Westerberg <mika.westerberg@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH 6/7] PCI: pciehp: Do not clear Presence Detect Changed during initialization
Date 2017-09-26 16:20 +0200
Message-ID <utYSm-5Rt-29@gated-at.bofh.it> (permalink)
References <utYSl-5Rt-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


It is possible that the hotplug event has already happened before the
driver is attached to a PCIe hotplug downstream port. If we just clear
the status we never get the hotplug interrupt and thus the event will be
missed.

To make sure that does not happen, we leave Presence Detect Changed bit
untouched during initialization. Then once the event is unmasked we get
an interrupt and handle the hotplug event properly.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/pci/hotplug/pciehp_hpc.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 83c93f9da65a..bc1622aa7a05 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -862,11 +862,16 @@ struct controller *pcie_init(struct pcie_device *dev)
 	if (link_cap & PCI_EXP_LNKCAP_DLLLARC)
 		ctrl->link_active_reporting = 1;
 
-	/* Clear all remaining event bits in Slot Status register */
+	/*
+	 * Clear all remaining event bits in Slot Status register except
+	 * Presence Detect Changed. We want to make sure possible
+	 * hotplug event is triggered when the interrupt is unmasked so
+	 * that we don't lose that event.
+	 */
 	pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
 		PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD |
-		PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC |
-		PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC);
+		PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_CC |
+		PCI_EXP_SLTSTA_DLLSC);
 
 	ctrl_info(ctrl, "Slot #%d AttnBtn%c PwrCtrl%c MRL%c AttnInd%c PwrInd%c HotPlug%c Surprise%c Interlock%c NoCompl%c LLActRep%c\n",
 		(slot_cap & PCI_EXP_SLTCAP_PSN) >> 19,
-- 
2.14.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/7] PCI: Improvements for native PCIe hotplug Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200
  [PATCH 7/7] PCI: pciehp: Check that the device is really present before touching it Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200
  [PATCH 5/7] PCI: pciehp: Fix race condition handling surprise link down Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200
  [PATCH 6/7] PCI: pciehp: Do not clear Presence Detect Changed during initialization Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200
  [PATCH 4/7] PCI: Distribute available resources to hotplug capable PCIe downstream ports Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200
  [PATCH 1/7] PCI: Do not allocate more buses than available in parent Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200

csiph-web