From: Zhao Liu <zhao1.liu@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org,
Dapeng Mi <dapeng1.mi@intel.com>, Zhao Liu <zhao1.liu@intel.com>
Subject: [PATCH 2/5] hw/timer/hpet: Adjust num_timers in hpet_init()
Date: Tue, 20 May 2025 23:27:47 +0800 [thread overview]
Message-ID: <20250520152750.2542612-3-zhao1.liu@intel.com> (raw)
In-Reply-To: <20250520152750.2542612-1-zhao1.liu@intel.com>
Currently, HPET adjusts num_timers in hpet_realize(), and doesn't change
it in any other place. And this field is initialized as a property.
Therefore, it's possible to move such adjustments to hept_init(), so
that Rust side can synchronize this change.
Adjust num_timers in hpet_init().
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/timer/hpet.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 0fd1337a1564..48b1a9289f83 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -682,6 +682,12 @@ static void hpet_init(Object *obj)
/* HPET Area */
memory_region_init_io(&s->iomem, obj, &hpet_ram_ops, s, "hpet", HPET_LEN);
sysbus_init_mmio(sbd, &s->iomem);
+
+ if (s->num_timers < HPET_MIN_TIMERS) {
+ s->num_timers = HPET_MIN_TIMERS;
+ } else if (s->num_timers > HPET_MAX_TIMERS) {
+ s->num_timers = HPET_MAX_TIMERS;
+ }
}
static void hpet_realize(DeviceState *dev, Error **errp)
@@ -710,11 +716,6 @@ static void hpet_realize(DeviceState *dev, Error **errp)
sysbus_init_irq(sbd, &s->irqs[i]);
}
- if (s->num_timers < HPET_MIN_TIMERS) {
- s->num_timers = HPET_MIN_TIMERS;
- } else if (s->num_timers > HPET_MAX_TIMERS) {
- s->num_timers = HPET_MAX_TIMERS;
- }
for (i = 0; i < HPET_MAX_TIMERS; i++) {
timer = &s->timer[i];
timer->qemu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, hpet_timer, timer);
--
2.34.1
next prev parent reply other threads:[~2025-05-20 15:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 15:27 [PATCH 0/5] hpet, rust: miscellaneous cleanup Zhao Liu
2025-05-20 15:27 ` [PATCH 1/5] hw/timer/hpet: Reorganize register decoding Zhao Liu
2025-05-20 15:27 ` Zhao Liu [this message]
2025-05-20 15:16 ` [PATCH 2/5] hw/timer/hpet: Adjust num_timers in hpet_init() Paolo Bonzini
2025-05-21 7:34 ` Zhao Liu
2025-05-20 15:27 ` [PATCH 3/5] rust/hpet: Drop BalCell wrapper for num_timers Zhao Liu
2025-05-20 15:27 ` [PATCH 4/5] rust: Fix Zhao's email address Zhao Liu
2025-05-20 15:57 ` Peter Maydell
2025-05-20 15:27 ` [PATCH 5/5] rust: Fix the typos in doc Zhao Liu
2025-05-20 15:43 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250520152750.2542612-3-zhao1.liu@intel.com \
--to=zhao1.liu@intel.com \
--cc=dapeng1.mi@intel.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).