linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] PCI: dwc-host: Add a warning to prevent invalid values
@ 2022-11-07 15:31 JunDong Song
  2022-11-07 15:31 ` [PATCH 2/2] " JunDong Song
  2022-11-10 21:32 ` [PATCH 1/2] " Bjorn Helgaas
  0 siblings, 2 replies; 3+ messages in thread
From: JunDong Song @ 2022-11-07 15:31 UTC (permalink / raw)
  To: jingoohan1, gustavo.pimentel, lpieralisi
  Cc: robh, kw, bhelgaas, linux-pci, linux-kernel, JunDong Song

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.

Signed-off-by: JunDong Song <jundongsong1@gmail.com>
---

When I use the pcie dwc driver, the controller speed is abnormal,
but it has not been detected because of the @max-link-speed error,
so I think I need to return an error or warning here.

Thanks.

 drivers/pci/controller/dwc/pcie-designware-ep.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index 83ddb1902..573342601 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -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 (unlikely(pci->link_gen < 0))
+			dev_warn(dev, "Failed to get max link speed\n");
+	}
 
 	epc = devm_pci_epc_create(dev, &epc_ops);
 	if (IS_ERR(epc)) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-10 21:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07 15:31 [PATCH 1/2] PCI: dwc-host: Add a warning to prevent invalid values JunDong Song
2022-11-07 15:31 ` [PATCH 2/2] " JunDong Song
2022-11-10 21:32 ` [PATCH 1/2] " Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).