From: "Chuanxiao.Dong" <chuanxiao.dong@intel.com>
To: linux-mtd@lists.infradead.org, dwmw2@infradead.org
Subject: [PATCH v2 6/6]nand/denali: change denali write page method
Date: Thu, 12 Aug 2010 18:51:58 +0800 [thread overview]
Message-ID: <20100812105158.GF11634@intel.com> (raw)
From 51c0771e113f9707a7cb6ff3d3300196c8ba4379 Mon Sep 17 00:00:00 2001
From: Chuanxiao Dong <chuanxiao.dong@intel.com>
Date: Thu, 12 Aug 2010 18:41:32 +0800
Subject: [PATCH 6/6] nand/denali: change denali write page method
In this way, driver will write data to MAIN and OOB area at
the same time. This feature will be used by Spectra FTL
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
---
drivers/mtd/nand/denali.c | 48 +++++++++++++++++++++++++++++++++-----------
1 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index aa8f334..a807c1d 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -1077,23 +1077,43 @@ static void write_page(struct mtd_info *mtd, struct nand_chip *chip,
* !raw_xfer - enable ecc
* raw_xfer - transfer spare
*/
- setup_ecc_for_xfer(denali, !raw_xfer, raw_xfer);
-
+ setup_ecc_for_xfer(denali, !raw_xfer, true);
+ clear_interrupts(denali);
/* copy buffer into DMA buffer */
- memcpy(denali->buf.buf, buf, mtd->writesize);
-
if (raw_xfer) {
+ memcpy(denali->buf.buf, buf, mtd->writesize);
/* transfer the data to the spare area */
memcpy(denali->buf.buf + mtd->writesize,
chip->oob_poi,
mtd->oobsize);
+ } else {
+ uint8_t *datadest, *oobsrc;
+ const uint8_t *src;
+ uint32_t i, cpysize;
+ datadest = denali->buf.buf;
+ src = buf;
+ oobsrc = chip->oob_poi + (mtd->oobsize - mtd->oobavail);
+ for (i = 0; i < chip->ecc.steps - 1; i++,
+ src += chip->ecc.size,
+ datadest += chip->ecc.size + chip->ecc.bytes)
+ memcpy(datadest, src, chip->ecc.size);
+ cpysize = mtd->writesize -
+ (chip->ecc.size + chip->ecc.bytes) * i;
+ memcpy(datadest, src, cpysize);
+ src += cpysize;
+ datadest += cpysize;
+ for (i = 0; i < denali->bbtskipbytes; i++)
+ *datadest++ = 0xff;
+ cpysize = mtd->oobsize - mtd->oobavail -
+ denali->bbtskipbytes - chip->ecc.bytes;
+ memcpy(datadest, src, cpysize);
+ datadest += cpysize + chip->ecc.bytes;
+ memcpy(datadest, oobsrc, mtd->oobavail);
}
+ denali_enable_dma(denali, true);
pci_dma_sync_single_for_device(pci_dev, addr, size, PCI_DMA_TODEVICE);
- clear_interrupts(denali);
- denali_enable_dma(denali, true);
-
denali_setup_dma(denali, DENALI_WRITE);
/* wait for operation to complete */
@@ -1103,13 +1123,17 @@ static void write_page(struct mtd_info *mtd, struct nand_chip *chip,
dev_err(&denali->dev->dev,
"timeout on write_page (type = %d)\n",
raw_xfer);
- denali->status =
- (irq_status & INTR_STATUS0__PROGRAM_FAIL) ?
- NAND_STATUS_FAIL : PASS;
- }
+ denali->status = NAND_STATUS_FAIL;
+ } else if (irq_status & INTR_STATUS0__PROGRAM_FAIL)
+ denali->status = NAND_STATUS_FAIL;
+ else
+ denali->status = PASS;
- denali_enable_dma(denali, false);
pci_dma_sync_single_for_cpu(pci_dev, addr, size, PCI_DMA_TODEVICE);
+
+ denali_enable_dma(denali, false);
+
+ memset(chip->oob_poi, 0xff, mtd->oobsize);
}
/* NAND core entry points */
--
1.6.6.1
reply other threads:[~2010-08-12 10:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20100812105158.GF11634@intel.com \
--to=chuanxiao.dong@intel.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).