Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3798525imm; Mon, 18 Jun 2018 04:22:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJf9352V4Pz/JYo+gjlpn0fQjvgbRsMBVNbRhJhL+FVeHHAa68UKJreaPKaLvD09W/YvJ7r X-Received: by 2002:a17:902:aa87:: with SMTP id d7-v6mr8106432plr.215.1529320948727; Mon, 18 Jun 2018 04:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529320948; cv=none; d=google.com; s=arc-20160816; b=Rg8MK6IPP7GW/xs852jAU78vpTRGib8FIu3AXWC5OfOQFA9Nq8Cswpw8G276t84R3x Zq1Urpek20VVycBQO1D7ttl5QRVdG6oVwTCuvxIly7elOw14mc0Soe7oatu+5n5h8gmn ARmEosi6uZZK1Jc2D6JBkrVogzCuyefNysyHpP4EZ3vMTrS90GhEfAR3WzTc0Ll6QLvZ Ea0V/0uoqQp+/WrA/sNtb5bGtZsGT3CTotuQjmb1Y+QLP+RIiiRccnk+kIL6Bs0LxZy6 fCTjIH1L8Jerw0w4/CWU9Qj6iLfVXe+B4yblPeEFGCtt9iSctr6vz2NbB9qRejGyznD2 Snlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:arc-authentication-results; bh=9Wtp+OMiqpQa9hbGe/uDtSIE1vEfRcochXnZGooTROM=; b=kH/yNdQs8r5RnqRFZtL97fnLfcwxMUHlu3a9g8R/I8vlfMoaB+aDNjzkONQo8gpMtU VM80TZh5mJilX4GCDB6v3CGxLSQBrfGX3n1NV4OWp2b3FIP0YAEjRJBt4pMAJLZF5rAY eJKD+EIpHZDygj05+6j/Mpni811yvLwOyfYzIPuxzeSDvcyVolRmdBs+QhbUKSiCBvWZ OkmJD1b37DtSBgRg9f5QbTLHHPDBAA184ZsEylgIq4DNbwNyua+uuB/3Q+SBE5SRsoiE GJExcmgYKGIARASUAq51OS79kjewO2Phm7iI6uoeehZ7s9FZqrj/5S1IjdQ7udJ83Eit v8PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=QrdruBvq; 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 73-v6si15862677pld.450.2018.06.18.04.22.15; Mon, 18 Jun 2018 04:22:28 -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=@agner.ch header.s=dkim header.b=QrdruBvq; 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 S935160AbeFRKv7 (ORCPT + 99 others); Mon, 18 Jun 2018 06:51:59 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:55778 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932612AbeFRKv4 (ORCPT ); Mon, 18 Jun 2018 06:51:56 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id F052E5C00F6; Mon, 18 Jun 2018 12:51:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1529319114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Wtp+OMiqpQa9hbGe/uDtSIE1vEfRcochXnZGooTROM=; b=QrdruBvqbBOHTIZ77QzY/6VJ6ukphcaTFxOy8/KW9+uP2kyIxN7470dFl8xz1254A56Rwd 0eT+rrVB+Pd/BVA7exwIdS+cJ/CbE1PMPEKlcDniqvHV4Qp3MaPy7pJTPVMGl9GpecFSmp t38ii5b7NTMlm5qUQqbwXoCUJX5GfmM= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Mon, 18 Jun 2018 12:51:52 +0200 From: Stefan Agner To: Boris Brezillon Cc: dwmw2@infradead.org, computersforpeace@gmail.com, marek.vasut@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, thierry.reding@gmail.com, dev@lynxeye.de, miquel.raynal@bootlin.com, richard@nod.at, marcel@ziswiler.com, krzk@kernel.org, digetx@gmail.com, benjamin.lindqvist@endian.se, jonathanh@nvidia.com, pdeschrijver@nvidia.com, pgaikwad@nvidia.com, mirza.krak@gmail.com, gaireg@gaireg.de, linux-mtd@lists.infradead.org, linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 0/6] mtd: rawnand: add NVIDIA Tegra NAND flash support In-Reply-To: <20180618115806.7be25499@bbrezillon> References: <20180617204605.4648-1-stefan@agner.ch> <20180618115806.7be25499@bbrezillon> Message-ID: <95279b61ce2630c1276669359b163933@agner.ch> X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.4 X-Spamd-Result: default: False [-0.10 / 15.00]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCPT_COUNT_TWELVE(0.00)[23]; TAGGED_RCPT(0.00)[dt]; MIME_GOOD(-0.10)[text/plain]; FROM_HAS_DN(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; ASN(0.00)[asn:29691, ipnet:2a02:418::/29, country:CH]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[32.81%]; ARC_NA(0.00)[] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18.06.2018 11:58, Boris Brezillon wrote: > On Sun, 17 Jun 2018 22:45:59 +0200 > Stefan Agner wrote: > >> Changes definitly calm down, most noteably probably the changes >> around checking whether a page is empty if the stack reports ECC >> errors.. I verified the code using raw nandwrites with OOB to >> simulate an empty page which has some bits flipped in the OOB area, >> everthing seems to work as I would expect it. >> >> For now I do not check extra OOB bytes since those are at variable >> locations depending on algorithm. > > Hm, if you expose them as free OOB bytes, you should also check them, > otherwise you might end up with corrupted data without noticing it. Note > that, depending on whether those free OOB bytes are ECC-protected or > not, you should change the way you do the check: > > - non-protected OOB bytes: all bytes should be 0xff (no bitflips > allowed) > - data+free OOB bytes protected by the same ECC bytes: you should pass > the free OOB bytes buffer to nand_check_erased_ecc_chunk() along with > the data and ECC buffers > - free OOB bytes have their own ECC bytes: call > nand_check_erased_ecc_chunk() separately and pass it the ECC + free > OOB buffers. This graphic taken from the public Tegra 2 Technical Reference Manual is quite useful: https://imgur.com/a/0Hqzbkc Tegra basically has all of the above, which makes the whole business really tricky... I am not sure if we really could do variant 1, non-protected OOB, but since we have the option of protected OOB, we probably anyway would do that. RS/Hamming implements variant 3. BCH implements variant 2. OOB is protected with the last data buffer. So this would require a algorithm depending implementation, which is probably not a big deal. But there is one more issue with BCH: Only if extra data are actually transferred, tag space is actually allocated. If no tag bytes are transferred, parity follows immediately skip bytes. As far as I know the MTD stacks OOB layout assumes that is always the same layout, no matter whether we write extra OOB data or not. For the Tegra NAND controller this would mean that we have to always transfer tag bytes and therefor penalize the use case we are most interested in (which is no extra OOB bytes, since UBI does not make use of it)... Furthermore I realized that testing is not easily possible since nandwrite with --oob seems not to make use of "oob_required" in the main page write but issues a separate OOB write command. I did not found a way to issue a write from user space which sets oob_required... Due to all this I rather prefer to not implement extra OOB support at this point. How do I do this properly? Set mtd_ooblayout_ops.free to NULL? -- Stefan > >> >> -- >> Stefan >> >> Changes since v1: >> - Split controller and NAND chip structure >> - Add BCH support >> - Allow to select algorithm and strength using device tree >> - Improve HW ECC error reporting and use DEC_STATUS_BUF only >> - Use SPDX license identifier >> - Use per algorithm mtd_ooblayout_ops >> - Use setup_data_interface callback for NAND timing configuration >> >> Changes since v2: >> - Set clock rate using assigned-clocks >> - Use BIT() macro >> - Fix and improve timing calculation >> - Improve ECC error handling >> - Store OOB layout for tag area in Tegra chip structure >> - Update/fix bindings >> - Use more specific variable names (replace "value") >> - Introduce nand-is-boot-medium >> - Choose sensible ECC strenght automatically >> - Use wait_for_completion_timeout >> - Print register dump on completion timeout >> - Unify tegra_nand_(read|write)_page in tegra_nand_page_xfer >> >> Changes since v3: >> - Implement tegra_nand_(read|write)_raw using DMA >> - Implement tegra_nand_(read|write)_oob using DMA >> - Name registers according to Tegra 2 Technical Reference Manual (v02p) >> - Use wait_for_completion_io_timeout to account for IO >> - Get chip select id from device tree reg property >> - Clear interrupts and reinit wait queues in case command/DMA times out >> - Set default MTD name after nand_set_flash_node >> - Move MODULE_DEVICE_TABLE after declaration of tegra_nand_of_match >> - Make (rs|bch)_strength static >> >> Changes since v4: >> - Pass OOB area to nand_check_erased_ecc_chunk >> - Pass algorithm specific bits_per_step to tegra_nand_get_strength >> - Store ECC layout in chip structure >> - Fix pointer assignment (use NULL) >> - Removed obsolete header delay.h >> - Fixed newlines >> - Use non-_io variant of wait_for_completion_timeout >> >> Lucas Stach (1): >> ARM: dts: tegra: add Tegra20 NAND flash controller node >> >> Stefan Agner (5): >> mtd: rawnand: add Reed-Solomon error correction algorithm >> mtd: rawnand: add an option to specify NAND chip as a boot device >> mtd: rawnand: tegra: add devicetree binding >> mtd: rawnand: add NVIDIA Tegra NAND Flash controller driver >> ARM: dts: tegra: enable NAND flash on Colibri T20 >> >> .../devicetree/bindings/mtd/nand.txt | 6 +- >> .../bindings/mtd/nvidia-tegra20-nand.txt | 64 + >> MAINTAINERS | 7 + >> arch/arm/boot/dts/tegra20-colibri-512.dtsi | 16 + >> arch/arm/boot/dts/tegra20.dtsi | 15 + >> drivers/mtd/nand/raw/Kconfig | 6 + >> drivers/mtd/nand/raw/Makefile | 1 + >> drivers/mtd/nand/raw/nand_base.c | 4 + >> drivers/mtd/nand/raw/tegra_nand.c | 1268 +++++++++++++++++ >> include/linux/mtd/rawnand.h | 7 + >> 10 files changed, 1393 insertions(+), 1 deletion(-) >> create mode 100644 Documentation/devicetree/bindings/mtd/nvidia-tegra20-nand.txt >> create mode 100644 drivers/mtd/nand/raw/tegra_nand.c >>