aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMikael Olsson <mikael.olsson@arm.com>2023-05-02 10:39:22 +0200
committerMikael Olsson <mikael.olsson@arm.com>2023-05-02 12:54:00 +0200
commit099d90cf81e0bf483f8ad02f0d61a4fcbbb64ba8 (patch)
tree7ed6035a6f838ccb97e3b6f6c134c36bf3e1e8b0 /kernel
parent4f795b3bdf69627ff114523f823b5f9c9003ec30 (diff)
downloadethos-u-linux-driver-stack-099d90cf81e0bf483f8ad02f0d61a4fcbbb64ba8.tar.gz
Fix kernel driver not setting coherent DMA mask
When the kernel driver creates the Ethos-U device, it doesn't setup the coherent DMA mask. This causes the kernel to generate a warning the first time any of the coherent DMA functions are used and the kernel will end up using a default DMA mask. To ensure that the device uses the correct DMA mask and to no longer get the warning, the kernel driver will now setup the DMA mask for the device. Change-Id: I92c67c85be1754970412da92161dbf1ec993bca3
Diffstat (limited to 'kernel')
-rw-r--r--kernel/ethosu_device.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/ethosu_device.c b/kernel/ethosu_device.c
index 96bd8b4..48aa0a5 100644
--- a/kernel/ethosu_device.c
+++ b/kernel/ethosu_device.c
@@ -33,6 +33,7 @@
#include "ethosu_network_info.h"
#include "uapi/ethosu.h"
+#include <linux/dma-mapping.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/io.h>
@@ -48,6 +49,8 @@
#define MINOR_BASE 0 /* Minor version starts at 0 */
#define MINOR_COUNT 64 /* Allocate minor versions */
+#define DMA_ADDR_BITS 32 /* Number of address bits */
+
/****************************************************************************
* Variables
****************************************************************************/
@@ -380,6 +383,14 @@ static int ethosu_device_register(struct device *dev,
return ret;
}
+ /* Set mask for coherent DMA addressing */
+ ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(DMA_ADDR_BITS));
+ if (ret) {
+ dev_err(parent, "Failed to set coherent DMA mask. ret=%d", ret);
+
+ return ret;
+ }
+
ret = device_register(dev);
if (ret) {
dev_err(parent, "Failed to register device. ret=%d", ret);