From 0ab8594396e901a76af88fe49a54e1a9d1a4dbc0 Mon Sep 17 00:00:00 2001 From: Jonas Jelonek Date: Thu, 5 Mar 2026 21:21:39 +0000 Subject: [PATCH] realtek: pcs: rtl930x: limit loop iterations Calibration for RTL930x uses multiple iterations for several checks. While this is fine and needed, it shouldn't be allowed to run forever in trust that at some point there will always be a "valid" value causing a loop exit. This has occured a couple of times, causing the driver to loop forever in case something doesn't run as expected. To avoid this (and in general as a good practice) limit the affected loop to a rough estimate of 10 iterations instead of running possibly forever. The estimate is based on the fact that under normal conditions it usually takes 1 or 2 to iterations to succeed, more is likely never to succeed but 10 gives some reasonable headroom. Signed-off-by: Jonas Jelonek Link: https://github.com/openwrt/openwrt/pull/22450 Signed-off-by: Robert Marko --- target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c index c59b30a346..a6f6d4f763 100644 --- a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c +++ b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c @@ -2276,7 +2276,7 @@ static void rtpcs_930x_sds_do_rx_calibration_2_3(struct rtpcs_serdes *sds) pr_info("start_1.2.3 Foreground Calibration\n"); - while (1) { + for (int run = 0; run < 10; run++) { if (sds == even_sds) rtpcs_sds_write(sds, 0x1f, 0x2, 0x2f); /* REG_DBGO_SEL */ else