From: Kyungmin Park <kmpark@infradead.org>
To: linux-mtd@lists.infradead.org
Cc: dwmw2@infradead.org, dedekind1@gmail.com
Subject: [PATCH] mtd: OneNAND: samsung: Write DMA support
Date: Wed, 08 Jun 2011 19:18:04 +0900 [thread overview]
Message-ID: <20110608101804.GA5527@july> (raw)
From: Kyungmin Park <kyungmin.park@samsung.com>
Implement the write DMA feature. It can reduce the CPU usage when write.
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
index 3306b5b..f24cb6f 100644
--- a/drivers/mtd/onenand/samsung.c
+++ b/drivers/mtd/onenand/samsung.c
@@ -712,6 +712,74 @@ normal:
return 0;
}
+static int s5pc110_write_bufferram(struct mtd_info *mtd, int area,
+ const unsigned char *buffer, int offset, size_t count)
+{
+ struct onenand_chip *this = mtd->priv;
+ struct device *dev = &onenand->pdev->dev;
+ void __iomem *p;
+ void *buf = (void *) buffer;
+ dma_addr_t dma_src, dma_dst;
+ int err, ofs, page_dma = 0;
+
+ p = this->base + area;
+ if (ONENAND_CURRENT_BUFFERRAM(this)) {
+ if (area == ONENAND_DATARAM)
+ p += this->writesize;
+ else
+ p += mtd->oobsize;
+ }
+
+ if (count != mtd->writesize || offset & 3 || (size_t) buf & 3)
+ goto normal;
+
+ /* Handle vmalloc address */
+ if (buf >= high_memory) {
+ struct page *page;
+
+ if (((size_t) buf & PAGE_MASK) !=
+ ((size_t) (buf + count - 1) & PAGE_MASK))
+ goto normal;
+
+ page = vmalloc_to_page(buf);
+ if (unlikely(!page))
+ goto normal;
+
+ /* Page offset */
+ ofs = ((size_t) buf & ~PAGE_MASK);
+ page_dma = 1;
+
+ /* DMA routine */
+ dma_src = dma_map_page(dev, page, ofs, count, DMA_TO_DEVICE);
+ dma_dst = onenand->phys_base + (p - this->base);
+ } else {
+ /* DMA routine */
+ dma_src = dma_map_single(dev, buf, count, DMA_TO_DEVICE);
+ dma_dst = onenand->phys_base + (p - this->base);
+ }
+
+ if (dma_mapping_error(dev, dma_src)) {
+ dev_err(dev, "Couldn't map a %d byte buffer for DMA\n", count);
+ goto normal;
+ }
+
+ err = s5pc110_dma_ops((void *) dma_dst, (void *) dma_src,
+ count, S5PC110_DMA_DIR_WRITE);
+
+ if (page_dma)
+ dma_unmap_page(dev, dma_src, count, DMA_TO_DEVICE);
+ else
+ dma_unmap_single(dev, dma_src, count, DMA_TO_DEVICE);
+
+ if (!err)
+ return 0;
+
+normal:
+ memcpy(p + offset, buffer, count);
+
+ return 0;
+}
+
static int s5pc110_chip_probe(struct mtd_info *mtd)
{
/* Now just return 0 */
@@ -844,6 +912,7 @@ static void s3c_onenand_setup(struct mtd_info *mtd)
} else if (onenand->type == TYPE_S5PC110) {
/* Use generic onenand functions */
this->read_bufferram = s5pc110_read_bufferram;
+ this->write_bufferram = s5pc110_write_bufferram;
this->chip_probe = s5pc110_chip_probe;
return;
} else {
next reply other threads:[~2011-06-08 10:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-08 10:18 Kyungmin Park [this message]
2011-06-29 7:22 ` [PATCH] mtd: OneNAND: samsung: Write DMA support Kyungmin Park
2011-06-30 7:21 ` Artem Bityutskiy
2011-06-30 7:55 ` Artem Bityutskiy
2011-06-30 9:19 ` Russell King - ARM Linux
2011-06-30 10:45 ` Artem Bityutskiy
2011-06-30 11:23 ` Russell King - ARM Linux
2011-06-30 13:38 ` Artem Bityutskiy
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=20110608101804.GA5527@july \
--to=kmpark@infradead.org \
--cc=dedekind1@gmail.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