From nobody Thu May 9 01:47:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574069015; cv=none; d=zoho.com; s=zohoarc; b=JtJkHLOm8e05jS3E2AWnL2HDbNn7J/J2Stk+TsfbkOfxphGh1Te5+MxoQcRsVvHGxLq/i3aVvKAFnqSu+6DTxt9MvDjplInnXEBNrAj9nxOsvR9w0MkqMeT+O9nJOeKBoSxApaJpk+HSsy6CNXI3690o0PDC+qBn7ULSLo+lLa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574069015; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Ch+VZD0TNK2lW72+YnTgMkP0tPv18dzjF/1xzI/fuyk=; b=DTiqy7SzMUY6t15Vj4308c926uZfnmL7FTvD3hrQQp7vKFzITG3y/5hObjd1QY9NFSiNX6Nl+4YEabeKLQgnbCKElLIlgz2Iy960M0D/hHAt5aa/rjJ7YRcuL/rqtloOUQ7DPtVmbSWbq8wIAohhX6VLkzoRGs9zjdH025yMim4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574069015133657.5124276083874; Mon, 18 Nov 2019 01:23:35 -0800 (PST) Received: from localhost ([::1]:59726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWdFq-0001AO-C4 for importer@patchew.org; Mon, 18 Nov 2019 04:23:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57059) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iWdF0-0000KL-2G for qemu-devel@nongnu.org; Mon, 18 Nov 2019 04:22:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iWdEy-0008Ea-Me for qemu-devel@nongnu.org; Mon, 18 Nov 2019 04:22:38 -0500 Received: from 4.mo68.mail-out.ovh.net ([46.105.59.63]:50020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iWdEy-0008E1-GK for qemu-devel@nongnu.org; Mon, 18 Nov 2019 04:22:36 -0500 Received: from player796.ha.ovh.net (unknown [10.108.54.94]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 5808214CA92 for ; Mon, 18 Nov 2019 10:22:34 +0100 (CET) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player796.ha.ovh.net (Postfix) with ESMTPSA id B3DF4C158129; Mon, 18 Nov 2019 09:22:27 +0000 (UTC) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: David Gibson Subject: [PATCH] ppc/pnv: Create BMC devices at machine init Date: Mon, 18 Nov 2019 10:22:22 +0100 Message-Id: <20191118092222.15691-1-clg@kaod.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Ovh-Tracer-Id: 7123005762017659878 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrudeghedgtdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdqfffguegfifdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffogggtgfesthekredtredtjeenucfhrhhomhepveorughrihgtucfnvgcuifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucfkpheptddrtddrtddrtddpledtrdejiedrhedtrddvvdefnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrhejleeirdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheptghlgheskhgrohgurdhorhhgpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehnohhnghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.59.63 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, Corey Minyard , Oliver O'Halloran , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The BMC of the OpenPOWER systems monitors the machine state using sensors, controls the power and controls the access to the PNOR flash device containing the firmware image required to boot the host. QEMU models the power cycle process, access to the sensors and access to the PNOR device. But, for these features to be available, the QEMU PowerNV machine needs two extras devices on the command line, an IPMI BT device for communication and a BMC backend device: -device ipmi-bmc-sim,id=3Dbmc0 -device isa-ipmi-bt,bmc=3Dbmc0,irq=3D10 The BMC properties are then defined accordingly in the device tree and OPAL self adapts. If a BMC device and an IPMI BT device are not available, OPAL does not try to communicate with the BMC in any manner. This is not how real systems behave. To be closer to the default behavior, create an IPMI BMC simulator device and an IPMI BT device at machine initialization time. We loose the ability to define an external BMC device but there are benefits: - a better match with real systems, - a better test coverage of the OPAL code, - system powerdown and reset commands that work, - a QEMU device tree compliant with the specifications (*). (*) Still needs a MBOX device. Signed-off-by: C=C3=A9dric Le Goater Acked-by: Corey Minyard --- include/hw/ppc/pnv.h | 2 +- hw/ppc/pnv.c | 33 ++++++++++++++++----------------- hw/ppc/pnv_bmc.c | 20 +++++++++++++++++--- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 07c56c05ad30..90f1343ed07c 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -198,7 +198,7 @@ static inline bool pnv_is_power9(PnvMachineState *pnv) */ void pnv_dt_bmc_sensors(IPMIBmc *bmc, void *fdt); void pnv_bmc_powerdown(IPMIBmc *bmc); -int pnv_bmc_hiomap(IPMIBmc *bmc); +IPMIBmc *pnv_bmc_create(void); =20 /* * POWER8 MMIO base addresses diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index c3ac0d6d5b4a..2117d879895c 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -551,27 +551,10 @@ static void pnv_powerdown_notify(Notifier *n, void *o= paque) =20 static void pnv_reset(MachineState *machine) { - PnvMachineState *pnv =3D PNV_MACHINE(machine); void *fdt; - Object *obj; =20 qemu_devices_reset(); =20 - /* - * OpenPOWER systems have a BMC, which can be defined on the - * command line with: - * - * -device ipmi-bmc-sim,id=3Dbmc0 - * - * This is the internal simulator but it could also be an external - * BMC. - */ - obj =3D object_resolve_path_type("", "ipmi-bmc-sim", NULL); - if (obj) { - pnv->bmc =3D IPMI_BMC(obj); - pnv_bmc_hiomap(pnv->bmc); - } - fdt =3D pnv_dt_create(machine); =20 /* Pack resulting tree */ @@ -629,6 +612,16 @@ static bool pnv_match_cpu(const char *default_type, co= nst char *cpu_type) return ppc_default->pvr_match(ppc_default, ppc->pvr); } =20 +static void ipmi_bt_init(ISABus *bus, IPMIBmc *bmc, uint32_t irq) +{ + Object *obj; + + obj =3D OBJECT(isa_create(bus, "isa-ipmi-bt")); + object_property_set_link(obj, OBJECT(bmc), "bmc", &error_fatal); + object_property_set_int(obj, irq, "irq", &error_fatal); + object_property_set_bool(obj, true, "realized", &error_fatal); +} + static void pnv_init(MachineState *machine) { PnvMachineState *pnv =3D PNV_MACHINE(machine); @@ -751,6 +744,9 @@ static void pnv_init(MachineState *machine) } g_free(chip_typename); =20 + /* Create the machine BMC simulator */ + pnv->bmc =3D pnv_bmc_create(); + /* Instantiate ISA bus on chip 0 */ pnv->isa_bus =3D pnv_isa_create(pnv->chips[0], &error_fatal); =20 @@ -760,6 +756,9 @@ static void pnv_init(MachineState *machine) /* Create an RTC ISA device too */ mc146818_rtc_init(pnv->isa_bus, 2000, NULL); =20 + /* Create the IPMI BT device for communication with the BMC */ + ipmi_bt_init(pnv->isa_bus, pnv->bmc, 10); + /* * OpenPOWER systems use a IPMI SEL Event message to notify the * host to powerdown diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c index aa5c89586c63..07fa1e1c7e45 100644 --- a/hw/ppc/pnv_bmc.c +++ b/hw/ppc/pnv_bmc.c @@ -17,6 +17,8 @@ */ =20 #include "qemu/osdep.h" +#include "qemu-common.h" +#include "qapi/error.h" #include "target/ppc/cpu.h" #include "qemu/log.h" #include "hw/ipmi/ipmi.h" @@ -211,8 +213,20 @@ static const IPMINetfn hiomap_netfn =3D { .cmd_handlers =3D hiomap_cmds }; =20 -int pnv_bmc_hiomap(IPMIBmc *bmc) +/* + * Instantiate the machine BMC. PowerNV uses the QEMU internal + * simulator but it could also be external. + */ +IPMIBmc *pnv_bmc_create(void) { - return ipmi_sim_register_netfn(IPMI_BMC_SIMULATOR(bmc), - IPMI_NETFN_OEM, &hiomap_netfn); + Object *obj; + + obj =3D object_new(TYPE_IPMI_BMC_SIMULATOR); + object_property_set_bool(obj, true, "realized", &error_fatal); + + /* Install the HIOMAP protocol handlers to access the PNOR */ + ipmi_sim_register_netfn(IPMI_BMC_SIMULATOR(obj), IPMI_NETFN_OEM, + &hiomap_netfn); + + return IPMI_BMC(obj); } --=20 2.21.0