public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] ubi: Only read the actual size of the VID header
@ 2012-11-01 22:49 Joe Hershberger
  2012-11-01 22:49 ` [U-Boot] [PATCH 2/2] nand: Move the sub-page read support enable to a flag Joe Hershberger
  2012-11-05 16:46 ` [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header Joe Hershberger
  0 siblings, 2 replies; 8+ messages in thread
From: Joe Hershberger @ 2012-11-01 22:49 UTC (permalink / raw)
  To: u-boot

If sub-page reads are supported, this will save reading unneeded data

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
 drivers/mtd/ubi/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 8423894..23660e3 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -916,7 +916,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
 
 	p = (char *)vid_hdr - ubi->vid_hdr_shift;
 	err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
-			  ubi->vid_hdr_alsize);
+			  UBI_VID_HDR_SIZE);
 	if (err) {
 		if (err != UBI_IO_BITFLIPS && err != -EBADMSG)
 			return err;
-- 
1.7.11.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] nand: Move the sub-page read support enable to a flag
  2012-11-01 22:49 [U-Boot] [PATCH 1/2] ubi: Only read the actual size of the VID header Joe Hershberger
@ 2012-11-01 22:49 ` Joe Hershberger
  2012-11-02 22:41   ` Scott Wood
  2012-11-05 16:46 ` [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header Joe Hershberger
  1 sibling, 1 reply; 8+ messages in thread
From: Joe Hershberger @ 2012-11-01 22:49 UTC (permalink / raw)
  To: u-boot

Use a flag instead of a hard-coded macro so that sub-page reads can be
enabled in other cases (such as on-die ecc).

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
 drivers/mtd/nand/nand_base.c | 9 +++++++--
 include/linux/mtd/nand.h     | 7 ++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 71f5027..4f2963b 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1245,7 +1245,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 			if (unlikely(ops->mode == MTD_OOB_RAW))
 				ret = chip->ecc.read_page_raw(mtd, chip,
 							      bufpoi, page);
-			else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
+			else if (!aligned && NAND_HAS_SUBPAGE_READ(chip) &&
+			    !oob)
 				ret = chip->ecc.read_subpage(mtd, chip,
 							col, bytes, bufpoi);
 			else
@@ -1256,7 +1257,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 
 			/* Transfer not aligned data */
 			if (!aligned) {
-				if (!NAND_SUBPAGE_READ(chip) && !oob &&
+				if (!NAND_HAS_SUBPAGE_READ(chip) && !oob &&
 				    !(mtd->ecc_stats.failed - stats.failed))
 					chip->pagebuf = realpage;
 				memcpy(buf, chip->buffers->databuf + col, bytes);
@@ -3149,6 +3150,10 @@ int nand_scan_tail(struct mtd_info *mtd)
 	/* Invalidate the pagebuffer reference */
 	chip->pagebuf = -1;
 
+	/* Large page NAND with SOFT_ECC should support subpage reads */
+	if ((chip->ecc.mode == NAND_ECC_SOFT) && (chip->page_shift > 9))
+		chip->options |= NAND_SUBPAGE_READ;
+
 	/* Fill in remaining MTD driver data */
 	mtd->type = MTD_NANDFLASH;
 	mtd->flags = (chip->options & NAND_ROM) ? MTD_CAP_ROM :
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index f63e04b..e9e9045 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -194,6 +194,9 @@ typedef enum {
 /* Device behaves just like nand, but is readonly */
 #define NAND_ROM		0x00000800
 
+/* Device supports subpage reads */
+#define NAND_SUBPAGE_READ       0x00001000
+
 /* Options valid for Samsung large page devices */
 #define NAND_SAMSUNG_LP_OPTIONS \
 	(NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK)
@@ -203,9 +206,7 @@ typedef enum {
 #define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING))
 #define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
 #define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK))
-/* Large page NAND with SOFT_ECC should support subpage reads */
-#define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT) \
-					&& (chip->page_shift > 9))
+#define NAND_HAS_SUBPAGE_READ(chip) ((chip->options & NAND_SUBPAGE_READ))
 
 /* Non chip related options */
 /*
-- 
1.7.11.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] nand: Move the sub-page read support enable to a flag
  2012-11-01 22:49 ` [U-Boot] [PATCH 2/2] nand: Move the sub-page read support enable to a flag Joe Hershberger
