Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1402943ybl; Thu, 22 Aug 2019 14:03:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfVRJSc607Hn97depqNirNm9XoUA2iKM/e2PCxEEXLVcnK+nIFHBYF5K8abYIjDQ2ntJ0t X-Received: by 2002:a63:211c:: with SMTP id h28mr996455pgh.438.1566507803787; Thu, 22 Aug 2019 14:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566507803; cv=none; d=google.com; s=arc-20160816; b=c2UD3cRN/MT/qR9k4mauYy25QZ5tZ6bdtr5do6W8SD5B5n5qnMhek4AswuNgXfi2Fq UGe3x/yZ+469WbhaS8YpSrck09dKyNZMjuwBSYg0TM31BnuPYmu/dCLGqpLR0etZiACn L7uZVXvzytfFfVa7SFB+F5+CxeEPPF8rMoqRp8Lr3ISYPe1k/1xPH3KWxibX1RP9iK/Q wNTz4hJ89umlYy9rci5r4GfOlLA3tGbIT1aey9k1+yVNZciWa1A1SMyHLwqcw2q3GiGd lYaOdXPTUpJCiCWvfMMrwowW5tqjirSS4UVcbPSvs+MyQSG3vrbJtfP3lzIFnGnIJD+e rmuQ== 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=LLSfhjZ20UrvmFyJq5xWniuCu6bmNYlvnVKbsaRQT+I=; b=e69g5C5LUfoCmrg3uypcrCLiyvyqAKjntqfmHH/ybsRZmRK7CGAEtXZFT0vRxRKToZ 7hJ+Nqf9sRydYnSY5zVAmHys6/QKCrni00uA5y+FFOydcnGdgeHCl5CbA1D/XNHcotFx +ldPPj3RnQew4S2ut+jV0ruMVU7VG/hHPzKZcYc8NEJywvxOB95UtPNa39Ds2C47bmrI m/bEJoQBql/uBj31oBFom+qQvXjPp1d0YG+y3SxUDKuS2OIWxaZKN+YUIBot8dqvqNN/ 9oqd5oYFyYBfP6tl85iVVcw+6J9qLinkQ0lFQl5+pApOU2bVvtr2l32RXk2k3022HBap itTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yadro.com header.s=mta-01 header.b=lem5IMtG; 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 k12si510312plt.92.2019.08.22.14.03.08; Thu, 22 Aug 2019 14:03:23 -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=lem5IMtG; 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 S2390160AbfHVQpz (ORCPT + 99 others); Thu, 22 Aug 2019 12:45:55 -0400 Received: from mta-02.yadro.com ([89.207.88.252]:36134 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390124AbfHVQpz (ORCPT ); Thu, 22 Aug 2019 12:45:55 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 340C142ED0; Thu, 22 Aug 2019 16:45:52 +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=1566492350; x= 1568306751; bh=LLSfhjZ20UrvmFyJq5xWniuCu6bmNYlvnVKbsaRQT+I=; b=l em5IMtGjuww6S3ubO3pVFjgLlBClF1l6ScWEkqV1ChoSHkEEot7RJPxm0N92b1Ny vVtZWkhqE+2O/0cyiSfBZaCKuFh+ubycfhdWJrAIEQMlO7dFc6oMBwhbGjaP8JUs pUEUqUD1hzjnrP4Ycbjvn2451WYGTFGXvn4L9iGosM= 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 MT5ByLDJR1cr; Thu, 22 Aug 2019 19:45:50 +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 368E342ECD; Thu, 22 Aug 2019 19:45:49 +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 19:45:48 +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> <5cb20f52-884a-b921-c904-ebf244092318@yadro.com> <20190822160127.GA6992@roeck-us.net> From: Alexander Amelkin Openpgp: preference=signencrypt Autocrypt: addr=a.amelkin@yadro.com; prefer-encrypt=mutual; keydata= mQINBFj0jdkBEADhQF4vZuu9vFfzxchRQtU/ys62Z13HTaYK/VCQKzPnm2mf593Il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0H0xkPygufjtiYo6jTb+BKa sG8AEQEAAYkCJQQYAQgADwIbDAUCWmWo6AUJcjFDNwAKCRDok1h7W3QXjc9vEADXse2POSaT 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: <0bce44fc-0d03-511d-245a-8f867a6e067b@yadro.com> Date: Thu, 22 Aug 2019 19:45:48 +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: <20190822160127.GA6992@roeck-us.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Ph7UczBb1taROq5iq7Drmb3GLE2mw8Tfa" 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 --Ph7UczBb1taROq5iq7Drmb3GLE2mw8Tfa Content-Type: multipart/mixed; boundary="c04A7lFeUTafm5XtcA5KOfAygNkAorqeW"; 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: <0bce44fc-0d03-511d-245a-8f867a6e067b@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> <5cb20f52-884a-b921-c904-ebf244092318@yadro.com> <20190822160127.GA6992@roeck-us.net> In-Reply-To: <20190822160127.GA6992@roeck-us.net> --c04A7lFeUTafm5XtcA5KOfAygNkAorqeW Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US 22.08.2019 19:01, Guenter Roeck wrote: > On Thu, Aug 22, 2019 at 05:36:21PM +0300, Alexander Amelkin wrote: >> 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_TIMEO= UT_STATUS >>>>>> to clear out boot code source and re-enable access to the primary = SPI 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# wo= uld be >>>>>> re-directed to CS1#. And CS0# is not accessable under this mode. T= o access >>>>>> CS0#, firmware should clear the 2nd boot mode register in the WDT2= status >>>>>> register WDT30.bit[1]." >>>>> Is there reason to not do this automatically when loading the modul= e >>>>> in alt-boot mode ? What means does userspace have to determine if C= S0 >>>>> or CS1 is active at any given time ? If there is reason to ever hav= e 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 = mounted. >>>> The filesystems, in the event of alternate/recovery boot, need to be= mounted >>>> from the same chip that the kernel was booted. For one reason becaus= e the main >>>> chip at CS0 is most probably corrupt. If you clear that bit when dri= ver is >>>> loaded, your software will not know that and will try to mount the w= rong >>>> filesystems. The whole idea of ASPEED's switching chipselects is to = have >>>> identical firmware in both chips, without the need to process the al= ternate >>>> boot state in any way except for indicating a successful boot and re= storing >>>> access to CS0 when needed. >>>> >>>> The userspace can read bootstatus sysfs node to determine if an alte= rnate >>>> boot has occured. >>>> >>>> With ASPEED, CS1 is activated automatically by wdt2 when system fail= s to boot >>>> from the primary flash chip (at CS0) and disable the watchdog to ind= icate a >>>> successful boot. When that happens, both CS0 and CS1 controls=C2=A0 = get routed in >>>> hardware to CS1 line, making the primary flash chip inaccessible. De= pending >>>> on the architecture of the user-space software, it may choose to re-= enable >>>> 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 f= ile 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. >> > That is different, though, to what you said earlier. Linux would then s= tart > with a clean file system, and not need access to the file system in cs1= at all. > Clearing the flag when starting the driver would then be ok. I don't see how that is different. Copying to memory may be done by start= up scripts that run after the driver is loaded, so they need to read the dat= a from the chip they are booted from. That is how it is done in OpenBMC, for ins= tance. Other flavors of firmware may choose a different approach. Having the control available via sysfs gives more flexibility. >> However, to be able to recover the main flash chip, the system needs C= S0 >> to function as such (not as CS1). That's why this control is needed. >> > If what you said is correct, not really. It should be fine and create m= ore > predictive behavior if the probe function selects cs0 automatically. Well, this is not a function for home users. This is for servers. You won= 't even find an ASPEED BMC chip in a home PC. Aspeed's dual-boot is quite an advanced feature and people willing to use it are expected to be able to predict the behavior. To me, as an embedded systems developer, automatic selection of cs0 by probe is a limitation. I prefer flexibility= =2E With best regards, Alexander Amelkin, BIOS/BMC Team Lead, YADRO https://yadro.com --c04A7lFeUTafm5XtcA5KOfAygNkAorqeW-- --Ph7UczBb1taROq5iq7Drmb3GLE2mw8Tfa 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 iQIcBAEBCAAGBQJdXsa8AAoJEOiTWHtbdBeNpz8QAMJqCodfgFfuRbOjdovLu46D K9uudfxOQCsAFxY+VgXu1E5Zso5OotrYjofklDbIb6Q9ZS3UgiNA4+UrWJ6Yhjnp Md6mh9ADb24rTpaPE74rj2JpyJz9jDwBB+C5ONnKPAcr0tXLjis+anVtDjHvQ8cK wOZKytgC2omgF5Xrlu0SjhVxf+kqHBpo69SCfMWsp0NIZzlTCovJH1IX54rC176k XpjeVIT4EzzdiRN/r6Ft8BfiD/JaYUs0OLCWckHTUCelHMCRKMsyzTKNwp3FE5sH qgeOqzgcN8Nj4ZvaVnzmiH/r61+NNArtLJaqsJJywXDA7+v0KkxV5urWghxD8FMs OUwnotJqSquXO7k9VcTnZQK/aeQvBoRdWfTpiybK5df61U26STEQzMAr5pslnDRl kJLiY32929QyDiIGy8yYcmvMRrvDotuPK+XtaJN20IISRnM6T6e6q+3mRCzAvykn LcjRcVUs+49DMuTswUNRxl7YggZaRwOqHGrEhPQv5LbZmvm2JtQwa+loV0/32mVp uajzhKaazw4JzUjvPDl5oVJX6+fEj+8/iFJksRRhs7De/rBhwxn1OmWcWeh4UMJ4 T3muwenl131/Sb3ufnGfPnG+oSd2TKlpKH4oi0dXuhu5EFkV3QQ7jWMbnJ+9m+d9 zs/9X7nt2Kc2pO2vcTne =G5CA -----END PGP SIGNATURE----- --Ph7UczBb1taROq5iq7Drmb3GLE2mw8Tfa--