From nobody Fri Nov 7 02:14:33 2025 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 1545352624730339.6570160127675; Thu, 20 Dec 2018 16:37:04 -0800 (PST) Received: from localhost ([::1]:41653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8oJ-0005OL-7V for importer@patchew.org; Thu, 20 Dec 2018 19:37:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8mU-0004QU-Pa for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:35:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8mQ-0003wf-KJ for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:35:09 -0500 Received: from 4.mo3.mail-out.ovh.net ([178.33.46.10]:52273) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8mQ-0003rP-B4 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:35:06 -0500 Received: from player697.ha.ovh.net (unknown [10.109.146.32]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 936241EE989 for ; Fri, 21 Dec 2018 01:35:04 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player697.ha.ovh.net (Postfix) with ESMTPSA id DC4CE112FD40; Fri, 21 Dec 2018 00:34:48 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:34:48 +0100 Message-ID: <154535248827.862554.14664931152289972599.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3834815085029792194 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvddtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.33.46.10 Subject: [Qemu-devel] [PATCH 01/15] ppc/spapr: Receive and store device tree blob from SLOF 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Alexey Kardashevskiy SLOF receives a device tree and updates it with various properties before switching to the guest kernel and QEMU is not aware of any changes made by SLOF. Since there is no real RTAS (QEMU implements it), it makes sense to pass the SLOF final device tree to QEMU to let it implement RTAS related tasks better, such as PCI host bus adapter hotplug. Specifially, now QEMU can find out the actual XICS phandle (for PHB hotplug) and the RTAS linux,rtas-entry/base properties (for firmware assisted NMI - FWNMI). This stores the initial DT blob in the sPAPR machine and replaces it in the KVMPPC_H_UPDATE_DT (new private hypercall) handler. This adds an @update_dt_enabled machine property to allow backward migration. SLOF already has a hypercall since https://github.com/aik/SLOF/commit/e6fc84652c9c0073f9183 This makes use of the new fdt_check_full() helper. In order to allow the configure script to pick the correct DTC version, this adjusts the DTC presense test. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Greg Kurz Signed-off-by: David Gibson Signed-off-by: Greg Kurz --- configure | 2 +- hw/ppc/spapr.c | 43 ++++++++++++++++++++++++++++++++++++++++++- hw/ppc/spapr_hcall.c | 42 ++++++++++++++++++++++++++++++++++++++++++ hw/ppc/trace-events | 3 +++ include/hw/ppc/spapr.h | 7 ++++++- 5 files changed, 94 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 224d3071ac61..baeeabc29f56 100755 --- a/configure +++ b/configure @@ -3916,7 +3916,7 @@ if test "$fdt" !=3D "no" ; then cat > $TMPC << EOF #include #include -int main(void) { fdt_first_subnode(0, 0); return 0; } +int main(void) { fdt_check_full(NULL, 0); return 0; } EOF if compile_prog "" "$fdt_libs" ; then # system DTC is good - use it diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 17ad84396b31..8ea680fcde1e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1668,7 +1668,10 @@ static void spapr_machine_reset(void) /* Load the fdt */ qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt)); - g_free(fdt); + g_free(spapr->fdt_blob); + spapr->fdt_size =3D fdt_totalsize(fdt); + spapr->fdt_initial_size =3D spapr->fdt_size; + spapr->fdt_blob =3D fdt; =20 /* Set up the entry state */ spapr_cpu_set_entry_state(first_ppc_cpu, SPAPR_ENTRY_POINT, fdt_addr); @@ -1919,6 +1922,39 @@ static const VMStateDescription vmstate_spapr_irq_ma= p =3D { }, }; =20 +static bool spapr_dtb_needed(void *opaque) +{ + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(opaque); + + return smc->update_dt_enabled; +} + +static int spapr_dtb_pre_load(void *opaque) +{ + sPAPRMachineState *spapr =3D (sPAPRMachineState *)opaque; + + g_free(spapr->fdt_blob); + spapr->fdt_blob =3D NULL; + spapr->fdt_size =3D 0; + + return 0; +} + +static const VMStateDescription vmstate_spapr_dtb =3D { + .name =3D "spapr_dtb", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D spapr_dtb_needed, + .pre_load =3D spapr_dtb_pre_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(fdt_initial_size, sPAPRMachineState), + VMSTATE_UINT32(fdt_size, sPAPRMachineState), + VMSTATE_VBUFFER_ALLOC_UINT32(fdt_blob, sPAPRMachineState, 0, NULL, + fdt_size), + VMSTATE_END_OF_LIST() + }, +}; + static const VMStateDescription vmstate_spapr =3D { .name =3D "spapr", .version_id =3D 3, @@ -1948,6 +1984,7 @@ static const VMStateDescription vmstate_spapr =3D { &vmstate_spapr_cap_ibs, &vmstate_spapr_irq_map, &vmstate_spapr_cap_nested_kvm_hv, + &vmstate_spapr_dtb, NULL } }; @@ -3929,6 +3966,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) hc->unplug =3D spapr_machine_device_unplug; =20 smc->dr_lmb_enabled =3D true; + smc->update_dt_enabled =3D true; mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("power9_v2.0"); mc->has_hotpluggable_cpus =3D true; smc->resize_hpt_default =3D SPAPR_RESIZE_HPT_ENABLED; @@ -4024,9 +4062,12 @@ DEFINE_SPAPR_MACHINE(4_0, "4.0", true); =20 static void spapr_machine_3_1_class_options(MachineClass *mc) { + sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + spapr_machine_4_0_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_3_1); mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("power8_v2.0"); + smc->update_dt_enabled =3D false; } =20 DEFINE_SPAPR_MACHINE(3_1, "3.1", false); diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index ae913d070f50..78fecc8fe906 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1717,6 +1717,46 @@ static target_ulong h_get_cpu_characteristics(PowerP= CCPU *cpu, =20 args[0] =3D characteristics; args[1] =3D behaviour; + return H_SUCCESS; +} + +static target_ulong h_update_dt(PowerPCCPU *cpu, sPAPRMachineState *spapr, + target_ulong opcode, target_ulong *args) +{ + target_ulong dt =3D ppc64_phys_to_real(args[0]); + struct fdt_header hdr =3D { 0 }; + unsigned cb; + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); + void *fdt; + + cpu_physical_memory_read(dt, &hdr, sizeof(hdr)); + cb =3D fdt32_to_cpu(hdr.totalsize); + + if (!smc->update_dt_enabled) { + return H_SUCCESS; + } + + /* Check that the fdt did not grow out of proportion */ + if (cb > spapr->fdt_initial_size * 2) { + trace_spapr_update_dt_failed_size(spapr->fdt_initial_size, cb, + fdt32_to_cpu(hdr.magic)); + return H_PARAMETER; + } + + fdt =3D g_malloc0(cb); + cpu_physical_memory_read(dt, fdt, cb); + + /* Check the fdt consistency */ + if (fdt_check_full(fdt, cb)) { + trace_spapr_update_dt_failed_check(spapr->fdt_initial_size, cb, + fdt32_to_cpu(hdr.magic)); + return H_PARAMETER; + } + + g_free(spapr->fdt_blob); + spapr->fdt_size =3D cb; + spapr->fdt_blob =3D fdt; + trace_spapr_update_dt(cb); =20 return H_SUCCESS; } @@ -1822,6 +1862,8 @@ static void hypercall_register_types(void) =20 /* ibm,client-architecture-support support */ spapr_register_hypercall(KVMPPC_H_CAS, h_client_architecture_support); + + spapr_register_hypercall(KVMPPC_H_UPDATE_DT, h_update_dt); } =20 type_init(hypercall_register_types) diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index dc5e65aee96d..0af155ed323d 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -22,6 +22,9 @@ spapr_cas_pvr_try(uint32_t pvr) "0x%x" spapr_cas_pvr(uint32_t cur_pvr, bool explicit_match, uint32_t new_pvr) "cu= rrent=3D0x%x, explicit_match=3D%u, new=3D0x%x" spapr_h_resize_hpt_prepare(uint64_t flags, uint64_t shift) "flags=3D0x%"PR= Ix64", shift=3D%"PRIu64 spapr_h_resize_hpt_commit(uint64_t flags, uint64_t shift) "flags=3D0x%"PRI= x64", shift=3D%"PRIu64 +spapr_update_dt(unsigned cb) "New blob %u bytes" +spapr_update_dt_failed_size(unsigned cbold, unsigned cbnew, unsigned magic= ) "Old blob %u bytes, new blob %u bytes, magic 0x%x" +spapr_update_dt_failed_check(unsigned cbold, unsigned cbnew, unsigned magi= c) "Old blob %u bytes, new blob %u bytes, magic 0x%x" =20 # hw/ppc/spapr_iommu.c spapr_iommu_put(uint64_t liobn, uint64_t ioba, uint64_t tce, uint64_t ret)= "liobn=3D0x%"PRIx64" ioba=3D0x%"PRIx64" tce=3D0x%"PRIx64" ret=3D%"PRId64 diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 2c77a8ba8810..36033b89d31a 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -103,6 +103,7 @@ struct sPAPRMachineClass { =20 /*< public >*/ bool dr_lmb_enabled; /* enable dynamic-reconfig/hotplug of LMBs = */ + bool update_dt_enabled; /* enable KVMPPC_H_UPDATE_DT */ bool use_ohci_by_default; /* use USB-OHCI instead of XHCI */ bool pre_2_10_has_unused_icps; bool legacy_irq_allocation; @@ -139,6 +140,9 @@ struct sPAPRMachineState { int vrma_adjust; ssize_t rtas_size; void *rtas_blob; + uint32_t fdt_size; + uint32_t fdt_initial_size; + void *fdt_blob; long kernel_size; bool kernel_le; uint32_t initrd_base; @@ -480,7 +484,8 @@ 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_UPDATE_DT (KVMPPC_HCALL_BASE + 0x3) +#define KVMPPC_HCALL_MAX KVMPPC_H_UPDATE_DT =20 typedef struct sPAPRDeviceTreeUpdateHeader { uint32_t version_id; From nobody Fri Nov 7 02:14:33 2025 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 1545352802689667.7372482279238; Thu, 20 Dec 2018 16:40:02 -0800 (PST) Received: from localhost ([::1]:41668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8rB-0008BJ-76 for importer@patchew.org; Thu, 20 Dec 2018 19:40:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8mq-0004k9-Pd for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:35:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8mn-0004gp-H6 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:35:32 -0500 Received: from 4.mo5.mail-out.ovh.net ([178.33.111.247]:50017) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8ml-0004XS-Gb for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:35:29 -0500 Received: from player795.ha.ovh.net (unknown [10.109.159.222]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id C406D20BC57 for ; Fri, 21 Dec 2018 01:35:25 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player795.ha.ovh.net (Postfix) with ESMTPSA id CEAED1007975; Fri, 21 Dec 2018 00:35:09 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:35:09 +0100 Message-ID: <154535250941.862554.15763512831843902652.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3840726059116698050 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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] [PATCH 02/15] 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 8ea680fcde1e..1f17b5d01f4f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2551,6 +2551,17 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) } } =20 +static PCIHostState *spapr_create_default_phb(void) +{ + 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 spapr_machine_init(MachineState *machine) { @@ -2782,7 +2793,7 @@ static void spapr_machine_init(MachineState *machine) /* Set up PCI */ spapr_pci_rtas_init(); =20 - phb =3D spapr_create_phb(spapr, 0); + phb =3D spapr_create_default_phb(); =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 2374d55fc112..e59adbe706bb 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1979,17 +1979,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 7c66c3872f96..a65cfef16945 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 spapr_qirq(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, uint32_t nr_msis); =20 From nobody Fri Nov 7 02:14:33 2025 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 1545352948133542.0225857198178; Thu, 20 Dec 2018 16:42:28 -0800 (PST) Received: from localhost ([::1]:41693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8tW-0001o1-HY for importer@patchew.org; Thu, 20 Dec 2018 19:42:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8nA-0004xy-Fr for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:35:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8n6-0005CF-Vl for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:35:52 -0500 Received: from 9.mo6.mail-out.ovh.net ([87.98.171.146]:50397) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8n6-00059p-PM for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:35:48 -0500 Received: from player695.ha.ovh.net (unknown [10.109.160.54]) by mo6.mail-out.ovh.net (Postfix) with ESMTP id 580D519FF27 for ; Fri, 21 Dec 2018 01:35:47 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player695.ha.ovh.net (Postfix) with ESMTPSA id E5A52F16757; Fri, 21 Dec 2018 00:35:30 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:35:30 +0100 Message-ID: <154535253055.862554.10471167343589360987.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3846637034106034626 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.171.146 Subject: [Qemu-devel] [PATCH 03/15] pci: allow cleanup/unregistration of PCI root 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Michael Roth This adds cleanup counterparts to pci_register_root_bus(), pci_root_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 Reviewed-by: Michael S. Tsirkin --- 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 efb5ce196ffb..16354f91206c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -333,6 +333,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_device_root_bus(const PCIDevice *d) { PCIBus *bus =3D pci_get_bus(d); @@ -379,6 +386,11 @@ static void pci_root_bus_init(PCIBus *bus, DeviceState= *parent, 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); @@ -413,6 +425,12 @@ PCIBus *pci_root_bus_new(DeviceState *parent, const ch= ar *name, return bus; } =20 +void pci_root_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) { @@ -423,6 +441,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_root_bus(DeviceState *parent, const char *name, pci_set_irq_fn set_irq, pci_map_irq_fn map_i= rq, void *irq_opaque, @@ -439,6 +466,12 @@ PCIBus *pci_register_root_bus(DeviceState *parent, con= st char *name, return bus; } =20 +void pci_unregister_root_bus(PCIBus *bus) +{ + pci_bus_irqs_cleanup(bus); + pci_root_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 e6514bba23aa..8998e3be3390 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -405,8 +405,10 @@ PCIBus *pci_root_bus_new(DeviceState *parent, const ch= ar *name, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, uint8_t devfn_min, const char *typename); +void pci_root_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); @@ -417,6 +419,7 @@ PCIBus *pci_register_root_bus(DeviceState *parent, cons= t char *name, MemoryRegion *address_space_io, uint8_t devfn_min, int nirq, const char *typename); +void pci_unregister_root_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 Fri Nov 7 02:14:33 2025 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 1545352817201856.2195223484935; Thu, 20 Dec 2018 16:40:17 -0800 (PST) Received: from localhost ([::1]:41671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8rP-0008My-MK for importer@patchew.org; Thu, 20 Dec 2018 19:40:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8nV-0005CZ-MJ for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:36:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8nQ-0005qC-Og for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:36:13 -0500 Received: from 3.mo2.mail-out.ovh.net ([46.105.58.226]:37287) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8nQ-0005og-Gj for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:36:08 -0500 Received: from player157.ha.ovh.net (unknown [10.109.143.18]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 87A01177065 for ; Fri, 21 Dec 2018 01:36:07 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player157.ha.ovh.net (Postfix) with ESMTPSA id 5CCB6FCCC45; Fri, 21 Dec 2018 00:35:52 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:35:52 +0100 Message-ID: <154535255201.862554.4906401457640454977.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3852548009610287554 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.58.226 Subject: [Qemu-devel] [PATCH 04/15] spapr_pci: add proper rollback on PHB realize error path 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The current realize code assumes the PHB is coldplugged, ie, QEMU will terminate if an error is detected, and does not bother to free anything it has already allocated. In order to support PHB hotplug, let's first ensure spapr_phb_realize() doesn't leak anything in case of error. Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index e59adbe706bb..46d7062dd143 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1570,6 +1570,7 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) sPAPRTCETable *tcet; const unsigned windows_supported =3D sphb->ddw_enabled ? SPAPR_PCI_DMA_MAX_WINDOWS : 1; + Object *drcs[PCI_SLOT_MAX * 8]; =20 if (!spapr) { error_setg(errp, TYPE_SPAPR_PCI_HOST_BRIDGE " needs a pseries mach= ine"); @@ -1733,7 +1734,10 @@ static void spapr_phb_realize(DeviceState *dev, Erro= r **errp) spapr_irq_claim(spapr, irq, true, &local_err); if (local_err) { error_propagate_prepend(errp, local_err, "can't allocate LSIs:= "); - return; + while (--i >=3D 0) { + spapr_irq_free(spapr, sphb->lsi_table[i].irq, 1); + } + goto fail_del_msiwindow; } =20 sphb->lsi_table[i].irq =3D irq; @@ -1741,9 +1745,10 @@ static void spapr_phb_realize(DeviceState *dev, Erro= r **errp) =20 /* allocate connectors for child PCI devices */ if (sphb->dr_enabled) { - for (i =3D 0; i < PCI_SLOT_MAX * 8; i++) { - spapr_dr_connector_new(OBJECT(phb), TYPE_SPAPR_DRC_PCI, - (sphb->index << 16) | i); + for (i =3D 0; i < ARRAY_SIZE(drcs); i++) { + drcs[i] =3D + OBJECT(spapr_dr_connector_new(OBJECT(phb), TYPE_SPAPR_DRC_= PCI, + (sphb->index << 16) | i)); } } =20 @@ -1753,13 +1758,38 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) if (!tcet) { error_setg(errp, "Creating window#%d failed for %s", i, sphb->dtbusname); - return; + while (--i >=3D 0) { + tcet =3D spapr_tce_find_by_liobn(sphb->dma_liobn[i]); + assert(tcet); + memory_region_del_subregion(&sphb->iommu_root, + spapr_tce_get_iommu(tcet)); + object_unparent(OBJECT(tcet)); + } + goto fail_free_drcs; } 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); + return; + +fail_free_drcs: + if (sphb->dr_enabled) { + for (i =3D 0; i < ARRAY_SIZE(drcs); i++) { + object_unparent(drcs[i]); + } + } +fail_del_msiwindow: + 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_root_bus(phb->bus); + memory_region_del_subregion(get_system_memory(), &sphb->iowindow); + if (sphb->mem64_win_pciaddr !=3D (hwaddr)-1) { + memory_region_del_subregion(get_system_memory(), &sphb->mem64windo= w); + } + memory_region_del_subregion(get_system_memory(), &sphb->mem32window); } =20 static int spapr_phb_children_reset(Object *child, void *opaque) From nobody Fri Nov 7 02:14:33 2025 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 1545352718138765.2862018539057; Thu, 20 Dec 2018 16:38:38 -0800 (PST) Received: from localhost ([::1]:41664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8po-0006st-JB for importer@patchew.org; Thu, 20 Dec 2018 19:38:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8no-0005PY-Hc for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:36:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8nl-0006LG-7f for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:36:32 -0500 Received: from 17.mo3.mail-out.ovh.net ([87.98.178.58]:58381) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8nk-0006IO-Ua for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:36:29 -0500 Received: from player168.ha.ovh.net (unknown [10.109.160.62]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id A56E51EE989 for ; Fri, 21 Dec 2018 01:36:27 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player168.ha.ovh.net (Postfix) with ESMTPSA id B09F7F6D60F; Fri, 21 Dec 2018 00:36:12 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:36:12 +0100 Message-ID: <154535257235.862554.618590581497296693.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3858177508480424386 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.178.58 Subject: [Qemu-devel] [PATCH 05/15] 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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). The formula that gives the number of DMA windows is moved to an inline function in the hw/pci-host/spapr.h header because it will have other users. Signed-off-by: Michael Roth Signed-off-by: Greg Kurz --- hw/ppc/spapr_pci.c | 56 +++++++++++++++++++++++++++++++++++++++= ++-- include/hw/pci-host/spapr.h | 4 +++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 46d7062dd143..b772b72d6a48 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1551,6 +1551,57 @@ 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) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); + 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 spapr_phb_windows_supported(sphb); + + 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]); + assert(tcet); + memory_region_del_subregion(&sphb->iommu_root, + spapr_tce_get_iommu(tcet)); + } + + for (i =3D PCI_NUM_PINS - 1; i >=3D 0; i--) { + spapr_irq_free(spapr, sphb->lsi_table[i].irq, 1); + } + + 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_root_bus(phb->bus); + + memory_region_del_subregion(get_system_memory(), &sphb->iowindow); + if (sphb->mem64_win_pciaddr !=3D (hwaddr)-1) { + memory_region_del_subregion(get_system_memory(), &sphb->mem64windo= w); + } + memory_region_del_subregion(get_system_memory(), &sphb->mem32window); +} + static void spapr_phb_realize(DeviceState *dev, Error **errp) { /* We don't use SPAPR_MACHINE() in order to exit gracefully if the user @@ -1568,8 +1619,7 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) PCIBus *bus; uint64_t msi_window_size =3D 4096; sPAPRTCETable *tcet; - const unsigned windows_supported =3D - sphb->ddw_enabled ? SPAPR_PCI_DMA_MAX_WINDOWS : 1; + const unsigned windows_supported =3D spapr_phb_windows_supported(sphb); Object *drcs[PCI_SLOT_MAX * 8]; =20 if (!spapr) { @@ -1988,6 +2038,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; @@ -2002,6 +2053,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 }, diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index a65cfef16945..9d2ec1a410e8 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -162,4 +162,8 @@ static inline void spapr_phb_vfio_reset(DeviceState *qd= ev) =20 void spapr_phb_dma_reset(sPAPRPHBState *sphb); =20 +static inline unsigned spapr_phb_windows_supported(sPAPRPHBState *sphb) +{ + return sphb->ddw_enabled ? SPAPR_PCI_DMA_MAX_WINDOWS : 1; +} #endif /* PCI_HOST_SPAPR_H */ From nobody Fri Nov 7 02:14:33 2025 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 1545352739141327.676337623117; Thu, 20 Dec 2018 16:38:59 -0800 (PST) Received: from localhost ([::1]:41667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8q9-0007HJ-IC for importer@patchew.org; Thu, 20 Dec 2018 19:38:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8o9-0005j3-K6 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:36:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8o6-0006t9-Df for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:36:53 -0500 Received: from 1.mo68.mail-out.ovh.net ([46.105.41.146]:54240) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8o6-0006rg-2U for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:36:50 -0500 Received: from player772.ha.ovh.net (unknown [10.109.159.224]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id BAAF310A80C for ; Fri, 21 Dec 2018 01:36:48 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player772.ha.ovh.net (Postfix) with ESMTPSA id 0A08910809A8; Fri, 21 Dec 2018 00:36:33 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:36:32 +0100 Message-ID: <154535259259.862554.5658306444032609904.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3864088480934238658 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.41.146 Subject: [Qemu-devel] [PATCH 06/15] spapr: enable PHB hotplug for default pseries 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Michael Roth The 'dr_phb_enabled' field of that class can be set as part of machine-specific init code. It will be used 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 --- hw/ppc/spapr.c | 2 ++ include/hw/ppc/spapr.h | 1 + 2 files changed, 3 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 1f17b5d01f4f..621006eaa862 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4011,6 +4011,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) smc->default_caps.caps[SPAPR_CAP_NESTED_KVM_HV] =3D SPAPR_CAP_OFF; spapr_caps_add_properties(smc, &error_abort); smc->irq =3D &spapr_irq_xics; + smc->dr_phb_enabled =3D true; } =20 static const TypeInfo spapr_machine_info =3D { @@ -4079,6 +4080,7 @@ static void spapr_machine_3_1_class_options(MachineCl= ass *mc) SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_3_1); mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("power8_v2.0"); smc->update_dt_enabled =3D false; + smc->dr_phb_enabled =3D false; } =20 DEFINE_SPAPR_MACHINE(3_1, "3.1", false); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 36033b89d31a..e96deefa30de 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -104,6 +104,7 @@ struct sPAPRMachineClass { /*< public >*/ bool dr_lmb_enabled; /* enable dynamic-reconfig/hotplug of LMBs = */ bool update_dt_enabled; /* enable KVMPPC_H_UPDATE_DT */ + bool dr_phb_enabled; /* enable dynamic-reconfig/hotplug of PHBs = */ bool use_ohci_by_default; /* use USB-OHCI instead of XHCI */ bool pre_2_10_has_unused_icps; bool legacy_irq_allocation; From nobody Fri Nov 7 02:14:33 2025 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 1545352959261146.54465588241646; Thu, 20 Dec 2018 16:42:39 -0800 (PST) Received: from localhost ([::1]:41694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8th-0001xe-Si for importer@patchew.org; Thu, 20 Dec 2018 19:42:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8ol-0006CX-0X for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:37:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8od-0007aK-T0 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:37:28 -0500 Received: from 1.mo2.mail-out.ovh.net ([46.105.63.121]:56793) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8oT-0007IQ-Ll for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:37:15 -0500 Received: from player758.ha.ovh.net (unknown [10.109.159.62]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 9699417704C for ; Fri, 21 Dec 2018 01:37:10 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player758.ha.ovh.net (Postfix) with ESMTPSA id 1D15F11487FD; Fri, 21 Dec 2018 00:36:54 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:36:53 +0100 Message-ID: <154535261366.862554.2330587135163596442.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3869999458215893442 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.63.121 Subject: [Qemu-devel] [PATCH 07/15] spapr_pci: Define SPAPR_MAX_PHBS in hw/pci-host/spapr.h 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" PHB hotplug will bring more users for it. Let's define it along with the PHB defines from which it is derived for simplicity. While here fix a misleading comment about manual placement, which was abandoned with 30b3bc5aa9f4. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater --- hw/ppc/spapr.c | 2 -- include/hw/pci-host/spapr.h | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 621006eaa862..fe3f9829ae6c 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3838,8 +3838,6 @@ static void spapr_phb_placement(sPAPRMachineState *sp= apr, uint32_t index, * 1TiB 64-bit MMIO windows for each PHB. */ const uint64_t base_buid =3D 0x800000020000000ULL; -#define SPAPR_MAX_PHBS ((SPAPR_PCI_LIMIT - SPAPR_PCI_BASE) / \ - SPAPR_PCI_MEM64_WIN_SIZE - 1) int i; =20 /* Sanity check natural alignments */ diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 9d2ec1a410e8..83d5075a6ef3 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -94,11 +94,13 @@ struct sPAPRPHBState { ((1ULL << 32) - SPAPR_PCI_MEM_WIN_BUS_OFFSET) #define SPAPR_PCI_MEM64_WIN_SIZE 0x10000000000ULL /* 1 TiB */ =20 -/* Without manual configuration, all PCI outbound windows will be - * within this range */ +/* All PCI outbound windows will be within this range */ #define SPAPR_PCI_BASE (1ULL << 45) /* 32 TiB */ #define SPAPR_PCI_LIMIT (1ULL << 46) /* 64 TiB */ =20 +#define SPAPR_MAX_PHBS ((SPAPR_PCI_LIMIT - SPAPR_PCI_BASE) / \ + SPAPR_PCI_MEM64_WIN_SIZE - 1) + #define SPAPR_PCI_2_7_MMIO_WIN_SIZE 0xf80000000 #define SPAPR_PCI_IO_WIN_SIZE 0x10000 =20 From nobody Fri Nov 7 02:14:33 2025 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 1545353119025635.2342619381421; Thu, 20 Dec 2018 16:45:19 -0800 (PST) Received: from localhost ([::1]:41716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8wH-00048H-Dy for importer@patchew.org; Thu, 20 Dec 2018 19:45:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8os-0006KG-RB for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:37:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8oo-0007uz-PQ for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:37:38 -0500 Received: from 3.mo177.mail-out.ovh.net ([46.105.36.172]:36007) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8om-0007qK-T5 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:37:34 -0500 Received: from player755.ha.ovh.net (unknown [10.109.146.240]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id 46D48D7105 for ; Fri, 21 Dec 2018 01:37:31 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player755.ha.ovh.net (Postfix) with ESMTPSA id 33E6F1271518; Fri, 21 Dec 2018 00:37:15 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:37:14 +0100 Message-ID: <154535263471.862554.11494652990553598582.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3876191906442615234 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.36.172 Subject: [Qemu-devel] [PATCH 08/15] 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Michael Roth Signed-off-by: Michael Roth Reviewed-by: David Gibson Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 13 +++++++++++++ hw/ppc/spapr_drc.c | 17 +++++++++++++++++ include/hw/ppc/spapr_drc.h | 8 ++++++++ 3 files changed, 38 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index fe3f9829ae6c..280e45037704 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2790,6 +2790,19 @@ static void spapr_machine_init(MachineState *machine) /* We always have at least the nvram device on VIO */ spapr_create_nvram(spapr); =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 (smc->dr_phb_enabled) { + for (i =3D 0; i < SPAPR_MAX_PHBS; 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 2edb7d1e9c8c..189ee681062a 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -696,6 +696,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, @@ -739,6 +748,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) @@ -1189,6 +1205,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 f6ff32e7e2f2..56bba36ad4da 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -70,6 +70,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 Fri Nov 7 02:14:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545352919052516.503176667762; Thu, 20 Dec 2018 16:41:59 -0800 (PST) Received: from localhost ([::1]:41692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8sy-0001ML-6Q for importer@patchew.org; Thu, 20 Dec 2018 19:41:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8pB-0006j7-7n for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:37:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8p8-0008Ns-1k for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:37:57 -0500 Received: from 3.mo69.mail-out.ovh.net ([188.165.52.203]:60920) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8p7-0008Lj-QL for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:37:53 -0500 Received: from player739.ha.ovh.net (unknown [10.109.160.5]) by mo69.mail-out.ovh.net (Postfix) with ESMTP id 80AA635890 for ; Fri, 21 Dec 2018 01:37:52 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player739.ha.ovh.net (Postfix) with ESMTPSA id A3C2D12EFED7; Fri, 21 Dec 2018 00:37:36 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:37:36 +0100 Message-ID: <154535265622.862554.13338931723631685938.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3882102881383520706 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 188.165.52.203 Subject: [Qemu-devel] [PATCH 09/15] 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 --- hw/ppc/spapr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 280e45037704..4f9d11b14666 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1350,6 +1350,14 @@ static void *spapr_build_fdt(sPAPRMachineState *spap= r, exit(1); } =20 + if (smc->dr_phb_enabled) { + ret =3D spapr_drc_populate_dt(fdt, 0, NULL, SPAPR_DR_CONNECTOR_TYP= E_PHB); + if (ret < 0) { + error_report("Couldn't set up PHB DR device tree properties"); + exit(1); + } + } + return fdt; } =20 From nobody Fri Nov 7 02:14:33 2025 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 1545353108764625.6999855124466; Thu, 20 Dec 2018 16:45:08 -0800 (PST) Received: from localhost ([::1]:41715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8w7-0003yc-8N for importer@patchew.org; Thu, 20 Dec 2018 19:45:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8pW-0007Dd-Fp for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:38:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8pT-0000JT-4j for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:38:18 -0500 Received: from 1.mo1.mail-out.ovh.net ([178.32.127.22]:37919) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8pS-0000Gr-TI for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:38:15 -0500 Received: from player687.ha.ovh.net (unknown [10.109.146.175]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id A6CEB14B541 for ; Fri, 21 Dec 2018 01:38:13 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player687.ha.ovh.net (Postfix) with ESMTPSA id BB4F71069A49; Fri, 21 Dec 2018 00:37:57 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:37:57 +0100 Message-ID: <154535267737.862554.5615504074002076384.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3888013855394863554 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 178.32.127.22 Subject: [Qemu-devel] [PATCH 10/15] 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 32719a1b72d0..baf30c55710a 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -526,6 +526,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 Fri Nov 7 02:14:33 2025 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 1545353272637226.6674173803142; Thu, 20 Dec 2018 16:47:52 -0800 (PST) Received: from localhost ([::1]:41736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8yg-00069O-RS for importer@patchew.org; Thu, 20 Dec 2018 19:47:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8pq-0007UZ-G4 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:38:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8pn-0000kp-5N for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:38:38 -0500 Received: from 7.mo177.mail-out.ovh.net ([46.105.61.149]:35781) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8pm-0000k5-UA for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:38:35 -0500 Received: from player694.ha.ovh.net (unknown [10.109.159.123]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id EC97CD77BD for ; Fri, 21 Dec 2018 01:38:33 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player694.ha.ovh.net (Postfix) with ESMTPSA id 05842FBFB5D; Fri, 21 Dec 2018 00:38:18 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:38:18 +0100 Message-ID: <154535269857.862554.12073245177305497837.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3893643353934764482 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.61.149 Subject: [Qemu-devel] [PATCH 11/15] 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 e330f24c71e0..d72aba555c5c 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -441,7 +441,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 04e3ebe3526a..e4310c78f2dc 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1052,7 +1052,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 6c91bd44a0a5..d74b121e8b6e 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -444,7 +444,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 96a43d2f709a..377aedeb27be 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -639,7 +639,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 b772b72d6a48..292dd95cbef9 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1723,7 +1723,7 @@ static void spapr_phb_realize(DeviceState *dev, Error= **errp) &sphb->memspace, &sphb->iospace, PCI_DEVFN(0, 0), PCI_NUM_PINS, TYPE_PCI_BU= S); 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 1bd6c8b45860..7573c40badbd 100644 --- a/hw/s390x/css-bridge.c +++ b/hw/s390x/css-bridge.c @@ -108,7 +108,7 @@ VirtualCssBus *virtual_css_bus_init(void) cbus =3D VIRTUAL_CSS_BUS(bus); =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 f7458445c0f5..01eea2752912 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -708,7 +708,7 @@ static void s390_pcihost_realize(DeviceState *dev, Erro= r **errp) pci_setup_iommu(b, s390_pci_dma_iommu, s); =20 bus =3D BUS(b); - qbus_set_hotplug_handler(bus, dev, &local_err); + qbus_set_hotplug_handler(bus, OBJECT(dev), &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -716,7 +716,7 @@ static void s390_pcihost_realize(DeviceState *dev, Erro= r **errp) phb->bus =3D b; =20 s->bus =3D S390_PCI_BUS(qbus_create(TYPE_S390_PCI_BUS, dev, NULL)); - qbus_set_hotplug_handler(BUS(s->bus), dev, &local_err); + qbus_set_hotplug_handler(BUS(s->bus), OBJECT(dev), &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -844,7 +844,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 3aa99717e235..9cf6290c2986 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 a3a019e30a74..584b4be07e79 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -1142,7 +1142,7 @@ pvscsi_realizefn(PCIDevice *pci_dev, Error **errp) 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 diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 8f716fc165a3..6b0137bb7699 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -1322,7 +1322,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 92851e55dfa9..3fa33901dfcf 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -422,8 +422,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 Fri Nov 7 02:14:33 2025 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 1545353272554726.6509977186715; Thu, 20 Dec 2018 16:47:52 -0800 (PST) Received: from localhost ([::1]:41735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8yc-00066G-Sf for importer@patchew.org; Thu, 20 Dec 2018 19:47:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8qF-0007rN-Bv for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:39:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8qC-00018g-4s for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:39:03 -0500 Received: from 10.mo178.mail-out.ovh.net ([46.105.76.150]:44534) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8qB-000141-TB for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:39:00 -0500 Received: from player737.ha.ovh.net (unknown [10.109.160.5]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 43AB542E1C for ; Fri, 21 Dec 2018 01:38:54 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id 3CAE412CFA01; Fri, 21 Dec 2018 00:38:39 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:38:38 +0100 Message-ID: <154535271886.862554.6726021603616372000.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3899554330913118658 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.76.150 Subject: [Qemu-devel] [PATCH 12/15] 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 --- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_pci.c | 5 ++++- include/hw/pci-host/spapr.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 4f9d11b14666..5c405a5fafca 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1297,7 +1297,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, - spapr->irq->nr_msis); + spapr->irq->nr_msis, 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 292dd95cbef9..5e7b40a8c910 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2140,7 +2140,7 @@ static void spapr_phb_pci_enumerate(sPAPRPHBState *ph= b) } =20 int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t xics_phandle, void = *fdt, - uint32_t nr_msis) + uint32_t nr_msis, int *node_offset) { int bus_off, i, j, ret; gchar *nodename; @@ -2195,6 +2195,9 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_= t xics_phandle, void *fdt, nodename =3D g_strdup_printf("pci@%" PRIx64, phb->buid); _FDT(bus_off =3D fdt_add_subnode(fdt, 0, nodename)); g_free(nodename); + 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 83d5075a6ef3..6ef8f141ea92 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -114,7 +114,7 @@ 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, - uint32_t nr_msis); + uint32_t nr_msis, int *node_offset); =20 void spapr_pci_rtas_init(void); =20 From nobody Fri Nov 7 02:14:33 2025 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 154535306458154.344852319154825; Thu, 20 Dec 2018 16:44:24 -0800 (PST) Received: from localhost ([::1]:41712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8vP-0003OZ-46 for importer@patchew.org; Thu, 20 Dec 2018 19:44:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ga8qX-00085f-5I for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:39:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ga8qT-0001V2-N9 for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:39:20 -0500 Received: from 10.mo177.mail-out.ovh.net ([46.105.73.133]:32900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ga8qT-0001TV-9J for qemu-devel@nongnu.org; Thu, 20 Dec 2018 19:39:17 -0500 Received: from player756.ha.ovh.net (unknown [10.109.160.54]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id BC1A6D78AB for ; Fri, 21 Dec 2018 01:39:15 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player756.ha.ovh.net (Postfix) with ESMTPSA id 6EBF2114437F; Fri, 21 Dec 2018 00:38:59 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 01:38:59 +0100 Message-ID: <154535273907.862554.16748545540859785258.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 3905465305957308866 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.73.133 Subject: [Qemu-devel] [PATCH 13/15] 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 5e7b40a8c910..688cca83ef2f 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2190,6 +2190,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_= t xics_phandle, void *fdt, sPAPRTCETable *tcet; PCIBus *bus =3D PCI_HOST_BRIDGE(phb)->bus; sPAPRFDT s_fdt; + sPAPRDRConnector *drc; =20 /* Start populating the FDT */ nodename =3D g_strdup_printf("pci@%" PRIx64, phb->buid); @@ -2256,6 +2257,14 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32= _t xics_phandle, void *fdt, tcet->liobn, tcet->bus_offset, tcet->nb_table << tcet->page_shift); =20 + drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_PHB, phb->index); + 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 Fri Nov 7 02:14:33 2025 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 1545374207214236.82518997228397; Thu, 20 Dec 2018 22:36:47 -0800 (PST) Received: from localhost ([::1]:42679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaEQM-0007yi-W9 for importer@patchew.org; Fri, 21 Dec 2018 01:36:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaEPJ-0007aY-2L for qemu-devel@nongnu.org; Fri, 21 Dec 2018 01:35:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gaEPF-00048D-ST for qemu-devel@nongnu.org; Fri, 21 Dec 2018 01:35:37 -0500 Received: from 9.mo179.mail-out.ovh.net ([46.105.76.148]:39983) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gaEPF-000477-GZ for qemu-devel@nongnu.org; Fri, 21 Dec 2018 01:35:33 -0500 Received: from player798.ha.ovh.net (unknown [10.109.143.3]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id 26A6E10EB84 for ; Fri, 21 Dec 2018 07:35:32 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player798.ha.ovh.net (Postfix) with ESMTPSA id BEB1C126F7C3; Fri, 21 Dec 2018 06:35:14 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 07:35:14 +0100 Message-ID: <154537411408.891668.13796612948399384908.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9922274407010769346 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgleeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.76.148 Subject: [Qemu-devel] [PATCH 14/15] spapr: Expose the name of the interrupt controller 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" This will be needed by PHB hotplug in order to access the phandle property. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater --- hw/intc/spapr_xive.c | 9 +++++++-- hw/intc/xics_spapr.c | 9 ++++++++- hw/ppc/spapr_irq.c | 3 +++ include/hw/ppc/spapr_irq.h | 1 + include/hw/ppc/spapr_xive.h | 1 + include/hw/ppc/xics.h | 1 + 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 87424de26c1c..0540aac88d2a 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -1410,6 +1410,12 @@ void spapr_xive_hcall_init(sPAPRMachineState *spapr) spapr_register_hypercall(H_INT_RESET, h_int_reset); } =20 +gchar *spapr_xive_get_nodename(sPAPRMachineState *spapr) +{ + return g_strdup_printf("interrupt-controller@%" PRIx64, + spapr->xive->tm_base + XIVE_TM_USER_PAGE * (1 << TM_SH= IFT)); +} + void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, uint32_t phandle) { @@ -1444,8 +1450,7 @@ void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t= nr_servers, void *fdt, XIVE_TM_OS_PAGE * (1ull << TM_SHIFT)); timas[3] =3D cpu_to_be64(1ull << TM_SHIFT); =20 - nodename =3D g_strdup_printf("interrupt-controller@%" PRIx64, - xive->tm_base + XIVE_TM_USER_PAGE * (1 << TM_SH= IFT)); + nodename =3D spapr_xive_get_nodename(spapr); _FDT(node =3D fdt_add_subnode(fdt, 0, nodename)); g_free(nodename); =20 diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index f67d3c80bf3a..75d40daf518d 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -244,6 +244,13 @@ void xics_spapr_init(sPAPRMachineState *spapr) spapr_register_hypercall(H_IPOLL, h_ipoll); } =20 +#define NODENAME "interrupt-controller" + +gchar *spapr_xics_get_nodename(sPAPRMachineState *spapr) +{ + return g_strdup(NODENAME); +} + void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, uint32_t phandle) { @@ -252,7 +259,7 @@ void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t n= r_servers, void *fdt, }; int node; =20 - _FDT(node =3D fdt_add_subnode(fdt, 0, "interrupt-controller")); + _FDT(node =3D fdt_add_subnode(fdt, 0, NODENAME)); =20 _FDT(fdt_setprop_string(fdt, node, "device_type", "PowerPC-External-Interrupt-Presentation")); diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 0999a2b2d69c..703c3a3c20d5 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -223,6 +223,7 @@ sPAPRIrq spapr_irq_xics =3D { .qirq =3D spapr_qirq_xics, .print_info =3D spapr_irq_print_info_xics, .dt_populate =3D spapr_dt_xics, + .get_nodename =3D spapr_xics_get_nodename, .cpu_intc_create =3D spapr_irq_cpu_intc_create_xics, .post_load =3D spapr_irq_post_load_xics, }; @@ -349,6 +350,7 @@ sPAPRIrq spapr_irq_xive =3D { .qirq =3D spapr_qirq_xive, .print_info =3D spapr_irq_print_info_xive, .dt_populate =3D spapr_dt_xive, + .get_nodename =3D spapr_xive_get_nodename, .cpu_intc_create =3D spapr_irq_cpu_intc_create_xive, .post_load =3D spapr_irq_post_load_xive, .reset =3D spapr_irq_reset_xive, @@ -462,6 +464,7 @@ sPAPRIrq spapr_irq_xics_legacy =3D { .qirq =3D spapr_qirq_xics, .print_info =3D spapr_irq_print_info_xics, .dt_populate =3D spapr_dt_xics, + .get_nodename =3D spapr_xics_get_nodename, .cpu_intc_create =3D spapr_irq_cpu_intc_create_xics, .post_load =3D spapr_irq_post_load_xics, }; diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index b34d5a00381b..59a1cf8bbc1d 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -42,6 +42,7 @@ typedef struct sPAPRIrq { void (*print_info)(sPAPRMachineState *spapr, Monitor *mon); void (*dt_populate)(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt, uint32_t phandle); + gchar *(*get_nodename)(sPAPRMachineState *spapr); Object *(*cpu_intc_create)(sPAPRMachineState *spapr, Object *cpu, Error **errp); int (*post_load)(sPAPRMachineState *spapr, int version_id); diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h index 728735dbcfbe..d280310ed587 100644 --- a/include/hw/ppc/spapr_xive.h +++ b/include/hw/ppc/spapr_xive.h @@ -47,6 +47,7 @@ typedef struct sPAPRMachineState sPAPRMachineState; void spapr_xive_hcall_init(sPAPRMachineState *spapr); void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, uint32_t phandle); +gchar *spapr_xive_get_nodename(sPAPRMachineState *spapr); void spapr_xive_set_tctx_os_cam(XiveTCTX *tctx); =20 #endif /* PPC_SPAPR_XIVE_H */ diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 14afda198cdb..eafb6428787f 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -204,6 +204,7 @@ typedef struct sPAPRMachineState sPAPRMachineState; =20 void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, uint32_t phandle); +gchar *spapr_xics_get_nodename(sPAPRMachineState *spapr); int xics_kvm_init(sPAPRMachineState *spapr, Error **errp); void xics_spapr_init(sPAPRMachineState *spapr); =20 From nobody Fri Nov 7 02:14:33 2025 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 1545374267744808.8854597780572; Thu, 20 Dec 2018 22:37:47 -0800 (PST) Received: from localhost ([::1]:42684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaERN-0000D9-5T for importer@patchew.org; Fri, 21 Dec 2018 01:37:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaEQF-000843-5P for qemu-devel@nongnu.org; Fri, 21 Dec 2018 01:36:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gaEQB-0004qK-Rt for qemu-devel@nongnu.org; Fri, 21 Dec 2018 01:36:35 -0500 Received: from 14.mo6.mail-out.ovh.net ([46.105.56.113]:60304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gaEQB-0004of-HG for qemu-devel@nongnu.org; Fri, 21 Dec 2018 01:36:31 -0500 Received: from player730.ha.ovh.net (unknown [10.109.146.19]) by mo6.mail-out.ovh.net (Postfix) with ESMTP id 242B71A0226 for ; Fri, 21 Dec 2018 07:36:30 +0100 (CET) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player730.ha.ovh.net (Postfix) with ESMTPSA id 868FCF32895; Fri, 21 Dec 2018 06:36:13 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 21 Dec 2018 07:36:12 +0100 Message-ID: <154537417263.891798.7533381599337392867.stgit@bahia.lan> In-Reply-To: <154535246529.862554.6113740443866753456.stgit@bahia.lan> References: <154535246529.862554.6113740443866753456.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 9938599953435040194 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudejgedgleeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.56.113 Subject: [Qemu-devel] [PATCH 15/15] 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: Cornelia Huck , Gerd Hoffmann , Eduardo Habkost , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , Michael Roth , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Michael Roth 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. We re-get the phandle of the interrupt controller systematically for simplicity. Signed-off-by: Michael Roth Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 147 ++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/ppc/spapr_drc.c | 1=20 hw/ppc/spapr_pci.c | 16 ----- include/hw/ppc/spapr.h | 1=20 4 files changed, 149 insertions(+), 16 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 5c405a5fafca..065c9f19700e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2923,6 +2923,10 @@ static void spapr_machine_init(MachineState *machine) register_savevm_live(NULL, "spapr/htab", -1, 1, &savevm_htab_handlers, spapr); =20 + if (smc->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()) { @@ -3716,6 +3720,135 @@ out: error_propagate(errp, local_err); } =20 +static void spapr_phb_pre_plug(HotplugHandler *hotplug_dev, DeviceState *d= ev, + Error **errp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); + sPAPRPHBState *sphb =3D SPAPR_PCI_HOST_BRIDGE(dev); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); + const unsigned windows_supported =3D spapr_phb_windows_supported(sphb); + + if (sphb->index =3D=3D (uint32_t)-1) { + error_setg(errp, "\"index\" for PAPR PHB is mandatory"); + return; + } + + /* + * This will check that sphb->index doesn't exceed the maximum number = of + * PHBs for the current machine type. + */ + smc->phb_placement(spapr, sphb->index, + &sphb->buid, &sphb->io_win_addr, + &sphb->mem_win_addr, &sphb->mem64_win_addr, + windows_supported, sphb->dma_liobn, errp); +} + +static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); + 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; + int ret; + bool hotplugged =3D spapr_drc_hotplugged(dev); + int offset, phandle =3D 0; + gchar *nodename =3D NULL; + + if (!smc->dr_phb_enabled) { + return; + } + + drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_PHB, sphb->index); + /* hotplug hooks should check it's enabled before getting this far */ + assert(drc); + + if (hotplugged) { + if (spapr->fdt_blob) { + /* + * SLOF might have pushed an updated FDT with new phandle valu= es. + * Re-get the one of our interrupt controller. + */ + nodename =3D spapr->irq->get_nodename(spapr); + + offset =3D fdt_subnode_offset(spapr->fdt_blob, 0, nodename); + if (offset < 0) { + error_setg(errp, "Can't find node \"%s\": %s", + nodename, fdt_strerror(offset)); + goto out; + } + + phandle =3D fdt_get_phandle(spapr->fdt_blob, offset); + if (phandle < 0) { + error_setg(errp, "Can't get phandle of node \"%s\": %s", + nodename, fdt_strerror(offset)); + goto out; + } + } + DEVICE_GET_CLASS(dev)->reset(dev); + } + + /* For cold-plugged at initial boot and fallback for hotplug */ + if (!phandle) { + phandle =3D PHANDLE_XICP; + } + + fdt =3D create_device_tree(&fdt_size); + ret =3D spapr_populate_pci_dt(sphb, phandle, fdt, spapr->irq->nr_msis, + &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: + g_free(nodename); + + 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->index); + 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) { @@ -3723,6 +3856,8 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, spapr_memory_plug(hotplug_dev, dev, 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 @@ -3741,6 +3876,7 @@ static void spapr_machine_device_unplug_request(Hotpl= ugHandler *hotplug_dev, { sPAPRMachineState *sms =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); MachineClass *mc =3D MACHINE_GET_CLASS(sms); + sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); =20 if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { if (spapr_ovec_test(sms->ov5_cas, OV5_HP_EVT)) { @@ -3760,6 +3896,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 (!smc->dr_phb_enabled) { + error_setg(errp, "PHB hot unplug not supported on this machine= "); + return; + } + spapr_phb_unplug_request(hotplug_dev, dev, errp); } } =20 @@ -3770,6 +3912,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 @@ -3777,7 +3921,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 189ee681062a..7a2676716364 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -703,6 +703,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 688cca83ef2f..5bc912aa0028 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1627,21 +1627,7 @@ static void spapr_phb_realize(DeviceState *dev, Erro= r **errp) return; } =20 - if (sphb->index !=3D (uint32_t)-1) { - Error *local_err =3D NULL; - - smc->phb_placement(spapr, sphb->index, - &sphb->buid, &sphb->io_win_addr, - &sphb->mem_win_addr, &sphb->mem64_win_addr, - windows_supported, sphb->dma_liobn, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - } else { - error_setg(errp, "\"index\" for PAPR PHB is mandatory"); - return; - } + assert(sphb->index !=3D (uint32_t)-1); /* checked in spapr_phb_pre_plu= g() */ =20 if (sphb->mem64_win_size !=3D 0) { if (sphb->mem_win_size > SPAPR_PCI_MEM32_WIN_SIZE) { diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index e96deefa30de..eff479b0a019 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -764,6 +764,7 @@ int spapr_max_server_number(sPAPRMachineState *spapr); /* 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);