Re: [PATCH v2 3/4] rtc: Add support for configuring the UIP timeout for RTC reads

From: Mateusz Jończyk
Date: Wed Nov 22 2023 - 12:06:21 EST


W dniu 20.11.2023 o 15:15, Mario Limonciello pisze:
> The UIP timeout is hardcoded to 10ms for all RTC reads, but in some
> contexts this might not be enough time. Add a timeout parameter to
> mc146818_get_time() and mc146818_get_time_callback().
>
> If UIP timeout is configured by caller to be >=100 ms and a call
> takes this long, log a warning.
>
> Make all callers use 10ms to ensure no functional changes.
>
> Cc: stable@xxxxxxxxxxxxxxx # 6.1.y: commit d2a632a8a117 ("rtc: mc146818-lib: reduce RTC_UIP polling period")

I was wrong and
commit d2a632a8a117 ("rtc: mc146818-lib: reduce RTC_UIP polling period") is
included in 6.1.y anyway (was merged before 6.1-rc1), does not have to be
mentioned in the line above.

> Fixes: ec5895c0f2d8 ("rtc: mc146818-lib: extract mc146818_avoid_UIP")
> Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
> ---
> v1->v2:
> * Add a warning if 100ms or more
> * Add stable and fixes tags
> ---
[snip]
> @@ -72,6 +76,9 @@ bool mc146818_avoid_UIP(void (*callback)(unsigned char seconds, void *param),
> }
> spin_unlock_irqrestore(&rtc_lock, flags);
>
> + if (i >= UIP_RECHECK_TIMEOUT_MS(100))
> + pr_warn("RTC took %d iterations to clear UIP\n", i);
> +
This warning message is difficult to understand for someone that is not familiar
with
the code / MC146818 documentation.
"Reading current time from RTC took around %d ms" would be better.
> return true;
> }
> return false;

Greetings,

Mateusz