From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Richard Henderson <rth@twiddle.net>,
Eduardo Habkost <ehabkost@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [PULL 09/15] pc: Implement -no-hpet as sugar for -machine hpet=on
Date: Fri, 30 Oct 2020 08:45:24 -0400 [thread overview]
Message-ID: <20201030124454.854286-10-mst@redhat.com> (raw)
In-Reply-To: <20201030124454.854286-1-mst@redhat.com>
From: Eduardo Habkost <ehabkost@redhat.com>
Get rid of yet another global variable.
The default will be hpet=on only if CONFIG_HPET=y.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20201021144716.1536388-1-ehabkost@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/i386/pc.h | 1 +
include/hw/i386/x86.h | 3 ---
hw/i386/pc.c | 63 +++++++++++++++++++++++++++++--------------
hw/i386/pc_piix.c | 2 +-
softmmu/vl.c | 4 +--
5 files changed, 47 insertions(+), 26 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 84639d0ebc..911e460097 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -43,6 +43,7 @@ typedef struct PCMachineState {
bool smbus_enabled;
bool sata_enabled;
bool pit_enabled;
+ bool hpet_enabled;
/* NUMA information: */
uint64_t numa_nodes;
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index bfa9cb2a25..739fac5087 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -126,7 +126,4 @@ qemu_irq x86_allocate_cpu_irq(void);
void gsi_handler(void *opaque, int n, int level);
void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
-/* hpet.c */
-extern int no_hpet;
-
#endif
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4e323755d0..416fb0e0f6 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1142,28 +1142,31 @@ void pc_basic_device_init(struct PCMachineState *pcms,
* Without KVM_CAP_PIT_STATE2, we cannot switch off the in-kernel PIT
* when the HPET wants to take over. Thus we have to disable the latter.
*/
- if (!no_hpet && (!kvm_irqchip_in_kernel() || kvm_has_pit_state2())) {
+ if (pcms->hpet_enabled && (!kvm_irqchip_in_kernel() ||
+ kvm_has_pit_state2())) {
hpet = qdev_try_new(TYPE_HPET);
- if (hpet) {
- /* For pc-piix-*, hpet's intcap is always IRQ2. For pc-q35-1.7
- * and earlier, use IRQ2 for compat. Otherwise, use IRQ16~23,
- * IRQ8 and IRQ2.
- */
- uint8_t compat = object_property_get_uint(OBJECT(hpet),
- HPET_INTCAP, NULL);
- if (!compat) {
- qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
- }
- sysbus_realize_and_unref(SYS_BUS_DEVICE(hpet), &error_fatal);
- sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE);
-
- for (i = 0; i < GSI_NUM_PINS; i++) {
- sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]);
- }
- pit_isa_irq = -1;
- pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);
- rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);
+ if (!hpet) {
+ error_report("couldn't create HPET device");
+ exit(1);
}
+ /* For pc-piix-*, hpet's intcap is always IRQ2. For pc-q35-1.7
+ * and earlier, use IRQ2 for compat. Otherwise, use IRQ16~23,
+ * IRQ8 and IRQ2.
+ */
+ uint8_t compat = object_property_get_uint(OBJECT(hpet),
+ HPET_INTCAP, NULL);
+ if (!compat) {
+ qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
+ }
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(hpet), &error_fatal);
+ sysbus_mmio_map(SYS_BUS_DEVICE(hpet), 0, HPET_BASE);
+
+ for (i = 0; i < GSI_NUM_PINS; i++) {
+ sysbus_connect_irq(SYS_BUS_DEVICE(hpet), i, gsi[i]);
+ }
+ pit_isa_irq = -1;
+ pit_alt_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT);
+ rtc_irq = qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT);
}
*rtc_state = mc146818_rtc_init(isa_bus, 2000, rtc_irq);
@@ -1535,6 +1538,20 @@ static void pc_machine_set_pit(Object *obj, bool value, Error **errp)
pcms->pit_enabled = value;
}
+static bool pc_machine_get_hpet(Object *obj, Error **errp)
+{
+ PCMachineState *pcms = PC_MACHINE(obj);
+
+ return pcms->hpet_enabled;
+}
+
+static void pc_machine_set_hpet(Object *obj, bool value, Error **errp)
+{
+ PCMachineState *pcms = PC_MACHINE(obj);
+
+ pcms->hpet_enabled = value;
+}
+
static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
@@ -1585,6 +1602,9 @@ static void pc_machine_initfn(Object *obj)
pcms->smbus_enabled = true;
pcms->sata_enabled = true;
pcms->pit_enabled = true;
+#ifdef CONFIG_HPET
+ pcms->hpet_enabled = true;
+#endif
pc_system_flash_create(pcms);
pcms->pcspk = isa_new(TYPE_PC_SPEAKER);
@@ -1705,6 +1725,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
object_class_property_add_bool(oc, PC_MACHINE_PIT,
pc_machine_get_pit, pc_machine_set_pit);
+
+ object_class_property_add_bool(oc, "hpet",
+ pc_machine_get_hpet, pc_machine_set_hpet);
}
static const TypeInfo pc_machine_info = {
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 0cf22a57ad..13d1628f13 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -216,7 +216,7 @@ static void pc_init1(MachineState *machine,
i440fx_state = NULL;
isa_bus = isa_bus_new(NULL, get_system_memory(), system_io,
&error_abort);
- no_hpet = 1;
+ pcms->hpet_enabled = false;
}
isa_bus_irqs(isa_bus, x86ms->gsi);
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 7c1c6d37ef..a537a0377f 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -146,7 +146,6 @@ static Chardev **serial_hds;
Chardev *parallel_hds[MAX_PARALLEL_PORTS];
int win2k_install_hack = 0;
int singlestep = 0;
-int no_hpet = 0;
int fd_bootchk = 1;
static int no_reboot;
int no_shutdown = 0;
@@ -3562,7 +3561,8 @@ void qemu_init(int argc, char **argv, char **envp)
qemu_opts_parse_noisily(olist, "acpi=off", false);
break;
case QEMU_OPTION_no_hpet:
- no_hpet = 1;
+ olist = qemu_find_opts("machine");
+ qemu_opts_parse_noisily(olist, "hpet=off", false);
break;
case QEMU_OPTION_no_reboot:
no_reboot = 1;
--
MST
next prev parent reply other threads:[~2020-10-30 12:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 12:45 [PULL 00/15] pc,pci,vhost,virtio: misc fixes Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 01/15] vhost-vdpa: negotiate VIRTIO_NET_F_STATUS with driver Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 02/15] vhost-vsock: set vhostfd to non-blocking mode Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 03/15] acpi/crs: Prevent bad ranges for host bridges Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 04/15] acpi/crs: Support ranges > 32b for hosts Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 05/15] hw/virtio/vhost-vdpa: Fix Coverity CID 1432864 Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 06/15] hw/pci: Extract pci_bus_change_irq_level() from pci_change_irq_level() Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 07/15] pci: Assert irqnum is between 0 and bus->nirqs in pci_bus_change_irq_level Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 08/15] vhost: Don't special case vq->used_phys in vhost_get_log_size() Michael S. Tsirkin
2020-10-30 12:45 ` Michael S. Tsirkin [this message]
2020-10-30 12:45 ` [PULL 10/15] pci: advertise a page aligned ATS Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 11/15] pci: Change error_report to assert(3) Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 12/15] pci: Disallow improper BAR registration for type 1 Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 13/15] vhost-blk: set features before setting inflight feature Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 14/15] virtio: skip guest index check on device load Michael S. Tsirkin
2020-10-30 12:45 ` [PULL 15/15] intel_iommu: Fix two misuse of "0x%u" prints Michael S. Tsirkin
2020-10-30 13:06 ` [PULL 00/15] pc,pci,vhost,virtio: misc fixes no-reply
-- strict thread matches above, loose matches on Subject: below --
2020-10-30 14:11 Michael S. Tsirkin
2020-10-30 14:12 ` [PULL 09/15] pc: Implement -no-hpet as sugar for -machine hpet=on Michael S. Tsirkin
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=20201030124454.854286-10-mst@redhat.com \
--to=mst@redhat.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).