From nobody Sun Apr 28 04:29:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 152974396973531.282850081660513; Sat, 23 Jun 2018 01:52:49 -0700 (PDT) Received: from localhost ([::1]:37609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWeHg-00089U-1E for importer@patchew.org; Sat, 23 Jun 2018 04:52:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWeFt-0007Ie-Rn for qemu-devel@nongnu.org; Sat, 23 Jun 2018 04:50:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWeFq-0001mV-RS for qemu-devel@nongnu.org; Sat, 23 Jun 2018 04:50:49 -0400 Received: from chuckie.co.uk ([82.165.15.123]:44525 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fWeFq-0001kj-Kz for qemu-devel@nongnu.org; Sat, 23 Jun 2018 04:50:46 -0400 Received: from host86-184-243-58.range86-184.btcentralplus.com ([86.184.243.58] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fWeFw-0001dA-G9; Sat, 23 Jun 2018 09:50:53 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, marcel@redhat.com, armbru@redhat.com, mst@redhat.com Date: Sat, 23 Jun 2018 09:50:27 +0100 Message-Id: <20180623085028.29553-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180623085028.29553-1-mark.cave-ayland@ilande.co.uk> References: <20180623085028.29553-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.184.243.58 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 1/2] sysbus: always allow explicit_ofw_unit_address() to override address generation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some SysBusDevices either use sysbus_init_mmio() without sysbus_mmio_map() = or the first MMIO memory region doesn't represent the bus address, causing an = invalid firmware device path to be generated. SysBusDeviceClass does provide a virtual explicit_ofw_unit_address() method= that can be used to override this process, but it is only considered as a fallba= ck option meaning that any existing MMIO memory regions still take priority wh= ilst determining the firmware device address. As any class defining explicit_ofw_unit_address() has explicitly requested a specialised behaviour then it should be used in preference to the default implementation rather than being used as a fallback. Signed-off-by: Mark Cave-Ayland --- hw/core/sysbus.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index ecfb0cfc0e..1ee0c162f4 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -293,16 +293,8 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev) { SysBusDevice *s =3D SYS_BUS_DEVICE(dev); SysBusDeviceClass *sbc =3D SYS_BUS_DEVICE_GET_CLASS(s); - /* for the explicit unit address fallback case: */ char *addr, *fw_dev_path; =20 - if (s->num_mmio) { - return g_strdup_printf("%s@" TARGET_FMT_plx, qdev_fw_name(dev), - s->mmio[0].addr); - } - if (s->num_pio) { - return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]); - } if (sbc->explicit_ofw_unit_address) { addr =3D sbc->explicit_ofw_unit_address(s); if (addr) { @@ -311,6 +303,13 @@ static char *sysbus_get_fw_dev_path(DeviceState *dev) return fw_dev_path; } } + if (s->num_mmio) { + return g_strdup_printf("%s@" TARGET_FMT_plx, qdev_fw_name(dev), + s->mmio[0].addr); + } + if (s->num_pio) { + return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]); + } return g_strdup(qdev_fw_name(dev)); } =20 --=20 2.11.0 From nobody Sun Apr 28 04:29:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529743968665910.7025659859951; Sat, 23 Jun 2018 01:52:48 -0700 (PDT) Received: from localhost ([::1]:37607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWeHf-000894-EW for importer@patchew.org; Sat, 23 Jun 2018 04:52:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWeFt-0007If-Rx for qemu-devel@nongnu.org; Sat, 23 Jun 2018 04:50:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWeFs-0001ml-4F for qemu-devel@nongnu.org; Sat, 23 Jun 2018 04:50:49 -0400 Received: from chuckie.co.uk ([82.165.15.123]:44528 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fWeFr-0001kl-UD for qemu-devel@nongnu.org; Sat, 23 Jun 2018 04:50:48 -0400 Received: from host86-184-243-58.range86-184.btcentralplus.com ([86.184.243.58] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fWeFx-0001dA-QB; Sat, 23 Jun 2018 09:50:54 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, lersek@redhat.com, marcel@redhat.com, armbru@redhat.com, mst@redhat.com Date: Sat, 23 Jun 2018 09:50:28 +0100 Message-Id: <20180623085028.29553-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180623085028.29553-1-mark.cave-ayland@ilande.co.uk> References: <20180623085028.29553-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.184.243.58 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 2/2] pci: allow DeviceClass fw_name to override pci_dev_fw_name() if set X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The current implementation of pci_dev_fw_name() scans through a fixed set of PCI class descriptions to determine the firmware device name but in some cases this isn't always appropriate, for example with the macio device which uses a class code of 0xff (unassigned). Rather than add a new entry for the macio device and risk a potential clash with another unassigned device later, add a check to pcibus_get_fw_dev_path() that will use DeviceClass fw_name if set in preference to pci_dev_fw_name(). This enables PCI devices such as macio to set dc->fw_name as required to match the name specified in the firmware. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/pci/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 80bc45930d..126dd683dc 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2411,12 +2411,14 @@ static char *pci_dev_fw_name(DeviceState *dev, char= *buf, int len) =20 static char *pcibus_get_fw_dev_path(DeviceState *dev) { + DeviceClass *dc =3D DEVICE_GET_CLASS(dev); PCIDevice *d =3D (PCIDevice *)dev; char path[50], name[33]; int off; =20 off =3D snprintf(path, sizeof(path), "%s@%x", - pci_dev_fw_name(dev, name, sizeof name), + dc->fw_name ? dc->fw_name : + pci_dev_fw_name(dev, name, sizeof name), PCI_SLOT(d->devfn)); if (PCI_FUNC(d->devfn)) snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn)= ); --=20 2.11.0