From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: linux-mtd@lists.infradead.org,
Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
linux-kernel@vger.kernel.org, Marek Vasut <marek.vasut@gmail.com>,
Brian Norris <computersforpeace@gmail.com>,
Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v2 1/3] mtd: nand: cafe: remove use of NAND_OWN_BUFFERS
Date: Thu, 7 Dec 2017 21:18:18 +0100 [thread overview]
Message-ID: <20171207211818.0125d499@bbrezillon> (raw)
In-Reply-To: <1512463636-28934-1-git-send-email-yamada.masahiro@socionext.com>
On Tue, 5 Dec 2017 17:47:14 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> 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: Boris Brezillon <boris.brezillon@free-electrons.com>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Applied the whole series.
Thanks,
Boris
> ---
>
> Changes in v2:
> - Newly added
>
> drivers/mtd/nand/cafe_nand.c | 24 ++++--------------------
> 1 file changed, 4 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
> index bc558c4..add4613 100644
> --- a/drivers/mtd/nand/cafe_nand.c
> +++ b/drivers/mtd/nand/cafe_nand.c
> @@ -613,7 +613,6 @@ static int cafe_nand_probe(struct pci_dev *pdev,
> uint32_t ctrl;
> int err = 0;
> int old_dma;
> - struct nand_buffers *nbuf;
>
> /* Very old versions shared the same PCI ident for all three
> functions on the chip. Verify the class too... */
> @@ -661,7 +660,6 @@ static int cafe_nand_probe(struct pci_dev *pdev,
>
> /* Enable the following for a flash based bad block table */
> cafe->nand.bbt_options = NAND_BBT_USE_FLASH;
> - cafe->nand.options = NAND_OWN_BUFFERS;
>
> if (skipbbt) {
> cafe->nand.options |= NAND_SKIP_BBTSCAN;
> @@ -731,15 +729,12 @@ static int cafe_nand_probe(struct pci_dev *pdev,
> if (err)
> goto out_irq;
>
> - cafe->dmabuf = dma_alloc_coherent(&cafe->pdev->dev,
> - 2112 + sizeof(struct nand_buffers) +
> - mtd->writesize + mtd->oobsize,
> - &cafe->dmaaddr, GFP_KERNEL);
> + cafe->dmabuf = dma_alloc_coherent(&cafe->pdev->dev, 2112,
> + &cafe->dmaaddr, GFP_KERNEL);
> if (!cafe->dmabuf) {
> err = -ENOMEM;
> goto out_irq;
> }
> - cafe->nand.buffers = nbuf = (void *)cafe->dmabuf + 2112;
>
> /* Set up DMA address */
> cafe_writel(cafe, cafe->dmaaddr & 0xffffffff, NAND_DMA_ADDR0);
> @@ -752,11 +747,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_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 */
> usedma = old_dma;
>
> @@ -801,10 +791,7 @@ static int cafe_nand_probe(struct pci_dev *pdev,
> goto out;
>
> out_free_dma:
> - dma_free_coherent(&cafe->pdev->dev,
> - 2112 + sizeof(struct nand_buffers) +
> - mtd->writesize + mtd->oobsize,
> - cafe->dmabuf, cafe->dmaaddr);
> + dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
> out_irq:
> /* Disable NAND IRQ in global IRQ mask register */
> cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK);
> @@ -829,10 +816,7 @@ static void cafe_nand_remove(struct pci_dev *pdev)
> nand_release(mtd);
> free_rs(cafe->rs);
> pci_iounmap(pdev, cafe->mmio);
> - dma_free_coherent(&cafe->pdev->dev,
> - 2112 + sizeof(struct nand_buffers) +
> - mtd->writesize + mtd->oobsize,
> - cafe->dmabuf, cafe->dmaaddr);
> + dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr);
> kfree(cafe);
> }
>
prev parent reply other threads:[~2017-12-07 20:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-05 8:47 [PATCH v2 1/3] mtd: nand: cafe: remove use of NAND_OWN_BUFFERS Masahiro Yamada
2017-12-05 8:47 ` [PATCH v2 2/3] mtd: nand: remove unused NAND_OWN_BUFFERS flag Masahiro Yamada
2017-12-05 8:47 ` [PATCH v2 3/3] mtd: nand: squash struct nand_buffers into struct nand_chip Masahiro Yamada
2017-12-05 11:49 ` Masahiro Yamada
2017-12-05 11:57 ` Boris Brezillon
2017-12-05 12:28 ` Masahiro Yamada
2017-12-05 13:30 ` Boris Brezillon
2017-12-05 9:44 ` [PATCH v2 1/3] mtd: nand: cafe: remove use of NAND_OWN_BUFFERS Boris Brezillon
2017-12-07 20:18 ` Boris Brezillon [this message]
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=20171207211818.0125d499@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
--cc=yamada.masahiro@socionext.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox