Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp716237pxb; Mon, 25 Oct 2021 17:19:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzePZYrBEYzT5gil9jSv+4GFz3Ebmj94KTBMQuyKuYGESB8lecyNX0BWsq1fb+xXTWSwnGY X-Received: by 2002:a63:9a12:: with SMTP id o18mr16309594pge.419.1635207543657; Mon, 25 Oct 2021 17:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635207543; cv=none; d=google.com; s=arc-20160816; b=DkjWMvFRo6dvvcZeX6jQvMlhX5BBadSKtlHFN1T4UB/5Dc/RTdeLmCBCpaz8OE51K9 yue06Xew1CiSsbCeTr5RcdhoQDtm2kRJ9ADvvGUyHMakkYicPhvHivBssnkhxw8a7xZA civv00gORPSeH4BOPGKyAtgePMnjXTjWlyTp5A4wHNvKvQRvzljQUudKoaWIgGHm+t/z WG3Yjx4DoNZSq7pkXv4Vs2JUTwZiJkZnBDZPHobQc/aZadp3nJSb5lzEPYAjMtcJWIxp JqHBoyYLBXSt9omDZvN1lqEBNMbLObNxZnZFC1ojwEFjPV2hqPSIAn1StNSXbX7N52ZN Y0Yg== 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=2Mh56w3oQzJmpgISvM13BGxPaxJUgVSqmtUOYZwZAjE=; b=tJ29p62SagiCr1Y+BTJlMDSGN1Y5Q7dPlzSMw/q7b0fm5Y+Oj2OoHV7Q/RRFClyVe+ uUPtxoeX5OCqWGOFkyaAid+SA4SOpYtvWDMOZcyyDjegrWNmv6WaZ3/WGp8RtroVAwks OcohTblNSp9OfYY71bvp49OTnLfFSWRmDChYIsRJ+v2JbzZy6M+SQTb4DpmumOLsJJzv eV3PnlmPtEKZzM4vqws8jLZiZiJixcbQHyF+3r8pGYgIIYYD5t3yDMij6CSYnhpNsAp2 TgUia07/GtkaKqtXjFamI5/VMy8ljvkyV7BG3Uux0hJNAU2MMti9JCsnbOJ0zxaXpp2r P0Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="CM3i0/b3"; 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 h8si1508607pfc.263.2021.10.25.17.18.50; Mon, 25 Oct 2021 17:19:03 -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="CM3i0/b3"; 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 S235810AbhJYTjn (ORCPT + 99 others); Mon, 25 Oct 2021 15:39:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:53620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236417AbhJYTeh (ORCPT ); Mon, 25 Oct 2021 15:34:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EE5E16117A; Mon, 25 Oct 2021 19:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635190239; bh=tZDxhnml6J/pYC6SCT4v70fUfCAV5raH4h8fIzLk93Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CM3i0/b3sFE5ED6I7O3xrNUrTIZvbGhDc1mQHoJAXlXvCGt1g3qJkZOj309SkhztE tmg/gdYtXBqMWGnWlh/E9OXwfDvh/xJ00pc9JY9AqOHPsUGV90/T9kFcLjl6lhujmX 4hJOo3dck7ABrWWGD+89sOVKq5zMiXPMuW0h7hAA= 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 5.10 10/95] xtensa: xtfpga: Try software restart before simulating CPU reset Date: Mon, 25 Oct 2021 21:14:07 +0200 Message-Id: <20211025190958.333595627@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025190956.374447057@linuxfoundation.org> References: <20211025190956.374447057@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 59b7f11f2a3e..538e6748e85a 100644 --- a/arch/xtensa/platforms/xtfpga/setup.c +++ b/arch/xtensa/platforms/xtfpga/setup.c @@ -51,8 +51,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