fmb_timer is now started in 3 different places. The new function will encapsulate that to make sure mui is added in all cases.
Reviewed-by: Matthew Rosato <[email protected]> Signed-off-by: Konstantin Shkolnyy <[email protected]> --- hw/s390x/s390-pci-bus.c | 5 ++--- hw/s390x/s390-pci-inst.c | 14 ++++++++++---- include/hw/s390x/s390-pci-inst.h | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index c16941ace6..452264976d 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1864,9 +1864,8 @@ static bool s390_pci_device_post_load_errp(void *opaque, int version_id, } pbdev->fmb_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, fmb_update, pbdev); - timer_mod(pbdev->fmb_timer, - qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + - pbdev->pci_group->zpci_group.mui); + s390_pci_schedule_fmb_timer(pbdev, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)); } return true; } diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 9b701b4dff..a559b1dcec 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1135,9 +1135,16 @@ static int fmb_do_update(S390PCIBusDevice *pbdev, int offset, uint64_t val, return ret; } +void s390_pci_schedule_fmb_timer(S390PCIBusDevice *pbdev, uint64_t start) +{ + timer_mod(pbdev->fmb_timer, start + pbdev->pci_group->zpci_group.mui); +} + void fmb_update(void *opaque) { S390PCIBusDevice *pbdev = opaque; + + /* Must be read before updating U bit */ int64_t t = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); int i; @@ -1174,7 +1181,7 @@ void fmb_update(void *opaque) sizeof(pbdev->fmb.last_update))) { return; } - timer_mod(pbdev->fmb_timer, t + pbdev->pci_group->zpci_group.mui); + s390_pci_schedule_fmb_timer(pbdev, t); } static int mpcifc_reg_int_interp(S390PCIBusDevice *pbdev, ZpciFib *fib) @@ -1367,9 +1374,8 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar, timer_del(pbdev->fmb_timer); } pbdev->fmb_addr = fmb_addr; - timer_mod(pbdev->fmb_timer, - qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + - pbdev->pci_group->zpci_group.mui); + s390_pci_schedule_fmb_timer(pbdev, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)); break; } default: diff --git a/include/hw/s390x/s390-pci-inst.h b/include/hw/s390x/s390-pci-inst.h index 873773f621..86d75134b9 100644 --- a/include/hw/s390x/s390-pci-inst.h +++ b/include/hw/s390x/s390-pci-inst.h @@ -114,6 +114,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar, uintptr_t ra); void fmb_timer_free(S390PCIBusDevice *pbdev); void fmb_update(void *opaque); +void s390_pci_schedule_fmb_timer(S390PCIBusDevice *pbdev, uint64_t start); uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, S390IOTLBEntry *entry); #define ZPCI_IO_BAR_MIN 0 -- 2.34.1
