๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Joseph Telaak via B4 Relay Sun, 15 Nov 2026 22:33
[PATCH net-next v4 2/2] net: dsa: mxl-gsw1xx: reset the switch through reset-gpios
#16796
Author: Joseph Telaak via B4 Relay
Date: Sun, 15 Nov 2026 22:33
128 lines
15256 bytes
From: Joseph Telaak <joseph@telaak.dev>

The switch keeps the configuration the bootloader left in it, and the
driver never resets it. The MDIO core asserts and releases reset-gpios
only for PHY devices, so a reset line described on the switch node has
no effect either.

On the GL.iNet GL-SFT1200, nothing answers at internal MDIO address 0
after the bootloader, and the PHY that answers at each port's address
belongs to the neighboring port, so port 0 fails with "failed to
connect to PHY: -ENODEV". Describing the PHYs at the addresses they
answer at is not enough: with them at 1 to 3 and no reset, neither LAN
port passes traffic. After a hardware reset every PHY is back at its
port's address and all ports work. GL.iNet's own firmware resets the
switch from Linux too.

Get the reset through the reset controller API and pulse it before the
first register access. The reset core hands a reset-gpios property to
the reset-gpio driver, so a board that wires the reset this way needs
CONFIG_RESET_GPIO; without it the reset is skipped. Imply it, so it is
enabled by default, and say so in the help text. The timing follows the
vendor's driver for the GSW150: asserted for 250 ms, then 1 s before the
switch is accessed. No timing is known for the other GSW1xx parts, so
they get the same.

The reset also returns the RGMII slew rates to their power-on defaults,
so a board that uses reset-gpios sets the ones it needs in its device
tree.

Signed-off-by: Joseph Telaak <joseph@telaak.dev>
---
 drivers/net/dsa/lantiq/Kconfig      |  5 +++++
 drivers/net/dsa/lantiq/mxl-gsw1xx.c | 26 ++++++++++++++++++++++++++
 drivers/net/dsa/lantiq/mxl-gsw1xx.h |  6 ++++++
 3 files changed, 37 insertions(+)

diff --git a/drivers/net/dsa/lantiq/Kconfig b/drivers/net/dsa/lantiq/Kconfig
index 98efeef266..c0f2e36bf6 100644
--- a/drivers/net/dsa/lantiq/Kconfig
+++ b/drivers/net/dsa/lantiq/Kconfig
@@ -16,6 +16,7 @@ config NET_DSA_MXL_GSW1XX
 	select NET_DSA_TAG_MXL_GSW1XX
 	select NET_DSA_LANTIQ_COMMON
 	select PHY_COMMON_PROPS
+	imply RESET_GPIO
 	help
 	  This enables support for the Intel/MaxLinear GSW1xx family of 1GE
 	  switches.
@@ -25,3 +26,7 @@ config NET_DSA_MXL_GSW1XX
 	    GSW141 6 port, 4 PHYs, RGMII & SGMII
 	    GSW145 6 port, 4 PHYs, RGMII & SGMII/2500Base-X, industrial temperature
 	    GSW150 7 port, 5 PHYs, 1x GMII/RGMII, 1x RGMII
+
+	  A switch whose hardware reset is described with reset-gpios is
+	  only reset when RESET_GPIO is enabled as well, which this option
+	  does by default.
diff --git a/drivers/net/dsa/lantiq/mxl-gsw1xx.c b/drivers/net/dsa/lantiq/mxl-gsw1xx.c
index 0c7ea242a6..33b73b2ed5 100644
--- a/drivers/net/dsa/lantiq/mxl-gsw1xx.c
+++ b/drivers/net/dsa/lantiq/mxl-gsw1xx.c
@@ -18,6 +18,7 @@
 #include <linux/phy/phy-common-props.h>
 #include <linux/property.h>
 #include <linux/regmap.h>
+#include <linux/reset.h>
 #include <linux/workqueue.h>
 #include <net/dsa.h>
 
@@ -719,6 +720,7 @@ static int gsw1xx_serdes_pcs_init(struct gsw1xx_priv *priv)
 static int gsw1xx_probe(struct mdio_device *mdiodev)
 {
 	struct device *dev = &mdiodev->dev;
+	struct reset_control *reset;
 	struct gsw1xx_priv *priv;
 	u32 version, val;
 	u8 shellver;
@@ -737,6 +739,30 @@ static int gsw1xx_probe(struct mdio_device *mdiodev)
 	if (!priv->gswip.hw_info)
 		return -EINVAL;
 
+	/* The MDIO core handles reset-gpios only for PHYs. Reset the switch
+	 * here, so it does not run with whatever the bootloader configured.
+	 */
+	reset = devm_reset_control_get_optional_exclusive(dev, NULL);
+	if (IS_ERR(reset))
+		return dev_err_probe(dev, PTR_ERR(reset),
+				     "failed to get reset control\n");
+
+	if (reset) {
+		ret = reset_control_assert(reset);
+		if (ret)
+			return dev_err_probe(dev, ret,
+					     "failed to assert reset\n");
+
+		fsleep(GSW1XX_RESET_ASSERT_US);
+
+		ret = reset_control_deassert(reset);
+		if (ret)
+			return dev_err_probe(dev, ret,
+					     "failed to deassert reset\n");
+
+		fsleep(GSW1XX_RESET_DEASSERT_US);
+	}
+
 	priv->gswip.gswip = gsw1xx_regmap_init(priv, "switch",
 					       GSW1XX_SWITCH_BASE, 0xfff);
 	if (IS_ERR(priv->gswip.gswip))
diff --git a/drivers/net/dsa/lantiq/mxl-gsw1xx.h b/drivers/net/dsa/lantiq/mxl-gsw1xx.h
index 81bc00eabb..7d91a7b7e2 100644
--- a/drivers/net/dsa/lantiq/mxl-gsw1xx.h
+++ b/drivers/net/dsa/lantiq/mxl-gsw1xx.h
@@ -19,6 +19,12 @@
 
 #define GSW1XX_SYS_CLK_FREQ			340000000
 
+/* Hardware reset timing of the vendor's driver for the GSW150, which is the
+ * only one known and is used for all the GSW1xx parts
+ */
+#define GSW1XX_RESET_ASSERT_US			250000
+#define GSW1XX_RESET_DEASSERT_US		1000000
+
 /* SMDIO switch register base address */
 #define GSW1XX_SMDIO_BADR			0x1f
 #define  GSW1XX_SMDIO_BADR_UNKNOWN		-1

-- 
Git-155)
Re: [PATCH net-next v4 2/2] net: dsa: mxl-gsw1xx: reset the switch through reset-gpios
#18504
Author: netdev-bot+sashiko
Date: Wed, 18 Nov 2026 12:33
151 lines
13585 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] gsw1xx_probe() (drivers/net/dsa/lantiq/mxl-gsw1xx.c) can skip
  the switch reset without logging anything.
- [Low] gsw1xx_probe() pulses the hardware reset on every probe attempt:
  assert, fsleep(250000), deassert, fsleep(1000000).

--

net: dsa: mxl-gsw1xx: reset the switch through reset-gpios

This patch gets an optional reset control in gsw1xx_probe() and pulses it
before the first register access. The pulse is 250 ms asserted, then 1 s
before access, which is the timing from the vendor's GSW150 driver. It
also adds imply RESET_GPIO to the Kconfig entry and extends the help text.

> diff --git a/drivers/net/dsa/lantiq/mxl-gsw1xx.c b/drivers/net/dsa/lantiq/mxl-gsw1xx.c
> index 0c7ea242a62c2..33b73b2ed5fe7 100644
> --- a/drivers/net/dsa/lantiq/mxl-gsw1xx.c
> +++ b/drivers/net/dsa/lantiq/mxl-gsw1xx.c

[ ... ]

