]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
dmaengine: bcm2835: Enforce control block alignment
authorLukas Wunner <lukas@wunner.de>
Wed, 23 Jan 2019 08:26:00 +0000 (09:26 +0100)
committerVinod Koul <vkoul@kernel.org>
Mon, 4 Feb 2019 07:11:28 +0000 (12:41 +0530)
Per section 4.2.1.1 of the BCM2835 ARM Peripherals spec, control blocks
"must start at a 256 bit aligned address":
https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf

This rule is currently satisfied only by accident because struct
bcm2835_dma_cb has a size of 256 bit and the DMA pool API happens to
allocate blocks consecutively.  It seems safer to be explicit and tell
the DMA pool allocator about the required alignment.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Frank Pavlic <f.pavlic@kunbus.de>
Cc: Martin Sperl <kernel@martin.sperl.org>
Cc: Florian Meier <florian.meier@koalo.de>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Acked-by: Florian Kauer <florian.kauer@koalo.de>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/bcm2835-dma.c

index a56fe373e8f917ddb3cb67123a757dda5878d1f3..6d66e233a1919a5e74f7d7cc6f394c0d3dd36344 100644 (file)
@@ -503,8 +503,12 @@ static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan)
 
        dev_dbg(dev, "Allocating DMA channel %d\n", c->ch);
 
+       /*
+        * Control blocks are 256 bit in length and must start at a 256 bit
+        * (32 byte) aligned address (BCM2835 ARM Peripherals, sec. 4.2.1.1).
+        */
        c->cb_pool = dma_pool_create(dev_name(dev), dev,
-                                    sizeof(struct bcm2835_dma_cb), 0, 0);
+                                    sizeof(struct bcm2835_dma_cb), 32, 0);
        if (!c->cb_pool) {
                dev_err(dev, "unable to allocate descriptor pool\n");
                return -ENOMEM;