From 099d90cf81e0bf483f8ad02f0d61a4fcbbb64ba8 Mon Sep 17 00:00:00 2001 From: Mikael Olsson Date: Tue, 2 May 2023 10:39:22 +0200 Subject: 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 --- kernel/ethosu_device.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'kernel') 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 #include #include #include @@ -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); -- cgit v1.2.1