Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4073995pxb; Mon, 4 Oct 2021 16:51:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVJEzFgw0veJKikg7QE9vbyWYClvOfY8NUeE+XWU/KfiC4l1ALYRpPK5hxvPHtTO4gkiTT X-Received: by 2002:a17:902:b593:b0:12d:7aa5:de2d with SMTP id a19-20020a170902b59300b0012d7aa5de2dmr2254828pls.31.1633391500058; Mon, 04 Oct 2021 16:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633391500; cv=none; d=google.com; s=arc-20160816; b=PgxcOCXuMz5VvcJSYqBZ83jwlX2lw3iu1pmgzjxhZdp3oD/QcG53IpNhZ5iyzBbu2k GQ6quVUUvAJuPqPE11Jby0gvhCPxLdIrJyDI5jrTchaBzhb0nYr6Oh3lON4frIITjc+F TWe48DhTRckHGRYAn5kZIFYrRdwZ+xFPiJ4ax5jTQq1cKAsd8U73JqDIliBCgShV5YXW 1Vu3efZYf947A7JM4z/M6YWmo8w4HFz5spAogOszQfjxtIXwcFPAaa6JVGiT16Q87zjZ M/i50qwcPYDMfJqr4dGE28owOZ+tSoG19MR759vCrkkHWUo8Ou/zCqIpNEZUTWBrQwIj EKIA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=jnVUz7cckIzuOpFBzdErFnhTI+WjBJRaEaWrDbGSfDs=; b=YW/wfLDdivdX44KZLKjB/hv/tIYrY3M4UUBv4WMroXIepEb595oKR3YzaaNnjjDR26 ELl/cf4GR2KYSCLXMBCQ2JOmYV9baNdx3kT+rWOQd2t2dfVxxcSWrZqkNPv0KLSxGpfa j7wK7BrOB/H4qBFEl3EdzpoI18zRE205EB2FX9sRey2Xh1fuzCUA2babq6TZmOYGxZUL NzPTGGWXaW0ZUOWR6TjfH/mSFJo+iMJOEhSokKAhQhBtsLUt6rUQkj/TZbvM0KlkkNYv TabkXPCcwABa4CYZ/vwfd60HZNBctLTbueR0hrscCVzBe87XqJYw3wBv5kijcxHBro3R 8BkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Czpbi/3B"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si20721884pll.56.2021.10.04.16.51.27; Mon, 04 Oct 2021 16:51:40 -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=@gmail.com header.s=20210112 header.b="Czpbi/3B"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233235AbhJDVrr (ORCPT + 99 others); Mon, 4 Oct 2021 17:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232772AbhJDVrq (ORCPT ); Mon, 4 Oct 2021 17:47:46 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15FE8C061745 for ; Mon, 4 Oct 2021 14:45:57 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id s16so15689816pfk.0 for ; Mon, 04 Oct 2021 14:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jnVUz7cckIzuOpFBzdErFnhTI+WjBJRaEaWrDbGSfDs=; b=Czpbi/3Bpn9+3YBD9owvuQYZnnr0sSH+KNYORW3yjVZRrBQDpf9rrGPBsojMISMe5r CVOFjSGpetj7UTT8eCgFhdKaZuh/4TZn+DBNaf9Kq2/rvKcbUHlypXztCdTMiGWpulFZ 9KSameZ2qta1WVf6b3cPco2qjVJMOoaJLfHxeCNHFhibkpDP6WFVhA2nqF7XSuWXAMtM 3L19kAsi7sxQPENYWpvZzy4+YHeY5+EykwHCcI/DxYUCbBpqd5W+H8cyJF2Ga9VDmdvQ RP+lQCKR3ZlIeVpUw0rnS5XsG94xNMYdCeK3SBnNYF8lyummYVKcYAlsig+Im3jwGIaJ 0WwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jnVUz7cckIzuOpFBzdErFnhTI+WjBJRaEaWrDbGSfDs=; b=OIhfYnmuotrPaRzzrb+DNt0UYuQA9wUsMTE6BRUkJFszW5/YnVrI5+8LIG/P5+dO/w imxWZkNNhgYfbkwpwFQmBzXLLMYNMdUNneDswXR/IHPflcvaXMd0sCIOTXAZ+ppSD2oo bgTZ1D6rRhE2JdCMyx174ee/1ijUstA4pp03b2tfqjuYZ+hU1MQv04681Mvtdqf6EEbT Aba46aDSSk5lxp/T7zDT7GotxqTJsVvBOO8Cr9AMkY1YLwHjDaXDuNwLhf3+FB6qOwE0 zNOUKzwXJNlHDHPYTgwe+hs/1viAMyRF3A4fLB9OWm22lcvpH6I2M3lO4RWgyBckB4i+ Y1eg== X-Gm-Message-State: AOAM5308Zy0rdCOTJ4DmJK/Ktrf8bPRs3W3yK6qre1y9/2nmYGMeRrIf Vg5OTA7e3eJ71xw49Lnvq5g= X-Received: by 2002:aa7:8116:0:b0:44b:e0d1:25e9 with SMTP id b22-20020aa78116000000b0044be0d125e9mr28136977pfi.53.1633383956496; Mon, 04 Oct 2021 14:45:56 -0700 (PDT) Received: from octofox.cadence.com ([2601:641:401:1d20:ecea:c8ec:ff7b:52]) by smtp.gmail.com with ESMTPSA id x11sm9372609pfh.75.2021.10.04.14.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 14:45:55 -0700 (PDT) From: Max Filippov To: linux-xtensa@linux-xtensa.org Cc: Chris Zankel , linux-kernel@vger.kernel.org, Guenter Roeck , Max Filippov Subject: [PATCH v2] xtensa: xtfpga: Try software restart before simulating CPU reset Date: Mon, 4 Oct 2021 14:45:44 -0700 Message-Id: <20211004214544.20167-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guenter Roeck 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 --- Changes v1->v2: - use WRITE_ONCE instead of simple assignment 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 4f7d6142d41f..324f1f2aba09 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.20.1