From nobody Wed Jun 26 20:26:59 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698484664; cv=none; d=zohomail.com; s=zohoarc; b=Oo4pqPbz8480UNr0T+KBUtx0c8/Y7cDYTrzM7BAOwvNfFMh5P1k44y1W9wq1+1XUAlpgaagHtnj0xFK9kdZCyXtSOyx59kecL4mtLO5i+QNp6xVq3ArgdP1M59XlK/anpRZfiCV14FGHeeqtCFdsV8Q2n33/IZkdgprJ4ruZf0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698484664; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ej/0VQgcuhB6At3SliPWrA14nBYtN5eCbtHeKda9dFU=; b=SloyBYvba7e4G4IX9tU8HuC38NKXP7dFqE9384319R4L8ctJ1617mdoMoYYqHq8BEaFpq6b+gqLpDJ5Ps5vB79TLKleybMV47SECgjZQIIXl8I4RmDnc0Rs/Ir6eQSnsbvsvtExJn6Lm2L2QdkydgwcozIKvh9uDkt5id/qJmHM= 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 1698484664435724.8652360040417; Sat, 28 Oct 2023 02:17:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwfQm-0004bj-Lh; Sat, 28 Oct 2023 05:16:32 -0400 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 1qwfQZ-0004Ww-FD for qemu-devel@nongnu.org; Sat, 28 Oct 2023 05:16:24 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwfQX-0007L2-C4 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 05:16:19 -0400 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-53f6ccea1eeso4836252a12.3 for ; Sat, 28 Oct 2023 02:16:17 -0700 (PDT) Received: from Provence.localdomain (dynamic-089-012-044-170.89.12.pool.telefonica.de. [89.12.44.170]) by smtp.gmail.com with ESMTPSA id q23-20020a50c357000000b00542df4a03d0sm571444edb.16.2023.10.28.02.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 02:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698484575; x=1699089375; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ej/0VQgcuhB6At3SliPWrA14nBYtN5eCbtHeKda9dFU=; b=fxtXHQvOzQC7y978RbrXAcd4SAtR2BcMYRrfY6W6G8eh1UE86a7sP55Mzn88Yc959v 40OeaCPh2Yz+j8zdDq2CwFr0MJDUxwmoYrQw9fHtblTAhwNFPIL4UfaZ18AjYWRqQBlb mwHdxl73EyLQEwetmtBDeQ3PTZibHjNQYVL77MEHpJtKorCdN+AD6LGcxOM/aNOT/kYb uT4LJmoGWdMKkh8ncSdbvB/xNKDYPGpu6/4/h35gA+BXSje0fTipT6wHtCef0Z7R+xGr u+K2S/rnlnEn3dvYHEr/I9HXVt6QbLnFN0Ig/gBTQnt0vFUE7UvBa461xoN91Jn53Vci NUQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698484575; x=1699089375; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ej/0VQgcuhB6At3SliPWrA14nBYtN5eCbtHeKda9dFU=; b=eo5BLtz/v79ECyH0RHD2T28Y9D+h+PMY3M96DvRDo2NDj2urB7jx+8A4WXaYdnGLN4 B9/u6ou5qnt0C7oQAQr+83560k7lImLKwdhp2x1NpbsWYNeCG9qqPhLRrLpiStllIKFC Q8U3dMeS1/r3IRRgL2F3DFbwsPBFC+ya4lbeYVo970Err7LW1fl7bd8ocwJEXAy/Is0P q7O5ZX7Vi+YVGy4EtVgAAZSjkFgiGnUfMYGzcTIVVQ6xL6tC+eylMSKAe/ruB8uJzfkL 840eorMQSzxRsbujzIdKMBTg5MqYxV2E8oPpW/S/WaFZ4rj3GdsG4xW7sk9AXQnt3w1w GwZA== X-Gm-Message-State: AOJu0YzI5qrxcNLxgnBfcexLj6KKNkel7wOINDaku70jvBAfNj1zt9YX VW3iYJKY3d/9Jfg3LwY84W2qCoWzUkg= X-Google-Smtp-Source: AGHT+IFVTWicPU8YhgsxCDvtOUFHQFrGVO4XwuTdlhOlnV8iVbtLhk3iaM/tL5POsHxYaOcY0Nh+kg== X-Received: by 2002:a50:8748:0:b0:542:d591:443b with SMTP id 8-20020a508748000000b00542d591443bmr758786edv.17.1698484574615; Sat, 28 Oct 2023 02:16:14 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH v5 1/5] hw/isa/vt82c686: Respect SCI interrupt assignment Date: Sat, 28 Oct 2023 11:16:02 +0200 Message-ID: <20231028091606.23700-2-shentey@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231028091606.23700-1-shentey@gmail.com> References: <20231028091606.23700-1-shentey@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::52c; envelope-from=shentey@gmail.com; helo=mail-ed1-x52c.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1698484666140100003 According to the datasheet, SCI interrupts of the power management function aren't routed through the PCI pins but rather directly to the integrated PI= C. The routing is configurable through the ACPI interrupt select register at o= ffset 0x42 in the PCI configuration space of the power management function. Note that pm_update_sci() is now redundant to acpi_update_sci() and shall be removed soon. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/isa/vt82c686.c | 48 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 57bdfb4e78..aeb9434a46 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -40,12 +40,17 @@ #define TYPE_VIA_PM "via-pm" OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM) =20 +#define VIA_PM_SCI_SELECT_OFS 0x42 +#define VIA_PM_SCI_SELECT_MASK 0xf + struct ViaPMState { PCIDevice dev; MemoryRegion io; ACPIREGS ar; APMState apm; PMSMBus smb; + + qemu_irq sci_irq; }; =20 static void pm_io_space_update(ViaPMState *s) @@ -148,18 +153,7 @@ static void pm_update_sci(ViaPMState *s) ACPI_BITMASK_POWER_BUTTON_ENABLE | ACPI_BITMASK_GLOBAL_LOCK_ENABLE | ACPI_BITMASK_TIMER_ENABLE)) !=3D 0); - if (pci_get_byte(s->dev.config + PCI_INTERRUPT_PIN)) { - /* - * FIXME: - * Fix device model that realizes this PM device and remove - * this work around. - * The device model should wire SCI and setup - * PCI_INTERRUPT_PIN properly. - * If PIN# =3D 0(interrupt pin isn't used), don't raise SCI as - * work around. - */ - pci_set_irq(&s->dev, sci_level); - } + qemu_set_irq(s->sci_irq, sci_level); /* schedule a timer interruption if needed */ acpi_pm_tmr_update(&s->ar, (s->ar.pm1.evt.en & ACPI_BITMASK_TIMER_ENAB= LE) && !(pmsts & ACPI_BITMASK_TIMER_STATUS)); @@ -213,6 +207,13 @@ static void via_pm_realize(PCIDevice *dev, Error **err= p) acpi_pm1_cnt_init(&s->ar, &s->io, false, false, 2, false); } =20 +static void via_pm_init(Object *obj) +{ + ViaPMState *s =3D VIA_PM(obj); + + qdev_init_gpio_out_named(DEVICE(obj), &s->sci_irq, "sci", 1); +} + typedef struct via_pm_init_info { uint16_t device_id; } ViaPMInitInfo; @@ -238,6 +239,7 @@ static void via_pm_class_init(ObjectClass *klass, void = *data) static const TypeInfo via_pm_info =3D { .name =3D TYPE_VIA_PM, .parent =3D TYPE_PCI_DEVICE, + .instance_init =3D via_pm_init, .instance_size =3D sizeof(ViaPMState), .abstract =3D true, .interfaces =3D (InterfaceInfo[]) { @@ -568,9 +570,27 @@ static const VMStateDescription vmstate_via =3D { } }; =20 +static void via_isa_set_pm_irq(void *opaque, int n, int level) +{ + ViaISAState *s =3D opaque; + PCIDevice *pci_dev =3D PCI_DEVICE(&s->pm); + uint8_t irq =3D pci_get_byte(pci_dev->config + VIA_PM_SCI_SELECT_OFS) + & VIA_PM_SCI_SELECT_MASK; + + if (irq =3D=3D 2) { + qemu_log_mask(LOG_GUEST_ERROR, "IRQ 2 for PM controller is reserve= d"); + return; + } + + if (irq !=3D 0) { + qemu_set_irq(s->isa_irqs_in[irq], level); + } +} + static void via_isa_init(Object *obj) { ViaISAState *s =3D VIA_ISA(obj); + DeviceState *dev =3D DEVICE(s); =20 object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC); object_initialize_child(obj, "ide", &s->ide, TYPE_VIA_IDE); @@ -578,6 +598,8 @@ static void via_isa_init(Object *obj) object_initialize_child(obj, "uhci2", &s->uhci[1], TYPE_VT82C686B_USB_= UHCI); object_initialize_child(obj, "ac97", &s->ac97, TYPE_VIA_AC97); object_initialize_child(obj, "mc97", &s->mc97, TYPE_VIA_MC97); + + qdev_init_gpio_in_named(dev, via_isa_set_pm_irq, "sci", 1); } =20 static const TypeInfo via_isa_info =3D { @@ -704,6 +726,8 @@ static void via_isa_realize(PCIDevice *d, Error **errp) if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) { return; } + qdev_connect_gpio_out_named(DEVICE(&s->pm), "sci", 0, + qdev_get_gpio_in_named(DEVICE(d), "sci", 0= )); =20 /* Function 5: AC97 Audio */ qdev_prop_set_int32(DEVICE(&s->ac97), "addr", d->devfn + 5); --=20 2.42.0 From nobody Wed Jun 26 20:26:59 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698484633; cv=none; d=zohomail.com; s=zohoarc; b=jiqyGZeARosz3ftAwupg5gpxRfHzk4kOjslS1TOZ2+9SQxZmlA1wEESfSBk3P2zpCmJEMz5cnDF2Q8ltvd4tXvUQodvP+6rdtZjO7nNG+2ChlGUef/a07gb1WhoD1NgO4LpD0+jIALBkDPH4Py1B/2qxYx4NqPubJBbnUBiDNeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698484633; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ka6L50tMkeS83/oFflbpxv4NcubY3eAUnuZsASjQAQc=; b=mdQKQutilbevMCxQReOpwZP1HSRvy0fyIL7mHm5j2G6p9M4VV4HDyAsk+LuJOddvDRebEZldZxcKnOQ2CLCgjyuQt4Qbxc5DTM3YW43yW4DLZavAGXuIKWNONFloY4xGJC7BNM97vZJWsRpRUE/JUoBxYk5qRonNd1kDvcuU3ss= 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 169848463384040.76016745761649; Sat, 28 Oct 2023 02:17:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwfQi-0004al-UX; Sat, 28 Oct 2023 05:16:28 -0400 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 1qwfQa-0004Xr-Qm for qemu-devel@nongnu.org; Sat, 28 Oct 2023 05:16:24 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwfQY-0007L6-B2 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 05:16:19 -0400 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-53e751aeb3cso4536314a12.2 for ; Sat, 28 Oct 2023 02:16:17 -0700 (PDT) Received: from Provence.localdomain (dynamic-089-012-044-170.89.12.pool.telefonica.de. [89.12.44.170]) by smtp.gmail.com with ESMTPSA id q23-20020a50c357000000b00542df4a03d0sm571444edb.16.2023.10.28.02.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 02:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698484576; x=1699089376; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ka6L50tMkeS83/oFflbpxv4NcubY3eAUnuZsASjQAQc=; b=Ec3q77RprQSv9QgI7bbOWFMndWwEJVPCM+LhNl7UGQ2jF5cLIX/9QM8qz4RQyuz2J3 IOJj8BeaJE+xa4yPQN2Ofkort6ykUz0dQdQGWTorXZ4jLj2fGjrwH88l8dWfdf5TaqI3 cjOTIOWVvK/JdeRFF+u4SufuX2oQzhxgoU56Md+EnF4kb9AZdEfGP4aBtAeWDYoUN16z Rse1hraa/L30PYo65yIbH3BMuf111qTYz0qOafRYuvV4Y2Gyf88Awr3ue4+/y7jcMPaT HsupfcPbJgHI7lEzJuxoY/l0nnRAj+90MGI6poqftuzD6/iJKiRZbdNKt+oQg+LPj/h/ BMuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698484576; x=1699089376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ka6L50tMkeS83/oFflbpxv4NcubY3eAUnuZsASjQAQc=; b=d0C4mglUAPb2LZ7R90BHPY4G7stSoLxR566xZ3LUvNdHKGzgqbFyHddw5ONRVgkRAc skao3Ym5N0NsyxvS9BSM9MLJL1iyASJKB3HlylELU0NbkUh8zI0irB1QAABoOrNnt6PN BKrMdo0Dhg06Mgquw6C1IEVwBulobRWEpM8ax5hn6FLBMzgLUgSMnn8mnGUu7GVkg2JP DgJsvjP6uj9WL8qcWgTTBpwH95Vz2DCrW8QjSGzmAWAOIPxB6TOuwTAOc5+3DP9l26Hu sWUnqe3x2fVIJ3uxJO+JIZjkA54zZzS7t460HvODRvxi53CUoX4ddbLScx/lsN5/hsR5 xWkA== X-Gm-Message-State: AOJu0YxfVx/EMu+rQ40tWVkVpgRCKVSGP41uo0v/hxSmD1v4uLajBE4X QSTrrb0Yx/u/rf6VboLuc4bqyQOY3eU= X-Google-Smtp-Source: AGHT+IFYFvvH64xZtFEjUCBPLvAYjfmt44OfTalSm6/98YAIjw4IHR/TO2EE8QigMqvlP2Mcpuk+cA== X-Received: by 2002:a05:6402:174f:b0:53e:817e:488 with SMTP id v15-20020a056402174f00b0053e817e0488mr4266029edx.11.1698484576436; Sat, 28 Oct 2023 02:16:16 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH v5 2/5] hw/isa/vt82c686: Add missing initialization of ACPI general purpose event registers Date: Sat, 28 Oct 2023 11:16:03 +0200 Message-ID: <20231028091606.23700-3-shentey@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231028091606.23700-1-shentey@gmail.com> References: <20231028091606.23700-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::52b; envelope-from=shentey@gmail.com; helo=mail-ed1-x52b.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1698484635663100003 Content-Type: text/plain; charset="utf-8" In order to be able to reuse acpi_update_sci(), these registers need to be initialized. In PIIX4, these registers are used to implement the Frankenstein hotplug functionality and are mapped outside of the device's IO region. Don't do th= at for VIA for now to avoid the Frankenstein functionality. Still, initialize = them to the size of the real VIA PM controller general purpose event registers b= ut stay conservative and don't map them for now. Signed-off-by: Bernhard Beschow --- hw/isa/vt82c686.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index aeb9434a46..60ca781e03 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -40,6 +40,8 @@ #define TYPE_VIA_PM "via-pm" OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM) =20 +#define VIA_PM_GPE_LEN 4 + #define VIA_PM_SCI_SELECT_OFS 0x42 #define VIA_PM_SCI_SELECT_MASK 0xf =20 @@ -179,6 +181,7 @@ static void via_pm_reset(DeviceState *d) acpi_pm1_evt_reset(&s->ar); acpi_pm1_cnt_reset(&s->ar); acpi_pm_tmr_reset(&s->ar); + acpi_gpe_reset(&s->ar); pm_update_sci(s); =20 pm_io_space_update(s); @@ -205,6 +208,7 @@ static void via_pm_realize(PCIDevice *dev, Error **errp) acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io); acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io); acpi_pm1_cnt_init(&s->ar, &s->io, false, false, 2, false); + acpi_gpe_init(&s->ar, VIA_PM_GPE_LEN); } =20 static void via_pm_init(Object *obj) --=20 2.42.0 From nobody Wed Jun 26 20:26:59 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698484671; cv=none; d=zohomail.com; s=zohoarc; b=TM4KR/oSNvbe6+TOdkTijSSxm2x/gvWc1zHSsJAcLfrEsUiaxmYKyhnrk/mPQvCbkKDhGCR56M+5EKnWh2RsEzJxbI6gmJG2MwVwrLzMH+SRHtpIFn4o0Wyc7H5j1SQI1qFYngSgNI/ut+jTTIcNi+++TqsH98wYIWSyxnxUIwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698484671; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Wi4p1sAuChlWfUU4ra+G274cuGU0HLuvHEq0YGgvFkE=; b=cmBaRZBsPsoopFHo/x6Q3bw3CwlutiGZ1pyCS0Iap+al5YKRhuNlHSsnJJ/no8AIiA4/FUl202nqn6C/7RTUVGGfhbebvv3KtUj+cUec8pVSjAsBy5pVFCMcup0Kuqf5lP22mRnvOMd3kh1VGnYliwJJlZbkNLiAt0GYgKU80So= 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 1698484671157532.23828474735; Sat, 28 Oct 2023 02:17:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwfQm-0004bY-7a; Sat, 28 Oct 2023 05:16:32 -0400 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 1qwfQc-0004Y0-6H for qemu-devel@nongnu.org; Sat, 28 Oct 2023 05:16:24 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwfQa-0007LL-Jc for qemu-devel@nongnu.org; Sat, 28 Oct 2023 05:16:21 -0400 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-542d3e47fd5so658182a12.0 for ; Sat, 28 Oct 2023 02:16:19 -0700 (PDT) Received: from Provence.localdomain (dynamic-089-012-044-170.89.12.pool.telefonica.de. [89.12.44.170]) by smtp.gmail.com with ESMTPSA id q23-20020a50c357000000b00542df4a03d0sm571444edb.16.2023.10.28.02.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 02:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698484578; x=1699089378; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wi4p1sAuChlWfUU4ra+G274cuGU0HLuvHEq0YGgvFkE=; b=amrrpOXYDq0e44g/PPgWQSsRKR4om9awERmTA9EtZg/iMAm71yskBLzO8kk4wxT9BP dJnN7JiV0ANpYUpKnzMNypUZ38cdfS21wfCPJI50n/zHLHvSAM3DWm9qdrYv8f0LonT8 8QzXjE5JzJPR8tNZGS1YSK1kUV2H6EA6FNNvI2xglhSzGIQde3uTDykTzICJrk29c3i4 yYMJiYir0VDEa5m92r3+UaX+LlvIQqlCgvD04x2wau/Uk5Skp9XzE5yJA5pN7JQ129S/ 1FAf9kMA7ZG7nt+uTBuXYgvbbUDDkOPQwT//A4LM+sKRQx6miDraO//sws8qNrzSDyXw 5qqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698484578; x=1699089378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wi4p1sAuChlWfUU4ra+G274cuGU0HLuvHEq0YGgvFkE=; b=eNnuD7brTBGDkky/xKYeT7FdVAZzt1wyhM81cZc2reMG8KKiCAsncXZoFb8EfDnB8R OTlpBR2vuOSqjxsMwoeCSv+FN9BtuU+dqQZ9HXA02yYUtv8RZshaKPiy1crjghogcSM1 1HT4Ap+ODJZtoFQF4gqfZB955DvNn8Ep+1Gij8z/70q62Ja61e0Nop2q1KvQ2u0ry22a KLtJIz+3wrctpU9MLR0cuiE8i4NF8vmlOqa7ZjbdrDpfrHhkH8Y/2/pmIv+LdqME5adx X7pURVfkf3zOsaoALJDWnret6FZBiro+TAlfRRGzxzzo6yqdhzmLfQzG0+yoiIiyZtwU grrQ== X-Gm-Message-State: AOJu0YxP3CYhtmmmx7GTFz8/GPi5FE/HTVJk+5tD3Zxhtyx0MmhpVCp9 SUeG9KSZ8sQGhzBZM/8QMyp5OU/GCHE= X-Google-Smtp-Source: AGHT+IG0CIwc3IYLrssR3ntG503WjKwg/WI1LDPgOCHA78sutJDtZScVM7bvaKAMse+n3KpIwdmnbg== X-Received: by 2002:a50:fa93:0:b0:533:4c15:c337 with SMTP id w19-20020a50fa93000000b005334c15c337mr4217563edr.16.1698484577507; Sat, 28 Oct 2023 02:16:17 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH v5 3/5] hw/isa/vt82c686: Reuse acpi_update_sci() Date: Sat, 28 Oct 2023 11:16:04 +0200 Message-ID: <20231028091606.23700-4-shentey@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231028091606.23700-1-shentey@gmail.com> References: <20231028091606.23700-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::529; envelope-from=shentey@gmail.com; helo=mail-ed1-x529.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1698484672381100003 Content-Type: text/plain; charset="utf-8" acpi_update_sci() covers everything pm_update_sci() does. It implements com= mon ACPI funtionality in a generic fashion. Note that it agnostic to any Frankenstein usage of the general purpose event registers in other device models. It just implements a generic mechanism which can be wired to arbitr= ary functionality. Signed-off-by: Bernhard Beschow --- hw/isa/vt82c686.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 60ca781e03..7b44ad9485 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -145,26 +145,10 @@ static const MemoryRegionOps pm_io_ops =3D { }, }; =20 -static void pm_update_sci(ViaPMState *s) -{ - int sci_level, pmsts; - - pmsts =3D acpi_pm1_evt_get_sts(&s->ar); - sci_level =3D (((pmsts & s->ar.pm1.evt.en) & - (ACPI_BITMASK_RT_CLOCK_ENABLE | - ACPI_BITMASK_POWER_BUTTON_ENABLE | - ACPI_BITMASK_GLOBAL_LOCK_ENABLE | - ACPI_BITMASK_TIMER_ENABLE)) !=3D 0); - qemu_set_irq(s->sci_irq, sci_level); - /* schedule a timer interruption if needed */ - acpi_pm_tmr_update(&s->ar, (s->ar.pm1.evt.en & ACPI_BITMASK_TIMER_ENAB= LE) && - !(pmsts & ACPI_BITMASK_TIMER_STATUS)); -} - static void pm_tmr_timer(ACPIREGS *ar) { ViaPMState *s =3D container_of(ar, ViaPMState, ar); - pm_update_sci(s); + acpi_update_sci(&s->ar, s->sci_irq); } =20 static void via_pm_reset(DeviceState *d) @@ -182,7 +166,7 @@ static void via_pm_reset(DeviceState *d) acpi_pm1_cnt_reset(&s->ar); acpi_pm_tmr_reset(&s->ar); acpi_gpe_reset(&s->ar); - pm_update_sci(s); + acpi_update_sci(&s->ar, s->sci_irq); =20 pm_io_space_update(s); smb_io_space_update(s); --=20 2.42.0 From nobody Wed Jun 26 20:26:59 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698484630; cv=none; d=zohomail.com; s=zohoarc; b=asqUjat7Tl3nhyanjXv6Ty6h+x92EXYemWBTg1qwKwYRdMWzFBQNxW3AMMB3K8GdkLJZd1+w5hzms4xT4P2Y0i/y0ZmXqdPLxAv54RkCGeqLq8xRr7Qi51Prqa7l3Z9LFM8iuW3OEfgKP5Vx0FQasESt6ROPLkXDY23dt1E74Bs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698484630; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=H5vrwRUQXmhV2FmE/eFche3gCK9KU8MjSPmr8QXRFCg=; b=OrzUUotyT+xVNHW0SSDpPkOBSQ/sGtdggtKSELnaxFeLNxkfIndgjX9EYDgVtkLdpPe+rPLUBl8agp9tFcZ2xAWKie8j1b5N9MK20mNTq37IWsZYc4Z8ePjCx4x8TXWy8FhVc957Gm8EmE28hvjn9LirP1mLaa+b1+VpO7JCL1M= 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 1698484630536978.0574781885289; Sat, 28 Oct 2023 02:17:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwfQk-0004bS-Jh; Sat, 28 Oct 2023 05:16:32 -0400 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 1qwfQd-0004YD-Os for qemu-devel@nongnu.org; Sat, 28 Oct 2023 05:16:24 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwfQc-0007LV-7X for qemu-devel@nongnu.org; Sat, 28 Oct 2023 05:16:23 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-538e8eca9c1so4437183a12.3 for ; Sat, 28 Oct 2023 02:16:21 -0700 (PDT) Received: from Provence.localdomain (dynamic-089-012-044-170.89.12.pool.telefonica.de. [89.12.44.170]) by smtp.gmail.com with ESMTPSA id q23-20020a50c357000000b00542df4a03d0sm571444edb.16.2023.10.28.02.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 02:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698484578; x=1699089378; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H5vrwRUQXmhV2FmE/eFche3gCK9KU8MjSPmr8QXRFCg=; b=Oeoqa0YMxc/LRQQTcTD82K+uHAEbtiXkbKNxQm7/SdqvJGfS1tUgJJeNh0shiyFYwl xexKnVJhV4p3/4RVP89YoSNl1AMDqamtg0ojluoz7a6nzgZhbuPtJJgzMDw96zXp66dd Tx1j8K/NTN9rgFcY+M1H6/+13AjUDRDv9z4qk5fIdch+b/41A+kahN0UlRU5+sU/Wiui XGbWHYR0+npACXvax8nqHt1HiIyGuTx7Hu6FkHSHw0Mdu289oAHVukInrMpYDY1p0M+V 2Y/Jhm6Cy7+IUzgTK2MFbVrFp7e7EOurkFBUIJSYqJQECY/jHhWH0EvPzHw9JiU0dpGs Jcgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698484578; x=1699089378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H5vrwRUQXmhV2FmE/eFche3gCK9KU8MjSPmr8QXRFCg=; b=R8JPDcxId9fxvX6E9EFMnptJ8PyTA5Q3LSF047Zu1ulUET/b8QqQFFDljFjYaCmSX6 2GjEx7Ym55hcCgKQymFUMsh9FNQoINGqOJCMGNOOuSQ5l6hjUutAiNc9woveMQugaKgj 9JVNxmTqkTINL6FPhBVkz1BngyB8ssGzgv2JqPvmAMLjoDToscLgAqRAOihLeCHl+lxF 68k3aq3XPUvtJ0FOcaURQ2A9ZLSCEm6D55RUmmImWSBg725CmiZHgvvyT2lf7e4mDNzi Q/BtHjzD4ESf4DDXu36nRXQzI1cxEMZcVtBSZRSCJLW2wLDgsGYKRgfDU31zBZWzsW4H GJdQ== X-Gm-Message-State: AOJu0YyVvF517vkh3w7Xb3dS2erqPdpPxpglYwXba+TJiP1hkI4man1I redIkJVDEVQtiD6snlVwdSGqNXHv51M= X-Google-Smtp-Source: AGHT+IF7MNWU013FdkEnNBUZodOv8taTLn0gFDC/KtngOEhe4HzY3yMbbyLvtEXD5tzBEfZgCizgxA== X-Received: by 2002:a05:6402:b52:b0:53d:b71d:34a7 with SMTP id bx18-20020a0564020b5200b0053db71d34a7mr3746082edb.6.1698484578368; Sat, 28 Oct 2023 02:16:18 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH v5 4/5] hw/isa/vt82c686: Implement ACPI powerdown Date: Sat, 28 Oct 2023 11:16:05 +0200 Message-ID: <20231028091606.23700-5-shentey@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231028091606.23700-1-shentey@gmail.com> References: <20231028091606.23700-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::533; envelope-from=shentey@gmail.com; helo=mail-ed1-x533.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1698484631759100005 Content-Type: text/plain; charset="utf-8" Allows guests to be powered off via an ACPI power button event which can be triggered e.g. through the GTK GUI. Signed-off-by: Bernhard Beschow --- hw/isa/vt82c686.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 7b44ad9485..e8ec63dea9 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -33,8 +33,10 @@ #include "qapi/error.h" #include "qemu/log.h" #include "qemu/module.h" +#include "qemu/notify.h" #include "qemu/range.h" #include "qemu/timer.h" +#include "sysemu/runstate.h" #include "trace.h" =20 #define TYPE_VIA_PM "via-pm" @@ -52,6 +54,8 @@ struct ViaPMState { APMState apm; PMSMBus smb; =20 + Notifier powerdown_notifier; + qemu_irq sci_irq; }; =20 @@ -172,6 +176,13 @@ static void via_pm_reset(DeviceState *d) smb_io_space_update(s); } =20 +static void via_pm_powerdown_req(Notifier *n, void *opaque) +{ + ViaPMState *s =3D container_of(n, ViaPMState, powerdown_notifier); + + acpi_pm1_evt_power_down(&s->ar); +} + static void via_pm_realize(PCIDevice *dev, Error **errp) { ViaPMState *s =3D VIA_PM(dev); @@ -193,6 +204,9 @@ static void via_pm_realize(PCIDevice *dev, Error **errp) acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io); acpi_pm1_cnt_init(&s->ar, &s->io, false, false, 2, false); acpi_gpe_init(&s->ar, VIA_PM_GPE_LEN); + + s->powerdown_notifier.notify =3D via_pm_powerdown_req; + qemu_register_powerdown_notifier(&s->powerdown_notifier); } =20 static void via_pm_init(Object *obj) --=20 2.42.0 From nobody Wed Jun 26 20:26:59 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698484677; cv=none; d=zohomail.com; s=zohoarc; b=JbYYRK+U/sxo0S2LA83h7lQjzcH8JTGTTVn7T388b+zsZSvPapzDXMNhK10c8BcXQ/lJ9m9+pUhdecI//mggb3YO+Wvaq5fyvlHJDlwffmWSsq1QZmMRJXo2dwI+nYfWgg3KrF+Xhj3xVLTLfF2WrszXG2E1Zd4kcXqu1ZER8/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698484677; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=u5GMr+5sSi8Dki015LfIdiYa+ARvYPPeJg2I3MJ1Pjw=; b=ZV4J0gsy6oH86WDBOZk0kgCQa40kWXrK3mz+0OqBlzY69eN+l3ZgKvtHWl27C/IiprrZZ/FYYkR/6gsPlilBOAcSU1EdnsEofx9vXV+CTBBXlAIxgoUXNRNeJFFxTWv1xB/JjDInhcJJFSdv6xcNV5wq35KiuwM9of+D7/mXMtM= 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 1698484677142883.4583858298562; Sat, 28 Oct 2023 02:17:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwfQm-0004bc-EU; Sat, 28 Oct 2023 05:16:32 -0400 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 1qwfQe-0004YM-TA for qemu-devel@nongnu.org; Sat, 28 Oct 2023 05:16:24 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwfQd-0007Lh-1l for qemu-devel@nongnu.org; Sat, 28 Oct 2023 05:16:24 -0400 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-51e28cac164so8181705a12.1 for ; Sat, 28 Oct 2023 02:16:22 -0700 (PDT) Received: from Provence.localdomain (dynamic-089-012-044-170.89.12.pool.telefonica.de. [89.12.44.170]) by smtp.gmail.com with ESMTPSA id q23-20020a50c357000000b00542df4a03d0sm571444edb.16.2023.10.28.02.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 02:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698484581; x=1699089381; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u5GMr+5sSi8Dki015LfIdiYa+ARvYPPeJg2I3MJ1Pjw=; b=FnAS98+OImNnNEaqfzBPWy00yGBPKl+8tsPPq0aZQo3gxpF+7oaUTc8o9qaFHsNPqP co5teYMDIp5eTuMsEYv89M4g+MV8bSXPW1ZEmYf9Ibz5ZQn0Puh++hhK8LnJl/8RnULE WSkdFsqdWG6rdydgZHJzaE2fb7Gkl9K5hMmVskAAL0/H3SMFCRaCzmGKLrcVDkKjtpsa QO+AUoOEUFmV1PDrg37s/v9ZSU38Lp3Pi/sLwr4GZ1/OGyCwFrkQia4CN0JsmIMVJ8eS H7+bPIgWkKNlfbgR0p8Rx1ZZnRa80/lGKIGHzl0pjS3mwcsONR6pW+J7jABfZm9Ukhy0 rWgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698484581; x=1699089381; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u5GMr+5sSi8Dki015LfIdiYa+ARvYPPeJg2I3MJ1Pjw=; b=dXMTuXvhlmMXNxFtebr0nvPkLrEfXkKs4EnhEiP68CxRlhr35cEVvZo5gTT0IZfrJy MgGf9dWacuAkmzLCH2gTqIJDXM79qJX8/Uf3ZU8IuFjnynud2MqAgLB3qqyTZBaeEd18 ZLVo4WC9EzNrZiwpcj47AHQFyQlwHaOClyacRRgibJn9aZknHabeF0HmwZjcj+pV/SL/ Ly5pNLoX9WYQcceqbPThFK7IrlAWM2kGRjYMHShvdj4QTVoiwL5Gwh9T3sxuNJYmaA/J 1mYf/3jgM2hnAJ8TFDIlBBTzOotQZ6MOTQPPp4Iz0IyytPSFE7sJFRmWUSjfgDmCrBDY ZkyQ== X-Gm-Message-State: AOJu0YzGBlTsTSYI2BHDubT96G81s0pCc9asEKlJyQdMvLTSE5rmAT+O 9z//5xQ53RNP+qaNdq9zCh1TSgShYTc= X-Google-Smtp-Source: AGHT+IFWVpQ+i6sO+Y7sTRNaLE+gRJaGs+Tv4y+kp7zK42hVPnWOHHEVpP6m2wEUbIPkvGZxkrKFpw== X-Received: by 2002:a50:cc49:0:b0:52c:f73:3567 with SMTP id n9-20020a50cc49000000b0052c0f733567mr8037582edi.13.1698484580702; Sat, 28 Oct 2023 02:16:20 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bernhard Beschow Subject: [PATCH v5 5/5] hw/isa/vt82c686: Implement software-based SMI triggering Date: Sat, 28 Oct 2023 11:16:06 +0200 Message-ID: <20231028091606.23700-6-shentey@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231028091606.23700-1-shentey@gmail.com> References: <20231028091606.23700-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::52d; envelope-from=shentey@gmail.com; helo=mail-ed1-x52d.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1698484678500100003 Content-Type: text/plain; charset="utf-8" If enabled, SMIs can be triggered via software by writing to an IO-mapped p= ort. SMIs usually trigger execution of BIOS code. If appropriate values are writ= ten to the port, the BIOS transitions the system into or out of ACPI mode. Note that APMState implements Intel-specific behavior where there are two IO ports which are mapped at fixed addresses. In VIA, there is only one such p= ort which is located inside a relocatable IO-mapped region. Hence, there is no = point in reusing APMState. Signed-off-by: Bernhard Beschow --- hw/isa/vt82c686.c | 95 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 8 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index e8ec63dea9..361b3bed0a 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -27,7 +27,6 @@ #include "hw/timer/i8254.h" #include "hw/rtc/mc146818rtc.h" #include "migration/vmstate.h" -#include "hw/isa/apm.h" #include "hw/acpi/acpi.h" #include "hw/i2c/pm_smbus.h" #include "qapi/error.h" @@ -42,6 +41,16 @@ #define TYPE_VIA_PM "via-pm" OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM) =20 +#define VIA_PM_IO_GBLEN 0x2a +#define VIA_PM_IO_GBLEN_SW_SMI_EN (1 << 6) + +#define VIA_PM_IO_GBLCTL 0x2c +#define VIA_PM_IO_GBLCTL_SMI_EN 1 +#define VIA_PM_IO_GBLCTL_SMIIG (1 << 4) +#define VIA_PM_IO_GBLCTL_INSMI (1 << 8) + +#define VIA_PM_IO_SMI_CMD 0x2f + #define VIA_PM_GPE_LEN 4 =20 #define VIA_PM_SCI_SELECT_OFS 0x42 @@ -49,14 +58,19 @@ OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM) =20 struct ViaPMState { PCIDevice dev; + MemoryRegion io; ACPIREGS ar; - APMState apm; + uint16_t gbl_en; + uint16_t gbl_ctl; + uint8_t smi_cmd; + PMSMBus smb; =20 Notifier powerdown_notifier; =20 qemu_irq sci_irq; + qemu_irq smi_irq; }; =20 static void pm_io_space_update(ViaPMState *s) @@ -90,7 +104,7 @@ static int vmstate_acpi_post_load(void *opaque, int vers= ion_id) =20 static const VMStateDescription vmstate_acpi =3D { .name =3D "vt82c686b_pm", - .version_id =3D 1, + .version_id =3D 2, .minimum_version_id =3D 1, .post_load =3D vmstate_acpi_post_load, .fields =3D (VMStateField[]) { @@ -98,9 +112,11 @@ static const VMStateDescription vmstate_acpi =3D { VMSTATE_UINT16(ar.pm1.evt.sts, ViaPMState), VMSTATE_UINT16(ar.pm1.evt.en, ViaPMState), VMSTATE_UINT16(ar.pm1.cnt.cnt, ViaPMState), - VMSTATE_STRUCT(apm, ViaPMState, 0, vmstate_apm, APMState), VMSTATE_TIMER_PTR(ar.tmr.timer, ViaPMState), VMSTATE_INT64(ar.tmr.overflow_time, ViaPMState), + VMSTATE_UINT16(gbl_en, ViaPMState), + VMSTATE_UINT16(gbl_ctl, ViaPMState), + VMSTATE_UINT8(smi_cmd, ViaPMState), VMSTATE_END_OF_LIST() } }; @@ -128,15 +144,75 @@ static void pm_write_config(PCIDevice *d, uint32_t ad= dr, uint32_t val, int len) } } =20 +static void via_pm_apm_ctrl_changed(ViaPMState *s, uint8_t val) +{ + s->smi_cmd =3D val; + + if (s->gbl_en & VIA_PM_IO_GBLEN_SW_SMI_EN + && s->gbl_ctl & VIA_PM_IO_GBLCTL_SMI_EN + && !(s->gbl_ctl & VIA_PM_IO_GBLCTL_SMIIG + && s->gbl_ctl & VIA_PM_IO_GBLCTL_INSMI)) { + s->gbl_ctl |=3D VIA_PM_IO_GBLCTL_INSMI; + + if (s->smi_irq) { + qemu_irq_raise(s->smi_irq); + } + } +} + static void pm_io_write(void *op, hwaddr addr, uint64_t data, unsigned siz= e) { + ViaPMState *s =3D op; + trace_via_pm_io_write(addr, data, size); + + switch (addr) { + case VIA_PM_IO_GBLEN: + s->gbl_en =3D (s->gbl_en & 0xff00) | data; + break; + case VIA_PM_IO_GBLEN + 1: + s->gbl_en =3D (s->gbl_en & 0x00ff) | (data << 8); + break; + case VIA_PM_IO_GBLCTL: + s->gbl_ctl =3D (s->gbl_ctl & 0xff00) | data; + break; + case VIA_PM_IO_GBLCTL + 1: + data <<=3D 8; + data &=3D ~(s->gbl_ctl & VIA_PM_IO_GBLCTL_INSMI); + s->gbl_ctl =3D (s->gbl_ctl & 0x00ff) | data; + break; + case VIA_PM_IO_SMI_CMD: + via_pm_apm_ctrl_changed(s, data); + break; + } } =20 static uint64_t pm_io_read(void *op, hwaddr addr, unsigned size) { - trace_via_pm_io_read(addr, 0, size); - return 0; + ViaPMState *s =3D op; + uint64_t data =3D 0; + + switch (addr) { + case VIA_PM_IO_GBLEN: + data =3D s->gbl_en & 0xff; + break; + case VIA_PM_IO_GBLEN + 1: + data =3D s->gbl_en >> 8; + break; + case VIA_PM_IO_GBLCTL: + data =3D s->gbl_ctl & 0xff; + break; + case VIA_PM_IO_GBLCTL + 1: + data =3D (s->gbl_ctl >> 8) & 0xd; + break; + case VIA_PM_IO_SMI_CMD: + data =3D s->smi_cmd; + break; + } + + trace_via_pm_io_read(addr, data, size); + + return data; } =20 static const MemoryRegionOps pm_io_ops =3D { @@ -166,6 +242,10 @@ static void via_pm_reset(DeviceState *d) /* SMBus IO base */ pci_set_long(s->dev.config + 0x90, 1); =20 + s->gbl_en =3D 0; + s->gbl_ctl =3D VIA_PM_IO_GBLCTL_SMIIG; + s->smi_cmd =3D 0; + acpi_pm1_evt_reset(&s->ar); acpi_pm1_cnt_reset(&s->ar); acpi_pm_tmr_reset(&s->ar); @@ -194,8 +274,6 @@ static void via_pm_realize(PCIDevice *dev, Error **errp) memory_region_add_subregion(pci_address_space_io(dev), 0, &s->smb.io); memory_region_set_enabled(&s->smb.io, false); =20 - apm_init(dev, &s->apm, NULL, s); - memory_region_init_io(&s->io, OBJECT(dev), &pm_io_ops, s, "via-pm", 12= 8); memory_region_add_subregion(pci_address_space_io(dev), 0, &s->io); memory_region_set_enabled(&s->io, false); @@ -214,6 +292,7 @@ static void via_pm_init(Object *obj) ViaPMState *s =3D VIA_PM(obj); =20 qdev_init_gpio_out_named(DEVICE(obj), &s->sci_irq, "sci", 1); + qdev_init_gpio_out_named(DEVICE(obj), &s->smi_irq, "smi-irq", 1); } =20 typedef struct via_pm_init_info { --=20 2.42.0