Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: PCI: mediatek: Add support for optional perstout reset
@ 2026-07-08  9:05 Christian Marangi
  2026-07-08  9:05 ` [PATCH 2/2] PCI: mediatek: handle optional reset for perstout for AN7583 Christian Marangi
  2026-07-08  9:11 ` [PATCH 1/2] dt-bindings: PCI: mediatek: Add support for optional perstout reset sashiko-bot
  0 siblings, 2 replies; 4+ messages in thread
From: Christian Marangi @ 2026-07-08  9:05 UTC (permalink / raw)
  To: Ryder Lee, Bjorn Helgaas, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
	Matthias Brugger, AngeloGioacchino Del Regno, Christian Marangi,
	linux-pci, linux-mediatek, devicetree, linux-kernel,
	linux-arm-kernel

Airoha AN7583 have a dedicated reset for PCIe PERSTOUT. Add optional
support for it in schema.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 .../devicetree/bindings/pci/mediatek-pcie.yaml       | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/pci/mediatek-pcie.yaml b/Documentation/devicetree/bindings/pci/mediatek-pcie.yaml
index c009a7a52bc6..cc5400c26185 100644
--- a/Documentation/devicetree/bindings/pci/mediatek-pcie.yaml
+++ b/Documentation/devicetree/bindings/pci/mediatek-pcie.yaml
@@ -43,10 +43,12 @@ properties:
       - enum: [ pipe_ck0, pipe_ck1 ]
 
   resets:
-    maxItems: 1
+    minItems: 1
+    maxItems: 2
 
   reset-names:
-    const: pcie-rst1
+    minItems: 1
+    maxItems: 2
 
   interrupts:
     maxItems: 1
@@ -127,6 +129,12 @@ allOf:
         phy-names:
           const: pcie-phy1
 
+        resets-names:
+          minItems: 1
+          items:
+            - const: pcie-rst1
+            - const: pcie-perstout1
+
         power-domain: false
 
       required:
-- 
2.53.0


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

* [PATCH 2/2] PCI: mediatek: handle optional reset for perstout for AN7583
  2026-07-08  9:05 [PATCH 1/2] dt-bindings: PCI: mediatek: Add support for optional perstout reset Christian Marangi
@ 2026-07-08  9:05 ` Christian Marangi
  2026-07-08  9:15   ` sashiko-bot
  2026-07-08  9:11 ` [PATCH 1/2] dt-bindings: PCI: mediatek: Add support for optional perstout reset sashiko-bot
  1 sibling, 1 reply; 4+ messages in thread
From: Christian Marangi @ 2026-07-08  9:05 UTC (permalink / raw)
  To: Ryder Lee, Bjorn Helgaas, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Philipp Zabel,
	Matthias Brugger, AngeloGioacchino Del Regno, Christian Marangi,
	linux-pci, linux-mediatek, devicetree, linux-kernel,
	linux-arm-kernel

The Airoha AN7583 provide the perstout via a dedicated reset line as using
the PCIe register is not possible as it will cause glitch.

Add support for it via the additional reset name pcie-perstout[slot] and
assert/deassert on an7583 specific startup.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/pci/controller/pcie-mediatek.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
index 8b57c3d75b94..3d4de9d69407 100644
--- a/drivers/pci/controller/pcie-mediatek.c
+++ b/drivers/pci/controller/pcie-mediatek.c
@@ -175,6 +175,7 @@ struct mtk_pcie_soc {
  * @phys_base: Physical address of the I/O register base region
  * @list: port list
  * @pcie: pointer to PCIe host info
+ * @perstout_reset: pointer to port perstout reset control
  * @reset: pointer to port reset control
  * @sys_ck: pointer to transaction/data link layer clock
  * @ahb_ck: pointer to AHB slave interface operating clock for CSR access
@@ -198,6 +199,7 @@ struct mtk_pcie_port {
 	struct list_head list;
 	struct mtk_pcie *pcie;
 	struct reset_control *reset;
+	struct reset_control *perstout_reset;
 	struct clk *sys_ck;
 	struct clk *ahb_ck;
 	struct clk *axi_ck;
@@ -865,6 +867,9 @@ static int mtk_pcie_startup_port_an7583(struct mtk_pcie_port *port)
 	size = lower_32_bits(resource_size(entry->res));
 	regmap_write(pbus_regmap, args[1], GENMASK(31, __fls(size)));
 
+	reset_control_assert(port->perstout_reset);
+	reset_control_deassert(port->perstout_reset);
+
 	return mtk_pcie_startup_port_v2(port);
 }
 
@@ -1020,6 +1025,11 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie,
 	if (PTR_ERR(port->reset) == -EPROBE_DEFER)
 		return PTR_ERR(port->reset);
 
+	snprintf(name, sizeof(name), "pcie-perstout%d", slot);
+	port->perstout_reset = devm_reset_control_get_optional_exclusive(dev, name);
+	if (PTR_ERR(port->perstout_reset) == -EPROBE_DEFER)
+		return PTR_ERR(port->perstout_reset);
+
 	/* some platforms may use default PHY setting */
 	snprintf(name, sizeof(name), "pcie-phy%d", slot);
 	port->phy = devm_phy_optional_get(dev, name);
-- 
2.53.0


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

* Re: [PATCH 1/2] dt-bindings: PCI: mediatek: Add support for optional perstout reset
  2026-07-08  9:05 [PATCH 1/2] dt-bindings: PCI: mediatek: Add support for optional perstout reset Christian Marangi
  2026-07-08  9:05 ` [PATCH 2/2] PCI: mediatek: handle optional reset for perstout for AN7583 Christian Marangi
