Skip to content

Commit c5215d5

Browse files
mripardshuahkh
authored andcommitted
kunit: Setup DMA masks on the kunit device
Commit d393acc ("drm/tests: Switch to kunit devices") switched the DRM device creation helpers from an ad-hoc implementation to the new kunit device creation helpers introduced in commit d03c720 ("kunit: Add APIs for managing devices"). However, while the DRM helpers were using a platform_device, the kunit helpers are using a dedicated bus and device type. That situation creates small differences in the initialisation, and one of them is that the kunit devices do not have the DMA masks setup. In turn, this means that we can't do any kind of DMA buffer allocation anymore, which creates a regression on some (downstream for now) tests. Let's set up a default DMA mask that should work on any platform to fix it. Fixes: d03c720 ("kunit: Add APIs for managing devices") Signed-off-by: Maxime Ripard <mripard@kernel.org> Tested-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 2fadeb9 commit c5215d5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/kunit/device.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include <linux/device.h>
13+
#include <linux/dma-mapping.h>
1314

1415
#include <kunit/test.h>
1516
#include <kunit/device.h>
@@ -133,6 +134,9 @@ static struct kunit_device *kunit_device_register_internal(struct kunit *test,
133134
return ERR_PTR(err);
134135
}
135136

137+
kunit_dev->dev.dma_mask = &kunit_dev->dev.coherent_dma_mask;
138+
kunit_dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
139+
136140
kunit_add_action(test, device_unregister_wrapper, &kunit_dev->dev);
137141

138142
return kunit_dev;

0 commit comments

Comments
 (0)