From: Harry Song <jundongsong1@gmail.com>
To: helgaas@kernel.org
Cc: bhelgaas@google.com, gustavo.pimentel@synopsys.com,
jingoohan1@gmail.com, jundongsong1@gmail.com, kw@linux.com,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
lpieralisi@kernel.org, robh@kernel.org
Subject: [PATCH V2] PCI: dwc: Warn about invalid 'max-link-speed' from DT
Date: Sun, 13 Nov 2022 16:10:06 +0800 [thread overview]
Message-ID: <20221113081006.3624-1-jundongsong1@gmail.com> (raw)
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: Harry Song <jundongsong1@gmail.com>
---
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(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index 83ddb1902..19892e939 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 (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)) {
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 39f3b37d4..42633ec8c 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -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;
--
2.25.1
reply other threads:[~2022-11-13 8:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221113081006.3624-1-jundongsong1@gmail.com \
--to=jundongsong1@gmail.com \
--cc=bhelgaas@google.com \
--cc=gustavo.pimentel@synopsys.com \
--cc=helgaas@kernel.org \
--cc=jingoohan1@gmail.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).