From patchwork Tue Jan 22 22:12:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10776365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C7CC1390 for ; Tue, 22 Jan 2019 22:30:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CF612B70E for ; Tue, 22 Jan 2019 22:30:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 213A82B718; Tue, 22 Jan 2019 22:30: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=-2.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CD9BC2B70E for ; Tue, 22 Jan 2019 22:30:57 +0000 (UTC) Received: from localhost ([127.0.0.1]:51587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm4ZN-00063e-7H for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Jan 2019 17:30:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm4W7-000313-D2 for qemu-devel@nongnu.org; Tue, 22 Jan 2019 17:27:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gm4II-0006iT-1T for qemu-devel@nongnu.org; Tue, 22 Jan 2019 17:13:18 -0500 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]:41791) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gm4IH-0006hs-Qw for qemu-devel@nongnu.org; Tue, 22 Jan 2019 17:13:17 -0500 Received: by mail-lf1-x141.google.com with SMTP id c16so85836lfj.8 for ; Tue, 22 Jan 2019 14:13:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wL56fAox7icrdi83CNQLZNN8qExDm9YrJmEUoAEyltY=; b=KsRfzCj5smGwaQ/Pni9Nro9p5lTNd8fmyEbWL4wGzqnL2dIo+40y7A+cqu2AgZNJbh Z/gQNyRNCe9vN14FZXqzT825gqsSgAU/1HOiq5sS+Cs3TudEfVI99Q/va95fHYL3IolL 0hhWni22/N7doPFy8OZG1a3MUzhxpQJtp1gEKHrC2nx+4aEbCMa2Im86unoJgTaO9qq2 3kpaJqmH1CPpWucsAhw1V60UDtupP7pv1jtUqX+I2pUnj4FJu6mcts0AsiqBB3JM/uaA 8n9A6KGEaaCDd0+DJYcPsh2QNmSQ1fClndlDr5Ij3uy+CJMeKNSE9MTg1OiEVYrKxnjt Hndg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wL56fAox7icrdi83CNQLZNN8qExDm9YrJmEUoAEyltY=; b=nPoiIhvYjpA4vhnicvCYSZ5sI+GyufwFMizvj8Yp+mlgwYPPSBD9OPSb0Co0WMzOSg Vnlg+/EgAG1O/PQLmPA7FnKSMvFdLF91eeoUUAbvKeBv0JUgJGXnE1oWW+L9Ym71vzHw 71EI9YwqikjzGG3NUPLWU4dSp+VMO1ovuvLlQLVB8pgcFYebtqusSPxgs7na6+rdIJvq HtbGJFb59dq0eXUaZDCeFWziQVZ8XeL0V5789QQbg/BNF6+PIoWEPQ/cnUb4I3tL+/bM hl7VKNiHTXspBMWOjKshrg+1DVU0WPAd13AgbaU7e1OpWSoz7j4XkxEzuZYNg1hMlQB3 JOKg== X-Gm-Message-State: AJcUukcVZ2kEJDxi+kbCM91QEfC4zgZep5nvTpGBHe26VNWsrnUL44KZ Sk9UqWvLQL21vmrTVaFmnsJBVFoBRFM= X-Google-Smtp-Source: ALg8bN5tmLZNlSqdtHMZJWI9QBJ10Itp2nxJXMGiav7h/YrKf2mXSb4bBZfFV0qQXb8Jw6/pE/IHIA== X-Received: by 2002:a19:a86:: with SMTP id 128mr21303775lfk.139.1548195195950; Tue, 22 Jan 2019 14:13:15 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id i13-v6sm184404ljg.82.2019.01.22.14.13.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 14:13:15 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Tue, 22 Jan 2019 14:12:55 -0800 Message-Id: <20190122221256.20883-2-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190122221256.20883-1-jcmvbkbc@gmail.com> References: <20190122221256.20883-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::141 Subject: [Qemu-devel] [PATCH 1/2] hw/xtensa: xtfpga: fix bootloader placement in SMP 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: Max Filippov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use BSP reset PC as a place for the mini-bootloader because in SMP configurations APs and BSP may have different boot addresses. This fixes SMP linux uImage boot on xtfpga boards. Signed-off-by: Max Filippov --- hw/xtensa/xtfpga.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 21094319a659..d3afdfc247a7 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -234,10 +234,15 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) int n; for (n = 0; n < smp_cpus; n++) { + CPUXtensaState *cenv = NULL; + cpu = XTENSA_CPU(cpu_create(machine->cpu_type)); - env = &cpu->env; + cenv = &cpu->env; + if (!env) { + env = cenv; + } - env->sregs[PRID] = n; + cenv->sregs[PRID] = n; qemu_register_reset(xtfpga_reset, cpu); /* Need MMU initialized prior to ELF loading, * so that ELF gets loaded into virtual addresses From patchwork Tue Jan 22 22:12:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10776361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AE211390 for ; Tue, 22 Jan 2019 22:29:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0724429D18 for ; Tue, 22 Jan 2019 22:29:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E980F2AE8B; Tue, 22 Jan 2019 22:29:05 +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=-2.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8B8A729D18 for ; Tue, 22 Jan 2019 22:29:05 +0000 (UTC) Received: from localhost ([127.0.0.1]:51516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm4XY-0004jm-Oe for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Jan 2019 17:29:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm4W5-0003Cu-Du for qemu-devel@nongnu.org; Tue, 22 Jan 2019 17:27:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gm4IK-0006jk-GM for qemu-devel@nongnu.org; Tue, 22 Jan 2019 17:13:21 -0500 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]:42114) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gm4IK-0006j0-8u for qemu-devel@nongnu.org; Tue, 22 Jan 2019 17:13:20 -0500 Received: by mail-lj1-x244.google.com with SMTP id l15-v6so99574lja.9 for ; Tue, 22 Jan 2019 14:13:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fKGAMLiGYpzYbr0rT9/NDrMmuQDLMVW75r0dxP9+VxQ=; b=TrCiZkYklJ9UeQlndWaOyI6xlcPQuVaro0NACxndA5iTrKSEfiszN2e6c42gFdcXrN /Te77pM/xQlO0uEjzKllMmmZRbJ8P5Ep7cN46P7FbftMqfyw+fLaoXakY1X30iODvqvB fwtOBDQZcc8scmmQtwDC8zd8wA4LbPaKowXIziZEqAieY/29okXwzqvNyBUZKRAuh48w f1D5c8AUqkdloit2FkGHgE3xNT39jtWOzlJx6iMcLneBREtRMOlWYRapNEMVuPn5o8FF z7c7CjmYbi6POxUiXvgGGsXV26ch3NWAbDFFGhykU4Q7x2QIj7glm6bQf7vBcnbyZkMW 0MbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fKGAMLiGYpzYbr0rT9/NDrMmuQDLMVW75r0dxP9+VxQ=; b=cKgCDMh/r4sJuY3PNibzRCBGPGhrfPW0eo9fO2AW7XhF3pFc2gSHdWWiKtSfX9G9f0 T8byAU98l4jb0iVm2S+/Y+26cBXMCm4nhqgh5yzbKtNoT3k8Si6akKSRbmgyuKE8WzMI AFpsktCKAPgW/FjObxHRXeqnpnLjfeJxH77+SwxdLm0VUbLguapSN+ADnqW6FfXrF2Ub 8CCBPUpmOLNfM4NjUW0MD8fKpmqCEY8s/RdfDiO9hduAHI55HxCN5vWLNkw19PocrAsb DrtZYbmABD/tJl9B8GAPvc0rq5XQTVUdMR0sJk0cHcHcJ699BzGbRxUL6kI/qKvrYXnu f7wg== X-Gm-Message-State: AJcUukcfFQL91H9Egnswc4geiloToRWTPzabRbpKxR4qXq/xmvhuXrfw p6ZnmPoUV6zx2tKetYWP01gnNP7opqo= X-Google-Smtp-Source: ALg8bN6vWJ3+b3WtUKj5ZewlGPLRKeqLYNUPlc6Z8MDQLYSdZymn+rqebSTCXibPQSiGfVzI5xBpcg== X-Received: by 2002:a2e:b04f:: with SMTP id d15-v6mr23525710ljl.3.1548195198362; Tue, 22 Jan 2019 14:13:18 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id i13-v6sm184404ljg.82.2019.01.22.14.13.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 14:13:17 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Tue, 22 Jan 2019 14:12:56 -0800 Message-Id: <20190122221256.20883-3-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190122221256.20883-1-jcmvbkbc@gmail.com> References: <20190122221256.20883-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::244 Subject: [Qemu-devel] [PATCH 2/2] hw/xtensa: xtfpga: use core frequency 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: Max Filippov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP XTFPGA board FPGA peripheral exposes hard-coded 10MHz frequency regardless of the actual used core frequency. Expose actual core frequency instead. Signed-off-by: Max Filippov --- hw/xtensa/xtfpga.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index d3afdfc247a7..7379b3fff427 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -61,6 +61,7 @@ typedef struct XtfpgaBoardDesc { typedef struct XtfpgaFpgaState { MemoryRegion iomem; + uint32_t freq; uint32_t leds; uint32_t switches; } XtfpgaFpgaState; @@ -83,7 +84,7 @@ static uint64_t xtfpga_fpga_read(void *opaque, hwaddr addr, return 0x09272011; case 0x4: /*processor clock frequency, Hz*/ - return 10000000; + return s->freq; case 0x8: /*LEDs (off = 0, on = 1)*/ return s->leds; @@ -119,13 +120,14 @@ static const MemoryRegionOps xtfpga_fpga_ops = { }; static XtfpgaFpgaState *xtfpga_fpga_init(MemoryRegion *address_space, - hwaddr base) + hwaddr base, uint32_t freq) { XtfpgaFpgaState *s = g_malloc(sizeof(XtfpgaFpgaState)); memory_region_init_io(&s->iomem, NULL, &xtfpga_fpga_ops, s, - "xtfpga.fpga", 0x10000); + "xtfpga.fpga", 0x10000); memory_region_add_subregion(address_space, base, &s->iomem); + s->freq = freq; xtfpga_fpga_reset(s); qemu_register_reset(xtfpga_fpga_reset, s); return s; @@ -231,6 +233,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) const char *dtb_filename = qemu_opt_get(machine_opts, "dtb"); const char *initrd_filename = qemu_opt_get(machine_opts, "initrd"); const unsigned system_io_size = 224 * MiB; + uint32_t freq = 10000000; int n; for (n = 0; n < smp_cpus; n++) { @@ -240,6 +243,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) cenv = &cpu->env; if (!env) { env = cenv; + freq = env->config->clock_freq_khz * 1000; } cenv->sregs[PRID] = n; @@ -277,7 +281,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) system_io, 0, system_io_size); memory_region_add_subregion(system_memory, board->io[1], io); } - xtfpga_fpga_init(system_io, 0x0d020000); + xtfpga_fpga_init(system_io, 0x0d020000, freq); if (nd_table[0].used) { xtfpga_net_init(system_io, 0x0d030000, 0x0d030400, 0x0d800000, xtensa_get_extint(env, 1), nd_table);