Skip to content

Commit 8c89ef7

Browse files
linuswChristoph Hellwig
authored andcommitted
of/platform: initialise AMBA default DMA masks
This addresses a v4.19-rc1 regression in the PL111 DRM driver in drivers/gpu/pl111/* The driver uses the CMA KMS helpers and will thus at some point call down to dma_alloc_attrs() to allocate a chunk of contigous DMA memory for the framebuffer. It appears that in v4.18, it was OK that this (and other DMA mastering AMBA devices) left dev->coherent_dma_mask blank (zero). In v4.19-rc1 the WARN_ON_ONCE(dev && !dev->coherent_dma_mask) in dma_alloc_attrs() in include/linux/dma-mapping.h is triggered. The allocation later fails when get_coherent_dma_mask() is called from __dma_alloc() and __dma_alloc() returns NULL: drm-clcd-pl111 dev:20: coherent DMA mask is unset drm-clcd-pl111 dev:20: [drm:drm_fb_helper_fbdev_setup] *ERROR* Failed to set fbdev configuration It turns out that in commit 4d8bde8 ("OF: Don't set default coherent DMA mask") the OF core stops setting the default DMA mask on new devices, especially those lines of the patch: - if (!dev->coherent_dma_mask) - dev->coherent_dma_mask = DMA_BIT_MASK(32); Robin Murphy solved a similar problem in a551621 ("of/platform: Initialise default DMA masks") by simply assigning dev.coherent_dma_mask and the dev.dma_mask to point to the same when creating devices from the device tree, and introducing the same code into the code path creating AMBA/PrimeCell devices solved my problem, graphics now come up. The code simply assumes that the device can access all of the system memory by setting the coherent DMA mask to 0xffffffff when creating a device from the device tree, which is crude, but seems to be what kernel v4.18 assumed. The AMBA PrimeCells do not differ between coherent and streaming DMA so we can just assign the same to any DMA mask. Possibly drivers should augment their coherent DMA mask in accordance with "dma-ranges" from the device tree if more finegranular masking is needed. Reported-by: Russell King <[email protected]> Fixes: 4d8bde8 ("OF: Don't set default coherent DMA mask") Cc: Russell King <[email protected]> Cc: Robin Murphy <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 5a7faef commit 8c89ef7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/of/platform.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
241241
if (!dev)
242242
goto err_clear_flag;
243243

244+
/* AMBA devices only support a single DMA mask */
245+
dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
246+
dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
247+
244248
/* setup generic device info */
245249
dev->dev.of_node = of_node_get(node);
246250
dev->dev.fwnode = &node->fwnode;

0 commit comments

Comments
 (0)