From nobody Thu May 2 18:49:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1660862922; cv=none; d=zohomail.com; s=zohoarc; b=HIhPnPN9B8PPeHkKcxGkWzlgFSPmmL8QmuHilWEx00Td/u/u0VcLigA0198oCO4ludaSUQVoivDVWqogGgpcSJGVJtEVKdQUGwqyqyb8BrxXy9XGQeTLdWcxSWkAl+ji5vATeHu8h5jr0pSYpbR0kE+MU2G1Yir/OVryQJdt8KQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660862922; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l2jG350q1kWFMbnETbVmOPR/7vr+uaxszonmxsSsv2Q=; b=ejNWWEaiEhnDfALv5yfDFTdEQnJh7mjnf4biEXilpOOeyGVYk+b/+yLTES6hLgMOyvRdGqoQxg1s4VTCjTmNr+Y43ZDTrAzwlcKb6gZ/tUe5vozzbKWudw4Ol5L77BRQ3+Je5Gbq8cuMbHTrJUsbp7iv/s7Nd85tKQ31QohMBWo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660862922472207.0175568436888; Thu, 18 Aug 2022 15:48:42 -0700 (PDT) Received: from localhost ([::1]:55982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOoJd-0004SQ-F8 for importer@patchew.org; Thu, 18 Aug 2022 18:48:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOoGQ-0002I2-GN; Thu, 18 Aug 2022 18:45:22 -0400 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]:40739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oOoGO-0000Ev-Vk; Thu, 18 Aug 2022 18:45:22 -0400 Received: by mail-ot1-x334.google.com with SMTP id z22-20020a056830129600b0063711f456ceso2030955otp.7; Thu, 18 Aug 2022 15:45:20 -0700 (PDT) Received: from balboa.ibmuc.com ([189.110.115.28]) by smtp.gmail.com with ESMTPSA id y14-20020a9d460e000000b006370c0e5be0sm739134ote.48.2022.08.18.15.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 15:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=l2jG350q1kWFMbnETbVmOPR/7vr+uaxszonmxsSsv2Q=; b=NpMtvsgftjfM0PYDCObHjIRRLEhCUpe7OBoLEeZ+WNpArIoEqPMWCUtPqTba4Yo+PS PHKMCar23hRj1GdKMVsTqfc9eoCeT0vX4OWzhgS1IJD2HZGxivsc0IrbaC89WS1jYaUe AjAPV+ENDWVTmGWHQNlJQ8zmx6nieVGfI85/D7oX33XSUGHIwUqkb/BLGwOZqo6zWP9O YVl3/782Cgi9jMs8CCDI1TTSfUIlfr3p+paZE+XwpR1+LvKBn7gA924V7KhsaEAdP60b 6vbpO9IER4Xoc+WqkMdz7OuqZHqjYBXcJLoXpbT5zLz8RTyqag1Gqz6KVFPuXYnnm5J7 VO0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=l2jG350q1kWFMbnETbVmOPR/7vr+uaxszonmxsSsv2Q=; b=62P77F1mgfyRbpTi2fdjP0jBodnzfZJLDpmqTEcsBi32ugBwf+9IPftzfcgI1kI2OH 0ct82cjGlGfWfyCrA4PoJZBfo8yVLrUMvvMB9kSEOu/E+SUFO1FUiYt4qvnroKedAshi xFGeUZtZVssbgHCxVBULYFudh4/svEmwzoLpKlSuf51heUHd3cZM1pWfP4SIauWIKDK8 iNwa62MLT3sSe0q5FHvi9/JnhVgzwt9TzrBNhfTFrkq6Va1DERCL7xtrYUf06/iPtYLg i4PvcACBCToR3qkKzNsYjpkSrZD+Q0QEguyHY22016K5j6QE8eRwnkTZiBxI/UIQytN4 wdEw== X-Gm-Message-State: ACgBeo1euwkUnc/q/iu17GWqA8jU3I3iCRgu0rYBDLoz09t1z4cig2Dk PYyewWVW3SK5VsjNDPLWqxSnhsEbmeH0JQ== X-Google-Smtp-Source: AA6agR77ChQFOwN3g3gYQ/FUdOsGFmh2VDHMQSx0pyYR/BXgiuyKWlzvTlPCU2Yye2Ma4oobtMTIWQ== X-Received: by 2002:a9d:12a2:0:b0:638:937a:f620 with SMTP id g31-20020a9d12a2000000b00638937af620mr1882236otg.29.1660862719395; Thu, 18 Aug 2022 15:45:19 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, fbarrat@linux.ibm.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 1/2] ppc/pnv: consolidate pnv_parent_*_fixup() helpers Date: Thu, 18 Aug 2022 19:45:10 -0300 Message-Id: <20220818224511.373255-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220818224511.373255-1-danielhb413@gmail.com> References: <20220818224511.373255-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::334; envelope-from=danielhb413@gmail.com; helo=mail-ot1-x334.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1660862923072100001 We have 2 helpers that amends the QOM and parent bus of a given object, repectively. These 2 helpers are called together, and not by accident. Due to QOM internals, doing an object_unparent() will result in the device being removed from its parent bus. This means that changing the QOM parent requires reassigning the parent bus again. Create a single helper called pnv_parent_fixup(), documenting some of the QOM specifics that we're dealing with the unparenting/parenting mechanics, and handle both the QOM and the parent bus assignment. Next patch will make use of this function to handle a case where we need to change the QOM parent while keeping the same parent bus assigned beforehand. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/hw/pci-host/pnv_phb.c b/hw/pci-host/pnv_phb.c index 17d9960aa1..4ea33fb6ba 100644 --- a/hw/pci-host/pnv_phb.c +++ b/hw/pci-host/pnv_phb.c @@ -21,34 +21,45 @@ =20 =20 /* - * Set the QOM parent of an object child. If the device state - * associated with the child has an id, use it as QOM id. Otherwise - * use object_typename[index] as QOM id. + * Set the QOM parent and parent bus of an object child. If the device + * state associated with the child has an id, use it as QOM id. + * Otherwise use object_typename[index] as QOM id. + * + * This helper does both operations at the same time because seting + * a new QOM child will erase the bus parent of the device. This happens + * because object_unparent() will call object_property_del_child(), + * which in turn calls the property release callback prop->release if + * it's defined. In our case this callback is set to + * object_finalize_child_property(), which was assigned during the + * first object_property_add_child() call. This callback will end up + * calling device_unparent(), and this function removes the device + * from its parent bus. + * + * The QOM and parent bus to be set aren=C2=B4t necessarily related, so + * let's receive both as arguments. */ -static void pnv_parent_qom_fixup(Object *parent, Object *child, int index) +static bool pnv_parent_fixup(Object *parent, BusState *parent_bus, + Object *child, int index, + Error **errp) { g_autofree char *default_id =3D g_strdup_printf("%s[%d]", object_get_typename(child), index); const char *dev_id =3D DEVICE(child)->id; =20 if (child->parent =3D=3D parent) { - return; + return true; } =20 object_ref(child); object_unparent(child); object_property_add_child(parent, dev_id ? dev_id : default_id, child); object_unref(child); -} - -static void pnv_parent_bus_fixup(DeviceState *parent, DeviceState *child, - Error **errp) -{ - BusState *parent_bus =3D qdev_get_parent_bus(parent); =20 - if (!qdev_set_parent_bus(child, parent_bus, errp)) { - return; + if (!qdev_set_parent_bus(DEVICE(child), parent_bus, errp)) { + return false; } + + return true; } =20 /* @@ -101,8 +112,10 @@ static bool pnv_phb_user_device_init(PnvPHB *phb, Erro= r **errp) * correctly the device tree. pnv_xscom_dt() needs every * PHB to be a child of the chip to build the DT correctly. */ - pnv_parent_qom_fixup(parent, OBJECT(phb), phb->phb_id); - pnv_parent_bus_fixup(DEVICE(chip), DEVICE(phb), errp); + if (!pnv_parent_fixup(parent, qdev_get_parent_bus(DEVICE(chip)), + OBJECT(phb), phb->phb_id, errp)) { + return false; + } =20 return true; } --=20 2.37.2 From nobody Thu May 2 18:49:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1660863009; cv=none; d=zohomail.com; s=zohoarc; b=Pm5UCLAd1PFWt/tOiV+Q6MbzGN3cYOSbCRvF1LzSQbREZE0k+hzADnmRBpuPqrebHvdfa5j2aSoHaxvIfb3lzuWiAFJv3sPsOgKK4OYqBm4MvgvOXlTiGc31snoQaeGhjEXVB/zneK6bTu4QY1x81hf+MKK1KjFrnLjMj+6338o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660863009; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ROQk4g7LuWhHUpzUtw1BkZDBSLzku3i/wSocwLBYeNg=; b=FOiWA5uPA23DlFZOs1xf0A5lubqC41z0N8+1bahq0hOTTD/MlI/KbKpSPOxKif6NX9AxM3FyrfV1TChPZZtR4xb29PJ8XTCL/PdnmHqIizqgtZ+04BTqR1xmy/Os7Cedpvi97BlAkRyzNEIVqfNWTVFoJ17Wmwzzk9r+fxOU5D0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660863009189913.3821412997324; Thu, 18 Aug 2022 15:50:09 -0700 (PDT) Received: from localhost ([::1]:49124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOoL2-0006S3-11 for importer@patchew.org; Thu, 18 Aug 2022 18:50:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOoGT-0002Q5-KR; Thu, 18 Aug 2022 18:45:25 -0400 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]:35740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oOoGR-0000FJ-Tu; Thu, 18 Aug 2022 18:45:25 -0400 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-10cf9f5b500so3429362fac.2; Thu, 18 Aug 2022 15:45:23 -0700 (PDT) Received: from balboa.ibmuc.com ([189.110.115.28]) by smtp.gmail.com with ESMTPSA id y14-20020a9d460e000000b006370c0e5be0sm739134ote.48.2022.08.18.15.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 15:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=ROQk4g7LuWhHUpzUtw1BkZDBSLzku3i/wSocwLBYeNg=; b=hld20G4eLlo5Sabb4jY+ilOp98u0kMBnVM7B0kpUjL85W1Hrc3I20qXStM/U4xOU0y 1+hjXuFGDLRKuFvZ/XZDDbyqdP6BAs+DOSPYJGpBoqdkxSoAja93I+5Rm4IyjdMtD4Gb r3M347X+SBZXavv7gqvNS/Ih1i3A50NLe5MSQrw8B8P+Z2xNCuR2QfuAPvA1tabsq4k5 SfIeDE3qThzZ+kwbD0uOivaKkGWh/0cOj+NqoarLLD6vwQ7fqamCTmmcNpprzgQ3bzUl xWG477x7CGVCPAM+6NSMSpYBKZvgx4kH7g7evQni0DzlXGEneU4rvpN6A5oi3/+jo03a W/wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ROQk4g7LuWhHUpzUtw1BkZDBSLzku3i/wSocwLBYeNg=; b=AsYH63Ymxs8/OvQqInQMjDJOQNACsh1F8R1Hjmr2KnCqwNVqE0DTba4863c3vTub+Y 4tl2//TqG5mm9X6M7HMXNXN1m+D9eZHAHOlRoroU/dUawxQluIMsM642S0etx/ctdya/ tMEEbzUturc/g8RasrSPGrKt0MrZAyrGd9+b0LDz+IXcePvdrn1ICNK3Kv/SkMAarbAN 2ObfkugOc44ZBZ6Y9BCFEkfX6+Ek82+S6GrsGRwx7qjXoAjykGrzpPQKR7yYUDUvFvUP dZJEsnUeyzpYiw+KFx7zDuLNsv4yqbfnBZ8NLMlKN28ouFYS/xpSU5KgliQFC59Jo1cz v0yg== X-Gm-Message-State: ACgBeo0O8q7w1tgnSj4vrUx57El6pDjtsU+K/u6WdBw2FYPy5rhZHCJ3 D7uz8gMhWiOLXtX/eIuYNpZ7Ifjf9IcY3g== X-Google-Smtp-Source: AA6agR7Y0EkaVZGPaHLloqJpmKuTpilKjai8Ysr3RCkkIru6UzwuC+QWPUc6mLTSIb/+s753VYtyeg== X-Received: by 2002:a05:6870:538c:b0:11b:e64f:ee1b with SMTP id h12-20020a056870538c00b0011be64fee1bmr5107105oan.92.1660862722005; Thu, 18 Aug 2022 15:45:22 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, fbarrat@linux.ibm.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 2/2] ppc/pnv: fix QOM parenting of user creatable root ports Date: Thu, 18 Aug 2022 19:45:11 -0300 Message-Id: <20220818224511.373255-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220818224511.373255-1-danielhb413@gmail.com> References: <20220818224511.373255-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::2b; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x2b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1660863010277100001 Content-Type: text/plain; charset="utf-8" User creatable root ports are being parented by the 'peripheral' or the 'peripheral-anon' container. This happens because this is the regular QOM schema for sysbus devices that are added via the command line. Let's make this QOM hierarchy similar to what we have with default root ports, i.e. the root port must be parented by the pnv-root-bus. To do that we change the qom and bus parent of the root port during root_port_realize(). The realize() is shared by the default root port code path, so we can remove the code inside pnv_phb_attach_root_port() that was adding the root port as a child of the bus as well. While we're at it, change pnv_phb_attach_root_port() to receive a PCIBus instead of a PCIHostState to make it clear that the function does not make use of the PHB. Signed-off-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/hw/pci-host/pnv_phb.c b/hw/pci-host/pnv_phb.c index 4ea33fb6ba..38ec8571b7 100644 --- a/hw/pci-host/pnv_phb.c +++ b/hw/pci-host/pnv_phb.c @@ -62,27 +62,11 @@ static bool pnv_parent_fixup(Object *parent, BusState *= parent_bus, return true; } =20 -/* - * Attach a root port device. - * - * 'index' will be used both as a PCIE slot value and to calculate - * QOM id. 'chip_id' is going to be used as PCIE chassis for the - * root port. - */ -static void pnv_phb_attach_root_port(PCIHostState *pci) +static void pnv_phb_attach_root_port(PCIBus *bus) { PCIDevice *root =3D pci_new(PCI_DEVFN(0, 0), TYPE_PNV_PHB_ROOT_PORT); - const char *dev_id =3D DEVICE(root)->id; - g_autofree char *default_id =3D NULL; - int index; =20 - index =3D object_property_get_int(OBJECT(pci->bus), "phb-id", &error_f= atal); - default_id =3D g_strdup_printf("%s[%d]", TYPE_PNV_PHB_ROOT_PORT, index= ); - - object_property_add_child(OBJECT(pci->bus), dev_id ? dev_id : default_= id, - OBJECT(root)); - - pci_realize_and_unref(root, pci->bus, &error_fatal); + pci_realize_and_unref(root, bus, &error_fatal); } =20 /* @@ -184,7 +168,7 @@ static void pnv_phb_realize(DeviceState *dev, Error **e= rrp) return; } =20 - pnv_phb_attach_root_port(pci); + pnv_phb_attach_root_port(pci->bus); } =20 static const char *pnv_phb_root_bus_path(PCIHostState *host_bridge, @@ -259,6 +243,11 @@ static void pnv_phb_root_port_realize(DeviceState *dev= , Error **errp) Error *local_err =3D NULL; int chip_id, index; =20 + /* + * 'index' will be used both as a PCIE slot value and to calculate + * QOM id. 'chip_id' is going to be used as PCIE chassis for the + * root port. + */ chip_id =3D object_property_get_int(OBJECT(bus), "chip-id", &error_fat= al); index =3D object_property_get_int(OBJECT(bus), "phb-id", &error_fatal); =20 @@ -266,6 +255,17 @@ static void pnv_phb_root_port_realize(DeviceState *dev= , Error **errp) qdev_prop_set_uint8(dev, "chassis", chip_id); qdev_prop_set_uint16(dev, "slot", index); =20 + /* + * User created root ports are QOM parented to one of + * the peripheral containers but it's already at the right + * parent bus. Change the QOM parent to be the same as the + * parent bus it's already assigned to. + */ + if (!pnv_parent_fixup(OBJECT(bus), BUS(bus), OBJECT(dev), + index, errp)) { + return; + } + rpc->parent_realize(dev, &local_err); if (local_err) { error_propagate(errp, local_err); --=20 2.37.2