Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3252094pxb; Sun, 3 Oct 2021 20:16:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmLzHO7IJc8ed5mf6RD2ruHz5a+8eKOdzdgm7IUYAzl1Sc5hopI/dE1brUQdmXsQWh/zwu X-Received: by 2002:a17:906:7047:: with SMTP id r7mr11048765ejj.286.1633317403748; Sun, 03 Oct 2021 20:16:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633317403; cv=none; d=google.com; s=arc-20160816; b=uotQw6DjmlMbu3GZdHTLlSn4Qyu4Mhu4/hiCG7qVwjx5so+6fI17DJHeOCUJcMx91C m5Fd/B06siNS5w4Di5wsqgGyKUTE0hjVZAnlnQGoNtfJNr9C/X5/xxvPG1tH4WnBuWa3 fOsnQ/hKCFtX3iVHadSNIDtKiG520fJNHlXf3UG3LH4u6tsIRzKfvl3qhbyyr5KDyf2F kyuXGhEyeLGhvaVB3MW6EVUkR88hRQaHisCIkw3h/dwzhN/NwIkhqK0yJTfxgHY1eeUc ja17Z/pchht/hqdKJD8x4XHtXK5HlYkBINx+y3VhSaUpwK1Wr2JLwqHyFOxUZgT+TDfY xcNQ== 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=RKnjjVOVAOCInl/nMgbxZfi/GBeRFnh4ynzj/tmEXRI=; b=I9jpxngFiAU56kAL4duMZ2E1nm+NKttLqPGxAoXGsZu23+A/b/hvV6gtw+A1TaF2Y0 9DhmTzeVrsXgvAP7CX6IjLBIgUeeBdtjDL2Y8OCOESKCEyEc/wDn9Z4GBzSWDLVAKEKZ ECRVAjOSIvUkslrg4tMn72pgj1crp40XyGNj73PngoWsy/r8U9yh0vIECvvxgEMmru/t KQx+59x/AGtob7F3f/LHGLY4v1LUyH/Np+yWRuE4GvpShsTNk5m1YMr8KUQ8Qo3f3wV2 C9tGmVJ2B8KUCsbKsNFXF/n8+Wrjsie8UkK3D7S+ytgz7MjyvdeFgq6ke12dMDi+zZ/k Ly1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kpLA465S; 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 c3si17160071ejc.450.2021.10.03.20.16.20; Sun, 03 Oct 2021 20:16:43 -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=kpLA465S; 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 S232279AbhJDDQG (ORCPT + 99 others); Sun, 3 Oct 2021 23:16:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232238AbhJDDQF (ORCPT ); Sun, 3 Oct 2021 23:16:05 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B39C0613EC for ; Sun, 3 Oct 2021 20:14:15 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id x8so2915504plv.8 for ; Sun, 03 Oct 2021 20:14:15 -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=RKnjjVOVAOCInl/nMgbxZfi/GBeRFnh4ynzj/tmEXRI=; b=kpLA465SHWMY05MKq0WxlBMzhIp3REP3vUwciyH55Un7boa2U2LWarStF9LHxVzvVI fJuobPWki3xq7eiK2VHUwVkqAbYp2F0yf/fov8LuiD35leNWSFTchCM04SQim4ymMSHC Pxpkl7SFe9cUZOGEglSBtHh8PD2WpCUDt3FfMfbSZnB4Ow5ok6SDlKZNJF9TVugsRUry +Tr8SWeq4e6PeSJJqoblTg69kQi2FCQu5LOmID/wZccTAs3r5YDOD7MyKkywbHhV9iJt wViCUeKWHj9JSoVmv5w+/+VTCvCZlifbS4GDLAbm6Ktgl6sKKj38htMuaIrXNKg9CipJ ZDvQ== 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=RKnjjVOVAOCInl/nMgbxZfi/GBeRFnh4ynzj/tmEXRI=; b=mX8/PNgTuIfxFJp1Y2vRvQjlQk9QHXW3GG1g+GXn2mYg/kTe+jy7YwoDfAxsA65B9C Sadh+x9b4rJ+nSDyjdeD6OMmPYOKm8+O2Jov0ia0hllDVWmv4X1ZuyfjB83A7lRoVXTy L5BvW8m4QQH1dZO9ZMz/ScLyrdrwpm3RX0prkaHa215XAXABmA+l7jFJMjbAic/nRmDX GhE/D5WbAu/L05e52FUnqU0NoJghv/1qL2k4y+HD9elsEHatSuqx60SD5AjJ83upuKrW GkM1fuPtU3BJnseSWW7nniVyQyj2UMzvuLAmLbQWvtNnbYxixafMuR98GpwwcyJ3DB1o M33w== X-Gm-Message-State: AOAM531LnizajJIO911jeWNwwKWyerMmATTLILi7qIN3mwda2zF0uohn iFFW0PbYZubfqaL5gbiMAkM= X-Received: by 2002:a17:902:6947:b0:13e:8e8d:cc34 with SMTP id k7-20020a170902694700b0013e8e8dcc34mr12787700plt.88.1633317254581; Sun, 03 Oct 2021 20:14:14 -0700 (PDT) Received: from octofox.hsd1.ca.comcast.net ([2601:641:401:1d20:ecea:c8ec:ff7b:52]) by smtp.gmail.com with ESMTPSA id h2sm11035776pjk.44.2021.10.03.20.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 20:14:13 -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] xtensa: xtfpga: Try software restart before simulating CPU reset Date: Sun, 3 Oct 2021 20:13:41 -0700 Message-Id: <20211004031341.20297-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 --- 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..9b1e36b06530 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. */ + *((unsigned int *)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