hpet: switch to fine-grained device locking
as a step towards lock-less HPET counter read, use per device locking instead of BQL. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/r/20250814160600.2327672-4-imammedo@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
4ae5e2b2bf
commit
7defb58baf
1 changed files with 6 additions and 0 deletions
|
|
@ -38,6 +38,7 @@
|
|||
#include "hw/timer/i8254.h"
|
||||
#include "system/address-spaces.h"
|
||||
#include "qom/object.h"
|
||||
#include "qemu/lockable.h"
|
||||
#include "trace.h"
|
||||
|
||||
struct hpet_fw_config hpet_fw_cfg = {.count = UINT8_MAX};
|
||||
|
|
@ -69,6 +70,7 @@ struct HPETState {
|
|||
SysBusDevice parent_obj;
|
||||
/*< public >*/
|
||||
|
||||
QemuMutex lock;
|
||||
MemoryRegion iomem;
|
||||
uint64_t hpet_offset;
|
||||
bool hpet_offset_saved;
|
||||
|
|
@ -428,6 +430,7 @@ static uint64_t hpet_ram_read(void *opaque, hwaddr addr,
|
|||
trace_hpet_ram_read(addr);
|
||||
addr &= ~4;
|
||||
|
||||
QEMU_LOCK_GUARD(&s->lock);
|
||||
/*address range of all global regs*/
|
||||
if (addr <= 0xff) {
|
||||
switch (addr) {
|
||||
|
|
@ -482,6 +485,7 @@ static void hpet_ram_write(void *opaque, hwaddr addr,
|
|||
int len = MIN(size * 8, 64 - shift);
|
||||
uint64_t old_val, new_val, cleared;
|
||||
|
||||
QEMU_LOCK_GUARD(&s->lock);
|
||||
trace_hpet_ram_write(addr, value);
|
||||
addr &= ~4;
|
||||
|
||||
|
|
@ -679,8 +683,10 @@ static void hpet_init(Object *obj)
|
|||
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
||||
HPETState *s = HPET(obj);
|
||||
|
||||
qemu_mutex_init(&s->lock);
|
||||
/* HPET Area */
|
||||
memory_region_init_io(&s->iomem, obj, &hpet_ram_ops, s, "hpet", HPET_LEN);
|
||||
memory_region_enable_lockless_io(&s->iomem);
|
||||
sysbus_init_mmio(sbd, &s->iomem);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue