Skip to contentSkip to conversation

Patch "mtd: nand: don't use read_buf for 8-bit ONFI transfers" has been added to the 3.14-stable tree

PATCH [email protected] 2 participants 2 messages Jul 28, 2015

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

mtd: nand: don't use read_buf for 8-bit ONFI transfers

to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mtd-nand-don-t-use-read_buf-for-8-bit-onfi-transfers.patch
and it can be found in the queue-3.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From bd9c6e99b58255b9de1982711ac9487c9a2f18be Mon Sep 17 00:00:00 2001

From: Brian Norris <[email protected]>
Date: Fri, 29 Nov 2013 22:04:28 -0800
Subject: mtd: nand: don't use read_buf for 8-bit ONFI transfers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From: Brian Norris <[email protected]>

commit bd9c6e99b58255b9de1982711ac9487c9a2f18be upstream.

Use a repeated read_byte() instead of read_buf(), since for x16 buswidth devices, we need to avoid the upper I/O[16:9] bits. See the following commit for reference:

commit 05f7835975dad6b3b517f9e23415985e648fb875

Author: Uwe Kleine-König <[email protected]>
Date:   Thu Dec 5 22:22:04 2013 +0100

mtd: nand: don't use {read,write}_buf for 8-bit transfers

Now, I think that all barriers to probing ONFI on x16 devices are removed, so remove the check from nand_flash_detect_onfi().

Tested on 8-bit ONFI NAND (Micron MT29F32G08CBADAWP).

---
 drivers/mtd/nand/nand_base.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/mtd/nand/nand_base.c +3 -11
@@ -3063,7 +3063,7 @@ static int nand_flash_detect_onfi(struct
 					int *busw)
 {
 	struct nand_onfi_params *p = &chip->onfi_params;
-	int i;
+	int i, j;
 	int val;
 
 	/* Try ONFI for unknown chip or LP */
@@ -3072,18 +3072,10 @@ static int nand_flash_detect_onfi(struct
 		chip->read_byte(mtd) != 'F' || chip->read_byte(mtd) != 'I')
 		return 0;
 
-	/*
-	 * ONFI must be probed in 8-bit mode or with NAND_BUSWIDTH_AUTO, not
-	 * with NAND_BUSWIDTH_16
-	 */
-	if (chip->options & NAND_BUSWIDTH_16) {
-		pr_err("ONFI cannot be probed in 16-bit mode; aborting\n");
-		return 0;
-	}
-
 	chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1);
 	for (i = 0; i < 3; i++) {
-		chip->read_buf(mtd, (uint8_t *)p, sizeof(*p));
+		for (j = 0; j < sizeof(*p); j++)
+			((uint8_t *)p)[j] = chip->read_byte(mtd);
 		if (onfi_crc16(ONFI_CRC_BASE, (uint8_t *)p, 254) ==
 				le16_to_cpu(p->crc)) {
 			break;

Patches currently in stable-queue which might be from [email protected] are

queue-3.14/mtd-nand-fix-erroneous-read_buf-call-in-nand_write_page_raw_syndrome.patch queue-3.14/mtd-fix-avoid-race-condition-when-accessing-mtd-usecount.patch queue-3.14/mtd-nand-don-t-use-read_buf-for-8-bit-onfi-transfers.patch queue-3.14/mtd-dc21285-use-raw-spinlock-functions-for-nw_gpio_lock.patch

#1 lore raw

+ linux-mtd

Quoted 8 lines · Greg Kroah-Hartman

This is a note to let you know that I've just added the patch titled

mtd: nand: don't use read_buf for 8-bit ONFI transfers

to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

Quoted 6 lines

The filename of the patch is:
mtd-nand-don-t-use-read_buf-for-8-bit-onfi-transfers.patch
and it can be found in the queue-3.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

IIRC, that patch goes best with this one too:

commit 3dad2344e92c6e1aeae42df1c4824f307c51bcc7
Author: Brian Norris <[email protected]>
Date: Wed Jan 29 14:08:12 2014 -0800

mtd: nand: force NAND_CMD_READID onto 8-bit bus

Someone who was able to test this better (I don't have x16 chips) might be able to say better.

Brian

Quoted 77 lines

From bd9c6e99b58255b9de1982711ac9487c9a2f18be Mon Sep 17 00:00:00 2001
From: Brian Norris <[email protected]>
Date: Fri, 29 Nov 2013 22:04:28 -0800
Subject: mtd: nand: don't use read_buf for 8-bit ONFI transfers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From: Brian Norris <[email protected]>

commit bd9c6e99b58255b9de1982711ac9487c9a2f18be upstream.

Use a repeated read_byte() instead of read_buf(), since for x16 buswidth devices, we need to avoid the upper I/O[16:9] bits. See the following commit for reference:

commit 05f7835975dad6b3b517f9e23415985e648fb875

Author: Uwe Kleine-K�nig <[email protected]>
Date:   Thu Dec 5 22:22:04 2013 +0100

mtd: nand: don't use {read,write}_buf for 8-bit transfers

Now, I think that all barriers to probing ONFI on x16 devices are removed, so remove the check from nand_flash_detect_onfi().

Tested on 8-bit ONFI NAND (Micron MT29F32G08CBADAWP).

---
 drivers/mtd/nand/nand_base.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/mtd/nand/nand_base.c +3 -11
@@ -3063,7 +3063,7 @@ static int nand_flash_detect_onfi(struct
 					int *busw)
 {
 	struct nand_onfi_params *p = &chip->onfi_params;
-	int i;
+	int i, j;
 	int val;
 
 	/* Try ONFI for unknown chip or LP */
@@ -3072,18 +3072,10 @@ static int nand_flash_detect_onfi(struct
 		chip->read_byte(mtd) != 'F' || chip->read_byte(mtd) != 'I')
 		return 0;
 
-	/*
-	 * ONFI must be probed in 8-bit mode or with NAND_BUSWIDTH_AUTO, not
-	 * with NAND_BUSWIDTH_16
-	 */
-	if (chip->options & NAND_BUSWIDTH_16) {
-		pr_err("ONFI cannot be probed in 16-bit mode; aborting\n");
-		return 0;
-	}
-
 	chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1);
 	for (i = 0; i < 3; i++) {
-		chip->read_buf(mtd, (uint8_t *)p, sizeof(*p));
+		for (j = 0; j < sizeof(*p); j++)
+			((uint8_t *)p)[j] = chip->read_byte(mtd);
 		if (onfi_crc16(ONFI_CRC_BASE, (uint8_t *)p, 254) ==
 				le16_to_cpu(p->crc)) {
 			break;

Patches currently in stable-queue which might be from [email protected] are

queue-3.14/mtd-nand-fix-erroneous-read_buf-call-in-nand_write_page_raw_syndrome.patch queue-3.14/mtd-fix-avoid-race-condition-when-accessing-mtd-usecount.patch queue-3.14/mtd-nand-don-t-use-read_buf-for-8-bit-onfi-transfers.patch queue-3.14/mtd-dc21285-use-raw-spinlock-functions-for-nw_gpio_lock.patch