From patchwork Mon Jun 17 14:33:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 167042 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp1089834ock; Mon, 17 Jun 2019 07:42:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqw05bsGcRiISbw3KkUcZCfgaYJXS2+qyigRrOS6bteUZL0Ip5f9mVRX0/WlgRjtpMSi2bdH X-Received: by 2002:a17:906:76c8:: with SMTP id q8mr92168818ejn.229.1560782579616; Mon, 17 Jun 2019 07:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560782579; cv=none; d=google.com; s=arc-20160816; b=nbwjNZeSkUpVpfzCSG+X+BugzYuuxwD5tnj0EyJ5sWxwmipDAfWBqQWrMvAfpKipQC gQXqBO5jiBXxMMxTDnF7N37JpAz0L4M8YLZ5sw694ZKXcVgnK2kEnSD+vBfYnECOw1E9 koPpAb/uoqQagQziM2Dul0FxpoaTT/9jv1h+T7IP+q1uKyY3h2TB25evEQhOSiDeIuxO XTd3QsO2OPaoMpJT8/QXVjsgAuY1SwwqdFO2ByTOvT9o9nOHfweon76cGOlVEP3Qs5LX Wz3AoMd98+c+//HPm9UQzf16kosHsfldUjBPSn0XzxZ7AHi1btSnHQJwDfplDlNm4D0u KraA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=4WOGglriexE6CQruKaZRN4iBHD/0/F+uA+DSiVuMmqg=; b=rK2vX8icCEjGlHGGnm8a1244WQRKKR+P8FO2Q88et4fyqPIGFe8g3Y8Y57iguc4okv 1lP8bLBzLI+vt1OMGYyKzntGc9/prWIxbR2RPmv4vBbV6pb9mth7rvLEAKn32DVahpoI LhZZpG6aki/mBtfMqqkiaYTX4oNUgUwbXdYTXI1A13JL7ArW1lLs+u8O1YGcSxgijOVq CQRPbhuGUaZxz+yZoN+o6JYrunmmQnajKSsvzNkdsoF3p7X8KSQoO7kdMcspenucIlCm iWLZKo3mwhqlykOUbEIncM4J38vy05v4KEHUEa0q4OQPUw0vodF1P98F0xEh/F60zukF rtVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JM4xLuSP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k7si8409823edi.117.2019.06.17.07.42.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Jun 2019 07:42:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JM4xLuSP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcsqY-0003gy-Im for patch@linaro.org; Mon, 17 Jun 2019 10:42:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46655) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcsiJ-0003YJ-HH for qemu-devel@nongnu.org; Mon, 17 Jun 2019 10:34:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcsiH-00083v-5o for qemu-devel@nongnu.org; Mon, 17 Jun 2019 10:34:27 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:41756) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hcsiG-00082k-Sq for qemu-devel@nongnu.org; Mon, 17 Jun 2019 10:34:25 -0400 Received: by mail-wr1-x444.google.com with SMTP id c2so10220246wrm.8 for ; Mon, 17 Jun 2019 07:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=4WOGglriexE6CQruKaZRN4iBHD/0/F+uA+DSiVuMmqg=; b=JM4xLuSPo6UIAnqHtv/qHpAvhqi7lBdsH7h5LMbfw35iHLuLPXKFrh/uCQfPuMPbHW WA6JN7xFrYDiVnRSxGBjJA9M8TA53OIZ5E5K5TnDvYejy2r9XYORgKfF1IeveQQSlBJJ EAiZOLWQgpIwUQkiBZ5HhnoH5DD8f2ixJ0XKIfXG5YBneOgKTcIGtMziA4+x/xT94sSA DckYdGnU/Bwn040Zqx65Qe1Iy+ctOa8mKlXmAfYWxGf1FWoB99krpFy+ewFEUBKeCGAM tf/UBb7Llwb1uHEV5NFf+kb8VlrKHzdisvBsbzrajV32S9P0zK7dwtfhUDrTZXY3jfc1 rjvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4WOGglriexE6CQruKaZRN4iBHD/0/F+uA+DSiVuMmqg=; b=NbH2B6NhK+Z9h7hILIjVneE8TkHfPAY5Flx1Ixq11Xok651QY3vzARTzfJ+QZlrtg+ DpAO3yw4mARTQcMGFeb+Mvqu5xJvTyCIfySxlzyWZuwE5KrqcZ+V1bFV7Wo3w+lt39q3 2Ie5tyLRYDivwBOHlLZ3pqwjXnNeMegZRBXpi3fzsYXtm5Z6ify4B0Weto5hQi+3OW14 rRBAfMoqNNFPM0ipRdflgEjABBJX/DoebsUBBTvfeJ/Ey1I/5c4/loCiZxrAUMPdgwNc /5LF7MvUfE+5g2+nvomfYum6Yr3jnpZYKBEEGYTIj9uBLN8YSFTFe09i+oT/IO9cypMI aW1g== X-Gm-Message-State: APjAAAUzr67pfDodIET6oScpFvwoDFrX7JmXbfm+uIOY23AqywWP2nvl mn33PaxTMDv5qYhgQ4Nlouu/iPR5OYY5Nw== X-Received: by 2002:a5d:5542:: with SMTP id g2mr1590568wrw.232.1560782063298; Mon, 17 Jun 2019 07:34:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a67sm13819985wmh.40.2019.06.17.07.34.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2019 07:34:22 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 15:33:56 +0100 Message-Id: <20190617143412.5734-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190617143412.5734-1-peter.maydell@linaro.org> References: <20190617143412.5734-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 08/24] hw/arm: Correctly disable FPU/DSP for some ARMSSE-based boards X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The SSE-200 hardware has configurable integration settings which determine whether its two CPUs have the FPU and DSP: * CPU0_FPU (default 0) * CPU0_DSP (default 0) * CPU1_FPU (default 1) * CPU1_DSP (default 1) Similarly, the IoTKit has settings for its single CPU: * CPU0_FPU (default 1) * CPU0_DSP (default 1) Of our four boards that use either the IoTKit or the SSE-200: * mps2-an505, mps2-an521 and musca-a use the default settings * musca-b1 enables FPU and DSP on both CPUs Currently QEMU models all these boards using CPUs with both FPU and DSP enabled. This means that we are incorrect for mps2-an521 and musca-a, which should not have FPU or DSP on CPU0. Create QOM properties on the ARMSSE devices corresponding to the default h/w integration settings, and make the Musca-B1 board enable FPU and DSP on both CPUs. This fixes the mps2-an521 and musca-a behaviour, and leaves the musca-b1 and mps2-an505 behaviour unchanged. Signed-off-by: Peter Maydell Reviewed-by: Alex Bennée Message-id: 20190517174046.11146-5-peter.maydell@linaro.org --- include/hw/arm/armsse.h | 7 +++++ hw/arm/armsse.c | 58 ++++++++++++++++++++++++++++++++--------- hw/arm/musca.c | 8 ++++++ 3 files changed, 61 insertions(+), 12 deletions(-) -- 2.20.1 diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h index 81e082cccf8..84080c22993 100644 --- a/include/hw/arm/armsse.h +++ b/include/hw/arm/armsse.h @@ -50,6 +50,11 @@ * address of each SRAM bank (and thus the total amount of internal SRAM) * + QOM property "init-svtor" sets the initial value of the CPU SVTOR register * (where it expects to load the PC and SP from the vector table on reset) + * + QOM properties "CPU0_FPU", "CPU0_DSP", "CPU1_FPU" and "CPU1_DSP" which + * set whether the CPUs have the FPU and DSP features present. The default + * (matching the hardware) is that for CPU0 in an IoTKit and CPU1 in an + * SSE-200 both are present; CPU0 in an SSE-200 has neither. + * Since the IoTKit has only one CPU, it does not have the CPU1_* properties. * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts for CPU 0, * which are wired to its NVIC lines 32 .. n+32 * + Named GPIO inputs "EXP_CPU1_IRQ" 0..n are the expansion interrupts for @@ -208,6 +213,8 @@ typedef struct ARMSSE { uint32_t mainclk_frq; uint32_t sram_addr_width; uint32_t init_svtor; + bool cpu_fpu[SSE_MAX_CPUS]; + bool cpu_dsp[SSE_MAX_CPUS]; } ARMSSE; typedef struct ARMSSEInfo ARMSSEInfo; diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c index 47d13312dc1..b5c614cc3a1 100644 --- a/hw/arm/armsse.c +++ b/hw/arm/armsse.c @@ -38,6 +38,33 @@ struct ARMSSEInfo { bool has_cachectrl; bool has_cpusecctrl; bool has_cpuid; + Property *props; +}; + +static Property iotkit_properties[] = { + DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, + MemoryRegion *), + DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), + DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0), + DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), + DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), + DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), + DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), + DEFINE_PROP_END_OF_LIST() +}; + +static Property armsse_properties[] = { + DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, + MemoryRegion *), + DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), + DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0), + DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), + DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), + DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false), + DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], false), + DEFINE_PROP_BOOL("CPU1_FPU", ARMSSE, cpu_fpu[1], true), + DEFINE_PROP_BOOL("CPU1_DSP", ARMSSE, cpu_dsp[1], true), + DEFINE_PROP_END_OF_LIST() }; static const ARMSSEInfo armsse_variants[] = { @@ -53,6 +80,7 @@ static const ARMSSEInfo armsse_variants[] = { .has_cachectrl = false, .has_cpusecctrl = false, .has_cpuid = false, + .props = iotkit_properties, }, { .name = TYPE_SSE200, @@ -66,6 +94,7 @@ static const ARMSSEInfo armsse_variants[] = { .has_cachectrl = true, .has_cpusecctrl = true, .has_cpuid = true, + .props = armsse_properties, }, }; @@ -533,6 +562,20 @@ static void armsse_realize(DeviceState *dev, Error **errp) return; } } + if (!s->cpu_fpu[i]) { + object_property_set_bool(cpuobj, false, "vfp", &err); + if (err) { + error_propagate(errp, err); + return; + } + } + if (!s->cpu_dsp[i]) { + object_property_set_bool(cpuobj, false, "dsp", &err); + if (err) { + error_propagate(errp, err); + return; + } + } if (i > 0) { memory_region_add_subregion_overlap(&s->cpu_container[i], 0, @@ -1222,16 +1265,6 @@ static const VMStateDescription armsse_vmstate = { } }; -static Property armsse_properties[] = { - DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, - MemoryRegion *), - DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), - DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0), - DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), - DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), - DEFINE_PROP_END_OF_LIST() -}; - static void armsse_reset(DeviceState *dev) { ARMSSE *s = ARMSSE(dev); @@ -1244,13 +1277,14 @@ static void armsse_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(klass); ARMSSEClass *asc = ARMSSE_CLASS(klass); + const ARMSSEInfo *info = data; dc->realize = armsse_realize; dc->vmsd = &armsse_vmstate; - dc->props = armsse_properties; + dc->props = info->props; dc->reset = armsse_reset; iic->check = armsse_idau_check; - asc->info = data; + asc->info = info; } static const TypeInfo armsse_info = { diff --git a/hw/arm/musca.c b/hw/arm/musca.c index 825d80e75a4..ddd8842732c 100644 --- a/hw/arm/musca.c +++ b/hw/arm/musca.c @@ -385,6 +385,14 @@ static void musca_init(MachineState *machine) qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor); qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); qdev_prop_set_uint32(ssedev, "MAINCLK", SYSCLK_FRQ); + /* + * Musca-A takes the default SSE-200 FPU/DSP settings (ie no for + * CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0. + */ + if (mmc->type == MUSCA_B1) { + qdev_prop_set_bit(ssedev, "CPU0_FPU", true); + qdev_prop_set_bit(ssedev, "CPU0_DSP", true); + } object_property_set_bool(OBJECT(&mms->sse), true, "realized", &error_fatal);