Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp851244ybt; Sun, 14 Jun 2020 01:56:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeMHQ4HVREloXvGJxdEjhfGrE7M7v8Oky4ycv7H+MY2sP0kKX2vsTiJG0lhPTJ9kTNqHMo X-Received: by 2002:a17:906:da05:: with SMTP id fi5mr21210855ejb.95.1592124979806; Sun, 14 Jun 2020 01:56:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592124979; cv=none; d=google.com; s=arc-20160816; b=xHoLbIkokxYeDkezCMyIOFH3H11z6sApE3Tgz0wlGAi9MHoJwhF32sB3n6RgcFQDlx twLaSzEGTBxYeSY4LKhDQ6gHe7B7hIDfRGYlaGnDtCdZqIejRQDa8qc0UQtCQ9aGi87p K6qeBaY17ucy+1Q+f6D6CJHF9l1VmWLox7OcRKhKZPEx8wgml60F5xPKV6FGRVuGybKt FrU2GHJY7OzwquqfeQ/f7/559gn5C3/KI3+VOcMW5LUuyVsqLV2Tf6johQJ9VzlpV5Xl FjPs1UEcFs6Lam54T25WKidxgSR/0R59xXazKrcpo03A6sAotX4biNClMgtSLk6/27+I eTfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=b3VS3PUglWU05RRagqbS4YBCgN8jvE9wxE1b+IXwJg8=; b=MG8fqpws7MomSc+/8oHw42VV2oPNhbgQS9HBZh+f+aQ1XSp8QLpyHVJZ3MCV0FryVu WSaRe4khdfr0YqyqIE6srADcGflXQ/TlgyibbHrfA0E3bTd6pitDvYPOS1H1OfgmJMe/ PiENqYouKz5TiH1yfNOCpDj4PKW9g1nN9OGvSVLvjj7/s05jYKcVW77ssKed1CEZ+rES LZiESV+kvqpnB0+4BfIYjQ+5hz+vvMJqr8uF/Vh+pxIw3C7W6P/Vn9qSGrddq8fTfhKR TZODmy1elpfO0lj2HoTBH/KWROEfq8GJOu7mx1EbMfBUJxHWy2YuP/NejpWGAsSyP/+E C9bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=k1x2oowR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i21si6853065ejj.293.2020.06.14.01.55.56; Sun, 14 Jun 2020 01:56:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=k1x2oowR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726889AbgFNIxO (ORCPT + 99 others); Sun, 14 Jun 2020 04:53:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbgFNIxO (ORCPT ); Sun, 14 Jun 2020 04:53:14 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85D99C03E969; Sun, 14 Jun 2020 01:53:12 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id l11so14053133wru.0; Sun, 14 Jun 2020 01:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=b3VS3PUglWU05RRagqbS4YBCgN8jvE9wxE1b+IXwJg8=; b=k1x2oowRu/p8CYe184hdaKdH+WgpxyUJ+jcROT3XOzPxfk63JicjMP0IKR7jvEyDAw Sxd5owQsw6RlmbM3iPX3sSjx8esbZCIHtyF2ogc95RQ59bQlh7gnnLgmpi2GmzBdZEYC FH6UaRk6pgJGIEaTAV5EeFUGYkdygxAaCzRTypJOs9WFFMal2nQp5dofFTBwncbNNssJ hTvnGpfAxTDSdJR+rdutMx+YbXIy7br3FJwdq2jwAPVjUJptN2+9Q4TfWZcf+i6tJtVp J5G1q8tIRGXWd2aO5tgrKVFmv+KC9ZfnNaLdkFKMriKWZ4U24jOiXKe6OMrttXyexFbV 8OBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=b3VS3PUglWU05RRagqbS4YBCgN8jvE9wxE1b+IXwJg8=; b=LI7CCxRvhKFU7Fc9qOVdjy4OLPSmNjvPOPY+94mTHXQqITJoz1fWaJCzPejwnxqiUs MIfxLHpOPnZMaPHq+RxERl9BjgJpMGsyM1X2KhVMsMSzeX9gOJm6pX6KaKMB9qOnDH5q Oa+j1ACU8Toq0T+DnePab4O9RL+S/q5Dj1y9qGWARbueib2tCZ0bf8zFOI97eO6aES6m CA/BrePmgz4fRqTaz4k2GKf4cAq6/4jRyj6CvmstOqEJvj6yfwps4SGFr83bX0M3G7Jm 6xVDf3lSiFirb1xuC5Ogq/Ca/83D3cZCmJkofDv8ob6dcvoxPlnz3yb6gXN7ZHQuWtOo 7TEw== X-Gm-Message-State: AOAM533nI//rfpZxc3jtTvhVeZYTB6hg+SXWWM6CgIhzkwSe27vNASh3 fZefk1IdLxccQfMVeUkDmGc= X-Received: by 2002:a5d:4701:: with SMTP id y1mr23136233wrq.310.1592124790802; Sun, 14 Jun 2020 01:53:10 -0700 (PDT) Received: from macbook-pro-alvaro-eth.lan (168.red-88-20-188.staticip.rima-tde.net. [88.20.188.168]) by smtp.gmail.com with ESMTPSA id a81sm18162266wmd.25.2020.06.14.01.53.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jun 2020 01:53:10 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] mtd: rawnand: brcmnand: force raw OOB writes From: =?utf-8?Q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= In-Reply-To: Date: Sun, 14 Jun 2020 10:53:09 +0200 Cc: Brian Norris , Miquel Raynal , Richard Weinberger , "R, Vignesh" , Sumit Semwal , MTD Maling List , bcm-kernel-feedback-list , Linux Kernel Mailing List , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20200605170720.2478262-1-noltari@gmail.com> <05C962F2-7D3B-4103-91DD-8D31C439D521@gmail.com> To: Kamal Dasu X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kamal, > El 13 jun 2020, a las 17:16, Kamal Dasu = escribi=C3=B3: >=20 > Alvaro, >=20 >=20 > On Sat, Jun 13, 2020 at 5:01 AM =C3=81lvaro Fern=C3=A1ndez Rojas > wrote: >>=20 >> Hi Kamal, >>=20 >>> El 12 jun 2020, a las 20:47, Kamal Dasu = escribi=C3=B3: >>>=20 >>> On Fri, Jun 5, 2020 at 1:07 PM =C3=81lvaro Fern=C3=A1ndez Rojas = wrote: >>>>=20 >>>> MTD_OPS_AUTO_OOB is writting OOB with ECC enabled, which changes = all ECC bytes >>>> from an erased page to 0x00 when JFFS2 cleanmarkers are added with = mtd-utils. >>>> | BBI | JFFS2 | ECC | JFFS2 | Spare | >>>> 00000800 ff ff 19 85 20 03 00 00 00 00 00 00 08 ff ff ff >>>>=20 >>>> However, if OOB is written with ECC disabled, the JFFS2 = cleanmarkers are >>>> correctly written without changing the ECC bytes: >>>> | BBI | JFFS2 | ECC | JFFS2 | Spare | >>>> 00000800 ff ff 19 85 20 03 ff ff ff 00 00 00 08 ff ff ff >>>=20 >>> Both brcmand_write_oob_raw() and brcmnand_write_oob() use >>> brcmnand_write() that uses PROGRAM_PAGE cmd, means also programs = data >>> areas and ECC when enabled is always calculated on DATA+OOB. since >>=20 >> Are you sure about that? I think that HW ECC is only calculated for = DATA, not for OOB. >> The fact that we=E2=80=99re not writing any DATA seems to be the = problem that is changing all ECC bytes to 0x00. >>=20 >=20 > Only true for 1-bit hamming code on early controller versions. For > BCH algorithms both data+oob are covered. And the controller driver > intentionally does not implement a spare area program cmd, even for > OOB writes. Also BRCMNAND_ACC_CONTROL_PARTIAL_PAGE=3D0 (when present) > does not allow for spare areas only writes. >=20 >>> in both cases we only want to modify OOB, data is always assumed to = be >>> 0xffs (means erased state). So as far as this api always is used on >>> the erased page it should be good. Are the sub-pages/oob areas read = by >>> jffs2 also read without ecc enabled?. Just want to be sure that it >>> does not break any other utilities like nandwrite. >>=20 >> No, sub-pages/oob areas read by JFFS2 with ECC enabled. >> I don=E2=80=99t think this breaks anything at all, since I tested = nandwrite with OOB enabled and everything was written perfectly. >>=20 >=20 > Going by the commit message you are assuming 1-bit hamming code, that > is the only exception on early version controllers where only data was > covered for ecc calculations when enabled. > Which version of the controller are you using ?. Did you test with > BCH-4 or any BCH ?. All my devices use hamming ECC, even the ones with controller version = v4.0 (BCM63268), which should also support BCH. Therefore I need to stick with hamming ECC if I want the bootloader to = be able to boot the kernel. However, I should get a new device with BCH in a few days. I=E2=80=99ll do more tests once I get it, but if BCH also covers OOB, = then we could conditionally force write_oob to RAW only if hamming is = configured. >=20 >> BTW, I tried another approach that forced MTD_OPS_AUTO_OOB to be = written as raw OOB, but it was rejected: >> = http://patchwork.ozlabs.org/project/linux-mtd/patch/20200504094253.2741109= -1-noltari@gmail.com/ >> https://lkml.org/lkml/2020/5/4/215 >>=20 >=20 > Are there any other use cases other than jffs2 where only oob needs to > be modified ?. But surely intentionally disabling ecc instead of > forcing it is the way, but I am not sure it will still work for other > BCH algorithms though where both data and oob are covered. I=E2=80=99ll test this and report back once I get my new device. >=20 >>>=20 >>>>=20 >>>> Signed-off-by: =C3=81lvaro Fern=C3=A1ndez Rojas >>>> --- >>>> drivers/mtd/nand/raw/brcmnand/brcmnand.c | 9 +-------- >>>> 1 file changed, 1 insertion(+), 8 deletions(-) >>>>=20 >>>> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c = b/drivers/mtd/nand/raw/brcmnand/brcmnand.c >>>> index 8f9ffb46a09f..566281770841 100644 >>>> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c >>>> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c >>>> @@ -2279,13 +2279,6 @@ static int brcmnand_write_page_raw(struct = nand_chip *chip, const uint8_t *buf, >>>> return nand_prog_page_end_op(chip); >>>> } >>>>=20 >>>> -static int brcmnand_write_oob(struct nand_chip *chip, int page) >>>> -{ >>>> - return brcmnand_write(nand_to_mtd(chip), chip, >>>> - (u64)page << chip->page_shift, NULL, >>>> - chip->oob_poi); >>>> -} >>>> - >>>> static int brcmnand_write_oob_raw(struct nand_chip *chip, int page) >>>> { >>>> struct mtd_info *mtd =3D nand_to_mtd(chip); >>>> @@ -2642,7 +2635,7 @@ static int brcmnand_init_cs(struct = brcmnand_host *host, struct device_node *dn) >>>> chip->ecc.write_oob_raw =3D brcmnand_write_oob_raw; >>>> chip->ecc.read_oob_raw =3D brcmnand_read_oob_raw; >>>> chip->ecc.read_oob =3D brcmnand_read_oob; >>>> - chip->ecc.write_oob =3D brcmnand_write_oob; >>>> + chip->ecc.write_oob =3D brcmnand_write_oob_raw; >>>>=20 >>>> chip->controller =3D &ctrl->controller; >>>>=20 >>>> -- >>>> 2.26.2 >>>>=20 >>=20 >> Best regards, >> =C3=81lvaro.