From patchwork Sun Mar 12 20:02:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Couzens X-Patchwork-Id: 95182 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp906674qgd; Sun, 12 Mar 2017 13:03:43 -0700 (PDT) X-Received: by 10.98.84.67 with SMTP id i64mr33965452pfb.44.1489349023293; Sun, 12 Mar 2017 13:03:43 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id m2si9372455pgn.334.2017.03.12.13.03.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Mar 2017 13:03:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=Y5UXVGnLmTlTqHxnlgogCiCX+x+B1A3qlBqLNJgE5O4=; b=cuJ /YRLbXqsG46O7o4bxrsaepfJplxapfU5MMmOqaEU+u7kTCqgp3Bs8EW4fEKW3qjFIG1nET/9Azaoj eZlKk9d2OjTUM/AU5rAt5Wfc2vzkUsauD9jCA1kWNM+fwFpyWcbSoMi1Bu88ORRLh7Ojl0SN3XbGN DdSpib+MlsSk2GCBb+ZZQ/6U/d0bKUdQEIT/VQiehdOOOEaJKu1xClZNSdYncCdhD0Yb08mPGgKeR 5Cz0wCTeoXdyKZhjzQtEuU7+OppldbwmTiR+I5Nqz3eH7MmpBpM4YR3NBlHtGuRt0P199NNegt5Y8 7F0XA7qHBnbpJ4kJMNUd/E+fko94pbA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cn9iN-0001dr-Qb; Sun, 12 Mar 2017 20:03:39 +0000 Received: from mail.base45.de ([2001:67c:2050:310::a:2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cn9iD-0001bt-PS for linux-mtd@lists.infradead.org; Sun, 12 Mar 2017 20:03:33 +0000 Received: from ip5b41c579.dynamic.kabel-deutschland.de ([91.65.197.121] helo=lazus.yip) by mail.base45.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cn9hk-0004pN-Lb; Sun, 12 Mar 2017 21:03:00 +0100 From: Alexander Couzens To: linux-mtd@lists.infradead.org Subject: [PATCH] nand_base: fix regression on nand with 64/128 oob size Date: Sun, 12 Mar 2017 21:02:32 +0100 Message-Id: <20170312200232.19269-1-lynxis@fe80.eu> X-Mailer: git-send-email 2.12.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170312_130330_002768_BEA5F311 X-CRM114-Status: GOOD ( 11.22 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Alexander Couzens , Richard Weinberger MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org 41b207a70d3a accidently changed the oob layout for nand when ECC doesn't use the full available ecc reserved data. This only affects controllers which use the default large page ops nand_ooblayout_ecc_lp. E.g. for davinci: - nand has 2048 byte page, 64 byte oob - 3 byte ecc every 512 byte using 1bit hw ecc - requires 12 byte of oob space for ecc - old layout reserved 24 byte based on 64 byte oob Old layout started using byte from offset 40 while new layout uses the last X bytes so it fits into the end of oob. Meaning in this example the old layout uses byte 40-51, while the new layout use byte 52-63. Signed-off-by: Alexander Couzens --- drivers/mtd/nand/nand_base.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) -- 2.12.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index b0524f8accb6..ba88345fd334 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -112,8 +112,25 @@ static int nand_ooblayout_ecc_lp(struct mtd_info *mtd, int section, if (section) return -ERANGE; + /* to be compatible with previous layouts + * 64 byte oob must have ecc data at byte 40, + * 128 byte oob must have ecc data at byte 80 */ + switch (mtd->oobsize) { + case 64: + oobregion->offset = 40; + break; + case 128: + oobregion->offset = 80; + break; + default: + oobregion->offset = mtd->oobsize - oobregion->length; + break; + } + oobregion->length = ecc->total; - oobregion->offset = mtd->oobsize - oobregion->length; + if (oobregion->offset + oobregion->length > mtd->oobsize) { + return -ERANGE; + } return 0; }