All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Mosberger <davidm@egauge.net>
To: linux-mtd@lists.infradead.org, computersforpeace@gmail.com,
	dedekind1@gmail.com, gsi@denx.de, pekon@ti.com
Cc: David Mosberger <davidm@egauge.net>
Subject: [PATCH v5 3/5] mtd: nand: Enable subpage-reads on flashes with on-die ECC enabled.
Date: Mon, 14 Apr 2014 13:35:32 -0600	[thread overview]
Message-ID: <1397504134-32178-4-git-send-email-davidm@egauge.net> (raw)
In-Reply-To: <1397504134-32178-1-git-send-email-davidm@egauge.net>

The Micron chips supported through the on-die ECC all have subpage capability,
so enable that.

Signed-off-by: David Mosberger <davidm@egauge.net>
---
 drivers/mtd/nand/nand_base.c |   56 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 54 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 997d7f1..7092875 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1304,6 +1304,52 @@ static int check_read_status_on_die(struct mtd_info *mtd, int page)
 }
 
 /**
+ * nand_read_subpage_on_die - [REPLACEABLE] raw sub-page read function
+ * @mtd: mtd info structure
+ * @chip: nand chip info structure
+ * @data_offs: offset of requested data within the page
+ * @readlen: data length
+ * @bufpoi: buffer to store read data
+ */
+static int nand_read_subpage_on_die(struct mtd_info *mtd,
+				    struct nand_chip *chip,
+				    uint32_t data_offs, uint32_t readlen,
+				    uint8_t *bufpoi, int page)
+{
+	int start_step, end_step, num_steps, ret;
+	int data_col_addr;
+	int datafrag_len;
+	uint32_t failed;
+	uint8_t *p;
+
+	/* Column address within the page aligned to ECC size */
+	start_step = data_offs / chip->ecc.size;
+	end_step = (data_offs + readlen - 1) / chip->ecc.size;
+	num_steps = end_step - start_step + 1;
+
+	/* Data size aligned to ECC ecc.size */
+	datafrag_len = num_steps * chip->ecc.size;
+	data_col_addr = start_step * chip->ecc.size;
+	p = bufpoi + data_col_addr;
+
+	failed = mtd->ecc_stats.failed;
+
+	ret = check_read_status_on_die(mtd, page);
+	if (ret < 0 || mtd->ecc_stats.failed != failed) {
+		memset(p, 0, datafrag_len);
+		return ret;
+	}
+
+	/* If we read not a page aligned data */
+	if (data_col_addr != 0)
+		chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1);
+
+	chip->read_buf(mtd, p, datafrag_len);
+
+	return ret;
+}
+
+/**
  * nand_read_page_on_die - [INTERN] read raw page data without ecc
  * @mtd: mtd info structure
  * @chip: nand chip info structure
@@ -4067,6 +4113,7 @@ int nand_scan_tail(struct mtd_info *mtd)
 		chip->bbt_options |= NAND_BBT_NO_OOB;
 		chip->ecc.layout = &nand_oob_64_on_die;
 		chip->ecc.read_page = nand_read_page_on_die;
+		chip->ecc.read_subpage = nand_read_subpage_on_die;
 		chip->ecc.write_page = nand_write_page_raw;
 		chip->ecc.read_oob = nand_read_oob_std;
 		chip->ecc.read_page_raw = nand_read_page_raw;
@@ -4144,8 +4191,13 @@ 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 ((ecc->mode == NAND_ECC_SOFT) && (chip->page_shift > 9))
+	/*
+	 * Large page NAND with SOFT_ECC or on-die ECC should support
+	 * subpage reads.
+	 */
+	if (((ecc->mode == NAND_ECC_SOFT)
+	     || (chip->ecc.mode == NAND_ECC_HW_ON_DIE))
+	    && (chip->page_shift > 9))
 		chip->options |= NAND_SUBPAGE_READ;
 
 	/* Fill in remaining MTD driver data */
-- 
1.7.9.5

  parent reply	other threads:[~2014-04-14 19:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1397504134-32178-1-git-send-email-davidm@egauge.net>
2014-04-14 19:35 ` [PATCH v5 1/5] mtd: nand: Detect Micron flash with on-die ECC (aka "internal ECC") enabled David Mosberger
2014-04-16 18:50   ` Gerhard Sittig
2014-04-14 19:35 ` [PATCH v5 2/5] mtd: nand: Add NAND_ECC_HW_ON_DIE ECC-mode David Mosberger
2014-04-16 19:18   ` Gerhard Sittig
2014-04-14 19:35 ` David Mosberger [this message]
2014-04-16 19:23   ` [PATCH v5 3/5] mtd: nand: Enable subpage-reads on flashes with on-die ECC enabled Gerhard Sittig
2014-04-14 19:35 ` [PATCH v5 4/5] mtd: nand: Allocate extra buffers needed for on-die ECC controller David Mosberger
2014-04-16 19:33   ` Gerhard Sittig
2014-04-16 18:47 ` [PATCH v5 0/5] mtd: nand: Add on-die ECC support Gerhard Sittig
     [not found] ` <1397504134-32178-6-git-send-email-davidm@egauge.net>
2014-04-16 19:49   ` [PATCH v5 5/5] mtd: nand: Improve bitflip detection for on-die ECC scheme Gerhard Sittig

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=1397504134-32178-4-git-send-email-davidm@egauge.net \
    --to=davidm@egauge.net \
    --cc=computersforpeace@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=gsi@denx.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=pekon@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.