public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Alexey, Korolev" <alexey.korolev@intel.com>
To: tglx@linutronix.de, jwboyer@gmail.com
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] Fixup in NAND bad block management + fix of misspring .(nand_base.c)
Date: Wed, 08 Feb 2006 19:05:32 +0300	[thread overview]
Message-ID: <43EA16CC.6060401@intel.com> (raw)
In-Reply-To: <43D10544.10408@intel.com>

Thomas,

Couple of week ago, I sent this patch to list serever.
There weren't any feedback on this code. I don't know acceptable it or not.
I would be very much appreciate if you review this patch.

Here is some notes to the patch:
At present time we have some issues with bad block management on ST NAND 
devices on Linux.
It is impossible to mark Bad block. The reason of  it  code doesn't work 
properly if bad block pattern is given.
I made small fix  in nand_block_bad function to cover the case of
devices with non-default bad block pattern.

Also there is a missprint in nand_prepare_oobbuf() function :

-        ofs += mtd->oobavail;
+        ofs += mtd->oobsize;
which could affect if somebody tries to write several pages with oob
data via nand_write_ecc call.

Please see the patch bellow:

Thanks,
Alexey

==================================
--- a/drivers/mtd/nand/nand_base.c    2006-01-20 18:13:49.657859296 +0300
+++ b/drivers/mtd/nand/nand_base.c    2006-01-20 18:38:50.281729792 +0300
@@ -410,6 +410,7 @@
 static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
 {
     int page, chipnr, res = 0;
+    int badblockpos;
     struct nand_chip *this = mtd->priv;
     u16 bad;
 
@@ -425,15 +426,22 @@
     } else
         page = (int) ofs;
 
+    /* If pattern is given we must use offset from badblock_pattern
structure
+       else we should use badblockpos which is filled by default values */
+    if (this->badblock_pattern)
+        badblockpos=this->badblock_pattern->offs;
+    else
+        badblockpos=this->badblockpos;
+
     if (this->options & NAND_BUSWIDTH_16) {
-        this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE,
page & this->pagemask);
+        this->cmdfunc (mtd, NAND_CMD_READOOB, badblockpos & 0xFE, page
& this->pagemask);
         bad = cpu_to_le16(this->read_word(mtd));
         if (this->badblockpos & 0x1)
-            bad >>= 8;
+            bad >>= 1;
         if ((bad & 0xFF) != 0xff)
             res = 1;
     } else {
-        this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos, page &
this->pagemask);
+        this->cmdfunc (mtd, NAND_CMD_READOOB, badblockpos, page &
this->pagemask);
         if (this->read_byte(mtd) != 0xff)
             res = 1;
     }
@@ -470,8 +478,11 @@
     if (this->options & NAND_USE_FLASH_BBT)
         return nand_update_bbt (mtd, ofs);
 
-    /* We write two bytes, so we dont have to mess with 16 bit access */
-    ofs += mtd->oobsize + (this->badblockpos & ~0x01);
+    if (this->badblock_pattern)
+        ofs += (this->badblock_pattern->offs & ~0x01);
+    else
+        ofs += (this->badblockpos & ~0x01);
+
     return nand_write_oob (mtd, ofs , 2, &retlen, buf);
 }
 
@@ -1700,7 +1711,7 @@
             len += num;
             fsbuf += num;
         }
-        ofs += mtd->oobavail;
+        ofs += mtd->oobsize;
     }
     return this->oob_buf;
 }

===================================================

  reply	other threads:[~2006-02-08 16:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-20 15:44 [PATCH] Fixup in NAND bad block management + fix of misspring . (nand_base.c) Alexey, Korolev
2006-02-08 16:05 ` Alexey, Korolev [this message]
2006-02-08 20:11   ` [PATCH] Fixup in NAND bad block management + fix of misspring .(nand_base.c) Vitaly Wool
2006-02-09 17:54     ` Alexey, Korolev
2006-03-12 15:18       ` Thomas Gleixner
2006-02-09 18:03   ` Alexey, Korolev
2006-02-10  6:52     ` Vitaly Wool
2006-02-20 10:53       ` Alexey, Korolev
2006-02-20 11:00         ` Thomas Gleixner
2006-02-20 11:56           ` [PATCH] Fixup in NAND bad block management + fix of misspring.(nand_base.c) Alexey, Korolev
2006-02-20 12:08             ` Vitaly Wool
2006-02-20 12:11             ` Thomas Gleixner
2006-03-02 17:29               ` [PATCH] Fixup in NAND bad block management + fix ofmisspring.(nand_base.c) Alexey, Korolev
2006-03-12 16:44                 ` Thomas Gleixner
2006-03-20 14:06                   ` [PATCH] Fixup in NAND bad block management + fixofmisspring.(nand_base.c) Alexey, Korolev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43EA16CC.6060401@intel.com \
    --to=alexey.korolev@intel.com \
    --cc=jwboyer@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox