mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] net: designware: wait longer for the MAC reset and report a timeout
@ 2026-10-25  9:35 Ahmad Fatoum
  2026-10-25  9:35 ` [PATCH 2/2] net: phy: mdio_bus: honour open-drain PHY reset GPIOs Ahmad Fatoum
  2026-10-26 13:01 ` [PATCH 1/2] net: designware: wait longer for the MAC reset and report a timeout Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-10-25  9:35 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The DMA soft reset completes only once the PHY supplies the RX clock,
which doesn't necessarily happen within 10 ms and indeed takes longer
on a Libre Computer Alta if eth_open_all() opens the interface right
after boot.

Let's wait 200 ms like Linux's dwmac_dma_reset() does since commit
56311a315da7 ("net: stmmac: dwmac_lib: enlarge dma reset timeout").

Also propagate the error through dwmac_ether_init(): so far, a possible
timeout while polling the bit was not propagated up to the probe.

Fixes: f0ae0c33f52c ("net: designware: Don't hang in reset with powered down phy")
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 drivers/net/designware.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index de7d3dcf1090..09d11b1d02a3 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -92,7 +92,7 @@ static int mac_reset(struct eth_device *dev)
 
 	start = get_time_ns();
 	while (readl(&dma_p->busmode) & DMAMAC_SRST) {
-		if (is_timeout(start, 10 * MSECOND)) {
+		if (is_timeout(start, 200 * MSECOND)) {
 			dev_err(&priv->netdev.dev, "MAC reset timeout\n");
 			return -EIO;
 		}
@@ -262,7 +262,9 @@ static int dwc_ether_open(struct eth_device *dev)
 	if (ret)
 		return ret;
 
-	dwc_ether_init(dev);
+	ret = dwc_ether_init(dev);
+	if (ret)
+		return ret;
 
 	descs_init(dev);
 
-- 
2.47.3




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

* [PATCH 2/2] net: phy: mdio_bus: honour open-drain PHY reset GPIOs
  2026-10-25  9:35 [PATCH 1/2] net: designware: wait longer for the MAC reset and report a timeout Ahmad Fatoum
@ 2026-10-25  9:35 ` Ahmad Fatoum
  2026-10-26 13:01 ` [PATCH 1/2] net: designware: wait longer for the MAC reset and report a timeout Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-10-25  9:35 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The PHY reset is requested through the legacy GPIO API, which knows
nothing about the GPIO_OPEN_DRAIN flag in the reset-gpios property. On
the Libre Computer Alta the RTL8211F's reset line is declared open drain,
and driving it high after the pulse leaves it low: the PHY stays in reset
and is never found. Released to input, the external pull-up takes over
and the PHY answers.

Let's request the GPIO as a descriptor so gpiolib applies the flags from
the device tree, as it does for every other consumer.

Fixes: 8fd3bb0f2284 ("phylib: add support for reset-gpios")
Assisted-by: Claude:fable-5.1
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 drivers/net/phy/mdio_bus.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 401206256127..7795fcf388d7 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -12,10 +12,9 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <common.h>
-#include <of_gpio.h>
 #include <driver.h>
 #include <init.h>
-#include <gpio.h>
+#include <linux/gpio/consumer.h>
 #include <clock.h>
 #include <net.h>
 #include <sched.h>
@@ -217,25 +216,16 @@ static bool of_mdiobus_child_is_phy(struct device_node *np)
  */
 static u64 of_mdiobus_reset_phy(struct mii_bus *bus, struct device_node *np)
 {
-	enum of_gpio_flags of_flags;
 	u32 reset_deassert_delay;
 	u32 reset_assert_delay;
-	unsigned long flags;
-	int gpio;
-	int ret;
+	struct gpio_desc *gpiod;
 
-	gpio = of_get_named_gpio_flags(np, "reset-gpios", 0, &of_flags);
-	if (!gpio_is_valid(gpio))
-		return 0;
-
-	flags = GPIOF_OUT_INIT_INACTIVE;
-	if (of_flags & OF_GPIO_ACTIVE_LOW)
-		flags |= GPIOF_ACTIVE_LOW;
-
-	ret = gpio_request_one(gpio, flags, np->name);
-	if (ret) {
-		dev_err(&bus->dev, "failed to request reset gpio for: %s\n",
-			np->name);
+	/* requested asserted, released below once the pulse is over */
+	gpiod = dev_gpiod_get(&bus->dev, np, "reset", GPIOD_OUT_HIGH, np->name);
+	if (IS_ERR(gpiod)) {
+		if (PTR_ERR(gpiod) != -ENOENT)
+			dev_err(&bus->dev, "failed to request reset gpio for: %s\n",
+				np->name);
 		return 0;
 	}
 
@@ -246,10 +236,9 @@ static u64 of_mdiobus_reset_phy(struct mii_bus *bus, struct device_node *np)
 	of_property_read_u32(np, "reset-deassert-us", &reset_deassert_delay);
 
 	/* reset the PHY */
-	dev_dbg(&bus->dev, "reset PHY with GPIO: %d\n", gpio);
-	gpio_set_active(gpio, 1);
+	dev_dbg(&bus->dev, "reset PHY %s\n", np->name);
 	udelay(reset_assert_delay);
-	gpio_set_active(gpio, 0);
+	gpiod_set_value(gpiod, 0);
 
 	return get_time_ns() + (u64)reset_deassert_delay * 1000;
 }
-- 
2.47.3




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

* Re: [PATCH 1/2] net: designware: wait longer for the MAC reset and report a timeout
  2026-10-25  9:35 [PATCH 1/2] net: designware: wait longer for the MAC reset and report a timeout Ahmad Fatoum
  2026-10-25  9:35 ` [PATCH 2/2] net: phy: mdio_bus: honour open-drain PHY reset GPIOs Ahmad Fatoum
@ 2026-10-26 13:01 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-10-26 13:01 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Sun, 25 Oct 2026 10:35:34 +0100, Ahmad Fatoum wrote:
> The DMA soft reset completes only once the PHY supplies the RX clock,
> which doesn't necessarily happen within 10 ms and indeed takes longer
> on a Libre Computer Alta if eth_open_all() opens the interface right
> after boot.
> 
> Let's wait 200 ms like Linux's dwmac_dma_reset() does since commit
> 56311a315da7 ("net: stmmac: dwmac_lib: enlarge dma reset timeout").
> 
> [...]

Applied, thanks!

[1/2] net: designware: wait longer for the MAC reset and report a timeout
      https://git.pengutronix.de/cgit/barebox/commit/?id=bd4f42074f79 (link may not be stable)
[2/2] net: phy: mdio_bus: honour open-drain PHY reset GPIOs
      https://git.pengutronix.de/cgit/barebox/commit/?id=b0d9e2bac7bf (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2026-10-26 13:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-25  9:35 [PATCH 1/2] net: designware: wait longer for the MAC reset and report a timeout Ahmad Fatoum
2026-10-25  9:35 ` [PATCH 2/2] net: phy: mdio_bus: honour open-drain PHY reset GPIOs Ahmad Fatoum
2026-10-26 13:01 ` [PATCH 1/2] net: designware: wait longer for the MAC reset and report a timeout Sascha Hauer

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