From nobody Tue Nov 26 10:30:07 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708966235; cv=none; d=zohomail.com; s=zohoarc; b=ScdfEsUUSepgw+gvqd53oPonWszTtBTAO0OlIrSS4rBmyxpzkZtuQibAEJ5Bg/K4dl2naJ28JQTqbA3GiXQtmE5GfWShl67RKwThY6GnheN6ODnDnQ2B1qp7dbdXmL7p25/ZvNCGM+i9H1M2gfzAvTEz5cmBFLdRjqJcPXPSfD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708966235; 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=BSZsP7iZ+WCm1GRQ6l/dckqzk5JVKU9/jCan+ZQ8ppM=; b=MpeEIqEy7n1TOPXc3eOXazIXGG8ixiFmdkFoLV4VX1v3KQ2Qw1Ym2/5BckLadDrx70Yq8W2A77S6QjW74p9V//6wmP0ypAioRynKV+Xnv2mj7KfoCaZ2TTZqUwqLJz0Wg1oe0DitkrMdScG8yutYCNbkWaR8cMnrM9UoS3r/iCY= 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 1708966235548314.9187396078804; Mon, 26 Feb 2024 08:50:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1reeAf-00063o-Ts; Mon, 26 Feb 2024 11:49:42 -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 1reeAe-0005y9-Jf for qemu-devel@nongnu.org; Mon, 26 Feb 2024 11:49:40 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1reeAc-0006Gn-Hc for qemu-devel@nongnu.org; Mon, 26 Feb 2024 11:49:40 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-412a57832fcso7833435e9.1 for ; Mon, 26 Feb 2024 08:49:38 -0800 (PST) Received: from m1x-phil.lan ([176.187.223.153]) by smtp.gmail.com with ESMTPSA id o5-20020a05600c510500b00412157dc70bsm8942178wms.30.2024.02.26.08.49.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 26 Feb 2024 08:49:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708966176; x=1709570976; 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=BSZsP7iZ+WCm1GRQ6l/dckqzk5JVKU9/jCan+ZQ8ppM=; b=GPopM5Kgqxq1LK39e2qEN0yZEP86Ffebq/R8Mc2TB/iZuZsU9M4vu9z18xHV0/evAK yRBmmQYB1o+DRTO6eitcl/qT+RY+nWy34KAv6mq2CdTFK42lxLGoA0NvsRigrOM8H0L7 7EQ/NSCTBsTa++I/tumLwWgkk9CAJEiqJNZVEqU9TbjER+UObQSWOk0Nirpzr+4A/8G7 OAvQR3vwpwMVrp6aGNq88629H1e+4xFv9vIVS/DSNMY+4eqdKvmxh5dA53c758kmh3O6 dXUgXqnElSPFplYgI9jCgDGtAvHbnpm7krZQp7nz9PgRl1EOB5fSknU2iJafwa4/zbpc MtQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708966176; x=1709570976; 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=BSZsP7iZ+WCm1GRQ6l/dckqzk5JVKU9/jCan+ZQ8ppM=; b=VbXiFbwEqcTtVSybF20idAE37JiuColuyDETxvqTNMrr81DpYF144d+s+TL/sHgGYs npBDqd9LH8io/z3fI49WjbYGVV+SSD+GjqqEXPBeBbU/MlG8RdU4u+LnnTKwkeSYP55/ 8ZkRYVSoUMSvg1PSDAElwafVmYiqH4aFpPMQDnOhY1Is6M5QHFZxh/yyFk7ntH0psXWO cssKfhnrfLTsmsOK5cjJUSFc02Rc/xhj4Lk65IHdcmnMXwZfOHqwUqttc1C9BVavr/AA BwtPZoxUS25hcxMtBa6IZK9oCId4OOsYkw/1Gfj4yQewH3vCgJq9V1ZHU11UbzKfcTvA eLyA== X-Gm-Message-State: AOJu0YxSaL/OWlltdS6qgcFP1yXUQwCcZd0Jwb+yvGIisAP/HAa7rz7h D/g8CpqKo31Yy+CE0tlrn5UzI/GTTQ6lN2G2r/5+05X4hzvQ1XSV7gaJfoOmT45RWbxneZ7nsfl S X-Google-Smtp-Source: AGHT+IFSqJhGU2EosIlK+UpRwF6yY5sOcOjxBheJ49rYM49QKig+cwz48xBMpyY0ZV2EeaJixfFq6A== X-Received: by 2002:a05:600c:1f86:b0:412:8306:a7bb with SMTP id je6-20020a05600c1f8600b004128306a7bbmr6393130wmb.12.1708966176308; Mon, 26 Feb 2024 08:49:36 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , "Edgar E . Iglesias" , Anton Johansson , Mark Cave-Ayland , Peter Maydell , Zhao Liu , Eduardo Habkost , Marcel Apfelbaum , Igor Mammedov , Richard Henderson , Ani Sinha , Bernhard Beschow , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , "Michael S. Tsirkin" , Laszlo Ersek , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 3/5] hw/ahci/ich9_tco: Set CPU SMI# interrupt using QDev GPIO API Date: Mon, 26 Feb 2024 17:49:10 +0100 Message-ID: <20240226164913.94077-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240226164913.94077-1-philmd@linaro.org> References: <20240226164913.94077-1-philmd@linaro.org> 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::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @linaro.org) X-ZM-MESSAGEID: 1708966237622100003 Use the CPU "SMI" IRQ, removing a call to cpu_interrupt() from hw/. Keep a reference to the IRQ in the TCOIORegs structure, which while being names with the Regs suffix doesn't contain only registers. Remove ich9_generate_smi(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- I suppose ideally ICH9 TCO would be a QOM object... --- include/hw/acpi/ich9.h | 1 + include/hw/acpi/ich9_tco.h | 4 ++-- hw/acpi/ich9.c | 3 ++- hw/acpi/ich9_tco.c | 13 ++++++++++--- hw/isa/ich9_lpc.c | 5 ----- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index 3587a35c9f..84e1557257 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -49,6 +49,7 @@ typedef struct ICH9LPCPMRegs { uint32_t smi_sts; =20 qemu_irq irq; /* SCI */ + qemu_irq smi; /* SMI */ =20 uint32_t pm_io_base; Notifier powerdown_notifier; diff --git a/include/hw/acpi/ich9_tco.h b/include/hw/acpi/ich9_tco.h index 68ee64942f..31730b8e14 100644 --- a/include/hw/acpi/ich9_tco.h +++ b/include/hw/acpi/ich9_tco.h @@ -73,10 +73,10 @@ typedef struct TCOIORegs { uint8_t timeouts_no; =20 MemoryRegion io; + qemu_irq smi; } TCOIORegs; =20 -void ich9_acpi_pm_tco_init(TCOIORegs *tr, MemoryRegion *parent); -void ich9_generate_smi(void); +void ich9_acpi_pm_tco_init(TCOIORegs *tr, MemoryRegion *parent, qemu_irq s= mi); =20 extern const VMStateDescription vmstate_ich9_sm_tco; =20 diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 1f41ab49c4..e0b3838365 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -318,7 +318,8 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm= , qemu_irq sci_irq) memory_region_add_subregion(&pm->io, ICH9_PMIO_SMI_EN, &pm->io_smi); =20 if (pm->enable_tco) { - ich9_acpi_pm_tco_init(&pm->tco_regs, &pm->io); + pm->smi =3D qdev_get_gpio_in_named(DEVICE(first_cpu), "SMI", 0); + ich9_acpi_pm_tco_init(&pm->tco_regs, &pm->io, pm->smi); } =20 if (pm->acpi_pci_hotplug.use_acpi_hotplug_bridge) { diff --git a/hw/acpi/ich9_tco.c b/hw/acpi/ich9_tco.c index 7499ec17db..1061b18b7e 100644 --- a/hw/acpi/ich9_tco.c +++ b/hw/acpi/ich9_tco.c @@ -14,6 +14,7 @@ =20 #include "hw/acpi/ich9_tco.h" #include "hw/isa/ich9_lpc.h" +#include "hw/irq.h" #include "trace.h" =20 enum { @@ -31,6 +32,11 @@ enum { SW_IRQ_GEN_DEFAULT =3D 0x03, }; =20 +static void ich9_generate_smi(TCOIORegs *tr) +{ + qemu_irq_raise(tr->smi); +} + static inline void tco_timer_reload(TCOIORegs *tr) { int ticks =3D tr->tco.tmr & TCO_TMR_MASK; @@ -72,7 +78,7 @@ static void tco_timer_expired(void *opaque) } =20 if (pm->smi_en & ICH9_PMIO_SMI_EN_TCO_EN) { - ich9_generate_smi(); + ich9_generate_smi(tr); } tr->tco.rld =3D tr->tco.tmr; tco_timer_reload(tr); @@ -154,7 +160,7 @@ static void tco_ioport_writew(TCOIORegs *tr, uint32_t a= ddr, uint32_t val) case TCO_DAT_IN: tr->tco.din =3D val; tr->tco.sts1 |=3D SW_TCO_SMI; - ich9_generate_smi(); + ich9_generate_smi(tr); break; case TCO_DAT_OUT: tr->tco.dout =3D val; @@ -225,7 +231,7 @@ static const MemoryRegionOps tco_io_ops =3D { .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 -void ich9_acpi_pm_tco_init(TCOIORegs *tr, MemoryRegion *parent) +void ich9_acpi_pm_tco_init(TCOIORegs *tr, MemoryRegion *parent, qemu_irq s= mi) { *tr =3D (TCOIORegs) { .tco =3D { @@ -245,6 +251,7 @@ void ich9_acpi_pm_tco_init(TCOIORegs *tr, MemoryRegion = *parent) .tco_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, tco_timer_expi= red, tr), .expire_time =3D -1, .timeouts_no =3D 0, + .smi =3D smi, }; memory_region_init_io(&tr->io, memory_region_owner(parent), &tco_io_ops, tr, "sm-tco", ICH9_PMIO_TCO_LEN); diff --git a/hw/isa/ich9_lpc.c b/hw/isa/ich9_lpc.c index 2339f66e0f..b1f41158c5 100644 --- a/hw/isa/ich9_lpc.c +++ b/hw/isa/ich9_lpc.c @@ -353,11 +353,6 @@ static PCIINTxRoute ich9_route_intx_pin_to_irq(void *o= paque, int pirq_pin) return route; } =20 -void ich9_generate_smi(void) -{ - cpu_interrupt(first_cpu, CPU_INTERRUPT_SMI); -} - /* Returns -1 on error, IRQ number on success */ static int ich9_lpc_sci_irq(ICH9LPCState *lpc) { --=20 2.41.0