From 2130ad32a03f8d2d772cbbd94eff5358d8ab9e33 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 29 Mar 2011 12:35:23 -0700 Subject: [PATCH 1/5] mtd: mtdswap: fix printk format warning The number is actually a sizeof(), so using %zu for it builds cleanly on 32-bit or 64-bit. drivers/mtd/mtdswap.c:1456: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'unsigned int' Signed-off-by: Randy Dunlap Signed-off-by: Artem Bityutskiy --- drivers/mtd/mtdswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c index 237913c5c92c..fed215c4cfa1 100644 --- a/drivers/mtd/mtdswap.c +++ b/drivers/mtd/mtdswap.c @@ -1452,7 +1452,7 @@ static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) oinfo = mtd->ecclayout; if (!mtd->oobsize || !oinfo || oinfo->oobavail < MTDSWAP_OOBSIZE) { printk(KERN_ERR "%s: Not enough free bytes in OOB, " - "%d available, %lu needed.\n", + "%d available, %zu needed.\n", MTDSWAP_PREFIX, oinfo->oobavail, MTDSWAP_OOBSIZE); return; } From 042bc9c0c434b61241ceda1d332e3076e2571859 Mon Sep 17 00:00:00 2001 From: Nicolas Ferre Date: Wed, 30 Mar 2011 16:26:40 +0800 Subject: [PATCH 2/5] mtd: atmel_nand: trivial: change DMA usage information trace Signed-off-by: Nicolas Ferre Signed-off-by: Artem Bityutskiy --- drivers/mtd/nand/atmel_nand.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 6fae04b3fc6d..7e88a801669c 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -611,7 +611,8 @@ static int __init atmel_nand_probe(struct platform_device *pdev) } } if (use_dma) - dev_info(host->dev, "Using DMA for NAND access.\n"); + dev_info(host->dev, "Using %s for DMA transfers.\n", + dma_chan_name(host->dma_chan)); else dev_info(host->dev, "No DMA support for NAND access.\n"); From cb457a4ddd4eeac9c81792a1e6a5d59b1b44abe1 Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Wed, 30 Mar 2011 16:26:41 +0800 Subject: [PATCH 3/5] mtd: atmel_nand: fix support for CPUs that do not support DMA access use_dma was always "1" even if the CPU does not support DMA Tested on AT91SAM9261EK by Jean-Christophe PLAGNIOL-VILLARD Reported-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Hong Xu Signed-off-by: Artem Bityutskiy --- drivers/mtd/nand/atmel_nand.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 7e88a801669c..f254fa636afc 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -599,7 +599,10 @@ static int __init atmel_nand_probe(struct platform_device *pdev) nand_chip->options |= NAND_USE_FLASH_BBT; } - if (cpu_has_dma() && use_dma) { + if (!cpu_has_dma()) + use_dma = 0; + + if (use_dma) { dma_cap_mask_t mask; dma_cap_zero(mask); From 9d51567e47a0d84f6b6e7751a4ea4f710cdcbbdf Mon Sep 17 00:00:00 2001 From: Nicolas Ferre Date: Fri, 1 Apr 2011 16:40:44 +0200 Subject: [PATCH 4/5] mtd: atmel_nand: modify test case for using DMA operations We have better performances not using DMA for oob operations. Modify size test so that it is using DMA for size greater than oobsize. Signed-off-by: Nicolas Ferre Signed-off-by: Artem Bityutskiy --- drivers/mtd/nand/atmel_nand.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index f254fa636afc..e9fdbe46b247 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -280,7 +280,8 @@ static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) struct nand_chip *chip = mtd->priv; struct atmel_nand_host *host = chip->priv; - if (use_dma && len >= mtd->oobsize) + if (use_dma && len > mtd->oobsize) + /* only use DMA for bigger than oob size: better performances */ if (atmel_nand_dma_op(mtd, buf, len, 1) == 0) return; @@ -295,7 +296,8 @@ static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len) struct nand_chip *chip = mtd->priv; struct atmel_nand_host *host = chip->priv; - if (use_dma && len >= mtd->oobsize) + if (use_dma && len > mtd->oobsize) + /* only use DMA for bigger than oob size: better performances */ if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0) return; From 80b4f81a49809774f1b123c456fb179e472dbd0e Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Thu, 31 Mar 2011 18:33:15 +0800 Subject: [PATCH 5/5] mtd: atmel_nand: use CPU I/O when buffer is in vmalloc(ed) region The previous way of dealing with vmalloc(ed) region by walking though the pages can not work well actually. We just fall back to CPU I/O when the buffer address is higher than `high_memory'. Signed-off-by: Nicolas Ferre Signed-off-by: Hong Xu Signed-off-by: Artem Bityutskiy --- drivers/mtd/nand/atmel_nand.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index e9fdbe46b247..950646aa4c4b 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -209,22 +209,8 @@ static int atmel_nand_dma_op(struct mtd_info *mtd, void *buf, int len, int err = -EIO; enum dma_data_direction dir = is_read ? DMA_FROM_DEVICE : DMA_TO_DEVICE; - if (buf >= high_memory) { - struct page *pg; - - if (((size_t)buf & PAGE_MASK) != - ((size_t)(buf + len - 1) & PAGE_MASK)) { - dev_warn(host->dev, "Buffer not fit in one page\n"); - goto err_buf; - } - - pg = vmalloc_to_page(buf); - if (pg == 0) { - dev_err(host->dev, "Failed to vmalloc_to_page\n"); - goto err_buf; - } - p = page_address(pg) + ((size_t)buf & ~PAGE_MASK); - } + if (buf >= high_memory) + goto err_buf; dma_dev = host->dma_chan->device;