__hwspin_lock_timeout(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __hwspin_lock_timeout(9) πŸ’…

okay bestie, welcome to the Kernel API Manual β€” we're talking about __hwspin_lock_timeout, and it's literally giving β€œlock an hwspinlock with timeout limit” energy ✨ let's go.

🌸 NAME 🌸

__hwspin_lock_timeout β€” lock an hwspinlock with timeout limit πŸŽ€

πŸ¦‹ SYNOPSIS πŸ¦‹

int __hwspin_lock_timeout (struct hwspinlock *hwlock , unsigned int to ,
       int mode , unsigned long *flags );

🧚 ARGUMENTS 🧚

  • hwlock β€” the hwspinlock to be locked πŸ”’
  • to β€” timeout value in msecs ⏳
  • mode β€” mode which controls whether local interrupts are disabled or not πŸŽ›οΈ
  • flags β€” a pointer to where the caller's interrupt state will be saved at (if requested) πŸ’Ύ

✨ DESCRIPTION ✨

This function locks the given hwlock. If the hwlock is already taken, the function will busy loop waiting for it to be released, but give up after timeout msecs have elapsed 😭

⚠️ Caution, bestie: If the mode is HWLOCK_RAW, that means user must protect the routine of getting hardware lock with mutex or spinlock. Since in some scenarios, user need some time-consuming or sleepable operations under the hardware lock, they need one sleepable lock (like mutex) to protect the operations. no cap, pay attention to this one πŸ’€

If the mode is HWLOCK_IN_ATOMIC (called from an atomic context) the timeout is handled with busy-waiting delays, hence shall not exceed few msecs. ⏱️

If the mode is neither HWLOCK_IN_ATOMIC nor HWLOCK_RAW, upon a successful return from this function, preemption (and possibly interrupts) is disabled, so the caller must not sleep, and is advised to release the hwspinlock as soon as possible. This is required in order to minimize remote cores polling on the hardware interconnect πŸ‘‘πŸ”₯

The user decides whether local interrupts are disabled or not, and if yes, whether he wants their previous state to be saved. It is up to the user to choose the appropriate mode of operation, exactly the same way users should decide between spin_lock, spin_lock_irq and spin_lock_irqsave 🫢

The function will never sleep. never. periodt πŸ’…

🌈 RETURN 🌈

0 when the hwlock was successfully taken, and an appropriate error code otherwise (most notably -ETIMEDOUT if the hwlock is still busy after timeout msecs). 🫑

πŸ’– SEE ALSO πŸ’–

peep the kernel file ./drivers/hwspinlock/hwspinlock_core.c plus these icons:


okay that's the whole vibe πŸ’– β€” sourced from ./drivers/hwspinlock, dated October 2026, and it's all about __hwspin_lock_timeout(9) at the very end. mwah πŸ«ΆπŸ’‹

πŸ“¦ where this page comes from