rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Add read_poll_timeout_atomic support
@ 2025-10-26 12:54 FUJITA Tomonori
  2025-10-26 12:54 ` [PATCH v3 1/2] rust: add udelay() function FUJITA Tomonori
  2025-10-26 12:54 ` [PATCH v3 2/2] rust: Add read_poll_timeout_atomic function FUJITA Tomonori
  0 siblings, 2 replies; 6+ messages in thread
From: FUJITA Tomonori @ 2025-10-26 12:54 UTC (permalink / raw)
  To: a.hindborg, alex.gaynor, aliceryhl, dakr, daniel.almeida, ojeda
  Cc: anna-maria, bjorn3_gh, boqun.feng, frederic, gary, jstultz,
	linux-kernel, lossin, lyude, rust-for-linux, sboyd, tglx, tmgross

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.


v2: https://lore.kernel.org/lkml/20251021071146.2357069-1-fujita.tomonori@gmail.com/
- revert the function name
- simplify the example code
- add debug_assert to check the range for udelay
v1: https://lore.kernel.org/lkml/20250821035710.3692455-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.


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 | 39 +++++++++++++++++++++
 3 files changed, 115 insertions(+), 1 deletion(-)


base-commit: 26c1a20bf7ce76e9afe4030f25bec20e3c63dcf8
-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-10-28  9:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-26 12:54 [PATCH v3 0/2] Add read_poll_timeout_atomic support FUJITA Tomonori
2025-10-26 12:54 ` [PATCH v3 1/2] rust: add udelay() function FUJITA Tomonori
2025-10-27  9:48   ` Andreas Hindborg
2025-10-28  9:55   ` Alice Ryhl
2025-10-26 12:54 ` [PATCH v3 2/2] rust: Add read_poll_timeout_atomic function FUJITA Tomonori
2025-10-28  9:56   ` Alice Ryhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).