@samitouri / QOSamiQemu / commits / 85379af120

hw/timer/hpet: Remove HPETState::hpet_offset_saved field

The HPETState::hpet_offset_saved boolean was only set in the hw_compat_2_11[] array, via the 'hpet-offset-saved=false' property. We removed all machines using that array, let's remove that property and all the code around it. Message-ID: <20250501230129.2596-6-philmd@linaro.org> [thuth: Adapted the rust part to the current master branch] Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20260306093134.27789-1-thuth@redhat.com>

Philippe Mathieu-Daudé committed May 1, 2025 at 23:17 UTC 85379af1202264c46322218d8c2937aaf3daa3ea
2 files changed +2 -16
hw/timer/hpet.c
+1 -8
@@ -75,7 +75,6 @@ struct HPETState {
75 QemuMutex lock;
76 MemoryRegion iomem;
77 uint64_t hpet_offset;
78 - bool hpet_offset_saved;
78 QemuSeqLock state_version;
79 qemu_irq irqs[HPET_NUM_IRQ_ROUTES];
80 uint32_t flags;
@@ -272,11 +271,6 @@ static int hpet_post_load(void *opaque, int version_id)
271 t->cmp64 = hpet_calculate_cmp64(t, s->hpet_counter, t->cmp);
272 t->last = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - NANOSECONDS_PER_SECOND;
273 }
275 - /* Recalculate the offset between the main counter and guest time */
276 - if (!s->hpet_offset_saved) {
277 - s->hpet_offset = ticks_to_ns(s->hpet_counter)
278 - - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
279 - }
274
275 return 0;
276 }
@@ -285,7 +279,7 @@ static bool hpet_offset_needed(void *opaque)
279 {
280 HPETState *s = opaque;
281
288 - return hpet_enabled(s) && s->hpet_offset_saved;
282 + return hpet_enabled(s);
283 }
284
285 static bool hpet_rtc_irq_level_needed(void *opaque)
@@ -766,7 +760,6 @@ static const Property hpet_device_properties[] = {
760 DEFINE_PROP_UINT8("timers", HPETState, num_timers, HPET_MIN_TIMERS),
761 DEFINE_PROP_BIT("msi", HPETState, flags, HPET_MSI_SUPPORT, false),
762 DEFINE_PROP_UINT32(HPET_INTCAP, HPETState, intcap, 0),
769 - DEFINE_PROP_BOOL("hpet-offset-saved", HPETState, hpet_offset_saved, true),
763 };
764
765 static void hpet_device_class_init(ObjectClass *klass, const void *data)
rust/hw/timer/hpet/src/device.rs
+1 -8
@@ -627,8 +627,6 @@ pub struct HPETState {
627 flags: u32,
628
629 hpet_offset_migration: BqlCell<u64>,
630 - #[property(rename = "hpet-offset-saved", default = true)]
631 - hpet_offset_saved: bool,
630
631 irqs: [InterruptSource; HPET_NUM_IRQ_ROUTES],
632 rtc_irq_level: BqlCell<u32>,
@@ -947,11 +945,6 @@ impl HPETState {
945 tn_regs.last = CLOCK_VIRTUAL.get_ns() - NANOSECONDS_PER_SECOND;
946 }
947
950 - // Recalculate the offset between the main counter and guest time
951 - if !self.hpet_offset_saved {
952 - self.hpet_offset_migration
953 - .set(ticks_to_ns(regs.counter) - CLOCK_VIRTUAL.get_ns());
954 - }
948 regs.hpet_offset = self.hpet_offset_migration.get();
949
950 Ok(())
@@ -962,7 +955,7 @@ impl HPETState {
955 }
956
957 fn is_offset_needed(&self) -> bool {
965 - self.regs.borrow().is_hpet_enabled() && self.hpet_offset_saved
958 + self.regs.borrow().is_hpet_enabled()
959 }
960
961 fn validate_num_timers(&self, _version_id: u8) -> bool {