Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Navid Ghahremani" <ghahramani.navid@gmail.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH 13/24] PCI: dwc: Add ZTE ZX279128S host controller driver
Date: Sat, 10 Oct 2026 13:14:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-166576@kernel.org> (raw)
In-Reply-To: <20261010130024.177503-14-ghahramani.navid@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] pci: race condition and state corruption in shared CRM2_RST register
- [Medium] pci: LNKCTL 32-bit read-modify-write clears LNKSTA W1C bits
- [Medium] pci: missing hardware cleanup on probe failure leaks clocks and PHY state
--

commit 41b496fd57c1fa24884637e3c63af32d3b98ad9f
Author: Navid Ghahremani <ghahramani.navid@gmail.com>
PCI: dwc: Add ZTE ZX279128S host controller driver

This commit adds a new PCIe controller driver for the ZTE ZX279128S SoC.
It supports bringing up both controller links using a vendor sequence,
handles shared board reset, and relies on legacy INTx interrupts.

> diff --git a/drivers/pci/controller/dwc/pcie-zx279128s.c b/drivers/pci/controller/dwc/pcie-zx279128s.c
> new file mode 100644
> index 0000000000000..3559beb35a142
> --- /dev/null
> +++ b/drivers/pci/controller/dwc/pcie-zx279128s.c
[ ... ]
> +static void zx279128s_pcie_force_gen1(struct dw_pcie *pci)
> +{
> +	u8 cap = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
> +	u32 val;
> +
> +	if (WARN_ON(!cap))
> +		return;
> +
> +	dw_pcie_dbi_ro_wr_en(pci);
> +
> +	val = dw_pcie_readl_dbi(pci, cap + PCI_EXP_LNKCTL2);
> +	val &= ~PCI_EXP_LNKCTL2_TLS;
> +	val |= PCI_EXP_LNKCTL2_TLS_2_5GT;
> +	dw_pcie_writel_dbi(pci, cap + PCI_EXP_LNKCTL2, val);
> +
> +	val = dw_pcie_readl_dbi(pci, cap + PCI_EXP_LNKCTL);
> +	dw_pcie_writel_dbi(pci, cap + PCI_EXP_LNKCTL, val | PCI_EXP_LNKCTL_RL);

[Severity: Medium]
Does using 32-bit accessors (dw_pcie_readl_dbi and dw_pcie_writel_dbi) for
the 16-bit PCI_EXP_LNKCTL and PCI_EXP_LNKCTL2 registers inadvertently clear
Write-1-to-Clear (W1C) bits in the adjacent Link Status registers?

Because the Link Status registers are adjacent to the Link Control registers,
a 32-bit read-modify-write includes them. If any W1C bits (like Link
Autonomous Bandwidth Status) were read as 1, writing them back as 1 clears
them, which can result in lost link events. Should this use 16-bit accessors
or dw_pcie_read_dbi() with a size of 2?

> +
> +	dw_pcie_dbi_ro_wr_dis(pci);
> +}
> +
> +static int zx279128s_pcie_init_crm(struct zx279128s_pcie *pcie)
> +{
> +	const struct zx279128s_pcie_port *port = pcie->port;
> +	struct regmap *crm1 = pcie->crm[ZX_CRM1];
> +	struct regmap *crm2 = pcie->crm[ZX_CRM2];
> +	int ret, i;
[ ... ]
> +	ret = regmap_write_bits(crm2, CRM2_RST, port->rst, port->rst);
> +	if (ret)
> +		return ret;
> +	ret = regmap_write_bits(crm2, CRM2_CLK, port->clk_off, 0);
> +	if (ret)
> +		return ret;
> +
> +	return regmap_write(crm2, CRM2_RST, CRM2_RST_ALL);

[Severity: High]
Does an unconditional regmap_write() of CRM2_RST_ALL completely overwrite
the shared CRM2_RST register, potentially corrupting the reset state of a
sibling PCIe controller or other SoC peripherals?

> +}
> +
> +static int zx279128s_pcie_host_init(struct dw_pcie_rp *pp)
> +{
> +	struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
> +	struct zx279128s_pcie *pcie = to_zx279128s_pcie(pci);
> +	int ret;
> +
> +	/*
> +	 * The board lines reset a device that can sit behind both controllers
> +	 * (the MT7915 of the H3600 uses both). The first controller to start
> +	 * resets and releases it; the second must not reset it again.
> +	 */
> +	mutex_lock(&zx279128s_board_lock);
> +	if (!zx279128s_board_released && (pcie->reset || pcie->enable)) {
[ ... ]
> +		msleep(200);
> +		zx279128s_board_released = true;
> +	}
> +	mutex_unlock(&zx279128s_board_lock);
> +
> +	ret = zx279128s_pcie_init_crm(pcie);

[Severity: High]
Since zx279128s_board_lock is released right before calling
zx279128s_pcie_init_crm(), can two concurrently probing controllers race
during initialization?

One controller might still be inside its 50ms fsleep() window after asserting
its reset bit, while the other completes its sequence and overwrites the
entire CRM2_RST register with CRM2_RST_ALL, prematurely deasserting the first
controller's reset.

> +	if (ret)
> +		return dev_err_probe(pci->dev, ret, "failed to initialize CRM\n");
> +
> +	/* Enable the controller, which starts link training */
[ ... ]
> +static const struct dw_pcie_host_ops zx279128s_pcie_host_ops = {
> +	.init = zx279128s_pcie_host_init,
> +	.msi_init = zx279128s_pcie_msi_init,
> +};

[Severity: Medium]
If the core dw_pcie_host_init() fails after successfully calling the driver's
.init callback, does the lack of a .deinit callback here cause the driver to
leak enabled clocks and leave PHYs powered on permanently?

Also, if any register access fails mid-sequence inside
zx279128s_pcie_init_crm(), the function returns immediately without rolling
back the already-enabled clocks and PHYs.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261010130024.177503-1-ghahramani.navid@gmail.com?part=13

  reply	other threads:[~2026-10-10 13:14 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10 12:59 [PATCH RFC 00/24] ARM: zte: Add support for Sanechips ZX279128S and ZTE ZXHN H3600 Navid Ghahremani
2026-10-10 12:59 ` [PATCH 01/24] dt-bindings: cache: l2c2x0: Describe ZTE device-read serialization Navid Ghahremani
2026-10-12  9:43   ` Krzysztof Kozlowski
2026-10-10 12:59 ` [PATCH 02/24] ARM: l2c: Serialize device reads with cache maintenance when requested Navid Ghahremani
2026-10-10 13:10   ` sashiko-bot
2026-10-10 14:28   ` Arnd Bergmann
2026-10-10 21:41     ` Navid Ghahremani
2026-10-11  1:02     ` Navid Ghahremani
2026-10-11 14:48       ` Arnd Bergmann
2026-10-10 12:59 ` [PATCH 03/24] wifi: mt76: Serialize MMIO reads with outer cache maintenance Navid Ghahremani
2026-10-10 12:59 ` [PATCH 04/24] dt-bindings: arm: Add ZTE ZX279128S platform descriptions Navid Ghahremani
2026-10-10 12:59 ` [PATCH 05/24] ARM: zte: Add ZX279128S platform and CPU hotplug support Navid Ghahremani
2026-10-10 14:13   ` Arnd Bergmann
2026-10-10 17:34     ` Stefan Dösinger
2026-10-10 21:26       ` Navid Ghahremani
2026-10-10 12:59 ` [PATCH 06/24] dt-bindings: clock: Add ZTE ZX279128S CRM clocks and resets Navid Ghahremani
2026-10-10 13:08   ` sashiko-bot
2026-10-11  9:13   ` Stefan Dösinger
2026-10-10 12:59 ` [PATCH 07/24] clk: zte: Add ZX279128S CRM clock and reset driver Navid Ghahremani
2026-10-10 13:15   ` sashiko-bot
2026-10-11 11:10   ` Stefan Dösinger
2026-10-10 12:59 ` [PATCH 08/24] dt-bindings: gpio: Add ZTE ZX279128S GPIO controller Navid Ghahremani
2026-10-10 12:59 ` [PATCH 09/24] gpio: Add ZTE ZX279128S GPIO driver Navid Ghahremani
2026-10-10 13:14   ` sashiko-bot
2026-10-11 11:19   ` Stefan Dösinger
2026-10-12 10:59   ` Uwe Kleine-König
2026-10-10 12:59 ` [PATCH 10/24] dt-bindings: pinctrl: pinctrl-single: Add ZTE ZX279128S pin mux Navid Ghahremani
2026-10-10 12:59 ` [PATCH 11/24] dt-bindings: mfd: syscon: Add ZX279128S system controller Navid Ghahremani
2026-10-10 13:08   ` sashiko-bot
2026-10-10 12:59 ` [PATCH 12/24] dt-bindings: PCI: Add ZTE ZX279128S host controller Navid Ghahremani
2026-10-10 13:12   ` sashiko-bot
2026-10-10 12:59 ` [PATCH 13/24] PCI: dwc: Add ZTE ZX279128S host controller driver Navid Ghahremani
2026-10-10 13:14   ` sashiko-bot [this message]
2026-10-11 13:03   ` Stefan Dösinger
2026-10-10 12:59 ` [PATCH 14/24] dt-bindings: net: Add ZTE ZX279128S MDIO controller Navid Ghahremani
2026-10-10 13:06   ` sashiko-bot
2026-10-10 12:59 ` [PATCH 15/24] net: mdio: " Navid Ghahremani
2026-10-10 13:11   ` sashiko-bot
2026-10-10 12:59 ` [PATCH 16/24] net: phy: Add Sanechips ZX5201 PHY support Navid Ghahremani
2026-10-10 12:59 ` [PATCH 17/24] dt-bindings: net: Add ZTE ZX279128S Ethernet switch Navid Ghahremani
2026-10-10 13:08   ` sashiko-bot
2026-10-10 12:59 ` [PATCH 18/24] net: ethernet: zte: Add ZX279128S Ethernet switch driver Navid Ghahremani
2026-10-10 13:19   ` sashiko-bot
2026-10-10 12:59 ` [PATCH 19/24] dt-bindings: spi: Add ZTE ZX279128S SPI flash controller Navid Ghahremani
2026-10-10 12:59 ` [PATCH 20/24] " Navid Ghahremani
2026-10-10 13:11   ` sashiko-bot
2026-10-11 16:32   ` Stefan Dösinger
2026-10-10 12:59 ` [PATCH 21/24] dt-bindings: usb: Add ZTE ZX279128S DWC3 controller Navid Ghahremani
2026-10-10 13:11   ` sashiko-bot
2026-10-10 13:00 ` [PATCH 22/24] usb: dwc3: generic-plat: Add ZTE ZX279128S Navid Ghahremani
2026-10-10 13:14   ` sashiko-bot
2026-10-10 13:00 ` [PATCH 23/24] ARM: dts: zte: Add ZX279128S SoC description Navid Ghahremani
2026-10-10 13:14   ` sashiko-bot
2026-10-10 13:00 ` [PATCH 24/24] ARM: dts: zte: Add ZTE ZXHN H3600 board Navid Ghahremani
2026-10-12 19:20 ` [PATCH RFC 00/24] ARM: zte: Add support for Sanechips ZX279128S and ZTE ZXHN H3600 Stefan Dösinger

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=sashiko-outbox-166576@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=ghahramani.navid@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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