Message ID | 1344893730-11345-1-git-send-email-jeff.westfahl@ni.com |
---|---|
State | New, archived |
Headers | show |
On Mon, 2012-08-13 at 16:35 -0500, Jeff Westfahl wrote: > Added a NAND device flag for subpage read support. Previously this was > hard coded based on large page and soft ECC. > Updated base NAND driver to use the new subpage read flag if the NAND is > large page and soft ECC. > > Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com> Brian, would you have a chance to review this patch?
On Fri, Aug 24, 2012 at 4:56 AM, Artem Bityutskiy <dedekind1@gmail.com> wrote: > On Mon, 2012-08-13 at 16:35 -0500, Jeff Westfahl wrote: >> Added a NAND device flag for subpage read support. Previously this was >> hard coded based on large page and soft ECC. >> Updated base NAND driver to use the new subpage read flag if the NAND is >> large page and soft ECC. >> >> Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com> > > Brian, would you have a chance to review this patch? Yes, I can try. I'll give it a little more thought on Monday. But I have an initial question: why do you need this patch? Specifically, is there a driver you have that supports/needs this change? Right now, your new flag won't be used for anything new. Side note: I have always thought that it was strange to have subpage-read support only baked into SOFT_ECC mode. There are presumably many potential applications in which a non-SOFT_ECC system could read partial pages safely. Brian
Brian Norris <computersforpeace@gmail.com> wrote on 08/24/2012 07:05:45 PM: > From: Brian Norris <computersforpeace@gmail.com> > To: dedekind1@gmail.com > Cc: Jeff Westfahl <jeff.westfahl@ni.com>, linux-mtd@lists.infradead.org > Date: 08/24/2012 07:06 PM > Subject: Re: [PATCH] mtd: nand: Added a device flag for subpage read support > > On Fri, Aug 24, 2012 at 4:56 AM, Artem Bityutskiy <dedekind1@gmail.com> wrote: > > On Mon, 2012-08-13 at 16:35 -0500, Jeff Westfahl wrote: > >> Added a NAND device flag for subpage read support. Previously this was > >> hard coded based on large page and soft ECC. > >> Updated base NAND driver to use the new subpage read flag if the NAND is > >> large page and soft ECC. > >> > >> Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com> > > > > Brian, would you have a chance to review this patch? > > Yes, I can try. I'll give it a little more thought on Monday. > > But I have an initial question: why do you need this patch? > Specifically, is there a driver you have that supports/needs this > change? Right now, your new flag won't be used for anything new. > > Side note: I have always thought that it was strange to have > subpage-read support only baked into SOFT_ECC mode. There are > presumably many potential applications in which a non-SOFT_ECC system > could read partial pages safely. > > Brian Brian, Your guess is correct. We're using an ARM SoC that isn't yet in mainline. Our design is using NAND with on-die ECC. With on-die ECC enabled, partial pages can be safely read. This patch helps cut UBI mount time on our board from about 8 seconds to about 1 second. Jeff
On Mon, 2012-08-13 at 16:35 -0500, Jeff Westfahl wrote: > Added a NAND device flag for subpage read support. Previously this was > hard coded based on large page and soft ECC. > Updated base NAND driver to use the new subpage read flag if the NAND is > large page and soft ECC. > > Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com> Pushed to l2-mtd.git, thanks!
On Wed, Aug 29, 2012 at 7:06 AM, Artem Bityutskiy <dedekind1@gmail.com> wrote: > On Mon, 2012-08-13 at 16:35 -0500, Jeff Westfahl wrote: >> Added a NAND device flag for subpage read support. Previously this was >> hard coded based on large page and soft ECC. >> Updated base NAND driver to use the new subpage read flag if the NAND is >> large page and soft ECC. >> >> Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com> > > Pushed to l2-mtd.git, thanks! I don't have a good system that supports subpage reads, but this patch looks fine. I forgot to ack: Reviewed-by: Brian Norris <computersforpeace@gmail.com>
On Wed, 2012-08-29 at 09:22 -0700, Brian Norris wrote:
> Reviewed-by: Brian Norris <computersforpeace@gmail.com>
Added, thanks!
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index a11253a..a1cb9b3 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1525,7 +1525,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, ret = chip->ecc.read_page_raw(mtd, chip, bufpoi, oob_required, 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 @@ -1542,7 +1543,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) && (ops->mode != MTD_OPS_RAW)) { chip->pagebuf = realpage; @@ -3477,6 +3478,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 57977c6..738540d 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -200,6 +200,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) @@ -208,9 +211,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)) /* Mask to zero out the chip options, which come from the id table */ #define NAND_CHIPOPTIONS_MSK 0x0000ffff
Added a NAND device flag for subpage read support. Previously this was hard coded based on large page and soft ECC. Updated base NAND driver to use the new subpage read flag if the NAND is large page and soft ECC. Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com> --- drivers/mtd/nand/nand_base.c | 9 +++++++-- include/linux/mtd/nand.h | 7 ++++--- 2 files changed, 11 insertions(+), 5 deletions(-)