Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1308216ybl; Thu, 22 Aug 2019 12:26:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlRQQbH3OylC1x7zQJFV07A6Jg0tPOA1YmvYNgKiJkrBCw60KbJvkhYN0Fe3I3CURymXWl X-Received: by 2002:a65:690b:: with SMTP id s11mr734125pgq.10.1566501971244; Thu, 22 Aug 2019 12:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566501971; cv=none; d=google.com; s=arc-20160816; b=e5uQDOU96MZej7etxnyYkeoczJqeAHfpIXCCM2JPTagvA06IADKpyWmHftDqkbOfF7 01tDjHT9cuowOHH8BpE3lBGundknvbPcl1mAirLLRgyFG+XolRUxg/w7OEF2r0+raSy5 p3QIpOY9xIyFA8okQiiS7M3FnNZ+uh5X61PkOdm1NHonwfsPfWLG6nYdDoB+aKTSaP5w bPgQdEqo0DahfuGkyidDFMJAoYGb7oOtj2Zy4MJaXYTFWFafwWd5GTh3dnGLfHhxSqJu a2ULc0vjHIVhVCOn6RiGYqQ9c7YGKQbiwqMjwh+BemexZko3dyYGSTNLvFk8TrJBdMwJ 2uKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:openpgp:from:references:cc:to :subject:dkim-signature; bh=iJnB+Nr4F9+QND6hlB5aSB//ubkLbe6jTSnQwQnCTE0=; b=I2cK1MsW3CcmjQKmDqoxIkhBbvYVAKeVSQvl1zRztCaaZklbyqx2bSp+Xd4/oY+Xum T2DK/u+OykN3IOh3l2lN4tbFmIiXJiS7njnCdky4wEGLiFgaS+uPDJ3YNM+felEIxjD5 qleOyivztZo/YIOmWcRAGTmwrhvg+lhb66jp6Z9jraoMwUad49OizVtDFfkmc0kxeFOD Wfg3iqJtw0WstRVsRINSbx7yHxQV0lh2s5ZXxmEgQNaG8qB8F78MVltXr6FCXCJcBvcs yJwxbwW1zuOm+mnH5w7G85GKx/uM2OjWfhB/FVtRml0IdFJOlDpKEUuQxhCOWi5ZXXJ2 FDvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yadro.com header.s=mta-01 header.b=hKIl6fK+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yadro.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d18si438519pfn.202.2019.08.22.12.25.55; Thu, 22 Aug 2019 12:26:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@yadro.com header.s=mta-01 header.b=hKIl6fK+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yadro.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389251AbfHVOg1 (ORCPT + 99 others); Thu, 22 Aug 2019 10:36:27 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:60982 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729731AbfHVOg0 (ORCPT ); Thu, 22 Aug 2019 10:36:26 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 8A69942ED3; Thu, 22 Aug 2019 14:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:in-reply-to:mime-version:user-agent :date:date:message-id:organization:from:from:references:subject :subject:received:received:received; s=mta-01; t=1566484582; x= 1568298983; bh=KjLZ/dXb03wCeLlcNpYc1sfR2QBhG4qiGXMw3VhDuCI=; b=h KIl6fK+ADBPFXUBs4nGI6DG4Ws8k+GDr1X5QqlQVHb9KjG9I2Yb9pq8Mz3cgp154 EQiRcBGjakvt56n3c4qo54o3sJyWb/im+VOl0DtHktQxhVbkKAVhFat6vDGASqT6 2kquwOsBC2X11clFMIzlQteIAbZ7Jv6qyaJOtPoX0Y= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qq5hMQ1PA2LM; Thu, 22 Aug 2019 17:36:22 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 8F97A412D3; Thu, 22 Aug 2019 17:36:22 +0300 (MSK) Received: from [172.17.14.197] (172.17.14.197) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Thu, 22 Aug 2019 17:36:22 +0300 Subject: Re: [PATCH 3/3] watchdog/aspeed: add support for dual boot To: Guenter Roeck CC: Ivan Mikhaylov , Wim Van Sebroeck , Joel Stanley , Andrew Jeffery , , , , References: <1f2cd155057e5ab0cdb20a9a11614bbb09bb49ad.camel@yadro.com> <20190821163220.GA11547@roeck-us.net> <9e7fe5cc-ba1b-b8b6-69c5-c3c6cf508a36@yadro.com> <20190821181008.GB15127@roeck-us.net> From: Alexander Amelkin Openpgp: preference=signencrypt Autocrypt: addr=a.amelkin@yadro.com; prefer-encrypt=mutual; keydata= mQINBFj0jdkBEADhQF4vZuu9vFfzxchRQtU/ys62Z13HTaYK/VCQKzPnm2mf593Il61FP9WV 0Srt4t4yumiXK7NhHeqktN/YZjYDYVr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YAQgADwIbDAUCWmWo6AUJcjFDNwAKCRDok1h7W3QXjc9vEADXse2POSaT M0uqR3KGTeF8XVKdyRqK9afWbMaxFzOWGp9pNtcmIvfmyE0M6LPLgUb33jek/Ngup/RN7CjZ NCjOc2HTID99uBkYyLEcOYb+bycAReswjrv3a49ZBmmGKJZ+aAm0t6Zo6ekTdUtvlIrVYvRs UWWj4HdCaD+BMvSqcDZgyQESLI9nfEGuWtVqdi2QlZZeQT7W+RH4lihHKTdzOsVC93o4h6og ZvgOJ/0g1SP3la88RWONejHxVbGzBOyNjkH71CFujnAfuVuuhkJaN8PY/CS56sKMREKJOy0L vouE7eSU4bp13GK1xsnbWcDQpyzTsCsP9taqQmeld8Hw1yuPamc6fdpKNyPHyN20vzh20f0C QUMAjh3Vym12aKhyRan08VNEaLOKiyya6+i9c3Z3LiWUEqTSzELCkesb68UQVtE6/CXPM2P/ vs3EQuLFXBC/rD9lurT0kG99xElAbKjHLer5NSw2WA2vQXaFadGNDyHI32Yt2cAqWzZtVqmN ESE0npJ5eeAcVWPHjhCwL8phZCDtfxJMy2cqYS8QLIBGfQTIHMQAgqBbpq9FLXCn008tvaTr KijxDkPtWeXDLbMgH1kA46gTPJWxsm0c45w7c3aXhXl4hOgXp+iWDTOT83tJU0zoD9hYlpZf dTYsE5wSxM06T2l/MILupCNZ7A== Organization: YADRO Message-ID: <5cb20f52-884a-b921-c904-ebf244092318@yadro.com> Date: Thu, 22 Aug 2019 17:36:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190821181008.GB15127@roeck-us.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="YIEW7bBuQgeLRG8A8mPFaUjOFyaWm03jp" X-Originating-IP: [172.17.14.197] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --YIEW7bBuQgeLRG8A8mPFaUjOFyaWm03jp Content-Type: multipart/mixed; boundary="CGCf03BkzPVvByrHDZk8giv8pTtRj2ooY"; protected-headers="v1" From: Alexander Amelkin To: Guenter Roeck Cc: Ivan Mikhaylov , Wim Van Sebroeck , Joel Stanley , Andrew Jeffery , linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Message-ID: <5cb20f52-884a-b921-c904-ebf244092318@yadro.com> Subject: Re: [PATCH 3/3] watchdog/aspeed: add support for dual boot References: <1f2cd155057e5ab0cdb20a9a11614bbb09bb49ad.camel@yadro.com> <20190821163220.GA11547@roeck-us.net> <9e7fe5cc-ba1b-b8b6-69c5-c3c6cf508a36@yadro.com> <20190821181008.GB15127@roeck-us.net> In-Reply-To: <20190821181008.GB15127@roeck-us.net> --CGCf03BkzPVvByrHDZk8giv8pTtRj2ooY Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US 21.08.2019 21:10, Guenter Roeck wrote: > On Wed, Aug 21, 2019 at 08:42:24PM +0300, Alexander Amelkin wrote: >> 21.08.2019 19:32, Guenter Roeck wrote: >>> On Wed, Aug 21, 2019 at 06:57:43PM +0300, Ivan Mikhaylov wrote: >>>> Set WDT_CLEAR_TIMEOUT_AND_BOOT_CODE_SELECTION into WDT_CLEAR_TIMEOUT= _STATUS >>>> to clear out boot code source and re-enable access to the primary SP= I flash >>>> chip while booted via wdt2 from the alternate chip. >>>> >>>> AST2400 datasheet says: >>>> "In the 2nd flash booting mode, all the address mapping to CS0# woul= d be >>>> re-directed to CS1#. And CS0# is not accessable under this mode. To = access >>>> CS0#, firmware should clear the 2nd boot mode register in the WDT2 s= tatus >>>> register WDT30.bit[1]." >>> Is there reason to not do this automatically when loading the module >>> in alt-boot mode ? What means does userspace have to determine if CS0= >>> or CS1 is active at any given time ? If there is reason to ever have = CS1 >>> active instead of CS0, what means would userspace have to enable it ?= >> Yes, there is. The driver is loaded long before the filesystems are mo= unted. >> The filesystems, in the event of alternate/recovery boot, need to be m= ounted >> from the same chip that the kernel was booted. For one reason because = the main >> chip at CS0 is most probably corrupt. If you clear that bit when drive= r is >> loaded, your software will not know that and will try to mount the wro= ng >> filesystems. The whole idea of ASPEED's switching chipselects is to ha= ve >> identical firmware in both chips, without the need to process the alte= rnate >> boot state in any way except for indicating a successful boot and rest= oring >> access to CS0 when needed. >> >> The userspace can read bootstatus sysfs node to determine if an altern= ate >> boot has occured. >> >> With ASPEED, CS1 is activated automatically by wdt2 when system fails = to boot >> from the primary flash chip (at CS0) and disable the watchdog to indic= ate a >> successful boot. When that happens, both CS0 and CS1 controls=C2=A0 ge= t routed in >> hardware to CS1 line, making the primary flash chip inaccessible. Depe= nding >> on the architecture of the user-space software, it may choose to re-en= able >> access to the primary chip via CS0 at different times. There must be a= way to do so. >> > So by activating cs0, userspace would essentially pull its own root fil= e system > from underneath itself ? Exactly. That's why for alternate boot the firmware would usually copy all filesystems to memory and mount from there. Some embedded systems do that always, regardless of which chip they boot from. However, to be able to recover the main flash chip, the system needs CS0 to function as such (not as CS1). That's why this control is needed. As Ivan mentioned, for AST2500 and the upcoming AST2600 the behavior is slightly different. They don't just connect both CS controls to CS1 bu= t instead swap them so the primary chip becomes secondary from the software point of view. The means to restore the normal wiring may still be needed. > >> This code most probably adds nothing at the assembly level. >> > That seems quite unlikely. Please demonstrate. Yes, you were right. It adds 7 instructions. We'll drop the check. It's just my DO-178 background, I add 'robustness' checks everywhere. >>>> + writel(WDT_CLEAR_TIMEOUT_AND_BOOT_CODE_SELECTION, >>>> + wdt->base + WDT_CLEAR_TIMEOUT_STATUS); >>>> + wdt->wdd.bootstatus |=3D WDIOF_EXTERN1; >>> The variable reflects the _boot status_. It should not change after b= ooting. >> Is there any documentation that dictates that? All I could find is >> >> "bootstatus: status of the device after booting". That doesn't look to= me like it absolutely can not change to reflect the updated status (that= is, to reflect that the originally set up alternate CS routing has been = reset to normal). >> > You choose to interpret "after booting" in a kind of novel way, > which I find a bit disturbing. I am not really sure how else to > describe "boot status" in a way that does not permit such > reinterpratation of the term. How about "Reflects reasons that caused a reboot, remains constant until = the next boot" ? > On top of that, how specifically would "WDIOF_EXTERN1" reflect > what you claim it does ? Not only you are hijacking bootstatus9 > (which is supposed to describe the reason for a reboot), you > are also hijacking WDIOF_EXTERN1. That seems highly arbitrary > to me, and is not really how an API/ABI should be used. We used WDIOF_EXTERN1 because: 1. We thought that bootstatus _can_ change 2. We thought that adding extra bits wouldn't be appreciated Now as you clarified that assumption 1 was wrong we are going to implemen= t status as I proposed earlier: > >> I think we could make 'access_cs0' readable instead, so it could repor= t the >> current state of the boot code selection bit. Reverted, I suppose. Tha= t >> way 'access_cs0' would report 1 after 1 has been written to it (it wou= ldn't >> be possible to write a zero). With best regards, Alexander Amelkin, BIOS/BMC Team Lead, YADRO https://yadro.com --CGCf03BkzPVvByrHDZk8giv8pTtRj2ooY-- --YIEW7bBuQgeLRG8A8mPFaUjOFyaWm03jp Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJdXqhlAAoJEOiTWHtbdBeNGSMP/1EdyFby2fvhiS+viqTox7Yh XBOSBOEbl1OohoMq87ZG6rhT5uuT+C+drxz+WIEP1wt2YgOS0gNO6ODsL9G9FZNf PYns9R2pKHQ+5oMqP7FalU9EoCJiHdGK6/HrP/QERHTt4+lVNeJg+GrbaNOaIZew qFsst9KCBmGxDJHv6j4sHExZBvsrP1P9+1q7LrJHP2ep3hWAKYcYlzsGooXtrFQH oSNeQJxW9o3OXwMihIYoDLyfsUpazxTw8p/+t6EO4sopjP5Hh3LGbGskM1NdFVkc sLFGBhX5qmMxRQhBHyIdCJz9c0D6uhTp5MfcllQf7+FVo+0QLo8WVSxGLUoP4TH5 BttQvU+7H7DCRu5WxBj00LhPS2wK1Xb2KJ1agoo7QSr/5RpNqyFRGKIykQmWNm/X TJ/Ru3IMUQl8HC2C3ihddw7CRm5js2X0n45HI+7BjqkO5e+yW7he/nIRDgm19udU ChkkjqMKRUAC4aOQWxDMEC20PMjsi+3r0eiF5BCgQJ6qIzlzU18V6JHCiaCGENr0 um1OktmfkT5SPqDJgDw0QX/7e/jIJD0mA5HZgKVQmtTPJEUN+YyHSWvseJKdyR6S 4/4udiV8wCHdXIgjgSAxcCrRKqX9zfjurOZUA0LneS3a88jfP2D5GLBV51+wIB1I xf+LRRJj90D2ov79r4dD =nMHV -----END PGP SIGNATURE----- --YIEW7bBuQgeLRG8A8mPFaUjOFyaWm03jp--