Skip to contentSkip to conversation

PCI: dwc: Warn about invalid 'max-link-speed' from DT

PATCH New Harry Song 1 participant 1 message Nov 13, 2022

Subsystems (3)
lore
Share & tools
lore

Harry Song

author
#0 lore raw

PATCH v2 1/1 PCI: dwc: Warn about invalid 'max-link-speed' from DT

of_pci_get_max_link_speed() may return a negative value, causing the controller to not set the speed correctly. Add a warning in case the driver engineer misses it.

---

V2: Change the description of the subject line;

     Remove unnecessary "unlikely";

Thanks for your comment, V1 is this one:
https://lore.kernel.org/lkml/20221110213239.GA672651@bhelgaas/

 drivers/pci/controller/dwc/pcie-designware-ep.c   | 5 ++++-
 drivers/pci/controller/dwc/pcie-designware-host.c | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +4 -1
index 83ddb1902..19892e939 100644
@@ -739,8 +739,11 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
 		return -ENOMEM;
 	ep->outbound_addr = addr;
 
-	if (pci->link_gen < 1)
+	if (pci->link_gen < 1) {
 		pci->link_gen = of_pci_get_max_link_speed(np);
+		if (pci->link_gen < 0)
+			dev_warn(dev, "Invalid to get max-link-speed from DT\n");
+	}
 
 	epc = devm_pci_epc_create(dev, &epc_ops);
 	if (IS_ERR(epc)) {
drivers/pci/controller/dwc/pcie-designware-host.c +4 -1
index 39f3b37d4..42633ec8c 100644
@@ -429,8 +429,11 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
 		pp->io_base = pci_pio_to_address(win->res->start);
 	}
 
-	if (pci->link_gen < 1)
+	if (pci->link_gen < 1) {
 		pci->link_gen = of_pci_get_max_link_speed(np);
+		if (pci->link_gen < 0)
+			dev_warn(dev, "Invalid to get max-link-speed from DT\n");
+	}
 
 	/* Set default bus ops */
 	bridge->ops = &dw_pcie_ops;
Signature · 1 line
2.25.1