From nobody Fri Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547240789211795.3586624905844; Fri, 11 Jan 2019 13:06:29 -0800 (PST) Received: from localhost ([127.0.0.1]:57506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi40L-0007i7-KY for importer@patchew.org; Fri, 11 Jan 2019 16:06:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3v4-0004BA-8D for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:00:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3v1-00012T-JD for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:00:46 -0500 Received: from 3.mo1.mail-out.ovh.net ([46.105.60.232]:32823) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3v1-0000zw-82 for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:00:43 -0500 Received: from player759.ha.ovh.net (unknown [10.109.146.53]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id CBA7F14E1E2 for ; Fri, 11 Jan 2019 22:00:41 +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 player759.ha.ovh.net (Postfix) with ESMTPSA id 51A1D1989E08; Fri, 11 Jan 2019 21:00:21 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:00:20 +0100 Message-ID: <154724042090.525985.13266460449119265532.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Ovh-Tracer-Id: 286260052315183410 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.60.232 Subject: [Qemu-devel] [PATCH v2 01/13] ppc: Move spapr-related prototypes from xics.h into a seperate header file 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth When compiling with Clang in -std=3Dgnu99 mode, there is a warning/error: CC ppc64-softmmu/hw/intc/xics_spapr.o In file included from /home/thuth/devel/qemu/hw/intc/xics_spapr.c:34: /home/thuth/devel/qemu/include/hw/ppc/xics.h:203:34: error: redefinition of= typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ /home/thuth/devel/qemu/include/hw/ppc/spapr_irq.h:25:34: note: previous def= inition is here typedef struct sPAPRMachineState sPAPRMachineState; ^ We have to remove the duplicated typedef here and include "spapr.h" instead. But "spapr.h" should not be included for the pnv machine files. So move the spapr-related prototypes into a new file called "xics_spapr.h" instead. Reviewed-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Thomas Huth Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Greg Kurz Reviewed-by: Michael S. Tsirkin --- hw/intc/xics_kvm.c | 1 + hw/intc/xics_spapr.c | 1 + hw/ppc/spapr_irq.c | 1 + include/hw/ppc/xics.h | 7 ------- include/hw/ppc/xics_spapr.h | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 include/hw/ppc/xics_spapr.h diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index ac94594b1919..dff13300504c 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -34,6 +34,7 @@ #include "sysemu/kvm.h" #include "hw/ppc/spapr.h" #include "hw/ppc/xics.h" +#include "hw/ppc/xics_spapr.h" #include "kvm_ppc.h" #include "qemu/config-file.h" #include "qemu/error-report.h" diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index 9c1a90d7094b..de6cc15b6474 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -32,6 +32,7 @@ #include "qemu/timer.h" #include "hw/ppc/spapr.h" #include "hw/ppc/xics.h" +#include "hw/ppc/xics_spapr.h" #include "hw/ppc/fdt.h" #include "qapi/visitor.h" =20 diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 5fce72fe0f6c..1da7a32348fc 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -14,6 +14,7 @@ #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_xive.h" #include "hw/ppc/xics.h" +#include "hw/ppc/xics_spapr.h" #include "sysemu/kvm.h" =20 #include "trace.h" diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 07508cbd217e..fad786e8b22d 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -200,13 +200,6 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon); void ics_resend(ICSState *ics); void icp_resend(ICPState *ss); =20 -typedef struct sPAPRMachineState sPAPRMachineState; - -void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, - uint32_t phandle); -int xics_kvm_init(sPAPRMachineState *spapr, Error **errp); -void xics_spapr_init(sPAPRMachineState *spapr); - Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp); =20 diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h new file mode 100644 index 000000000000..b1ab27d022cf --- /dev/null +++ b/include/hw/ppc/xics_spapr.h @@ -0,0 +1,37 @@ +/* + * QEMU PowerPC pSeries Logical Partition (aka sPAPR) hardware System Emul= ator + * + * PAPR Virtualized Interrupt System, aka ICS/ICP aka xics + * + * Copyright (c) 2010, 2011 David Gibson, IBM Corporation. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef XICS_SPAPR_H +#define XICS_SPAPR_H + +#include "hw/ppc/spapr.h" + +void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, + uint32_t phandle); +int xics_kvm_init(sPAPRMachineState *spapr, Error **errp); +void xics_spapr_init(sPAPRMachineState *spapr); + +#endif /* XICS_SPAPR_H */ From nobody Fri Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547240624083780.6001919941567; Fri, 11 Jan 2019 13:03:44 -0800 (PST) Received: from localhost ([127.0.0.1]:56870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3xu-0005ji-Tv for importer@patchew.org; Fri, 11 Jan 2019 16:03:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3vR-0004Sl-L4 for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:01:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3vQ-0001Nh-Ej for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:01:09 -0500 Received: from 4.mo178.mail-out.ovh.net ([46.105.49.171]:47747) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3vQ-0001LF-7r for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:01:08 -0500 Received: from player159.ha.ovh.net (unknown [10.109.146.163]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id A48BC45B00 for ; Fri, 11 Jan 2019 22:01:06 +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 player159.ha.ovh.net (Postfix) with ESMTPSA id 56F31178E46A; Fri, 11 Jan 2019 21:00:47 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:00:46 +0100 Message-ID: <154724044676.525985.4801504682864299114.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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: 293296928230840626 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.49.171 Subject: [Qemu-devel] [PATCH v2 02/13] spapr: Rename xics to intc in interrupt controller agnostic 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" All this code is used with both the XICS and XIVE interrupt controllers. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Michael S. Tsirkin --- hw/ppc/spapr.c | 6 +++--- hw/ppc/spapr_events.c | 2 +- hw/ppc/spapr_pci.c | 6 +++--- hw/ppc/spapr_vio.c | 2 +- include/hw/pci-host/spapr.h | 2 +- include/hw/ppc/spapr.h | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 83081defde4e..26f8e55cc25e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -96,7 +96,7 @@ =20 #define MIN_RMA_SLOF 128UL =20 -#define PHANDLE_XICP 0x00001111 +#define PHANDLE_INTC 0x00001111 =20 /* These two functions implement the VCPU id numbering: one to compute them * all and one to identify thread 0 of a VCORE. Any change to the first one @@ -1276,7 +1276,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, =20 /* /interrupt controller */ spapr->irq->dt_populate(spapr, spapr_max_server_number(spapr), fdt, - PHANDLE_XICP); + PHANDLE_INTC); =20 ret =3D spapr_populate_memory(spapr, fdt); if (ret < 0) { @@ -1296,7 +1296,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, } =20 QLIST_FOREACH(phb, &spapr->phbs, list) { - ret =3D spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt, + ret =3D spapr_populate_pci_dt(phb, PHANDLE_INTC, fdt, spapr->irq->nr_msis); if (ret < 0) { error_report("couldn't setup PCI devices in fdt"); diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index 32719a1b72d0..d4e75211954d 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -282,7 +282,7 @@ void spapr_dt_events(sPAPRMachineState *spapr, void *fd= t) continue; } =20 - spapr_dt_xics_irq(interrupts, source->irq, false); + spapr_dt_intc_irq(interrupts, source->irq, false); =20 _FDT(node_offset =3D fdt_add_subnode(fdt, event_sources, source_na= me)); _FDT(fdt_setprop(fdt, node_offset, "interrupts", interrupts, diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index b74f2632ecc6..24f95a400623 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2066,7 +2066,7 @@ static void spapr_phb_pci_enumerate(sPAPRPHBState *ph= b) =20 } =20 -int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t xics_phandle, void = *fdt, +int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t intc_phandle, void = *fdt, uint32_t nr_msis) { int bus_off, i, j, ret; @@ -2164,8 +2164,8 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_= t xics_phandle, void *fdt, irqmap[1] =3D 0; irqmap[2] =3D 0; irqmap[3] =3D cpu_to_be32(j+1); - irqmap[4] =3D cpu_to_be32(xics_phandle); - spapr_dt_xics_irq(&irqmap[5], phb->lsi_table[lsi_num].irq, tru= e); + irqmap[4] =3D cpu_to_be32(intc_phandle); + spapr_dt_intc_irq(&irqmap[5], phb->lsi_table[lsi_num].irq, tru= e); } } /* Write interrupt map */ diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index 7e8a9ad09337..cfd9849d8dfb 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -158,7 +158,7 @@ static int vio_make_devnode(VIOsPAPRDevice *dev, if (dev->irq) { uint32_t ints_prop[2]; =20 - spapr_dt_xics_irq(ints_prop, dev->irq, false); + spapr_dt_intc_irq(ints_prop, dev->irq, false); ret =3D fdt_setprop(fdt, node_off, "interrupts", ints_prop, sizeof(ints_prop)); if (ret < 0) { diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 4eb3a2ce3eb8..e0e683c32469 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -113,7 +113,7 @@ static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRP= HBState *phb, int pin) return spapr_qirq(spapr, phb->lsi_table[pin].irq); } =20 -int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t xics_phandle, void = *fdt, +int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t intc_phandle, void = *fdt, uint32_t nr_msis); =20 void spapr_pci_rtas_init(void); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 9e01a5a12e4a..7193ce094689 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -682,7 +682,7 @@ void spapr_load_rtas(sPAPRMachineState *spapr, void *fd= t, hwaddr addr); * "interrupt-controller" node has its "#interrupt-cells" property set to = 2 (ie, * VIO devices, RTAS event sources and PHBs). */ -static inline void spapr_dt_xics_irq(uint32_t *intspec, int irq, bool is_l= si) +static inline void spapr_dt_intc_irq(uint32_t *intspec, int irq, bool is_l= si) { intspec[0] =3D cpu_to_be32(irq); intspec[1] =3D is_lsi ? cpu_to_be32(1) : 0; From nobody Fri Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547240665626147.88806580622963; Fri, 11 Jan 2019 13:04:25 -0800 (PST) Received: from localhost ([127.0.0.1]:57034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3ya-0006J1-G5 for importer@patchew.org; Fri, 11 Jan 2019 16:04:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3vw-0004np-PQ for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:01:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3vu-0001hR-Pg for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:01:40 -0500 Received: from 14.mo3.mail-out.ovh.net ([188.165.43.98]:43118) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3vs-0001dK-PR for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:01:38 -0500 Received: from player726.ha.ovh.net (unknown [10.109.143.216]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 10A631F0ACC for ; Fri, 11 Jan 2019 22:01: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 player726.ha.ovh.net (Postfix) with ESMTPSA id D188A1806C1F; Fri, 11 Jan 2019 21:01:11 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:01:11 +0100 Message-ID: <154724047146.525985.16163962086149442020.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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: 300052325358213426 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 188.165.43.98 Subject: [Qemu-devel] [PATCH v2 03/13] 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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. The unrealize function is able to cope with partially realized PHBs. It is hence used to implement proper rollback on the realize error path. Signed-off-by: Michael Roth Signed-off-by: Greg Kurz Reviewed-by: Michael S. Tsirkin --- v2: - implement rollback with unrealize function --- hw/ppc/spapr_pci.c | 73 +++++++++++++++++++++++++++++++++++++++= +--- include/hw/pci-host/spapr.h | 4 ++ 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 24f95a400623..0d680b71b5d6 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1559,6 +1559,64 @@ 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); + + if (sphb->msi) { + g_hash_table_unref(sphb->msi); + sphb->msi =3D NULL; + } + + /* + * 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]); + if (tcet) { + memory_region_del_subregion(&sphb->iommu_root, + spapr_tce_get_iommu(tcet)); + } + } + + for (i =3D PCI_NUM_PINS - 1; i >=3D 0; i--) { + if (sphb->lsi_table[i].irq) { + spapr_irq_free(spapr, sphb->lsi_table[i].irq, 1); + sphb->lsi_table[i].irq =3D 0; + } + } + + 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 @@ -1576,8 +1634,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); =20 if (!spapr) { error_setg(errp, TYPE_SPAPR_PCI_HOST_BRIDGE " needs a pseries mach= ine"); @@ -1734,14 +1791,14 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) if (local_err) { error_propagate_prepend(errp, local_err, "can't allocate LSIs: "); - return; + goto unrealize; } } =20 spapr_irq_claim(spapr, irq, true, &local_err); if (local_err) { error_propagate_prepend(errp, local_err, "can't allocate LSIs:= "); - return; + goto unrealize; } =20 sphb->lsi_table[i].irq =3D irq; @@ -1761,13 +1818,17 @@ 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; + goto unrealize; } 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; + +unrealize: + spapr_phb_unrealize(dev, NULL); } =20 static int spapr_phb_children_reset(Object *child, void *opaque) @@ -1966,6 +2027,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; @@ -1981,6 +2043,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 e0e683c32469..16f42d0c0254 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -164,4 +164,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 Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547240805164557.2516648494201; Fri, 11 Jan 2019 13:06:45 -0800 (PST) Received: from localhost ([127.0.0.1]:57609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi40k-0007zd-0w for importer@patchew.org; Fri, 11 Jan 2019 16:06:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3wF-00051l-52 for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:02:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3wE-0001rj-1v for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:01:59 -0500 Received: from 10.mo173.mail-out.ovh.net ([46.105.74.148]:45560) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3wD-0001rH-Sp for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:01:58 -0500 Received: from player730.ha.ovh.net (unknown [10.109.160.226]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id 77F42E8FCF for ; Fri, 11 Jan 2019 22:01:56 +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 1D4A9177A1AB; Fri, 11 Jan 2019 21:01:36 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:01:35 +0100 Message-ID: <154724049571.525985.13385611401284661365.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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: 307370676861638962 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.74.148 Subject: [Qemu-devel] [PATCH v2 04/13] 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost 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 Reviewed-by: Michael S. Tsirkin --- hw/ppc/spapr.c | 13 +++++++++++++ hw/ppc/spapr_drc.c | 17 +++++++++++++++++ include/hw/ppc/spapr.h | 1 + include/hw/ppc/spapr_drc.h | 8 ++++++++ 4 files changed, 39 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 26f8e55cc25e..9eeb6792e261 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2797,6 +2797,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.h b/include/hw/ppc/spapr.h index 7193ce094689..4eb80c3d888c 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 dr_phb_enabled; /* enable dynamic-reconfig/hotplug of PHBs = */ 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; 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 Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 154724082287916.43723966743414; Fri, 11 Jan 2019 13:07:02 -0800 (PST) Received: from localhost ([127.0.0.1]:57690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi415-0008GT-HP for importer@patchew.org; Fri, 11 Jan 2019 16:07:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3wg-0005Kw-U4 for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:02:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3wf-00022p-0o for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:02:26 -0500 Received: from 5.mo4.mail-out.ovh.net ([188.165.44.50]:37532) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3wc-00021H-V5 for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:02:24 -0500 Received: from player763.ha.ovh.net (unknown [10.109.160.46]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 68E901C6C7C for ; Fri, 11 Jan 2019 22:02:21 +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 player763.ha.ovh.net (Postfix) with ESMTPSA id 02A3D1931D35; Fri, 11 Jan 2019 21:02:01 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:02:01 +0100 Message-ID: <154724052141.525985.14534597290520128299.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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: 314407551302408498 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 188.165.44.50 Subject: [Qemu-devel] [PATCH v2 05/13] 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost 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 Reviewed-by: Michael S. Tsirkin --- hw/ppc/spapr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 9eeb6792e261..ef8984286587 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 Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547241013828212.65006405315341; Fri, 11 Jan 2019 13:10:13 -0800 (PST) Received: from localhost ([127.0.0.1]:58469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi44C-0002Pi-OP for importer@patchew.org; Fri, 11 Jan 2019 16:10:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3x6-0005ec-JN for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:02:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3x4-0002BW-1D for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:02:52 -0500 Received: from 7.mo2.mail-out.ovh.net ([188.165.48.182]:52036) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3x2-00029t-Ht for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:02:49 -0500 Received: from player734.ha.ovh.net (unknown [10.109.159.224]) by mo2.mail-out.ovh.net (Postfix) with ESMTP id 80EF6176E2F for ; Fri, 11 Jan 2019 22:02:45 +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 player734.ha.ovh.net (Postfix) with ESMTPSA id BC73F1861DBB; Fri, 11 Jan 2019 21:02:26 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:02:26 +0100 Message-ID: <154724054608.525985.11651229273967588290.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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: 321162948996471090 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 188.165.48.182 Subject: [Qemu-devel] [PATCH v2 06/13] 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost 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 Reviewed-by: Michael S. Tsirkin --- 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 d4e75211954d..6cd640b700dd 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 Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547241005117938.1987518593608; Fri, 11 Jan 2019 13:10:05 -0800 (PST) Received: from localhost ([127.0.0.1]:58442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi443-0002G4-Uk for importer@patchew.org; Fri, 11 Jan 2019 16:10:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3xj-00064i-9y for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:03:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3xg-0002S6-LI for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:03:30 -0500 Received: from 3.mo173.mail-out.ovh.net ([46.105.34.1]:60292) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3xe-0002Iv-Kl for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:03:28 -0500 Received: from player729.ha.ovh.net (unknown [10.109.146.106]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id 44308E7682 for ; Fri, 11 Jan 2019 22:03: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 player729.ha.ovh.net (Postfix) with ESMTPSA id BAB1D1BC9411; Fri, 11 Jan 2019 21:02:50 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:02:50 +0100 Message-ID: <154724057022.525985.2498693456915341883.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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: 327355401488144690 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.34.1 Subject: [Qemu-devel] [PATCH v2 07/13] 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost 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 Acked-by: Halil Pasic Reviewed-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin --- hw/acpi/pcihp.c | 2 +- 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 +-- 13 files changed, 16 insertions(+), 24 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 7bc7a723407b..942918132376 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -251,7 +251,7 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_= dev, AcpiPciHpState *s, object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) { PCIBus *sec =3D pci_bridge_get_sec_bus(PCI_BRIDGE(pdev)); =20 - qbus_set_hotplug_handler(BUS(sec), DEVICE(hotplug_dev), + qbus_set_hotplug_handler(BUS(sec), OBJECT(hotplug_dev), &error_abort); /* We don't have to overwrite any other hotplug handler yet */ assert(QLIST_EMPTY(&sec->child)); diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 88f9a9ec0912..df8c0db909ce 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -536,7 +536,7 @@ static void piix4_pm_realize(PCIDevice *dev, Error **er= rp) =20 piix4_acpi_system_hot_add_init(pci_address_space_io(dev), pci_get_bus(dev), s); - qbus_set_hotplug_handler(BUS(pci_get_bus(dev)), DEVICE(s), &error_abor= t); + qbus_set_hotplug_handler(BUS(pci_get_bus(dev)), OBJECT(s), &error_abor= t); =20 piix4_pm_add_propeties(s); } 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 2d3d8a047b83..a2287c3eb997 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -534,7 +534,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 45053b39b92c..52ccdc5ae3b9 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -648,7 +648,7 @@ int shpc_init(PCIDevice *d, PCIBus *sec_bus, MemoryRegi= on *bar, shpc_cap_update_dword(d); memory_region_add_subregion(bar, offset, &shpc->mmio); =20 - qbus_set_hotplug_handler(BUS(sec_bus), DEVICE(d), NULL); + qbus_set_hotplug_handler(BUS(sec_bus), OBJECT(d), NULL); =20 d->cap_present |=3D QEMU_PCI_CAP_SHPC; return 0; diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 0d680b71b5d6..be9e01d84eaf 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1737,7 +1737,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 15759b6514a5..c01eed2bd35b 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_plug(HotplugHandler *hotplug_d= ev, DeviceState *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 bc014c1c9fca..e11f6badcc2e 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -427,8 +427,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 Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547241130885172.8886329332713; Fri, 11 Jan 2019 13:12:10 -0800 (PST) Received: from localhost ([127.0.0.1]:59071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi45r-0004BD-EU for importer@patchew.org; Fri, 11 Jan 2019 16:11:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3xu-0006Dz-8r for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:03:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3xq-0002cT-8f for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:03:42 -0500 Received: from 10.mo3.mail-out.ovh.net ([87.98.165.232]:39150) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3xo-0002Wb-8n for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:03:36 -0500 Received: from player799.ha.ovh.net (unknown [10.109.143.246]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 6B7DD1EE14D for ; Fri, 11 Jan 2019 22:03: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 player799.ha.ovh.net (Postfix) with ESMTPSA id 9BE631933C76; Fri, 11 Jan 2019 21:03:12 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:03:12 +0100 Message-ID: <154724059225.525985.4732492675250957133.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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: 334110800460421426 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 87.98.165.232 Subject: [Qemu-devel] [PATCH v2 08/13] 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost 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 Reviewed-by: Michael S. Tsirkin --- 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 ef8984286587..ebb6fbbb2b69 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_INTC, 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 be9e01d84eaf..d8a285cc291d 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2130,7 +2130,7 @@ static void spapr_phb_pci_enumerate(sPAPRPHBState *ph= b) } =20 int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_t intc_phandle, void = *fdt, - uint32_t nr_msis) + uint32_t nr_msis, int *node_offset) { int bus_off, i, j, ret; gchar *nodename; @@ -2185,6 +2185,9 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_= t intc_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 16f42d0c0254..caee5df4d52f 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 intc_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 Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547241013646149.6270964247882; Fri, 11 Jan 2019 13:10:13 -0800 (PST) Received: from localhost ([127.0.0.1]:58473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi44C-0002R3-Ix for importer@patchew.org; Fri, 11 Jan 2019 16:10:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3yC-0006SN-JM for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:04:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3yA-0002oN-RP for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:04:00 -0500 Received: from 8.mo173.mail-out.ovh.net ([46.105.46.122]:38191) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3yA-0002lk-0Q for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:03:58 -0500 Received: from player698.ha.ovh.net (unknown [10.109.143.183]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id 328D3E7B6F for ; Fri, 11 Jan 2019 22:03:55 +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 player698.ha.ovh.net (Postfix) with ESMTPSA id A55D918F905D; Fri, 11 Jan 2019 21:03:36 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:03:36 +0100 Message-ID: <154724061631.525985.17693829495178769590.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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: 340866198667368754 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.46.122 Subject: [Qemu-devel] [PATCH v2 09/13] 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost 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 Reviewed-by: Michael S. Tsirkin --- 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 d8a285cc291d..f2b9066ecabe 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2180,6 +2180,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32_= t intc_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); @@ -2246,6 +2247,14 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb, uint32= _t intc_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 Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547240951665750.4900534392469; Fri, 11 Jan 2019 13:09:11 -0800 (PST) Received: from localhost ([127.0.0.1]:58200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi43B-0001PZ-0W for importer@patchew.org; Fri, 11 Jan 2019 16:09:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3yn-0006uh-OK for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:04:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3yj-0002zF-LH for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:04:37 -0500 Received: from 7.mo3.mail-out.ovh.net ([46.105.57.200]:34753) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3yj-0002up-Eg for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:04:33 -0500 Received: from player696.ha.ovh.net (unknown [10.109.159.132]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id E70F41EEE12 for ; Fri, 11 Jan 2019 22:04:18 +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 player696.ha.ovh.net (Postfix) with ESMTPSA id 7635F1A7A233; Fri, 11 Jan 2019 21:04:00 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:04:00 +0100 Message-ID: <154724064012.525985.14816153453704405652.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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: 347340122840734002 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.57.200 Subject: [Qemu-devel] [PATCH v2 10/13] spapr_irq: Expose the phandle of the interrupt controller 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" This will be used by PHB hotplug in order to create the "interrupt-map" property of the PHB node. Signed-off-by: Greg Kurz Reviewed-by: Michael S. Tsirkin --- hw/intc/spapr_xive.c | 34 ++++++++++++++++++++++++++++++++-- hw/intc/xics_spapr.c | 28 +++++++++++++++++++++++++++- hw/ppc/spapr_irq.c | 13 ++++++++++++- include/hw/ppc/spapr_irq.h | 1 + include/hw/ppc/spapr_xive.h | 2 ++ include/hw/ppc/xics_spapr.h | 2 ++ 6 files changed, 76 insertions(+), 4 deletions(-) diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index d391177ab81f..ffae680024d7 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -1414,6 +1414,12 @@ void spapr_xive_hcall_init(sPAPRMachineState *spapr) spapr_register_hypercall(H_INT_RESET, h_int_reset); } =20 +static gchar *xive_nodename(sPAPRXive *xive) +{ + return g_strdup_printf("interrupt-controller@%" PRIx64, + 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) { @@ -1450,8 +1456,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 xive_nodename(xive); _FDT(node =3D fdt_add_subnode(fdt, 0, nodename)); g_free(nodename); =20 @@ -1479,3 +1484,28 @@ void spapr_dt_xive(sPAPRMachineState *spapr, uint32_= t nr_servers, void *fdt, _FDT(fdt_setprop(fdt, 0, "ibm,plat-res-int-priorities", plat_res_int_priorities, sizeof(plat_res_int_prioriti= es))); } + +uint32_t spapr_get_phandle_xive(sPAPRMachineState *spapr, void *fdt, + Error **errp) +{ + gchar *nodename =3D xive_nodename(spapr->xive); + int phandle =3D -1, offset; + + offset =3D fdt_subnode_offset(fdt, 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(phandle)); + goto out; + } + +out: + g_free(nodename); + return phandle; +} diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index de6cc15b6474..7763b81d90dd 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -35,6 +35,7 @@ #include "hw/ppc/xics_spapr.h" #include "hw/ppc/fdt.h" #include "qapi/visitor.h" +#include "qapi/error.h" =20 /* * Guest interfaces @@ -245,6 +246,8 @@ void xics_spapr_init(sPAPRMachineState *spapr) spapr_register_hypercall(H_IPOLL, h_ipoll); } =20 +#define NODENAME "interrupt-controller" + void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, uint32_t phandle) { @@ -253,7 +256,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")); @@ -266,3 +269,26 @@ void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t = nr_servers, void *fdt, _FDT(fdt_setprop_cell(fdt, node, "linux,phandle", phandle)); _FDT(fdt_setprop_cell(fdt, node, "phandle", phandle)); } + +uint32_t spapr_get_phandle_xics(sPAPRMachineState *spapr, void *fdt, + Error **errp) +{ + int phandle =3D -1, offset; + + offset =3D fdt_subnode_offset(fdt, 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(phandle)); + goto out; + } + +out: + return phandle; +} diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 1da7a32348fc..ba0df9ae2e1b 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -255,6 +255,7 @@ sPAPRIrq spapr_irq_xics =3D { .post_load =3D spapr_irq_post_load_xics, .reset =3D spapr_irq_reset_xics, .set_irq =3D spapr_irq_set_irq_xics, + .get_phandle =3D spapr_get_phandle_xics, }; =20 /* @@ -411,6 +412,7 @@ sPAPRIrq spapr_irq_xive =3D { .post_load =3D spapr_irq_post_load_xive, .reset =3D spapr_irq_reset_xive, .set_irq =3D spapr_irq_set_irq_xive, + .get_phandle =3D spapr_get_phandle_xive, }; =20 /* @@ -569,6 +571,13 @@ static void spapr_irq_set_irq_dual(void *opaque, int s= rcno, int val) spapr_irq_current(spapr)->set_irq(spapr, srcno, val); } =20 +static uint32_t spapr_irq_get_phandle_dual(sPAPRMachineState *spapr, void = *fdt, + Error **errp) +{ + return spapr_irq_current(spapr)->get_phandle(spapr, fdt, errp); +} + + /* * Define values in sync with the XIVE and XICS backend */ @@ -589,7 +598,8 @@ sPAPRIrq spapr_irq_dual =3D { .cpu_intc_create =3D spapr_irq_cpu_intc_create_dual, .post_load =3D spapr_irq_post_load_dual, .reset =3D spapr_irq_reset_dual, - .set_irq =3D spapr_irq_set_irq_dual + .set_irq =3D spapr_irq_set_irq_dual, + .get_phandle =3D spapr_irq_get_phandle_dual, }; =20 /* @@ -706,4 +716,5 @@ sPAPRIrq spapr_irq_xics_legacy =3D { .cpu_intc_create =3D spapr_irq_cpu_intc_create_xics, .post_load =3D spapr_irq_post_load_xics, .set_irq =3D spapr_irq_set_irq_xics, + .get_phandle =3D spapr_get_phandle_xics, }; diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index 14b02c3aca33..990743a23582 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -47,6 +47,7 @@ typedef struct sPAPRIrq { int (*post_load)(sPAPRMachineState *spapr, int version_id); void (*reset)(sPAPRMachineState *spapr, Error **errp); void (*set_irq)(void *opaque, int srcno, int val); + uint32_t (*get_phandle)(sPAPRMachineState *spapr, void *fdt, Error **e= rrp); } sPAPRIrq; =20 extern sPAPRIrq spapr_irq_xics; diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h index 7fdc25057420..53a34f14b258 100644 --- a/include/hw/ppc/spapr_xive.h +++ b/include/hw/ppc/spapr_xive.h @@ -49,4 +49,6 @@ void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_= servers, void *fdt, void spapr_xive_set_tctx_os_cam(XiveTCTX *tctx); void spapr_xive_mmio_set_enabled(sPAPRXive *xive, bool enable); =20 +uint32_t spapr_get_phandle_xive(sPAPRMachineState *spapr, void *fdt, + Error **errp); #endif /* PPC_SPAPR_XIVE_H */ diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h index b1ab27d022cf..8899c5346375 100644 --- a/include/hw/ppc/xics_spapr.h +++ b/include/hw/ppc/xics_spapr.h @@ -31,6 +31,8 @@ =20 void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, uint32_t phandle); +uint32_t spapr_get_phandle_xics(sPAPRMachineState *spapr, void *fdt, + Error **errp); int xics_kvm_init(sPAPRMachineState *spapr, Error **errp); void xics_spapr_init(sPAPRMachineState *spapr); =20 From nobody Fri Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547241207162203.09031724909573; Fri, 11 Jan 2019 13:13:27 -0800 (PST) Received: from localhost ([127.0.0.1]:59468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi47K-0004rl-4v for importer@patchew.org; Fri, 11 Jan 2019 16:13:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi3yv-00070i-MG for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:04:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi3yu-00035a-AG for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:04:45 -0500 Received: from 9.mo177.mail-out.ovh.net ([46.105.72.238]:59667) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi3yu-00034h-1W for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:04:44 -0500 Received: from player691.ha.ovh.net (unknown [10.109.159.154]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id BC7AFD9B7E for ; Fri, 11 Jan 2019 22:04:42 +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 player691.ha.ovh.net (Postfix) with ESMTPSA id 375E51AB9D7B; Fri, 11 Jan 2019 21:04:24 +0000 (UTC) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:04:23 +0100 Message-ID: <154724066386.525985.7102226604937744914.stgit@bahia.lan> In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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: 354095522168478002 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrfeehgddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 46.105.72.238 Subject: [Qemu-devel] [PATCH v2 11/13] spapr_irq: Allow synchronization of a single irq state to KVM 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" When using the in-kernel interrupt controller, the state of all irqs is synchronized to KVM at machine reset time. In the case of PHB hotplug, we will need to synchronize LSIs manually. Do this for the existing KVM XICS implementation and put a placeholder for the upcoming KVM XIVE. Signed-off-by: Greg Kurz Reviewed-by: Michael S. Tsirkin --- hw/intc/xics_kvm.c | 67 +++++++++++++++++++++++++---------------= ---- hw/ppc/spapr_irq.c | 31 ++++++++++++++++++++ include/hw/ppc/spapr_irq.h | 2 + include/hw/ppc/xics.h | 2 + 4 files changed, 73 insertions(+), 29 deletions(-) diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index dff13300504c..d3bbb2bcf19c 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -253,43 +253,52 @@ static void ics_synchronize_state(ICSState *ics) ics_get_kvm_state(ics); } =20 -static int ics_set_kvm_state(ICSState *ics, int version_id) +int ics_set_kvm_state_one(ICSState *ics, unsigned srcno, Error **errp) { + ICSIRQState *irq; uint64_t state; - int i; - Error *local_err =3D NULL; =20 - for (i =3D 0; i < ics->nr_irqs; i++) { - ICSIRQState *irq =3D &ics->irqs[i]; - int ret; + assert(srcno < ics->nr_irqs); =20 - state =3D irq->server; - state |=3D (uint64_t)(irq->saved_priority & KVM_XICS_PRIORITY_MASK) - << KVM_XICS_PRIORITY_SHIFT; - if (irq->priority !=3D irq->saved_priority) { - assert(irq->priority =3D=3D 0xff); - state |=3D KVM_XICS_MASKED; - } + irq =3D &ics->irqs[srcno]; + state =3D irq->server; + state |=3D (uint64_t)(irq->saved_priority & KVM_XICS_PRIORITY_MASK) + << KVM_XICS_PRIORITY_SHIFT; + if (irq->priority !=3D irq->saved_priority) { + assert(irq->priority =3D=3D 0xff); + state |=3D KVM_XICS_MASKED; + } =20 - if (ics->irqs[i].flags & XICS_FLAGS_IRQ_LSI) { - state |=3D KVM_XICS_LEVEL_SENSITIVE; - if (irq->status & XICS_STATUS_ASSERTED) { - state |=3D KVM_XICS_PENDING; - } - } else { - if (irq->status & XICS_STATUS_MASKED_PENDING) { - state |=3D KVM_XICS_PENDING; - } - } - if (irq->status & XICS_STATUS_PRESENTED) { - state |=3D KVM_XICS_PRESENTED; + if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) { + state |=3D KVM_XICS_LEVEL_SENSITIVE; + if (irq->status & XICS_STATUS_ASSERTED) { + state |=3D KVM_XICS_PENDING; } - if (irq->status & XICS_STATUS_QUEUED) { - state |=3D KVM_XICS_QUEUED; + } else { + if (irq->status & XICS_STATUS_MASKED_PENDING) { + state |=3D KVM_XICS_PENDING; } + } + if (irq->status & XICS_STATUS_PRESENTED) { + state |=3D KVM_XICS_PRESENTED; + } + if (irq->status & XICS_STATUS_QUEUED) { + state |=3D KVM_XICS_QUEUED; + } + + return kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURCES, + srcno + ics->offset, &state, true, errp); +} + +static int ics_set_kvm_state(ICSState *ics, int version_id) +{ + int i; + Error *local_err =3D NULL; + + for (i =3D 0; i < ics->nr_irqs; i++) { + int ret; =20 - ret =3D kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURCES, - i + ics->offset, &state, true, &local_err); + ret =3D ics_set_kvm_state_one(ics, i, &local_err); if (local_err) { error_report_err(local_err); return ret; diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index ba0df9ae2e1b..2cf666c2ebc5 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -236,6 +236,17 @@ static void spapr_irq_reset_xics(sPAPRMachineState *sp= apr, Error **errp) /* TODO: create the KVM XICS device */ } =20 +static void spapr_irq_sync_to_kvm_xics(sPAPRMachineState *spapr, int irq, + Error **errp) +{ + MachineState *machine =3D MACHINE(spapr); + ICSState *ics =3D spapr->ics; + + if (kvm_enabled() && machine_kernel_irqchip_allowed(machine)) { + ics_set_kvm_state_one(ics, irq - ics->offset, errp); + } +} + #define SPAPR_IRQ_XICS_NR_IRQS 0x1000 #define SPAPR_IRQ_XICS_NR_MSIS \ (XICS_IRQ_BASE + SPAPR_IRQ_XICS_NR_IRQS - SPAPR_IRQ_MSI) @@ -256,6 +267,7 @@ sPAPRIrq spapr_irq_xics =3D { .reset =3D spapr_irq_reset_xics, .set_irq =3D spapr_irq_set_irq_xics, .get_phandle =3D spapr_get_phandle_xics, + .sync_to_kvm =3D spapr_irq_sync_to_kvm_xics, }; =20 /* @@ -389,6 +401,12 @@ static void spapr_irq_set_irq_xive(void *opaque, int s= rcno, int val) xive_source_set_irq(&spapr->xive->source, srcno, val); } =20 +static void spapr_irq_sync_to_kvm_xive(sPAPRMachineState *spapr, int irq, + Error **errp) +{ + /* TODO: to be implemented when adding KVM XIVE support */ +} + /* * XIVE uses the full IRQ number space. Set it to 8K to be compatible * with XICS. @@ -413,6 +431,7 @@ sPAPRIrq spapr_irq_xive =3D { .reset =3D spapr_irq_reset_xive, .set_irq =3D spapr_irq_set_irq_xive, .get_phandle =3D spapr_get_phandle_xive, + .sync_to_kvm =3D spapr_irq_sync_to_kvm_xive, }; =20 /* @@ -577,6 +596,11 @@ static uint32_t spapr_irq_get_phandle_dual(sPAPRMachin= eState *spapr, void *fdt, return spapr_irq_current(spapr)->get_phandle(spapr, fdt, errp); } =20 +static void spapr_irq_sync_to_kvm_dual(sPAPRMachineState *spapr, int irq, + Error **errp) +{ + spapr_irq_current(spapr)->sync_to_kvm(spapr, irq, errp); +} =20 /* * Define values in sync with the XIVE and XICS backend @@ -600,6 +624,7 @@ sPAPRIrq spapr_irq_dual =3D { .reset =3D spapr_irq_reset_dual, .set_irq =3D spapr_irq_set_irq_dual, .get_phandle =3D spapr_irq_get_phandle_dual, + .sync_to_kvm =3D spapr_irq_sync_to_kvm_dual, }; =20 /* @@ -645,6 +670,11 @@ void spapr_irq_reset(sPAPRMachineState *spapr, Error *= *errp) } } =20 +void spapr_irq_sync_to_kvm(sPAPRMachineState *spapr, int irq, Error **errp) +{ + spapr->irq->sync_to_kvm(spapr, irq, errp); +} + /* * XICS legacy routines - to deprecate one day */ @@ -717,4 +747,5 @@ sPAPRIrq spapr_irq_xics_legacy =3D { .post_load =3D spapr_irq_post_load_xics, .set_irq =3D spapr_irq_set_irq_xics, .get_phandle =3D spapr_get_phandle_xics, + .sync_to_kvm =3D spapr_irq_sync_to_kvm_xics, }; diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index 990743a23582..9c111f3211b3 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -48,6 +48,7 @@ typedef struct sPAPRIrq { void (*reset)(sPAPRMachineState *spapr, Error **errp); void (*set_irq)(void *opaque, int srcno, int val); uint32_t (*get_phandle)(sPAPRMachineState *spapr, void *fdt, Error **e= rrp); + void (*sync_to_kvm)(sPAPRMachineState *spapr, int irq, Error **errp); } sPAPRIrq; =20 extern sPAPRIrq spapr_irq_xics; @@ -61,6 +62,7 @@ void spapr_irq_free(sPAPRMachineState *spapr, int irq, in= t num); qemu_irq spapr_qirq(sPAPRMachineState *spapr, int irq); int spapr_irq_post_load(sPAPRMachineState *spapr, int version_id); void spapr_irq_reset(sPAPRMachineState *spapr, Error **errp); +void spapr_irq_sync_to_kvm(sPAPRMachineState *spapr, int irq, Error **errp= ); =20 /* * XICS legacy routines diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index fad786e8b22d..52de166a2982 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -203,4 +203,6 @@ void icp_resend(ICPState *ss); Object *icp_create(Object *cpu, const char *type, XICSFabric *xi, Error **errp); =20 +int ics_set_kvm_state_one(ICSState *ics, unsigned srcno, Error **errp); + #endif /* XICS_H */ From nobody Fri Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547242477779259.70778786131905; Fri, 11 Jan 2019 13:34:37 -0800 (PST) Received: from localhost ([127.0.0.1]:37354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi4Ro-0000wL-KQ for importer@patchew.org; Fri, 11 Jan 2019 16:34:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi4Pu-0008C3-CG for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:32:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi4BD-00080j-PB for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:17:29 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50630 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi4BC-0007zU-6E for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:17:27 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0BLDg11132927 for ; Fri, 11 Jan 2019 16:17:23 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2pxxsme4tn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 11 Jan 2019 16:17:23 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Jan 2019 21:17:21 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 11 Jan 2019 21:17:16 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0BLHFSb23724272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 11 Jan 2019 21:17:15 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2CECD11C052; Fri, 11 Jan 2019 21:17:15 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B7C511C04C; Fri, 11 Jan 2019 21:17:15 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 11 Jan 2019 21:17:15 +0000 (GMT) Received: from bahia.lan (sig-9-145-42-56.uk.ibm.com [9.145.42.56]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 95CA8220234; Fri, 11 Jan 2019 22:17:13 +0100 (CET) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:17:13 +0100 In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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-TM-AS-GCONF: 00 x-cbid: 19011121-4275-0000-0000-000002FDDA3F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011121-4276-0000-0000-0000380BF038 Message-Id: <154724143303.527341.6106211869690782552.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-11_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=8 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901110168 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v2 12/13] 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Michael S. Tsirkin --- v2: - reworked phandle handling - sync LSIs to KVM --- hw/ppc/spapr.c | 125 ++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/ppc/spapr_drc.c | 1=20 hw/ppc/spapr_pci.c | 27 +++++----- include/hw/ppc/spapr.h | 1=20 4 files changed, 138 insertions(+), 16 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ebb6fbbb2b69..96979caa5b11 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2930,6 +2930,11 @@ 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), + &error_fatal); + } + qemu_register_boot_set(spapr_boot_set, spapr); =20 if (kvm_enabled()) { @@ -3727,6 +3732,112 @@ 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 phandle; + + 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) { + phandle =3D spapr->irq->get_phandle(spapr, spapr->fdt_blob, + &local_err); + if (local_err) { + goto out; + } + } else { + phandle =3D PHANDLE_INTC; + } + + 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: + 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) { @@ -3734,6 +3845,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 @@ -3752,6 +3865,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)) { @@ -3771,6 +3885,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 @@ -3781,6 +3901,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 @@ -3788,7 +3910,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 f2b9066ecabe..6ee285e84efb 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1641,21 +1641,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) { @@ -1873,6 +1859,17 @@ static void spapr_phb_reset(DeviceState *qdev) if (spapr_phb_eeh_available(SPAPR_PCI_HOST_BRIDGE(qdev))) { spapr_phb_vfio_reset(qdev); } + + if (spapr_drc_hotplugged(qdev)) { + sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); + int i; + + for (i =3D 0; i < PCI_NUM_PINS; i++) { + uint32_t irq =3D sphb->lsi_table[i].irq; + + spapr_irq_sync_to_kvm(spapr, irq, &error_abort); + } + } } =20 static Property spapr_phb_properties[] =3D { diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 4eb80c3d888c..92aae58916ff 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -766,6 +766,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); From nobody Fri Apr 19 05:40:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547242563119572.7029309912385; Fri, 11 Jan 2019 13:36:03 -0800 (PST) Received: from localhost ([127.0.0.1]:37811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi4TC-00026w-2R for importer@patchew.org; Fri, 11 Jan 2019 16:36:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gi4Ps-00089e-GZ for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:32:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gi4Bv-0008Bl-54 for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:18:11 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49394) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gi4Bu-0008BW-Qv for qemu-devel@nongnu.org; Fri, 11 Jan 2019 16:18:11 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0BLDedm104279 for ; Fri, 11 Jan 2019 16:18:09 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2pxybvuwy7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 11 Jan 2019 16:18:09 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Jan 2019 21:18:06 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 11 Jan 2019 21:18:02 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0BLI10K63832260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 11 Jan 2019 21:18:01 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4AA3142045; Fri, 11 Jan 2019 21:18:01 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3280B42041; Fri, 11 Jan 2019 21:18:01 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 11 Jan 2019 21:18:01 +0000 (GMT) Received: from bahia.lan (sig-9-145-42-56.uk.ibm.com [9.145.42.56]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id EB23A220234; Fri, 11 Jan 2019 22:17:59 +0100 (CET) From: Greg Kurz To: David Gibson Date: Fri, 11 Jan 2019 22:17:59 +0100 In-Reply-To: <154724039526.525985.3172545257507998890.stgit@bahia.lan> References: <154724039526.525985.3172545257507998890.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-TM-AS-GCONF: 00 x-cbid: 19011121-0020-0000-0000-000003052639 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011121-0021-0000-0000-000021563152 Message-Id: <154724147951.527463.17505220446068348190.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-11_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=920 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901110168 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2 13/13] 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: Thomas Huth , Cornelia Huck , Gerd Hoffmann , Michael Roth , "Michael S. Tsirkin" , Alexey Kardashevskiy , David Hildenbrand , qemu-devel@nongnu.org, Greg Kurz , qemu-s390x@nongnu.org, Dmitry Fleytman , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum , Paolo Bonzini , Eduardo Habkost 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 Reviewed-by: Michael S. Tsirkin --- hw/ppc/spapr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 96979caa5b11..59088203e0b2 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4164,6 +4164,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 { @@ -4229,6 +4230,7 @@ static void spapr_machine_3_1_class_options(MachineCl= ass *mc) compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len); 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);