> @@ -737,6 +739,30 @@ static int gsw1xx_probe(struct mdio_device *mdiodev)
>  	if (!priv->gswip.hw_info)
>  		return -EINVAL;
>  
> +	/* The MDIO core handles reset-gpios only for PHYs. Reset the switch
> +	 * here, so it does not run with whatever the bootloader configured.
> +	 */
> +	reset = devm_reset_control_get_optional_exclusive(dev, NULL);
> +	if (IS_ERR(reset))
> +		return dev_err_probe(dev, PTR_ERR(reset),
> +				     "failed to get reset control\n");
> +
> +	if (reset) {

[Severity: Medium]
If the switch node has reset-gpios, can the reset still be skipped here
with no message at all?

In two configurations, devm_reset_control_get_optional_exclusive()
returns NULL even when reset-gpios is in the DT.

With CONFIG_RESET_CONTROLLER=n, the stub in include/linux/reset.h does:

    return optional ? NULL : ERR_PTR(-ENOTSUPP);

With CONFIG_RESET_GPIO=n, __fwnode_reset_control_get() in
drivers/reset/core.c returns before it tries the reset-gpios fallback:

    if (!IS_ENABLED(CONFIG_RESET_GPIO))
        return optional ? NULL : ERR_PTR(ret);

In both cases the if (reset) branch is not taken. Probe then continues
with the bootloader state. The commit message says this state makes port
0 fail with "failed to connect to PHY: -ENODEV".

The new help text in drivers/net/dsa/lantiq/Kconfig says:

    A switch whose hardware reset is described with reset-gpios is
    only reset when RESET_GPIO is enabled as well, which this option
    does by default.

Is this true for every config? RESET_GPIO is inside "if RESET_CONTROLLER"
and depends on GPIOLIB. RESET_CONTROLLER is only default y if
ARCH_HAS_RESET_CONTROLLER. NET_DSA_MXL_GSW1XX provides neither
dependency, so on x86 or generic MIPS, for example, the imply has no
effect.

The reset-gpios binding added earlier in this series describes it as the
switch's hardware reset input. It also says the slew rates return to
their power-on defaults "after a reset through reset-gpios". A DT that
follows the binding can silently get neither.

Other DSA drivers with a switch-level reset-gpios call
devm_gpiod_get_optional() directly, and that only needs GPIOLIB. Examples
are qca8k-8xxx.c, realtek/rtl83xx.c, mv88e6xxx/chip.c, lan9303-core.c,
vitesse-vsc73xx-core.c, mt7530-mdio.c and ksz_common.c.

Would that approach work here? If not, could probe at least warn or fail
when reset-gpios is present but no reset control was obtained? Could the
help text also name the RESET_CONTROLLER and GPIOLIB dependency?

> +		ret = reset_control_assert(reset);
> +		if (ret)
> +			return dev_err_probe(dev, ret,
> +					     "failed to assert reset\n");
> +
> +		fsleep(GSW1XX_RESET_ASSERT_US);
> +
> +		ret = reset_control_deassert(reset);
> +		if (ret)
> +			return dev_err_probe(dev, ret,
> +					     "failed to deassert reset\n");
> +
> +		fsleep(GSW1XX_RESET_DEASSERT_US);
> +	}

[Severity: Low]
Does this pulse the reset again on every probe attempt after
-EPROBE_DEFER?

The reset runs before gswip_probe_common() reaches dsa_register_switch().
dsa_register_switch() can return -EPROBE_DEFER, for example when the
conduit is not registered yet:

net/dsa/dsa.c:dsa_port_parse_of() {
    ...
		conduit = of_find_net_device_by_node(ethernet);
		of_node_put(ethernet);
		if (!conduit) {
			rtnl_unlock();
			return -EPROBE_DEFER;
		}
    ...
}

It also defers when the tagger module is not loaded yet.

For MDIO-attached switches, the conduit is often missing on the first
try. The MAC driver registers its MDIO bus, which probes the switch,
before it calls register_netdev(). That first attempt usually runs inside
the MAC driver's own probe.

