From: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
Dave Gordon
<david.s.gordon-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
Brian Norris
<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Maxime Ripard
<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Dan Williams
<dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Mauro Carvalho Chehab
<m.chehab-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
Hans Verkuil
<hans.verkuil-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
Laurent Pinchart
<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>,
linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Ian Campbell
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 6/7] mtd: nand: sunxi: add support for DMA assisted operations
Date: Thu, 17 Mar 2016 15:06:19 +0100 [thread overview]
Message-ID: <20160317150619.7d6b5f37@bbrezillon> (raw)
In-Reply-To: <1457435715-24740-7-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
On Tue, 8 Mar 2016 12:15:14 +0100
Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> wrote:
> The sunxi NAND controller is able to pipeline ECC operations only when
> operated in DMA mode, which improves a lot NAND throughput while keeping
> CPU usage low.
>
> Signed-off-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
> drivers/mtd/nand/sunxi_nand.c | 301 +++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 297 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
> index 07c3af7..7ba285e 100644
> --- a/drivers/mtd/nand/sunxi_nand.c
> +++ b/drivers/mtd/nand/sunxi_nand.c
[...]
> +static int sunxi_nfc_hw_ecc_write_page_dma(struct mtd_info *mtd,
> + struct nand_chip *chip,
> + const u8 *buf,
> + int oob_required,
> + int page)
> +{
> + struct nand_chip *nand = mtd_to_nand(mtd);
> + struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller);
> + struct nand_ecc_ctrl *ecc = &nand->ecc;
> + struct sg_table sgt;
> + int ret, i;
> +
> + ret = sunxi_nfc_wait_cmd_fifo_empty(nfc);
> + if (ret)
> + return ret;
> +
> + ret = sunxi_nfc_dma_op_prepare(mtd, buf, ecc->size, ecc->steps,
> + DMA_TO_DEVICE, &sgt);
> + if (ret)
> + goto pio_fallback;
> +
> + for (i = 0; i < ecc->steps; i++) {
> + const u8 *oob = nand->oob_poi + (i * (ecc->bytes + 4));
> +
> + sunxi_nfc_hw_ecc_set_prot_oob_bytes(mtd, oob, i, !i, page);
> + }
> +
> + sunxi_nfc_hw_ecc_enable(mtd);
> + sunxi_nfc_randomizer_config(mtd, page, false);
> + sunxi_nfc_randomizer_enable(mtd);
> +
> + writel((NAND_CMD_RNDIN << 8) | NAND_CMD_PAGEPROG,
> + nfc->regs + NFC_REG_RCMD_SET);
> +
> + dma_async_issue_pending(nfc->dmac);
> +
> + writel(NFC_PAGE_OP | NFC_DATA_SWAP_METHOD |
> + NFC_DATA_TRANS | NFC_ACCESS_DIR,
> + nfc->regs + NFC_REG_CMD);
> +
> + ret = sunxi_nfc_wait_events(nfc, NFC_CMD_INT_FLAG, true, 0);
> + if (ret)
> + dmaengine_terminate_all(nfc->dmac);
> +
> + sunxi_nfc_randomizer_disable(mtd);
> + sunxi_nfc_hw_ecc_disable(mtd);
> +
> + sunxi_nfc_dma_op_cleanup(mtd, DMA_FROM_DEVICE, &sgt);
Should be DMA_TO_DEVICE here ^
> +
> + if (ret)
> + return ret;
> +
> + if (oob_required || (chip->options & NAND_NEED_SCRAMBLING))
> + /* TODO: use DMA to transfer extra OOB bytes ? */
> + sunxi_nfc_hw_ecc_write_extra_oob(mtd, chip->oob_poi,
> + NULL, page);
> +
> + return 0;
> +
> +pio_fallback:
> + return sunxi_nfc_hw_ecc_write_page(mtd, chip, buf, oob_required, page);
> +}
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2016-03-17 14:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-08 11:15 [PATCH 0/7] mtd: nand: sunxi: add support for DMA operations Boris Brezillon
[not found] ` <1457435715-24740-1-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-03-08 11:15 ` [PATCH 1/7] mtd: nand: sunxi: move some ECC related operations to their own functions Boris Brezillon
2016-03-08 11:15 ` [PATCH 2/7] mtd: nand: sunxi: make OOB retrieval optional Boris Brezillon
2016-03-08 11:15 ` [PATCH 3/7] mtd: nand: sunxi: make cur_off parameter optional in extra oob helpers Boris Brezillon
2016-03-08 11:15 ` [PATCH 4/7] scatterlist: add sg_alloc_table_from_buf() helper Boris Brezillon
[not found] ` <1457435715-24740-5-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-03-08 16:51 ` Laurent Pinchart
2016-03-08 16:57 ` Boris Brezillon
2016-03-21 15:46 ` Boris Brezillon
2016-03-08 11:15 ` [PATCH 5/7] mtd: provide helper to prepare buffers for DMA operations Boris Brezillon
[not found] ` <1457435715-24740-6-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-03-08 14:18 ` Vinod Koul
2016-03-08 14:46 ` Boris Brezillon
2016-03-08 11:15 ` [PATCH 6/7] mtd: nand: sunxi: add support for DMA assisted operations Boris Brezillon
[not found] ` <1457435715-24740-7-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-03-17 14:06 ` Boris Brezillon [this message]
2016-03-08 11:15 ` [PATCH 7/7] mtd: nand: sunxi: update DT bindings Boris Brezillon
2016-03-17 15:28 ` Rob Herring
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=20160317150619.7d6b5f37@bbrezillon \
--to=boris.brezillon-wi1+55scjutkeb57/3fjtnbpr1lh4cv8@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=david.s.gordon-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=hans.verkuil-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
--cc=m.chehab-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=wens-jdAy2FN1RRM@public.gmane.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).