Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp310239pxj; Thu, 20 May 2021 09:49:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEw6xC8hNHhPqUzeORKfBS5GqHP0wruOyOCm3f0EoxlRyNA/LPpkAGI1Wx6dj3MyxpuJl4 X-Received: by 2002:a17:906:dcb:: with SMTP id p11mr5706397eji.117.1621529389146; Thu, 20 May 2021 09:49:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621529389; cv=none; d=google.com; s=arc-20160816; b=vaYxLfpH3kCCMCAu7KgM1NgttgjPOqZc2KcJdTiYESFMp38ya8BphWCDUpCLFnCmeG LSrcpnxa/eAf9+f8y+EB1DhD4KMojBtXBX40KeT7yiR7ZE0aF5clWYC8zQ1sH1KoaZIT Mlu+pHMihZjx7WrqlLVCS7CdmUMArNQ2L5WS/oazwnBsYoof1BZPFzxEyW66C/DfMkXW dMs20LAf3GVxZ17jFLKfkxMPfxx2itIFCsoPCOkBZ+54RYxT+MBNcrFSyHowd4Y43S7l sLkvp+hb6LHKmr7bCn98nOWiexDpdi70EZxkPU5zyDxvXNqApUO4u7uYqiJcGgqJtg5x vVTw== 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=Hvdr7W4IkRHsAOnHli2qcMHOu9hVBbJwFd0i8MeO6Zw=; b=ZI2ATN1HkBXRnlZBtzWwo5oJbTbIfHl4WZfv7Hww6QUuLFbhqfqiwnXqMVlhTufTiP dhsslbRge8i0mrJM8JXl+0SUpU9dwZuZKFevH6u/+n7+Sw6b50prRVYVQGArcd9m+hMU 8CpoyjTy73T5IaIkKlO1jrrBqY+bwE6v8iLG/p6se+aikPq3AAECsTZCRs8Y2kMiwYrU LlJp4/SZdDbYzykeaFU4AEzlHb49pPMraRue6nrFQ3EJlXwqWZPPLml1G5TFGY8ZzP4A 6pcObqItHl02myh4culJto4SsvvvN9Awo0TfM5XVMfPSXk6lpHlvqvPpgbQu41XM2jCR FwYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rkUZc9iT; 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 x9si3732683eje.36.2021.05.20.09.49.25; Thu, 20 May 2021 09:49:49 -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=rkUZc9iT; 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 S234505AbhETJxH (ORCPT + 99 others); Thu, 20 May 2021 05:53:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:54318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234594AbhETJum (ORCPT ); Thu, 20 May 2021 05:50:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0441661261; Thu, 20 May 2021 09:35:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503336; bh=lkWwZMFJ429GqPC8y3MPC1rl2U3TSrVxtBf5jaz9avk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rkUZc9iTCfmCBxK6yaBNwj7lGqPN9JbaCXVUVI7jdEykXixPb6oZdj41I13UW7lQH Wm8iQ6Jn443ae1ZF5tFFvgLw1nh9JYwAb6wjj5iB7X+sbMgiqSdrApMHSe0Bb41CFb q9/5cOq0aNXiDt/uBcQJpv7j7ZVSPHCPSuyAXRqE= 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 4.19 174/425] mtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC Date: Thu, 20 May 2021 11:19:03 +0200 Message-Id: <20210520092137.159601491@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 aad8d107b85d..774ffa9e23f3 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -2239,6 +2239,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