@ 2012-11-02 22:41   ` Scott Wood
  0 siblings, 0 replies; 8+ messages in thread
From: Scott Wood @ 2012-11-02 22:41 UTC (permalink / raw)
  To: u-boot

On 11/01/2012 05:49:29 PM, Joe Hershberger wrote:
> Use a flag instead of a hard-coded macro so that sub-page reads can be
> enabled in other cases (such as on-die ecc).
> 
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> ---
>  drivers/mtd/nand/nand_base.c | 9 +++++++--
>  include/linux/mtd/nand.h     | 7 ++++---
>  2 files changed, 11 insertions(+), 5 deletions(-)

This looks a lot like commit a5ff4f102937a3492bca4a9ff0c341d78813414c  
in Linux, but I don't see any attribution...

-Scott

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header
  2012-11-01 22:49 [U-Boot] [PATCH 1/2] ubi: Only read the actual size of the VID header Joe Hershberger
  2012-11-01 22:49 ` [U-Boot] [PATCH 2/2] nand: Move the sub-page read support enable to a flag Joe Hershberger
@ 2012-11-05 16:46 ` Joe Hershberger
  2012-11-05 16:46   ` [U-Boot] [PATCH v2 2/2] nand: Move the sub-page read support enable to a flag Joe Hershberger
  2012-11-06  8:19   ` [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header Stefan Roese
  1 sibling, 2 replies; 8+ messages in thread
From: Joe Hershberger @ 2012-11-05 16:46 UTC (permalink / raw)
  To: u-boot

If sub-page reads are supported, this will save reading unneeded data

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---

 drivers/mtd/ubi/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 8423894..23660e3 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -916,7 +916,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
 
 	p = (char *)vid_hdr - ubi->vid_hdr_shift;
 	err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
-			  ubi->vid_hdr_alsize);
+			  UBI_VID_HDR_SIZE);
 	if (err) {
 		if (err != UBI_IO_BITFLIPS && err != -EBADMSG)
 			return err;
-- 
1.7.11.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH v2 2/2] nand: Move the sub-page read support enable to a flag
  2012-11-05 16:46 ` [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header Joe Hershberger
@ 2012-11-05 16:46   ` Joe Hershberger
  2012-11-16  0:10     ` [U-Boot] [U-Boot, v2, " Scott Wood
  2012-11-06  8:19   ` [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header Stefan Roese
  1 sibling, 1 reply; 8+ messages in thread
From: Joe Hershberger @ 2012-11-05 16:46 UTC (permalink / raw)
  To: u-boot

Use a flag instead of a hard-coded macro so that sub-page reads can be
enabled in other cases (such as on-die ecc).

This is the same as a5ff4f102937a3492bca4a9ff0c341d78813414c in Linux

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
Changes in v2:
- Added Linux commit ID to commit message

 drivers/mtd/nand/nand_base.c | 9 +++++++--
 include/linux/mtd/nand.h     | 7 ++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 71f5027..4f2963b 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1245,7 +1245,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 			if (unlikely(ops->mode == MTD_OOB_RAW))
 				ret = chip->ecc.read_page_raw(mtd, chip,
 							      bufpoi, page);
-			else if (!aligned && NAND_SUBPAGE_READ(chip) && !oob)
+			else if (!aligned && NAND_HAS_SUBPAGE_READ(chip) &&
+			    !oob)
 				ret = chip->ecc.read_subpage(mtd, chip,
 							col, bytes, bufpoi);
 			else
@@ -1256,7 +1257,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 
 			/* Transfer not aligned data */
 			if (!aligned) {
-				if (!NAND_SUBPAGE_READ(chip) && !oob &&
+				if (!NAND_HAS_SUBPAGE_READ(chip) && !oob &&
 				    !(mtd->ecc_stats.failed - stats.failed))
 					chip->pagebuf = realpage;
 				memcpy(buf, chip->buffers->databuf + col, bytes);
@@ -3149,6 +3150,10 @@ int nand_scan_tail(struct mtd_info *mtd)
 	/* Invalidate the pagebuffer reference */
 	chip->pagebuf = -1;
 
+	/* Large page NAND with SOFT_ECC should support subpage reads */
+	if ((chip->ecc.mode == NAND_ECC_SOFT) && (chip->page_shift > 9))
+		chip->options |= NAND_SUBPAGE_READ;
+
 	/* Fill in remaining MTD driver data */
 	mtd->type = MTD_NANDFLASH;
 	mtd->flags = (chip->options & NAND_ROM) ? MTD_CAP_ROM :
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index f63e04b..e9e9045 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -194,6 +194,9 @@ typedef enum {
 /* Device behaves just like nand, but is readonly */
 #define NAND_ROM		0x00000800
 
+/* Device supports subpage reads */
+#define NAND_SUBPAGE_READ       0x00001000
+
 /* Options valid for Samsung large page devices */
 #define NAND_SAMSUNG_LP_OPTIONS \
 	(NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK)
@@ -203,9 +206,7 @@ typedef enum {
 #define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING))
 #define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG))
 #define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK))
-/* Large page NAND with SOFT_ECC should support subpage reads */
-#define NAND_SUBPAGE_READ(chip) ((chip->ecc.mode == NAND_ECC_SOFT) \
-					&& (chip->page_shift > 9))
+#define NAND_HAS_SUBPAGE_READ(chip) ((chip->options & NAND_SUBPAGE_READ))
 
 /* Non chip related options */
 /*
-- 
1.7.11.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header
  2012-11-05 16:46 ` [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header Joe Hershberger
  2012-11-05 16:46   ` [U-Boot] [PATCH v2 2/2] nand: Move the sub-page read support enable to a flag Joe Hershberger
@ 2012-11-06  8:19   ` Stefan Roese
  2012-11-06 23:47     ` Joe Hershberger
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Roese @ 2012-11-06  8:19 UTC (permalink / raw)
  To: u-boot

On 11/05/2012 05:46 PM, Joe Hershberger wrote:
> If sub-page reads are supported, this will save reading unneeded data
> 
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> ---
> 
>  drivers/mtd/ubi/io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
> index 8423894..23660e3 100644
> --- a/drivers/mtd/ubi/io.c
> +++ b/drivers/mtd/ubi/io.c
> @@ -916,7 +916,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
>  
>  	p = (char *)vid_hdr - ubi->vid_hdr_shift;
>  	err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
> -			  ubi->vid_hdr_alsize);
> +			  UBI_VID_HDR_SIZE);
>  	if (err) {
>  		if (err != UBI_IO_BITFLIPS && err != -EBADMSG)
>  			return err;

Joe, are you pushing this change to Linux as well? I would really like
to see Artem commenting on this.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header
  2012-11-06  8:19   ` [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header Stefan Roese
@ 2012-11-06 23:47     ` Joe Hershberger
  0 siblings, 0 replies; 8+ messages in thread
From: Joe Hershberger @ 2012-11-06 23:47 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On Tue, Nov 6, 2012 at 2:19 AM, Stefan Roese <sr@denx.de> wrote:
> On 11/05/2012 05:46 PM, Joe Hershberger wrote:
>> If sub-page reads are supported, this will save reading unneeded data
>>
>> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
>> ---
>>
>>  drivers/mtd/ubi/io.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
>> index 8423894..23660e3 100644
>> --- a/drivers/mtd/ubi/io.c
>> +++ b/drivers/mtd/ubi/io.c
>> @@ -916,7 +916,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
>>
>>       p = (char *)vid_hdr - ubi->vid_hdr_shift;
>>       err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset,
>> -                       ubi->vid_hdr_alsize);
>> +                       UBI_VID_HDR_SIZE);
>>       if (err) {
>>               if (err != UBI_IO_BITFLIPS && err != -EBADMSG)
>>                       return err;
>
> Joe, are you pushing this change to Linux as well? I would really like
> to see Artem commenting on this.

Yes.  We will post this to Linux as well.

-Joe

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [U-Boot, v2, 2/2] nand: Move the sub-page read support enable to a flag
  2012-11-05 16:46   ` [U-Boot] [PATCH v2 2/2] nand: Move the sub-page read support enable to a flag Joe Hershberger
@ 2012-11-16  0:10     ` Scott Wood
  0 siblings, 0 replies; 8+ messages in thread
From: Scott Wood @ 2012-11-16  0:10 UTC (permalink / raw)
  To: u-boot

On Mon, Nov 05, 2012 at 06:46:31AM -0000, Joe Hershberger wrote:
> Use a flag instead of a hard-coded macro so that sub-page reads can be
> enabled in other cases (such as on-die ecc).
> 
> This is the same as a5ff4f102937a3492bca4a9ff0c341d78813414c in Linux
> 
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>

Applied to u-boot-nand-flash

-Scott

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-11-16  0:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-01 22:49 [U-Boot] [PATCH 1/2] ubi: Only read the actual size of the VID header Joe Hershberger
2012-11-01 22:49 ` [U-Boot] [PATCH 2/2] nand: Move the sub-page read support enable to a flag Joe Hershberger
2012-11-02 22:41   ` Scott Wood
2012-11-05 16:46 ` [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header Joe Hershberger
2012-11-05 16:46   ` [U-Boot] [PATCH v2 2/2] nand: Move the sub-page read support enable to a flag Joe Hershberger
2012-11-16  0:10     ` [U-Boot] [U-Boot, v2, " Scott Wood
2012-11-06  8:19   ` [U-Boot] [PATCH v2 1/2] ubi: Only read the actual size of the VID header Stefan Roese
2012-11-06 23:47     ` Joe Hershberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox