Skip to content

Commit df518a0

Browse files
pinchartlffainelli
authored andcommitted
firmware: raspberrypi: Use correct device for DMA mappings
The buffer used to transfer data over the mailbox interface is mapped using the client's device. This is incorrect, as the device performing the DMA transfer is the mailbox itself. Fix it by using the mailbox controller device instead. This requires including the mailbox_controller.h header to dereference the mbox_chan and mbox_controller structures. The header is not meant to be included by clients. This could be fixed by extending the client API with a function to access the controller's device. Fixes: 4e3d606 ("ARM: bcm2835: Add the Raspberry Pi firmware driver") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Stefan Wahren <wahrenst@gmx.net> Tested-by: Ivan T. Ivanov <iivanov@suse.de> Link: https://lore.kernel.org/r/20240326195807.15163-3-laurent.pinchart@ideasonboard.com Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
1 parent 2604f31 commit df518a0

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/firmware/raspberrypi.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/dma-mapping.h>
1010
#include <linux/kref.h>
1111
#include <linux/mailbox_client.h>
12+
#include <linux/mailbox_controller.h>
1213
#include <linux/module.h>
1314
#include <linux/of.h>
1415
#include <linux/of_platform.h>
@@ -97,8 +98,8 @@ int rpi_firmware_property_list(struct rpi_firmware *fw,
9798
if (size & 3)
9899
return -EINVAL;
99100

100-
buf = dma_alloc_coherent(fw->cl.dev, PAGE_ALIGN(size), &bus_addr,
101-
GFP_ATOMIC);
101+
buf = dma_alloc_coherent(fw->chan->mbox->dev, PAGE_ALIGN(size),
102+
&bus_addr, GFP_ATOMIC);
102103
if (!buf)
103104
return -ENOMEM;
104105

@@ -126,7 +127,7 @@ int rpi_firmware_property_list(struct rpi_firmware *fw,
126127
ret = -EINVAL;
127128
}
128129

129-
dma_free_coherent(fw->cl.dev, PAGE_ALIGN(size), buf, bus_addr);
130+
dma_free_coherent(fw->chan->mbox->dev, PAGE_ALIGN(size), buf, bus_addr);
130131

131132
return ret;
132133
}

0 commit comments

Comments
 (0)