From patchwork Thu Oct 20 05:12:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 9385937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6DD2960762 for ; Thu, 20 Oct 2016 05:24:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 628C729A62 for ; Thu, 20 Oct 2016 05:24:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5768829A96; Thu, 20 Oct 2016 05:24:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E72F429A62 for ; Thu, 20 Oct 2016 05:24:57 +0000 (UTC) Received: from localhost ([::1]:52496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bx5qb-0008Mn-4T for patchwork-qemu-devel@patchwork.kernel.org; Thu, 20 Oct 2016 01:24:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bx5eZ-0005fv-BJ for qemu-devel@nongnu.org; Thu, 20 Oct 2016 01:12:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bx5eX-0007Yt-So for qemu-devel@nongnu.org; Thu, 20 Oct 2016 01:12:31 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:46189) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bx5eX-0007WS-5O; Thu, 20 Oct 2016 01:12:29 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3szxkp1s26z9t0p; Thu, 20 Oct 2016 16:12:17 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1476940338; bh=3Q/0MQvAYhLnMhj17e3DePhDRc2QxcLBEkM5J4neY8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LJR0h2cmMjDv/Fnj3rUR4U9Or1/CdvUnxLWq08RRpIwB8d5VZaEVn2kt5UZx2XXdP NpLhA2/0ilPgDgdlfABoP8efCqqy0lHLmMXv+exaO+6y0jUeBuJT+B95q4vdRG/mpZ TUoWmsFSdk6CmjMbVBcL8jYM5ZY1Wtylf+lNacjM= From: David Gibson To: aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, groug@kaod.org Date: Thu, 20 Oct 2016 16:12:09 +1100 Message-Id: <1476940330-27705-13-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476940330-27705-1-git-send-email-david@gibson.dropbear.id.au> References: <1476940330-27705-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PATCH 12/13] spapr: Consolidate construction of /vdevice device tree 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: lvivier@redhat.com, thuth@redhat.com, agraf@suse.de, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Construction of the /vdevice node (and its children) is divided between spapr_create_fdt_skel() (at init time), which creates the base node, and spapr_populate_vdevice() (at reset time) which creates the nodes for each individual virtual device. This consolidates both into a single function called from spapr_build_fdt(). Signed-off-by: David Gibson Reviewed-by: Thomas Huth --- hw/ppc/spapr.c | 19 ++----------------- hw/ppc/spapr_vio.c | 23 ++++++++++++++++------- include/hw/ppc/spapr_vio.h | 2 +- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 68dfc0a..2ecac4e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -316,18 +316,6 @@ static void *spapr_create_fdt_skel(sPAPRMachineState *spapr) _FDT((fdt_property_cell(fdt, "#address-cells", 0x2))); _FDT((fdt_property_cell(fdt, "#size-cells", 0x2))); - /* vdevice */ - _FDT((fdt_begin_node(fdt, "vdevice"))); - - _FDT((fdt_property_string(fdt, "device_type", "vdevice"))); - _FDT((fdt_property_string(fdt, "compatible", "IBM,vdevice"))); - _FDT((fdt_property_cell(fdt, "#address-cells", 0x1))); - _FDT((fdt_property_cell(fdt, "#size-cells", 0x0))); - _FDT((fdt_property_cell(fdt, "#interrupt-cells", 0x2))); - _FDT((fdt_property(fdt, "interrupt-controller", NULL, 0))); - - _FDT((fdt_end_node(fdt))); - _FDT((fdt_end_node(fdt))); /* close root node */ _FDT((fdt_finish(fdt))); @@ -943,11 +931,8 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, exit(1); } - ret = spapr_populate_vdevice(spapr->vio_bus, fdt); - if (ret < 0) { - error_report("couldn't setup vio devices in fdt"); - exit(1); - } + /* /vdevice */ + spapr_dt_vdevice(spapr->vio_bus, fdt); if (object_resolve_path_type("", TYPE_SPAPR_RNG, NULL)) { ret = spapr_rng_populate_dt(fdt); diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index 2b67df0..cc1e09c 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -36,6 +36,7 @@ #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "hw/ppc/xics.h" +#include "hw/ppc/fdt.h" #include "trace.h" #include @@ -624,11 +625,21 @@ static int compare_reg(const void *p1, const void *p2) return 1; } -int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt) +void spapr_dt_vdevice(VIOsPAPRBus *bus, void *fdt) { DeviceState *qdev, **qdevs; BusChild *kid; int i, num, ret = 0; + int node; + + _FDT(node = fdt_add_subnode(fdt, 0, "vdevice")); + + _FDT(fdt_setprop_string(fdt, node, "device_type", "vdevice")); + _FDT(fdt_setprop_string(fdt, node, "compatible", "IBM,vdevice")); + _FDT(fdt_setprop_cell(fdt, node, "#address-cells", 1)); + _FDT(fdt_setprop_cell(fdt, node, "#size-cells", 0)); + _FDT(fdt_setprop_cell(fdt, node, "#interrupt-cells", 2)); + _FDT(fdt_setprop(fdt, node, "interrupt-controller", NULL, 0)); /* Count qdevs on the bus list */ num = 0; @@ -650,19 +661,17 @@ int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt) * to know that will mean they are in forward order in the tree. */ for (i = num - 1; i >= 0; i--) { VIOsPAPRDevice *dev = (VIOsPAPRDevice *)(qdevs[i]); + VIOsPAPRDeviceClass *vdc = VIO_SPAPR_DEVICE_GET_CLASS(dev); ret = vio_make_devnode(dev, fdt); - if (ret < 0) { - goto out; + error_report("Couldn't create device node /vdevice/%s@%"PRIx32, + vdc->dt_name, dev->reg); + exit(1); } } - ret = 0; -out: g_free(qdevs); - - return ret; } gchar *spapr_vio_stdout_path(VIOsPAPRBus *bus) diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index a0e7542..14f5022 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -80,7 +80,7 @@ struct VIOsPAPRBus { extern VIOsPAPRBus *spapr_vio_bus_init(void); extern VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg); -extern int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt); +void spapr_dt_vdevice(VIOsPAPRBus *bus, void *fdt); extern gchar *spapr_vio_stdout_path(VIOsPAPRBus *bus); static inline qemu_irq spapr_vio_qirq(VIOsPAPRDevice *dev)