Skip to contentSkip to conversation

PCI hotplug feature

PATCH Superseded Oza Pawandeep 2 participants 6 messages Aug 15, 2017 – Aug 17, 2017

Subsystems (4)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover PCI hotplug feature

These patches bring in PCI hotplug support for iproc family chipsets.

It includes DT binding documentation update and, implementation in iproc pcie RC driver.

These patch set is made on top of following patches. [PATCH v6 2/2] PCI: iproc: add device shutdown for PCI RC [PATCH v6 1/2] PCI: iproc: Retry request when CRS returned from EP

Changes since v2:
Addressed Rob Herring's comments.
Made generic PCI hotplug properties 'slot-pluggable' and 'prsnt-gpios'

Oza Pawandeep (3):
PCI: iproc: Implement PCI hotplug support Documentation/devicetree: Add PCIe hotplug property
PCI: iproc: Implement optional property prsnt-gpios

 .../devicetree/bindings/pci/brcm,iproc-pcie.txt    |  14 +++
 Documentation/devicetree/bindings/pci/pci.txt      |  15 +++
 drivers/pci/host/pcie-iproc-platform.c             |   3 +
 drivers/pci/host/pcie-iproc.c                      | 130 ++++++++++++++++++++-
 drivers/pci/host/pcie-iproc.h                      |   7 ++
 5 files changed, 163 insertions(+), 6 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/3 PCI: iproc: Implement PCI hotplug support

This patch implements PCI hotplug support for iproc family chipsets.

iproc based SOC (e.g. Stingray) does not have hotplug controller integrated.
Hence, standard PCI hotplug framework hooks can-not be used. e.g. controlled power up/down of slot.

The mechanism, for e.g. Stingray has adopted for PCI hotplug is as follows:
PCI present lines are input to GPIOs depending on the type of connector (x2, x4, x8).

The implementation essentially takes care of following:

Quoted 4 lines

Initializing hotplug irq thread.
Detecting the endpoint device based on link state. Handling PERST and detecting the plugged devices. Ordered Hot plug-out, where User is expected

to write 1 to /sys/bus/pci/devices/<pci_dev>/remove

Quoted 2 lines

Handling spurious interrupt
Handling multiple interrupts and makes sure that card is

enumerated only once.

drivers/pci/host/pcie-iproc-platform.c +3 -0
index 9512960..e1eb141 100644
@@ -89,6 +89,9 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)
 		pcie->need_ob_cfg = true;
 	}
 
+	if (of_property_read_bool(np, "slot-pluggable"))
+		pcie->enable_hotplug = true;
+
 	/* PHY use is optional */
 	pcie->phy = devm_phy_get(dev, "pcie-phy");
 	if (IS_ERR(pcie->phy)) {
drivers/pci/host/pcie-iproc.c +124 -6

176 lines not on this page · raw message

drivers/pci/host/pcie-iproc.h +7 -0
index a6b55ce..e5d0cd4 100644
@@ -77,6 +77,10 @@ struct iproc_pcie_ib {
  * @ib: inbound mapping related parameters
  * @ib_map: outbound mapping region related parameters
  *
+ * @enable_hotplug: indicates PCI hotplug feature is enabled
+ * @ep_is_present: when PCIe hotplug is enabled, this flag is used to
+ * indicate whether or not the endpoint device is present
+ *
  * @need_msi_steer: indicates additional configuration of the iProc PCIe
  * controller is required to steer MSI writes to external interrupt controller
  * @msi: MSI data
@@ -104,6 +108,9 @@ struct iproc_pcie {
 	struct iproc_pcie_ib ib;
 	const struct iproc_pcie_ib_map *ib_map;
 
+	bool enable_hotplug;
+	bool ep_is_present;
+
 	bool need_msi_steer;
 	struct iproc_msi *msi;
 };
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/3 Documentation/devicetree: Add PCIe hotplug property

In reply to Oza Pawandeep

Host drivers have the requirement of implementing PCI hotplug based on the how their SOC supports PCI hotplug.

Couple of properties have been added. the one to enable the hotplug feature itself, and the other caters to the PCI hotplug implementation with the use of gpios.

Documentation/devicetree/bindings/pci/pci.txt +15 -0
index 50f9e2c..0bf25a1 100644
@@ -24,3 +24,18 @@ driver implementation may support the following properties:
    unsupported link speed, for instance, trying to do training for
    unsupported link speed, etc.  Must be '4' for gen4, '3' for gen3, '2'
    for gen2, and '1' for gen1. Any other values are invalid.
+
+- slot-pluggable:
+   PCI hotplug feature is supported.
+   PCI hotplug implementation is SOC/Board specific, and also it depends on
+   how add-in card is designed (e.g. how many present pins are implemented).
+   If the slot-pluggable property is present, the following propertey could
+   become effective.
+   - prsnt-gpios:
+      Array of gpios, could be present if hotplug is supported.
+      This property defines gpio based hotplug implementation.
+      Example:
+      If x8 card is connected, then it might be possible that all the
+      3 present pins could go low, or at least one pin goes low.
+      If x4 card is connected, then it might be possible that 2 present
+      pins go low, or at least one pin goes low.
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 3/3 PCI: iproc: Implement optional property prsnt-gpios

In reply to Oza Pawandeep

Add description for optional device tree property
'prsnt-gpios' for PCI hotplug feature.

Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt +14 -0
index b8e48b4..0c5f631 100644
@@ -72,6 +72,20 @@ Optional properties:
 - brcm,pcie-msi-inten: Needs to be present for some older iProc platforms that
 require the interrupt enable registers to be set explicitly to enable MSI
 
+Optional properties:
+- slot-pluggable: PCI hotplug feature is supported.
+- prsnt-gpios: Array of gpios, needs to be present if Hotplug is supported.
+
+Refer to the following binding documents for more detailed description on
+the use of 'slot-pluggable' and 'prsnt-gpios'.
+  Documentation/devicetree/bindings/pci/pci.txt
+
+Example:
+prsnt-gpios: <&pca9505 32 1>, <&pca9505 33 1>;
+This is x4 connector: monitoring max 2 present lines.
+prsnt-gpios: <&pca9505 32 1>, <&pca9505 33 1>, <&pca9505 34 1>;
+This is x8 connector: monitoring max 3 present lines.
+
 Example:
 	pcie0: pcie at 18012000 {
 		compatible = "brcm,iproc-pcie";
Signature · 1 line
1.9.1
maintainer Acked-by on v2 2/3
#3 lore raw

Re: [PATCH v2 2/3] Documentation/devicetree: Add PCIe hotplug property

In reply to Oza Pawandeep
Quoted 8 lines · Oza Pawandeep

Host drivers have the requirement of implementing PCI hotplug based on the how their SOC supports PCI hotplug.

Couple of properties have been added. the one to enable the hotplug feature itself, and the other caters to the PCI hotplug implementation with the use of gpios.

"dt-bindings: PCI: ..." preferred for the subject if you respin.