From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150100559190356.28315142199267; Tue, 25 Jul 2017 10:59:51 -0700 (PDT) Received: from localhost ([::1]:33868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da47a-0001Hw-B3 for importer@patchew.org; Tue, 25 Jul 2017 13:59:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56521) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da46F-0000MS-TW for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:58:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da46C-0000oi-UW for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:58:28 -0400 Received: from 18.mo5.mail-out.ovh.net ([178.33.45.10]:45301) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da46C-0000oJ-I9 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:58:24 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 0E0F711634A for ; Tue, 25 Jul 2017 19:58:23 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 989CE20067; Tue, 25 Jul 2017 19:58:15 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 19:58:15 +0200 Message-ID: <150100549536.27487.11322702271540744350.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9709197850122951129 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.45.10 Subject: [Qemu-devel] [for-2.11 PATCH 01/26] spapr: move spapr_create_phb() to core machine code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 This function is only used when creating the default PHB. Let's rename it and move it to the core machine code for clarity. Signed-off-by: Greg Kurz Reviewed-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- hw/ppc/spapr.c | 13 ++++++++++++- hw/ppc/spapr_pci.c | 11 ----------- include/hw/pci-host/spapr.h | 2 -- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 2a3e53d5d58c..53969315ac24 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2142,6 +2142,17 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) g_free(type); } =20 +static PCIHostState *spapr_create_default_phb(sPAPRMachineState *spapr) +{ + DeviceState *dev; + + dev =3D qdev_create(NULL, TYPE_SPAPR_PCI_HOST_BRIDGE); + qdev_prop_set_uint32(dev, "index", 0); + qdev_init_nofail(dev); + + return PCI_HOST_BRIDGE(dev); +} + /* pSeries LPAR / sPAPR hardware init */ static void ppc_spapr_init(MachineState *machine) { @@ -2374,7 +2385,7 @@ static void ppc_spapr_init(MachineState *machine) /* Set up PCI */ spapr_pci_rtas_init(); =20 - phb =3D spapr_create_phb(spapr, 0); + phb =3D spapr_create_default_phb(spapr); =20 for (i =3D 0; i < nb_nics; i++) { NICInfo *nd =3D &nd_table[i]; diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index d84abf1070a0..70a99a032267 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1982,17 +1982,6 @@ static const TypeInfo spapr_phb_info =3D { } }; =20 -PCIHostState *spapr_create_phb(sPAPRMachineState *spapr, int index) -{ - DeviceState *dev; - - dev =3D qdev_create(NULL, TYPE_SPAPR_PCI_HOST_BRIDGE); - qdev_prop_set_uint32(dev, "index", index); - qdev_init_nofail(dev); - - return PCI_HOST_BRIDGE(dev); -} - typedef struct sPAPRFDT { void *fdt; int node_off; diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 38470b2f0e5c..5a4e9686d562 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -111,8 +111,6 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRP= HBState *phb, int pin) return xics_get_qirq(XICS_FABRIC(spapr), phb->lsi_table[pin].irq); } =20 -PCIHostState *spapr_create_phb(sPAPRMachineState *spapr, int index); - int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t xics_phandle, void *fdt); From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501005747296699.8996010025016; Tue, 25 Jul 2017 11:02:27 -0700 (PDT) Received: from localhost ([::1]:33887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4A1-0003Oj-NJ for importer@patchew.org; Tue, 25 Jul 2017 14:02:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da46S-0000Ym-8A for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:58:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da46P-0000s4-9H for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:58:40 -0400 Received: from 10.mo5.mail-out.ovh.net ([46.105.52.148]:37713) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da46P-0000rh-3Q for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:58:37 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id BC2C5116337 for ; Tue, 25 Jul 2017 19:58:35 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 54F4520077; Tue, 25 Jul 2017 19:58:28 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 19:58:28 +0200 Message-ID: <150100550805.27487.16069660631488548584.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9712857024677779929 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.52.148 Subject: [Qemu-devel] [for-2.11 PATCH 02/26] spapr_pci: use memory_region_add_subregion() with DMA windows X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Passing a null priority to memory_region_add_subregion_overlap() is strictly equivalent to calling memory_region_add_subregion(). Signed-off-by: Greg Kurz Reviewed-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- hw/ppc/spapr_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 70a99a032267..3fe7f3145467 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1752,8 +1752,8 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) i, sphb->dtbusname); return; } - memory_region_add_subregion_overlap(&sphb->iommu_root, 0, - spapr_tce_get_iommu(tcet), 0); + memory_region_add_subregion(&sphb->iommu_root, 0, + spapr_tce_get_iommu(tcet)); } =20 sphb->msi =3D g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g= _free); From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501005914235961.7903340262261; Tue, 25 Jul 2017 11:05:14 -0700 (PDT) Received: from localhost ([::1]:33902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Ck-00060P-FJ for importer@patchew.org; Tue, 25 Jul 2017 14:05:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da46f-0000lz-3t for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:58:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da46c-0000xT-2r for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:58:53 -0400 Received: from 12.mo5.mail-out.ovh.net ([46.105.39.65]:44076) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da46b-0000wX-SG for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:58:50 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 6CD7711641C for ; Tue, 25 Jul 2017 19:58:48 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 06E9F20077; Tue, 25 Jul 2017 19:58:40 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 19:58:40 +0200 Message-ID: <150100552078.27487.390170136970607382.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9716516197364505049 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.39.65 Subject: [Qemu-devel] [for-2.11 PATCH 03/26] spapr_iommu: use g_strdup_printf() instead of snprintf() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Passing a stack allocated buffer of arbitrary length to snprintf() without checking the return value can cause the resultant strings to be silently truncated. Signed-off-by: Greg Kurz --- hw/ppc/spapr_iommu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index e614621a8317..740d42608b61 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -252,17 +252,19 @@ static int spapr_tce_table_realize(DeviceState *dev) { sPAPRTCETable *tcet =3D SPAPR_TCE_TABLE(dev); Object *tcetobj =3D OBJECT(tcet); - char tmp[32]; + gchar *tmp; =20 tcet->fd =3D -1; tcet->need_vfio =3D false; - snprintf(tmp, sizeof(tmp), "tce-root-%x", tcet->liobn); + tmp =3D g_strdup_printf("tce-root-%x", tcet->liobn); memory_region_init(&tcet->root, tcetobj, tmp, UINT64_MAX); + g_free(tmp); =20 - snprintf(tmp, sizeof(tmp), "tce-iommu-%x", tcet->liobn); + tmp =3D g_strdup_printf("tce-iommu-%x", tcet->liobn); memory_region_init_iommu(&tcet->iommu, sizeof(tcet->iommu), TYPE_SPAPR_IOMMU_MEMORY_REGION, tcetobj, tmp, 0); + g_free(tmp); =20 QLIST_INSERT_HEAD(&spapr_tce_tables, tcet, list); =20 @@ -307,7 +309,7 @@ void spapr_tce_set_need_vfio(sPAPRTCETable *tcet, bool = need_vfio) sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn) { sPAPRTCETable *tcet; - char tmp[32]; + gchar *tmp; =20 if (spapr_tce_find_by_liobn(liobn)) { error_report("Attempted to create TCE table with duplicate" @@ -318,8 +320,9 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, = uint32_t liobn) tcet =3D SPAPR_TCE_TABLE(object_new(TYPE_SPAPR_TCE_TABLE)); tcet->liobn =3D liobn; =20 - snprintf(tmp, sizeof(tmp), "tce-table-%x", liobn); + tmp =3D g_strdup_printf("tce-table-%x", liobn); object_property_add_child(OBJECT(owner), tmp, OBJECT(tcet), NULL); + g_free(tmp); =20 object_property_set_bool(OBJECT(tcet), true, "realized", NULL); =20 From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501005742086421.1437518939256; Tue, 25 Jul 2017 11:02:22 -0700 (PDT) Received: from localhost ([::1]:33886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da49z-0003NT-72 for importer@patchew.org; Tue, 25 Jul 2017 14:02:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da46r-0000zM-N9 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da46o-00013c-NB for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:05 -0400 Received: from 3.mo5.mail-out.ovh.net ([46.105.40.108]:34550) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da46o-00013F-GI for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:02 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 20FB911641E for ; Tue, 25 Jul 2017 19:59:01 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id AB99020067; Tue, 25 Jul 2017 19:58:53 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 19:58:53 +0200 Message-ID: <150100553345.27487.10049014405920351882.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9720175371932047833 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.40.108 Subject: [Qemu-devel] [for-2.11 PATCH 04/26] spapr_drc: use g_strdup_printf() instead of snprintf() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Passing a stack allocated buffer of arbitrary length to snprintf() without checking the return value can cause the resultant strings to be silently truncated. Signed-off-by: Greg Kurz --- hw/ppc/spapr_drc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 15bae5c216a9..e4e8383ec7b5 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -488,7 +488,7 @@ static void realize(DeviceState *d, Error **errp) { sPAPRDRConnector *drc =3D SPAPR_DR_CONNECTOR(d); Object *root_container; - char link_name[256]; + gchar *link_name; gchar *child_name; Error *err =3D NULL; =20 @@ -501,11 +501,12 @@ static void realize(DeviceState *d, Error **errp) * existing in the composition tree */ root_container =3D container_get(object_get_root(), DRC_CONTAINER_PATH= ); - snprintf(link_name, sizeof(link_name), "%x", spapr_drc_index(drc)); + link_name =3D g_strdup_printf("%x", spapr_drc_index(drc)); child_name =3D object_get_canonical_path_component(OBJECT(drc)); trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name); object_property_add_alias(root_container, link_name, drc->owner, child_name, &err); + g_free(link_name); if (err) { error_report_err(err); object_unref(OBJECT(drc)); @@ -521,13 +522,14 @@ static void unrealize(DeviceState *d, Error **errp) { sPAPRDRConnector *drc =3D SPAPR_DR_CONNECTOR(d); Object *root_container; - char name[256]; + gchar *name; Error *err =3D NULL; =20 trace_spapr_drc_unrealize(spapr_drc_index(drc)); root_container =3D container_get(object_get_root(), DRC_CONTAINER_PATH= ); - snprintf(name, sizeof(name), "%x", spapr_drc_index(drc)); + name =3D g_strdup_printf("%x", spapr_drc_index(drc)); object_property_del(root_container, name, &err); + g_free(name); if (err) { error_report_err(err); object_unref(OBJECT(drc)); @@ -729,10 +731,11 @@ static const TypeInfo spapr_drc_lmb_info =3D { sPAPRDRConnector *spapr_drc_by_index(uint32_t index) { Object *obj; - char name[256]; + gchar *name; =20 - snprintf(name, sizeof(name), "%s/%x", DRC_CONTAINER_PATH, index); + name =3D g_strdup_printf("%s/%x", DRC_CONTAINER_PATH, index); obj =3D object_resolve_path(name, NULL); + g_free(name); =20 return !obj ? NULL : SPAPR_DR_CONNECTOR(obj); } From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15010061285641018.1546177435303; Tue, 25 Jul 2017 11:08:48 -0700 (PDT) Received: from localhost ([::1]:33925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4GE-0000Vd-41 for importer@patchew.org; Tue, 25 Jul 2017 14:08:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da474-00017g-FK for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da471-000183-GC for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:18 -0400 Received: from 2.mo5.mail-out.ovh.net ([178.33.109.111]:59101) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da471-00017T-AA for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:15 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id C8ADD116464 for ; Tue, 25 Jul 2017 19:59:13 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 60C4920067; Tue, 25 Jul 2017 19:59:06 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 19:59:06 +0200 Message-ID: <150100554612.27487.13537614128295672408.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9723553074743843289 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.109.111 Subject: [Qemu-devel] [for-2.11 PATCH 05/26] spapr_iommu: convert TCE table object to realize() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Greg Kurz Reviewed-by: Alexey Kardashevskiy --- hw/ppc/spapr_iommu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index 740d42608b61..d4eca2a77225 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -248,7 +248,7 @@ static const VMStateDescription vmstate_spapr_tce_table= =3D { } }; =20 -static int spapr_tce_table_realize(DeviceState *dev) +static void spapr_tce_table_realize(DeviceState *dev, Error **errp) { sPAPRTCETable *tcet =3D SPAPR_TCE_TABLE(dev); Object *tcetobj =3D OBJECT(tcet); @@ -270,8 +270,6 @@ static int spapr_tce_table_realize(DeviceState *dev) =20 vmstate_register(DEVICE(tcet), tcet->liobn, &vmstate_spapr_tce_table, tcet); - - return 0; } =20 void spapr_tce_set_need_vfio(sPAPRTCETable *tcet, bool need_vfio) @@ -618,7 +616,7 @@ int spapr_tcet_dma_dt(void *fdt, int node_off, const ch= ar *propname, static void spapr_tce_table_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); - dc->init =3D spapr_tce_table_realize; + dc->realize =3D spapr_tce_table_realize; dc->reset =3D spapr_tce_reset; dc->unrealize =3D spapr_tce_table_unrealize; =20 From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006278146555.7521256011216; Tue, 25 Jul 2017 11:11:18 -0700 (PDT) Received: from localhost ([::1]:33940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Id-0002q5-Kk for importer@patchew.org; Tue, 25 Jul 2017 14:11:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da47G-0001Hq-UO for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da47D-0001E6-Ul for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:31 -0400 Received: from 19.mo5.mail-out.ovh.net ([46.105.35.78]:47276) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da47D-0001Dl-O4 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:27 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 7128D116502 for ; Tue, 25 Jul 2017 19:59:26 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 0DB7920078; Tue, 25 Jul 2017 19:59:19 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 19:59:18 +0200 Message-ID: <150100555881.27487.6700589734222986048.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9727212245518162393 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.35.78 Subject: [Qemu-devel] [for-2.11 PATCH 06/26] spapr_pci: parent the MSI memory region to the PHB X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 This memory region should be owned by the PHB. This ensures the PHB cannot be finalized as long as the the region is guest visible, or used by a CPU or a device. Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 3fe7f3145467..4e4165b44b9a 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1703,7 +1703,7 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) } #endif =20 - memory_region_init_io(&sphb->msiwindow, NULL, &spapr_msi_ops, spapr, + memory_region_init_io(&sphb->msiwindow, OBJECT(sphb), &spapr_msi_ops, = spapr, "msi", msi_window_size); memory_region_add_subregion(&sphb->iommu_root, SPAPR_PCI_MSI_WINDOW, &sphb->msiwindow); From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501005684991939.560852790523; Tue, 25 Jul 2017 11:01:24 -0700 (PDT) Received: from localhost ([::1]:33883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da495-0002aA-6h for importer@patchew.org; Tue, 25 Jul 2017 14:01:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da47T-0001TJ-F7 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da47Q-0001Ig-F5 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:43 -0400 Received: from 3.mo5.mail-out.ovh.net ([46.105.40.108]:59462) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da47Q-0001IO-7w for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:40 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 1F522116555 for ; Tue, 25 Jul 2017 19:59:39 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id B01CB20067; Tue, 25 Jul 2017 19:59:31 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 19:59:31 +0200 Message-ID: <150100557147.27487.5031800506520955290.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9730871424125737433 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.40.108 Subject: [Qemu-devel] [for-2.11 PATCH 07/26] spapr_drc: fix realize and unrealize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 If object_property_add_alias() returns an error in realize(), we should propagate it to the caller and certainly not unref the DRC. Same thing goes for unrealize(). Since object_property_del() is the last call, we can even get rid of the intermediate Error *. And finally, unrealize() should undo all registrations performed by realize(). Signed-off-by: Greg Kurz --- hw/ppc/spapr_drc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index e4e8383ec7b5..d72453bcb42f 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -506,12 +506,12 @@ static void realize(DeviceState *d, Error **errp) trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name); object_property_add_alias(root_container, link_name, drc->owner, child_name, &err); + g_free(child_name); g_free(link_name); if (err) { - error_report_err(err); - object_unref(OBJECT(drc)); + error_propagate(errp, err); + return; } - g_free(child_name); vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc, drc); qemu_register_reset(drc_reset, drc); @@ -523,17 +523,14 @@ static void unrealize(DeviceState *d, Error **errp) sPAPRDRConnector *drc =3D SPAPR_DR_CONNECTOR(d); Object *root_container; gchar *name; - Error *err =3D NULL; =20 trace_spapr_drc_unrealize(spapr_drc_index(drc)); + qemu_unregister_reset(drc_reset, drc); + vmstate_unregister(DEVICE(drc), &vmstate_spapr_drc, drc); root_container =3D container_get(object_get_root(), DRC_CONTAINER_PATH= ); name =3D g_strdup_printf("%x", spapr_drc_index(drc)); - object_property_del(root_container, name, &err); + object_property_del(root_container, name, errp); g_free(name); - if (err) { - error_report_err(err); - object_unref(OBJECT(drc)); - } } =20 sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type, From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501005916746328.9946461897714; Tue, 25 Jul 2017 11:05:16 -0700 (PDT) Received: from localhost ([::1]:33903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Cn-00063W-Dm for importer@patchew.org; Tue, 25 Jul 2017 14:05:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da47g-0001eV-Hp for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da47d-0001Nw-Hh for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:56 -0400 Received: from 15.mo5.mail-out.ovh.net ([178.33.107.29]:55023) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da47d-0001NH-B3 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 13:59:53 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id C38C01164EB for ; Tue, 25 Jul 2017 19:59:51 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 5EE3320077; Tue, 25 Jul 2017 19:59:44 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 19:59:44 +0200 Message-ID: <150100558414.27487.6550654617210440325.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9734249121385322969 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.107.29 Subject: [Qemu-devel] [for-2.11 PATCH 08/26] spapr_drc: add unrealize method to physical DRC class X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 When hot-unplugging a PHB, all its PCI DRC connectors get unrealized. This patch adds an unrealize method to the physical DRC class, in order to undo registrations performed in realize_physical(). Signed-off-by: Greg Kurz --- hw/ppc/spapr_drc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index d72453bcb42f..105ce85b6d04 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -626,12 +626,28 @@ static void realize_physical(DeviceState *d, Error **= errp) qemu_register_reset(drc_physical_reset, drcp); } =20 +static void unrealize_physical(DeviceState *d, Error **errp) +{ + sPAPRDRCPhysical *drcp =3D SPAPR_DRC_PHYSICAL(d); + Error *local_err =3D NULL; + + unrealize(d, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + vmstate_unregister(DEVICE(drcp), &vmstate_spapr_drc_physical, drcp); + qemu_unregister_reset(drc_physical_reset, drcp); +} + static void spapr_drc_physical_class_init(ObjectClass *k, void *data) { DeviceClass *dk =3D DEVICE_CLASS(k); sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_CLASS(k); =20 dk->realize =3D realize_physical; + dk->unrealize =3D unrealize_physical; drck->dr_entity_sense =3D physical_entity_sense; drck->isolate =3D drc_isolate_physical; drck->unisolate =3D drc_unisolate_physical; From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006098910183.3240986222536; Tue, 25 Jul 2017 11:08:18 -0700 (PDT) Received: from localhost ([::1]:33922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Fh-0008Vq-6R for importer@patchew.org; Tue, 25 Jul 2017 14:08:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da47t-0001rW-5J for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da47q-0001TV-4x for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:09 -0400 Received: from 7.mo5.mail-out.ovh.net ([178.32.124.100]:48314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da47p-0001T2-UJ for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:06 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 71FAB11658C for ; Tue, 25 Jul 2017 20:00:04 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 0DF0E20081; Tue, 25 Jul 2017 19:59:57 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 19:59:56 +0200 Message-ID: <150100559681.27487.12465113775325434061.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9737908296866109913 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.124.100 Subject: [Qemu-devel] [for-2.11 PATCH 09/26] spapr_drc: pass object ownership to parent/owner X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth DRC objects attach themselves to an owner as a child property. unref afterward to allow them to be finalized when their owner is finalized. Signed-off-by: Michael Roth Reviewed-by: Paolo Bonzini Reviewed-by: David Gibson Signed-off-by: Greg Kurz --- Changes since RFC: - rebased against ppc-for-2.10 --- hw/ppc/spapr_drc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 105ce85b6d04..eb8024d37c54 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -544,6 +544,7 @@ sPAPRDRConnector *spapr_dr_connector_new(Object *owner,= const char *type, prop_name =3D g_strdup_printf("dr-connector[%"PRIu32"]", spapr_drc_index(drc)); object_property_add_child(owner, prop_name, OBJECT(drc), NULL); + object_unref(OBJECT(drc)); object_property_set_bool(OBJECT(drc), true, "realized", NULL); g_free(prop_name); =20 From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006477280155.4229060539584; Tue, 25 Jul 2017 11:14:37 -0700 (PDT) Received: from localhost ([::1]:33968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Lq-0005pT-QQ for importer@patchew.org; Tue, 25 Jul 2017 14:14:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da485-000263-HL for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da482-0001dp-IJ for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:21 -0400 Received: from 8.mo5.mail-out.ovh.net ([178.32.116.78]:50717) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da482-0001dL-BF for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:18 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 1D3821165DB for ; Tue, 25 Jul 2017 20:00:17 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id AE69D20087; Tue, 25 Jul 2017 20:00:09 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:00:09 +0200 Message-ID: <150100560947.27487.8779404117672050454.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9741567472344340953 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.116.78 Subject: [Qemu-devel] [for-2.11 PATCH 10/26] spapr_iommu: pass object ownership to parent/owner X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth TCE table objects attach themselves to an owner as a child property. unref afterward to allow them to be finalized when their owner is finalized. Signed-off-by: Michael Roth Reviewed-by: Paolo Bonzini Reviewed-by: David Gibson Signed-off-by: Greg Kurz --- Changes since RFC: - s/DRC/TCE table/ in changelog --- hw/ppc/spapr_iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index d4eca2a77225..8ec4e7a40834 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -321,6 +321,7 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, = uint32_t liobn) tmp =3D g_strdup_printf("tce-table-%x", liobn); object_property_add_child(OBJECT(owner), tmp, OBJECT(tcet), NULL); g_free(tmp); + object_unref(OBJECT(tcet)); =20 object_property_set_bool(OBJECT(tcet), true, "realized", NULL); =20 From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501005757413800.2482991074341; Tue, 25 Jul 2017 11:02:37 -0700 (PDT) Received: from localhost ([::1]:33889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4AA-0003Vn-Ty for importer@patchew.org; Tue, 25 Jul 2017 14:02:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da48I-0002GB-5G for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da48F-0001rF-5G for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:34 -0400 Received: from 7.mo5.mail-out.ovh.net ([178.32.124.100]:42460) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da48E-0001pS-Ub for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:31 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id BBBB511661A for ; Tue, 25 Jul 2017 20:00:29 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 5A9CB20074; Tue, 25 Jul 2017 20:00:22 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:00:22 +0200 Message-ID: <150100562212.27487.3148886355304043696.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9744945171702585817 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.124.100 Subject: [Qemu-devel] [for-2.11 PATCH 11/26] spapr_iommu: unregister vmstate at unrealize time X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Greg Kurz --- hw/ppc/spapr_iommu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index 8ec4e7a40834..40a44c563824 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -374,6 +374,8 @@ static void spapr_tce_table_unrealize(DeviceState *dev,= Error **errp) { sPAPRTCETable *tcet =3D SPAPR_TCE_TABLE(dev); =20 + vmstate_unregister(DEVICE(tcet), &vmstate_spapr_tce_table, tcet); + QLIST_REMOVE(tcet, list); =20 spapr_tce_table_disable(tcet); From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501005921720220.9697562853139; Tue, 25 Jul 2017 11:05:21 -0700 (PDT) Received: from localhost ([::1]:33904 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Cs-000687-80 for importer@patchew.org; Tue, 25 Jul 2017 14:05:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da48V-0002RO-T7 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da48S-00021E-Qp for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:47 -0400 Received: from 2.mo5.mail-out.ovh.net ([178.33.109.111]:52524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da48S-0001yR-4J for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:44 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id A8E64116677 for ; Tue, 25 Jul 2017 20:00:42 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 0719F20074; Tue, 25 Jul 2017 20:00:34 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:00:34 +0200 Message-ID: <150100563478.27487.17227002781587919515.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9748604345668180441 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.109.111 Subject: [Qemu-devel] [for-2.11 PATCH 12/26] pci: allow cleanup/unregistration of PCI buses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth This adds cleanup counterparts to pci_register_bus(), pci_bus_new(), and pci_bus_irqs(). These cleanup routines are needed in the case of hotpluggable PCIHostBridge implementations. Currently we can rely on the object_unparent()'ing of the PCIHostState recursively unparenting and cleaning up it's child buses, but we need explicit calls to also: 1) remove the PCIHostState from pci_host_bridges global list. otherwise, we risk accessing freed memory when we access the list later 2) clean up memory allocated in pci_bus_irqs() Both are handled outside the context of any particular bus or host bridge's init/realize functions, making it difficult to avoid the need for explicit cleanup functions without remodeling how PCIHostBridges are created. So keep it simple and just add them for now. Cc: Michael S. Tsirkin Cc: Paolo Bonzini Signed-off-by: Michael Roth Reviewed-by: David Gibson Signed-off-by: Greg Kurz --- Changes since RFC: - rebased against ppc-for-2.10 - renamed arg of pci_host_bus_register() to host for consistency --- hw/pci/pci.c | 33 +++++++++++++++++++++++++++++++++ include/hw/pci/pci.h | 3 +++ 2 files changed, 36 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 258fbe51e2ee..22765b8529d1 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -319,6 +319,13 @@ static void pci_host_bus_register(DeviceState *host) QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next); } =20 +static void pci_host_bus_unregister(DeviceState *host) +{ + PCIHostState *host_bridge =3D PCI_HOST_BRIDGE(host); + + QLIST_REMOVE(host_bridge, next); +} + PCIBus *pci_find_primary_bus(void) { PCIBus *primary_bus =3D NULL; @@ -380,6 +387,11 @@ static void pci_bus_init(PCIBus *bus, DeviceState *par= ent, pci_host_bus_register(parent); } =20 +static void pci_bus_uninit(PCIBus *bus) +{ + pci_host_bus_unregister(BUS(bus)->parent); +} + bool pci_bus_is_express(PCIBus *bus) { return object_dynamic_cast(OBJECT(bus), TYPE_PCIE_BUS); @@ -412,6 +424,12 @@ PCIBus *pci_bus_new(DeviceState *parent, const char *n= ame, return bus; } =20 +void pci_bus_cleanup(PCIBus *bus) +{ + pci_bus_uninit(bus); + object_unparent(OBJECT(bus)); +} + void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_= irq, void *irq_opaque, int nirq) { @@ -422,6 +440,15 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq,= pci_map_irq_fn map_irq, bus->irq_count =3D g_malloc0(nirq * sizeof(bus->irq_count[0])); } =20 +void pci_bus_irqs_cleanup(PCIBus *bus) +{ + bus->set_irq =3D NULL; + bus->map_irq =3D NULL; + bus->irq_opaque =3D NULL; + bus->nirq =3D 0; + g_free(bus->irq_count); +} + PCIBus *pci_register_bus(DeviceState *parent, const char *name, pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, void *irq_opaque, @@ -437,6 +464,12 @@ PCIBus *pci_register_bus(DeviceState *parent, const ch= ar *name, return bus; } =20 +void pci_unregister_bus(PCIBus *bus) +{ + pci_bus_irqs_cleanup(bus); + pci_bus_cleanup(bus); +} + int pci_bus_num(PCIBus *s) { return PCI_BUS_GET_CLASS(s)->bus_num(s); diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index e598b095ebca..3667e4cda73e 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -400,8 +400,10 @@ PCIBus *pci_bus_new(DeviceState *parent, const char *n= ame, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, uint8_t devfn_min, const char *typename); +void pci_bus_cleanup(PCIBus *bus); void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, pci_map_irq_fn map_= irq, void *irq_opaque, int nirq); +void pci_bus_irqs_cleanup(PCIBus *bus); int pci_bus_get_irq_level(PCIBus *bus, int irq_num); /* 0 <=3D pin <=3D 3 0 =3D INTA, 1 =3D INTB, 2 =3D INTC, 3 =3D INTD */ int pci_swizzle_map_irq_fn(PCIDevice *pci_dev, int pin); @@ -411,6 +413,7 @@ PCIBus *pci_register_bus(DeviceState *parent, const cha= r *name, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, uint8_t devfn_min, int nirq, const char *typename= ); +void pci_unregister_bus(PCIBus *bus); void pci_bus_set_route_irq_fn(PCIBus *, pci_route_irq_fn); PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin); bool pci_intx_route_changed(PCIINTxRoute *old, PCIINTxRoute *new); From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006480100196.4074763319046; Tue, 25 Jul 2017 11:14:40 -0700 (PDT) Received: from localhost ([::1]:33969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Ls-0005qb-E1 for importer@patchew.org; Tue, 25 Jul 2017 14:14:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da48h-0002am-Th for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da48e-0002En-O4 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:00 -0400 Received: from 10.mo5.mail-out.ovh.net ([46.105.52.148]:35844) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da48e-0002Di-Ib for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:00:56 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 247AE116609 for ; Tue, 25 Jul 2017 20:00:55 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id AEC8B20074; Tue, 25 Jul 2017 20:00:47 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:00:47 +0200 Message-ID: <150100564746.27487.5195312465666688402.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9752263519367633369 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.52.148 Subject: [Qemu-devel] [for-2.11 PATCH 13/26] qdev: store DeviceState's canonical path to use when unparenting X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth device_unparent(dev, ...) is called when a device is unparented, either directly, or as a result of a parent device being finalized, and handles some final cleanup for the device. Part of this includes emiting a DEVICE_DELETED QMP event to notify management, which includes the device's path in the composition tree as provided by object_get_canonical_path(). object_get_canonical_path() assumes the device is still connected to the machine/root container, and will assert otherwise, but in some situations this isn't the case: If the parent is finalized as a result of object_unparent(), it will still be attached to the composition tree at the time any children are unparented as a result of that same call to object_unparent(). However, in some cases, object_unparent() will complete without finalizing the parent device, due to lingering references that won't be released till some time later. One such example is if the parent has MemoryRegion children (which take a ref on their parent), who in turn have AddressSpace's (which take a ref on their regions), since those AddressSpaces get cleaned up asynchronously by the RCU thread. In this case qdev:device_unparent() may be called for a child Device that no longer has a path to the root/machine container, causing object_get_canonical_path() to assert. Fix this by storing the canonical path during realize() so the information will still be available for device_unparent() in such cases. Cc: Michael S. Tsirkin Cc: Paolo Bonzini Signed-off-by: Michael Roth Signed-off-by: Greg Kurz --- Changes since RFC: - rebased against ppc-for-2.10 --- hw/core/qdev.c | 15 ++++++++++++--- include/hw/qdev-core.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 606ab53c42cd..a64b35c16251 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -928,6 +928,12 @@ static void device_set_realized(Object *obj, bool valu= e, Error **errp) goto post_realize_fail; } =20 + /* always re-initialize since we clean up in device_unparent() ins= tead + * of unrealize() + */ + g_free(dev->canonical_path); + dev->canonical_path =3D object_get_canonical_path(OBJECT(dev)); + if (qdev_get_vmsd(dev)) { if (vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev)= , dev, dev->instance_id_alias, @@ -984,6 +990,7 @@ child_realize_fail: } =20 post_realize_fail: + g_free(dev->canonical_path); if (dc->unrealize) { dc->unrealize(dev, NULL); } @@ -1102,10 +1109,12 @@ static void device_unparent(Object *obj) =20 /* Only send event if the device had been completely realized */ if (dev->pending_deleted_event) { - gchar *path =3D object_get_canonical_path(OBJECT(dev)); + g_assert(dev->canonical_path); =20 - qapi_event_send_device_deleted(!!dev->id, dev->id, path, &error_ab= ort); - g_free(path); + qapi_event_send_device_deleted(!!dev->id, dev->id, dev->canonical_= path, + &error_abort); + g_free(dev->canonical_path); + dev->canonical_path =3D NULL; } =20 qemu_opts_del(dev->opts); diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index ae317286a480..9237b6849ff3 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -153,6 +153,7 @@ struct DeviceState { /*< public >*/ =20 const char *id; + char *canonical_path; bool realized; bool pending_deleted_event; QemuOpts *opts; From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006706363253.4489792402411; Tue, 25 Jul 2017 11:18:26 -0700 (PDT) Received: from localhost ([::1]:34014 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4PU-0000Ym-Tx for importer@patchew.org; Tue, 25 Jul 2017 14:18:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da48u-0002nj-Rb for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da48r-0002Pm-Rn for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:12 -0400 Received: from 9.mo5.mail-out.ovh.net ([178.32.96.204]:34015) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da48r-0002Ou-LC for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:09 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id CC12F116651 for ; Tue, 25 Jul 2017 20:01:07 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 6284820074; Tue, 25 Jul 2017 20:01:00 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:01:00 +0200 Message-ID: <150100566015.27487.526106415682092173.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9755641220481522137 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.96.204 Subject: [Qemu-devel] [for-2.11 PATCH 14/26] spapr_pci: add PHB unrealize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth To support PHB hotplug we need to clean up lingering references, memory, child properties, etc. prior to the PHB object being finalized. Generally this will be called as a result of calling object_unparent() on the PHB object, which in turn would normally be called as the result of an unplug() operation. When the PHB is finalized, child objects will be unparented in turn, and finalized if the PHB was the only reference holder. so we don't bother to explicitly unparent child objects of the PHB (spapr_iommu, spapr_drc, etc). Signed-off-by: Michael Roth Signed-off-by: Greg Kurz --- Changes since RFC: - rebased against ppc-for-2.10 - s/object_unref/object_unparent/ in the changelog - adapted to DDW and 64-bit MMIO window - free dtbusname in finalize function - don't bother to unparent memory regions: they seem to drop any reference on the PHB during unrealize (ie, I couldn't find a scenario where the PHB isn't finalized) --- hw/ppc/spapr_pci.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 4e4165b44b9a..994d2f36105f 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1530,6 +1530,50 @@ static void spapr_pci_unplug_request(HotplugHandler = *plug_handler, } } =20 +static void spapr_phb_finalizefn(Object *obj) +{ + sPAPRPHBState *sphb =3D SPAPR_PCI_HOST_BRIDGE(obj); + + g_free(sphb->dtbusname); + sphb->dtbusname =3D NULL; +} + +static void spapr_phb_unrealize(DeviceState *dev, Error **errp) +{ + SysBusDevice *s =3D SYS_BUS_DEVICE(dev); + PCIHostState *phb =3D PCI_HOST_BRIDGE(s); + sPAPRPHBState *sphb =3D SPAPR_PCI_HOST_BRIDGE(phb); + sPAPRTCETable *tcet; + int i; + const unsigned windows_supported =3D + sphb->ddw_enabled ? SPAPR_PCI_DMA_MAX_WINDOWS : 1; + + g_hash_table_unref(sphb->msi); + + /* remove IO/MMIO subregions and aliases, rest should get cleaned + * via PHB's unrealize->object_finalize + */ + for (i =3D windows_supported - 1; i >=3D 0; i--) { + tcet =3D spapr_tce_find_by_liobn(sphb->dma_liobn[i]); + g_assert(tcet); + memory_region_del_subregion(&sphb->iommu_root, + spapr_tce_get_iommu(tcet)); + } + + QLIST_REMOVE(sphb, list); + + memory_region_del_subregion(&sphb->iommu_root, &sphb->msiwindow); + + address_space_destroy(&sphb->iommu_as); + + qbus_set_hotplug_handler(BUS(phb->bus), NULL, &error_abort); + pci_unregister_bus(phb->bus); + + memory_region_del_subregion(get_system_memory(), &sphb->iowindow); + memory_region_del_subregion(get_system_memory(), &sphb->mem64window); + memory_region_del_subregion(get_system_memory(), &sphb->mem32window); +} + static void spapr_phb_realize(DeviceState *dev, Error **errp) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); @@ -1961,6 +2005,7 @@ static void spapr_phb_class_init(ObjectClass *klass, = void *data) =20 hc->root_bus_path =3D spapr_phb_root_bus_path; dc->realize =3D spapr_phb_realize; + dc->unrealize =3D spapr_phb_unrealize; dc->props =3D spapr_phb_properties; dc->reset =3D spapr_phb_reset; dc->vmsd =3D &vmstate_spapr_pci; @@ -1975,6 +2020,7 @@ static const TypeInfo spapr_phb_info =3D { .name =3D TYPE_SPAPR_PCI_HOST_BRIDGE, .parent =3D TYPE_PCI_HOST_BRIDGE, .instance_size =3D sizeof(sPAPRPHBState), + .instance_finalize =3D spapr_phb_finalizefn, .class_init =3D spapr_phb_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_HOTPLUG_HANDLER }, From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006105591567.2020294508621; Tue, 25 Jul 2017 11:08:25 -0700 (PDT) Received: from localhost ([::1]:33923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Fq-0000CG-4F for importer@patchew.org; Tue, 25 Jul 2017 14:08:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da497-00030C-Qg for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da494-0002ZB-1S for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:25 -0400 Received: from 9.mo5.mail-out.ovh.net ([178.32.96.204]:36845) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da493-0002Wu-S0 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:21 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 77AC8116653 for ; Tue, 25 Jul 2017 20:01:20 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 13B3F20078; Tue, 25 Jul 2017 20:01:13 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:01:12 +0200 Message-ID: <150100567284.27487.16381745122889215367.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9759300394038761945 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.96.204 Subject: [Qemu-devel] [for-2.11 PATCH 15/26] spapr: add pseries-2.11 machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 22 ++++++++++++++++++++-- include/hw/compat.h | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 53969315ac24..277daa4f9645 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3533,18 +3533,36 @@ static const TypeInfo spapr_machine_info =3D { type_init(spapr_machine_register_##suffix) =20 /* + * pseries-2.11 + */ +static void spapr_machine_2_11_instance_options(MachineState *machine) +{ +} + +static void spapr_machine_2_11_class_options(MachineClass *mc) +{ + /* Defaults for the latest behaviour inherited from the base class */ +} + +DEFINE_SPAPR_MACHINE(2_11, "2.11", true); + +/* * pseries-2.10 */ +#define SPAPR_COMPAT_2_10 \ + HW_COMPAT_2_10 \ + static void spapr_machine_2_10_instance_options(MachineState *machine) { } =20 static void spapr_machine_2_10_class_options(MachineClass *mc) { - /* Defaults for the latest behaviour inherited from the base class */ + spapr_machine_2_11_class_options(mc); + SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_10); } =20 -DEFINE_SPAPR_MACHINE(2_10, "2.10", true); +DEFINE_SPAPR_MACHINE(2_10, "2.10", false); =20 /* * pseries-2.9 diff --git a/include/hw/compat.h b/include/hw/compat.h index 08f36004dad7..3e101f8f6783 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -1,6 +1,9 @@ #ifndef HW_COMPAT_H #define HW_COMPAT_H =20 +#define HW_COMPAT_2_10 \ + /* empty */ + #define HW_COMPAT_2_9 \ {\ .driver =3D "pci-bridge",\ From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006276836918.0955136224799; Tue, 25 Jul 2017 11:11:16 -0700 (PDT) Received: from localhost ([::1]:33939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Ia-0002nU-Bn for importer@patchew.org; Tue, 25 Jul 2017 14:11:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da49J-00039e-Q3 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da49G-0002lJ-NF for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:37 -0400 Received: from 11.mo5.mail-out.ovh.net ([46.105.47.167]:54552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da49G-0002jz-GE for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:34 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 2727A1165D3 for ; Tue, 25 Jul 2017 20:01:33 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id B6CDE20078; Tue, 25 Jul 2017 20:01:25 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:01:25 +0200 Message-ID: <150100568549.27487.11903027800624299907.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9762959567368198617 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.47.167 Subject: [Qemu-devel] [for-2.11 PATCH 16/26] spapr: enable PHB hotplug for pseries-2.11 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth The 'dr_phb_enabled' field of that class can be set as part of machine-specific init code, and is then propagated to sPAPREnvironment to conditionally enable creation of DRC objects and device-tree description to facilitate hotplug of PHBs. Since we can't migrate this state to older machine types, default the option to true and disable it for older machine types. Signed-off-by: Michael Roth Signed-off-by: Greg Kurz --- Changes since RFC: - rebased against ppc-for-2.10 - updated changelog and title - set default to true and disable for 2.10 and older --- hw/ppc/spapr.c | 6 ++++++ include/hw/ppc/spapr.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 277daa4f9645..8dc505343c0f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2382,6 +2382,8 @@ static void ppc_spapr_init(MachineState *machine) /* We always have at least the nvram device on VIO */ spapr_create_nvram(spapr); =20 + spapr->dr_phb_enabled =3D smc->dr_phb_enabled; + /* Set up PCI */ spapr_pci_rtas_init(); =20 @@ -3482,6 +3484,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) * in which LMBs are represented and hot-added */ mc->numa_mem_align_shift =3D 28; + smc->dr_phb_enabled =3D true; } =20 static const TypeInfo spapr_machine_info =3D { @@ -3558,8 +3561,11 @@ static void spapr_machine_2_10_instance_options(Mach= ineState *machine) =20 static void spapr_machine_2_10_class_options(MachineClass *mc) { + sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + spapr_machine_2_11_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_10); + smc->dr_phb_enabled =3D false; } =20 DEFINE_SPAPR_MACHINE(2_10, "2.10", false); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 2a303a705c17..8004d9c2ab2c 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -59,6 +59,7 @@ struct sPAPRMachineClass { =20 /*< public >*/ bool dr_lmb_enabled; /* enable dynamic-reconfig/hotplug of LMBs = */ + bool dr_phb_enabled; /* enable dynamic-reconfig/hotplug of PHBs = */ bool use_ohci_by_default; /* use USB-OHCI instead of XHCI */ const char *tcg_default_cpu; /* which (TCG) CPU to simulate by default= */ bool pre_2_10_has_unused_icps; @@ -122,6 +123,8 @@ struct sPAPRMachineState { * occurs during the unplug process. */ QTAILQ_HEAD(, sPAPRDIMMState) pending_dimm_unplugs; =20 + bool dr_phb_enabled; /* hotplug / dynamic-reconfiguration of PHBs */ + /*< public >*/ char *kvm_type; MemoryHotplugState hotplug_memory; From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006095871222.76391973666648; Tue, 25 Jul 2017 11:08:15 -0700 (PDT) Received: from localhost ([::1]:33921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Fg-0008VO-5Z for importer@patchew.org; Tue, 25 Jul 2017 14:08:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da49W-0003LO-K4 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da49T-00030C-J0 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:50 -0400 Received: from 18.mo5.mail-out.ovh.net ([178.33.45.10]:57772) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da49T-0002yS-C4 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:01:47 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id C7DB611658C for ; Tue, 25 Jul 2017 20:01:45 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 658772007C; Tue, 25 Jul 2017 20:01:38 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:01:38 +0200 Message-ID: <150100569817.27487.947951250042841104.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9766337269616384473 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.45.10 Subject: [Qemu-devel] [for-2.11 PATCH 17/26] spapr_pci: introduce drc_id property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 With the addition of PHB hotplug, we have a static number of DRCs that can be used to handle hotplug/unplug operations on our PHBs, and need a consistent way to map PHBs to these connectors, and assign a unique identifiers for the connectors. This patch adds a drc_id property for that purpose. Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 1 + include/hw/pci-host/spapr.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 994d2f36105f..54533d8a3841 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1878,6 +1878,7 @@ static Property spapr_phb_properties[] =3D { pre_2_8_migration, false), DEFINE_PROP_BOOL("pcie-extended-configuration-space", sPAPRPHBState, pcie_ecs, true), + DEFINE_PROP_UINT32("drc_id", sPAPRPHBState, drc_id, -1), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 5a4e9686d562..31bae68167f2 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -82,6 +82,8 @@ struct sPAPRPHBState { =20 bool pcie_ecs; /* Allow access to PCIe extended config space? */ =20 + uint32_t drc_id; + /* Fields for migration compatibility hacks */ bool pre_2_8_migration; uint32_t mig_liobn; From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006249244652.0737251250509; Tue, 25 Jul 2017 11:10:49 -0700 (PDT) Received: from localhost ([::1]:33937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4I8-0002LL-7O for importer@patchew.org; Tue, 25 Jul 2017 14:10:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da49j-0003WV-6u for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da49g-0003Fc-52 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:03 -0400 Received: from 13.mo5.mail-out.ovh.net ([87.98.182.191]:56356) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da49f-0003Dx-VJ for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:00 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 7BA6E11667B for ; Tue, 25 Jul 2017 20:01:58 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 11DB82007C; Tue, 25 Jul 2017 20:01:51 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:01:50 +0200 Message-ID: <150100571083.27487.4628655387393519076.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9769996443313412569 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.182.191 Subject: [Qemu-devel] [for-2.11 PATCH 18/26] spapr: create DR connectors for PHBs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth Signed-off-by: Michael Roth Reviewed-by: David Gibson Signed-off-by: Greg Kurz --- Changes since RFC: - rebased against ppc-for-2.10 (reset hooks registering already merged) - added new DRC type for PHB --- hw/ppc/spapr.c | 15 +++++++++++++++ hw/ppc/spapr_drc.c | 17 +++++++++++++++++ include/hw/ppc/spapr_drc.h | 8 ++++++++ 3 files changed, 40 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 8dc505343c0f..5950c009ab7e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -98,6 +98,9 @@ =20 #define PHANDLE_XICP 0x00001111 =20 +/* maximum number of hotpluggable PHBs */ +#define SPAPR_DRC_MAX_PHB 256 + static ICSState *spapr_ics_create(sPAPRMachineState *spapr, const char *type_ics, int nr_irqs, Error **errp) @@ -2384,6 +2387,18 @@ static void ppc_spapr_init(MachineState *machine) =20 spapr->dr_phb_enabled =3D smc->dr_phb_enabled; =20 + /* Setup hotplug / dynamic-reconfiguration connectors. top-level + * connectors (described in root DT node's "ibm,drc-types" property) + * are pre-initialized here. additional child connectors (such as + * connectors for a PHBs PCI slots) are added as needed during their + * parent's realization. + */ + if (spapr->dr_phb_enabled) { + for (i =3D 0; i < SPAPR_DRC_MAX_PHB; i++) { + spapr_dr_connector_new(OBJECT(machine), TYPE_SPAPR_DRC_PHB, i); + } + } + /* Set up PCI */ spapr_pci_rtas_init(); =20 diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index eb8024d37c54..2e1049ce61c7 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -697,6 +697,15 @@ static void spapr_drc_lmb_class_init(ObjectClass *k, v= oid *data) drck->release =3D spapr_lmb_release; } =20 +static void spapr_drc_phb_class_init(ObjectClass *k, void *data) +{ + sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_CLASS(k); + + drck->typeshift =3D SPAPR_DR_CONNECTOR_TYPE_SHIFT_PHB; + drck->typename =3D "PHB"; + drck->drc_name_prefix =3D "PHB "; +} + static const TypeInfo spapr_dr_connector_info =3D { .name =3D TYPE_SPAPR_DR_CONNECTOR, .parent =3D TYPE_DEVICE, @@ -740,6 +749,13 @@ static const TypeInfo spapr_drc_lmb_info =3D { .class_init =3D spapr_drc_lmb_class_init, }; =20 +static const TypeInfo spapr_drc_phb_info =3D { + .name =3D TYPE_SPAPR_DRC_PHB, + .parent =3D TYPE_SPAPR_DRC_LOGICAL, + .instance_size =3D sizeof(sPAPRDRConnector), + .class_init =3D spapr_drc_phb_class_init, +}; + /* helper functions for external users */ =20 sPAPRDRConnector *spapr_drc_by_index(uint32_t index) @@ -1179,6 +1195,7 @@ static void spapr_drc_register_types(void) type_register_static(&spapr_drc_cpu_info); type_register_static(&spapr_drc_pci_info); type_register_static(&spapr_drc_lmb_info); + type_register_static(&spapr_drc_phb_info); =20 spapr_rtas_register(RTAS_SET_INDICATOR, "set-indicator", rtas_set_indicator); diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index a7958d0a8d14..535fc61b98a8 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -69,6 +69,14 @@ #define SPAPR_DRC_LMB(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ TYPE_SPAPR_DRC_LMB) =20 +#define TYPE_SPAPR_DRC_PHB "spapr-drc-phb" +#define SPAPR_DRC_PHB_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_PHB) +#define SPAPR_DRC_PHB_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, TYPE_SPAPR_DRC_PH= B) +#define SPAPR_DRC_PHB(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_PHB) + /* * Various hotplug types managed by sPAPRDRConnector * From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006917968476.0193928346779; Tue, 25 Jul 2017 11:21:57 -0700 (PDT) Received: from localhost ([::1]:34065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Sx-0003Xc-C3 for importer@patchew.org; Tue, 25 Jul 2017 14:21:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da49w-0003fo-BR for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da49t-0003VD-AR for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:16 -0400 Received: from 6.mo5.mail-out.ovh.net ([178.32.119.138]:37905) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da49t-0003Tz-4C for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:13 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 282D211348C for ; Tue, 25 Jul 2017 20:02:11 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id B70822007E; Tue, 25 Jul 2017 20:02:03 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:02:03 +0200 Message-ID: <150100572350.27487.14857589060586322098.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9773655619764591065 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.119.138 Subject: [Qemu-devel] [for-2.11 PATCH 19/26] spapr: populate PHB DRC entries for root DT node X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Nathan Fontenot This add entries to the root OF node to advertise our PHBs as being DR-capable in accordance with PAPR specification. Signed-off-by: Nathan Fontenot Signed-off-by: Michael Roth Reviewed-by: David Gibson Signed-off-by: Greg Kurz --- Changes since RFC: - rebased against ppc-for-2.10 - use error_report --- hw/ppc/spapr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 5950c009ab7e..632040f35ecc 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1151,6 +1151,16 @@ static void *spapr_build_fdt(sPAPRMachineState *spap= r, exit(1); } =20 + if (smc->dr_phb_enabled) { + int offset =3D fdt_path_offset(fdt, "/"); + ret =3D spapr_drc_populate_dt(fdt, offset, NULL, + SPAPR_DR_CONNECTOR_TYPE_PHB); + if (ret < 0) { + error_report("Couldn't set up PHB DR device tree properties"); + exit(1); + } + } + return fdt; } =20 From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006426411430.6234551086194; Tue, 25 Jul 2017 11:13:46 -0700 (PDT) Received: from localhost ([::1]:33966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4L1-0004vq-MD for importer@patchew.org; Tue, 25 Jul 2017 14:13:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4A8-0003pw-BK for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da4A5-0003kl-89 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:28 -0400 Received: from 3.mo5.mail-out.ovh.net ([46.105.40.108]:51824) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da4A5-0003jm-1y for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:25 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id C844F11348C for ; Tue, 25 Jul 2017 20:02:23 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 67BA720078; Tue, 25 Jul 2017 20:02:16 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:02:16 +0200 Message-ID: <150100573617.27487.6315231818700234374.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9777033316338211289 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.40.108 Subject: [Qemu-devel] [for-2.11 PATCH 20/26] spapr_events: add support for phb hotplug events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth Extend the existing EPOW event format we use for PCI devices to emit PHB plug/unplug events. Signed-off-by: Michael Roth Reviewed-by: David Gibson Signed-off-by: Greg Kurz --- Changes since RFC: - rebased against ppc-for-2.10 --- hw/ppc/spapr_events.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index f952b78237e1..24ea43d2b951 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -531,6 +531,9 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint= 8_t hp_action, case SPAPR_DR_CONNECTOR_TYPE_CPU: hp->hotplug_type =3D RTAS_LOG_V6_HP_TYPE_CPU; break; + case SPAPR_DR_CONNECTOR_TYPE_PHB: + hp->hotplug_type =3D RTAS_LOG_V6_HP_TYPE_PHB; + break; default: /* we shouldn't be signaling hotplug events for resources * that don't support them From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006431398650.2948130457796; Tue, 25 Jul 2017 11:13:51 -0700 (PDT) Received: from localhost ([::1]:33967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4L6-00050v-MN for importer@patchew.org; Tue, 25 Jul 2017 14:13:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4AM-000471-TC for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da4AI-00047q-88 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:42 -0400 Received: from 11.mo5.mail-out.ovh.net ([46.105.47.167]:46073) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da4AH-00045q-Rc for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:38 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 86DE6113EF1 for ; Tue, 25 Jul 2017 20:02:36 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 1417F20078; Tue, 25 Jul 2017 20:02:29 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:02:28 +0200 Message-ID: <150100574883.27487.14886260798861983416.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9780692492070525401 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.47.167 Subject: [Qemu-devel] [for-2.11 PATCH 21/26] qdev: pass an Object * to qbus_set_hotplug_handler() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth Certain devices types, like memory/CPU, are now being handled using a hotplug interface provided by a top-level MachineClass. Hotpluggable host bridges are another such device where it makes sense to use a machine-level hotplug handler. However, unlike those devices, host-bridges have a parent bus (the main system bus), and devices with a parent bus use a different mechanism for registering their hotplug handlers: qbus_set_hotplug_handler(). This interface currently expects a handler to be a subclass of DeviceClass, but this is not the case for MachineClass, which derives directly from ObjectClass. Internally, the interface only requires an ObjectClass, so expose that in qbus_set_hotplug_handler(). Cc: Michael S. Tsirkin Cc: Eduardo Habkost Signed-off-by: Michael Roth Signed-off-by: Greg Kurz Reviewed-by: David Gibson --- Changes since RFC: - rebased against ppc-for-2.10 - changed qbus_set_hotplug_handler() declaration and dropped qbus_set_hotplug_handler_internal() (Paolo) - updated title and changelog accordingly --- hw/acpi/piix4.c | 2 +- hw/char/virtio-serial-bus.c | 2 +- hw/core/bus.c | 11 ++--------- hw/pci/pcie.c | 2 +- hw/pci/shpc.c | 2 +- hw/ppc/spapr_pci.c | 2 +- hw/s390x/css-bridge.c | 2 +- hw/s390x/s390-pci-bus.c | 6 +++--- hw/scsi/virtio-scsi.c | 2 +- hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/dev-smartcard-reader.c | 2 +- include/hw/qdev-core.h | 3 +-- 12 files changed, 15 insertions(+), 23 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index f276967365c4..f99c7438235e 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -447,7 +447,7 @@ static void piix4_update_bus_hotplug(PCIBus *pci_bus, v= oid *opaque) =20 /* pci_bus cannot outlive PIIX4PMState, because /machine keeps it alive * and it's not hot-unpluggable */ - qbus_set_hotplug_handler(BUS(pci_bus), DEVICE(s), &error_abort); + qbus_set_hotplug_handler(BUS(pci_bus), OBJECT(s), &error_abort); } =20 static void piix4_pm_machine_ready(Notifier *n, void *opaque) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index f5bc173844e4..4880236f4258 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1042,7 +1042,7 @@ static void virtio_serial_device_realize(DeviceState = *dev, Error **errp) /* Spawn a new virtio-serial bus on which the ports will ride as devic= es */ qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_= BUS, dev, vdev->bus_name); - qbus_set_hotplug_handler(BUS(&vser->bus), DEVICE(vser), errp); + qbus_set_hotplug_handler(BUS(&vser->bus), OBJECT(vser), errp); vser->bus.vser =3D vser; QTAILQ_INIT(&vser->ports); =20 diff --git a/hw/core/bus.c b/hw/core/bus.c index 4651f244864c..e09843f6abea 100644 --- a/hw/core/bus.c +++ b/hw/core/bus.c @@ -22,22 +22,15 @@ #include "hw/qdev.h" #include "qapi/error.h" =20 -static void qbus_set_hotplug_handler_internal(BusState *bus, Object *handl= er, - Error **errp) +void qbus_set_hotplug_handler(BusState *bus, Object *handler, Error **errp) { - object_property_set_link(OBJECT(bus), OBJECT(handler), QDEV_HOTPLUG_HANDLER_PROPERTY, errp); } =20 -void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, Error *= *errp) -{ - qbus_set_hotplug_handler_internal(bus, OBJECT(handler), errp); -} - void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp) { - qbus_set_hotplug_handler_internal(bus, OBJECT(bus), errp); + qbus_set_hotplug_handler(bus, OBJECT(bus), errp); } =20 int qbus_walk_children(BusState *bus, diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 32191f2a55f7..52d9ff947f7c 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -443,7 +443,7 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot) dev->exp.hpev_notified =3D false; =20 qbus_set_hotplug_handler(BUS(pci_bridge_get_sec_bus(PCI_BRIDGE(dev))), - DEVICE(dev), NULL); + OBJECT(dev), NULL); } =20 void pcie_cap_slot_reset(PCIDevice *dev) diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 69fc14b218d8..feed8a45e535 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -648,7 +648,7 @@ int shpc_init(PCIDevice *d, PCIBus *sec_bus, MemoryRegi= on *bar, shpc_cap_update_dword(d); memory_region_add_subregion(bar, offset, &shpc->mmio); =20 - qbus_set_hotplug_handler(BUS(sec_bus), DEVICE(d), NULL); + qbus_set_hotplug_handler(BUS(sec_bus), OBJECT(d), NULL); =20 d->cap_present |=3D QEMU_PCI_CAP_SHPC; return 0; diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 54533d8a3841..b73e099e0285 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1714,7 +1714,7 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) &sphb->memspace, &sphb->iospace, PCI_DEVFN(0, 0), PCI_NUM_PINS, TYPE_PCI_BUS); phb->bus =3D bus; - qbus_set_hotplug_handler(BUS(phb->bus), DEVICE(sphb), NULL); + qbus_set_hotplug_handler(BUS(phb->bus), OBJECT(sphb), NULL); =20 /* * Initialize PHB address space. diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c index c4a9735d7108..19eda77979d1 100644 --- a/hw/s390x/css-bridge.c +++ b/hw/s390x/css-bridge.c @@ -107,7 +107,7 @@ VirtualCssBus *virtual_css_bus_init(void) cbus->squash_mcss =3D s390_get_squash_mcss(); =20 /* Enable hotplugging */ - qbus_set_hotplug_handler(bus, dev, &error_abort); + qbus_set_hotplug_handler(bus, OBJECT(dev), &error_abort); =20 css_register_io_adapters(CSS_IO_ADAPTER_VIRTIO, true, false, 0, &error_abort); diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 61cfd2138f68..503b7ae05abb 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -566,11 +566,11 @@ static int s390_pcihost_init(SysBusDevice *dev) pci_setup_iommu(b, s390_pci_dma_iommu, s); =20 bus =3D BUS(b); - qbus_set_hotplug_handler(bus, DEVICE(dev), NULL); + qbus_set_hotplug_handler(bus, OBJECT(dev), NULL); phb->bus =3D b; =20 s->bus =3D S390_PCI_BUS(qbus_create(TYPE_S390_PCI_BUS, DEVICE(s), NULL= )); - qbus_set_hotplug_handler(BUS(s->bus), DEVICE(s), NULL); + qbus_set_hotplug_handler(BUS(s->bus), OBJECT(s), NULL); =20 s->iommu_table =3D g_hash_table_new_full(g_int64_hash, g_int64_equal, NULL, g_free); @@ -678,7 +678,7 @@ static void s390_pcihost_hot_plug(HotplugHandler *hotpl= ug_dev, pci_setup_iommu(&pb->sec_bus, s390_pci_dma_iommu, s); =20 bus =3D BUS(&pb->sec_bus); - qbus_set_hotplug_handler(bus, DEVICE(s), errp); + qbus_set_hotplug_handler(bus, OBJECT(s), errp); =20 if (dev->hotplugged) { pci_default_write_config(pdev, PCI_PRIMARY_BUS, s->bus_no, 1); diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index eb639442d192..b4c26d4862b5 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -893,7 +893,7 @@ static void virtio_scsi_device_realize(DeviceState *dev= , Error **errp) scsi_bus_new(&s->bus, sizeof(s->bus), dev, &virtio_scsi_scsi_info, vdev->bus_name); /* override default SCSI bus hotplug-handler, with virtio-scsi's one */ - qbus_set_hotplug_handler(BUS(&s->bus), dev, &error_abort); + qbus_set_hotplug_handler(BUS(&s->bus), OBJECT(dev), &error_abort); =20 virtio_scsi_dataplane_setup(s, errp); } diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index 4a106da85646..036e44caca42 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -1146,7 +1146,7 @@ pvscsi_init(PCIDevice *pci_dev) scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(pci_dev), &pvscsi_scsi_info, NULL); /* override default SCSI bus hotplug-handler, with pvscsi's one */ - qbus_set_hotplug_handler(BUS(&s->bus), DEVICE(s), &error_abort); + qbus_set_hotplug_handler(BUS(&s->bus), OBJECT(s), &error_abort); pvscsi_reset_state(s); =20 return 0; diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index bef1f03c426b..f2a86de6c556 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -1337,7 +1337,7 @@ static void ccid_realize(USBDevice *dev, Error **errp) usb_desc_init(dev); qbus_create_inplace(&s->bus, sizeof(s->bus), TYPE_CCID_BUS, DEVICE(dev= ), NULL); - qbus_set_hotplug_handler(BUS(&s->bus), DEVICE(dev), &error_abort); + qbus_set_hotplug_handler(BUS(&s->bus), OBJECT(dev), &error_abort); s->intr =3D usb_ep_get(dev, USB_TOKEN_IN, CCID_INT_IN_EP); s->bulk =3D usb_ep_get(dev, USB_TOKEN_IN, CCID_BULK_IN_EP); s->card =3D NULL; diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 9237b6849ff3..ce01ff42850b 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -397,8 +397,7 @@ char *qdev_get_dev_path(DeviceState *dev); =20 GSList *qdev_build_hotpluggable_device_list(Object *peripheral); =20 -void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, - Error **errp); +void qbus_set_hotplug_handler(BusState *bus, Object *handler, Error **errp= ); =20 void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp); =20 From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006643241630.1543682070243; Tue, 25 Jul 2017 11:17:23 -0700 (PDT) Received: from localhost ([::1]:34012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4OU-0008E0-Kv for importer@patchew.org; Tue, 25 Jul 2017 14:17:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4AY-0004Ju-0S for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da4AU-0004KZ-UM for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:54 -0400 Received: from 17.mo5.mail-out.ovh.net ([46.105.56.132]:49771) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da4AU-0004JJ-NU for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:02:50 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 3A620114B8D for ; Tue, 25 Jul 2017 20:02:49 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id C735E20078; Tue, 25 Jul 2017 20:02:41 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:02:41 +0200 Message-ID: <150100576156.27487.15628232978800114846.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9784351666272180697 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.56.132 Subject: [Qemu-devel] [for-2.11 PATCH 22/26] spapr_pci: provide node start offset via spapr_populate_pci_dt() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth PHB hotplug re-uses PHB device tree generation code and passes it to a guest via RTAS. Doing this requires knowledge of where exactly in the device tree the node describing the PHB begins. Provide this via a new optional pointer that can be used to store the PHB node's start offset. Signed-off-by: Michael Roth Reviewed-by: David Gibson Signed-off-by: Greg Kurz --- Changes since RFC: - rebased against ppc-for-2.10 --- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_pci.c | 6 +++++- include/hw/pci-host/spapr.h | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 632040f35ecc..1a6cd4efeb97 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1098,7 +1098,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, } =20 QLIST_FOREACH(phb, &spapr->phbs, list) { - ret =3D spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt); + ret =3D spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt, NULL); if (ret < 0) { error_report("couldn't setup PCI devices in fdt"); exit(1); diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index b73e099e0285..79f10ff453d0 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2109,7 +2109,8 @@ static void spapr_phb_pci_enumerate(sPAPRPHBState *ph= b) =20 int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t xics_phandle, - void *fdt) + void *fdt, + int *node_offset) { int bus_off, i, j, ret; char nodename[FDT_NAME_MAX]; @@ -2166,6 +2167,9 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, if (bus_off < 0) { return bus_off; } + if (node_offset) { + *node_offset =3D bus_off; + } =20 /* Write PHB properties */ _FDT(fdt_setprop_string(fdt, bus_off, "device_type", "pci")); diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 31bae68167f2..7837fb0b1110 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -115,7 +115,8 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRP= HBState *phb, int pin) =20 int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t xics_phandle, - void *fdt); + void *fdt, + int *node_offset); =20 void spapr_pci_rtas_init(void); =20 From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501007092873319.17599650980833; Tue, 25 Jul 2017 11:24:52 -0700 (PDT) Received: from localhost ([::1]:34101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Vm-0005pL-61 for importer@patchew.org; Tue, 25 Jul 2017 14:24:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Ak-0004W6-F5 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:03:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da4Ah-0004VM-Cj for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:03:06 -0400 Received: from 2.mo5.mail-out.ovh.net ([178.33.109.111]:60606) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da4Ah-0004U1-6c for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:03:03 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id DEC171151B3 for ; Tue, 25 Jul 2017 20:03:01 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 78F1020078; Tue, 25 Jul 2017 20:02:54 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:02:54 +0200 Message-ID: <150100577425.27487.12203768480364790462.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9787729366907328985 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.109.111 Subject: [Qemu-devel] [for-2.11 PATCH 23/26] spapr_pci: add ibm, my-drc-index property for PHB hotplug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Michael Roth This is needed to denote a boot-time PHB as being hot-pluggable. Signed-off-by: Michael Roth Reviewed-by: David Gibson Signed-off-by: Greg Kurz --- Changes since RFC: - rebased against ppc-for-2.10 - use phb->drc_id --- hw/ppc/spapr_pci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 79f10ff453d0..58406a1b7e93 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2160,6 +2160,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, sPAPRTCETable *tcet; PCIBus *bus =3D PCI_HOST_BRIDGE(phb)->bus; sPAPRFDT s_fdt; + sPAPRDRConnector *drc; =20 /* Start populating the FDT */ snprintf(nodename, FDT_NAME_MAX, "pci@%" PRIx64, phb->buid); @@ -2229,6 +2230,14 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, tcet->liobn, tcet->bus_offset, tcet->nb_table << tcet->page_shift); =20 + drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_PHB, phb->drc_id); + if (drc) { + uint32_t drc_index =3D cpu_to_be32(spapr_drc_index(drc)); + + _FDT(fdt_setprop(fdt, bus_off, "ibm,my-drc-index", &drc_index, + sizeof(drc_index))); + } + /* Walk the bridges and program the bus numbers*/ spapr_phb_pci_enumerate(phb); _FDT(fdt_setprop_cell(fdt, bus_off, "qemu,phb-enumerated", 0x1)); From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501006841064564.7469745873761; Tue, 25 Jul 2017 11:20:41 -0700 (PDT) Received: from localhost ([::1]:34055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Rg-0002Y4-6g for importer@patchew.org; Tue, 25 Jul 2017 14:20:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Az-0004jT-LS for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:03:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da4Aw-0004fE-Gi for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:03:21 -0400 Received: from 4.mo5.mail-out.ovh.net ([178.33.111.247]:47838) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da4Aw-0004eQ-5h for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:03:18 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 19DB411665C for ; Tue, 25 Jul 2017 20:03:17 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 276AB20078; Tue, 25 Jul 2017 20:03:07 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:03:06 +0200 Message-ID: <150100578691.27487.8944448515009831240.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9791951492121467353 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.111.247 Subject: [Qemu-devel] [for-2.11 PATCH 24/26] spapr: allow guest to update the XICS phandle X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The "phandle" property of the XICS node is referenced by the "interrupt-map" property of each PHB node. This is used by the guest OS to setup IRQs for all PCI devices. QEMU uses an arbitrary value (0x1111) for this phandle, but SLOF converts this value to a SLOF specific one, which is then presented to the guest OS. This patches introduces the new KVMPPC_H_UPDATE_PHANDLE hcall, which is used by SLOF to communicate the patched phandle value back to QEMU. This value is then cached and preserved accross migration until machine reset. This is required to be able to support PHB hotplug. Note, that SLOF already has some code to call KVMPPC_H_RTAS_UPDATE, so we have to introduce its number even if QEMU currently doesn't implement it. Suggested-by: Thomas Huth Signed-off-by: Greg Kurz Reviewed-by: Alexey Kardashevskiy --- hw/ppc/spapr.c | 25 +++++++++++++++++++++++-- hw/ppc/spapr_hcall.c | 20 ++++++++++++++++++++ include/hw/ppc/spapr.h | 11 ++++++++++- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 1a6cd4efeb97..90485054c2e7 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -96,8 +96,6 @@ =20 #define MIN_RMA_SLOF 128UL =20 -#define PHANDLE_XICP 0x00001111 - /* maximum number of hotpluggable PHBs */ #define SPAPR_DRC_MAX_PHB 256 =20 @@ -1454,6 +1452,7 @@ static void ppc_spapr_reset(void) first_ppc_cpu->env.nip =3D SPAPR_ENTRY_POINT; =20 spapr->cas_reboot =3D false; + spapr->xics_phandle =3D UINT32_MAX; } =20 static void spapr_create_nvram(sPAPRMachineState *spapr) @@ -1652,6 +1651,26 @@ static const VMStateDescription vmstate_spapr_patb_e= ntry =3D { }, }; =20 +static bool spapr_xics_phandle_needed(void *opaque) +{ + sPAPRMachineState *spapr =3D opaque; + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(MACHINE(spapr)); + + /* Don't break older machine types that don't support PHB hotplug. */ + return smc->dr_phb_enabled && spapr->xics_phandle !=3D UINT32_MAX; +} + +static const VMStateDescription vmstate_spapr_xics_phandle =3D { + .name =3D "spapr_xics_phandle", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D spapr_xics_phandle_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(xics_phandle, sPAPRMachineState), + VMSTATE_END_OF_LIST() + }, +}; + static const VMStateDescription vmstate_spapr =3D { .name =3D "spapr", .version_id =3D 3, @@ -1671,6 +1690,7 @@ static const VMStateDescription vmstate_spapr =3D { &vmstate_spapr_ov5_cas, &vmstate_spapr_patb_entry, &vmstate_spapr_pending_events, + &vmstate_spapr_xics_phandle, NULL } }; @@ -2702,6 +2722,7 @@ static void spapr_machine_initfn(Object *obj) =20 spapr->htab_fd =3D -1; spapr->use_hotplug_event_source =3D true; + spapr->xics_phandle =3D UINT32_MAX; object_property_add_str(obj, "kvm-type", spapr_get_kvm_type, spapr_set_kvm_type, NULL); object_property_set_description(obj, "kvm-type", diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 72ea5a8247bf..ce8a9eb66b23 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1623,6 +1623,25 @@ static target_ulong h_client_architecture_support(Po= werPCCPU *cpu, return H_SUCCESS; } =20 +static target_ulong h_update_phandle(PowerPCCPU *cpu, sPAPRMachineState *s= papr, + target_ulong opcode, target_ulong *ar= gs) +{ + target_ulong old_phandle =3D args[0]; + target_ulong new_phandle =3D args[1]; + + if (new_phandle >=3D UINT32_MAX) { + return H_PARAMETER; + } + + /* We only have a "phandle" property in the XICS node at the moment. */ + if (old_phandle !=3D (uint32_t) PHANDLE_XICP) { + return H_PARAMETER; + } + + spapr->xics_phandle =3D (uint32_t) new_phandle; + return H_SUCCESS; +} + static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) + 1]; static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - KVMPPC_HCA= LL_BASE + 1]; =20 @@ -1717,6 +1736,7 @@ static void hypercall_register_types(void) =20 /* qemu/KVM-PPC specific hcalls */ spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas); + spapr_register_hypercall(KVMPPC_H_UPDATE_PHANDLE, h_update_phandle); =20 /* ibm,client-architecture-support support */ spapr_register_hypercall(KVMPPC_H_CAS, h_client_architecture_support); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 8004d9c2ab2c..f09c54d5bb94 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -125,6 +125,8 @@ struct sPAPRMachineState { =20 bool dr_phb_enabled; /* hotplug / dynamic-reconfiguration of PHBs */ =20 + uint32_t xics_phandle; + /*< public >*/ char *kvm_type; MemoryHotplugState hotplug_memory; @@ -402,7 +404,9 @@ struct sPAPRMachineState { #define KVMPPC_H_LOGICAL_MEMOP (KVMPPC_HCALL_BASE + 0x1) /* Client Architecture support */ #define KVMPPC_H_CAS (KVMPPC_HCALL_BASE + 0x2) -#define KVMPPC_HCALL_MAX KVMPPC_H_CAS +#define KVMPPC_H_RTAS_UPDATE (KVMPPC_HCALL_BASE + 0x3) +#define KVMPPC_H_UPDATE_PHANDLE (KVMPPC_HCALL_BASE + 0x4) +#define KVMPPC_HCALL_MAX KVMPPC_H_UPDATE_PHANDLE =20 typedef struct sPAPRDeviceTreeUpdateHeader { uint32_t version_id; @@ -707,4 +711,9 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_= cpu_data arg); =20 #define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift)) =20 +/* Boot time value of the "phandle" property of the "interrupt-controller" + * node. + */ +#define PHANDLE_XICP 0x00001111 + #endif /* HW_SPAPR_H */ From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501007169092952.0625493289385; Tue, 25 Jul 2017 11:26:09 -0700 (PDT) Received: from localhost ([::1]:34110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4Wz-0006Xk-Lm for importer@patchew.org; Tue, 25 Jul 2017 14:26:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1da4BC-0004sy-3w for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:03:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1da4B9-0004pO-0g for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:03:34 -0400 Received: from 10.mo5.mail-out.ovh.net ([46.105.52.148]:40106) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1da4B8-0004oH-Qr for qemu-devel@nongnu.org; Tue, 25 Jul 2017 14:03:30 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 8B5E9116654 for ; Tue, 25 Jul 2017 20:03:29 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 2796A20078; Tue, 25 Jul 2017 20:03:22 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 25 Jul 2017 20:03:21 +0200 Message-ID: <150100580191.27487.17612552307249886496.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9795610668416539097 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheehgdduvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.52.148 Subject: [Qemu-devel] [for-2.11 PATCH 25/26] spapr_pci: drop abusive sanity check when migrating the LSI table X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The guest can allocate blocks of IRQs when calling the ibm,change-msi RTAS call. This has an impact on the IRQ numbers returned by subsequent calls to spapr_ics_alloc_block(). It doesn't cause any problem right now because PHB are cold plugged and the LSI table have the same numbers at the destination and the source. But this won't be the case anymore when we support PHB hotplug. In this case the IRQ numbers in the LSI table are state that we should migrate. This patch hence changes the destination to always accept the LSI table from the migration stream, like it is already done for MSIs. No effort is made to preserve the current behavior of failing migration when LSI numbers are different with older machine types, for simplicity. Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 58406a1b7e93..157867af8178 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1887,8 +1887,7 @@ static const VMStateDescription vmstate_spapr_pci_lsi= =3D { .version_id =3D 1, .minimum_version_id =3D 1, .fields =3D (VMStateField[]) { - VMSTATE_UINT32_EQUAL(irq, struct spapr_pci_lsi, NULL), - + VMSTATE_UINT32(irq, struct spapr_pci_lsi), VMSTATE_END_OF_LIST() }, }; From nobody Sat May 4 10:35:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501058477869963.2197910434068; Wed, 26 Jul 2017 01:41:17 -0700 (PDT) Received: from localhost ([::1]:36819 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daHsY-0001wv-7e for importer@patchew.org; Wed, 26 Jul 2017 04:41:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daHrg-0001eU-0C for qemu-devel@nongnu.org; Wed, 26 Jul 2017 04:40:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daHrc-0003CX-TZ for qemu-devel@nongnu.org; Wed, 26 Jul 2017 04:40:20 -0400 Received: from 17.mo5.mail-out.ovh.net ([46.105.56.132]:51202) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1daHrc-0003C5-Ix for qemu-devel@nongnu.org; Wed, 26 Jul 2017 04:40:16 -0400 Received: from player760.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id DCE90116ADD for ; Wed, 26 Jul 2017 10:40:14 +0200 (CEST) Received: from [192.168.0.243] (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player760.ha.ovh.net (Postfix) with ESMTPA id 5A7B920094; Wed, 26 Jul 2017 10:40:05 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Wed, 26 Jul 2017 10:40:04 +0200 Message-ID: <150105840463.12000.9666180368681199673.stgit@bahia> In-Reply-To: <150100547373.27487.3154210751350595400.stgit@bahia> References: <150100547373.27487.3154210751350595400.stgit@bahia> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 6155576267842886105 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelkedrheejgddtkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.56.132 Subject: [Qemu-devel] [for-2.11 PATCH 26/26] spapr: add hotplug hooks for PHB hotplug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Michael Roth , qemu-ppc@nongnu.org, Bharata B Rao , Paolo Bonzini , Daniel Henrique Barboza , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Hotplugging PHBs is a machine-level operation, but PHBs reside on the main system bus, so we register spapr machine as the handler for the main system bus. Signed-off-by: Michael Roth Signed-off-by: Greg Kurz --- - rebased against ppc-for-2.10 - converted to unplug_request - handle drc_id at pre-plug - reset hotplugged PHB at plug - compatibility with older machine types --- hw/ppc/spapr.c | 114 +++++++++++++++++++++++++++++++++++++++= ++++ hw/ppc/spapr_drc.c | 1=20 hw/ppc/spapr_pci.c | 2 - include/hw/pci-host/spapr.h | 2 + include/hw/ppc/spapr.h | 1=20 5 files changed, 118 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 90485054c2e7..589f76ef9fb8 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2540,6 +2540,10 @@ static void ppc_spapr_init(MachineState *machine) register_savevm_live(NULL, "spapr/htab", -1, 1, &savevm_htab_handlers, spapr); =20 + if (spapr->dr_phb_enabled) { + qbus_set_hotplug_handler(sysbus_get_default(), OBJECT(machine), NU= LL); + } + qemu_register_boot_set(spapr_boot_set, spapr); =20 if (kvm_enabled()) { @@ -3238,6 +3242,103 @@ out: error_propagate(errp, local_err); } =20 +static void spapr_phb_pre_plug(HotplugHandler *hotplug_dev, DeviceState *d= ev, + Error **errp) +{ + sPAPRPHBState *sphb =3D SPAPR_PCI_HOST_BRIDGE(dev); + + if (sphb->drc_id =3D=3D (uint32_t)-1) { + sphb->drc_id =3D sphb->index; + } + + if (sphb->drc_id >=3D SPAPR_DRC_MAX_PHB) { + error_setg(errp, "PHB id %d out of range", sphb->drc_id); + } +} + +static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); + sPAPRPHBState *sphb =3D SPAPR_PCI_HOST_BRIDGE(dev); + void *fdt =3D NULL; + int fdt_start_offset; + int fdt_size; + Error *local_err =3D NULL; + sPAPRDRConnector *drc; + uint32_t phandle; + int ret; + bool hotplugged =3D spapr_drc_hotplugged(dev); + + if (!spapr->dr_phb_enabled) { + return; + } + + drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_PHB, sphb->drc_id); + /* hotplug hooks should check it's enabled before getting this far */ + g_assert(drc); + + if (hotplugged) { + if (spapr->xics_phandle =3D=3D UINT32_MAX) { + error_setg(&local_err, + "SLOF didn't update the XICS phandle. PHB hotplug c= ancelled"); + goto out; + } + phandle =3D spapr->xics_phandle; + + spapr_phb_reset(dev); + } else { + phandle =3D PHANDLE_XICP; + } + + fdt =3D create_device_tree(&fdt_size); + ret =3D spapr_populate_pci_dt(sphb, phandle, fdt, &fdt_start_offset); + if (ret < 0) { + error_setg(&local_err, "unable to create FDT for %sPHB", + dev->hotplugged ? "hotplugged " : ""); + goto out; + } + + if (hotplugged) { + /* generally SLOF creates these, for hotplug it's up to QEMU */ + _FDT(fdt_setprop_string(fdt, fdt_start_offset, "name", "pci")); + } + + spapr_drc_attach(drc, DEVICE(dev), fdt, fdt_start_offset, &local_err); +out: + if (local_err) { + error_propagate(errp, local_err); + g_free(fdt); + return; + } + + if (hotplugged) { + spapr_hotplug_req_add_by_index(drc); + } else if (drc) { + spapr_drc_reset(drc); + } +} + +void spapr_phb_release(DeviceState *dev) +{ + object_unparent(OBJECT(dev)); +} + +static void spapr_phb_unplug_request(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + sPAPRPHBState *sphb =3D SPAPR_PCI_HOST_BRIDGE(dev); + sPAPRDRConnector *drc; + + drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_PHB, sphb->drc_id); + g_assert(drc); + + if (!spapr_drc_unplug_requested(drc)) { + spapr_drc_detach(drc); + spapr_hotplug_req_remove_by_index(drc); + } +} + static void spapr_machine_device_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -3284,6 +3385,8 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, spapr_memory_plug(hotplug_dev, dev, node, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { spapr_core_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE= )) { + spapr_phb_plug(hotplug_dev, dev, errp); } } =20 @@ -3311,6 +3414,12 @@ static void spapr_machine_device_unplug_request(Hotp= lugHandler *hotplug_dev, return; } spapr_core_unplug_request(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE= )) { + if (sms->dr_phb_enabled) { + spapr_phb_unplug_request(hotplug_dev, dev, errp); + } else { + error_setg(errp, "PHB hot unplug not supported on this machine= "); + } } } =20 @@ -3321,6 +3430,8 @@ static void spapr_machine_device_pre_plug(HotplugHand= ler *hotplug_dev, spapr_memory_pre_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { spapr_core_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE= )) { + spapr_phb_pre_plug(hotplug_dev, dev, errp); } } =20 @@ -3328,7 +3439,8 @@ static HotplugHandler *spapr_get_hotplug_handler(Mach= ineState *machine, DeviceState *dev) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || - object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { + object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE) || + object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE)) { return HOTPLUG_HANDLER(machine); } return NULL; diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 2e1049ce61c7..845fcf70b932 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -704,6 +704,7 @@ static void spapr_drc_phb_class_init(ObjectClass *k, vo= id *data) drck->typeshift =3D SPAPR_DR_CONNECTOR_TYPE_SHIFT_PHB; drck->typename =3D "PHB"; drck->drc_name_prefix =3D "PHB "; + drck->release =3D spapr_phb_release; } =20 static const TypeInfo spapr_dr_connector_info =3D { diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 157867af8178..c12f71ae3e2d 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1833,7 +1833,7 @@ void spapr_phb_dma_reset(sPAPRPHBState *sphb) sphb->dma_win_size >> SPAPR_TCE_PAGE_SHIFT); } =20 -static void spapr_phb_reset(DeviceState *qdev) +void spapr_phb_reset(DeviceState *qdev) { sPAPRPHBState *sphb =3D SPAPR_PCI_HOST_BRIDGE(qdev); =20 diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 7837fb0b1110..15799cee4280 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -120,6 +120,8 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, =20 void spapr_pci_rtas_init(void); =20 +void spapr_phb_reset(DeviceState *qdev); + sPAPRPHBState *spapr_pci_find_phb(sPAPRMachineState *spapr, uint64_t buid); PCIDevice *spapr_pci_find_dev(sPAPRMachineState *spapr, uint64_t buid, uint32_t config_addr); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index f09c54d5bb94..a2f6782bdbbf 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -673,6 +673,7 @@ void spapr_reallocate_hpt(sPAPRMachineState *spapr, int= shift, /* CPU and LMB DRC release callbacks. */ void spapr_core_release(DeviceState *dev); void spapr_lmb_release(DeviceState *dev); +void spapr_phb_release(DeviceState *dev); =20 void spapr_rtc_read(sPAPRRTCState *rtc, struct tm *tm, uint32_t *ns); int spapr_rtc_import_offset(sPAPRRTCState *rtc, int64_t legacy_offset);