Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2014475imm; Thu, 24 May 2018 04:32:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpZeXPJWDvPHFJJaDqqEBIDSAI3iyVfFNvtDeTFt4OpMD9S3tOg5Nq1OpSLzL7jikpfN34S X-Received: by 2002:a17:902:bd82:: with SMTP id q2-v6mr6926388pls.77.1527161539277; Thu, 24 May 2018 04:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161539; cv=none; d=google.com; s=arc-20160816; b=dZCwq9aIINJpaoZbQc446LKAnkfylDu/FeGRNDS0PlNw/LLKVBBWHfVWIEGmGNgR3f xrXQZrkjAprjuckT3Vki/O29g7mxzzvn42jBgSfR0HLx/Teee7Yd3LA5ESpW0F1LRNPP EFbA3kLu5J1Racf+NhL5O+crVr6iNOl+gFFBnkWXIzX7AkXJJ6ogx6Zupo1NlL92A6Rf M07xsWBCjmr0pAin+6brcpJWHFMgwckMAAAO8/6CXDxoxSPWKStd7XsvhlMcb5ilOHVd NQMitXh5bDdksh4Ve4QLD7Ui244z7Tv7I5nnxkFlRBpU+Hg+nXd1xQWS9AKxYue+nP0V 85ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ek10nw6bJzABKcGf4m/kQ9f/Xwq5o+P8MRat0CjVEO8=; b=dRCuR0v7F5BrzH66fkIw5X3GL11uncJ73+Rc7cGD/gEJoSdSm1FmyaJRixgXqPF76E wUyHUdmEPhnCHDsJNjVqLBk2Ed6wj/JIAdRBk0Lt5ZLJPuv9Jwx9yMBkdqBl0qxnC8AI 2EmQ1h5Us335y1cviBQt/T2e3p+DIwqwK1kFatqz5JYXn+DB/dpa/pNieWxqnjtTK+NF YQDiAscPMMEo2MNC7jYP0EANz5ekKgVDFppB6WnTh+kluka27c2rnQDSz9iVxxHmGlU6 lM4Q0ZNZtYqCQr4dtAWiZLoRbiSdL5T+QtyULwzNns3ntkwy7xPU9J0hW8jHmK0c5rqr yiyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@endian-se.20150623.gappssmtp.com header.s=20150623 header.b=QAOU5KAD; 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 c10-v6si1907654plz.190.2018.05.24.04.32.04; Thu, 24 May 2018 04:32:19 -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=@endian-se.20150623.gappssmtp.com header.s=20150623 header.b=QAOU5KAD; 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 S968953AbeEXLa0 (ORCPT + 99 others); Thu, 24 May 2018 07:30:26 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:41249 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968877AbeEXLaQ (ORCPT ); Thu, 24 May 2018 07:30:16 -0400 Received: by mail-yw0-f193.google.com with SMTP id u71-v6so414542ywf.8 for ; Thu, 24 May 2018 04:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endian-se.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ek10nw6bJzABKcGf4m/kQ9f/Xwq5o+P8MRat0CjVEO8=; b=QAOU5KAD33l+cMRYtjWRVv9RnbEK3GmtjtAxKtlzKPyFpQ7muV04HSNf9QVzA+5tSC zpEjljk8OGhR/NI6U6RpT6SLO1s8/+J7H553R8U4PTCyOzW9Tx5BLnSQk+fVIUuy+VRt pns+aMNXC/MaRTHJgHeoytUCrM2MtcW99QY4v4QwQyT0jn3r8q0BhcjlLINcaIerhnUF 9NOwkHJm8FurwXjurSMiOORt+0p2Gb7BTM3Zbv9F6IJU79LpaTHIailqrNe3IGb1owx7 xsL6YrInUEY7dXWeyhhp0ZWFsBBaE3JQtCms/uPJxlIdP6RJqykBiyI9H8JAJozC8QMQ 438g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ek10nw6bJzABKcGf4m/kQ9f/Xwq5o+P8MRat0CjVEO8=; b=l6ckbMGYy8/kiHue2CQWodmkPVvGKEDdecXPAFU3+wWxAykThDyvTt8208Mmxzq0by agQ/ALuC1DM2PiH70hg6/HZVDsOhCgQM4sWOJW5agSDZIOg+34D8p68f22Wix+1voZJl hKHmLZCfOeNhSpgGYpp703H+CsIWtHmYu3+64gfIO8AwcJgIJsxAxZ4A1KV+6lrAUq3T B0kR32K+p1KbXrDkwucSlp+4yCHs87DxBdXKVXxyYDPTsyImc5nuAkKx9p/Ju0DXzvZ9 JVHd0xIpuvWOldreKMSiYn8atFPh5j/XN90KdyfDR+tjCeFKt2+1s2Sc6Q04E3MNPAYy tJiw== X-Gm-Message-State: ALKqPwf3Iu3KcnLjjcvAHdrexz54K2glRABGXcFk+v+9TPPELiRIpBvV FxiYj2RxyAk2U2hhLWtobZGs8jwSxczYpaITD9sNmg== X-Received: by 2002:a81:5217:: with SMTP id g23-v6mr3721713ywb.230.1527161415119; Thu, 24 May 2018 04:30:15 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:2d26:0:0:0:0:0 with HTTP; Thu, 24 May 2018 04:30:14 -0700 (PDT) In-Reply-To: References: <86fdf19ec92b732709732fb60199f16488b4b727.1526990589.git.stefan@agner.ch> From: Benjamin Lindqvist Date: Thu, 24 May 2018 13:30:14 +0200 Message-ID: Subject: Re: [RESEND PATCH 2/5] mtd: rawnand: add NVIDIA Tegra NAND Flash controller driver To: Stefan Agner Cc: boris.brezillon@bootlin.com, dwmw2@infradead.org, computersforpeace@gmail.com, marek.vasut@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, thierry.reding@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, Lucas Stach , miquel.raynal@bootlin.com, richard@nod.at, marcel@ziswiler.com, krzk@kernel.org, digetx@gmail.com, jonathanh@nvidia.com, pdeschrijver@nvidia.com, pgaikwad@nvidia.com, Mirza Krak , linux-mtd@lists.infradead.org, linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org 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 Hi Stefan, It seems to me that a probe similar to what the BootROM does shouldn't be awfully complicated to implement - just cycle through the switch cases in case of an ECC error. But I guess that's more of an idea for further improvements rather than a comment to the patch set under review. However, I think that allowing for an override of the oobsize inference would be a good idea before merging, no? This could just be a trivial #ifdef (at least temporarily). If you agree but don't feel like doing it yourself, I'd be happy to pitch in. Let me know. Best regards, Benjamin 2018-05-24 13:00 GMT+02:00 Stefan Agner : > On 24.05.2018 09:45, Benjamin Lindqvist wrote: >> Hi Stefan (and all), >> >> First off, I apoloigize in advance if I'm deviating from common >> kernel mailing list courtesy -- this is my first time responding. >> I just have a comment on the NAND driver that I'd like to bring >> to the public. >> > > Welcome! > >>> + switch (mtd->oobsize) { >>> ... >>> + case 224: >>> + mtd_set_ooblayout(mtd, &tegra_nand_oob_224_ops); >>> + chip->ecc.strength = 8; >>> + chip->ecc.bytes = 18; >>> + value |= CFG_ECC_SEL | CFG_TVAL_8; >>> + break; + case 224: >> >> I am not sure how you arrived at this oobsize-based inference. I >> have not seen any explicit relation between oob size and ECC >> algorithm used in the reference manual. Indeed, the U-Boot I was >> working on (a fork of the Toradex 2015.04 U-Boot) always has >> oobsize == 224 but used either BCH[t=16] or RS[t=4]. In fact, we >> tried choosing RS[t=8] in U-Boot but we failed to make the >> BootROM decode this at all. So we had to use RS[t=4]. But >> changing the algorithm did not automatically change the oobsize, >> at least it didn't for us. So maybe you should consider if this >> is really the way to go about deciding which algorithm is used. > > The oobsize based inference to set the HW ECC mode comes from the > patchset I picked up. Typically, the size of the OOB area is such that > it allows "good enough" error correction required for that chip. So > using it as indicator for the ECC algorithm is not entirely off... > > But yeah I agree we have better means, and I already started working on > a better mechanism. Also, I worked on BCH support, and it looks pretty > good already. > > If we want to auto select mode we can use the ECC requirements from > ONFI/JEDEC/parameter page. Or we could use device tree only. > > Thanks for bringing up the Boot ROM issue. In fact I investigated the > supported modes the recent days too. First off, as you mentioned, the > boot ROM seems to probe different modes until it succeeds. By trying > through all RS and BCH modes, it seems that it only probes some modes: > - RS t=4 > - BCH t=8 > - BCH t=16 > > I guess those are preferred modes in practise. Not sure if we should > make sure the auto selection such that it only chooses from this list... > >> >> Note that we're in fact using this patch set in Linux today, but >> we had to remove the oobsize inference part. Currently we're >> simply hard coding it to CFG_TVAL_4, but maybe it would be >> cleaner to add ECC algo as a board config instead, e.g. in the >> .dts file or whatever. This seems to be done by other vendors >> already, see for example excerpt of >> Documentation/devicetree/bindings/mtd/gpmc-nand.txt below: >> >> - ti,nand-ecc-opt: A string setting the ECC layout to use. One of: >> "sw" 1-bit Hamming ecc code via software >> "hw" use "ham1" instead >> "hw-romcode" use "ham1" instead >> "ham1" 1-bit Hamming ecc code >> "bch4" 4-bit BCH ecc code >> "bch8" 8-bit BCH ecc code >> "bch16" 16-bit BCH ECC code >> Refer below "How to select correct ECC scheme for your device ?" >> >> It seems as if this method would be equally applicable to Tegra NAND. > > Yeah, ideally we can reuse "nand-ecc-algo". Although, Reed-Solomon is > not yet in the list. So using this property would require to extend > this standard property. > > -- > Stefan