hwspin_unlock_irqrestore(9)
π hwspin_unlock_irqrestore β Kernel API Manual, bestie edition β¨
okay so you're looking at hwspin_unlock_irqrestore(9) from the Kernel API Manual and honestly? she's the cleanup queen π β the one you call when you've already grabbed your lock and you need to put everything back exactly how you found it. no cap.
πΈ NAME πΈ
hwspin_unlock_irqrestore β unlock hwspinlock, restore irq state π
β¨ SYNOPSIS β¨
void hwspin_unlock_irqrestore (struct hwspinlock *hwlock , unsigned long
*flags );
like, that's the whole signature. two args. she's lowkey elegant π
π¦ ARGUMENTS π¦
hwlockβ a previously-acquired hwspinlock which we want to unlock π this is the one you already grabbed, bestie, we're letting her goflagsβ previous caller's interrupt state to restore π«Ά the interrupt state from whoever called us, handed back so we can put it right back where it belongs
π DESCRIPTION π
so what does she actually do? three things, and she does them all in one go, main character energy fr fr:
This function will unlock a specific hwspinlock, enable preemption and restore the previous state of the local interrupts. π It should be used to undo, e.g., hwspin_trylock_irqsave.
think of it as the undo button for hwspin_trylock_irqsave β you locked, you saved the irq state, and now you're reversing out of it. it's giving symmetry. it's giving closure. it's giving responsible kernel developer π
β οΈ okay real talk though β hwlock must be already locked before calling this function: it is a bug to call unlock on a hwlock that is already unlocked. not a vibe. not a slay. that's a bug, periodt. π if you're out here unlocking something that was never locked, the kernel is gonna have opinions and none of them are cute.
π SEE ALSO π
Kernel file ./include/linux/hwspinlock.h π β and the whole friend group, because she does not exist in a vacuum, iykyk:
hwspin_trylock_irqsave(9)hwspin_trylock_irq(9)hwspin_trylock_raw(9)hwspin_trylock_in_atomic(9)hwspin_trylock(9)hwspin_lock_timeout_irqsave(9)hwspin_lock_timeout_irq(9)hwspin_lock_timeout_raw(9)hwspin_lock_timeout_in_atomic(9)hwspin_lock_timeout(9)hwspin_unlock_irq(9)hwspin_unlock_raw(9)hwspin_unlock_in_atomic(9)hwspin_unlock(9)
πΈ cute sign-off time πΈ β this lil page lives under ./include/linux, dated October 2026, and it's literally called hwspin_unlock_irqrestore(9). go lock responsibly, bestie. 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