From patchwork Thu May 19 22:48:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 9128391 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 B5EC16048B for ; Thu, 19 May 2016 22:49:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A96D61FF45 for ; Thu, 19 May 2016 22:49:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E53D20265; Thu, 19 May 2016 22:49:41 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 454201FF45 for ; Thu, 19 May 2016 22:49:41 +0000 (UTC) Received: from localhost ([::1]:52391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3WlA-0003qR-GX for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 May 2016 18:49:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3WkZ-0003lU-Sb for qemu-devel@nongnu.org; Thu, 19 May 2016 18:49:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b3WkX-0006Qu-QW for qemu-devel@nongnu.org; Thu, 19 May 2016 18:49:02 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3WkX-0006Qh-H5; Thu, 19 May 2016 18:49:01 -0400 Received: by mail-wm0-x242.google.com with SMTP id w143so24695094wmw.3; Thu, 19 May 2016 15:49:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eguJGXoW2JNWNoeUK84+yRlcn5YhLOeAn6BAZbSkcLY=; b=z8AMbRXh52/5+ZnRztBQ6EjulP+hye2370+OxODQtTWSq10vRRh6TllSE2IwBFY5QI DT2m6kw/cRcxAKBmHWDNCD8gP2980gt3rRWxzGTiMg3lt2TAg5KnrxfE0AlGCE7d+jpZ 9VnmVsGrs4ieQ17v5WMKI51D+cNHCQW0HgCmyFU+cnMvCFAJZe9+x8271mzURipOX1sk fcGaC5EHxIi2k/41W9m+HoG2eXJ7kLVUzhK/+RrwrnjLa9D7vYNBXuwXOMuSOl7bVrfR lmIqfHJHQ7QYNmeo7GRp/n+x7OlUc6BmLTfhTd3F/CZMASObYXo7h+g6XhdKy0Vt1ygV lvkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eguJGXoW2JNWNoeUK84+yRlcn5YhLOeAn6BAZbSkcLY=; b=kpSGsW4LCfBynj28mYB62eO3FxSRjRipdHDZ3uZMtw5EmOwhHkJKJ9Tf3v+HFRbDzI hqGHhYUUyiEed8/KpEM4GArAMr3xWlFUVT10Q4KDhiFUpnqzAop5SzgbfUAbWta1zVCl Bji1xAqIWXkV/xTCrlIEG8nJnhielIYC3RrZxAy5uxjAHIv7mX0KeP+/UJpJYhjgQEMW XSJ3OztpnOx0lrbSKU4GSRR/F2huR3bDRS3VHoNhisBnXj4V9w/mN/BORIdFd3HX3zqL 11qUVpr4XGgj5zddB3wNkMyyfs8RM2HUijx3jfzUM+RJAHhFsX+PbZOEE7bVISZQyWAW Ddjg== X-Gm-Message-State: AOPr4FWVPCJRGSOqLj99Cd8XqARF0t8+/0AtLMJ/Lz+6x7dsoBz7DT9iqd6wQCtFqrObSQ== X-Received: by 10.28.154.2 with SMTP id c2mr125373wme.9.1463698140885; Thu, 19 May 2016 15:49:00 -0700 (PDT) Received: from localhost (81-231-233-234-no56.tbcn.telia.com. [81.231.233.234]) by smtp.gmail.com with ESMTPSA id i4sm16678325wjj.49.2016.05.19.15.49.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 May 2016 15:49:00 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Date: Fri, 20 May 2016 00:48:52 +0200 Message-Id: <1463698133-30880-5-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1463698133-30880-1-git-send-email-edgar.iglesias@gmail.com> References: <1463698133-30880-1-git-send-email-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH v1 4/5] xlnx-zynqmp: Delay realization of GIC until post CPU realization 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: peter.maydell@linaro.org, crosthwaite.peter@gmail.com, edgar.iglesiasl@xilinx.com, qemu-arm@nongnu.org, alistair.francis@xilinx.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Edgar E. Iglesias" Delay the realization of the GIC until after CPUs are realized. This is needed for KVM as the in-kernel GIC model will fail if it is realized with no available CPUs. Signed-off-by: Edgar E. Iglesias --- hw/arm/xlnx-zynqmp.c | 56 +++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index c180206..0648028 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -258,33 +258,9 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", GIC_NUM_SPI_INTR + 32); qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 2); qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", XLNX_ZYNQMP_NUM_APU_CPUS); - object_property_set_bool(OBJECT(&s->gic), true, "realized", &err); - if (err) { - error_propagate(errp, err); - return; - } - assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions) == XLNX_ZYNQMP_GIC_REGIONS); - for (i = 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) { - SysBusDevice *gic = SYS_BUS_DEVICE(&s->gic); - const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i]; - MemoryRegion *mr = sysbus_mmio_get_region(gic, r->region_index); - uint32_t addr = r->address; - int j; - - sysbus_mmio_map(gic, r->region_index, addr); - - for (j = 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) { - MemoryRegion *alias = &s->gic_mr[i][j]; - - addr += XLNX_ZYNQMP_GIC_REGION_SIZE; - memory_region_init_alias(alias, OBJECT(s), "zynqmp-gic-alias", mr, - 0, XLNX_ZYNQMP_GIC_REGION_SIZE); - memory_region_add_subregion(system_memory, addr, alias); - } - } + /* Realize APUs before realizing the GIC. KVM requires this. */ for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) { - qemu_irq irq; char *name; object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC, @@ -310,6 +286,36 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) error_propagate(errp, err); return; } + } + + object_property_set_bool(OBJECT(&s->gic), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + + assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions) == XLNX_ZYNQMP_GIC_REGIONS); + for (i = 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) { + SysBusDevice *gic = SYS_BUS_DEVICE(&s->gic); + const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i]; + MemoryRegion *mr = sysbus_mmio_get_region(gic, r->region_index); + uint32_t addr = r->address; + int j; + + sysbus_mmio_map(gic, r->region_index, addr); + + for (j = 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) { + MemoryRegion *alias = &s->gic_mr[i][j]; + + addr += XLNX_ZYNQMP_GIC_REGION_SIZE; + memory_region_init_alias(alias, OBJECT(s), "zynqmp-gic-alias", mr, + 0, XLNX_ZYNQMP_GIC_REGION_SIZE); + memory_region_add_subregion(system_memory, addr, alias); + } + } + + for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) { + qemu_irq irq; sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i, qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),