mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
Lockless IO requires to lock the registers during MMIO access. So it's necessary to get (or borrow) registers data at top level, and not to borrow again in child function calls. Change the argument types from BqlRefCell<HPETRegisters> to &HPETRegisters/&mut HPETRegisters in child methods, and do borrow the data once at top level. This allows BqlRefCell<HPETRegisters> to be directly replaced with Mutex<HPETRegisters> in subsequent steps without causing lock reentrancy issues. Note, passing reference instead of BqlRef/BqlRefMut because BqlRefMut cannot be re-borrowed as BqlRef, though BqlRef/BqlRefMut themselves play as the "guard". Passing reference is directly and the extra bql::is_locked check could help to consolidate safety guarantee. Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20251113051937.4017675-19-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>