From patchwork Tue Dec 28 19:37:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700568 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A36C4C433EF for ; Tue, 28 Dec 2021 19:44:05 +0000 (UTC) Received: from localhost ([::1]:37682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IOC-0007GY-Jz for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:44:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IIf-0003ie-7f; Tue, 28 Dec 2021 14:38:21 -0500 Received: from [2607:f8b0:4864:20::82d] (port=33330 helo=mail-qt1-x82d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IId-00043q-IR; Tue, 28 Dec 2021 14:38:20 -0500 Received: by mail-qt1-x82d.google.com with SMTP id v4so14447659qtk.0; Tue, 28 Dec 2021 11:38:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eJ6+Ke1xC05ZgUOb+BKNnwR7Eg4U6KM0vXnMAljxOwI=; b=Wl2PKkHA7+6CR8ngCYI2Q7X92pnxesKw+lgQCG79Bvlc3phRGubx50c21bAgAyKXxE mdUGq305//tgKWoLmM71ESXG5ad1r1kX0+P8I7Rg/kqsmBjUtlWkcoyzrm3YB7n05/Tt YNosD2QKvkz6job+837G2Rsxh6EJvlbrWn0pNjFRPUooCA8bQmMq1A4TWLj4W2Dt17uI O/2U2y1U2SZ7Sf8g8vooY1F2NT8dGF6lVBcpKicYTDBufPVOfWTrIRt7YOAyBwbIT28b tAckKb0Fjy/8jMKtRV7/x7GxqDTEhPuPG3so7UNMYuoDoB0csUP83pJ66NGcqO820FsL SsNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eJ6+Ke1xC05ZgUOb+BKNnwR7Eg4U6KM0vXnMAljxOwI=; b=tArT+SEQToAMsJI4M/HG9RjAi2dyasD6QGo07fWhWz21BwZjn32mcif2u4JOH5//VJ pvkCtRanvDlFH6CquwPvVQDhwT1q6MZqcNYb/WY+Aq9LgFxN6qJjsDohl5Hd9SRKRP5Y ZpaWfb7XE9zbUQmOcq37ZbDfV//mOoSWi8GaWE+6MN6aSOn/bX68xiE1d6MqkWm/apjq jNKc794VoTgVbAKP6HYubpp7zfpvEGAqTHitHAVND87TEhcwrGOaNwd5rkP1CcgmD5/5 S0B9VkwK1+tpMeWaG2dRybd4QOqpplPfWgegVkiTClUNrlmY9NtdLPphoBumrlZLgc3+ ElZA== X-Gm-Message-State: AOAM532W0VH+mTwh3m9fP/Nq6lt7ZgU677fVwelALEtGUz3IIN1TMaYW WFlkZQ4ZThTOFi5zVEbHt1kil9EIvPk= X-Google-Smtp-Source: ABdhPJxEj0D1qSuV90fNQ+Xam1DKB/em3wP04aZT66P4OsuZ9buDfhbTLMl3fioFe0AXAU9UYI6dJQ== X-Received: by 2002:a05:622a:5:: with SMTP id x5mr19978778qtw.110.1640720298344; Tue, 28 Dec 2021 11:38:18 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:18 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 01/17] pnv_phb3.c: add unique chassis and slot for pnv_phb3_root_port Date: Tue, 28 Dec 2021 16:37:50 -0300 Message-Id: <20211228193806.1198496-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x82d.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" When creating a pnv_phb3_root_port using the command line, the first root port is created successfully, but the second fails with the following error: qemu-system-ppc64: -device pnv-phb3-root-port,bus=phb3-root.0,id=pcie.3: Can't add chassis slot, error -16 This error comes from the realize() function of its parent type, rp_realize() from TYPE_PCIE_ROOT_PORT. pcie_chassis_add_slot() fails with -EBUSY if there's an existing PCIESlot that has the same chassis/slot value, regardless of being in a different bus. One way to prevent this error is simply set chassis and slot values in the command line. However, since phb3 root buses only supports a single root port, we can just get an unique chassis/slot value by checking which root bus the pnv_phb3_root_port is going to be attached, get the equivalent phb3 device and use its chip-id and index values, which are guaranteed to be unique. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb3.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c index 4e2d680d44..130d392b3e 100644 --- a/hw/pci-host/pnv_phb3.c +++ b/hw/pci-host/pnv_phb3.c @@ -1156,8 +1156,24 @@ static const TypeInfo pnv_phb3_root_bus_info = { static void pnv_phb3_root_port_realize(DeviceState *dev, Error **errp) { PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(dev); + PCIDevice *pci = PCI_DEVICE(dev); + PCIBus *bus = pci_get_bus(pci); + PnvPHB3 *phb = NULL; Error *local_err = NULL; + phb = (PnvPHB3 *) object_dynamic_cast(OBJECT(bus->qbus.parent), + TYPE_PNV_PHB3); + + if (!phb) { + error_setg(errp, +"pnv_phb3_root_port devices must be connected to pnv-phb3 buses"); + return; + } + + /* Set unique chassis/slot values for the root port */ + qdev_prop_set_uint8(&pci->qdev, "chassis", phb->chip_id); + qdev_prop_set_uint16(&pci->qdev, "slot", phb->phb_id); + rpc->parent_realize(dev, &local_err); if (local_err) { error_propagate(errp, local_err); From patchwork Tue Dec 28 19:37:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AEF20C433F5 for ; Tue, 28 Dec 2021 19:43:56 +0000 (UTC) Received: from localhost ([::1]:37000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IO2-0006n9-CM for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:43:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IIh-0003k5-2R; Tue, 28 Dec 2021 14:38:23 -0500 Received: from [2607:f8b0:4864:20::833] (port=34698 helo=mail-qt1-x833.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIf-000445-GO; Tue, 28 Dec 2021 14:38:22 -0500 Received: by mail-qt1-x833.google.com with SMTP id o17so17087437qtk.1; Tue, 28 Dec 2021 11:38:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0gqiZsTwBeBRumWsH7uAf7GyzP7xKDYzPW4/g4mv+D0=; b=DzHGjM7CyLLXS+SwhvRj9Hw0KJJ6M1+8lFYJvz5V2i5SftEdwk6B8Q/qC216B3khTm 2yevhAOLG0J5mpCWbEPOyP39PEEdbrtlFoiaozG+NQGbhVqf6+CGN6CnrylTZH6CY935 7tKjgG1RS7fOCPFaUxsKXKP3KmI6/yrGDKxpL2Z1fIx9GHQF4eISI5UFeOVd4VMkXxvx ocZKwloeJS2Kvop7m6HMVvyF5WAlRUo6jf2PNQOpw89jnaQ+mv3EeI6VFCniHM86R6W/ zbfJVGKdF63r3GACmKDKJW5DUtmMkZ2kPz0sh/O5PRta84YUp7ymjtIMln9+DKEE3drH SEYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0gqiZsTwBeBRumWsH7uAf7GyzP7xKDYzPW4/g4mv+D0=; b=5rWsjs7elchB7daaUmTFioCeOYNrDByC68LvFbTHeHaRGg/czOkIKYuc8KUg2UQ2Ll W4d8NmfaGxUSB4ny6VQDQm0PyeAu4Cp8J6oHFDjv9UbNSALceGet99qQc/3FTRBEWjVy dkBOd9+OngaIb0QcM1dVSWrWtHUoWS8fT/C5XJqucPMuoa/Yx/MUnl/hNmjN5TARXOzq e4jMaEsRgNz/uNdhUx74YeY72k8wCAu6rSCYrRtOoObCn3NjOKtwuj7i+O8tUf39+Ivk m7I7aoQ0xe7mPDvApX5wyj0hKqd0qUZcm3gCL8CxiNQ3vfcw/YrkzXNr+pmYT3V9eZ8O Ljaw== X-Gm-Message-State: AOAM531UWEpYn8onMrlwu47MtIwhiBYaYegvJDnES2n6NcPLs7i1/Ibc Edh+6pMMIez+PxSix4aLk6WTPadUsiw= X-Google-Smtp-Source: ABdhPJzTRkKbncKoQKA4IOGPkLrWyYDT+Z7R3tJMTsLhjD7zZOosppymqTfjVpGbcW+p0vge7P6jxw== X-Received: by 2002:ac8:7e83:: with SMTP id w3mr20054975qtj.160.1640720300434; Tue, 28 Dec 2021 11:38:20 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:20 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 02/17] pnv_phb3.c: do not set 'root-bus' as bus name Date: Tue, 28 Dec 2021 16:37:51 -0300 Message-Id: <20211228193806.1198496-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::833 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x833.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" All pnv-phb3-root-bus buses are being created as 'root-bus'. This makes it impossible to, for example, add a pnv-phb3-root-port in a specific root bus, since they all have the same name. By default the device will be parented by the pnv-phb3 device that precedeced it in the QEMU command line. Moreover, this doesn't all for custom bus naming. Libvirt, for instance, likes to name these buses as 'pcie.N', where 'N' is the index value of the controller in the domain XML, by using the 'id' command line attribute. At this moment this is also being ignored - the created root bus will always be named 'root-bus'. This patch fixes both scenarios by removing the 'root-bus' name from the pci_register_root_bus() call. If an "id" is provided, use that. Otherwise use 'NULL' as bus name. The 'NULL' value will be handled in qbus_init_internal() and it will defaulted as lowercase bus type + the global bus_id value. After this path we can define the bus name by using the 'id' attribute: qemu-system-ppc64 -m 4G -machine powernv8,accel=tcg \ -device pnv-phb3,chip-id=0,index=1,id=pcie.0 dev: pnv-phb3, id "pcie.0" index = 1 (0x1) chip-id = 0 (0x0) x-config-reg-migration-enabled = true bypass-iommu = false bus: pcie.0 type pnv-phb3-root-bus And without an 'id' we will have the following default: qemu-system-ppc64 -m 4G -machine powernv8,accel=tcg \ -device pnv-phb3,chip-id=0,index=1 dev: pnv-phb3, id "" index = 1 (0x1) chip-id = 0 (0x0) x-config-reg-migration-enabled = true bypass-iommu = false bus: pnv-phb3-root-bus.0 type pnv-phb3-root-bus Signed-off-by: Daniel Henrique Barboza Reviewed-by: Cédric Le Goater --- hw/pci-host/pnv_phb3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c index 130d392b3e..f1b1f109a3 100644 --- a/hw/pci-host/pnv_phb3.c +++ b/hw/pci-host/pnv_phb3.c @@ -1064,7 +1064,8 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp) memory_region_init(&phb->pci_mmio, OBJECT(phb), "pci-mmio", PCI_MMIO_TOTAL_SIZE); - pci->bus = pci_register_root_bus(dev, "root-bus", + pci->bus = pci_register_root_bus(dev, + dev->id ? dev->id : NULL, pnv_phb3_set_irq, pnv_phb3_map_irq, phb, &phb->pci_mmio, &phb->pci_io, 0, 4, TYPE_PNV_PHB3_ROOT_BUS); From patchwork Tue Dec 28 19:37:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700570 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3150EC433F5 for ; Tue, 28 Dec 2021 19:48:24 +0000 (UTC) Received: from localhost ([::1]:45646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2ISN-0004H3-1M for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:48:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IIm-0003l1-JT; Tue, 28 Dec 2021 14:38:30 -0500 Received: from [2607:f8b0:4864:20::f2f] (port=42805 helo=mail-qv1-xf2f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIh-00044M-Ht; Tue, 28 Dec 2021 14:38:24 -0500 Received: by mail-qv1-xf2f.google.com with SMTP id q4so17256912qvh.9; Tue, 28 Dec 2021 11:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=piKMipm/jtlGzPVWLh3Y4aDoia+41Dlhy/W+XbF0Y6o=; b=mExBK0ImQrP8SuyC0JJRlaN2GlqLyMPHVY3dZdvtG/e01cili+1/vsHGWjYPSFgTYV as3n91SMpV8FaYgePI1qQbVqkaurixBx92aVNBvIy+mGUE52C+QzAr0nQaQeO7djcgqf 26OfU4Nzqg3dZXt4CcEoDmkEdp0pUUluKsC9L1Z2eKnmr3XrSOzKoLQ5ZEeeyXzMKYpk G7TolePgZnNBKkylC6QHSAAz63vj6YyzZK50Vi+ROdOye72eVmmuugzLIvdbeL7AH0ZV XActukzMsVnx6mBoFz+buMgOW4LsdQR5Hmrw64R+HsR6R7A/Ee5l9qT2LfugluDhQdLC YMgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=piKMipm/jtlGzPVWLh3Y4aDoia+41Dlhy/W+XbF0Y6o=; b=zir7hlTsupq3P36NM4JSwW2p5l/DeTCMgCDIhnbDzMEnkOsZsWxUIqVS1pLaumyo0V hxclbJ4iQWG5ysUgRGgLjfcRW1oabtdDZLSMwfxMEfsdGT7Ypj93UkGzq7L+ssZkpkya kjA977JXSKURrM0KbIBoGhnhJPvTdrrKB/zOZ1DSWdTzRPxropCFh/kzeP28LvMZblW0 OTgaHBr2d0sekMZtEmqbGBprbQRJDgxt+RXwuayw6NttIlsY+ClTG6iBLdewK6kZQOlN 3VxNNdTeB1aUyG9BZc6XKXjagd6vNYnoZUW68et3bPM9LpJq2B27ePJgIvWxpNWbv0SF wIXg== X-Gm-Message-State: AOAM533irum3R6A7Alb1Gof/M4FJG1SEC6URPWsQBqt4VU09ReALoCzz 11DsJGjc/yjk8NFB5qC3dLKfPgTYumk= X-Google-Smtp-Source: ABdhPJwhaldaChSHNrVbHrmZo1amNO2U1LrP+0M8wOQxegWg/ZvzIh5f3bwxpfTW8b492tyDTNj1/w== X-Received: by 2002:ad4:5be5:: with SMTP id k5mr20440485qvc.124.1640720302363; Tue, 28 Dec 2021 11:38:22 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:22 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 03/17] pnv_phb3.h: change TYPE_PNV_PHB3_ROOT_BUS name Date: Tue, 28 Dec 2021 16:37:52 -0300 Message-Id: <20211228193806.1198496-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2f (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2f; envelope-from=danielhb413@gmail.com; helo=mail-qv1-xf2f.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The TYPE_PNV_PHB3_ROOT_BUS name is used as the default bus name when the dev has no 'id'. However, pnv-phb3-root-bus is a bit too long to be used as a bus name. Most common QEMU buses and PCI controllers are named based on their bus type (e.g. pSeries spapr-pci-host-bridge is called 'pci'). The most common name for a PCIE bus controller in QEMU is 'pcie'. Naming it 'pcie' would break the documented use of the pnv-phb3 device, since 'pcie.0' would now refer to the root bus instead of the first root port. There's nothing particularly wrong with the 'root-bus' name used before, aside from the fact that 'root-bus' is being used for pnv-phb3 and pnv-phb4 created buses, which is not quite correct since these buses aren't implemented the same way in QEMU - you can't plug a pnv-phb4-root-port into a pnv-phb3 root bus, for example. This patch renames it as 'phb3-root', which is a compromise between the existing and the previously used name. Creating 3 phbs without ID will result in an "info qtree" output similar to this: bus: main-system-bus type System dev: pnv-phb3, id "" index = 2 (0x2) chip-id = 0 (0x0) x-config-reg-migration-enabled = true bypass-iommu = false bus: phb3-root.2 type phb3-root dev: pnv-phb3, id "" index = 1 (0x1) chip-id = 0 (0x0) x-config-reg-migration-enabled = true bypass-iommu = false bus: phb3-root.1 type phb3-root dev: pnv-phb3, id "" index = 0 (0x0) chip-id = 0 (0x0) x-config-reg-migration-enabled = true bypass-iommu = false bus: phb3-root.0 type phb3-root Signed-off-by: Daniel Henrique Barboza --- include/hw/pci-host/pnv_phb3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/pci-host/pnv_phb3.h b/include/hw/pci-host/pnv_phb3.h index 2e423c3890..658ee40e13 100644 --- a/include/hw/pci-host/pnv_phb3.h +++ b/include/hw/pci-host/pnv_phb3.h @@ -105,7 +105,7 @@ struct PnvPBCQState { /* * PHB3 PCIe Root port */ -#define TYPE_PNV_PHB3_ROOT_BUS "pnv-phb3-root-bus" +#define TYPE_PNV_PHB3_ROOT_BUS "phb3-root" #define TYPE_PNV_PHB3_ROOT_PORT "pnv-phb3-root-port" From patchwork Tue Dec 28 19:37:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63672C433F5 for ; Tue, 28 Dec 2021 19:44:33 +0000 (UTC) Received: from localhost ([::1]:38788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IOe-0007zo-5u for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:44:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IIp-0003le-1t; Tue, 28 Dec 2021 14:38:32 -0500 Received: from [2607:f8b0:4864:20::f2c] (port=41485 helo=mail-qv1-xf2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIn-00044Z-4Q; Tue, 28 Dec 2021 14:38:30 -0500 Received: by mail-qv1-xf2c.google.com with SMTP id h5so17250074qvh.8; Tue, 28 Dec 2021 11:38:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jnMv/5hIl0V178unfqwgd3QFIUiErNAVfl6i1TwmTC4=; b=SzxpmiAheiYxTHj/Mdzc75y+duNKhz50soFpVpeTU9lCbyuHhS9kekpu05BR0TaPmM PR+Bv7is893hCMOOU7+55dvEcl0Q8UVp8jHhG/G7hAECcdAlBfEHwXp4Mx34orJBsq6C mUrO3ypDCt9tQQl6rElC1WDIRBJXzFEW5RjZ02Gxr16U171aad9qMm5IF+tM5kfBwI5l ndae1kXsFZGLIhIu1Z30Lb4/p97u1TaPghgGZHeTfPepEtJNBQow6+e6Uw0kiFyI3EDL c2II84cZ0q6DNDvm/MSRvhir9f5WIUVJ+HY0POK1wxLX+OE7kdACbfU7PnLFiYSGsKtP fAug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jnMv/5hIl0V178unfqwgd3QFIUiErNAVfl6i1TwmTC4=; b=xjRgW8HFSzDMvSh4fDAEp8l2Jiuj8du/6z5us51mxmxLj/R5IFP/bsek2uyaEer8tL 0hrrJGVxA7/YBAR2EuYOpMxhXWwl0+WxQNmxoW7FOz3SclpfBNQFC1GFtUL2q/MlaGMi 5+XvwY/kfAyCYRkZmUEWUbsE6uJKDMMc6wuAY3Mpt66YOVsBjxhVcJ0lwGnyi+eGTToy 1UpyZQTU8OWvf+ZLrvRGEvHkc3Br03/wuFhLQGGOt9LIzr0qFDRl++SMXicJgFckIK9y Gkw1apdkZIPw0ihi0PvsjFvoYn4qwLVOOfSEbhYJy3iHzvnELhVXikNgholO6gnOVn/R /Yvg== X-Gm-Message-State: AOAM532Gms+pNVjFw8YlPZ7BXvoDVYOJ6xnRaiEStOScbyO7kA/Zl3hQ 0UJ/wSBOT40GMz6dB42HJR92t+7RC/Y= X-Google-Smtp-Source: ABdhPJzFO7qJICbURovH/hBsauDJGihO0WV7gO54nfwf1oQ0WTn9FhUr/Z6PQBZVPac9mFI59eYr2A== X-Received: by 2002:ad4:5cac:: with SMTP id q12mr20724568qvh.37.1640720304396; Tue, 28 Dec 2021 11:38:24 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:24 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 04/17] pnv_phb4.c: add unique chassis and slot for pnv_phb4_root_port Date: Tue, 28 Dec 2021 16:37:53 -0300 Message-Id: <20211228193806.1198496-5-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2c; envelope-from=danielhb413@gmail.com; helo=mail-qv1-xf2c.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" A similar situation as described previously with pnv_phb3_root_port devices also happens with pnv_phb4_root_ports. The solution is the same: assign an unique chassis/slot combo for them. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 23ab3ba594..4554490e51 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -1396,8 +1396,23 @@ static void pnv_phb4_root_port_reset(DeviceState *dev) static void pnv_phb4_root_port_realize(DeviceState *dev, Error **errp) { PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(dev); + PCIDevice *pci = PCI_DEVICE(dev); + PCIBus *bus = pci_get_bus(pci); + PnvPHB4 *phb = NULL; Error *local_err = NULL; + phb = (PnvPHB4 *) object_dynamic_cast(OBJECT(bus->qbus.parent), + TYPE_PNV_PHB4); + + if (!phb) { + error_setg(errp, "%s must be connected to pnv-phb4 buses", dev->id); + return; + } + + /* Set unique chassis/slot values for the root port */ + qdev_prop_set_uint8(&pci->qdev, "chassis", phb->chip_id); + qdev_prop_set_uint16(&pci->qdev, "slot", phb->phb_id); + rpc->parent_realize(dev, &local_err); if (local_err) { error_propagate(errp, local_err); From patchwork Tue Dec 28 19:37:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700573 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7AD43C433EF for ; Tue, 28 Dec 2021 19:48:48 +0000 (UTC) Received: from localhost ([::1]:47520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2ISl-0005Xh-HK for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:48:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IIp-0003ld-1t; Tue, 28 Dec 2021 14:38:32 -0500 Received: from [2607:f8b0:4864:20::82c] (port=34692 helo=mail-qt1-x82c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIn-00044e-3b; Tue, 28 Dec 2021 14:38:30 -0500 Received: by mail-qt1-x82c.google.com with SMTP id o17so17087660qtk.1; Tue, 28 Dec 2021 11:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vrkDjgKppKzQGTIo1wj0QuJKlu9Bp3LERFGDDCEreL0=; b=poR8A13lvSzVio4je5btxfZBwW10Ke1ZAYi/sEzVq+XXgcd7ZVtsCkCTxYHBs4Yx8n gH4/NXyl7OwimN1pCmwXZYYJHlOR+r0nDnSwWgTfeIsery6rPer9MDAjMHb3v34Ul26B yxSDX88rckuLiLy2pCFBi/pgNjfSqjaBs8Y/W+EyG5FQul8WiOgP6yYgeGlDHEFaNkD6 n5Fsi/Cal0i/rhdGkVJbSdOcLZFd71s6to9byymL7Gygcil/+FvKwBDGQxE071SWItyR 5kKH2R9yDYSrqb3MSvb0lED6A2Ike2bTjZwd36X3grt3GSVK5Uh/h6Dxka8MRm95c4oB r3aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vrkDjgKppKzQGTIo1wj0QuJKlu9Bp3LERFGDDCEreL0=; b=pb3nIwtCx1dpu6IW2dPyuNJkCvRZIoRLXpvYsQvhaJtu6XNlbNnwEvrMcfuKjSTZ+D aGhsq4GmkhNYxPXNYCrwArO60Fx9HtA504uyuarglkdjanrzKtokPLZFSSHNeEFTcGt5 KyywKhd/MHLIu7WG3cJunjlZ3Opg2BozBYiRBBnn+XT4fTS8zE8JFo2gfn1K5Wr5T0Ji aMGb9sz3RjWuG/zOjUC/WBVDosH8dabgD0/qgzfnHACFM7R1vRo2oOj2OUY9iiAsNNah 78A8jC+/su+lRobsCIQ0YuND9Fb+pY5gOwirm8OKnBhSeJIXV+lmBzxyBVKy83Z8JCcp TU7g== X-Gm-Message-State: AOAM5312/hr5VlvxPXWqXbTjShfkvsLPEsvGbeWCOgjUDOM2aA5xvdPh IhoAB7QS0bUagT53FhQyvwRFjhuvz78= X-Google-Smtp-Source: ABdhPJwYN/NuDbcBAln5MNF0PmdqoF/i3lzpSTdDIhs+C5LdUNj5CFdLCY4rPoXQEIzSCQK0yxzAdQ== X-Received: by 2002:ac8:5a42:: with SMTP id o2mr19665505qta.400.1640720306240; Tue, 28 Dec 2021 11:38:26 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:26 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 05/17] pnv.c: simplify pnv_phb_attach_root_port() Date: Tue, 28 Dec 2021 16:37:54 -0300 Message-Id: <20211228193806.1198496-6-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::82c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82c; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x82c.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The root port 'chassis' and 'slot' attributes are being set in the realize() callback of phb3_root_port and phb4_root_port. Remove the unneeded 'chassis' and 'slot' setting from pnv_phb_attach_root_port(). Signed-off-by: Daniel Henrique Barboza --- hw/ppc/pnv.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 1bd84d20c1..605296fab5 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1222,12 +1222,10 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp) } /* Attach a root port */ -static void pnv_phb_attach_root_port(PCIHostState *pci, int id, const char *name) +static void pnv_phb_attach_root_port(PCIHostState *pci, const char *name) { PCIDevice *root = pci_new(PCI_DEVFN(0, 0), name); - qdev_prop_set_uint8(&root->qdev, "chassis", id); - qdev_prop_set_uint16(&root->qdev, "slot", id); pci_realize_and_unref(root, pci->bus, &error_fatal); } @@ -1326,7 +1324,7 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) return; } - pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), phb->phb_id, + pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), TYPE_PNV_PHB3_ROOT_PORT); } } @@ -1506,7 +1504,7 @@ static void pnv_chip_power9_pec_realize(PnvChip *chip, Error **errp) for (j = 0; j < pec->num_stacks; j++) { PnvPHB4 *phb = &pec->stacks[j].phb; - pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), phb->phb_id, + pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), TYPE_PNV_PHB4_ROOT_PORT); } } @@ -1754,7 +1752,7 @@ static void pnv_chip_power10_phb_realize(PnvChip *chip, Error **errp) for (j = 0; j < pec->num_stacks; j++) { PnvPHB4 *phb = &pec->stacks[j].phb; - pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), phb->phb_id, + pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), TYPE_PNV_PHB5_ROOT_PORT); } } From patchwork Tue Dec 28 19:37:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6A6CEC433EF for ; Tue, 28 Dec 2021 19:48:37 +0000 (UTC) Received: from localhost ([::1]:46326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2ISa-0004l4-BD for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:48:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IIq-0003lx-9b; Tue, 28 Dec 2021 14:38:33 -0500 Received: from [2607:f8b0:4864:20::835] (port=43900 helo=mail-qt1-x835.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIo-00044m-6h; Tue, 28 Dec 2021 14:38:32 -0500 Received: by mail-qt1-x835.google.com with SMTP id q14so17033996qtx.10; Tue, 28 Dec 2021 11:38:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Nwy2ZGHqvc+k0rdub4aVFsOUVnUkdPKBQhOT8bnwF9o=; b=BRruy8DdRCdtUyzynSVkT7piWoZEUP1uZpxF8wYpyMyvdD5PxKnhqngyCFtpx+TTcY 4EJPJTMzR2Fee+gIIW3PSiC+q+4NTqLAZwxkaj9anFpPvV9OE6U6CR3o42m1gax2BKKD UL/7BQ+nPRZc1SGV5yiFiA55Wmdn55U7QOjdKyfP+qsGQJKDmCgUIuQNSKw7kliU2ITD Nz35lALVVgYDb7G42+wVaZuvL79Ga7hmBNghy3Y3rzFwTkMTwm8uLj7c6/fsJ3n9FVkp OIIBQLOZfFi0yheWfVbiMuAxrLAooz5KxHChgoKlp5L/3RKJk/y25Nt/bKrU7YzR0WNQ qRsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Nwy2ZGHqvc+k0rdub4aVFsOUVnUkdPKBQhOT8bnwF9o=; b=ljRvrcq77JM1rr1wdl8qXPE8nn9TFlxzF8fHMyw2M1tT/euHYrjbTHmg4BUSM+dqsQ f1+JXkmoFEeHoYh+ZvUDLFpIZXAj/vqCdS7or7lcU+4IfjQn3Ony3iC3uXIh4MaCDI/3 UIPNFU0enELJCggb/i18WLFZ0PPABZJ1i0d+hg6rgFFu+XzVetPuKOG6D2cb+NkVl1EW rdToFvBR+SKmPs1rjaJ+q8t2GSumsGuTD5exKmUV5iFzs/kDQZnxAQTfIxUXZZW7NY4k dkeVxlA/je9ErL5nTYxvwblbNXtOoGeEqzh89Zq+bR7V7RuQCxncS3WsnakPs9NmpwQD dw0Q== X-Gm-Message-State: AOAM531cnecmK4aFi1kK2iVBa8WHUWwEdhgGAvug/KxPkDBwS98hDEes 7IV65sDYwI5kedr/hwtVaeqRrthIkL8= X-Google-Smtp-Source: ABdhPJzzqlz9focIPKsJodzeDKnZehCQxgVdu3i60AKGLmjDFf8iSsAOd9cStwwxWfGxKsARuP3d+Q== X-Received: by 2002:ac8:7dcd:: with SMTP id c13mr19802345qte.133.1640720308422; Tue, 28 Dec 2021 11:38:28 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:28 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 06/17] pnv_phb4.c: attach default root port in phb4 realize() Date: Tue, 28 Dec 2021 16:37:55 -0300 Message-Id: <20211228193806.1198496-7-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::835 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x835.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We're adding the default pnv_phb4_root_port in pnv_chip_power9_pec_realize() by going into each stack, from eack pec, accessing the stack PHB and adding the port. This will be an annoyance when trying to implement user creatable PHB4 devices because, when that happens, stack->phb is not guaranteed to be valid at that time (we'll assign a PHB to its stack in phb4_realize(), after stk_realize()). Let's move the attachment of the default root port to pnv_phb4_realize() instead. This will create all the default root ports we already create today, and it'll be one less thing to worry about when implementing user creatable PHB4s. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4.c | 7 +++++++ hw/ppc/pnv.c | 20 +++----------------- include/hw/ppc/pnv.h | 1 + 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 4554490e51..daa468b812 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -22,6 +22,7 @@ #include "hw/irq.h" #include "hw/qdev-properties.h" #include "qom/object.h" +#include "sysemu/sysemu.h" #include "trace.h" #define phb_error(phb, fmt, ...) \ @@ -1224,6 +1225,12 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp) pnv_phb4_update_xsrc(phb); phb->qirqs = qemu_allocate_irqs(xive_source_set_irq, xsrc, xsrc->nr_irqs); + + /* Add the default pnv-phb4-root-port */ + if (defaults_enabled()) { + pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), + TYPE_PNV_PHB4_ROOT_PORT); + } } static const char *pnv_phb4_root_bus_path(PCIHostState *host_bridge, diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 605296fab5..c88fef26cf 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1222,7 +1222,7 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp) } /* Attach a root port */ -static void pnv_phb_attach_root_port(PCIHostState *pci, const char *name) +void pnv_phb_attach_root_port(PCIHostState *pci, const char *name) { PCIDevice *root = pci_new(PCI_DEVFN(0, 0), name); @@ -1478,7 +1478,7 @@ static void pnv_chip_quad_realize(Pnv9Chip *chip9, Error **errp) static void pnv_chip_power9_pec_realize(PnvChip *chip, Error **errp) { Pnv9Chip *chip9 = PNV9_CHIP(chip); - int i, j; + int i; for (i = 0; i < chip->num_pecs; i++) { PnvPhb4PecState *pec = &chip9->pecs[i]; @@ -1500,13 +1500,6 @@ static void pnv_chip_power9_pec_realize(PnvChip *chip, Error **errp) pnv_xscom_add_subregion(chip, pec_nest_base, &pec->nest_regs_mr); pnv_xscom_add_subregion(chip, pec_pci_base, &pec->pci_regs_mr); - - for (j = 0; j < pec->num_stacks; j++) { - PnvPHB4 *phb = &pec->stacks[j].phb; - - pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), - TYPE_PNV_PHB4_ROOT_PORT); - } } } @@ -1726,7 +1719,7 @@ static void pnv_chip_power10_quad_realize(Pnv10Chip *chip10, Error **errp) static void pnv_chip_power10_phb_realize(PnvChip *chip, Error **errp) { Pnv10Chip *chip10 = PNV10_CHIP(chip); - int i, j; + int i; for (i = 0; i < chip->num_pecs; i++) { PnvPhb4PecState *pec = &chip10->pecs[i]; @@ -1748,13 +1741,6 @@ static void pnv_chip_power10_phb_realize(PnvChip *chip, Error **errp) pnv_xscom_add_subregion(chip, pec_nest_base, &pec->nest_regs_mr); pnv_xscom_add_subregion(chip, pec_pci_base, &pec->pci_regs_mr); - - for (j = 0; j < pec->num_stacks; j++) { - PnvPHB4 *phb = &pec->stacks[j].phb; - - pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), - TYPE_PNV_PHB5_ROOT_PORT); - } } } diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 6c48fc62ff..7f2197dcc0 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -196,6 +196,7 @@ DECLARE_INSTANCE_CHECKER(PnvChip, PNV_CHIP_POWER10, PowerPCCPU *pnv_chip_find_cpu(PnvChip *chip, uint32_t pir); void pnv_chip_parent_fixup(PnvChip *chip, Object *obj, int index); +void pnv_phb_attach_root_port(PCIHostState *pci, const char *name); #define TYPE_PNV_MACHINE MACHINE_TYPE_NAME("powernv") typedef struct PnvMachineClass PnvMachineClass; From patchwork Tue Dec 28 19:37:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700572 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3C7EC433F5 for ; Tue, 28 Dec 2021 19:48:47 +0000 (UTC) Received: from localhost ([::1]:47344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2ISk-0005Ql-Mm for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:48:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IIr-0003m0-Ej; Tue, 28 Dec 2021 14:38:34 -0500 Received: from [2607:f8b0:4864:20::836] (port=36779 helo=mail-qt1-x836.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIq-000450-3L; Tue, 28 Dec 2021 14:38:33 -0500 Received: by mail-qt1-x836.google.com with SMTP id m18so16626467qtk.3; Tue, 28 Dec 2021 11:38:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WeRunpZECrRIjZXf1LpiTz+adBXtU5tmvX+ycePIviw=; b=D35PS8dtZnF93XS+CISZAPuRTAr6eZd38X/WfL6WmKXqgSdAYdcZRRNDdHpiGYfLnW fI8SddaA2J9J+GmLpogUloiJ0yzIdBMXzVSnA3c5S+B4aktBzrE1fCyM0bl/X8W4BXu6 SVaWOZEi8rmt0GUonEn6KsP8+qHCChDQpw6paUbNutHVvkRJdGWRZyqFR03JeHB5y4SX 3oRXHHXuL5b95bE0MB5hj8mnRoJZi8mHSdwsQirUSfynk4vCWC/h4OY65Alq/wnIQ9n2 wWAKJS4JRuIWzeLhFE4FjxFKXt4ac5BOYs07l591W6EH80YZES0l1x+QHJRPs031bI+q 2M/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WeRunpZECrRIjZXf1LpiTz+adBXtU5tmvX+ycePIviw=; b=ILycVozHpg2WJgO5+VvSpUPktC1l9CcqEWiPjJpYwxYhmIraQlviEf3PEuz4jRgLrK YpgmCVVqUTR+9gKbYE2Kebh3rdlf7910NTnf1//UrhSgrs7PCFvNLM1rdX75/XYfqOjS Daqek0+73VJEn9rJI+E5Hpjsm3Cyq0OIhnnIKtG9F9CbGIGnlIU85w6HUvr1VTMJlHa+ Im+wQg+3sd93V5DGiJEXng1WWDXwereY24aufhbcH/ntZwO57zwrk+8tiiGA4Jerj3bb 11gkMkTjn3kRsEOhuDR+yRXWEXw0DdmSppG1THhrG8v0FMJndq6o8W0geZmPwOc4e2dg FnGw== X-Gm-Message-State: AOAM531+niX1v5y1HN3WLoINRidD/AEPpryebQW7/ta5QfN5mCQ/bjq4 rfQV6KpmjasYy60GFsl8ajAWdntoaxE= X-Google-Smtp-Source: ABdhPJxI0JNp9heZN62T+w0lS5IO5EAk1hRT9n3Srkn4OGW4VbXapXzHA8fUvhJXorWxp9utj1/qMg== X-Received: by 2002:a05:622a:194:: with SMTP id s20mr20115993qtw.617.1640720310320; Tue, 28 Dec 2021 11:38:30 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:30 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 07/17] pnv_phb4.c: check if root port exists in rc_config functions Date: Tue, 28 Dec 2021 16:37:56 -0300 Message-Id: <20211228193806.1198496-8-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::836 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::836; envelope-from=danielhb413@gmail.com; helo=mail-qt1-x836.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" pnv_phb4_rc_config_read() and pnv_phb4_rc_config_write() are asserting the existence of the root port. The root port is now optional, and there will be cases where a pnv-phb4 device won't have a root port attached. Instead of asserting, check if the root port exists before read/writing into it. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index daa468b812..6bd907f91a 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -152,7 +152,9 @@ static void pnv_phb4_rc_config_write(PnvPHB4 *phb, unsigned off, } pdev = pci_find_device(pci->bus, 0, 0); - assert(pdev); + if (!pdev) { + return; + } pci_host_config_write_common(pdev, off, PHB_RC_CONFIG_SIZE, bswap32(val), 4); @@ -171,7 +173,9 @@ static uint64_t pnv_phb4_rc_config_read(PnvPHB4 *phb, unsigned off, } pdev = pci_find_device(pci->bus, 0, 0); - assert(pdev); + if (!pdev) { + return 0x0; + } val = pci_host_config_read_common(pdev, off, PHB_RC_CONFIG_SIZE, 4); return bswap32(val); From patchwork Tue Dec 28 19:37:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700574 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C90E5C433F5 for ; Tue, 28 Dec 2021 19:52:01 +0000 (UTC) Received: from localhost ([::1]:56022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IVs-0002pi-Rf for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:52:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IIu-0003nZ-H5; Tue, 28 Dec 2021 14:38:39 -0500 Received: from [2607:f8b0:4864:20::f2a] (port=33303 helo=mail-qv1-xf2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIs-00045L-7M; Tue, 28 Dec 2021 14:38:35 -0500 Received: by mail-qv1-xf2a.google.com with SMTP id kk22so17335211qvb.0; Tue, 28 Dec 2021 11:38:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HY2BEZ8i4szMfC53wb4G/PMw/ni+HX+v3ma0MbUIMOo=; b=ILmUGo0D9mbJD/EcoV0jZuuOwWQkq5KtvVqMJDlf5EDfqFg0DcFwGT0Jp7S0tRjJZQ qU3H3BHAdrzDt/wUWiWqCbxKJnS5zovm9Dcmgrxw5xY2IgHGCR6JigtcLUSHahddWYpw hs0T8EzNowCf5wsVLKKbLcokpYzrP/iiFGX8ey+s+gIehWwauGSKk3ZoVEz7BS/hvbz0 pk1fdDfwU/AmkgcFNXhTpZ2RLTVt5TqN8d8tZa5eJ+b2BV+EZXwGM/iQ3Ixtql6Gw6C2 Hm23Dn2C1osAB/2KOFvDEsXrVhrm6JgGEx7y1GRSJHr6fqLoJxCfpgAkBnEvaFAQjSrw 2rdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HY2BEZ8i4szMfC53wb4G/PMw/ni+HX+v3ma0MbUIMOo=; b=cz7XFNsKGZtHLu4nU2UexyTw+lQ0V+1zrR+p4u0wmm7KVj7E6DlK0YIKVCuZakTbPZ pTnqlb5Ps4v7Hf0ZRczobx7yrSBfdrcJP9J/lQ1ZjGm7equWUODs0cbmVJl4b9uPWr1n tvfSys2MXyvXXqbU116BC3DbOTDR1mZPCL06c6jOYbNe/twiaMIZB5FBLHkJRa5JENMB V6QB+/c+bpWDBXDOu8ZpWYI6rpewrmN3iXMBaJANBml3neldxa1KfBFH3zXxbqSeQMRf oI2J0T4oGal2yo7iCnzHS2b9LZJGJPgzd1fxZhPNhvgpInnVIfeoqOlkBPxCHAZZ9xn0 0CzQ== X-Gm-Message-State: AOAM533kBw3SvCf7VI+oAxsVNsebn3GeyUqsXGKs6qXLCSs4O6YteyUe ZH5TqQQjo8EybO8T3gCpAgJskQ3qtec= X-Google-Smtp-Source: ABdhPJxNmO935OY0vhH36/YAvSoQ5fs6Osd5EDVCKUba5hW1v92LL+xDn26YAGurvGynK59lxPjNzA== X-Received: by 2002:a05:6214:1c48:: with SMTP id if8mr20279459qvb.14.1640720312267; Tue, 28 Dec 2021 11:38:32 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:32 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 08/17] pnv_phb4.c: introduce pnv_phb4_set_stack_phb_props() Date: Tue, 28 Dec 2021 16:37:57 -0300 Message-Id: <20211228193806.1198496-9-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f2a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=danielhb413@gmail.com; helo=mail-qv1-xf2a.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We want to be able to support user creatable pnv-phb4 objects to allow users to instantiate a powernv9 machine similar to what it is done with powernv8. The main difference is that pnv-phb3 devs are attached directly to the system bus and can be created in the command line. PCI devices such as root-ports can be explictly connected to them. This allows users to create the phbs, assign a bus name if desired, then connect devices onto them. pnv-phb4 devices on the other hand are created by adding PCI Express Controllers (PEC) that will create a certain amount of pnv-phb4 buses depending on the PEC index used. Index 0 will create 1 phb, index 1 creates 2 phbs, index 2 creates 3 phbs. Creating all PECs from the same chip will create 6 PHBs. This doesn't users to rename the buses, like it is done with pnv-phb3, because there's no user control over how the pnv-phb4 are being created - aside from the amount of phbs and in which chips they'll reside. This implicit relationship between PEC devices and available buses can be tolerable for users that knows how the hardware works, but it's annoying for Libvirt to deal with. Since there's no explicit relationship, in the command line, between the created buses and the PCI devices that will connect to them, the domain XML needs to make a lot of extra assumptions regarding the relationship between regular PCI devices and the existing PECs. The first step to allow for user creatable pnv-phb4 devices is to decouple the pvn-phb logic from the pnv-phb4-pec code. This patch adds a helper called pnv_phb4_set_stack_phb_props() to remove the code from pnv_phb4_pec.c that initiates the object properties of pnv-phb4 devices. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4.c | 27 +++++++++++++++++++++++++++ hw/pci-host/pnv_phb4_pec.c | 14 +------------- include/hw/pci-host/pnv_phb4.h | 1 + 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 6bd907f91a..0ea505cc94 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -1164,6 +1164,33 @@ static AddressSpace *pnv_phb4_dma_iommu(PCIBus *bus, void *opaque, int devfn) return &ds->dma_as; } +/* + * Set the object properties of a phb in relation with its stack. + * + * Note: stack->pec must not be NULL. + */ +void pnv_phb4_set_stack_phb_props(PnvPhb4PecStack *stack, + PnvPHB4 *phb) +{ + PnvPhb4PecState *pec = stack->pec; + PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec); + char name[64]; + + snprintf(name, sizeof(name), "xscom-pec-%d.%d-pci-stack-%d-phb", + pec->chip_id, pec->index, stack->stack_no); + pnv_xscom_region_init(&stack->phb_regs_mr, OBJECT(phb), + &pnv_phb4_xscom_ops, phb, name, 0x40); + + object_property_set_int(OBJECT(phb), "chip-id", pec->chip_id, + &error_fatal); + object_property_set_int(OBJECT(phb), "version", pecc->version, + &error_fatal); + object_property_set_int(OBJECT(phb), "device-id", pecc->device_id, + &error_fatal); + object_property_set_link(OBJECT(phb), "stack", OBJECT(stack), + &error_abort); +} + static void pnv_phb4_instance_init(Object *obj) { PnvPHB4 *phb = PNV_PHB4(obj); diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 98e7ff78bd..700ee4b185 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -595,19 +595,7 @@ static void pnv_pec_stk_realize(DeviceState *dev, Error **errp) PHB4_PEC_PCI_STK_REGS_COUNT); /* PHB pass-through */ - snprintf(name, sizeof(name), "xscom-pec-%d.%d-pci-stack-%d-phb", - pec->chip_id, pec->index, stack->stack_no); - pnv_xscom_region_init(&stack->phb_regs_mr, OBJECT(&stack->phb), - &pnv_phb4_xscom_ops, &stack->phb, name, 0x40); - - object_property_set_int(OBJECT(&stack->phb), "chip-id", pec->chip_id, - &error_fatal); - object_property_set_int(OBJECT(&stack->phb), "version", pecc->version, - &error_fatal); - object_property_set_int(OBJECT(&stack->phb), "device-id", pecc->device_id, - &error_fatal); - object_property_set_link(OBJECT(&stack->phb), "stack", OBJECT(stack), - &error_abort); + pnv_phb4_set_stack_phb_props(stack, &stack->phb); if (!sysbus_realize(SYS_BUS_DEVICE(&stack->phb), errp)) { return; } diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 629db632d9..d7838513f1 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -133,6 +133,7 @@ struct PnvPHB4 { void pnv_phb4_pic_print_info(PnvPHB4 *phb, Monitor *mon); void pnv_phb4_update_regions(PnvPhb4PecStack *stack); +void pnv_phb4_set_stack_phb_props(PnvPhb4PecStack *stack, PnvPHB4 *phb); extern const MemoryRegionOps pnv_phb4_xscom_ops; /* From patchwork Tue Dec 28 19:37:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6DA9DC433F5 for ; Tue, 28 Dec 2021 19:54:26 +0000 (UTC) Received: from localhost ([::1]:36906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IYD-0000TI-DQ for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:54:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IIy-0003oK-3q; Tue, 28 Dec 2021 14:38:40 -0500 Received: from [2607:f8b0:4864:20::735] (port=41820 helo=mail-qk1-x735.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIu-00045c-Gu; Tue, 28 Dec 2021 14:38:37 -0500 Received: by mail-qk1-x735.google.com with SMTP id m2so16410609qkd.8; Tue, 28 Dec 2021 11:38:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zLe//ch48ZEy/Xo4bh9yQktCRczkd5ojG/PJyiMgfbk=; b=daqYKiZkSXbj6OAshbvmPQTeFsZ53MxPCmzIuW3ntXcOGByME7InCtsK+uts506s9L wP0mN+2VjZ8X+XUpM1n2ATnMvO4RVlRIEBUBCKkAdEnHKmyRb1kRpUsN8+tihV/r21Eu bEgpw5z7G26x1umhQiUrmeIoQbm4AlvlBgS2kX6hNJIoMlY0QqGrW5dmUbw+2I+TrK9C Ouo+xDD2jfwPaXa7CbS2Omf5njbDVT1cy0StKz9zg1pTjmrXqJyft5ctaEfzVbbe01O1 ehJV/EU1+jlebdJpv1Gpa7lmrkh589Gdjw3rypWtDNiVNssDIMe8seV6qVZYt55cJyDV MZqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zLe//ch48ZEy/Xo4bh9yQktCRczkd5ojG/PJyiMgfbk=; b=jUCTaLVsP024J6j47JPf1YvGf/egUhHZOzIir9+nay+vF4qsG7dMteZkIjBUovXfsO ujs8sV1tDGdCnwUhFivt7WCs0NPsG5d4D6NrDFMJJLzQ8vaIZeH2as4Ra1W5CV4V5DQI btZqr1WPzxMXPnqJ4UhoQ+NF00r0dxmOUS1uHL38A+JJFa9FeSRMMWKHpylraS6llPKK sCLK+j60gDEHLPzkGUxEkaFKP0cAmApqTqqP8xA+p2ALvUaqkoFUdwHC4Z7q24XWqVOT 5gMTBKktCsEsCiyNuO97/ZpHu/jGH+22MQdkIJGoffZoSv7uce01WviCludYiX2qo8xW yMIQ== X-Gm-Message-State: AOAM532GLVNABg0TQrJH8f92xqzV3T834wtf7c7lA4vQuYS6Eq5uC3iL M0nLQJze+u5IiGlyc2BAh1iwz2wZnK0= X-Google-Smtp-Source: ABdhPJxach8w4AoJgE99myOhcvdtLwPxISOEOJnMrwOXXfyMk+LPM92q7LClvv39WV0rxd2L1mzYYQ== X-Received: by 2002:a37:6706:: with SMTP id b6mr16236837qkc.16.1640720314379; Tue, 28 Dec 2021 11:38:34 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:34 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 09/17] pnv_phb4_pec.c: move pnv_pec_phb_offset() to pnv_phb4.c Date: Tue, 28 Dec 2021 16:37:58 -0300 Message-Id: <20211228193806.1198496-10-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::735 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x735.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The logic inside pnv_pec_phb_offset() wiil be useful in the next patch to determine the stack that should contain a PHB4 device. Move the function to pnv_phb4.c and make it public since there's no pnv_phb4_pec.h header. While we're at it, add 'stack_index' as a parameter and make the function return 'phb-id' directly. And rename it to pnv_pec_get_phb_id() to be even clearer about the function intent. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4.c | 17 +++++++++++++++++ hw/pci-host/pnv_phb4_pec.c | 15 +-------------- include/hw/pci-host/pnv_phb4.h | 2 ++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 0ea505cc94..36c56007ba 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -1164,6 +1164,23 @@ static AddressSpace *pnv_phb4_dma_iommu(PCIBus *bus, void *opaque, int devfn) return &ds->dma_as; } +/* + * Return the index/phb-id of a PHB4 that belongs to a + * pec->stacks[stack_index] stack. + */ +int pnv_pec_get_phb_id(PnvPhb4PecState *pec, int stack_index) +{ + PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec); + int index = pec->index; + int offset = 0; + + while (index--) { + offset += pecc->num_stacks[index]; + } + + return offset + stack_index; +} + /* * Set the object properties of a phb in relation with its stack. * diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 700ee4b185..bc2f8bb8b1 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -374,19 +374,6 @@ static void pnv_pec_instance_init(Object *obj) } } -static int pnv_pec_phb_offset(PnvPhb4PecState *pec) -{ - PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec); - int index = pec->index; - int offset = 0; - - while (index--) { - offset += pecc->num_stacks[index]; - } - - return offset; -} - static void pnv_pec_realize(DeviceState *dev, Error **errp) { PnvPhb4PecState *pec = PNV_PHB4_PEC(dev); @@ -422,7 +409,7 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp) for (i = 0; i < pec->num_stacks; i++) { PnvPhb4PecStack *stack = &pec->stacks[i]; Object *stk_obj = OBJECT(stack); - int phb_id = pnv_pec_phb_offset(pec) + i; + int phb_id = pnv_pec_get_phb_id(pec, i); object_property_set_int(stk_obj, "stack-no", i, &error_abort); object_property_set_int(stk_obj, "phb-id", phb_id, &error_abort); diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index d7838513f1..0fa88ca3fa 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -15,6 +15,7 @@ #include "hw/ppc/xive.h" #include "qom/object.h" +typedef struct PnvPhb4PecState PnvPhb4PecState; typedef struct PnvPhb4PecStack PnvPhb4PecStack; typedef struct PnvPHB4 PnvPHB4; typedef struct PnvChip PnvChip; @@ -134,6 +135,7 @@ struct PnvPHB4 { void pnv_phb4_pic_print_info(PnvPHB4 *phb, Monitor *mon); void pnv_phb4_update_regions(PnvPhb4PecStack *stack); void pnv_phb4_set_stack_phb_props(PnvPhb4PecStack *stack, PnvPHB4 *phb); +int pnv_pec_get_phb_id(PnvPhb4PecState *pec, int stack_index); extern const MemoryRegionOps pnv_phb4_xscom_ops; /* From patchwork Tue Dec 28 19:37:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700575 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EF6CC433EF for ; Tue, 28 Dec 2021 19:52:10 +0000 (UTC) Received: from localhost ([::1]:56822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IW1-0003O0-8w for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:52:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IJ1-0003p8-D6; Tue, 28 Dec 2021 14:38:44 -0500 Received: from [2607:f8b0:4864:20::730] (port=39563 helo=mail-qk1-x730.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIy-00045t-FX; Tue, 28 Dec 2021 14:38:41 -0500 Received: by mail-qk1-x730.google.com with SMTP id 69so18038975qkd.6; Tue, 28 Dec 2021 11:38:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lDufAFtHrqzL2AMvGvzbxBe50CphAPMCKn/qo2ry2KU=; b=fiPiIpH8ij/lpuJOj72AOa3BFFfnQZkpfAOq9Cq+1NLp6GYXrq4xMXJSKt7iiDUO0o YS851xHBNyDkNRGOvKuS513qfZ1yYHlroUgEDeLYeWwVHPsZ6iDeuw8wRs0EXOQmZnJX xh1HtR9sWQMlGD8DWTZchf62tw+09kPhdDReW3TU/b/3cxYaVdavf/BC4QOFijOgqjcB Lfubv8JRTP90YKItesO6KNwq2TK3MMC+ahrubF6oFCVmgsaPwkkUdhuwpljVTEEFj5VE y90Ch8Z2UJzXMRHdYKUNXrR+5SsOlx53YveuENuGNE+Z3v1dkqkIZm+k1enP4dSprXwU JCsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lDufAFtHrqzL2AMvGvzbxBe50CphAPMCKn/qo2ry2KU=; b=pk0xEwrmPUunJn+8e9UefvxfSQ6Qc7C5FGvL4njuaZRtvQ7pmrE2wPsuTxOgP/nnpq 2bTI+yn2t4XHI7pIuw3BMI4ayq6zQOKzXzuN9zvOsp5ZsbzJEFQZieWk6JPVlsAQSVhH XJrRh8kjnAMthscHHHiGTQ5WfpukhWca2Ah/IkwWo/lwkkx5ZKsy6aBpXXlspXkg0cUw BmXeh83B6GbDEV01Y2kavmVvili4Isg9WQTmQ9UPnv4p2+CgSI9Zgbl8rb/qYKVbRT04 v+cnXDRkgMPZ6QDhf6l4bzDItsv74wSAJKPOdPj9K6sw2jMof78d5bgiEl0xYg59yDrD 9pmw== X-Gm-Message-State: AOAM532X+jPnoHvDUAFSoxYOpKzwW4savdHmWQSj4lEFF6wxmW21kPK7 OIu+FVlv5264shQoB91S2c0czBKCJVk= X-Google-Smtp-Source: ABdhPJw4WT4nN1LUfNiNgndYby9T0oQj4KblUp3Bv2Uh7F66r6HotYPqdAQwJCcKdxp0xDA4mrOWAA== X-Received: by 2002:a05:620a:284d:: with SMTP id h13mr16312825qkp.612.1640720316397; Tue, 28 Dec 2021 11:38:36 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:36 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 10/17] pnv_phb4.c: introduce pnv_pec_init_stack_xscom() Date: Tue, 28 Dec 2021 16:37:59 -0300 Message-Id: <20211228193806.1198496-11-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::730 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x730.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The XSCOM address space of the stack must be populated after the initialization of its associated PHB4 is completed. At this moment this is always true because stk_realize() will always succeeds the realize of stack->phb, but that will not be the case with user creatable pnv-phb4 devices. Create a helper that can be used later on during pnv-phb4 realize() to initialize the xscom address space of its stack. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4.c | 26 ++++++++++++++++++++++++++ hw/pci-host/pnv_phb4_pec.c | 19 +------------------ include/hw/pci-host/pnv_phb4.h | 1 + 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 36c56007ba..31284e0460 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -1164,6 +1164,32 @@ static AddressSpace *pnv_phb4_dma_iommu(PCIBus *bus, void *opaque, int devfn) return &ds->dma_as; } +/* + * Init the xscom address space of the stack. This must be + * called after the associated stack->phb is defined. + */ +void pnv_pec_init_stack_xscom(PnvPhb4PecStack *stack) +{ + PnvPhb4PecState *pec = stack->pec; + PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec); + PnvChip *chip = pec->chip; + uint32_t pec_nest_base = pecc->xscom_nest_base(pec); + uint32_t pec_pci_base = pecc->xscom_pci_base(pec); + + + /* Populate the XSCOM address space. */ + pnv_xscom_add_subregion(chip, + pec_nest_base + 0x40 * (stack->stack_no + 1), + &stack->nest_regs_mr); + pnv_xscom_add_subregion(chip, + pec_pci_base + 0x40 * (stack->stack_no + 1), + &stack->pci_regs_mr); + pnv_xscom_add_subregion(chip, + pec_pci_base + PNV9_XSCOM_PEC_PCI_STK0 + + 0x40 * stack->stack_no, + &stack->phb_regs_mr); +} + /* * Return the index/phb-id of a PHB4 that belongs to a * pec->stacks[stack_index] stack. diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index bc2f8bb8b1..4f6db26633 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -560,10 +560,6 @@ static void pnv_pec_stk_realize(DeviceState *dev, Error **errp) { PnvPhb4PecStack *stack = PNV_PHB4_PEC_STACK(dev); PnvPhb4PecState *pec = stack->pec; - PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec); - PnvChip *chip = pec->chip; - uint32_t pec_nest_base; - uint32_t pec_pci_base; char name[64]; assert(pec); @@ -587,20 +583,7 @@ static void pnv_pec_stk_realize(DeviceState *dev, Error **errp) return; } - pec_nest_base = pecc->xscom_nest_base(pec); - pec_pci_base = pecc->xscom_pci_base(pec); - - /* Populate the XSCOM address space. */ - pnv_xscom_add_subregion(chip, - pec_nest_base + 0x40 * (stack->stack_no + 1), - &stack->nest_regs_mr); - pnv_xscom_add_subregion(chip, - pec_pci_base + 0x40 * (stack->stack_no + 1), - &stack->pci_regs_mr); - pnv_xscom_add_subregion(chip, - pec_pci_base + PNV9_XSCOM_PEC_PCI_STK0 + - 0x40 * stack->stack_no, - &stack->phb_regs_mr); + pnv_pec_init_stack_xscom(stack); } static Property pnv_pec_stk_properties[] = { diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 0fa88ca3fa..0f6c81c9cb 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -134,6 +134,7 @@ struct PnvPHB4 { void pnv_phb4_pic_print_info(PnvPHB4 *phb, Monitor *mon); void pnv_phb4_update_regions(PnvPhb4PecStack *stack); +void pnv_pec_init_stack_xscom(PnvPhb4PecStack *stack); void pnv_phb4_set_stack_phb_props(PnvPhb4PecStack *stack, PnvPHB4 *phb); int pnv_pec_get_phb_id(PnvPhb4PecState *pec, int stack_index); extern const MemoryRegionOps pnv_phb4_xscom_ops; From patchwork Tue Dec 28 19:38:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18908C433F5 for ; Tue, 28 Dec 2021 19:52:12 +0000 (UTC) Received: from localhost ([::1]:56958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IW3-0003TH-54 for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:52:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IJ1-0003p7-BR; Tue, 28 Dec 2021 14:38:44 -0500 Received: from [2607:f8b0:4864:20::f33] (port=41493 helo=mail-qv1-xf33.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIy-000463-FN; Tue, 28 Dec 2021 14:38:41 -0500 Received: by mail-qv1-xf33.google.com with SMTP id h5so17250475qvh.8; Tue, 28 Dec 2021 11:38:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4WZ6JNIq3xK0p0FOmEg7AUGxE7yaj6GV0bZDM+lh/uI=; b=lmfvFE4rZSNO6ueI3dDa5T/mVd+mLABJYVDmFZxZg8KT8dAaQDb46D7avRFAVTKTJ0 i/UqclDDxmCsmbS+mU2R98xnoQuO6QioJPrpjG8nu4ihoi5YkHUsGY6TAlL8U3Lh340Y 7V5q5tatoCykY/J1aW8w9Q/6xF3dlnCFRfIWD1Kr1hYVkBenGemYr3J2Cx6O3TvGs4G2 0phTfbe20vyPuc87X6W+ILZdJwJE51se+E6eSwDLSELVFNTemVucoCbpRSEhicyljxWV LwLfdmndkEQJ/SynW7e33g4BRwNtX0Ux7y3DuDNmhT4sXjixEjpFlsQ5y/HTxICOwV6X 1hiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4WZ6JNIq3xK0p0FOmEg7AUGxE7yaj6GV0bZDM+lh/uI=; b=b7SMQwTyz3OlaWuigTdUjHY8XLo4JW2OSUfy8HofJGwU3EevajFwg80uHbkfrmLK+U sfBtt4liZEXkitL0gnxzAHl7HNQmsvGWTWnWChw0VpffQ67fIQzZnB0qdtvXSyI1q+V1 AkdwKPbbuvgdEKJxVvnj5f6DMKBrJQUsOqGDMnL/i20bjwN1WWoMEXp5FYMDlbW+6W0/ vgsy+d5cnOcPZ6gwASeJTpmo8lrXoMakOSy0OzTAmjteb0mDNu84RjNLFS/Hx3Aj8lXQ jZGxTPJwHsdwjxbFR/y8UhnG1f67q9/a3Fqlg+Et3eezwhrYSmr8GLn/u2ruxLqJ69rX dWrA== X-Gm-Message-State: AOAM5330SIiKcf6hjb93xGFFh1L9Rh5LHicZXG3z/3/jTM+/eHMU32QC al8jyaCRqUatoyKbi0GyEVhaiY5lYWw= X-Google-Smtp-Source: ABdhPJzYNxo6w5gnD/IL0awVeSeTMzIfDZJkNn+wqJ0y/YJA6JRWUQlJGS8ETDGwlmdJ+xQEuqSgZQ== X-Received: by 2002:a05:6214:e83:: with SMTP id hf3mr20757988qvb.13.1640720318352; Tue, 28 Dec 2021 11:38:38 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:38 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 11/17] pnv_phb4_pec.c: use pnv_pec_get_phb_id() in pnv_pec_dt_xscom() Date: Tue, 28 Dec 2021 16:38:00 -0300 Message-Id: <20211228193806.1198496-12-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f33 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f33; envelope-from=danielhb413@gmail.com; helo=mail-qv1-xf33.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Relying on stack->phb to write the xscom DT of the PEC is something that we won't be able to do with user creatable pnv-phb4 devices. Hopefully, this can be done by using pnv_pec_get_phb_id(), which is already used by pnv_pec_realize() to set the phb-id of the stack. Use the same idea in pnv_pec_dt_xscom() to write ibm,phb-index without the need to accessing stack->phb, since stack->phb is not granted to be != NULL when user creatable phbs are introduced. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Cédric Le Goater --- hw/pci-host/pnv_phb4_pec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 4f6db26633..56ffd446ab 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -466,8 +466,7 @@ static int pnv_pec_dt_xscom(PnvXScomInterface *dev, void *fdt, pecc->compat_size))); for (i = 0; i < pec->num_stacks; i++) { - PnvPhb4PecStack *stack = &pec->stacks[i]; - PnvPHB4 *phb = &stack->phb; + int phb_id = pnv_pec_get_phb_id(pec, i); int stk_offset; name = g_strdup_printf("stack@%x", i); @@ -477,7 +476,7 @@ static int pnv_pec_dt_xscom(PnvXScomInterface *dev, void *fdt, _FDT((fdt_setprop(fdt, stk_offset, "compatible", pecc->stk_compat, pecc->stk_compat_size))); _FDT((fdt_setprop_cell(fdt, stk_offset, "reg", i))); - _FDT((fdt_setprop_cell(fdt, stk_offset, "ibm,phb-index", phb->phb_id))); + _FDT((fdt_setprop_cell(fdt, stk_offset, "ibm,phb-index", phb_id))); } return 0; From patchwork Tue Dec 28 19:38:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700580 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E654C433EF for ; Tue, 28 Dec 2021 19:56:01 +0000 (UTC) Received: from localhost ([::1]:41662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IZk-0003lD-Ct for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:56:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IJ3-0003pc-N5; Tue, 28 Dec 2021 14:38:51 -0500 Received: from [2607:f8b0:4864:20::731] (port=41817 helo=mail-qk1-x731.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IIz-00046I-VO; Tue, 28 Dec 2021 14:38:44 -0500 Received: by mail-qk1-x731.google.com with SMTP id m2so16410818qkd.8; Tue, 28 Dec 2021 11:38:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GjKRBmPEKhn1TcAQb/t7oYLA8tdf6AgYCnXFZrqJgiA=; b=cxSof2AnYWdtJDRrd4TqJuW0yb1/z01CBriABVJq/B/wIv01cA6be61YJTSd8DQJjb o/NFpdnew0sso38ZnegLKbhI1PrTe6SYfix50iN0sojAYzAVyaVG4N6hmkxQbYXIPrSo HA2K7kL8121CHLDZMkFVbwrtkt/yRjRxwdzB0l9cWg80vbz1AqwMK3aXFIv6abCOoQa+ TjMKGRdv9wag5TvA7tter+p9a47wajurmoVlTIBYlY4fBQYh4Jildfj/7Xp4ECI/enZw zHgnuq8nIpf5xKSk5riuh+ybYgU306Z5ur1xG7cfP3yUgZfZOdBw+++H4Rt/JB3r5/Hz SRmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GjKRBmPEKhn1TcAQb/t7oYLA8tdf6AgYCnXFZrqJgiA=; b=KwXPoNeK3yUY1EsUmNzmXWZwyO2oGgc/SahrMaAl2UtCyAHPBclZd0+wPASTvezabH oqbFLW/ArntGmk5jaTeyeuNJUtkEjQdpmElzf6RJvTujYB7F49D2JhNJ68Ja3uGUzTzw PP+2gOgPo4wmOgYmxGZCXj7EejBaC3eR/yO90vxiwqJqxqJilncwuGsTW3U7UyCrltyk vBCLcz+IyP2zSZNbZ9TBxXY7YxpgvC9AC4xyNLSsXY6kkDkqic5/w0rZaWDnwyV2ZD97 IO7lhvVAW9OV1teR9T5Iom8w/X28ngc5xT89X72JK+zHkPdsS4ngVd80GqqUZ4LPZgRA c9Pw== X-Gm-Message-State: AOAM533GXMo4z5V7IKDQPHjXQjZ5kCyXDpNix+ebI1TrLCpjNk8CVoJF K4CIP2+q10kDmN+DcsPtyfTk4WwdbmA= X-Google-Smtp-Source: ABdhPJwSeQbesm3BZQROdcIJnQGWAfxYvAy5BpEUG7uChj62/JGO5QnwrDKEEpeU7xedCqXW8905hA== X-Received: by 2002:a05:620a:2f9:: with SMTP id a25mr16496939qko.498.1640720320188; Tue, 28 Dec 2021 11:38:40 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:40 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 12/17] pnv_phb4_pec.c: use 'default_enabled()' to init stack->phb Date: Tue, 28 Dec 2021 16:38:01 -0300 Message-Id: <20211228193806.1198496-13-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::731 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::731; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x731.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The next step before enabling user creatable pnv-phb4 devices is to decople the init of the stack->phb object from pnv_pec_stk_instance_init(). First, use 'defaults_enabled()' inside pnv_pec_realize() to create the stack->phb object, while removing the equivalent object_initiate_child() call from stk_instance_init(). Create a new "phb" stack property link so we can assign stack->phb in an idiomatic manner. Then we need to handle stack->phb->index assignment. The value is retrieved with pnv_pec_get_phd_id() and, until this patch, this was being assigned to a 'phb-id' stack link to phb->index. It is simpler to assign this directly given that now we need to interact with the PnvPHB4 object directly to set its other attributes. Assign phb->index directly with the value of pnv_pec_get_phb_id(), and remove the now unused link. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4_pec.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 56ffd446ab..031e98f1f4 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -19,6 +19,7 @@ #include "hw/pci/pci_bus.h" #include "hw/ppc/pnv.h" #include "hw/qdev-properties.h" +#include "sysemu/sysemu.h" #include @@ -409,11 +410,29 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp) for (i = 0; i < pec->num_stacks; i++) { PnvPhb4PecStack *stack = &pec->stacks[i]; Object *stk_obj = OBJECT(stack); - int phb_id = pnv_pec_get_phb_id(pec, i); object_property_set_int(stk_obj, "stack-no", i, &error_abort); - object_property_set_int(stk_obj, "phb-id", phb_id, &error_abort); object_property_set_link(stk_obj, "pec", OBJECT(pec), &error_abort); + + /* Create and realize the default stack->phb */ + if (defaults_enabled()) { + PnvPHB4 *phb = PNV_PHB4(qdev_new(TYPE_PNV_PHB4)); + int phb_id = pnv_pec_get_phb_id(pec, i); + + object_property_set_int(OBJECT(phb), "index", + phb_id, &error_abort); + object_property_set_link(OBJECT(phb), "stack", + stk_obj, &error_abort); + + pnv_phb4_set_stack_phb_props(stack, phb); + if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), errp)) { + return; + } + + object_property_set_link(stk_obj, "phb", OBJECT(phb), + &error_abort); + } + if (!qdev_realize(DEVICE(stk_obj), NULL, errp)) { return; } @@ -549,10 +568,6 @@ static const TypeInfo pnv_pec_type_info = { static void pnv_pec_stk_instance_init(Object *obj) { - PnvPhb4PecStack *stack = PNV_PHB4_PEC_STACK(obj); - - object_initialize_child(obj, "phb", &stack->phb, TYPE_PNV_PHB4); - object_property_add_alias(obj, "phb-id", OBJECT(&stack->phb), "index"); } static void pnv_pec_stk_realize(DeviceState *dev, Error **errp) @@ -589,6 +604,8 @@ static Property pnv_pec_stk_properties[] = { DEFINE_PROP_UINT32("stack-no", PnvPhb4PecStack, stack_no, 0), DEFINE_PROP_LINK("pec", PnvPhb4PecStack, pec, TYPE_PNV_PHB4_PEC, PnvPhb4PecState *), + DEFINE_PROP_LINK("phb", PnvPhb4PecStack, phb, TYPE_PNV_PHB4, + PnvPHB4 *), DEFINE_PROP_END_OF_LIST(), }; From patchwork Tue Dec 28 19:38:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 029A3C433F5 for ; Tue, 28 Dec 2021 19:54:32 +0000 (UTC) Received: from localhost ([::1]:37452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IYJ-0000sW-51 for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:54:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IJ5-0003pp-Aw; Tue, 28 Dec 2021 14:38:51 -0500 Received: from [2607:f8b0:4864:20::f31] (port=46018 helo=mail-qv1-xf31.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IJ3-00046U-Es; Tue, 28 Dec 2021 14:38:46 -0500 Received: by mail-qv1-xf31.google.com with SMTP id a9so17271494qvd.12; Tue, 28 Dec 2021 11:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BwiPurepIdu2ui5Uj2Sm66gn0qyrXmboe6qAgQoXMj8=; b=h3oixMnsKdB33OXF4OvHTHkWwZY+E0F3xbi0B4weX5mjExC+DwFLXzkPe8kiMk+o+Z N68wssGrjUnQ+EB2huWzlaK1I+iTk1EPw1Tbzu1LlHd4i7j3o74LITJb+6sHL8LU118V zobFvNf0blO+mO3BuwWLMGm4gj17zW+Vcj1cn6DqEYBJt/E3IwicTKJr7Mb1CM8x3DBg GMjU6z/WT2UewdR82SGIwNlzfkHwmTvI5KZmpe3MaLWMQrCV9ZLji3F+ilk6A9ilBEP6 dQQ3mOyFcW9//RWryaXeFClSwgDRx2ubDQmkE5BqgJoBWCoWOnv1AS3XOdRNf13jNIYq 3LkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BwiPurepIdu2ui5Uj2Sm66gn0qyrXmboe6qAgQoXMj8=; b=5RdVxfPYsv+g0/6FGRTTnThKGloac6R5egyo4O7zOMLDcPNrW//JpcTpd/SkFKeOSN gxwV+6felUsZ3sYLW4iXFJj5/IWFom/wfLja4Hvz/SXt/pwGFgUANxa6s2ycYJ4drRMm sDJScdLrTbXP8NBRtR8v3MJcmqWKX+NvkB+HDGUKa/jZbKQBSYceaoGOUpniuzR/pi6U qYKgMFM047S8gZdZyE6aGsmoz+eQOTT9Y5D2ovxONE6rs8n93L0J+rDdUC+DZlfOXE3b Y5h/+E7yDYupgwWyFdbaA9cDKsqrpKCgGGia+wMtroNx1q/6IBVN7x4okbZNySc3ZJKC QE4A== X-Gm-Message-State: AOAM53036z+z5jI6g1Onts8S2WEqNUQvnSQhVSEN2LdBgmJ3ap4mnDiV p+QAv+EiEDZtgll9nNviQfU8UDFN6kI= X-Google-Smtp-Source: ABdhPJzsjtRbPlK546gQM7jo+pEVhGKmu4qx/fUa4rHp9A2RGO36dOSPhbZhAo9M8SKecmONDvXD1g== X-Received: by 2002:a05:6214:f23:: with SMTP id iw3mr7319611qvb.83.1640720322326; Tue, 28 Dec 2021 11:38:42 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:42 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 13/17] pnv_phb4.h: turn phb into a pointer in struct PnvPhb4PecStack Date: Tue, 28 Dec 2021 16:38:02 -0300 Message-Id: <20211228193806.1198496-14-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::f31 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::f31; envelope-from=danielhb413@gmail.com; helo=mail-qv1-xf31.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" At this moment, stack->phb is the plain PnvPHB4 device itself instead of a pointer to the device. This will present a problem when adding user creatable devices because we can't deal with this struct and the realize() callback from the user creatable device. We can't get rid of this attribute, similar to what we did when enabling pnv-phb3 user creatable devices, because pnv_phb4_update_regions() needs to access stack->phb to do its job. This function is called twice in pnv_pec_stk_update_map(), which is one of the nested xscom write callbacks (via pnv_pec_stk_nest_xscom_write()). In fact, pnv_pec_stk_update_map() code comment is explicit about how the order of the unmap/map operations relates with the PHB subregions. All of this indicates that this code is tied together in a way that we either go on a crusade, featuring lots of refactories and redesign and considerable pain, to decouple stack and phb mapping, or we allow stack update_map operations to access the associated PHB as it is today even after introducing pnv-phb4 user devices. This patch chooses the latter. Instead of getting rid of stack->phb, turn it into a PHB pointer. This will allow us to assign an user created PHB to an existing stack later. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4.c | 2 +- hw/pci-host/pnv_phb4_pec.c | 2 +- include/hw/pci-host/pnv_phb4.h | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 31284e0460..5b2f644662 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -1564,7 +1564,7 @@ type_init(pnv_phb4_register_types); void pnv_phb4_update_regions(PnvPhb4PecStack *stack) { - PnvPHB4 *phb = &stack->phb; + PnvPHB4 *phb = stack->phb; /* Unmap first always */ if (memory_region_is_mapped(&phb->mr_regs)) { diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 031e98f1f4..3797696e8f 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -592,7 +592,7 @@ static void pnv_pec_stk_realize(DeviceState *dev, Error **errp) PHB4_PEC_PCI_STK_REGS_COUNT); /* PHB pass-through */ - pnv_phb4_set_stack_phb_props(stack, &stack->phb); + pnv_phb4_set_stack_phb_props(stack, stack->phb); if (!sysbus_realize(SYS_BUS_DEVICE(&stack->phb), errp)) { return; } diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 0f6c81c9cb..d67e33924b 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -181,8 +181,11 @@ struct PnvPhb4PecStack { /* The owner PEC */ PnvPhb4PecState *pec; - /* The actual PHB */ - PnvPHB4 phb; + /* + * PHB4 pointer. pnv_phb4_update_regions() needs to access + * the PHB4 via a PnvPhb4PecStack pointer. + */ + PnvPHB4 *phb; }; struct PnvPhb4PecState { From patchwork Tue Dec 28 19:38:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64E33C433F5 for ; Tue, 28 Dec 2021 19:57:52 +0000 (UTC) Received: from localhost ([::1]:46496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IbX-0006z6-Fr for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:57:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IJS-0003tm-Jf; Tue, 28 Dec 2021 14:39:12 -0500 Received: from [2607:f8b0:4864:20::734] (port=43695 helo=mail-qk1-x734.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IJ4-000473-Un; Tue, 28 Dec 2021 14:39:05 -0500 Received: by mail-qk1-x734.google.com with SMTP id f138so18017216qke.10; Tue, 28 Dec 2021 11:38:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/1oOrn19Qq5V7IB3zLGoiPnWM8P3PNbcnKYmFkDvzEs=; b=WqImzzBW1ZB7tzjrHHskpS0sbkjWn3XnALYFQFfrCJQ4DvJSjMA7/ZpqW/So5guaP3 eC6gW5AprY80l1LjnfQFEmnj6lBXDKaEOIQHSsR4yN24Io/MxcbqABozdsR6vcFCR8hK /HnslhySnlSNQqaxtBSadQVNOJAkXO8Uj1XU+R9PjIJpKxXl7rt2hWrQaI5yRrRMSHui dbJzrZah87DoY66v2D6k5AlxiC9z3fVeZtNen218q49Gbs9UNtzJy4TFGuaCRBe9MTZA 4tnggNVaHJIUJiuc7yJgcPWmO2E10cpUkWGy2+6Di/rYZDP7zz6bQHYz/cfsWE4mHpmf TAfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/1oOrn19Qq5V7IB3zLGoiPnWM8P3PNbcnKYmFkDvzEs=; b=3DC2ZOQjfuf8mKSjzY42ybky75MtY3uUR/fvjuUjDeNt6+ePgZtS8oIubsCAAtC1x2 /ERrcL94jZSw/i8tfCSt1txe0slMg7ThWxC+wAv8/O5s75LIh8L3lwaliMqVbmPiwUtD 6KwcLWj7ZC7obwLKBIwx7Gp4LxqwTUuBp189h0JdzNUeLb/XADyOeFSi+gZJb+tVZwwg ASPAT5DulWy0oKynH0QLlG1F2vfLJitO9oZnPBcENtoREeCy6f3ld4biz2LZMZxEsB02 4QM3bl1cmgef4jn5iDg3XFm4IX3h++2cws0nkeCP5SzHwEdnJ8uSnxeTVCF/jShjSuHv 2Tlg== X-Gm-Message-State: AOAM533GbdsYHr20pjbmi6Kf9ZG7AXQSj9ghp6FLW/+sJa5MOAuPkV8S 4MKhx2W5MCx3kpm99ni0ySvZQAJRIjM= X-Google-Smtp-Source: ABdhPJxz/hQ+sWKudY5oMdf1Xg2XnXcA9ofemfYUEh0KfCwNIMQsn6WGOpaBsHUcQM2zSoA5sVl51g== X-Received: by 2002:a05:620a:3195:: with SMTP id bi21mr16108241qkb.547.1640720324601; Tue, 28 Dec 2021 11:38:44 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:44 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 14/17] Revert "ppc/pnv: Introduce support for user created PHB4 devices" Date: Tue, 28 Dec 2021 16:38:03 -0300 Message-Id: <20211228193806.1198496-15-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::734 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x734.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The upcoming code that allows for user creatable pnv-phb4 devices relies on finding the correct pnv-phb4-pec controller to associate with. At this moment the code that added support for user creatable pnv-phb4-pec devices does not update chip9->pecs[] and pec->chip->num_pecs after pnv_pec_realize(). This is not trivial to do because chip9-pecs[] is an array of PEC devices, not an array of pointers to PEC devices. All of this wasn't a problem back when this commit was introduced because the pnv-phb4 devices of each pnv-phb4-pec were being created automatically. We had a change of heart since then, realizing that dealing with pnv-phb4-pec is too complicated from the user standpoint. In theory we could work the code to change chip9->pecs[] to be an array of pointers and go from there, but in reality this will be a wasted effort since we're going to backtrack on the user-creatable pnv-phb4-pec. All PCI Express controllers of all chips will be created by default. When running with default settings all pnv-phb4 PHBs will be created, as usual. When running with '-nodefaults' the PECs will be created without the PHBs, and then the user will be responsible for adding them by hand in the command line. Instead of fixing this situation with chip9->pecs[] not being up to date with each user created pnv-phb4-pec, then work on user creatable pnv-phb4 support, then removing the support for user pnv-phb4-pec, let's remove user-creatable pnv-phb4-pec right now and spare the extra code. This reverts commit 7a221a8f6eb04d3e03081b06a89896803554e37d. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4_pec.c | 19 +------------------ hw/ppc/pnv.c | 5 ++--- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 3797696e8f..aa93ad3f10 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -382,17 +382,6 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp) char name[64]; int i; - /* User created devices */ - if (!pec->chip) { - PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine()); - - pec->chip = pnv_get_chip(pnv, pec->chip_id); - if (!pec->chip) { - error_setg(errp, "invalid chip id: %d", pec->chip_id); - return; - } - } - if (pec->index >= PNV_CHIP_GET_CLASS(pec->chip)->num_pecs) { error_setg(errp, "invalid PEC index: %d", pec->index); return; @@ -400,12 +389,6 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp) pec->num_stacks = pecc->num_stacks[pec->index]; - /* - * Reparent user created devices to the chip to build correctly - * the device tree. - */ - pnv_chip_parent_fixup(pec->chip, OBJECT(pec), pec->index); - /* Create stacks */ for (i = 0; i < pec->num_stacks; i++) { PnvPhb4PecStack *stack = &pec->stacks[i]; @@ -538,7 +521,7 @@ static void pnv_pec_class_init(ObjectClass *klass, void *data) dc->realize = pnv_pec_realize; device_class_set_props(dc, pnv_pec_properties); - dc->user_creatable = true; + dc->user_creatable = false; pecc->xscom_nest_base = pnv_pec_xscom_nest_base; pecc->xscom_pci_base = pnv_pec_xscom_pci_base; diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index c88fef26cf..bf2607446a 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1426,9 +1426,8 @@ static void pnv_chip_power9_instance_init(Object *obj) object_initialize_child(obj, "homer", &chip9->homer, TYPE_PNV9_HOMER); - if (defaults_enabled()) { - chip->num_pecs = pcc->num_pecs; - } + /* Number of PECs is the chip default */ + chip->num_pecs = pcc->num_pecs; for (i = 0; i < chip->num_pecs; i++) { object_initialize_child(obj, "pec[*]", &chip9->pecs[i], From patchwork Tue Dec 28 19:38:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81894C433F5 for ; Tue, 28 Dec 2021 20:00:28 +0000 (UTC) Received: from localhost ([::1]:50714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2Ie3-0001R9-Df for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 15:00:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IJk-0003yX-Cc; Tue, 28 Dec 2021 14:39:28 -0500 Received: from [2607:f8b0:4864:20::72a] (port=38737 helo=mail-qk1-x72a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IJI-00047H-7s; Tue, 28 Dec 2021 14:39:12 -0500 Received: by mail-qk1-x72a.google.com with SMTP id i187so15919071qkf.5; Tue, 28 Dec 2021 11:38:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ohoSIe9dPQzV0x/ZlZpIkKXNEFON8gaCRXDiudVk8ZA=; b=WnWKekmSDbhk+zq2LaKXG6U0yxZw4RXH3IMyVN5RBHFUVQrjpkLiz07effNMzuXymZ i02CpXK3EwklutZ7/Bh57DBHqz6XnIYcQGFFwhUxZ1KB6kWairtHXn2ddQ/ylfcVXX46 YMgt2Ol/SW+NC4KYgbh7g2h2sweJVIDmlmzNsSh5+gb8200rAbYbyiEa397DRew9wom7 YfM9RiC52dN9WI/HsXVsHJd64pNT/R3wFIiapU8ZkaA+Uws69GX8D662VHeluDpSEppg AWlKW0GQk2n7gRyKQ9lKT7TI+1ug6Psm9fp7ZyMdP4zSposbl4A7A5hDKTSqL2OrUspJ 64LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ohoSIe9dPQzV0x/ZlZpIkKXNEFON8gaCRXDiudVk8ZA=; b=pZ+3m4OrtCJTOGtl/mUXJ76gra0OJV32jTYanis1GYgNyHlvcZTyP1z2GIQC/JCcwH WZ7FkrzqTqAAVPe39MKLINb6gCyYUksmcPL+dULl233luUqEB63FZHSbkG6gbAFSDs0U Oh0V24sDq5V9ekZMB28tpn5+Wmuwi529+dqC4Y3k64I5j6QDfaaN9BaUj0Q2yT5SfjyH HzCvv2Z8hbIC0jfSzzZEIp/Ou/1XUvTywJr1navgzCzwuGRe+CsH5NTgqolfLSha4qT0 IXN2KJdQsBFIXg3HWB9XQQMTSsmDVovBA26tHdeaKokkYKW7W+byfiPoFN3pNjELNIrl QzNQ== X-Gm-Message-State: AOAM530mdTkv8ojQtPoI1dTdTex/2JHOD4yx6T+y28X56pN8JlwpT195 xmXRfcUlcEo0ML9nr5tYPMjS3upfBE4= X-Google-Smtp-Source: ABdhPJyab3HBsTCyHMtrYlttL/e8HeOoNLeBx57tMVQqlHf+ZGR4KW39rkj3UkP3+bzfj3mNsMHtSg== X-Received: by 2002:a05:620a:4e8:: with SMTP id b8mr16491211qkh.366.1640720326654; Tue, 28 Dec 2021 11:38:46 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:46 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 15/17] ppc/pnv: Introduce user creatable pnv-phb4 devices Date: Tue, 28 Dec 2021 16:38:04 -0300 Message-Id: <20211228193806.1198496-16-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::72a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x72a.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch introduces pnv-phb4 user creatable devices that are created in a similar manner as pnv-phb3 devices, allowing the user to interact with the PHBs directly instead of creating PCI Express Controllers that will create a certain amount of PHBs per controller index. First thing we need is to discover which stack will host the created PHB, which is done by the new pnv_phb4_get_stack() function. During pnv_phb4_realize() we'll inspect phb->stack to see if we're dealing with an user creatable device or not. When using default settings, the automatically created PHB4 devices will be realized with phb->stack already assigned beforehand during PEC realize. In case we're dealing with an user device, find its stack, set the PHB attributes based on the stack it belongs and assign the PHB to the stack. The xscom stack initialization takes place in pnv_pec_stk_realize() when using default settings, but at that point we aren't aware of any user PHB4 devices that will belong to the stack. In that case we'll postpone xscom stack init until the the end of pnv_phb4_realize(), after all the memory mappings of the PHB are done. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4.c | 84 +++++++++++++++++++++++++++++++++++++- hw/pci-host/pnv_phb4_pec.c | 12 +++--- hw/ppc/pnv.c | 2 + 3 files changed, 90 insertions(+), 8 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 5b2f644662..7b53c12b7c 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -1244,6 +1244,41 @@ static void pnv_phb4_instance_init(Object *obj) object_initialize_child(obj, "source", &phb->xsrc, TYPE_XIVE_SOURCE); } +static PnvPhb4PecStack *pnv_phb4_get_stack(PnvChip *chip, PnvPHB4 *phb, + Error **errp) +{ + Pnv9Chip *chip9 = NULL; + int chip_id = phb->chip_id; + int index = phb->phb_id; + int i, j; + + if (chip->num_pecs == 0) { + /* Something weird happened. Bail out */ + error_setg(errp, "chip id %d has no PCIE controllers", chip_id); + return NULL; + } + + chip9 = PNV9_CHIP(chip); + + for (i = 0; i < chip->num_pecs; i++) { + /* + * For each PEC, check the amount of stacks it supports + * and see if the given phb4 index matches a stack. + */ + PnvPhb4PecState *pec = &chip9->pecs[i]; + + for (j = 0; j < pec->num_stacks; j++) { + if (index == pnv_pec_get_phb_id(pec, j)) { + return &pec->stacks[j]; + } + } + } + + error_setg(errp, "pnv-phb4 index %d didn't match any existing PEC", + chip_id); + return NULL; +} + static void pnv_phb4_realize(DeviceState *dev, Error **errp) { PnvPHB4 *phb = PNV_PHB4(dev); @@ -1251,8 +1286,49 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp) XiveSource *xsrc = &phb->xsrc; int nr_irqs; char name[32]; + PnvPhb4PecStack *stack = NULL; + bool stack_init_xscom = false; + Error *local_err = NULL; - assert(phb->stack); + /* User created PHB */ + if (!phb->stack) { + PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine()); + PnvChip *chip = pnv_get_chip(pnv, phb->chip_id); + BusState *s; + + if (!chip) { + error_setg(errp, "invalid chip id: %d", phb->chip_id); + return; + } + + stack = pnv_phb4_get_stack(chip, phb, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + object_property_set_int(OBJECT(phb), "index", + phb->phb_id, &error_abort); + + pnv_phb4_set_stack_phb_props(stack, phb); + + /* Assign the phb to the stack */ + stack->phb = phb; + + /* + * Reparent user created devices to the chip to build + * correctly the device tree. + */ + pnv_chip_parent_fixup(chip, OBJECT(phb), phb->phb_id); + + s = qdev_get_parent_bus(DEVICE(chip)); + if (!qdev_set_parent_bus(DEVICE(phb), s, &local_err)) { + error_propagate(errp, local_err); + return; + } + + stack_init_xscom = true; + } /* Set the "big_phb" flag */ phb->big_phb = phb->phb_id == 0 || phb->phb_id == 3; @@ -1305,6 +1381,10 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp) pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), TYPE_PNV_PHB4_ROOT_PORT); } + + if (stack_init_xscom) { + pnv_pec_init_stack_xscom(stack); + } } static const char *pnv_phb4_root_bus_path(PCIHostState *host_bridge, @@ -1416,7 +1496,7 @@ static void pnv_phb4_class_init(ObjectClass *klass, void *data) dc->realize = pnv_phb4_realize; device_class_set_props(dc, pnv_phb4_properties); set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); - dc->user_creatable = false; + dc->user_creatable = true; xfc->notify = pnv_phb4_xive_notify; } diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index aa93ad3f10..27973779c5 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -574,13 +574,13 @@ static void pnv_pec_stk_realize(DeviceState *dev, Error **errp) &pnv_pec_stk_pci_xscom_ops, stack, name, PHB4_PEC_PCI_STK_REGS_COUNT); - /* PHB pass-through */ - pnv_phb4_set_stack_phb_props(stack, stack->phb); - if (!sysbus_realize(SYS_BUS_DEVICE(&stack->phb), errp)) { - return; + /* + * There is no guarantee that stack->phb will be available + * at this point. + */ + if (stack->phb) { + pnv_pec_init_stack_xscom(stack); } - - pnv_pec_init_stack_xscom(stack); } static Property pnv_pec_stk_properties[] = { diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index bf2607446a..e93e77cb2e 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -2270,6 +2270,8 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data) pnv_machine_get_endian, pnv_machine_set_endian); object_class_property_set_description(oc, "endianness", "Change CPU initial endianness (default is big)"); + + machine_class_allow_dynamic_sysbus_dev(mc, TYPE_PNV_PHB4); } static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) From patchwork Tue Dec 28 19:38:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8EBAAC433F5 for ; Tue, 28 Dec 2021 19:57:07 +0000 (UTC) Received: from localhost ([::1]:43912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2Iao-0005GI-MH for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:57:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IJk-0003yN-By; Tue, 28 Dec 2021 14:39:28 -0500 Received: from [2607:f8b0:4864:20::72e] (port=34345 helo=mail-qk1-x72e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IJP-00047U-0f; Tue, 28 Dec 2021 14:39:12 -0500 Received: by mail-qk1-x72e.google.com with SMTP id b85so18060948qkc.1; Tue, 28 Dec 2021 11:38:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PNhOzWP9PX7G1H2sftmFTSQjjRvS33WOhuhoOf1dM90=; b=ed30qr921Q9zhFsAL+1qaAuLeduthWaEZZNl2LPBVLKSrMIDpNmAYXfDQUJnQuwT/M 68et+yfWU+829f+fn5tomFhMqkmTqGDuRnoT9xht79kthopVoEGbZMlvDhXjfIExrZ4V h28E23OG8veUbSGH4gze1kbv8GyY5y4nSSMaBDVmXl/YrH6SlWIB73X1MsGj4l45poKX /UTWZpycxQ1E+XaIqPvji/uWPyDzJBMxSH3m3R1XDLiId9sCcnWzrzkuGmmE3TEQvlCp woxj4YG1lMRlWM6Wxh0vAie+oSfvpVBMwiJ/ykWXT+KQXW6pn12p4/JybKkQ/jnpFtgJ CJrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PNhOzWP9PX7G1H2sftmFTSQjjRvS33WOhuhoOf1dM90=; b=VXFEmYqiuaIaisW60mIuK6tPnF2zAAXLH2E9xDUrrXkVazCuwWL7m0yXh18LplT4Pk TDrz0bQ66a7qOI6HhFLRMmskpCNKPqysEwvX3Ce2/sOCjJE4prya4VrA98fqnfCDDx6m uiavSzU/Im4L9QHSRsfBVuIkfrcQXfM5bNJcXoSFHiLldZaTmcrf4hXLtko5jumOiKzW Alzj1OF6bnxntH5iDd/xTU5w70k/saTjc6DObD981OravbS6XoEcYv5SI6aSK1ZCK4Vt mUFaakWCPEBQ9+XZKOGFJoNUdYnWgK7Ve+26/v4njmm7aICsxgLY1Ki6faX973gLY0z0 hMyw== X-Gm-Message-State: AOAM531q2IZ63gJMBAEKt0D0YovZhZOK0KUQT3jmqdVOEwmXTrnhSPHP T+gOpnocHMM9u6XjZlW4d/0mmQTuhM4= X-Google-Smtp-Source: ABdhPJxgosBN6bk/EZCPGR3F5eNrS+SdpfS700pcOwr8VH9dfLw4ycAescJ7Ny0hvIGYFCozlvfzeQ== X-Received: by 2002:a05:620a:2942:: with SMTP id n2mr16500836qkp.340.1640720328504; Tue, 28 Dec 2021 11:38:48 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:48 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 16/17] pnv_phb4.c: do not set 'root-bus' as bus name Date: Tue, 28 Dec 2021 16:38:05 -0300 Message-Id: <20211228193806.1198496-17-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::72e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x72e.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This change has the same motivation as the one done for pnv-phb3-root-bus buses previously. Defaulting every bus to 'root-bus' makes it impossible to attach root ports to specific buses and it doesn't allow for custom bus naming because we're ignoring the 'id' value when registering the root bus. After this patch, creating pnv-phb4 devices with 'id' being set will result in the following qtree: qemu-system-ppc64 -m 4G -machine powernv9,accel=tcg \ -device pnv-phb4,chip-id=0,index=0,id=pcie.0 \ -device pnv-phb4,chip-id=1,index=4,id=pcie.1 bus: main-system-bus type System dev: pnv-phb4, id "pcie.1" index = 4 (0x4) chip-id = 1 (0x1) version = 704374636546 (0xa400000002) device-id = 1217 (0x4c1) x-config-reg-migration-enabled = true bypass-iommu = false bus: pcie.1 type pnv-phb4-root-bus dev: pnv-phb4, id "pcie.0" index = 0 (0x0) chip-id = 0 (0x0) version = 704374636546 (0xa400000002) device-id = 1217 (0x4c1) x-config-reg-migration-enabled = true bypass-iommu = false bus: pcie.0 type pnv-phb4-root-bus And without setting any ids: qemu-system-ppc64 -m 4G -machine powernv9,accel=tcg \ -device pnv-phb4,chip-id=0,index=0,id=pcie.0 \ -device pnv-phb4,chip-id=1,index=4,id=pcie.1 bus: main-system-bus type System dev: pnv-phb4, id "" index = 4 (0x4) chip-id = 1 (0x1) version = 704374636546 (0xa400000002) device-id = 1217 (0x4c1) x-config-reg-migration-enabled = true bypass-iommu = false bus: pnv-phb4-root-bus.1 type pnv-phb4-root-bus dev: pnv-phb4, id "" index = 0 (0x0) chip-id = 0 (0x0) version = 704374636546 (0xa400000002) device-id = 1217 (0x4c1) x-config-reg-migration-enabled = true bypass-iommu = false bus: pnv-phb4-root-bus.0 type pnv-phb4-root-bus Signed-off-by: Daniel Henrique Barboza Reviewed-by: Cédric Le Goater --- hw/pci-host/pnv_phb4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 7b53c12b7c..982a61ebc0 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -1354,7 +1354,7 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp) memory_region_init(&phb->pci_mmio, OBJECT(phb), name, PCI_MMIO_TOTAL_SIZE); - pci->bus = pci_register_root_bus(dev, "root-bus", + pci->bus = pci_register_root_bus(dev, dev->id, pnv_phb4_set_irq, pnv_phb4_map_irq, phb, &phb->pci_mmio, &phb->pci_io, 0, 4, TYPE_PNV_PHB4_ROOT_BUS); From patchwork Tue Dec 28 19:38:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12700577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2B202C433FE for ; Tue, 28 Dec 2021 19:52:14 +0000 (UTC) Received: from localhost ([::1]:57182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2IW5-0003bw-5E for qemu-devel@archiver.kernel.org; Tue, 28 Dec 2021 14:52:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2IJk-0003yf-Dg; Tue, 28 Dec 2021 14:39:28 -0500 Received: from [2607:f8b0:4864:20::732] (port=34349 helo=mail-qk1-x732.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2IJT-00047b-ET; Tue, 28 Dec 2021 14:39:17 -0500 Received: by mail-qk1-x732.google.com with SMTP id b85so18061030qkc.1; Tue, 28 Dec 2021 11:38:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2XiWEBDF142LHMVr3kJNFRGx9OjiLnQOHdejwQhKny8=; b=m9g8B3UI72qSVdHYMjUGwj19zxo2UPV9yB8e5CT/D4zejfgzozDgvkEQI7KVw2enz1 5WbXX6yPHVqGRYGba31vkBfcNN5EXJ3uDQ74kdNpXi9m8tTIuEomRQRkSJ0FUrd4rXSA 7nfneZV/F29uEho/iUR4SD6Y7lEHvKZvQWkbe82xGMn6FfftQ6ksnLCkGk31NwZryLFk jQmbXAUdKougMsLjslAPcHnSzbe+uukhXEff6pxvGeeVhfdEiahXeRaaCETnsm2XQyWt LcdVBOMKgZ2npn8RdamZFsLpuLCPoq2kHBMecENON+kpBjJKMFV+PmG594udBwkrfpDJ zZow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2XiWEBDF142LHMVr3kJNFRGx9OjiLnQOHdejwQhKny8=; b=T3gJ4eeGXiS2J7DUyOs2g6CASVnGgsb808Nt24bX2gyeAqUZUC4h/HMyF4pX0qwLiv 3oftSyUtIPxwIKz1Bl90Rcu8jJIDiggDmAJ9Ci0z+VOaQqK05mQxYohJARgmQb8a8J94 Dq9d1ItDBRkIOY2KGjXK4NHyo2GsVXizXWKbCSUVX8TTjEVnbTxqzuJ4rnTzAE20IsMC 1wUvGAeVwk1+nIm63IvxbAuW8/QYbSgEK1kwHLeGynM/kbpyXYsvgpH0sJrJvw/etc+/ HRLo1Dg42NAp1qW2e2SMADKtt7CBFBghZlyiAK/DZVFvb3sC4p5jpPFbOXbsoqjUFrq1 wtNg== X-Gm-Message-State: AOAM532iLBB72NQQ4i4AgCPf95ZlQQ7IxDUBXdMNmYIboVf2Uj/+fCAy y5qUhPNmLRgUL4YBfr0suPczAAKLp/s= X-Google-Smtp-Source: ABdhPJxS3KRIbEK6lFBodBzjAVORQ2iwj802LdSLcfal285AZDgiq0/U0RfsXEPuXk3E2EvyQxC43A== X-Received: by 2002:a05:620a:1249:: with SMTP id a9mr15531412qkl.76.1640720330645; Tue, 28 Dec 2021 11:38:50 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c6:7ce4:b718:2cc0:32df:97ee]) by smtp.gmail.com with ESMTPSA id r20sm16924059qkp.21.2021.12.28.11.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Dec 2021 11:38:50 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Subject: [PATCH 17/17] pnv_phb4.c: change TYPE_PNV_PHB4_ROOT_BUS name Date: Tue, 28 Dec 2021 16:38:06 -0300 Message-Id: <20211228193806.1198496-18-danielhb413@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228193806.1198496-1-danielhb413@gmail.com> References: <20211228193806.1198496-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::732 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=danielhb413@gmail.com; helo=mail-qk1-x732.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Similar to what was happening with pnv-phb3 buses, TYPE_PNV_PHB4_ROOT_BUS set to "pnv-phb4-root-bus" is a bit too long for a default root bus name. The usual default name for theses buses in QEMU are 'pcie', but we want to make a distinction between pnv-phb4 buses and other PCIE buses, at least as far as default name goes, because not all PCIE devices are attachable to a pnv-phb4 root-bus type. Changing the default to 'phb4-root' allow us to have a shorter name while making this bus distinct, and the user can always set its own bus naming via the "id" attribute anyway. This is the 'info qtree' output after this change, using a powernv9 domain with 2 sockets and default settings enabled: qemu-system-ppc64 -m 4G -machine powernv9,accel=tcg \ -smp 2,sockets=2,cores=1,threads=1 dev: pnv-phb4, id "" index = 5 (0x5) chip-id = 1 (0x1) version = 704374636546 (0xa400000002) device-id = 1217 (0x4c1) x-config-reg-migration-enabled = true bypass-iommu = false bus: phb4-root.11 type phb4-root dev: pnv-phb4-root-port, id "" (...) dev: pnv-phb4, id "" index = 0 (0x0) chip-id = 1 (0x1) version = 704374636546 (0xa400000002) device-id = 1217 (0x4c1) x-config-reg-migration-enabled = true bypass-iommu = false bus: phb4-root.6 type phb4-root dev: pnv-phb4-root-port, id "" (..) dev: pnv-phb4, id "" index = 5 (0x5) chip-id = 0 (0x0) version = 704374636546 (0xa400000002) device-id = 1217 (0x4c1) x-config-reg-migration-enabled = true bypass-iommu = false bus: phb4-root.5 type phb4-root dev: pnv-phb4-root-port, id "" (...) dev: pnv-phb4, id "" index = 0 (0x0) chip-id = 0 (0x0) version = 704374636546 (0xa400000002) device-id = 1217 (0x4c1) x-config-reg-migration-enabled = true bypass-iommu = false bus: phb4-root.0 type phb4-root dev: pnv-phb4-root-port, id "" Signed-off-by: Daniel Henrique Barboza --- include/hw/pci-host/pnv_phb4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index d67e33924b..cd0714d30b 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -47,7 +47,7 @@ typedef struct PnvPhb4DMASpace { /* * PHB4 PCIe Root port */ -#define TYPE_PNV_PHB4_ROOT_BUS "pnv-phb4-root-bus" +#define TYPE_PNV_PHB4_ROOT_BUS "phb4-root" #define TYPE_PNV_PHB4_ROOT_PORT "pnv-phb4-root-port" #define TYPE_PNV_PHB5_ROOT_PORT "pnv-phb5-root-port"