[PATCH v4 0/2] Add read_poll_timeout_atomic support

FUJITA Tomonori posted 2 patches 1 month, 1 week ago
rust/helpers/time.c       |  5 +++
rust/kernel/io/poll.rs    | 72 ++++++++++++++++++++++++++++++++++++++-
rust/kernel/time/delay.rs | 37 ++++++++++++++++++++
3 files changed, 113 insertions(+), 1 deletion(-)
[PATCH v4 0/2] Add read_poll_timeout_atomic support
Posted by FUJITA Tomonori 1 month, 1 week ago
Add read_poll_timeout_atomic function which polls periodically until a
condition is met, an error occurs, or the attempt limit is reached.

This helper is used to wait for a condition in atomic context,
mirroring the C's read_poll_timeout_atomic().

In atomic context, the timekeeping infrastructure is unavailable, so
reliable time-based timeouts cannot be implemented. So instead, the
helper accepts a maximum number of attempts and busy-waits (udelay +
cpu_relax) between tries.

v4:
- update the comment on udelay
- add Alice and Andreas' Reviewed-by
v3: https://lore.kernel.org/lkml/20251026125458.2772103-1-fujita.tomonori@gmail.com/
- revert the function name
- simplify the example code
- add debug_assert to check the range for udelay
v2: https://lore.kernel.org/lkml/20251021071146.2357069-1-fujita.tomonori@gmail.com/
- use the attempt limit instead of timeout
- rename the function to read_poll_count_atomic
- add the comment about C's udelay behavior.
v1: https://lore.kernel.org/lkml/20250821035710.3692455-1-fujita.tomonori@gmail.com/

FUJITA Tomonori (2):
  rust: add udelay() function
  rust: Add read_poll_timeout_atomic function

 rust/helpers/time.c       |  5 +++
 rust/kernel/io/poll.rs    | 72 ++++++++++++++++++++++++++++++++++++++-
 rust/kernel/time/delay.rs | 37 ++++++++++++++++++++
 3 files changed, 113 insertions(+), 1 deletion(-)


base-commit: b0b7301b004301afe920b3d08caa6171dd3f4011
-- 
2.43.0
Re: [PATCH v4 0/2] Add read_poll_timeout_atomic support
Posted by Danilo Krummrich 1 month, 1 week ago
On Mon Nov 3, 2025 at 12:29 PM CET, FUJITA Tomonori wrote:

Applied to driver-core-testing, thanks!

> FUJITA Tomonori (2):
>   rust: add udelay() function
>   rust: Add read_poll_timeout_atomic function

    [ Adjust imports to use "kernel vertical" style. - Danilo ]
Re: [PATCH v4 0/2] Add read_poll_timeout_atomic support
Posted by Danilo Krummrich 1 month, 1 week ago
On 11/3/25 12:29 PM, FUJITA Tomonori wrote:
>   rust: add udelay() function
>   rust: Add read_poll_timeout_atomic function

@Andreas: Mind providing an ACK so I can pick this one up including the udelay()
patch?
Re: [PATCH v4 0/2] Add read_poll_timeout_atomic support
Posted by Andreas Hindborg 1 month, 1 week ago
Danilo Krummrich <dakr@kernel.org> writes:

> On 11/3/25 12:29 PM, FUJITA Tomonori wrote:
>>   rust: add udelay() function
>>   rust: Add read_poll_timeout_atomic function
>
> @Andreas: Mind providing an ACK so I can pick this one up including the udelay()
> patch?

Acked-by: Andreas Hindborg <a.hindborg@kernel.org>


Best regards,
Andreas Hindborg