From patchwork Thu May 19 22:54:18 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: 9128405 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 395D560467 for ; Thu, 19 May 2016 23:01:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C38D1FEDE for ; Thu, 19 May 2016 23:01:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 204B020265; Thu, 19 May 2016 23:01:15 +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 B0DA71FEDE for ; Thu, 19 May 2016 23:01:14 +0000 (UTC) Received: from localhost ([::1]:52463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3WwL-0005VT-Ng for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 May 2016 19:01:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3Wpq-0008Ms-Kt for qemu-devel@nongnu.org; Thu, 19 May 2016 18:54:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b3Wpo-0007GS-AH for qemu-devel@nongnu.org; Thu, 19 May 2016 18:54:29 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3Wpn-0007GD-SJ; Thu, 19 May 2016 18:54:28 -0400 Received: by mail-wm0-x242.google.com with SMTP id w143so24718068wmw.3; Thu, 19 May 2016 15:54:27 -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=QCGqPBJLKgkcxER37u9HTQZlCWjRGLOGCUdmsHYZVSq/szfdrwTQou3HmLgV8n6iSi yrn50eWLOjhoEygU/OfHGVzb5LuJocSTyD2DejfXhYOpTivpw0Ek8+7EZ0bzhnelN9Q3 awkenJN4E5LzaneAtNOHuhpE6TLNB/QQQ5OitFWh+3iD1xMTHOBKI1l7OVHuX65NLN6u GNG+PBnXhGMqpEw1OGhoUH/vEzdJwtjEjlSNhrbvd4VUDfjrmFIgeGObeCAJ3xAcIPXC yTbCHnzOEt5zQLFDQlXRGza6zgG3EqA7t6RekxwWo0S3aELX+ktjFC0S+XVCMGcY5Iwn Fm/w== 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=KTTJolCwMrXTBrTlDiZggXl7npqiPHRVLnZnVosSoThBubl2XFpoiyKVEr+9U/EkXP VOv5qXsEeSoCNViO4cA58PaTdPzW67DTZn6xJNHY+vwF8GHkn6rp51ERo/fTLuMwhrsA 5LsJs1WWO8dfOUzl2en9TnHipEmXjED2094QzrT/skG4UpEflJChs32IUPsW5h2ku6PN 1DE3LtBe6cpJA9SpG7RBsUQtwbSKqq7Umj0Mwx/2XEU9XEGVCXONCYb/pRGM0TtVlSBe ZFRcwCccEyMql/3Ag4FsJdaahmOV45vmnozrf1DuGegDC5IJk11/LqnZDWmL+eUCPAHA k/1Q== X-Gm-Message-State: AOPr4FXq/VMHwCptCjvhjIPy5k8IhA6tVFtJxKtwpFIGHTyZeVX8T24pVhCsPWYgNI/fLw== X-Received: by 10.28.157.143 with SMTP id g137mr208150wme.29.1463698467180; Thu, 19 May 2016 15:54:27 -0700 (PDT) Received: from localhost (81-231-233-234-no56.tbcn.telia.com. [81.231.233.234]) by smtp.gmail.com with ESMTPSA id e8sm16698584wjm.23.2016.05.19.15.54.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 May 2016 15:54:26 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Date: Fri, 20 May 2016 00:54:18 +0200 Message-Id: <1463698459-31312-5-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1463698459-31312-1-git-send-email-edgar.iglesias@gmail.com> References: <1463698459-31312-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: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, crosthwaite.peter@gmail.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 Reviewed-by: Peter Maydell --- 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]),