Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp678195pxb; Mon, 25 Oct 2021 16:30:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhV6Xfnpy/ik/n50wb//G/lrIpMxEuFMZvuw4rhKZNU4JLfw8q+SBdCwq/Zs9NuAYgrBQs X-Received: by 2002:a17:906:6149:: with SMTP id p9mr25062477ejl.362.1635204617715; Mon, 25 Oct 2021 16:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635204617; cv=none; d=google.com; s=arc-20160816; b=r9tBtZtlmEnCEaWl56IB9u04E5l8Ytq+SHa21MElCMArCrpKOb+M/X15paNA0WyxJh 18x2LGM9LyXFDJsEyicW332kjAT7xoTlfZ5JSYR81fx7XviRSpn54vogtzkP96pwWjql p8I8mz1HTQI5k8KkNbEsPh40KGa8PDT+PJz0n51TYlAgxM2L2xXALrdJyrOR21V9ubBe MmxsSgNDfO/DwzcFa9xyCzDGTBanbr3idI7KpbkTUy6zWq2P7F43G0u+jbU2AGIi0gLG J1rpZjZqs4eEPxGD6b/f2uGENl5LK6cbLewS3VimvBvbQi+cliK+fiVppF5d5WEW/zwd qGaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KIY0nmlyiVNm1j/VURheTlMIbJqpuZU2zmPD2qfDMhs=; b=D+141SDf+vEafB8v8zIVtOpD+BWj6r3bVUkYpUv4e6FIVZdTfL4lOidjdUjYtxGMgf lORG/cL4hibSywRD83NPY5+ttleYUxLUqOSGk9BXJmJZHrz3kz85bBHRMRFDti6xlMZ8 0SjbdRKt+A4hIl3Jxuu5vuxt06QPhZB8k9XU2gj0Ffp7bdehKy9HgYABlrMvSrW+RqZN +b6Lj2V8tE3auLzQ2kJUhFGNKP7S1z7vJ/sDLMtxf9Jud7ftuaZflZ94ugUOYEGqZUuI 9igWgzb9TF+I4CCbWx0/n55dKhh7zw3PcAHY7PgUxCqkCGEF+ptat1kf3t4rh3EZt/SX SeJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A93SDyFJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j1si23535870edf.29.2021.10.25.16.29.54; Mon, 25 Oct 2021 16:30:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A93SDyFJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235015AbhJYT31 (ORCPT + 99 others); Mon, 25 Oct 2021 15:29:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:40188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235292AbhJYT0k (ORCPT ); Mon, 25 Oct 2021 15:26:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 590766108C; Mon, 25 Oct 2021 19:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635189801; bh=Kw7lkG9kOuWj0W+L7dSn2mt0ZsB27lwqqvz5rScPANU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A93SDyFJ8Yi/F6b2pyar8xToSd68RR8bXoo5omhWSXVR0lbaNO900jzghoTK3oSs/ wZlIp1nEEpe0U7mMuwxYfNqGNPv+Uo3f/yyb5odDpF9KsD3GIU2Kkw9tgND5HyFPco akY2OMy8S2n28umhNWPFzDhttjHupKTDdnIWyLPQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , Max Filippov , Sasha Levin Subject: [PATCH 4.19 03/37] xtensa: xtfpga: Try software restart before simulating CPU reset Date: Mon, 25 Oct 2021 21:14:28 +0200 Message-Id: <20211025190928.971632271@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025190926.680827862@linuxfoundation.org> References: <20211025190926.680827862@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guenter Roeck [ Upstream commit 012e974501a270d8dfd4ee2039e1fdf7579c907e ] Rebooting xtensa images loaded with the '-kernel' option in qemu does not work. When executing a reboot command, the qemu session either hangs or experiences an endless sequence of error messages. Kernel panic - not syncing: Unrecoverable error in exception handler Reset code jumps to the CPU restart address, but Linux can not recover from there because code and data in the kernel init sections have been discarded and overwritten at this point. XTFPGA platforms have a means to reset the CPU by writing 0xdead into a specific FPGA IO address. When used in QEMU the kernel image loaded with the '-kernel' option gets restored to its original state allowing the machine to boot successfully. Use that mechanism to attempt a platform reset. If it does not work, fall back to the existing mechanism. Signed-off-by: Guenter Roeck Signed-off-by: Max Filippov Signed-off-by: Sasha Levin --- arch/xtensa/platforms/xtfpga/setup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/platforms/xtfpga/setup.c b/arch/xtensa/platforms/xtfpga/setup.c index 982e7c22e7ca..db5122765f16 100644 --- a/arch/xtensa/platforms/xtfpga/setup.c +++ b/arch/xtensa/platforms/xtfpga/setup.c @@ -54,8 +54,12 @@ void platform_power_off(void) void platform_restart(void) { - /* Flush and reset the mmu, simulate a processor reset, and - * jump to the reset vector. */ + /* Try software reset first. */ + WRITE_ONCE(*(u32 *)XTFPGA_SWRST_VADDR, 0xdead); + + /* If software reset did not work, flush and reset the mmu, + * simulate a processor reset, and jump to the reset vector. + */ cpu_reset(); /* control never gets here */ } -- 2.33.0