From: kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org
To: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
Lee Jones <lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>,
Vinod Koul <vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Subject: [PATCH v3 10/11] dmaengine: bcm2835: add dma_memcopy support to bcm2835-dma
Date: Sat, 5 Mar 2016 10:52:21 +0000 [thread overview]
Message-ID: <1457175142-28665-11-git-send-email-kernel@martin.sperl.org> (raw)
In-Reply-To: <1457175142-28665-1-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
From: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Add dma_memcopy support to bcm2835-dma.
Also added check for an error condition in bcm2835_dma_create_cb_chain
that showed up during development of this patch.
Tested using dmatest for all 11 available dma channels with the
following output:
[ 476.543529] dmatest: Started 1 threads using dma0chan0
[ 489.011154] dmatest: dma0chan0-copy0: summary 10000 tests, 0 failures 802 iops 6452 KB/s (0)
[ 489.078379] dmatest: Started 1 threads using dma0chan1
[ 501.494448] dmatest: dma0chan1-copy0: summary 10000 tests, 0 failures 806 iops 6376 KB/s (0)
[ 501.562567] dmatest: Started 1 threads using dma0chan10
[ 514.515164] dmatest: dma0chan10-copy: summary 10000 tests, 0 failures 772 iops 6169 KB/s (0)
[ 514.582969] dmatest: Started 1 threads using dma0chan2
[ 527.092284] dmatest: dma0chan2-copy0: summary 10000 tests, 0 failures 800 iops 6405 KB/s (0)
[ 527.160290] dmatest: Started 1 threads using dma0chan3
[ 539.541064] dmatest: dma0chan3-copy0: summary 10000 tests, 0 failures 808 iops 6424 KB/s (0)
[ 539.608849] dmatest: Started 1 threads using dma0chan4
[ 552.402978] dmatest: dma0chan4-copy0: summary 10000 tests, 0 failures 782 iops 6286 KB/s (0)
[ 552.470852] dmatest: Started 1 threads using dma0chan5
[ 565.184158] dmatest: dma0chan5-copy0: summary 10000 tests, 0 failures 787 iops 6231 KB/s (0)
[ 565.251846] dmatest: Started 1 threads using dma0chan6
[ 577.959385] dmatest: dma0chan6-copy0: summary 10000 tests, 0 failures 787 iops 6244 KB/s (0)
[ 578.027259] dmatest: Started 1 threads using dma0chan7
[ 590.834078] dmatest: dma0chan7-copy0: summary 10000 tests, 0 failures 781 iops 6295 KB/s (0)
[ 590.901668] dmatest: Started 1 threads using dma0chan8
[ 603.640192] dmatest: dma0chan8-copy0: summary 10000 tests, 0 failures 785 iops 6265 KB/s (0)
[ 603.708531] dmatest: Started 1 threads using dma0chan9
[ 616.420882] dmatest: dma0chan9-copy0: summary 10000 tests, 0 failures 787 iops 6285 KB/s (0)
Signed-off-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
Reviewed-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
---
drivers/dma/bcm2835-dma.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 6c4b4e2..2884285 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -326,6 +326,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
struct bcm2835_cb_entry *cb_entry;
struct bcm2835_dma_cb *control_block;
+ if (!frames)
+ return NULL;
+
/* allocate and setup the descriptor. */
d = kzalloc(sizeof(*d) + frames * sizeof(struct bcm2835_cb_entry),
gfp);
@@ -623,6 +626,34 @@ static void bcm2835_dma_issue_pending(struct dma_chan *chan)
spin_unlock_irqrestore(&c->vc.lock, flags);
}
+struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
+ struct dma_chan *chan, dma_addr_t dst, dma_addr_t src,
+ size_t len, unsigned long flags)
+{
+ struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
+ struct bcm2835_desc *d;
+ u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC;
+ u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP;
+ size_t max_len = bcm2835_dma_max_frame_length(c);
+ size_t frames;
+
+ /* if src, dst or len is not given return with an error */
+ if (!src || !dst || !len)
+ return NULL;
+
+ /* calculate number of frames */
+ frames = bcm2835_dma_frames_for_length(len, max_len);
+
+ /* allocate the CB chain - this also fills in the pointers */
+ d = bcm2835_dma_create_cb_chain(chan, DMA_MEM_TO_MEM, false,
+ info, extra, frames,
+ src, dst, len, 0, GFP_KERNEL);
+ if (!d)
+ return NULL;
+
+ return vchan_tx_prep(&c->vc, &d->vd, flags);
+}
+
static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
struct dma_chan *chan,
struct scatterlist *sgl, unsigned int sg_len,
@@ -909,17 +940,20 @@ static int bcm2835_dma_probe(struct platform_device *pdev)
dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask);
dma_cap_set(DMA_CYCLIC, od->ddev.cap_mask);
dma_cap_set(DMA_SLAVE, od->ddev.cap_mask);
+ dma_cap_set(DMA_MEMCPY, od->ddev.cap_mask);
od->ddev.device_alloc_chan_resources = bcm2835_dma_alloc_chan_resources;
od->ddev.device_free_chan_resources = bcm2835_dma_free_chan_resources;
od->ddev.device_tx_status = bcm2835_dma_tx_status;
od->ddev.device_issue_pending = bcm2835_dma_issue_pending;
od->ddev.device_prep_dma_cyclic = bcm2835_dma_prep_dma_cyclic;
od->ddev.device_prep_slave_sg = bcm2835_dma_prep_slave_sg;
+ od->ddev.device_prep_dma_memcpy = bcm2835_dma_prep_dma_memcpy;
od->ddev.device_config = bcm2835_dma_slave_config;
od->ddev.device_terminate_all = bcm2835_dma_terminate_all;
od->ddev.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
od->ddev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
- od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
+ od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV) |
+ BIT(DMA_MEM_TO_MEM);
od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
od->ddev.dev = &pdev->dev;
INIT_LIST_HEAD(&od->ddev.channels);
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-03-05 10:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-05 10:52 [PATCH v3 00/11] dmaengine: bcm2835: bugfix + enhancement of driver kernel-TqfNSX0MhmxHKSADF0wUEw
[not found] ` <1457175142-28665-1-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-03-05 10:52 ` [PATCH v3 01/11] dmaengine: bcm2835: set residue_granularity field kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52 ` [PATCH v3 02/11] dmaengine: bcm2835: remove unnecessary masking of dma channels kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52 ` [PATCH v3 03/11] dmaengine: bcm2835: use shared interrupt for channel 11 to 14 kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52 ` [PATCH v3 04/11] ARM: bcm2835: dt: add bindings for shared interrupt properties kernel-TqfNSX0MhmxHKSADF0wUEw
[not found] ` <1457175142-28665-5-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-03-07 23:24 ` Eric Anholt
[not found] ` <87fuw1yipi.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2016-03-08 11:23 ` Martin Sperl
[not found] ` <3503D512-7E9C-46E8-91C7-CAD828DD48D1-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-03-11 5:53 ` Vinod Koul
2016-03-10 8:57 ` Mark Rutland
2016-03-11 8:51 ` Martin Sperl
[not found] ` <E60A6B56-0F3F-465C-8BF7-59EF35D41070-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-03-22 9:23 ` Martin Sperl
[not found] ` <56F10F21.9020709-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2016-03-22 10:24 ` Mark Rutland
2016-03-05 10:52 ` [PATCH v3 05/11] dmaengine: bcm2835: add additional defines for DMA-registers kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52 ` [PATCH v3 06/11] dmaengine: bcm2835: move cyclic member from bcm2835_chan into bcm2835_desc kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52 ` [PATCH v3 07/11] dmaengine: bcm2835: move controlblock chain generation into separate method kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52 ` [PATCH v3 08/11] dmaengine: bcm2835: limit max length based on channel type kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52 ` [PATCH v3 09/11] dmaengine: bcm2835: add slave_sg support to bcm2835-dma kernel-TqfNSX0MhmxHKSADF0wUEw
2016-03-05 10:52 ` kernel-TqfNSX0MhmxHKSADF0wUEw [this message]
2016-03-05 10:52 ` [PATCH v3 11/11] dmaengine: bcm2835: expose dma registers via debugfs kernel-TqfNSX0MhmxHKSADF0wUEw
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=1457175142-28665-11-git-send-email-kernel@martin.sperl.org \
--to=kernel-tqfnsx0mhmxhksadf0wuew@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org \
--cc=lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
--cc=vinod.koul-ral2JQCrhuEAvxtiuMwx3w@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).