@ 2026-07-08  9:11 ` sashiko-bot
  1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-07-08  9:11 UTC (permalink / raw)
  To: Christian Marangi; +Cc: robh, linux-pci, devicetree, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch introduces a typo `resets-names:` instead of `reset-names:` in the `airoha,an7583-pcie` conditional block.
--

--- Patch [1]: [PATCH 1/2] dt-bindings: PCI: mediatek: Add support for optional perstout reset ---
commit 940c7b8d9eadf01ceca0b3e3526e890e946e92a5
Author: Christian Marangi <ansuelsmth@gmail.com>

dt-bindings: PCI: mediatek: Add support for optional perstout reset

This commit adds optional schema support for a dedicated PCIe PERSTOUT reset
on Airoha AN7583 devices. It bumps the maximum items for resets and
reset-names, and adds specific name constraints in the conditional block.

> diff --git a/Documentation/devicetree/bindings/pci/mediatek-pcie.yaml b/Documentation/devicetree/bindings/pci/mediatek-pcie.yaml
> --- a/Documentation/devicetree/bindings/pci/mediatek-pcie.yaml
> +++ b/Documentation/devicetree/bindings/pci/mediatek-pcie.yaml
[ ... ]
> @@ -127,6 +129,12 @@ allOf:
>          phy-names:
>            const: pcie-phy1
>  
> +        resets-names:

[Severity: Medium]
This isn't a runtime bug, but there appears to be a typo in this property
name (resets-names instead of reset-names). Will this cause the DT binding
schema validation to ignore these constraints and silently allow incorrectly
ordered values for the reset-names property?

> +          minItems: 1
> +          items:
> +            - const: pcie-rst1
> +            - const: pcie-perstout1
> +
>          power-domain: false
>  
>        required:

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708090533.19734-1-ansuelsmth@gmail.com?part=1

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

* Re: [PATCH 2/2] PCI: mediatek: handle optional reset for perstout for AN7583
  2026-07-08  9:05 ` [PATCH 2/2] PCI: mediatek: handle optional reset for perstout for AN7583 Christian Marangi
@ 2026-07-08  9:15   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-07-08  9:15 UTC (permalink / raw)
  To: Christian Marangi; +Cc: devicetree, conor+dt, robh, linux-pci

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing T_PERST delay between PCIe PERST# assert and deassert.
- [Medium] Fails to handle non-EPROBE_DEFER error pointers from devm_reset_control_get_optional_exclusive().
--

--- Patch [2]: [PATCH 2/2] PCI: mediatek: handle optional reset for perstout for AN7583 ---
commit 78554414cf365c230ecb9c4411ea14d8c699dd5c
Author: Christian Marangi <ansuelsmth@gmail.com>

PCI: mediatek: handle optional reset for perstout for AN7583

The commit adds support for a dedicated perstout reset line for the Airoha
AN7583 SoC to avoid glitches. It introduces the pcie-perstout[slot] reset
name handling and asserts/deasserts it during AN7583 specific startup.

> diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> index 8b57c3d75b942..3d4de9d694071 100644
> --- a/drivers/pci/controller/pcie-mediatek.c
> +++ b/drivers/pci/controller/pcie-mediatek.c
[ ... ]
> @@ -865,6 +867,9 @@ static int mtk_pcie_startup_port_an7583(struct mtk_pcie_port *port)
>  	size = lower_32_bits(resource_size(entry->res));
>  	regmap_write(pbus_regmap, args[1], GENMASK(31, __fls(size)));
>  
> +	reset_control_assert(port->perstout_reset);
> +	reset_control_deassert(port->perstout_reset);

[Severity: High]
Is it intentional to omit the 100ms T_PERST delay here?

Without a delay between assert and deassert, the endpoint device will receive
a zero-width reset pulse which violates the PCIe CEM specification. Because
the AN7583 quirks likely include MTK_PCIE_SKIP_RSTB, the standard 100ms
delay in mtk_pcie_startup_port_v2() will be skipped, leaving no delay at all
before link training begins.

> +
>  	return mtk_pcie_startup_port_v2(port);
>  }
>  
> @@ -1020,6 +1025,11 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie,
>  	if (PTR_ERR(port->reset) == -EPROBE_DEFER)
>  		return PTR_ERR(port->reset);
>  
> +	snprintf(name, sizeof(name), "pcie-perstout%d", slot);
> +	port->perstout_reset = devm_reset_control_get_optional_exclusive(dev, name);
> +	if (PTR_ERR(port->perstout_reset) == -EPROBE_DEFER)
> +		return PTR_ERR(port->perstout_reset);

[Severity: Medium]
Will this silently leak non-EPROBE_DEFER error pointers (like -EINVAL or
-ENOMEM) into port->perstout_reset?

If devm_reset_control_get_optional_exclusive() fails with something other
than -EPROBE_DEFER, the error pointer will be stored in port->perstout_reset
since IS_ERR() isn't checked first. 

When this pointer is later passed to reset_control_assert() in
mtk_pcie_startup_port_an7583(), it will trigger a WARN_ON(IS_ERR(rstc)) in
the reset core framework.

> +
>  	/* some platforms may use default PHY setting */
>  	snprintf(name, sizeof(name), "pcie-phy%d", slot);
>  	port->phy = devm_phy_optional_get(dev, name);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708090533.19734-1-ansuelsmth@gmail.com?part=2

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

end of thread, other threads:[~2026-07-08  9:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08  9:05 [PATCH 1/2] dt-bindings: PCI: mediatek: Add support for optional perstout reset Christian Marangi
2026-07-08  9:05 ` [PATCH 2/2] PCI: mediatek: handle optional reset for perstout for AN7583 Christian Marangi
2026-07-08  9:15   ` sashiko-bot
2026-07-08  9:11 ` [PATCH 1/2] dt-bindings: PCI: mediatek: Add support for optional perstout reset sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox