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 08/11] dmaengine: bcm2835: limit max length based on channel type
Date: Sat, 5 Mar 2016 10:52:19 +0000 [thread overview]
Message-ID: <1457175142-28665-9-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>
The bcm2835 dma system has 2 basic types of dma-channels:
* "normal" channels
* "light" channels
Lite channels are limited in several aspects:
* internal data-structure is 128 bit (not 256)
* does not support BCM2835_DMA_TDMODE (2D)
* DMA length register is limited to 16 bit.
so 0-65535 (not 0-65536 as mentioned in the official datasheet)
* BCM2835_DMA_S/D_IGNORE are not supported
The detection of the type of mode is implemented by looking at
the LITE bit in the DEBUG register for each channel.
This allows automatic detection.
Based on this the maximum block size is set to (64K - 4) or to 1G
and this limit is honored during generation of control block
chains. The effect is that when a LITE channel is used more
control blocks are used to do the same transfer (compared
to a normal channel).
As there are several sources/target DREQS that are 32 bit wide
we need to have the transfer to be a multiple of 4 as this would
break he transfer otherwise.
This is why the limit of (64K - 4) was chosen over the
alternative of (64K - 4K).
Signed-off-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
---
drivers/dma/bcm2835-dma.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 1ae53b8..024c949 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -83,6 +83,8 @@ struct bcm2835_chan {
int irq_number;
unsigned long irq_flags;
+
+ bool is_lite_channel;
};
struct bcm2835_desc {
@@ -185,6 +187,16 @@ struct bcm2835_desc {
#define BCM2835_DMA_IRQ_SHARED_DEFAULT 11
#define BCM2835_DMA_IRQ_ALL_DEFAULT 12
+/* the max dma length for different channels */
+#define MAX_DMA_LEN SZ_1G
+#define MAX_LITE_DMA_LEN (SZ_64K - 4)
+
+static inline size_t bcm2835_dma_max_frame_length(struct bcm2835_chan *c)
+{
+ /* lite and normal channels have different max frame length */
+ return c->is_lite_channel ? MAX_LITE_DMA_LEN : MAX_DMA_LEN;
+}
+
/* how many frames of max_len size do we need to transfer len bytes */
static inline size_t bcm2835_dma_frames_for_length(size_t len,
size_t max_len)
@@ -233,8 +245,10 @@ static void bcm2835_dma_create_cb_set_length(
size_t *total_len,
u32 finalextrainfo)
{
- /* set the length */
- control_block->length = len;
+ size_t max_len = bcm2835_dma_max_frame_length(chan);
+
+ /* set the length taking lite-channel limitations into account */
+ control_block->length = min_t(u32, len, max_len);
/* finished if we have no period_length */
if (!period_len)
@@ -570,6 +584,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
dma_addr_t src, dst;
u32 info = BCM2835_DMA_WAIT_RESP;
u32 extra = BCM2835_DMA_INT_EN;
+ size_t max_len = bcm2835_dma_max_frame_length(c);
size_t frames;
/* Grab configuration */
@@ -612,7 +627,10 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic(
}
/* calculate number of frames */
- frames = DIV_ROUND_UP(buf_len, period_len);
+ frames = /* number of periods */
+ DIV_ROUND_UP(buf_len, period_len) *
+ /* number of frames per period */
+ bcm2835_dma_frames_for_length(period_len, max_len);
/*
* allocate the CB chain
@@ -713,6 +731,11 @@ static int bcm2835_dma_chan_init(struct bcm2835_dmadev *d, int chan_id,
c->irq_number = irq;
c->irq_flags = irq_flags;
+ /* check in DEBUG register if this is a LITE channel */
+ if (readl(c->chan_base + BCM2835_DMA_DEBUG) &
+ BCM2835_DMA_DEBUG_LITE)
+ c->is_lite_channel = true;
+
return 0;
}
--
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 ` kernel-TqfNSX0MhmxHKSADF0wUEw [this message]
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 ` [PATCH v3 10/11] dmaengine: bcm2835: add dma_memcopy " kernel-TqfNSX0MhmxHKSADF0wUEw
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-9-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).