]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
arm/mach-bcm283x/mbox: Flush and invalidate dcache when using fw mailbox
authorAlexander Stein <alexanders83@web.de>
Fri, 24 Jul 2015 07:22:13 +0000 (09:22 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Thu, 10 Sep 2015 06:25:46 +0000 (08:25 +0200)
When using dcache the setup data for the mailbox must be actually written
into memory before calling into firmware. Thus flush and invalidate the
memory.

Signed-off-by: Alexander Stein <alexanders83@web.de>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
Tested-by: Stephen Warren <swarren@wwwdotorg.org>
arch/arm/mach-bcm283x/include/mach/mbox.h
arch/arm/mach-bcm283x/mbox.c

index 54d369c46c03094f7ad4633e8caa65cddba2c202..ff959c8a97d8ee3249a742b564a2bd1e8f2314da 100644 (file)
@@ -522,6 +522,9 @@ int bcm2835_mbox_call_raw(u32 chan, u32 send, u32 *recv);
  * a termination value are expected to immediately follow the header in
  * memory, as required by the property protocol.
  *
  * a termination value are expected to immediately follow the header in
  * memory, as required by the property protocol.
  *
+ * Each struct bcm2835_mbox_hdr passed must be allocated with
+ * ALLOC_CACHE_ALIGN_BUFFER(x, y, z) to ensure proper cache flush/invalidate.
+ *
  * Returns 0 for success, any other value for error.
  */
 int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer);
  * Returns 0 for success, any other value for error.
  */
 int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer);
index 1af9be78c68a3ccb5ba019a3f1e95e9122160142..311bd8feaab071fdb7ffdb23477ef8c68cdbcd23 100644 (file)
@@ -111,9 +111,18 @@ int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer)
        dump_buf(buffer);
 #endif
 
        dump_buf(buffer);
 #endif
 
+       flush_dcache_range((unsigned long)buffer,
+                          (unsigned long)((void *)buffer +
+                          roundup(buffer->buf_size, ARCH_DMA_MINALIGN)));
+
        ret = bcm2835_mbox_call_raw(chan, phys_to_bus((u32)buffer), &rbuffer);
        if (ret)
                return ret;
        ret = bcm2835_mbox_call_raw(chan, phys_to_bus((u32)buffer), &rbuffer);
        if (ret)
                return ret;
+
+       invalidate_dcache_range((unsigned long)buffer,
+                               (unsigned long)((void *)buffer +
+                               roundup(buffer->buf_size, ARCH_DMA_MINALIGN)));
+
        if (rbuffer != phys_to_bus((u32)buffer)) {
                printf("mbox: Response buffer mismatch\n");
                return -1;
        if (rbuffer != phys_to_bus((u32)buffer)) {
                printf("mbox: Response buffer mismatch\n");
                return -1;