diff mbox series

[v3,2/2] PCI: OF: Support external-facing property

Message ID 20190411124027.9490-3-jean-philippe.brucker@arm.com (mailing list archive)
State Accepted, archived
Commit 9cb30a71acd45d65321c73160626f15fcdceba7a
Headers show
Series PCI: Describe external-facing ports in device tree | expand

Commit Message

Jean-Philippe Brucker April 11, 2019, 12:40 p.m. UTC
Set the "untrusted" attribute to any PCIe port that has an
"external-facing" device tree property. Any device downstream of this
port will inherit the attribute and have only the strictest IOMMU
protection.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
v2->v3:
* Use of_property_read_bool().
* Firmware can in theory set the property on the host bridge node.
  Handle this case.
* Don't pass a NULL node to the of driver. Although it is handled
  gracefully at the moment, it isn't documented and we might as well
  proof this too.
---
 drivers/pci/of.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index 3d32da15c215..67376cf45880 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -31,10 +31,16 @@  void pci_release_of_node(struct pci_dev *dev)
 
 void pci_set_bus_of_node(struct pci_bus *bus)
 {
-	if (bus->self == NULL)
-		bus->dev.of_node = pcibios_get_phb_of_node(bus);
-	else
-		bus->dev.of_node = of_node_get(bus->self->dev.of_node);
+	struct device_node *node;
+
+	if (bus->self == NULL) {
+		node = pcibios_get_phb_of_node(bus);
+	} else {
+		node = of_node_get(bus->self->dev.of_node);
+		if (node && of_property_read_bool(node, "external-facing"))
+			bus->self->untrusted = true;
+	}
+	bus->dev.of_node = node;
 }
 
 void pci_release_bus_of_node(struct pci_bus *bus)