Commit 4342557fad308dd4ca8f9c2e74ea4f2dbddd5685

Authored by Alexander Stein
Committed by Tom Rini
1 parent 927753aeb9

arm/mach-bcm283x/mbox: Flush and invalidate dcache when using fw mailbox

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>

Showing 2 changed files with 12 additions and 0 deletions Side-by-side Diff

arch/arm/mach-bcm283x/include/mach/mbox.h
... ... @@ -522,6 +522,9 @@
522 522 * a termination value are expected to immediately follow the header in
523 523 * memory, as required by the property protocol.
524 524 *
  525 + * Each struct bcm2835_mbox_hdr passed must be allocated with
  526 + * ALLOC_CACHE_ALIGN_BUFFER(x, y, z) to ensure proper cache flush/invalidate.
  527 + *
525 528 * Returns 0 for success, any other value for error.
526 529 */
527 530 int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer);
arch/arm/mach-bcm283x/mbox.c
... ... @@ -111,9 +111,18 @@
111 111 dump_buf(buffer);
112 112 #endif
113 113  
  114 + flush_dcache_range((unsigned long)buffer,
  115 + (unsigned long)((void *)buffer +
  116 + roundup(buffer->buf_size, ARCH_DMA_MINALIGN)));
  117 +
114 118 ret = bcm2835_mbox_call_raw(chan, phys_to_bus((u32)buffer), &rbuffer);
115 119 if (ret)
116 120 return ret;
  121 +
  122 + invalidate_dcache_range((unsigned long)buffer,
  123 + (unsigned long)((void *)buffer +
  124 + roundup(buffer->buf_size, ARCH_DMA_MINALIGN)));
  125 +
117 126 if (rbuffer != phys_to_bus((u32)buffer)) {
118 127 printf("mbox: Response buffer mismatch\n");
119 128 return -1;