__hwspin_lock_timeout(9)
π
__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 themodeisHWLOCK_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:
__hwspin_trylock(9)__hwspin_unlock(9)hwspin_lock_bust(9)of_hwspin_lock_simple_xlate(9)of_hwspin_lock_get_id(9)of_hwspin_lock_get_id_byname(9)hwspin_lock_register(9)hwspin_lock_unregister(9)devm_hwspin_lock_unregister(9)devm_hwspin_lock_register(9)__hwspin_lock_request(9)hwspin_lock_request_specific(9)hwspin_lock_free(9)devm_hwspin_lock_free(9)devm_hwspin_lock_request_specific(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms