From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23DC3C433DF for ; Thu, 4 Jun 2020 00:16:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC8C42067B for ; Thu, 4 Jun 2020 00:16:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=mvista-com.20150623.gappssmtp.com header.i=@mvista-com.20150623.gappssmtp.com header.b="lM8tc5nS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC8C42067B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mvista.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jgdY7-0000WR-BI; Thu, 04 Jun 2020 00:15:59 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jgdY6-0000WM-MF for xen-devel@lists.xenproject.org; Thu, 04 Jun 2020 00:15:58 +0000 X-Inumbo-ID: 8ebf0d10-a5f8-11ea-81bc-bc764e2007e4 Received: from mail-oi1-x244.google.com (unknown [2607:f8b0:4864:20::244]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8ebf0d10-a5f8-11ea-81bc-bc764e2007e4; Thu, 04 Jun 2020 00:15:55 +0000 (UTC) Received: by mail-oi1-x244.google.com with SMTP id p70so3491538oic.12 for ; Wed, 03 Jun 2020 17:15:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mvista-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xNaE8BU6OnVudV+0jcBlA9EVCk9/AsZCS2vA0geAa4Y=; b=lM8tc5nSF85XXZ9shJIIrnNTmYah9p+3ij5LyA6KzyiD0gWSLGfvrwnj5FTO6evu6Q BJ81o89iBaf7Nn9wlv/Tr+yTgQATCKixCpBBOhRaE6598wn0xV2i5HVbnBBPH1+nXVyn f1rtOKqf3yGjvc8NrJTtNGFvfO65+kznCRn3tOjhkOdTpAITJWt9MiaJb46eHEH8nXtx twU6oh8+U+nzAs0/R5BkrEIiUDR/tf72gngriLoov7CZgYE9IE7W8cuu9tALG2ypa4OG 5U5LL8K+A9xj/Q1EGUNbtleFSZivu5UULISfyVB0CG3+4BDWkFwolGC2pHtAKjKXKk2m Iicw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=xNaE8BU6OnVudV+0jcBlA9EVCk9/AsZCS2vA0geAa4Y=; b=pMMVcZ5sknOy8mtO6WDwJnJBhCkYndEMp9okzqrYa9TuNO6KL7hhJql4N22eJ0OOJu B8kMHvm9FDg+lArv0VQOi1p+fwRoh3LMurDIC+bubut4sJSOzGTusStu7dqQCof/oCnY 9BXeMPnlTtz7KmMPaB3VXZYlWHpCrZ+z/ZPzh5Z9D+mPoDfhzWkeAGcF2T9byVYBzUAr vtJDG/0FPGPmXiu6oGX6T3Hp3HY2JGR8xLw1JJ6oJ/PBybH0by3qcS12y9UyEKyoW+ue KofjfFcN66Sa7JpSMlojJWxBosWyhylDnn43K+xkz7nz40QjYZudhXRtnJWC3iff7IZk vWjg== X-Gm-Message-State: AOAM530m6jFyZ7z/HXAG8+gd1GqUrD/SCrGFwKmfnib50s3C8OevwrpP mds7cmZgmIMz5EPvVNR1B7sqOA== X-Google-Smtp-Source: ABdhPJwAzowLe8zoLzVaeSS1eYVvpg4W92K/C0JBzgt54bnfnjfO1APESwKUIcCaGqEKmrnTsWjwdQ== X-Received: by 2002:aca:4f4a:: with SMTP id d71mr1421012oib.123.1591229754912; Wed, 03 Jun 2020 17:15:54 -0700 (PDT) Received: from minyard.net ([2001:470:b8f6:1b:9d35:f7bd:647:6545]) by smtp.gmail.com with ESMTPSA id g10sm840201otn.34.2020.06.03.17.15.54 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jun 2020 17:15:54 -0700 (PDT) Date: Wed, 3 Jun 2020 19:15:52 -0500 From: Corey Minyard To: Stefano Stabellini Subject: Re: [PATCH] xen/rpi4: implement watchdog-based reset Message-ID: <20200604001552.GC2903@minyard.net> References: <20200603223156.12767-1-sstabellini@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200603223156.12767-1-sstabellini@kernel.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Reply-To: cminyard@mvista.com Cc: xen-devel@lists.xenproject.org, roman@zededa.com, julien@xen.org, Stefano Stabellini , tamas@tklengyel.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Wed, Jun 03, 2020 at 03:31:56PM -0700, Stefano Stabellini wrote: > Touching the watchdog is required to be able to reboot the board. > > The implementation is based on > drivers/watchdog/bcm2835_wdt.c:__bcm2835_restart in Linux. Ah, I was looking at this just today, as it had been annoying me greatly. This works for me, so: Tested-by: Corey Minyard However, I was wondering if it might be better to handle this by failing the operation in xen and passing it back to dom0 to do. On the Pi you send a firmware message to reboot, and that seems like too much to do in Xen, but it would seem possible to send this back to dom0. Just a thought, as it might be a more general fix for other devices in the same situation. Thanks, -corey > > Signed-off-by: Stefano Stabellini > --- > xen/arch/arm/platforms/brcm-raspberry-pi.c | 60 ++++++++++++++++++++++ > 1 file changed, 60 insertions(+) > > diff --git a/xen/arch/arm/platforms/brcm-raspberry-pi.c b/xen/arch/arm/platforms/brcm-raspberry-pi.c > index f5ae58a7d5..0214ae2b3c 100644 > --- a/xen/arch/arm/platforms/brcm-raspberry-pi.c > +++ b/xen/arch/arm/platforms/brcm-raspberry-pi.c > @@ -18,6 +18,10 @@ > */ > > #include > +#include > +#include > +#include > +#include > > static const char *const rpi4_dt_compat[] __initconst = > { > @@ -37,12 +41,68 @@ static const struct dt_device_match rpi4_blacklist_dev[] __initconst = > * The aux peripheral also shares a page with the aux UART. > */ > DT_MATCH_COMPATIBLE("brcm,bcm2835-aux"), > + /* Special device used for rebooting */ > + DT_MATCH_COMPATIBLE("brcm,bcm2835-pm"), > { /* sentinel */ }, > }; > > + > +#define PM_PASSWORD 0x5a000000 > +#define PM_RSTC 0x1c > +#define PM_WDOG 0x24 > +#define PM_RSTC_WRCFG_FULL_RESET 0x00000020 > +#define PM_RSTC_WRCFG_CLR 0xffffffcf > + > +static void __iomem *rpi4_map_watchdog(void) > +{ > + void __iomem *base; > + struct dt_device_node *node; > + paddr_t start, len; > + int ret; > + > + node = dt_find_compatible_node(NULL, NULL, "brcm,bcm2835-pm"); > + if ( !node ) > + return NULL; > + > + ret = dt_device_get_address(node, 0, &start, &len); > + if ( ret ) > + { > + dprintk(XENLOG_ERR, "Cannot read watchdog register address\n"); > + return NULL; > + } > + > + base = ioremap_nocache(start & PAGE_MASK, PAGE_SIZE); > + if ( !base ) > + { > + dprintk(XENLOG_ERR, "Unable to map watchdog register!\n"); > + return NULL; > + } > + > + return base; > +} > + > +static void rpi4_reset(void) > +{ > + u32 val; > + void __iomem *base = rpi4_map_watchdog(); > + if ( !base ) > + return; > + > + /* use a timeout of 10 ticks (~150us) */ > + writel(10 | PM_PASSWORD, base + PM_WDOG); > + val = readl(base + PM_RSTC); > + val &= PM_RSTC_WRCFG_CLR; > + val |= PM_PASSWORD | PM_RSTC_WRCFG_FULL_RESET; > + writel(val, base + PM_RSTC); > + > + /* No sleeping, possibly atomic. */ > + mdelay(1); > +} > + > PLATFORM_START(rpi4, "Raspberry Pi 4") > .compatible = rpi4_dt_compat, > .blacklist_dev = rpi4_blacklist_dev, > + .reset = rpi4_reset, > .dma_bitsize = 30, > PLATFORM_END > > -- > 2.17.1 >