[PATCH v4 5/5] mtd: nand: Improve bitflip detection for on-die ECC scheme.

David Mosberger davidm at egauge.net
Tue Apr 1 08:51:13 PDT 2014


Pekon,

On Tue, Apr 1, 2014 at 12:29 AM, Gupta, Pekon <pekon at ti.com> wrote:

>>+/*
>>+ * Return the number of bits that differ between buffers SRC1 and
>>+ * SRC2, both of which are LEN bytes long.
>>+ *
>>+ * This code could be optimized for, but it only gets called on pages
>>+ * with bitflips and compared to the cost of migrating an eraseblock,
>>+ * the execution time here is trivial...
>>+ */
>>+static int
>>+bitdiff(const void *s1, const void *s2, size_t len)
>>+{
>>+      const uint8_t *src1 = s1, *src2 = s2;
>>+      int count = 0, i;
>>+
>>+      for (i = 0; i < len; ++i)
>>+              count += hweight8(*src1++ ^ *src2++);
>>+      return count;
>
> hweight8() might not be good option, how about using hweight32 ?

Why don't you read the comment above.  Yes, you can add more code
and make it faster and it will not matter one bit, so I chose to go with
the shortest code possible.  Sue me.

>>+                      flips += hweight8(chkoob[*eccpos] ^ rawoob[*eccpos]);
>>+                      ++eccpos;
>>+              }
>>+              if (flips > 0)
>>+                      mtd->ecc_stats.corrected += flips;
>>+              max_bitflips = max_t(int, max_bitflips, flips);
>>+              chkbuf += chip->ecc.size;
>>+              rawbuf += chip->ecc.size;
>>+      }
>>+
>>+      /* Re-issue the READ command for the actual data read that follows.  */
>>+      chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
>>+
>
> If you refer my previous feedbacks, you could avoided this extra
> "chip->read_buf(mtd, chkbuf, read_size);" by calling it in nand_page_read_on_die();

The code you quote has no chip->read_buf call so I'm not sure how to avoid
something that isn't there.  I'm more than happy to address your concern once
I understand what it is.

  --david
-- 
eGauge Systems LLC, http://egauge.net/, 1.877-EGAUGE1, fax 720.545.9768



More information about the linux-mtd mailing list