Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4607359pxj; Wed, 12 May 2021 09:08:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq5DP0u+VyGSJR2u9+mCh8LWy8sHwagiyEtYYkJ3whvKXYZS0T4kKoFJq8bVzFwsdlPAwg X-Received: by 2002:adf:e384:: with SMTP id e4mr3717287wrm.347.1620835712304; Wed, 12 May 2021 09:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835712; cv=none; d=google.com; s=arc-20160816; b=oRkJ7UUIwIxO5lzZBHhzT/ZDPHy9PLqZIRJlrICwOfvDraOyRjqDyCBJlUkvpQ7Y2Q yfIsrcS1mToRCPZU+bFLWdzF/REvji68SuvosnV8/3rmWOKAImTxgpsDuycZm3IRh5Db G27SxmDucmEaWrnAAZniKoD0JA6kRB0rzvsRSXR6cVERpurK8k0i4TrYec+Z8QBOVuZH 0vu612mseW2r85wVx9uSfd1dvqs/XYr4UyDS3tLllerRRCFsCBvEo2+0vtrUlFcRXU4c tjKtVfkptLpVHGgVEGZaRRNR+0JWt8swdfKo6P+OyShEky3wqX3FbFMuYEHf8JEZL76a Ec/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LN1OSsaPKAojtU7J6Bz1FUWboOcbnqpbZsEvUdJnupE=; b=E9fSsRPVXZm0ldPKI/Kg+ODCzMQAQ8jWzfqsRA5Q4LT9JVya/fCwET925xuGzqZnVz 3i4S5OSrgDWSmjP7Q1lV6bMsmDqOmOO414gos8/9NNyttcVR7LVM8yxPHaiHUZXp79d8 jBrvG7xzS+xM67kR72PTjkHY9uN7ZVoQbyV2n426T9TnbZhbpWu39kLdf3b4kv78uaNW nSZtQBbVenaZMoA1GjQgFQmUqTmgra0Y3Z5p7yCH44Y2CuSViRCQbyrNt8A1HwMsA0IG b5MZCQCXlJ29/yxBFVtYnzvGBecgRyRWWUX4vEOrgv2CYfMpvDnv1a+8mHR0Xg9kbmsO B5Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0nATnGsj; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd28si297023ejb.696.2021.05.12.09.08.08; Wed, 12 May 2021 09:08:32 -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=@linuxfoundation.org header.s=korg header.b=0nATnGsj; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238727AbhELQGK (ORCPT + 99 others); Wed, 12 May 2021 12:06:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:38716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234270AbhELPY3 (ORCPT ); Wed, 12 May 2021 11:24:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 36794619CB; Wed, 12 May 2021 15:10:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832202; bh=iV4WMK8HInr0iIyKVyvH74cMMCc63XB8xO0MfQtayBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0nATnGsjzKPWX2VlAwXjHaa3zwE4whaGyiElTZQEqTAeo9DYYseiIPtq4W329abKU UevBbp73o2q2A2nEzNt502W4GlRTnvRQSQCSl8++9vbdSfmunYXFq3kHZ3qzErf4uw JSL4pYTPv/KppsJ3yCqKQuUYEVWE/hfQsMdX75cw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= , Brian Norris , Miquel Raynal , Sasha Levin Subject: [PATCH 5.10 149/530] mtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC Date: Wed, 12 May 2021 16:44:19 +0200 Message-Id: <20210512144824.745733927@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Álvaro Fernández Rojas [ Upstream commit f5200c14242fb8fa4a9b93f7fd4064d237e58785 ] Hamming ECC doesn't cover the OOB data, so reading or writing OOB shall always be done without ECC enabled. This is a problem when adding JFFS2 cleanmarkers to erased blocks. If JFFS2 clenmarkers are added to the OOB with ECC enabled, OOB bytes will be changed from ff ff ff to 00 00 00, reporting incorrect ECC errors. Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller") Signed-off-by: Álvaro Fernández Rojas Acked-by: Brian Norris Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20210224080210.23686-1-noltari@gmail.com Signed-off-by: Sasha Levin --- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c index 2da39ab89286..909b14cc8e55 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -2688,6 +2688,12 @@ static int brcmnand_attach_chip(struct nand_chip *chip) ret = brcmstb_choose_ecc_layout(host); + /* If OOB is written with ECC enabled it will cause ECC errors */ + if (is_hamming_ecc(host->ctrl, &host->hwcfg)) { + chip->ecc.write_oob = brcmnand_write_oob_raw; + chip->ecc.read_oob = brcmnand_read_oob_raw; + } + return ret; } -- 2.30.2