From: Wentao Liang <vulab@iscas.ac.cn>
To: "Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] PCI: keystone: drop host bridge reference in ks_pcie_quirk()
Date: Tue, 3 Nov 2026 10:42:39 +0000 [thread overview]
Message-ID: <20261103104239.1373754-1-vulab@iscas.ac.cn> (raw)
pci_get_host_bridge_device() takes a kobject reference on the host
bridge device. ks_pcie_quirk() returns without releasing it on every
path after the lookup, including the AM654 PG1.0 path that only limits
the MRRS, so the reference is leaked once for each enabled downstream
device below an AM654 root complex.
Move the AM654 handling out of the enclosing conditional and release
the reference through a single cleanup label.
Fixes: 86f271f22bbb ("PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0)")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/pci/controller/dwc/pci-keystone.c | 45 +++++++++++++----------
1 file changed, 26 insertions(+), 19 deletions(-)
diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
index edfbc32904cd..0c46887de0d5 100644
--- a/drivers/pci/controller/dwc/pci-keystone.c
+++ b/drivers/pci/controller/dwc/pci-keystone.c
@@ -579,26 +579,33 @@ static void ks_pcie_quirk(struct pci_dev *dev)
* when MRRS is set to more than 128 bytes. Force the MRRS to
* 128 bytes in all downstream devices.
*/
- if (pci_match_id(am6_pci_devids, bridge)) {
- bridge_dev = pci_get_host_bridge_device(dev);
- if (!bridge_dev || !bridge_dev->parent)
- return;
-
- ks_pcie = dev_get_drvdata(bridge_dev->parent);
- if (!ks_pcie)
- return;
-
- val = ks_pcie_app_readl(ks_pcie, PID);
- val &= RTL;
- val >>= RTL_SHIFT;
- if (val != AM6_PCI_PG1_RTL_VER)
- return;
-
- if (pcie_get_readrq(dev) > 128) {
- dev_info(&dev->dev, "limiting MRRS to 128 bytes\n");
- pcie_set_readrq(dev, 128);
- }
+ if (!pci_match_id(am6_pci_devids, bridge))
+ return;
+
+ bridge_dev = pci_get_host_bridge_device(dev);
+ if (!bridge_dev)
+ return;
+
+ if (!bridge_dev->parent)
+ goto put_bridge;
+
+ ks_pcie = dev_get_drvdata(bridge_dev->parent);
+ if (!ks_pcie)
+ goto put_bridge;
+
+ val = ks_pcie_app_readl(ks_pcie, PID);
+ val &= RTL;
+ val >>= RTL_SHIFT;
+ if (val != AM6_PCI_PG1_RTL_VER)
+ goto put_bridge;
+
+ if (pcie_get_readrq(dev) > 128) {
+ dev_info(&dev->dev, "limiting MRRS to 128 bytes\n");
+ pcie_set_readrq(dev, 128);
}
+
+put_bridge:
+ pci_put_host_bridge_device(bridge_dev);
}
DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, ks_pcie_quirk);
--
2.34.1
next reply other threads:[~2026-11-03 10:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 10:42 Wentao Liang [this message]
2026-11-03 11:10 ` Krzysztof Kozlowski
2026-11-03 23:33 ` kernel test robot
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=20261103104239.1373754-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=bhelgaas@google.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=stable@vger.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
all inboxes | Powered by JetHome®