Each retry resets the chip again and blocks for another 1.25 s, because
both fsleep() calls become msleep(). The commit message says this timing
is only known for the GSW150. Nothing breaks, since the next attempt
redoes the PCS init and the GPIO pin-mux, so the cost is boot time.

Could the reset be pulsed only once, or could the line state be kept
across probe attempts?

>  	priv->gswip.gswip = gsw1xx_regmap_init(priv, "switch",
>  					       GSW1XX_SWITCH_BASE, 0xfff);
>  	if (IS_ERR(priv->gswip.gswip))

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115-mxl-gsw1xx-reset-v4-0-4ecd18c922e2%40telaak.dev
Re: [PATCH net-next v4 2/2] net: dsa: mxl-gsw1xx: reset the switch through reset-gpios
#18517
Author: Daniel Golle
Date: Wed, 18 Nov 2026 13:07
34 lines
9128 bytes
On Sun, Nov 15, 2026 at 05:33:46PM -0500, Joseph Telaak via B4 Relay wrote:
> From: Joseph Telaak <joseph@telaak.dev>
> 
> The switch keeps the configuration the bootloader left in it, and the
> driver never resets it. The MDIO core asserts and releases reset-gpios
> only for PHY devices, so a reset line described on the switch node has
> no effect either.
> 
> On the GL.iNet GL-SFT1200, nothing answers at internal MDIO address 0
> after the bootloader, and the PHY that answers at each port's address
> belongs to the neighboring port, so port 0 fails with "failed to
> connect to PHY: -ENODEV". Describing the PHYs at the addresses they
> answer at is not enough: with them at 1 to 3 and no reset, neither LAN
> port passes traffic. After a hardware reset every PHY is back at its
> port's address and all ports work. GL.iNet's own firmware resets the
> switch from Linux too.
> 
> Get the reset through the reset controller API and pulse it before the
> first register access. The reset core hands a reset-gpios property to
> the reset-gpio driver, so a board that wires the reset this way needs
> CONFIG_RESET_GPIO; without it the reset is skipped. Imply it, so it is
> enabled by default, and say so in the help text. The timing follows the
> vendor's driver for the GSW150: asserted for 250 ms, then 1 s before the
> switch is accessed. No timing is known for the other GSW1xx parts, so
> they get the same.
> 
> The reset also returns the RGMII slew rates to their power-on defaults,
> so a board that uses reset-gpios sets the ones it needs in its device
> tree.
> 
> Signed-off-by: Joseph Telaak <joseph@telaak.dev>

Reviewed-by: Daniel Golle <daniel@makrotopia.org>
Re: [PATCH net-next v4 2/2] net: dsa: mxl-gsw1xx: reset the switch through reset-gpios
#18746
Author: Joseph Telaak
Date: Wed, 18 Nov 2026 20:16
26 lines
11593 bytes
On Wed, Nov 18, 2026 at 12:33:56PM +0000, netdev-bot+sashiko@kernel.org wrote:
> [Severity: Medium]
> If the switch node has reset-gpios, can the reset still be skipped here
> with no message at all?

Only in a kernel built without RESET_CONTROLLER or without RESET_GPIO,
and then the switch runs as the bootloader left it, as it did before
this patch. That is how an optional reset control behaves in every
driver that uses one. The driver uses the reset controller API rather
than devm_gpiod_get_optional() because Daniel asked for it in v1.

On the SF19A2890, the board this is for, the SoC's peripheral clock and
reset driver (under review on linux-clk) selects RESET_CONTROLLER, so
the imply does enable RESET_GPIO there by default. Selecting
RESET_CONTROLLER from this driver would turn the reset framework on in
every config that builds it, for one GPIO line; imply only takes effect
where RESET_GPIO can be enabled.

> Does this pulse the reset again on every probe attempt after
> -EPROBE_DEFER?

Yes, as in the realtek DSA drivers. The v4 changelog says why the pulse
stays in probe.

Joseph
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads