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 <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/22450
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Jonas Jelonek 2026-03-05 21:21:39 +00:00 committed by Robert Marko
parent 92e7876477
commit 0ab8594396

View 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