Received: by 10.213.65.68 with SMTP id h4csp891491imn; Tue, 27 Mar 2018 10:41:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx484jafxRNDYMpAETUJ8lPpRedHiQz9Xc6D9MKRberhswiqxKowrwc3CzFHFGjL4gBGv+NkV X-Received: by 2002:a17:902:a9c4:: with SMTP id b4-v6mr222931plr.333.1522172463244; Tue, 27 Mar 2018 10:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522172463; cv=none; d=google.com; s=arc-20160816; b=Qhn4FqrQyB3VnyWaAhKcF8WfEByWoVBtx+dkokJ0tNL/5b09u03MmTR4FLFqcgH/06 Ik8d30FElzfySf43r+qU9Kwi/V68cV5pTh/+RcxHGxbuRoJWjtDncyj+Fbrq5jEWXWUN r8Exfy+RY33AHOs47vv97TAS/cALEhrbSYTRBk5UGwnwsE29oO6lZXkzYn53gDHFFwYU NKjUVJFri2nUxL9vhRcmxNjjvewDZAKLLMhdPOwYsoebkkrlUyxKQ7nRODdByd7xo3Xc 5ERZ5iw+R9OdYYlv/uHWX3vqmVSWSq5FO6Oq70f5NfK75dwTaoZ7EItbaDTtaocbwDUq uiWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zLB1pe7uTOG8xY1yemv3EXuA1zq3wslZMy63eR4xCvI=; b=Mmf/KuFHrcR+vMdVhoAMor9e9EglYJxDECzA/Jde8q4iS/3aln7NPvbJWcG2PLNR1W dyv6IbcNNUwdkGN3GcrQJ/UxDgb09zXk88tBg0pEEP82z3i1ANWw963Zsa7SkxcG8FMC SPyS/YZSm6ryMf+uU5254SRQqx7NOPxIKs1tyCYYT/GLnpn7fE7R7fUmDvlIwjI4+NeE NXUvOFGXYGneDK9h2gfQL0kd3o2Gib8sL7mj29x++62jsa0MpRik49oKsZprFZU9dmR1 qzGPOo1CRd5gVuXWdIwQyhA1+zdk7Nikmn8Ea3pRt0wfYacQ2ZJwJGQByczRlHYRGTTC znNA== 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 r25si1105908pge.759.2018.03.27.10.40.48; Tue, 27 Mar 2018 10:41:03 -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 S1754347AbeC0Rjs (ORCPT + 99 others); Tue, 27 Mar 2018 13:39:48 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44336 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754207AbeC0QeT (ORCPT ); Tue, 27 Mar 2018 12:34:19 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 199621219; Tue, 27 Mar 2018 16:34:18 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, NeilBrown , Matt Redfearn , John Crispin , Ralf Baechle , linux-mips@linux-mips.org, James Hogan Subject: [PATCH 4.14 002/101] MIPS: ralink: Fix booting on MT7621 Date: Tue, 27 Mar 2018 18:26:34 +0200 Message-Id: <20180327162750.137919079@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162749.993880276@linuxfoundation.org> References: <20180327162749.993880276@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: NeilBrown commit a63d706ea719190a79a6c769e898f70680044d3e upstream. Since commit 3af5a67c86a3 ("MIPS: Fix early CM probing") the MT7621 has not been able to boot. This commit 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 add a call to __sync(). Fixes: 3af5a67c86a3 ("MIPS: Fix early CM probing") Signed-off-by: NeilBrown Reviewed-by: Matt Redfearn Cc: John Crispin Cc: Ralf Baechle Cc: linux-mips@linux-mips.org Cc: # 4.5+ Patchwork: https://patchwork.linux-mips.org/patch/18859/ Signed-off-by: James Hogan Signed-off-by: Greg Kroah-Hartman --- arch/mips/ralink/mt7621.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) --- a/arch/mips/ralink/mt7621.c +++ b/arch/mips/ralink/mt7621.c @@ -170,6 +170,28 @@ void prom_soc_init(struct ralink_soc_inf 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); + __sync(); + } + n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0); n1 = __raw_readl(sysc + SYSC_REG_CHIP_NAME1); @@ -194,26 +216,6 @@ void prom_soc_init(struct ralink_soc_inf 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;