Received: by 10.213.65.68 with SMTP id h4csp300698imn; Tue, 20 Mar 2018 04:03:12 -0700 (PDT) X-Google-Smtp-Source: AG47ELsOBiMkcAkLBxRtoph8Aa+3MP21uuLIxSpMxrgzT4jIv1R860zgqNR90wA907WgyY/logHN X-Received: by 2002:a17:902:41:: with SMTP id 59-v6mr16354964pla.248.1521543792622; Tue, 20 Mar 2018 04:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521543792; cv=none; d=google.com; s=arc-20160816; b=jSjOwMjpQbmCG1Cw+FJO5ZFYe4WZs4y+t2PmTgQjqg+mTiBsqjxZHwh0UnITAVonzD RjQpuMzviZMZrmh4AB6S1O/+K+R87CJjrziAJNCJP59rmapkpr2OipaycVa2zPOECefM dbQ2UQClNgMcZ3rDqJaxOg0aVh36yuALdmuNqQBGpQbV48yHmEmdRjIezI1p/nhEQ9Mz +s3snhiZS0hthkP7pXgNKt1wgkimgmUgZrCAIjOBpJWedyhjQ3/vkY6pCfNUCcnzn0te wjSjOBiEsB/IXfbfUhTyMW0LKypvVL5A0+tOThvvbMAOb/PzZpTVAAscCBK60cBYAbAc jBAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=tfJNbr2N5VHeBK/CEQi8Oh25xW0FnXV5jGYS2MWzrSI=; b=DQXEh70ugd33ihI7v8XfIIAfR9jYOckNzgLJXJAGuuXSL4BBhZ1ziWoiVdoIjQX81v aACxgGob+zTbbmJCs0BWdA1L+h7YR31J3VI0be5TwHSofM9ylh2BET/eO2zbesaJXkv0 XSpBNqxJymcm0Q1kf/iVZ28XPBxQiO0Gh+BS3RMm7FuI5fOC55wq9oq+f+a5s505Bfg3 oVVwTnV7rJ+CU2sFZAyn2u2cxyK/dZqasQRUIxk4H7GfGgRtbMMBOJRyJnIe8Hzv+EVX Vuxmk0bul3dzE3Md8nkvBxnACkaACzgCXlEnl+8/IAQSqkvAnhme7i9y3VtZ4QOrHB4M tu9Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si1010961pgt.198.2018.03.20.04.02.57; Tue, 20 Mar 2018 04:03:12 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752737AbeCTLB6 (ORCPT + 99 others); Tue, 20 Mar 2018 07:01:58 -0400 Received: from 9pmail.ess.barracuda.com ([64.235.154.210]:39106 "EHLO 9pmail.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752533AbeCTLB4 (ORCPT ); Tue, 20 Mar 2018 07:01:56 -0400 Received: from mipsdag02.mipstec.com (mail2.mips.com [12.201.5.32]) by mx1412.ess.rzc.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=NO); Tue, 20 Mar 2018 11:01:45 +0000 Received: from [192.168.155.41] (192.168.155.41) by mipsdag02.mipstec.com (10.20.40.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Tue, 20 Mar 2018 04:01:50 -0700 Subject: Re: [PATCH v2] MIPS: ralink: fix booting on mt7621 To: NeilBrown , John Crispin , Ralf Baechle , James Hogan CC: , References: <87efkf9z0o.fsf@notabene.neil.brown.name> <87605r9mwf.fsf@notabene.neil.brown.name> From: Matt Redfearn Message-ID: Date: Tue, 20 Mar 2018 11:01:49 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <87605r9mwf.fsf@notabene.neil.brown.name> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.155.41] X-ClientProxiedBy: mipsdag02.mipstec.com (10.20.40.47) To mipsdag02.mipstec.com (10.20.40.47) X-BESS-ID: 1521543705-452060-25377-39749-1 X-BESS-VER: 2018.3.1-r1803192000 X-BESS-Apparent-Source-IP: 12.201.5.32 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.191229 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Neil, On 20/03/18 08:22, NeilBrown wrote: > > Further testing showed that the original version of this > patch wasn't 100% reliable. Very occasionally the read > of SYSC_REG_CHIP_NAME0 returns garbage. Repeating the > read seems to be reliable, but it hasn't happened enough > for me to be completely confident. > So this version repeats that first read. You almost certainly need a sync() to ensure that the write to gcr_reg0 has completed before attempting to read sysc + SYSC_REG_CHIP_NAME0. > > Thanks, > NeilBrown > > > ----------------8<-------------------- > Since commit 3af5a67c86a3 ("MIPS: Fix early CM probing") the MT7621 > has not been able to boot. > > This patched caused mips_cm_probe() to be called before > mt7621.c::proc_soc_init(). > > prom_soc_init() has a comment explaining that mips_cm_probe() > "wipes out the bootloader config" and means that configuration > registers are no longer available. It has some code to re-enable > this config. > > Before this re-enable code is run, the sysc register cannot be > read, so when SYSC_REG_CHIP_NAME0 is read, a garbage value > is returned and panic() is called. > > If we move the config-repair code to the top of prom_soc_init(), > the registers can be read and boot can proceed. > > Very occasionally, the first register read after the reconfiguration > returns garbage. So repeat that read to be on the safe side. > > Fixes: 3af5a67c86a3 ("MIPS: Fix early CM probing") > Signed-off-by: NeilBrown > --- > arch/mips/ralink/mt7621.c | 43 +++++++++++++++++++++++-------------------- > 1 file changed, 23 insertions(+), 20 deletions(-) > > diff --git a/arch/mips/ralink/mt7621.c b/arch/mips/ralink/mt7621.c > index 1b274742077d..c37716407fbe 100644 > --- a/arch/mips/ralink/mt7621.c > +++ b/arch/mips/ralink/mt7621.c > @@ -170,6 +170,29 @@ void prom_soc_init(struct ralink_soc_info *soc_info) > u32 n1; > u32 rev; > > + /* Early detection of CMP support */ > + mips_cm_probe(); > + mips_cpc_probe(); > + > + if (mips_cps_numiocu(0)) { > + /* > + * mips_cm_probe() wipes out bootloader > + * config for CM regions and we have to configure them > + * again. This SoC cannot talk to pamlbus devices > + * witout proper iocu region set up. > + * > + * FIXME: it would be better to do this with values > + * from DT, but we need this very early because > + * without this we cannot talk to pretty much anything > + * including serial. > + */ > + write_gcr_reg0_base(MT7621_PALMBUS_BASE); > + write_gcr_reg0_mask(~MT7621_PALMBUS_SIZE | > + CM_GCR_REGn_MASK_CMTGT_IOCU0); i.e. Try putting a sync() here. > + } > + > + n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0); > + /* Sometimes first read returns garbage, so try again to be safe */ Rather than doing this, which is a bit of a hack and there's no guarantee the second read won't also read garbage without the barrier. Thanks, Matt > n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0); > n1 = __raw_readl(sysc + SYSC_REG_CHIP_NAME1); > > @@ -194,26 +217,6 @@ void prom_soc_init(struct ralink_soc_info *soc_info) > > rt2880_pinmux_data = mt7621_pinmux_data; > > - /* Early detection of CMP support */ > - mips_cm_probe(); > - mips_cpc_probe(); > - > - if (mips_cps_numiocu(0)) { > - /* > - * mips_cm_probe() wipes out bootloader > - * config for CM regions and we have to configure them > - * again. This SoC cannot talk to pamlbus devices > - * witout proper iocu region set up. > - * > - * FIXME: it would be better to do this with values > - * from DT, but we need this very early because > - * without this we cannot talk to pretty much anything > - * including serial. > - */ > - write_gcr_reg0_base(MT7621_PALMBUS_BASE); > - write_gcr_reg0_mask(~MT7621_PALMBUS_SIZE | > - CM_GCR_REGn_MASK_CMTGT_IOCU0); > - } > > if (!register_cps_smp_ops()) > return; >