From nobody Fri Nov 7 13:05:15 2025 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 1547746465002318.6679501312144; Thu, 17 Jan 2019 09:34:25 -0800 (PST) Received: from localhost ([127.0.0.1]:48793 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkBYd-0000XR-Em for importer@patchew.org; Thu, 17 Jan 2019 12:34:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkBH0-00036p-D5 for qemu-devel@nongnu.org; Thu, 17 Jan 2019 12:16:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkBGy-0001DA-VE for qemu-devel@nongnu.org; Thu, 17 Jan 2019 12:16:10 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34764 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 1gkBGy-0001Bk-Ot for qemu-devel@nongnu.org; Thu, 17 Jan 2019 12:16:08 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0HHESON017183 for ; Thu, 17 Jan 2019 12:16:08 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2q2whj97y8-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 17 Jan 2019 12:16:07 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 Jan 2019 17:16:05 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 17 Jan 2019 17:16:01 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0HHG0WW38600820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 17 Jan 2019 17:16:00 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25681A405B; Thu, 17 Jan 2019 17:16:00 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 07C16A4054; Thu, 17 Jan 2019 17:16:00 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 17 Jan 2019 17:15:59 +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 CA95A220129; Thu, 17 Jan 2019 18:15:58 +0100 (CET) From: Greg Kurz To: David Gibson Date: Thu, 17 Jan 2019 18:15:58 +0100 In-Reply-To: <154774526588.1208625.11295698301887807297.stgit@bahia.lan> References: <154774526588.1208625.11295698301887807297.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: 19011717-0012-0000-0000-000002E96360 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011717-0013-0000-0000-000021208091 Message-Id: <154774535838.1208625.13126682782876422159.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-01-17_05:, , 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=876 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901170123 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 v3 14/19] spapr: Factor out setting of "phandle" DT property to sPAPR irq frontend 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" The setting of the "phandle" and "linux,phandle" properties of the interrupt controller node is duplicate code in XICS and XIVE. Move it to a new spapr_irq_dt_populate() function. Note that for XIVE, we set the "ibm,plat-res-int-priorities" machine property earlier so that the offset returned by fdt_add_subnode() can be safely returned to the caller. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater --- hw/intc/spapr_xive.c | 21 +++++++++------------ hw/intc/xics_spapr.c | 7 +++---- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_irq.c | 17 +++++++++++++---- include/hw/ppc/spapr_irq.h | 6 ++++-- include/hw/ppc/spapr_xive.h | 3 +-- include/hw/ppc/xics_spapr.h | 3 +-- 7 files changed, 32 insertions(+), 27 deletions(-) diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index aab63cfd1178..e542ae59d7fd 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -1411,8 +1411,7 @@ void spapr_xive_hcall_init(sPAPRMachineState *spapr) spapr_register_hypercall(H_INT_RESET, h_int_reset); } =20 -void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, - uint32_t phandle) +int spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt) { sPAPRXive *xive =3D spapr->xive; int node; @@ -1439,6 +1438,13 @@ void spapr_dt_xive(sPAPRMachineState *spapr, uint32_= t nr_servers, void *fdt, }; gchar *nodename; =20 + /* + * The "ibm,plat-res-int-priorities" property defines the priority + * ranges reserved by the hypervisor + */ + _FDT(fdt_setprop(fdt, 0, "ibm,plat-res-int-priorities", + plat_res_int_priorities, sizeof(plat_res_int_prioriti= es))); + /* Thread Interrupt Management Area : User (ring 3) and OS (ring 2) */ timas[0] =3D cpu_to_be64(xive->tm_base + XIVE_TM_USER_PAGE * (1ull << TM_SHIFT)); @@ -1465,14 +1471,5 @@ void spapr_dt_xive(sPAPRMachineState *spapr, uint32_= t nr_servers, void *fdt, _FDT(fdt_setprop(fdt, node, "interrupt-controller", NULL, 0)); _FDT(fdt_setprop_cell(fdt, node, "#interrupt-cells", 2)); =20 - /* For SLOF */ - _FDT(fdt_setprop_cell(fdt, node, "linux,phandle", phandle)); - _FDT(fdt_setprop_cell(fdt, node, "phandle", phandle)); - - /* - * The "ibm,plat-res-int-priorities" property defines the priority - * ranges reserved by the hypervisor - */ - _FDT(fdt_setprop(fdt, 0, "ibm,plat-res-int-priorities", - plat_res_int_priorities, sizeof(plat_res_int_prioriti= es))); + return node; } diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c index de6cc15b6474..375cb883c86d 100644 --- a/hw/intc/xics_spapr.c +++ b/hw/intc/xics_spapr.c @@ -245,8 +245,7 @@ void xics_spapr_init(sPAPRMachineState *spapr) spapr_register_hypercall(H_IPOLL, h_ipoll); } =20 -void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, - uint32_t phandle) +int spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt) { uint32_t interrupt_server_ranges_prop[] =3D { 0, cpu_to_be32(nr_servers), @@ -263,6 +262,6 @@ void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t n= r_servers, void *fdt, interrupt_server_ranges_prop, sizeof(interrupt_server_ranges_prop))); _FDT(fdt_setprop_cell(fdt, node, "#interrupt-cells", 2)); - _FDT(fdt_setprop_cell(fdt, node, "linux,phandle", phandle)); - _FDT(fdt_setprop_cell(fdt, node, "phandle", phandle)); + + return node; } diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 2c8d0c0e149c..135136b4cf5f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1275,7 +1275,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, _FDT(fdt_setprop_cell(fdt, 0, "#size-cells", 2)); =20 /* /interrupt controller */ - spapr->irq->dt_populate(spapr, spapr_max_server_number(spapr), fdt, + spapr_irq_dt_populate(spapr, spapr_max_server_number(spapr), fdt, PHANDLE_INTC); =20 ret =3D spapr_populate_memory(spapr, fdt); diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index 396dd09bdbe0..b3e0713428ed 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -11,6 +11,7 @@ #include "qemu/log.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "hw/ppc/fdt.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_xive.h" #include "hw/ppc/xics.h" @@ -536,11 +537,10 @@ static void spapr_irq_print_info_dual(sPAPRMachineSta= te *spapr, Monitor *mon) spapr_irq_current(spapr)->print_info(spapr, mon); } =20 -static void spapr_irq_dt_populate_dual(sPAPRMachineState *spapr, - uint32_t nr_servers, void *fdt, - uint32_t phandle) +static int spapr_irq_dt_populate_dual(sPAPRMachineState *spapr, + uint32_t nr_servers, void *fdt) { - spapr_irq_current(spapr)->dt_populate(spapr, nr_servers, fdt, phandle); + return spapr_irq_current(spapr)->dt_populate(spapr, nr_servers, fdt); } =20 static void spapr_irq_cpu_intc_create_dual(sPAPRMachineState *spapr, @@ -671,6 +671,15 @@ void spapr_irq_reset(sPAPRMachineState *spapr, Error *= *errp) } } =20 +void spapr_irq_dt_populate(sPAPRMachineState *spapr, uint32_t nr_servers, + void *fdt, uint32_t phandle) +{ + int node =3D spapr->irq->dt_populate(spapr, nr_servers, fdt); + + _FDT(fdt_setprop_cell(fdt, node, "linux,phandle", phandle)); + _FDT(fdt_setprop_cell(fdt, node, "phandle", phandle)); +} + /* * XICS legacy routines - to deprecate one day */ diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h index 42b325eb51ba..dfed6b7e9976 100644 --- a/include/hw/ppc/spapr_irq.h +++ b/include/hw/ppc/spapr_irq.h @@ -41,8 +41,8 @@ typedef struct sPAPRIrq { void (*free)(sPAPRMachineState *spapr, int irq, int num); qemu_irq (*qirq)(sPAPRMachineState *spapr, int irq); void (*print_info)(sPAPRMachineState *spapr, Monitor *mon); - void (*dt_populate)(sPAPRMachineState *spapr, uint32_t nr_servers, - void *fdt, uint32_t phandle); + int (*dt_populate)(sPAPRMachineState *spapr, uint32_t nr_servers, + void *fdt); void (*cpu_intc_create)(sPAPRMachineState *spapr, PowerPCCPU *cpu, Error **errp); int (*post_load)(sPAPRMachineState *spapr, int version_id); @@ -63,6 +63,8 @@ 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_dt_populate(sPAPRMachineState *spapr, uint32_t nr_servers, + void *fdt, uint32_t phandle); =20 /* * XICS legacy routines diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h index f8854a4a6a18..29dafead9ba0 100644 --- a/include/hw/ppc/spapr_xive.h +++ b/include/hw/ppc/spapr_xive.h @@ -44,8 +44,7 @@ void spapr_xive_pic_print_info(sPAPRXive *xive, Monitor *= mon); typedef struct sPAPRMachineState sPAPRMachineState; =20 void spapr_xive_hcall_init(sPAPRMachineState *spapr); -void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, - uint32_t phandle); +int 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 diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h index b1ab27d022cf..9f51f8621f75 100644 --- a/include/hw/ppc/xics_spapr.h +++ b/include/hw/ppc/xics_spapr.h @@ -29,8 +29,7 @@ =20 #include "hw/ppc/spapr.h" =20 -void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fd= t, - uint32_t phandle); +int spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt= ); int xics_kvm_init(sPAPRMachineState *spapr, Error **errp); void xics_spapr_init(sPAPRMachineState *spapr); =20