From nobody Wed May 15 02:49:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672735876; cv=none; d=zohomail.com; s=zohoarc; b=DoTAxFu4N24s62hy8p47SGkXT6YwVfHy3jNLkrPsjmtMhGMBYSkAhF7M8+f6qIcFYO69SbXnIY7XQlYzJJFP1txf3KrIaG11TWQux/XGVSXB+Ronni0VboRF8olBo/9ffL733jGazDF9YtPmV22fgkg4+UyEyZfVUEIYoliPuec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672735876; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W4J5XF+GdZZ0UzQNX2tdo924NG6UaFX7Rr6HkoV0EVo=; b=RolZbcubq6r7DpN99NFJRkSS7ziFhFTyqDFrgu3mOVI6SX0NIfibFrmrJlbJPJkQbQoCWSFuY3PXb8HcDDiCBBSIvu+YvTWdVf+LkAehCiy/H8lxr/NSvc2i5gtr5bDNVhQql1QbS+EqcSIYJJI3UaA389WOIu6wH0hJ+McAKeU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672735876213489.5064946667409; Tue, 3 Jan 2023 00:51:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCcya-0001dq-N3; Tue, 03 Jan 2023 03:48:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcy3-0001aK-NW for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcy1-0007WJ-SQ for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:19 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-PcL2CAAnPROun5EdeIGXkQ-1; Tue, 03 Jan 2023 03:48:11 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7766D380673B; Tue, 3 Jan 2023 08:48:10 +0000 (UTC) Received: from thuth.com (unknown [10.39.193.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id A72AD40C1141; Tue, 3 Jan 2023 08:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672735696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W4J5XF+GdZZ0UzQNX2tdo924NG6UaFX7Rr6HkoV0EVo=; b=YH4eC3N3a40tlhcvMm0idGs77IuXO/affVatBg9QMFioQy1PU47r12lj7y9zzrmL6zbWY5 +IIeE3dlUxUk+y6bvcJRR61xqGcCCzq9QYLGmAMPcadwfx6WsNmrRs3LoO7/0GexLZrcFi JL9Qe16Tw5ff/XApj8OfBpcbupQo/Og= X-MC-Unique: PcL2CAAnPROun5EdeIGXkQ-1 From: Thomas Huth To: Paolo Bonzini , Michael S Tsirkin , qemu-devel@nongnu.org, Bernhard Beschow , Mark Cave-Ayland Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno Subject: [PATCH 1/6] hw/i386/pc: Create RTC controllers in south bridges Date: Tue, 3 Jan 2023 09:47:56 +0100 Message-Id: <20230103084801.20437-2-thuth@redhat.com> In-Reply-To: <20230103084801.20437-1-thuth@redhat.com> References: <20230103084801.20437-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672735877053100003 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow Just like in the real hardware (and in PIIX4), create the RTC controllers in the south bridges. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Message-Id: <20221022150508.26830-11-shentey@gmail.com> Signed-off-by: Thomas Huth --- include/hw/i386/ich9.h | 2 ++ include/hw/southbridge/piix.h | 3 +++ hw/i386/pc.c | 12 +++++++++++- hw/i386/pc_piix.c | 8 ++++++++ hw/i386/pc_q35.c | 1 + hw/isa/lpc_ich9.c | 8 ++++++++ hw/isa/piix3.c | 15 +++++++++++++++ hw/isa/Kconfig | 2 ++ 8 files changed, 50 insertions(+), 1 deletion(-) diff --git a/include/hw/i386/ich9.h b/include/hw/i386/ich9.h index 23ee8e371b..672efc6bce 100644 --- a/include/hw/i386/ich9.h +++ b/include/hw/i386/ich9.h @@ -11,6 +11,7 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/ich9.h" #include "hw/pci/pci_bus.h" +#include "hw/rtc/mc146818rtc.h" #include "qom/object.h" =20 void ich9_lpc_set_irq(void *opaque, int irq_num, int level); @@ -39,6 +40,7 @@ struct ICH9LPCState { */ uint8_t irr[PCI_SLOT_MAX][PCI_NUM_PINS]; =20 + RTCState rtc; APMState apm; ICH9LPCPMRegs pm; uint32_t sci_level; /* track sci level */ diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h index 2693778b23..b1fa08dd2b 100644 --- a/include/hw/southbridge/piix.h +++ b/include/hw/southbridge/piix.h @@ -14,6 +14,7 @@ =20 #include "hw/pci/pci.h" #include "qom/object.h" +#include "hw/rtc/mc146818rtc.h" =20 /* PIRQRC[A:D]: PIRQx Route Control Registers */ #define PIIX_PIRQCA 0x60 @@ -52,6 +53,8 @@ struct PIIXState { /* This member isn't used. Just for save/load compatibility */ int32_t pci_irq_levels_vmstate[PIIX_NUM_PIRQS]; =20 + RTCState rtc; + /* Reset Control Register contents */ uint8_t rcr; =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index d489ecc0d1..448557333b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1304,7 +1304,17 @@ void pc_basic_device_init(struct PCMachineState *pcm= s, pit_alt_irq =3D qdev_get_gpio_in(hpet, HPET_LEGACY_PIT_INT); rtc_irq =3D qdev_get_gpio_in(hpet, HPET_LEGACY_RTC_INT); } - *rtc_state =3D mc146818_rtc_init(isa_bus, 2000, rtc_irq); + + if (rtc_irq) { + qdev_connect_gpio_out(DEVICE(*rtc_state), 0, rtc_irq); + } else { + uint32_t irq =3D object_property_get_uint(OBJECT(*rtc_state), + "irq", + &error_fatal); + isa_connect_gpio_out(*rtc_state, 0, irq); + } + object_property_add_alias(OBJECT(pcms), "rtc-time", OBJECT(*rtc_state), + "date"); =20 qemu_register_boot_set(pc_boot_set, *rtc_state); =20 diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index b48047f50c..87aab3d853 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -32,6 +32,7 @@ #include "hw/i386/pc.h" #include "hw/i386/apic.h" #include "hw/pci-host/i440fx.h" +#include "hw/rtc/mc146818rtc.h" #include "hw/southbridge/piix.h" #include "hw/display/ramfb.h" #include "hw/firmware/smbios.h" @@ -223,10 +224,17 @@ static void pc_init1(MachineState *machine, piix3->pic =3D x86ms->gsi; piix3_devfn =3D piix3->dev.devfn; isa_bus =3D ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0")); + rtc_state =3D ISA_DEVICE(object_resolve_path_component(OBJECT(pci_= dev), + "rtc")); } else { pci_bus =3D NULL; isa_bus =3D isa_bus_new(NULL, get_system_memory(), system_io, &error_abort); + + rtc_state =3D isa_new(TYPE_MC146818_RTC); + qdev_prop_set_int32(DEVICE(rtc_state), "base_year", 2000); + isa_realize_and_unref(rtc_state, isa_bus, &error_fatal); + i8257_dma_init(isa_bus, 0); pcms->hpet_enabled =3D false; } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 67ceb04bcc..6a36e6bb12 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -238,6 +238,7 @@ static void pc_q35_init(MachineState *machine) lpc =3D pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_D= EV, ICH9_LPC_FUNC), true, TYPE_ICH9_LPC_DEVICE); + rtc_state =3D ISA_DEVICE(object_resolve_path_component(OBJECT(lpc), "r= tc")); =20 object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, TYPE_HOTPLUG_HANDLER, diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index 8d541e2b54..498175c1cc 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -663,6 +663,8 @@ static void ich9_lpc_initfn(Object *obj) static const uint8_t acpi_enable_cmd =3D ICH9_APM_ACPI_ENABLE; static const uint8_t acpi_disable_cmd =3D ICH9_APM_ACPI_DISABLE; =20 + object_initialize_child(obj, "rtc", &lpc->rtc, TYPE_MC146818_RTC); + object_property_add_uint8_ptr(obj, ACPI_PM_PROP_SCI_INT, &lpc->sci_gsi, OBJ_PROP_FLAG_READ); object_property_add_uint8_ptr(OBJECT(lpc), ACPI_PM_PROP_ACPI_ENABLE_CM= D, @@ -728,6 +730,12 @@ static void ich9_lpc_realize(PCIDevice *d, Error **err= p) isa_bus_irqs(isa_bus, lpc->gsi); =20 i8257_dma_init(isa_bus, 0); + + /* RTC */ + qdev_prop_set_int32(DEVICE(&lpc->rtc), "base_year", 2000); + if (!qdev_realize(DEVICE(&lpc->rtc), BUS(isa_bus), errp)) { + return; + } } =20 static bool ich9_rst_cnt_needed(void *opaque) diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index eabad7ba58..c68e51ddad 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -28,6 +28,7 @@ #include "hw/dma/i8257.h" #include "hw/southbridge/piix.h" #include "hw/irq.h" +#include "hw/qdev-properties.h" #include "hw/isa/isa.h" #include "hw/xen/xen.h" #include "sysemu/runstate.h" @@ -312,6 +313,12 @@ static void pci_piix3_realize(PCIDevice *dev, Error **= errp) PIIX_RCR_IOPORT, &d->rcr_mem, 1); =20 i8257_dma_init(isa_bus, 0); + + /* RTC */ + qdev_prop_set_int32(DEVICE(&d->rtc), "base_year", 2000); + if (!qdev_realize(DEVICE(&d->rtc), BUS(isa_bus), errp)) { + return; + } } =20 static void build_pci_isa_aml(AcpiDevAmlIf *adev, Aml *scope) @@ -338,6 +345,13 @@ static void build_pci_isa_aml(AcpiDevAmlIf *adev, Aml = *scope) } } =20 +static void pci_piix3_init(Object *obj) +{ + PIIX3State *d =3D PIIX3_PCI_DEVICE(obj); + + object_initialize_child(obj, "rtc", &d->rtc, TYPE_MC146818_RTC); +} + static void pci_piix3_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -364,6 +378,7 @@ static const TypeInfo piix3_pci_type_info =3D { .name =3D TYPE_PIIX3_PCI_DEVICE, .parent =3D TYPE_PCI_DEVICE, .instance_size =3D sizeof(PIIX3State), + .instance_init =3D pci_piix3_init, .abstract =3D true, .class_init =3D pci_piix3_class_init, .interfaces =3D (InterfaceInfo[]) { diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig index 18b5c6bf3f..af5ec9cd61 100644 --- a/hw/isa/Kconfig +++ b/hw/isa/Kconfig @@ -35,6 +35,7 @@ config PIIX3 bool select I8257 select ISA_BUS + select MC146818RTC =20 config PIIX4 bool @@ -79,3 +80,4 @@ config LPC_ICH9 select ISA_BUS select ACPI_SMBUS select ACPI_X86_ICH + select MC146818RTC --=20 2.31.1 From nobody Wed May 15 02:49:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672735753; cv=none; d=zohomail.com; s=zohoarc; b=QWTEzq/ASmw1i9yxD+WUgIPbKk+8CLRjJiDRmyq6igcu0lX27ExZ/04FcdwpEwxQQ7+TB69NqaIqGhqPedkSHbeg++IOqpZLqQWFT+U5u7vcIexQa8vdTsD4Kka3KF5N9loiH+XKDJDkkM4sGn1/No6UeAQTWYvavi8mEI9vwqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672735753; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fcpalQmSGKiDkMUeJpJznYsPJJDFvrth7y1iNREQ3cM=; b=Fq7jukaKNaIzq2+EdEUtEVocP3KAJ95ul+ZUsNPTYFeoF3RV8AzjUTZSi31zHuP4YBI9pPrmXF4wmZ3AgmCADxw+ymVsvRFxedB6knNZkF7E2VlDkxMvj8ufG/EkQgRw8i03gSL0ftdMUvkA1yjBEk9IuAdnFheB/pmM4YRj7BY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672735753603257.8820277509117; Tue, 3 Jan 2023 00:49:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCcyW-0001cR-VP; Tue, 03 Jan 2023 03:48:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcy3-0001aL-Rv for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcy2-0007WF-9B for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:19 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-284-LlbxJYxmPVWZTN3P1Y8dEQ-1; Tue, 03 Jan 2023 03:48:14 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BBD443C0D84C; Tue, 3 Jan 2023 08:48:13 +0000 (UTC) Received: from thuth.com (unknown [10.39.193.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCBC340C1141; Tue, 3 Jan 2023 08:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672735695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fcpalQmSGKiDkMUeJpJznYsPJJDFvrth7y1iNREQ3cM=; b=FN8MpG6yljjKvJkJi9XFOKaVcB2tgBcpgWX8CndDZkhEMG7siYEMTgehv5T551KsXz3Is7 k/9o74BUga4RyHYF1Sn2bk6ZCI9DrDaaDoISkf3iR1d2HIRId7w7x2nAlPyJmX7JpzFWES pJNQiOgo/OKIUqilGsDpG4YTP7pUB+c= X-MC-Unique: LlbxJYxmPVWZTN3P1Y8dEQ-1 From: Thomas Huth To: Paolo Bonzini , Michael S Tsirkin , qemu-devel@nongnu.org, Bernhard Beschow , Mark Cave-Ayland Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno Subject: [PATCH 2/6] hw/i386/pc: No need for rtc_state to be an out-parameter Date: Tue, 3 Jan 2023 09:47:57 +0100 Message-Id: <20230103084801.20437-3-thuth@redhat.com> In-Reply-To: <20230103084801.20437-1-thuth@redhat.com> References: <20230103084801.20437-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672735755237100001 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow Now that the RTC is created as part of the southbridges it doesn't need to be an out-parameter any longer. Signed-off-by: Bernhard Beschow Reviewed-by: Peter Maydell Reviewed-by: Michael S. Tsirkin Message-Id: <20221022150508.26830-12-shentey@gmail.com> Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/i386/pc.h | 2 +- hw/i386/pc.c | 12 ++++++------ hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 991f905f5d..dd059e8667 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -169,7 +169,7 @@ uint64_t pc_pci_hole64_start(void); DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus); void pc_basic_device_init(struct PCMachineState *pcms, ISABus *isa_bus, qemu_irq *gsi, - ISADevice **rtc_state, + ISADevice *rtc_state, bool create_fdctrl, uint32_t hpet_irqs); void pc_cmos_init(PCMachineState *pcms, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 448557333b..53a5443e09 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1251,7 +1251,7 @@ static void pc_superio_init(ISABus *isa_bus, bool cre= ate_fdctrl, =20 void pc_basic_device_init(struct PCMachineState *pcms, ISABus *isa_bus, qemu_irq *gsi, - ISADevice **rtc_state, + ISADevice *rtc_state, bool create_fdctrl, uint32_t hpet_irqs) { @@ -1306,17 +1306,17 @@ void pc_basic_device_init(struct PCMachineState *pc= ms, } =20 if (rtc_irq) { - qdev_connect_gpio_out(DEVICE(*rtc_state), 0, rtc_irq); + qdev_connect_gpio_out(DEVICE(rtc_state), 0, rtc_irq); } else { - uint32_t irq =3D object_property_get_uint(OBJECT(*rtc_state), + uint32_t irq =3D object_property_get_uint(OBJECT(rtc_state), "irq", &error_fatal); - isa_connect_gpio_out(*rtc_state, 0, irq); + isa_connect_gpio_out(rtc_state, 0, irq); } - object_property_add_alias(OBJECT(pcms), "rtc-time", OBJECT(*rtc_state), + object_property_add_alias(OBJECT(pcms), "rtc-time", OBJECT(rtc_state), "date"); =20 - qemu_register_boot_set(pc_boot_set, *rtc_state); + qemu_register_boot_set(pc_boot_set, rtc_state); =20 if (!xen_enabled() && (x86ms->pit =3D=3D ON_OFF_AUTO_AUTO || x86ms->pit =3D=3D ON_OFF_AU= TO_ON)) { diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 87aab3d853..bc9ea8cdae 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -260,7 +260,7 @@ static void pc_init1(MachineState *machine, } =20 /* init basic PC hardware */ - pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, true, + pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, true, 0x4); =20 pc_nic_init(pcmc, isa_bus, pci_bus); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 6a36e6bb12..a54dd7be14 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -292,7 +292,7 @@ static void pc_q35_init(MachineState *machine) } =20 /* init basic PC hardware */ - pc_basic_device_init(pcms, isa_bus, x86ms->gsi, &rtc_state, !mc->no_fl= oppy, + pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, !mc->no_flo= ppy, 0xff0104); =20 /* connect pm stuff to lpc */ --=20 2.31.1 From nobody Wed May 15 02:49:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672735767; cv=none; d=zohomail.com; s=zohoarc; b=m6KTIq9UX12iLrVOVwfoLDLM4KsFzahoueKanoP2SQIbvP/6cbPkiD0wEpo3SBaWDdTOT1531tfoAuq+sAVNIvhiaBCX9gV9cxOR1XqAyktMji7XCPZGfBJ38qUQ4KcRTmYnxAWACpFSiAEykfvf3i8gXv/rh59707fdeWvX1eM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672735767; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AB3P1rDR73woLJnKRJ70GZwrOLXk2allUBLGu8JVgDs=; b=k/Jhiby7xcIolW6S+2PRJXLIkSWlPrG2qP/8UMgeOSHwZSc1hpS5zEb6i6P20yi5n/7BESHNF9vk3hJxykwej5HaJ8EfsqvfDvCQSD6cKMvmFpjB2uNj8i7Y7InjsgsMrhzaWWlulvhVJsLFrtKHzg1R8++kv9Cgcunk1YZfwDc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672735767840288.46435786904567; Tue, 3 Jan 2023 00:49:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCcyb-0001dx-Sm; Tue, 03 Jan 2023 03:48:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcy8-0001b1-Nk for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcy6-0007Ws-Gq for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:24 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-578-oUrPA1obNY6EIzSfzdnmjQ-1; Tue, 03 Jan 2023 03:48:17 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6BDB2A5957F; Tue, 3 Jan 2023 08:48:16 +0000 (UTC) Received: from thuth.com (unknown [10.39.193.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2660B4014CE6; Tue, 3 Jan 2023 08:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672735701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AB3P1rDR73woLJnKRJ70GZwrOLXk2allUBLGu8JVgDs=; b=cXgx4wzG4dOkss+/nNd78q0+KPswnYc9wTUFZCRwA14/9O6Kezt3klK4dcjRztPZvG4dap zDsXmkfYbm3sAJjoTBCDaAHYfyngc3IPJdioZaCwkM5WramTBmfgMXK3fH/jc7+OJSnU8n 95Vt1JqMXtAnQQHmLpiBQdB29RBCL2E= X-MC-Unique: oUrPA1obNY6EIzSfzdnmjQ-1 From: Thomas Huth To: Paolo Bonzini , Michael S Tsirkin , qemu-devel@nongnu.org, Bernhard Beschow , Mark Cave-Ayland Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno Subject: [PATCH 3/6] hw/intc: Extract the IRQ counting functions into a separate file Date: Tue, 3 Jan 2023 09:47:58 +0100 Message-Id: <20230103084801.20437-4-thuth@redhat.com> In-Reply-To: <20230103084801.20437-1-thuth@redhat.com> References: <20230103084801.20437-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672735768340100002 Content-Type: text/plain; charset="utf-8" These IRQ counting functions will soon be required in binaries that do not include the APIC code, too, so let's extract them into a separate file that can be linked independently of the APIC code. While we're at it, change the apic_* prefix into kvm_* since the functions are used from the i8259 PIC (i.e. not the APIC), too. Signed-off-by: Thomas Huth Reviewed-by: Bernhard Beschow --- include/hw/i386/apic.h | 2 -- include/hw/i386/apic_internal.h | 1 - include/hw/intc/kvm_irqcount.h | 10 +++++++ hw/i386/kvm/i8259.c | 4 +-- hw/i386/kvm/ioapic.c | 4 +-- hw/intc/apic.c | 3 +- hw/intc/apic_common.c | 30 ++------------------ hw/intc/kvm_irqcount.c | 49 +++++++++++++++++++++++++++++++++ hw/rtc/mc146818rtc.c | 6 ++-- hw/intc/meson.build | 6 ++++ hw/intc/trace-events | 9 +++--- 11 files changed, 81 insertions(+), 43 deletions(-) create mode 100644 include/hw/intc/kvm_irqcount.h create mode 100644 hw/intc/kvm_irqcount.c diff --git a/include/hw/i386/apic.h b/include/hw/i386/apic.h index da1d2fe155..bdc15a7a73 100644 --- a/include/hw/i386/apic.h +++ b/include/hw/i386/apic.h @@ -9,8 +9,6 @@ int apic_accept_pic_intr(DeviceState *s); void apic_deliver_pic_intr(DeviceState *s, int level); void apic_deliver_nmi(DeviceState *d); int apic_get_interrupt(DeviceState *s); -void apic_reset_irq_delivered(void); -int apic_get_irq_delivered(void); void cpu_set_apic_base(DeviceState *s, uint64_t val); uint64_t cpu_get_apic_base(DeviceState *s); void cpu_set_apic_tpr(DeviceState *s, uint8_t val); diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_interna= l.h index c175e7e718..e61ad04769 100644 --- a/include/hw/i386/apic_internal.h +++ b/include/hw/i386/apic_internal.h @@ -199,7 +199,6 @@ typedef struct VAPICState { =20 extern bool apic_report_tpr_access; =20 -void apic_report_irq_delivered(int delivered); bool apic_next_timer(APICCommonState *s, int64_t current_time); void apic_enable_tpr_access_reporting(DeviceState *d, bool enable); void apic_enable_vapic(DeviceState *d, hwaddr paddr); diff --git a/include/hw/intc/kvm_irqcount.h b/include/hw/intc/kvm_irqcount.h new file mode 100644 index 0000000000..0ed5999e49 --- /dev/null +++ b/include/hw/intc/kvm_irqcount.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#ifndef KVM_IRQCOUNT_H +#define KVM_IRQCOUNT_H + +void kvm_report_irq_delivered(int delivered); +void kvm_reset_irq_delivered(void); +int kvm_get_irq_delivered(void); + +#endif diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c index d61bae4dc3..3ca0e1ff03 100644 --- a/hw/i386/kvm/i8259.c +++ b/hw/i386/kvm/i8259.c @@ -14,7 +14,7 @@ #include "hw/isa/i8259_internal.h" #include "hw/intc/i8259.h" #include "qemu/module.h" -#include "hw/i386/apic_internal.h" +#include "hw/intc/kvm_irqcount.h" #include "hw/irq.h" #include "sysemu/kvm.h" #include "qom/object.h" @@ -117,7 +117,7 @@ static void kvm_pic_set_irq(void *opaque, int irq, int = level) =20 pic_stat_update_irq(irq, level); delivered =3D kvm_set_irq(kvm_state, irq, level); - apic_report_irq_delivered(delivered); + kvm_report_irq_delivered(delivered); } =20 static void kvm_pic_realize(DeviceState *dev, Error **errp) diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index ee7c8ef68b..272e26b4a2 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -15,7 +15,7 @@ #include "hw/i386/x86.h" #include "hw/qdev-properties.h" #include "hw/i386/ioapic_internal.h" -#include "hw/i386/apic_internal.h" +#include "hw/intc/kvm_irqcount.h" #include "sysemu/kvm.h" =20 /* PC Utility function */ @@ -116,7 +116,7 @@ static void kvm_ioapic_set_irq(void *opaque, int irq, i= nt level) =20 ioapic_stat_update_irq(common, irq, level); delivered =3D kvm_set_irq(kvm_state, s->kvm_gsi_base + irq, level); - apic_report_irq_delivered(delivered); + kvm_report_irq_delivered(delivered); } =20 static void kvm_ioapic_realize(DeviceState *dev, Error **errp) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 3df11c34d6..2d3e55f4e2 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -22,6 +22,7 @@ #include "hw/i386/apic.h" #include "hw/i386/ioapic.h" #include "hw/intc/i8259.h" +#include "hw/intc/kvm_irqcount.h" #include "hw/pci/msi.h" #include "qemu/host-utils.h" #include "sysemu/kvm.h" @@ -399,7 +400,7 @@ void apic_poll_irq(DeviceState *dev) =20 static void apic_set_irq(APICCommonState *s, int vector_num, int trigger_m= ode) { - apic_report_irq_delivered(!apic_get_bit(s->irr, vector_num)); + kvm_report_irq_delivered(!apic_get_bit(s->irr, vector_num)); =20 apic_set_bit(s->irr, vector_num); if (trigger_mode) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 2a20982066..4a34f03047 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -25,6 +25,7 @@ #include "qapi/visitor.h" #include "hw/i386/apic.h" #include "hw/i386/apic_internal.h" +#include "hw/intc/kvm_irqcount.h" #include "trace.h" #include "hw/boards.h" #include "sysemu/hax.h" @@ -33,7 +34,6 @@ #include "hw/sysbus.h" #include "migration/vmstate.h" =20 -static int apic_irq_delivered; bool apic_report_tpr_access; =20 void cpu_set_apic_base(DeviceState *dev, uint64_t val) @@ -122,32 +122,6 @@ void apic_handle_tpr_access_report(DeviceState *dev, t= arget_ulong ip, vapic_report_tpr_access(s->vapic, CPU(s->cpu), ip, access); } =20 -void apic_report_irq_delivered(int delivered) -{ - apic_irq_delivered +=3D delivered; - - trace_apic_report_irq_delivered(apic_irq_delivered); -} - -void apic_reset_irq_delivered(void) -{ - /* Copy this into a local variable to encourage gcc to emit a plain - * register for a sys/sdt.h marker. For details on this workaround, s= ee: - * https://sourceware.org/bugzilla/show_bug.cgi?id=3D13296 - */ - volatile int a_i_d =3D apic_irq_delivered; - trace_apic_reset_irq_delivered(a_i_d); - - apic_irq_delivered =3D 0; -} - -int apic_get_irq_delivered(void) -{ - trace_apic_get_irq_delivered(apic_irq_delivered); - - return apic_irq_delivered; -} - void apic_deliver_nmi(DeviceState *dev) { APICCommonState *s =3D APIC_COMMON(dev); @@ -272,7 +246,7 @@ static void apic_reset_common(DeviceState *dev) s->apicbase =3D APIC_DEFAULT_ADDRESS | bsp | MSR_IA32_APICBASE_ENABLE; s->id =3D s->initial_apic_id; =20 - apic_reset_irq_delivered(); + kvm_reset_irq_delivered(); =20 s->vapic_paddr =3D 0; info->vapic_base_update(s); diff --git a/hw/intc/kvm_irqcount.c b/hw/intc/kvm_irqcount.c new file mode 100644 index 0000000000..2ef8a83a7a --- /dev/null +++ b/hw/intc/kvm_irqcount.c @@ -0,0 +1,49 @@ +/* + * KVM PIC functions for counting the delivered IRQs. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include "hw/intc/kvm_irqcount.h" +#include "trace.h" + +static int kvm_irq_delivered; + +void kvm_report_irq_delivered(int delivered) +{ + kvm_irq_delivered +=3D delivered; + + trace_kvm_report_irq_delivered(kvm_irq_delivered); +} + +void kvm_reset_irq_delivered(void) +{ + /* + * Copy this into a local variable to encourage gcc to emit a plain + * register for a sys/sdt.h marker. For details on this workaround, s= ee: + * https://sourceware.org/bugzilla/show_bug.cgi?id=3D13296 + */ + volatile int k_i_d =3D kvm_irq_delivered; + trace_kvm_reset_irq_delivered(k_i_d); + + kvm_irq_delivered =3D 0; +} + +int kvm_get_irq_delivered(void) +{ + trace_kvm_get_irq_delivered(kvm_irq_delivered); + + return kvm_irq_delivered; +} diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c index 1ebb412479..947d68c257 100644 --- a/hw/rtc/mc146818rtc.c +++ b/hw/rtc/mc146818rtc.c @@ -27,6 +27,7 @@ #include "qemu/module.h" #include "qemu/bcd.h" #include "hw/acpi/acpi_aml_interface.h" +#include "hw/intc/kvm_irqcount.h" #include "hw/irq.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" @@ -46,7 +47,6 @@ =20 #ifdef TARGET_I386 #include "qapi/qapi-commands-misc-target.h" -#include "hw/i386/apic.h" #endif =20 //#define DEBUG_CMOS @@ -124,9 +124,9 @@ void qmp_rtc_reset_reinjection(Error **errp) =20 static bool rtc_policy_slew_deliver_irq(RTCState *s) { - apic_reset_irq_delivered(); + kvm_reset_irq_delivered(); qemu_irq_raise(s->irq); - return apic_get_irq_delivered(); + return kvm_get_irq_delivered(); } =20 static void rtc_coalesced_timer(void *opaque) diff --git a/hw/intc/meson.build b/hw/intc/meson.build index bcbf22ff51..cd9f1ee888 100644 --- a/hw/intc/meson.build +++ b/hw/intc/meson.build @@ -25,6 +25,12 @@ softmmu_ss.add(when: 'CONFIG_XILINX', if_true: files('xi= linx_intc.c')) softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP', if_true: files('xlnx-zynqmp-ipi= .c')) softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-pmu-io= mod-intc.c')) =20 +if config_all_devices.has_key('CONFIG_APIC') or \ + config_all_devices.has_key('CONFIG_I8259') or \ + config_all_devices.has_key('CONFIG_MC146818RTC') + softmmu_ss.add(files('kvm_irqcount.c')) +endif + specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinne= r-a10-pic.c')) specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common= .c')) specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_co= mmon.c')) diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 6fbc2045e6..50cadfb996 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -10,10 +10,6 @@ pic_ioport_read(bool master, uint64_t addr, int val) "ma= ster %d addr 0x%"PRIx64" # apic_common.c cpu_set_apic_base(uint64_t val) "0x%016"PRIx64 cpu_get_apic_base(uint64_t val) "0x%016"PRIx64 -# coalescing -apic_report_irq_delivered(int apic_irq_delivered) "coalescing %d" -apic_reset_irq_delivered(int apic_irq_delivered) "old coalescing %d" -apic_get_irq_delivered(int apic_irq_delivered) "returning coalescing %d" =20 # apic.c apic_local_deliver(int vector, uint32_t lvt) "vector %d delivery mode %d" @@ -30,6 +26,11 @@ ioapic_mem_read(uint8_t addr, uint8_t regsel, uint8_t si= ze, uint32_t val) "ioapi ioapic_mem_write(uint8_t addr, uint8_t regsel, uint8_t size, uint32_t val)= "ioapic mem write addr 0x%"PRIx8" regsel: 0x%"PRIx8" size 0x%"PRIx8" val 0= x%"PRIx32 ioapic_set_irq(int vector, int level) "vector: %d level: %d" =20 +# kvm_irqcount.c +kvm_report_irq_delivered(int irq_delivered) "coalescing %d" +kvm_reset_irq_delivered(int irq_delivered) "old coalescing %d" +kvm_get_irq_delivered(int irq_delivered) "returning coalescing %d" + # slavio_intctl.c slavio_intctl_mem_readl(uint32_t cpu, uint64_t addr, uint32_t ret) "read c= pu %d reg 0x%"PRIx64" =3D 0x%x" slavio_intctl_mem_writel(uint32_t cpu, uint64_t addr, uint32_t val) "write= cpu %d reg 0x%"PRIx64" =3D 0x%x" --=20 2.31.1 From nobody Wed May 15 02:49:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672735768; cv=none; d=zohomail.com; s=zohoarc; b=VOL9o7ePFG7Spu5IxWB0uj8RCvJa49E5TnJhKkhwfX/bBJl1HcM6abyJVGDot3xsn1RhDJp6PN3+1XMIVcS7hNIpOpFRDqV0O3Lp6F/M5Fd8awNgUMqzdI51cN49K8w4x+2fhAntimfFoshZ0U1aYgeziaUVRhwEeAG/L08ZWfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672735768; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y7KXtpG+7C3jP94gnszNmUGjaNP/TUycZmSujpd/usA=; b=i9QK6xIxezQh4R+NYRhMH5YJKLLOLr7Gy9bziAdEMarfn3mOnlwXi4kg1BD4r8Tkc5uiLQ2/1DydLeHOVPywdtYfvJVWroIbnTEir9NDOpMxTx2eXdJ+XCenLtU9OC1evgJAeRQGtJDUDlB9zSj9VWFRv5plB7KBRety/IihZJI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672735768044139.7679496799335; Tue, 3 Jan 2023 00:49:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCcyb-0001dw-S8; Tue, 03 Jan 2023 03:48:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcyB-0001bD-Pq for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcyA-0007X3-84 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:27 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-534--8pE4zUHPgK7BD_X2Bn9rg-1; Tue, 03 Jan 2023 03:48:20 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1D249811E9C; Tue, 3 Jan 2023 08:48:20 +0000 (UTC) Received: from thuth.com (unknown [10.39.193.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50E5B40C1141; Tue, 3 Jan 2023 08:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672735705; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y7KXtpG+7C3jP94gnszNmUGjaNP/TUycZmSujpd/usA=; b=X2pw5ONG/WbS8+oWHcbY31/IzjdZgvvTdTbZJ6GEY08H6Nz8TG+b2KL/qh1EU/cSkmY5uG rHTxJVVeMQ5mboCSJD5t0LPn9MThxpmFDzOncAf1TBhO/g1jkijfXBkZqDnDRkfPlD6gik 1+aMy6TI5a80dwOpGlcYr6Ef6MPqFyo= X-MC-Unique: -8pE4zUHPgK7BD_X2Bn9rg-1 From: Thomas Huth To: Paolo Bonzini , Michael S Tsirkin , qemu-devel@nongnu.org, Bernhard Beschow , Mark Cave-Ayland Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno Subject: [PATCH 4/6] hw/rtc/mc146818rtc: Add a property for the availability of the slew tick policy Date: Tue, 3 Jan 2023 09:47:59 +0100 Message-Id: <20230103084801.20437-5-thuth@redhat.com> In-Reply-To: <20230103084801.20437-1-thuth@redhat.com> References: <20230103084801.20437-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672735768308100001 Content-Type: text/plain; charset="utf-8" We want to get rid of the "#ifdef TARGET_I386" statements in the mc146818 code, so we need a different way to decide whether the slew tick policy is available or not. Introduce a new property "slew-tick-policy-available" which can be set by the machines that support this tick policy. Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/rtc/mc146818rtc.h | 1 + hw/i386/pc_piix.c | 1 + hw/isa/lpc_ich9.c | 1 + hw/isa/piix3.c | 1 + hw/rtc/mc146818rtc.c | 16 ++++++++++------ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/hw/rtc/mc146818rtc.h b/include/hw/rtc/mc146818rtc.h index 1db0fcee92..54af63d091 100644 --- a/include/hw/rtc/mc146818rtc.h +++ b/include/hw/rtc/mc146818rtc.h @@ -45,6 +45,7 @@ struct RTCState { QEMUTimer *coalesced_timer; Notifier clock_reset_notifier; LostTickPolicy lost_tick_policy; + bool slew_tick_policy_available; Notifier suspend_notifier; QLIST_ENTRY(RTCState) link; }; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index bc9ea8cdae..382c6add3b 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -233,6 +233,7 @@ static void pc_init1(MachineState *machine, =20 rtc_state =3D isa_new(TYPE_MC146818_RTC); qdev_prop_set_int32(DEVICE(rtc_state), "base_year", 2000); + qdev_prop_set_bit(DEVICE(rtc_state), "slew-tick-policy-available",= true); isa_realize_and_unref(rtc_state, isa_bus, &error_fatal); =20 i8257_dma_init(isa_bus, 0); diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index 498175c1cc..aeab4d8549 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -733,6 +733,7 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp) =20 /* RTC */ qdev_prop_set_int32(DEVICE(&lpc->rtc), "base_year", 2000); + qdev_prop_set_bit(DEVICE(&lpc->rtc), "slew-tick-policy-available", tru= e); if (!qdev_realize(DEVICE(&lpc->rtc), BUS(isa_bus), errp)) { return; } diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index c68e51ddad..825b1cbee2 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -316,6 +316,7 @@ static void pci_piix3_realize(PCIDevice *dev, Error **e= rrp) =20 /* RTC */ qdev_prop_set_int32(DEVICE(&d->rtc), "base_year", 2000); + qdev_prop_set_bit(DEVICE(&d->rtc), "slew-tick-policy-available", true); if (!qdev_realize(DEVICE(&d->rtc), BUS(isa_bus), errp)) { return; } diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c index 947d68c257..86381a74c3 100644 --- a/hw/rtc/mc146818rtc.c +++ b/hw/rtc/mc146818rtc.c @@ -922,14 +922,16 @@ static void rtc_realizefn(DeviceState *dev, Error **e= rrp) rtc_set_date_from_host(isadev); =20 switch (s->lost_tick_policy) { -#ifdef TARGET_I386 - case LOST_TICK_POLICY_SLEW: - s->coalesced_timer =3D - timer_new_ns(rtc_clock, rtc_coalesced_timer, s); - break; -#endif case LOST_TICK_POLICY_DISCARD: break; + case LOST_TICK_POLICY_SLEW: +#ifdef TARGET_I386 + if (s->slew_tick_policy_available) { + s->coalesced_timer =3D timer_new_ns(rtc_clock, rtc_coalesced_t= imer, s); + break; + } +#endif + /* fallthrough */ default: error_setg(errp, "Invalid lost tick policy."); return; @@ -989,6 +991,8 @@ static Property mc146818rtc_properties[] =3D { DEFINE_PROP_UINT8("irq", RTCState, isairq, RTC_ISA_IRQ), DEFINE_PROP_LOSTTICKPOLICY("lost_tick_policy", RTCState, lost_tick_policy, LOST_TICK_POLICY_DISCARD), + DEFINE_PROP_BOOL("slew-tick-policy-available", RTCState, + slew_tick_policy_available, false), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.31.1 From nobody Wed May 15 02:49:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672735830; cv=none; d=zohomail.com; s=zohoarc; b=Ns3knMEx4rlpQ2uQOTaD4aNtfXpE3rh2w+103iDgmUexhERPEtLAZ10MGfdBisE4A2nnU6uXPIleLu3T+qWgRHlN4HQCWOmUahocwsmuRgBhN5E9/nedn8LWLVkE/sszZcmHC4F3KM0tvOgzwL9BVOo8kQobq048myh3gIehudo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672735830; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Wr/ztDqaZEjIYIMtFBFgRuGPJsaGNHHvqse+3TfFIpg=; b=Dxh720GatBeQ44o7e7yHuVfFFltKaxZhcHLzk4mmucBVhjWtJkVZaMrM1thcsmFHFQ6LQUGYroU+weQ23ynRd2cGGaUcXEbx+Lfrfn5wDbllATUCv8D9Gr0IyCJt4YfEMGHTYX35Kxqrwhg7PaCpPjIla2/89zlRd0PWUpI+BwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672735830553545.1681722841205; Tue, 3 Jan 2023 00:50:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCcya-0001de-DY; Tue, 03 Jan 2023 03:48:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcyD-0001bF-MC for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcyC-0007XA-0h for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:29 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-85-c2uOpbbnMCu4a9eRNORw4Q-1; Tue, 03 Jan 2023 03:48:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2E8223C0D841; Tue, 3 Jan 2023 08:48:23 +0000 (UTC) Received: from thuth.com (unknown [10.39.193.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A41C40C1141; Tue, 3 Jan 2023 08:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672735707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wr/ztDqaZEjIYIMtFBFgRuGPJsaGNHHvqse+3TfFIpg=; b=h7oFI2p6nPSWEc/uGm+mFyFlumr2f4yuF8Hep6omyvTjcRWptE9R1ynVlJLkqXoiIHQS3G N9sGkp55XTUqZ8HKdzma5zLnX9aFJguQJOHfEAdtVNcTPap7TLE1tdK+3YGRzN9WMXUjT3 +reqHyjqNXvoDbiNws+hw4C1xmo1mI8= X-MC-Unique: c2uOpbbnMCu4a9eRNORw4Q-1 From: Thomas Huth To: Paolo Bonzini , Michael S Tsirkin , qemu-devel@nongnu.org, Bernhard Beschow , Mark Cave-Ayland Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno Subject: [PATCH 5/6] hw/rtc/mc146818rtc: Make the mc146818 RTC device target independent Date: Tue, 3 Jan 2023 09:48:00 +0100 Message-Id: <20230103084801.20437-6-thuth@redhat.com> In-Reply-To: <20230103084801.20437-1-thuth@redhat.com> References: <20230103084801.20437-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672735830910100001 Content-Type: text/plain; charset="utf-8" The only reason for this code being target dependent was the IRQ-counting related code in rtc_policy_slew_deliver_irq(). Since these functions have been moved into a new, separate file (kvm_irqcount.c) which is now always compiled and linked if either APIC or the mc146818 device are required, and since we've got a new mechanism for deciding whether the slew tick policy is available now (via the "slew-tick-policy-available" property), we can get rid of the #ifdef TARGET_I386 switches in mc146818rtc.c and declare it in the softmmu_ss instead of specific_ss, so that the code only gets compiled once for all targets. Signed-off-by: Thomas Huth Reviewed-by: Bernhard Beschow --- include/hw/rtc/mc146818rtc.h | 1 + hw/rtc/mc146818rtc.c | 15 +-------------- hw/rtc/meson.build | 3 +-- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/include/hw/rtc/mc146818rtc.h b/include/hw/rtc/mc146818rtc.h index 54af63d091..9d15d70da8 100644 --- a/include/hw/rtc/mc146818rtc.h +++ b/include/hw/rtc/mc146818rtc.h @@ -56,5 +56,6 @@ ISADevice *mc146818_rtc_init(ISABus *bus, int base_year, qemu_irq intercept_irq); void rtc_set_memory(ISADevice *dev, int addr, int val); int rtc_get_memory(ISADevice *dev, int addr); +void qmp_rtc_reset_reinjection(Error **errp); =20 #endif /* HW_RTC_MC146818RTC_H */ diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c index 86381a74c3..4497ddf024 100644 --- a/hw/rtc/mc146818rtc.c +++ b/hw/rtc/mc146818rtc.c @@ -45,10 +45,6 @@ #include "qapi/visitor.h" #include "hw/rtc/mc146818rtc_regs.h" =20 -#ifdef TARGET_I386 -#include "qapi/qapi-commands-misc-target.h" -#endif - //#define DEBUG_CMOS //#define DEBUG_COALESCED =20 @@ -112,7 +108,6 @@ static void rtc_coalesced_timer_update(RTCState *s) static QLIST_HEAD(, RTCState) rtc_devices =3D QLIST_HEAD_INITIALIZER(rtc_devices); =20 -#ifdef TARGET_I386 void qmp_rtc_reset_reinjection(Error **errp) { RTCState *s; @@ -124,6 +119,7 @@ void qmp_rtc_reset_reinjection(Error **errp) =20 static bool rtc_policy_slew_deliver_irq(RTCState *s) { + assert(s->slew_tick_policy_available); kvm_reset_irq_delivered(); qemu_irq_raise(s->irq); return kvm_get_irq_delivered(); @@ -145,13 +141,6 @@ static void rtc_coalesced_timer(void *opaque) =20 rtc_coalesced_timer_update(s); } -#else -static bool rtc_policy_slew_deliver_irq(RTCState *s) -{ - assert(0); - return false; -} -#endif =20 static uint32_t rtc_periodic_clock_ticks(RTCState *s) { @@ -925,12 +914,10 @@ static void rtc_realizefn(DeviceState *dev, Error **e= rrp) case LOST_TICK_POLICY_DISCARD: break; case LOST_TICK_POLICY_SLEW: -#ifdef TARGET_I386 if (s->slew_tick_policy_available) { s->coalesced_timer =3D timer_new_ns(rtc_clock, rtc_coalesced_t= imer, s); break; } -#endif /* fallthrough */ default: error_setg(errp, "Invalid lost tick policy."); diff --git a/hw/rtc/meson.build b/hw/rtc/meson.build index dc33973384..34a4d316fa 100644 --- a/hw/rtc/meson.build +++ b/hw/rtc/meson.build @@ -13,5 +13,4 @@ softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(= 'aspeed_rtc.c')) softmmu_ss.add(when: 'CONFIG_GOLDFISH_RTC', if_true: files('goldfish_rtc.c= ')) softmmu_ss.add(when: 'CONFIG_LS7A_RTC', if_true: files('ls7a_rtc.c')) softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-rtc.= c')) - -specific_ss.add(when: 'CONFIG_MC146818RTC', if_true: files('mc146818rtc.c'= )) +softmmu_ss.add(when: 'CONFIG_MC146818RTC', if_true: files('mc146818rtc.c')) --=20 2.31.1 From nobody Wed May 15 02:49:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672735801; cv=none; d=zohomail.com; s=zohoarc; b=Re6jxv86/HQOrRSDXxgWbNXWlpymEkyMUCO6I4xWJ6YOLczyomeQk5Y5QZuhmjlH6BG0/RTpNvRpgA8HAu7mixVDd6yQPDeIao2l5SWITjJpEFSEJiIrrppSOu2dcD06RLi5+W1e39y6X6DD6FoYHGDq4fZgkj66w83TVQn7OjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672735801; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JP8yvFnO+sMzdcLZ770nqwSJNaTq4oXE344WoEOJ8oM=; b=nqIHhk12ek8aYKQVDG32XD+hSEGFTiC+XRLD6BanM30et3aw+XjuqIi1kX+Us6ytQ24FHjmrv4opTUfGr8mC7ki/pokqhqowDnYCpho/foEHMx7Kqttzn1/ruJK+bJGqaBKk0jAhpwD5fA/PhSOgWru5VrWFck0wZgN+w5xi2mk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672735801645239.79005299959783; Tue, 3 Jan 2023 00:50:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCcyc-0001dz-6w; Tue, 03 Jan 2023 03:48:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcyH-0001bY-Bk for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCcyF-0007XP-4F for qemu-devel@nongnu.org; Tue, 03 Jan 2023 03:48:32 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-428-luR7oqgnPb2m6Q4vk_UfGA-1; Tue, 03 Jan 2023 03:48:27 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F2F185A588; Tue, 3 Jan 2023 08:48:26 +0000 (UTC) Received: from thuth.com (unknown [10.39.193.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C8EA400D752; Tue, 3 Jan 2023 08:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672735710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JP8yvFnO+sMzdcLZ770nqwSJNaTq4oXE344WoEOJ8oM=; b=KXHC+I7q2s0UNe1S0+ACviBH9sdTqPmEPfid9tyJ9hkcW4FiwYtgacffM43U6W+6euzBPx VKdx8eqnW/CFBfAiU0vVatcRdkNma4/+aPIn3/4sLssNXBShFZJJCm8ngymSNHTJRj+CGR IY2Xra+XVYp485/Jb74TbjRjpcs9C0s= X-MC-Unique: luR7oqgnPb2m6Q4vk_UfGA-1 From: Thomas Huth To: Paolo Bonzini , Michael S Tsirkin , qemu-devel@nongnu.org, Bernhard Beschow , Mark Cave-Ayland Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , BALATON Zoltan , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aurelien Jarno Subject: [PATCH 6/6] softmmu/rtc: Emit warning when using driftfix=slew on systems without mc146818 Date: Tue, 3 Jan 2023 09:48:01 +0100 Message-Id: <20230103084801.20437-7-thuth@redhat.com> In-Reply-To: <20230103084801.20437-1-thuth@redhat.com> References: <20230103084801.20437-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672735802449100003 Content-Type: text/plain; charset="utf-8" The 'slew' lost tick policy is only available on systems with a mc146818 RTC. On other systems, "-rtc driftfix=3Dslew" is currently silently ignored. Let's emit at least a warning in this case to make the users aware that there is something wrong in their command line settings. Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- softmmu/rtc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/softmmu/rtc.c b/softmmu/rtc.c index 7e2956f81e..f7114bed7d 100644 --- a/softmmu/rtc.c +++ b/softmmu/rtc.c @@ -33,6 +33,7 @@ #include "sysemu/replay.h" #include "sysemu/sysemu.h" #include "sysemu/rtc.h" +#include "hw/rtc/mc146818rtc.h" =20 static enum { RTC_BASE_UTC, @@ -177,10 +178,13 @@ void configure_rtc(QemuOpts *opts) value =3D qemu_opt_get(opts, "driftfix"); if (value) { if (!strcmp(value, "slew")) { - object_register_sugar_prop("mc146818rtc", + object_register_sugar_prop(TYPE_MC146818_RTC, "lost_tick_policy", "slew", false); + if (!object_class_by_name(TYPE_MC146818_RTC)) { + warn_report("driftfix 'slew' is not available with this ma= chine"); + } } else if (!strcmp(value, "none")) { /* discard is default */ } else { --=20 2.31.1