Skip to contentSkip to conversation

net: lwip: call sys_check_timeouts and schedule on rx

PATCH In review Tim Harvey 4 participants 16 messages May 30, 2025 – Jun 19, 2025 Networking

lore
Share & tools
lore

Tim Harvey

author
#0 lore raw

PATCH v2 1/5 net: lwip: call sys_check_timeouts and schedule on rx

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call net_lwip_rx()

---
 net/lwip/dhcp.c     | 1 -
 net/lwip/dns.c      | 1 -
 net/lwip/net-lwip.c | 7 +++++++
 net/lwip/ping.c     | 1 -
 net/lwip/tftp.c     | 1 -
 net/lwip/wget.c     | 1 -
 6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
 	/* Wait for DHCP to complete */
 	do {
 		net_lwip_rx(udev, netif);
-		sys_check_timeouts();
 		bound = dhcp_supplied_address(netif);
 		if (bound)
 			break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
 			net_lwip_rx(udev, netif);
 			if (dns_cb_arg.done)
 				break;
-			sys_check_timeouts();
 			if (ctrlc()) {
 				printf("\nAbort\n");
 				break;
net/lwip/net-lwip.c +7 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
 #include <lwip/etharp.h>
 #include <lwip/init.h>
 #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
 #include <net.h>
 #include <timer.h>
+#include <u-boot/schedule.h>
 
 /* xx:xx:xx:xx:xx:xx\0 */
 #define MAC_ADDR_STRLEN 18
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
 	int len;
 	int i;
 
+	/* lwIP timers */
+	sys_check_timeouts();
+	/* Other tasks and actions */
+	schedule();
+
 	if (!eth_is_active(udev))
 		return -EINVAL;
 
net/lwip/ping.c +0 -1
index d8042ceecf99..1390b914f7d8 100644
@@ -136,7 +136,6 @@ static int ping_loop(struct udevice *udev, const ip_addr_t *addr)
 	ping_send(&ctx);
 
 	do {
-		sys_check_timeouts();
 		net_lwip_rx(udev, netif);
 		if (ctx.alive)
 			break;
net/lwip/tftp.c +0 -1
index fae701bad2eb..7495dc077ba5 100644
@@ -200,7 +200,6 @@ static int tftp_loop(struct udevice *udev, ulong addr, char *fname,
 	sys_timeout(NO_RSP_TIMEOUT_MS, no_response, &ctx);
 	while (!ctx.done) {
 		net_lwip_rx(udev, netif);
-		sys_check_timeouts();
 		if (ctrlc()) {
 			printf("\nAbort\n");
 			ctx.done = ABORTED;
net/lwip/wget.c +0 -1
index ea1113e18b11..fcaf684e61da 100644
@@ -525,7 +525,6 @@ int wget_do_request(ulong dst_addr, char *uri)
 
 	while (!ctx.done) {
 		net_lwip_rx(udev, netif);
-		sys_check_timeouts();
 		if (ctrlc())
 			break;
 	}
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v2 2/5 net: lwip: enable IP_FRAG and IP_REASSEMBLY

Enable IP_FRAG and IP_REASSEMBLY to allow packets larger than MTU.

---
v2:
- added tags

---
 lib/lwip/u-boot/lwipopts.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/lwip/u-boot/lwipopts.h +2 -2
index edac74ff7a21..1818a445dc5e 100644
@@ -72,8 +72,8 @@
 
 #define IP_FORWARD                      0
 #define IP_OPTIONS_ALLOWED              1
-#define IP_REASSEMBLY                   0
-#define IP_FRAG                         0
+#define IP_REASSEMBLY                   1
+#define IP_FRAG                         1
 #define IP_REASS_MAXAGE                 3
 #define IP_REASS_MAX_PBUFS              4
 #define IP_FRAG_USES_STATIC_BUF         0
Signature · 1 line
2.25.1
Acked-by on v2 2/5
#2 lore raw

Re: [PATCH v2 2/5] net: lwip: enable IP_FRAG and IP_REASSEMBLY

Quoted 4 lines · Tim Harvey

Enable IP_FRAG and IP_REASSEMBLY to allow packets larger than MTU.

In future, please, address your patches to the email address [email protected] as indicated by get_maintainers.pl.

Quoted 22 lines

---
v2:
- added tags

---
  lib/lwip/u-boot/lwipopts.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
lib/lwip/u-boot/lwipopts.h +2 -2
index edac74ff7a21..1818a445dc5e 100644
@@ -72,8 +72,8 @@
 
  #define IP_FORWARD                      0
  #define IP_OPTIONS_ALLOWED              1
-#define IP_REASSEMBLY                   0
-#define IP_FRAG                         0
+#define IP_REASSEMBLY                   1
+#define IP_FRAG                         1
  #define IP_REASS_MAXAGE                 3
  #define IP_REASS_MAX_PBUFS              4
  #define IP_FRAG_USES_STATIC_BUF         0
author
#3 lore raw

PATCH v2 3/5 net: lwip: tftp: add support for setting blocksize at runtime

In reply to Tim Harvey

Add support for setting the blocksize at runtime via the tftpblocksize env variable as such is done with the legacy stack (CONFIG_NET).

---
v2:
- added tags

---
 net/lwip/tftp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/lwip/tftp.c +6 -1
index 7495dc077ba5..e7502a0cbab1 100644
@@ -156,8 +156,10 @@ static void no_response(void *arg)
 static int tftp_loop(struct udevice *udev, ulong addr, char *fname,
 		     ip_addr_t srvip, uint16_t srvport)
 {
+	int blksize = CONFIG_TFTP_BLOCKSIZE;
 	struct netif *netif;
 	struct tftp_ctx ctx;
+	const char *ep;
 	err_t err;
 
 	if (!fname || addr == 0)
@@ -186,7 +188,10 @@ static int tftp_loop(struct udevice *udev, ulong addr, char *fname,
 	if (!(err == ERR_OK || err == ERR_USE))
 		log_err("tftp_init_client err: %d\n", err);
 
-	tftp_client_set_blksize(CONFIG_TFTP_BLOCKSIZE);
+	ep = env_get("tftpblocksize");
+	if (ep)
+		blksize = simple_strtol(ep, NULL, 10);
+	tftp_client_set_blksize(blksize);
 
 	ctx.start_time = get_timer(0);
 	err = tftp_get(&ctx, &srvip, srvport, fname, TFTP_MODE_OCTET);
Signature · 1 line
2.25.1
author
#4 lore raw

PATCH v2 4/5 net: lwip: move dns init to common function

In reply to Tim Harvey

move the dns init including setting the dns servers from env vars to a common function as other commands that support hostname lookups will need this.

---
v2:
- added tags

---
 include/net-lwip.h  |  1 +
 net/lwip/dns.c      | 20 +-------------------
 net/lwip/net-lwip.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 19 deletions(-)
include/net-lwip.h +1 -0
index b762956e8fda..6b5eb1990fbf 100644
@@ -17,6 +17,7 @@ static inline int eth_is_on_demand_init(void)
 
 int eth_init_state_only(void); /* Set active state */
 
+int net_lwip_dns_init(void);
 int net_lwip_eth_start(void);
 struct netif *net_lwip_new_netif(struct udevice *udev);
 struct netif *net_lwip_new_netif_noip(struct udevice *udev);
net/lwip/dns.c +1 -19
index 738f8bf3196b..744040f26d29 100644
@@ -44,12 +44,9 @@ static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg)
 static int dns_loop(struct udevice *udev, const char *name, const char *var)
 {
 	struct dns_cb_arg dns_cb_arg = { };
-	bool has_server = false;
 	struct netif *netif;
 	ip_addr_t ipaddr;
-	ip_addr_t ns;
 	ulong start;
-	char *nsenv;
 	int ret;
 
 	dns_cb_arg.var = var;
@@ -58,22 +55,7 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
 	if (!netif)
 		return CMD_RET_FAILURE;
 
-	dns_init();
-
-	nsenv = env_get("dnsip");
-	if (nsenv && ipaddr_aton(nsenv, &ns)) {
-		dns_setserver(0, &ns);
-		has_server = true;
-	}
-
-	nsenv = env_get("dnsip2");
-	if (nsenv && ipaddr_aton(nsenv, &ns)) {
-		dns_setserver(1, &ns);
-		has_server = true;
-	}
-
-	if (!has_server) {
-		log_err("No valid name server (dnsip/dnsip2)\n");
+	if (net_lwip_dns_init()) {
 		net_lwip_remove_netif(netif);
 		return CMD_RET_FAILURE;
 	}
net/lwip/net-lwip.c +30 -0
index e8d4cc542ed8..23dccfef8993 100644
@@ -7,6 +7,7 @@
 #include <dm/uclass.h>
 #include <hexdump.h>
 #include <lwip/ip4_addr.h>
+#include <lwip/dns.h>
 #include <lwip/err.h>
 #include <lwip/netif.h>
 #include <lwip/pbuf.h>
@@ -139,6 +140,35 @@ static int get_udev_ipv4_info(struct udevice *dev, ip4_addr_t *ip,
 	return 0;
 }
 
+/*
+ * Initialize DNS via env
+ */
+int net_lwip_dns_init(void)
+{
+	bool has_server = false;
+	ip_addr_t ns;
+	char *nsenv;
+
+	nsenv = env_get("dnsip");
+	if (nsenv && ipaddr_aton(nsenv, &ns)) {
+		dns_setserver(0, &ns);
+		has_server = true;
+	}
+
+	nsenv = env_get("dnsip2");
+	if (nsenv && ipaddr_aton(nsenv, &ns)) {
+		dns_setserver(1, &ns);
+		has_server = true;
+	}
+
+	if (!has_server) {
+		log_err("No valid name server (dnsip/dnsip2)\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  * Initialize the network stack if needed and start the current device if valid
  */
Signature · 1 line
2.25.1
author
#5 lore raw

PATCH v2 5/5 net: lwip: wget: initialize dns if a hostname is used in a URL

In reply to Tim Harvey

Initialize dns servers if a hostname (vs ipaddr) is used in a URL. Otherwise the wget will fail without displaying an error due to dns_gethostbyname failing silently when no DNS servers are set unless you have previously performed a 'dns <arg>' command.

---
v2:
- added tags

---
 net/lwip/wget.c | 4 ++++
 1 file changed, 4 insertions(+)
net/lwip/wget.c +4 -0
index fcaf684e61da..2ca369db65a1 100644
@@ -460,6 +460,10 @@ int wget_do_request(ulong dst_addr, char *uri)
 	if (!netif)
 		return -1;
 
+	/* if URL with hostname init dns */
+	if (!ipaddr_aton(ctx.server_name, NULL) && net_lwip_dns_init())
+		return CMD_RET_FAILURE;
+
 	memset(&conn, 0, sizeof(conn));
 #if CONFIG_IS_ENABLED(WGET_HTTPS)
 	if (is_https) {
Signature · 1 line
2.25.1
#6 lore raw
In reply to Tim Harvey
Quoted 64 lines · Tim Harvey

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call

    net_lwip_rx()
---
  net/lwip/dhcp.c     | 1 -
  net/lwip/dns.c      | 1 -
  net/lwip/net-lwip.c | 7 +++++++
  net/lwip/ping.c     | 1 -
  net/lwip/tftp.c     | 1 -
  net/lwip/wget.c     | 1 -
  6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
  	/* Wait for DHCP to complete */
  	do {
  		net_lwip_rx(udev, netif);
-		sys_check_timeouts();
  		bound = dhcp_supplied_address(netif);
  		if (bound)
  			break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
  			net_lwip_rx(udev, netif);
  			if (dns_cb_arg.done)
  				break;
-			sys_check_timeouts();
  			if (ctrlc()) {
  				printf("\nAbort\n");
  				break;
net/lwip/net-lwip.c +2 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
  #include <lwip/etharp.h>
  #include <lwip/init.h>
  #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
  #include <net.h>
  #include <timer.h>
+#include <u-boot/schedule.h>
 
  /* xx:xx:xx:xx:xx:xx\0 */
  #define MAC_ADDR_STRLEN 18

net/lwip/net-lwip.c int net_lwip_rx(struct udevice *udev, struct netif *netif) · line 292

Quoted 7 lines
net/lwip/net-lwip.c +4 -0
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
  	int len;
  	int i;
 
+	/* lwIP timers */
+	sys_check_timeouts();
+	/* Other tasks and actions */
+	schedule(

Some scheduled tasks have a long duration, specifically video_sync_all() called via video_idle(). This change will lead to lost packages.

@Tom, Simon

The EFI code was impacted by 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()"). This added schedule() calls to EFI networking. Package losses can expected if schedule() takes more than 1 µs. This is much shorter than the time needed for synchronizing a 1 MiB frame buffer. The cyclic framework was explicitly meant for short duration function calls, not for long duration tasks like syncing the video frame buffer.

I think we should remove video_idle() from the cyclic framework. video_sync_all() should only be triggered if there is video output.

Best regards

Heinrich

Quoted 40 lines
net/lwip/net-lwip.c +1 -0
+
  	if (!eth_is_active(udev))
  		return -EINVAL;
 
net/lwip/ping.c +0 -1
index d8042ceecf99..1390b914f7d8 100644
@@ -136,7 +136,6 @@ static int ping_loop(struct udevice *udev, const ip_addr_t *addr)
  	ping_send(&ctx);
 
  	do {
-		sys_check_timeouts();
  		net_lwip_rx(udev, netif);
  		if (ctx.alive)
  			break;
net/lwip/tftp.c +0 -1
index fae701bad2eb..7495dc077ba5 100644
@@ -200,7 +200,6 @@ static int tftp_loop(struct udevice *udev, ulong addr, char *fname,
  	sys_timeout(NO_RSP_TIMEOUT_MS, no_response, &ctx);
  	while (!ctx.done) {
  		net_lwip_rx(udev, netif);
-		sys_check_timeouts();
  		if (ctrlc()) {
  			printf("\nAbort\n");
  			ctx.done = ABORTED;
net/lwip/wget.c +0 -1
index ea1113e18b11..fcaf684e61da 100644
@@ -525,7 +525,6 @@ int wget_do_request(ulong dst_addr, char *uri)
 
  	while (!ctx.done) {
  		net_lwip_rx(udev, netif);
-		sys_check_timeouts();
  		if (ctrlc())
  			break;
  	}
author
#7 lore raw
Quoted 89 lines · Heinrich Schuchardt
Quoted 64 lines · Tim Harvey

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call

    net_lwip_rx()
---
  net/lwip/dhcp.c     | 1 -
  net/lwip/dns.c      | 1 -
  net/lwip/net-lwip.c | 7 +++++++
  net/lwip/ping.c     | 1 -
  net/lwip/tftp.c     | 1 -
  net/lwip/wget.c     | 1 -
  6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
      /* Wait for DHCP to complete */
      do {
              net_lwip_rx(udev, netif);
-             sys_check_timeouts();
              bound = dhcp_supplied_address(netif);
              if (bound)
                      break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
                      net_lwip_rx(udev, netif);
                      if (dns_cb_arg.done)
                              break;
-                     sys_check_timeouts();
                      if (ctrlc()) {
                              printf("\nAbort\n");
                              break;
net/lwip/net-lwip.c +2 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
  #include <lwip/etharp.h>
  #include <lwip/init.h>
  #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
  #include <net.h>
  #include <timer.h>
+#include <u-boot/schedule.h>
 
  /* xx:xx:xx:xx:xx:xx\0 */
  #define MAC_ADDR_STRLEN 18

net/lwip/net-lwip.c int net_lwip_rx(struct udevice *udev, struct netif *netif) · line 292

Quoted 7 lines
net/lwip/net-lwip.c +4 -0
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
      int len;
      int i;
 
+     /* lwIP timers */
+     sys_check_timeouts();
+     /* Other tasks and actions */
+     schedule(

Some scheduled tasks have a long duration, specifically video_sync_all() called via video_idle(). This change will lead to lost packages.

@Tom, Simon

The EFI code was impacted by 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()"). This added schedule() calls to EFI networking. Package losses can expected if schedule() takes more than 1 µs. This is much shorter than the time needed for synchronizing a 1 MiB frame buffer. The cyclic framework was explicitly meant for short duration function calls, not for long duration tasks like syncing the video frame buffer.

Quoted 3 lines

I think we should remove video_idle() from the cyclic framework. video_sync_all() should only be triggered if there is video output.

Hi Heinrich,

It makes sense what you are saying but I don't have the hardware to test your scenario. Can you submit a patch for discussion with a fixes tag?

Best Regards,

Tim

author
#8 lore raw
Quoted 96 lines · Tim Harvey
Quoted 89 lines · Heinrich Schuchardt
Quoted 64 lines · Tim Harvey

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call

    net_lwip_rx()
---
  net/lwip/dhcp.c     | 1 -
  net/lwip/dns.c      | 1 -
  net/lwip/net-lwip.c | 7 +++++++
  net/lwip/ping.c     | 1 -
  net/lwip/tftp.c     | 1 -
  net/lwip/wget.c     | 1 -
  6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
      /* Wait for DHCP to complete */
      do {
              net_lwip_rx(udev, netif);
-             sys_check_timeouts();
              bound = dhcp_supplied_address(netif);
              if (bound)
                      break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
                      net_lwip_rx(udev, netif);
                      if (dns_cb_arg.done)
                              break;
-                     sys_check_timeouts();
                      if (ctrlc()) {
                              printf("\nAbort\n");
                              break;
net/lwip/net-lwip.c +2 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
  #include <lwip/etharp.h>
  #include <lwip/init.h>
  #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
  #include <net.h>
  #include <timer.h>
+#include <u-boot/schedule.h>
 
  /* xx:xx:xx:xx:xx:xx\0 */
  #define MAC_ADDR_STRLEN 18

net/lwip/net-lwip.c int net_lwip_rx(struct udevice *udev, struct netif *netif) · line 292

Quoted 7 lines
net/lwip/net-lwip.c +4 -0
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
      int len;
      int i;
 
+     /* lwIP timers */
+     sys_check_timeouts();
+     /* Other tasks and actions */
+     schedule(

Some scheduled tasks have a long duration, specifically video_sync_all() called via video_idle(). This change will lead to lost packages.

@Tom, Simon

The EFI code was impacted by 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()"). This added schedule() calls to EFI networking. Package losses can expected if schedule() takes more than 1 µs. This is much shorter than the time needed for synchronizing a 1 MiB frame buffer. The cyclic framework was explicitly meant for short duration function calls, not for long duration tasks like syncing the video frame buffer.

Quoted 3 lines

I think we should remove video_idle() from the cyclic framework. video_sync_all() should only be triggered if there is video output.

Quoted 5 lines

Hi Heinrich,

It makes sense what you are saying but I don't have the hardware to test your scenario. Can you submit a patch for discussion with a fixes tag?

Gentle ping here.

Can we get some discussion on the point Heinrich brings up about video_idle in cyclic? Without my patch here which this discussion is blocking, large lwIP network transfers are quite broken on boards with watchdogs.

Best Regards,

Tim

#9 lore raw
Quoted 103 lines · Tim Harvey
Quoted 96 lines · Tim Harvey
Quoted 89 lines · Heinrich Schuchardt
Quoted 64 lines · Tim Harvey

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call

    net_lwip_rx()
---
  net/lwip/dhcp.c     | 1 -
  net/lwip/dns.c      | 1 -
  net/lwip/net-lwip.c | 7 +++++++
  net/lwip/ping.c     | 1 -
  net/lwip/tftp.c     | 1 -
  net/lwip/wget.c     | 1 -
  6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
      /* Wait for DHCP to complete */
      do {
              net_lwip_rx(udev, netif);
-             sys_check_timeouts();
              bound = dhcp_supplied_address(netif);
              if (bound)
                      break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
                      net_lwip_rx(udev, netif);
                      if (dns_cb_arg.done)
                              break;
-                     sys_check_timeouts();
                      if (ctrlc()) {
                              printf("\nAbort\n");
                              break;
net/lwip/net-lwip.c +2 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
  #include <lwip/etharp.h>
  #include <lwip/init.h>
  #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
  #include <net.h>
  #include <timer.h>
+#include <u-boot/schedule.h>
 
  /* xx:xx:xx:xx:xx:xx\0 */
  #define MAC_ADDR_STRLEN 18

net/lwip/net-lwip.c int net_lwip_rx(struct udevice *udev, struct netif *netif) · line 292

Quoted 7 lines
net/lwip/net-lwip.c +4 -0
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
      int len;
      int i;
 
+     /* lwIP timers */
+     sys_check_timeouts();
+     /* Other tasks and actions */
+     schedule(

Some scheduled tasks have a long duration, specifically video_sync_all() called via video_idle(). This change will lead to lost packages.

@Tom, Simon

The EFI code was impacted by 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()"). This added schedule() calls to EFI networking. Package losses can expected if schedule() takes more than 1 µs. This is much shorter than the time needed for synchronizing a 1 MiB frame buffer. The cyclic framework was explicitly meant for short duration function calls, not for long duration tasks like syncing the video frame buffer.

Quoted 3 lines

I think we should remove video_idle() from the cyclic framework. video_sync_all() should only be triggered if there is video output.

Quoted 5 lines

Hi Heinrich,

It makes sense what you are saying but I don't have the hardware to test your scenario. Can you submit a patch for discussion with a fixes tag?

Quoted 6 lines

Gentle ping here.

Can we get some discussion on the point Heinrich brings up about video_idle in cyclic? Without my patch here which this discussion is blocking, large lwIP network transfers are quite broken on boards with watchdogs.

Another option might be to increase the watchdog timeout?

Regards,

Signature · 1 line
Jerome
Quoted 4 lines

Best Regards,

Tim

author
#10 lore raw
Quoted 107 lines · Jerome Forissier
Quoted 103 lines · Tim Harvey
Quoted 101 lines · Tim Harvey
Quoted 89 lines · Heinrich Schuchardt
Quoted 64 lines · Tim Harvey

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call

    net_lwip_rx()
---
  net/lwip/dhcp.c     | 1 -
  net/lwip/dns.c      | 1 -
  net/lwip/net-lwip.c | 7 +++++++
  net/lwip/ping.c     | 1 -
  net/lwip/tftp.c     | 1 -
  net/lwip/wget.c     | 1 -
  6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
      /* Wait for DHCP to complete */
      do {
              net_lwip_rx(udev, netif);
-             sys_check_timeouts();
              bound = dhcp_supplied_address(netif);
              if (bound)
                      break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
                      net_lwip_rx(udev, netif);
                      if (dns_cb_arg.done)
                              break;
-                     sys_check_timeouts();
                      if (ctrlc()) {
                              printf("\nAbort\n");
                              break;
net/lwip/net-lwip.c +2 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
  #include <lwip/etharp.h>
  #include <lwip/init.h>
  #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
  #include <net.h>
  #include <timer.h>
+#include <u-boot/schedule.h>
 
  /* xx:xx:xx:xx:xx:xx\0 */
  #define MAC_ADDR_STRLEN 18

net/lwip/net-lwip.c int net_lwip_rx(struct udevice *udev, struct netif *netif) · line 292

Quoted 7 lines
net/lwip/net-lwip.c +4 -0
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
      int len;
      int i;
 
+     /* lwIP timers */
+     sys_check_timeouts();
+     /* Other tasks and actions */
+     schedule(

Some scheduled tasks have a long duration, specifically video_sync_all() called via video_idle(). This change will lead to lost packages.

@Tom, Simon

The EFI code was impacted by 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()"). This added schedule() calls to EFI networking. Package losses can expected if schedule() takes more than 1 µs. This is much shorter than the time needed for synchronizing a 1 MiB frame buffer. The cyclic framework was explicitly meant for short duration function calls, not for long duration tasks like syncing the video frame buffer.

Quoted 3 lines

I think we should remove video_idle() from the cyclic framework. video_sync_all() should only be triggered if there is video output.

Hi Heinrich,

It makes sense what you are saying but I don't have the hardware to test your scenario. Can you submit a patch for discussion with a fixes tag?

Quoted 9 lines
Quoted 6 lines

Gentle ping here.

Can we get some discussion on the point Heinrich brings up about video_idle in cyclic? Without my patch here which this discussion is blocking, large lwIP network transfers are quite broken on boards with watchdogs.

Another option might be to increase the watchdog timeout?

Hi Jerome,

I don't think that makes much sense. Long transfers for compressed disk images can take minutes sometimes. It doesn't make sense to not call any cyclic's in that timeframe. Additionally its possible some older less capable watchdogs don't have that much flexibility in timeouts.

What Heinrich points out here seems valid but I'm not familiar with the video framework to work up a patch.

Best Regards,

Tim

#11 lore raw
Quoted 116 lines · Tim Harvey
Quoted 114 lines · Jerome Forissier
Quoted 109 lines · Tim Harvey
Quoted 96 lines · Tim Harvey
Quoted 89 lines · Heinrich Schuchardt
Quoted 64 lines · Tim Harvey

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call

    net_lwip_rx()
---
  net/lwip/dhcp.c     | 1 -
  net/lwip/dns.c      | 1 -
  net/lwip/net-lwip.c | 7 +++++++
  net/lwip/ping.c     | 1 -
  net/lwip/tftp.c     | 1 -
  net/lwip/wget.c     | 1 -
  6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
      /* Wait for DHCP to complete */
      do {
              net_lwip_rx(udev, netif);
-             sys_check_timeouts();
              bound = dhcp_supplied_address(netif);
              if (bound)
                      break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
                      net_lwip_rx(udev, netif);
                      if (dns_cb_arg.done)
                              break;
-                     sys_check_timeouts();
                      if (ctrlc()) {
                              printf("\nAbort\n");
                              break;
net/lwip/net-lwip.c +2 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
  #include <lwip/etharp.h>
  #include <lwip/init.h>
  #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
  #include <net.h>
  #include <timer.h>
+#include <u-boot/schedule.h>
 
  /* xx:xx:xx:xx:xx:xx\0 */
  #define MAC_ADDR_STRLEN 18

net/lwip/net-lwip.c int net_lwip_rx(struct udevice *udev, struct netif *netif) · line 292

Quoted 7 lines
net/lwip/net-lwip.c +4 -0
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
      int len;
      int i;
 
+     /* lwIP timers */
+     sys_check_timeouts();
+     /* Other tasks and actions */
+     schedule(

Some scheduled tasks have a long duration, specifically video_sync_all() called via video_idle(). This change will lead to lost packages.

@Tom, Simon

The EFI code was impacted by 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()"). This added schedule() calls to EFI networking. Package losses can expected if schedule() takes more than 1 µs. This is much shorter than the time needed for synchronizing a 1 MiB frame buffer. The cyclic framework was explicitly meant for short duration function calls, not for long duration tasks like syncing the video frame buffer.

Quoted 3 lines

I think we should remove video_idle() from the cyclic framework. video_sync_all() should only be triggered if there is video output.

Quoted 5 lines

Hi Heinrich,

It makes sense what you are saying but I don't have the hardware to test your scenario. Can you submit a patch for discussion with a fixes tag?

Gentle ping here.

Can we get some discussion on the point Heinrich brings up about video_idle in cyclic? Without my patch here which this discussion is blocking, large lwIP network transfers are quite broken on boards with watchdogs.

Quoted 7 lines
Quoted 2 lines

Another option might be to increase the watchdog timeout?

Hi Jerome,

I don't think that makes much sense. Long transfers for compressed disk images can take minutes sometimes. It doesn't make sense to not call any cyclic's in that timeframe.

Sorry I wasn't clear and I was mistaken. I was not suggesting not to call schedule() in the network receive loop, I was responding to the fact that schedule()->video_idle()->video_sync_all() can take a long time. I thought this would in turn cause issues with watchdogs (hence my question if the watchdog can be adjusted), while in fact the issue is packet loss. So please ignore my comment ;)
Not using the cyclic framework for this video thing is probably the right thing to do I guess.

Quoted 6 lines

Additionally its possible some
older less capable watchdogs don't have that much flexibility in timeouts.

What Heinrich points out here seems valid but I'm not familiar with the video framework to work up a patch.

Yeah, same.

Thanks,

Signature · 1 line
Jerome
Quoted 3 lines

Best Regards,

Tim

#12 lore raw
In reply to Heinrich Schuchardt
Quoted 85 lines · Heinrich Schuchardt
Quoted 63 lines · Tim Harvey

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call

    net_lwip_rx()
---
  net/lwip/dhcp.c     | 1 -
  net/lwip/dns.c      | 1 -
  net/lwip/net-lwip.c | 7 +++++++
  net/lwip/ping.c     | 1 -
  net/lwip/tftp.c     | 1 -
  net/lwip/wget.c     | 1 -
  6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
  	/* Wait for DHCP to complete */
  	do {
  		net_lwip_rx(udev, netif);
-		sys_check_timeouts();
  		bound = dhcp_supplied_address(netif);
  		if (bound)
  			break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
  			net_lwip_rx(udev, netif);
  			if (dns_cb_arg.done)
  				break;
-			sys_check_timeouts();
  			if (ctrlc()) {
  				printf("\nAbort\n");
  				break;
net/lwip/net-lwip.c +2 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
  #include <lwip/etharp.h>
  #include <lwip/init.h>
  #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
  #include <net.h>
  #include <timer.h>
+#include <u-boot/schedule.h>
  /* xx:xx:xx:xx:xx:xx\0 */
  #define MAC_ADDR_STRLEN 18

net/lwip/net-lwip.c int net_lwip_rx(struct udevice *udev, struct netif *netif) · line 291

Quoted 6 lines
net/lwip/net-lwip.c +4 -0
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
  	int len;
  	int i;
+	/* lwIP timers */
+	sys_check_timeouts();
+	/* Other tasks and actions */
+	schedule(

Some scheduled tasks have a long duration, specifically video_sync_all() called via video_idle(). This change will lead to lost packages.

@Tom, Simon

The EFI code was impacted by 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()"). This added schedule() calls to EFI networking. Package losses can expected if schedule() takes more than 1 µs. This is much shorter than the time needed for synchronizing a 1 MiB frame buffer. The cyclic framework was explicitly meant for short duration function calls, not for long duration tasks like syncing the video frame buffer.

Quoted 2 lines

I think we should remove video_idle() from the cyclic framework. video_sync_all() should only be triggered if there is video output.

So for testing purposes, if CYCLIC is disabled but LWIP is enabled, things are fine here? And so we need to at least partially revert commit 5c8dddadf1c9 ("video: Use cyclic to handle video sync") if not fully revert it?

Signature · 1 line
Tom
author
#13 lore raw
Quoted 87 lines · Tom Rini
Quoted 85 lines · Heinrich Schuchardt
Quoted 63 lines · Tim Harvey

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call

    net_lwip_rx()
---
  net/lwip/dhcp.c     | 1 -
  net/lwip/dns.c      | 1 -
  net/lwip/net-lwip.c | 7 +++++++
  net/lwip/ping.c     | 1 -
  net/lwip/tftp.c     | 1 -
  net/lwip/wget.c     | 1 -
  6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
    /* Wait for DHCP to complete */
    do {
            net_lwip_rx(udev, netif);
-           sys_check_timeouts();
            bound = dhcp_supplied_address(netif);
            if (bound)
                    break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
                    net_lwip_rx(udev, netif);
                    if (dns_cb_arg.done)
                            break;
-                   sys_check_timeouts();
                    if (ctrlc()) {
                            printf("\nAbort\n");
                            break;
net/lwip/net-lwip.c +2 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
  #include <lwip/etharp.h>
  #include <lwip/init.h>
  #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
  #include <net.h>
  #include <timer.h>
+#include <u-boot/schedule.h>
  /* xx:xx:xx:xx:xx:xx\0 */
  #define MAC_ADDR_STRLEN 18

net/lwip/net-lwip.c int net_lwip_rx(struct udevice *udev, struct netif *netif) · line 291

Quoted 6 lines
net/lwip/net-lwip.c +4 -0
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
    int len;
    int i;
+   /* lwIP timers */
+   sys_check_timeouts();
+   /* Other tasks and actions */
+   schedule(

Some scheduled tasks have a long duration, specifically video_sync_all() called via video_idle(). This change will lead to lost packages.

@Tom, Simon

The EFI code was impacted by 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()"). This added schedule() calls to EFI networking. Package losses can expected if schedule() takes more than 1 µs. This is much shorter than the time needed for synchronizing a 1 MiB frame buffer. The cyclic framework was explicitly meant for short duration function calls, not for long duration tasks like syncing the video frame buffer.

Quoted 7 lines
Quoted 2 lines

I think we should remove video_idle() from the cyclic framework. video_sync_all() should only be triggered if there is video output.

So for testing purposes, if CYCLIC is disabled but LWIP is enabled, things are fine here? And so we need to at least partially revert commit 5c8dddadf1c9 ("video: Use cyclic to handle video sync") if not fully revert it?

Hi Tom,

I can't disable CYCLIC without also disabling WDT which then works fine as the watchdog isn't being used.

You are likely pointing to the correct patch that is causing Heinrich's issue but as far as I know he has the hardware/configuration needed to test this and I don't know how to re-create his issue.

So in my opinion there is nothing wrong with my patch here and it's more of an issue with the video using cyclic for video sync.

Best Regards,

Tim

author
#14 lore raw
Quoted 102 lines · Tim Harvey
Quoted 87 lines · Tom Rini
Quoted 85 lines · Heinrich Schuchardt
Quoted 63 lines · Tim Harvey

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call

    net_lwip_rx()
---
  net/lwip/dhcp.c     | 1 -
  net/lwip/dns.c      | 1 -
  net/lwip/net-lwip.c | 7 +++++++
  net/lwip/ping.c     | 1 -
  net/lwip/tftp.c     | 1 -
  net/lwip/wget.c     | 1 -
  6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
    /* Wait for DHCP to complete */
    do {
            net_lwip_rx(udev, netif);
-           sys_check_timeouts();
            bound = dhcp_supplied_address(netif);
            if (bound)
                    break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
                    net_lwip_rx(udev, netif);
                    if (dns_cb_arg.done)
                            break;
-                   sys_check_timeouts();
                    if (ctrlc()) {
                            printf("\nAbort\n");
                            break;
net/lwip/net-lwip.c +2 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
  #include <lwip/etharp.h>
  #include <lwip/init.h>
  #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
  #include <net.h>
  #include <timer.h>
+#include <u-boot/schedule.h>
  /* xx:xx:xx:xx:xx:xx\0 */
  #define MAC_ADDR_STRLEN 18

net/lwip/net-lwip.c int net_lwip_rx(struct udevice *udev, struct netif *netif) · line 291

Quoted 6 lines
net/lwip/net-lwip.c +4 -0
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
    int len;
    int i;
+   /* lwIP timers */
+   sys_check_timeouts();
+   /* Other tasks and actions */
+   schedule(

Some scheduled tasks have a long duration, specifically video_sync_all() called via video_idle(). This change will lead to lost packages.

@Tom, Simon

The EFI code was impacted by 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()"). This added schedule() calls to EFI networking. Package losses can expected if schedule() takes more than 1 µs. This is much shorter than the time needed for synchronizing a 1 MiB frame buffer. The cyclic framework was explicitly meant for short duration function calls, not for long duration tasks like syncing the video frame buffer.

Quoted 7 lines
Quoted 2 lines

I think we should remove video_idle() from the cyclic framework. video_sync_all() should only be triggered if there is video output.

So for testing purposes, if CYCLIC is disabled but LWIP is enabled, things are fine here? And so we need to at least partially revert commit 5c8dddadf1c9 ("video: Use cyclic to handle video sync") if not fully revert it?

Hi Tom,

I can't disable CYCLIC without also disabling WDT which then works fine as the watchdog isn't being used.

Quoted 8 lines

You are likely pointing to the correct patch that is causing Heinrich's issue but as far as I know he has the hardware/configuration needed to test this and I don't know how to re-create his issue.

So in my opinion there is nothing wrong with my patch here and it's more of an issue with the video using cyclic for video sync.

Incidentally, I've noticed that I only have this watchdog-not-getting-reset issue when using the IMX FEC driver. The IMX QOS (imx8mp) has calls to udelay in the packet send and udelay calls schedule. I'm not sure how many network drivers out there end up calling udelay/schedule on their own.

Best Regards,

Tim

Reviewed-by
#15 lore raw
Quoted 103 lines · Tim Harvey
Quoted 102 lines · Tim Harvey
Quoted 87 lines · Tom Rini
Quoted 85 lines · Heinrich Schuchardt
Quoted 63 lines · Tim Harvey

Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx.

As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx().

This resolves the issue of an active watchdog resetting the board on long network activities.

---
v2:
- remove duplication of sys_check_timeouts() from functions that call

    net_lwip_rx()
---
  net/lwip/dhcp.c     | 1 -
  net/lwip/dns.c      | 1 -
  net/lwip/net-lwip.c | 7 +++++++
  net/lwip/ping.c     | 1 -
  net/lwip/tftp.c     | 1 -
  net/lwip/wget.c     | 1 -
  6 files changed, 7 insertions(+), 5 deletions(-)
net/lwip/dhcp.c +0 -1
index 92bd7067a7fb..b79b746db390 100644
@@ -57,7 +57,6 @@ static int dhcp_loop(struct udevice *udev)
    /* Wait for DHCP to complete */
    do {
            net_lwip_rx(udev, netif);
-           sys_check_timeouts();
            bound = dhcp_supplied_address(netif);
            if (bound)
                    break;
net/lwip/dns.c +0 -1
index 19172ac959ac..738f8bf3196b 100644
@@ -91,7 +91,6 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
                    net_lwip_rx(udev, netif);
                    if (dns_cb_arg.done)
                            break;
-                   sys_check_timeouts();
                    if (ctrlc()) {
                            printf("\nAbort\n");
                            break;
net/lwip/net-lwip.c +2 -0
index f05c4cd3f64f..e8d4cc542ed8 100644
@@ -13,8 +13,10 @@
  #include <lwip/etharp.h>
  #include <lwip/init.h>
  #include <lwip/prot/etharp.h>
+#include <lwip/timeouts.h>
  #include <net.h>
  #include <timer.h>
+#include <u-boot/schedule.h>
  /* xx:xx:xx:xx:xx:xx\0 */
  #define MAC_ADDR_STRLEN 18

net/lwip/net-lwip.c int net_lwip_rx(struct udevice *udev, struct netif *netif) · line 291

Quoted 6 lines
net/lwip/net-lwip.c +4 -0
@@ -284,6 +286,11 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif)
    int len;
    int i;
+   /* lwIP timers */
+   sys_check_timeouts();
+   /* Other tasks and actions */
+   schedule(

Some scheduled tasks have a long duration, specifically video_sync_all() called via video_idle(). This change will lead to lost packages.

@Tom, Simon

The EFI code was impacted by 29caf9305b6f ("cyclic: Use schedule() instead of WATCHDOG_RESET()"). This added schedule() calls to EFI networking. Package losses can expected if schedule() takes more than 1 µs. This is much shorter than the time needed for synchronizing a 1 MiB frame buffer. The cyclic framework was explicitly meant for short duration function calls, not for long duration tasks like syncing the video frame buffer.

Quoted 7 lines
Quoted 2 lines

I think we should remove video_idle() from the cyclic framework. video_sync_all() should only be triggered if there is video output.

So for testing purposes, if CYCLIC is disabled but LWIP is enabled, things are fine here? And so we need to at least partially revert commit 5c8dddadf1c9 ("video: Use cyclic to handle video sync") if not fully revert it?

Hi Tom,

I can't disable CYCLIC without also disabling WDT which then works fine as the watchdog isn't being used.

Quoted 7 lines
Quoted 7 lines

You are likely pointing to the correct patch that is causing Heinrich's issue but as far as I know he has the hardware/configuration needed to test this and I don't know how to re-create his issue.

So in my opinion there is nothing wrong with my patch here and it's more of an issue with the video using cyclic for video sync.

I agree. This patch is:

...and I will add the whole series in my next PR to Tom.

Thanks,

Signature · 1 line
Jerome
Quoted 11 lines
Quoted 1 line

Incidentally, I've noticed that I only have this watchdog-not-getting-reset issue when using the IMX FEC driver. The IMX QOS (imx8mp) has calls to udelay in the packet send and udelay calls schedule. I'm not sure how many network drivers out there end up calling udelay/schedule on their own.

Best Regards,

Tim