Commit f880b07b authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Boris Brezillon

mtd: nand: cafe: remove use of NAND_OWN_BUFFERS

This driver is the last/only user of NAND_OWN_BUFFERS.  Boris suggested
to remove this flag.

Taking a closer look at this driver, it calls dma_alloc_coherent() for
the concatenated area for the DMA bounce buffer + struct nand_buffers,
but the latter does not need to be DMA-coherent; cafe_{write,read}_buf
simply do memcpy() between buffers when usedma==1.

Let's do dma_alloc_coherent() for the DMA bounce buffer in the front,
and leave the nand_buffers allocation to nand_scan_tail(), then rip off
NAND_OWN_BUFFERS.

The magic number, 2112, is still mysterious (hard-coded writesize +
oobsize ?), but this is not our main interest.  I am keeping it.
Suggested-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 17fa8044
...@@ -605,7 +605,6 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -605,7 +605,6 @@ static int cafe_nand_probe(struct pci_dev *pdev,
uint32_t ctrl; uint32_t ctrl;
int err = 0; int err = 0;
int old_dma; int old_dma;
struct nand_buffers *nbuf;
/* Very old versions shared the same PCI ident for all three /* Very old versions shared the same PCI ident for all three
functions on the chip. Verify the class too... */ functions on the chip. Verify the class too... */
...@@ -653,7 +652,6 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -653,7 +652,6 @@ static int cafe_nand_probe(struct pci_dev *pdev,
/* Enable the following for a flash based bad block table */ /* Enable the following for a flash based bad block table */
cafe->nand.bbt_options = NAND_BBT_USE_FLASH; cafe->nand.bbt_options = NAND_BBT_USE_FLASH;
cafe->nand.options = NAND_OWN_BUFFERS;
if (skipbbt) { if (skipbbt) {
cafe->nand.options |= NAND_SKIP_BBTSCAN; cafe->nand.options |= NAND_SKIP_BBTSCAN;
...@@ -723,15 +721,12 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -723,15 +721,12 @@ static int cafe_nand_probe(struct pci_dev *pdev,
if (err) if (err)
goto out_irq; goto out_irq;
cafe->dmabuf = dma_alloc_coherent(&cafe->pdev->dev, cafe->dmabuf = dma_alloc_coherent(&cafe->pdev->dev, 2112,
2112 + sizeof(struct nand_buffers) +
mtd->writesize + mtd->oobsize,
&cafe->dmaaddr, GFP_KERNEL); &cafe->dmaaddr, GFP_KERNEL);
if (!cafe->dmabuf) { if (!cafe->dmabuf) {
err = -ENOMEM; err = -ENOMEM;
goto out_irq; goto out_irq;
} }
cafe->nand.buffers = nbuf = (void *)cafe->dmabuf + 2112;
/* Set up DMA address */ /* Set up DMA address */
cafe_writel(cafe, cafe->dmaaddr & 0xffffffff, NAND_DMA_ADDR0); cafe_writel(cafe, cafe->dmaaddr & 0xffffffff, NAND_DMA_ADDR0);
...@@ -744,11 +739,6 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -744,11 +739,6 @@ static int cafe_nand_probe(struct pci_dev *pdev,
cafe_dev_dbg(&cafe->pdev->dev, "Set DMA address to %x (virt %p)\n", cafe_dev_dbg(&cafe->pdev->dev, "Set DMA address to %x (virt %p)\n",
cafe_readl(cafe, NAND_DMA_ADDR0), cafe->dmabuf); cafe_readl(cafe, NAND_DMA_ADDR0), cafe->dmabuf);
/* this driver does not need the @ecccalc and @ecccode */
nbuf->ecccalc = NULL;
nbuf->ecccode = NULL;
nbuf->databuf = (uint8_t *)(nbuf + 1);
/* Restore the DMA flag */ /* Restore the DMA flag */
usedma = old_dma; usedma = old_dma;
...@@ -793,10 +783,7 @@ static int cafe_nand_probe(struct pci_dev *pdev, ...@@ -793,10 +783,7 @@ static int cafe_nand_probe(struct pci_dev *pdev,
goto out; goto out;
out_free_dma: out_free_dma:
dma_free_coherent(&cafe->pdev->dev, dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
2112 + sizeof(struct nand_buffers) +
mtd->writesize + mtd->oobsize,
cafe->dmabuf, cafe->dmaaddr);
out_irq: out_irq:
/* Disable NAND IRQ in global IRQ mask register */ /* Disable NAND IRQ in global IRQ mask register */
cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK); cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK);
...@@ -821,10 +808,7 @@ static void cafe_nand_remove(struct pci_dev *pdev) ...@@ -821,10 +808,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
nand_release(mtd); nand_release(mtd);
free_rs(cafe->rs); free_rs(cafe->rs);
pci_iounmap(pdev, cafe->mmio); pci_iounmap(pdev, cafe->mmio);
dma_free_coherent(&cafe->pdev->dev, dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
2112 + sizeof(struct nand_buffers) +
mtd->writesize + mtd->oobsize,
cafe->dmabuf, cafe->dmaaddr);
kfree(cafe); kfree(cafe);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment