Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp769917imm; Wed, 8 Aug 2018 05:35:14 -0700 (PDT) X-Google-Smtp-Source: AA+uWPykg8Ocxc//eEWBDtRjxlbnOJupTBAJDAJJ8kiiR5MSA61n4GsU9Yn39bp2bxygxizpDb+K X-Received: by 2002:a62:3703:: with SMTP id e3-v6mr2780835pfa.117.1533731714198; Wed, 08 Aug 2018 05:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533731714; cv=none; d=google.com; s=arc-20160816; b=cYlxjZ3XnTKw6V5YBtvO5Ls4nm0yxuy3LEiUtRAR5KD5isPBd6yOrVHD7wyIg41DQA cxpDLRkYkevIrB2qmAQV3c0nsfTRzSvvSECCtgpabRdNqgy7CPgLU30nSFU9V4mgsShH B14F5cffp9nYHlY7PyYBZ75dp88Cv0j1KEFyaQZABXmOv2C9mUhqgHLcL6mAweS4nPyf GcgQ+xTtdRvm2D+Ad5LlZURKhvLSqhEvEXHCxUkd4+MCjpYnsRaGekvNvqy+JS000Ikr PH6xF/ICP1h6q3sOemG1FDHtexyRkEXMqLSFJqmOYmWCG4ll+UE8y5pw/4SOtfkMIlC4 oCpw== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=k55ITjpQR48/rHyGVCGT+21KFe9k74AzpCGCl8wwRg4=; b=hGveAPgSZFD9bw8mts208uJe6lXMe/q3aHkj9Ikx23V7KR4M/+p/9FbvLRxI+wZ4Kj wRyh8jqof1pqhlfph+q/8Qv8oBzO6JJe5gGkHbmla3mtdVRNHLkVZtY7cHHM6FVQ1GvD 7MkKMN8eNFl9UpqSL5wcCYCnxrkiaJEMTU1NCDwZqoSXZOKpQfHmvwoF7gOFtUeftzyx qxzTqASb0L+cI3oOUjBMr2Ry/0kAvrLuHbdV62suoX9ovdx0a0UBFi3f0x1Yictn+9vp qRhl1ALk9Ta/HTQ08AeNKOSeOWr/pS4odbwJFFJlQzmURS8BWn/WXoriiXz/sBQYzwLD v2ZA== 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 1-v6si3245018plr.148.2018.08.08.05.34.59; Wed, 08 Aug 2018 05:35:14 -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 S1727172AbeHHOxe convert rfc822-to-8bit (ORCPT + 99 others); Wed, 8 Aug 2018 10:53:34 -0400 Received: from mail.bootlin.com ([62.4.15.54]:58899 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726733AbeHHOxe (ORCPT ); Wed, 8 Aug 2018 10:53:34 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id CB2042084E; Wed, 8 Aug 2018 14:34:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from xps13 (AAubervilliers-681-1-99-143.w90-88.abo.wanadoo.fr [90.88.4.143]) by mail.bootlin.com (Postfix) with ESMTPSA id 7732020741; Wed, 8 Aug 2018 14:33:51 +0200 (CEST) Date: Wed, 8 Aug 2018 14:33:52 +0200 From: Miquel Raynal To: Kurt Kanzenbach Cc: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Masahiro Yamada , Gregory CLEMENT , Jane Wan , Jagdish Gediya , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mtd: nand: fsl-ifc: fixup SRAM init for newer ctrl versions Message-ID: <20180808143352.2f5b999c@xps13> In-Reply-To: <20180808100909.anfi3qlfjnzb74p2@linutronix.de> References: <20180806092137.9287-1-kurt@linutronix.de> <20180806092137.9287-3-kurt@linutronix.de> <20180808114832.61d31c29@xps13> <20180808100909.anfi3qlfjnzb74p2@linutronix.de> Organization: Bootlin X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kurt, > > > @@ -769,6 +770,23 @@ static int fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) > > > uint32_t csor = 0, csor_8k = 0, csor_ext = 0; > > > uint32_t cs = priv->bank; > > > > > > + if (ctrl->version > FSL_IFC_VERSION_1_1_0) { > > > > This is redundant and fsl_ifc_sram_init() is called only if > > "ctrl->version > FSL_FC_VERSION_1_1_0". > > No, it's not. It's called when ctrl->version >= > FSL_IFC_VERSION_1_1_0. Therefore, this check is needed. Oh right, I missed the "=". > > > > > So this means this function has never worked? > > It did work for e.g. IFC controller in version 1.1.0. > > However, it worked for the newer versions by accident, because U-Boot > already initialized the SRAM correctly. If you boot without NAND > initialization in U-Boot, then you'll hit the issue. > > > > > If this is the case, there should be at least a Fixes: tag. > > > > Maybe it would be cleaner to always call fsl_ifc_sram_init() from the > > probe(), and just exit with a "return 0" here if the version is old? > > (I'll let you choose the way you prefer). > > Sounds like a good idea. Otherwise we have to check the version twice. > > > > > > + u32 ncfgr, status; > > > + int ret; > > > + > > > + /* Trigger auto initialization */ > > > + ncfgr = ifc_in32(&ifc_runtime->ifc_nand.ncfgr); > > > + ifc_out32(ncfgr | IFC_NAND_NCFGR_SRAM_INIT_EN, &ifc_runtime->ifc_nand.ncfgr); > > > + > > > + /* Wait until done */ > > > + ret = readx_poll_timeout(ifc_in32, &ifc_runtime->ifc_nand.ncfgr, > > > + status, !(status & IFC_NAND_NCFGR_SRAM_INIT_EN), > > > + 10, 1000); > > > > Nit: I always prefer when delays/timeouts are defined (and may be > > reused). > > Me too. I've missed that there is already a timeout constant > IFC_TIMEOUT_MSECS (500). As it's huge, I'll add a second one. Well, I'm not bothered with huge timeouts, it's in the error path so we don't really care. Thanks, Miquèl