]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: pcs: rtl930x: limit loop iterations
authorJonas Jelonek <jelonek.jonas@gmail.com>
Thu, 5 Mar 2026 21:21:39 +0000 (21:21 +0000)
committerRobert Marko <robimarko@gmail.com>
Sat, 21 Mar 2026 22:06:10 +0000 (23:06 +0100)
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 <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/22450
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c

index c59b30a346d514168bac753426b560b319b69b5c..a6f6d4f763c899ff3af95f0d5b5f10580c0ef70b 100644 (file)
@@ -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