Skip to content

Commit 1a86630

Browse files
committed
drm/etnaviv: add DMA configuration for etnaviv platform device
The etnaviv device is a virtual device backing the DRM device, which may drive multiple hardware GPU core devices. As most of the dma-mapping handling is done through the virtual device, we need to make sure that a proper DMA setup is in place. The easiest way to get a reasonable configuration is to let the virtual device share the DMA configuration with one of the GPU devices, so call of_dma_configure() with the right parameters manually. This assumes that all etnaviv driven GPU devices in the system share the same DMA configuration. If we ever encounter a SoC where the GPUs are on busses with different offsets or behind different IOMMUs that will require much deeper changes to the driver, as we would need to implement etnaviv specific versions of most of the DRM helper functions. For now we should be fine with this solution. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Tested-by: Guido Günther <agx@sigxcpu.org> Tested-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
1 parent 5b394b2 commit 1a86630

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

drivers/gpu/drm/etnaviv/etnaviv_drv.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,6 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
592592
struct device *dev = &pdev->dev;
593593
struct component_match *match = NULL;
594594

595-
dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
596-
597595
if (!dev->platform_data) {
598596
struct device_node *core_node;
599597

@@ -655,13 +653,30 @@ static int __init etnaviv_init(void)
655653
for_each_compatible_node(np, NULL, "vivante,gc") {
656654
if (!of_device_is_available(np))
657655
continue;
658-
pdev = platform_device_register_simple("etnaviv", -1,
659-
NULL, 0);
660-
if (IS_ERR(pdev)) {
661-
ret = PTR_ERR(pdev);
656+
657+
pdev = platform_device_alloc("etnaviv", -1);
658+
if (!pdev) {
659+
ret = -ENOMEM;
660+
of_node_put(np);
661+
goto unregister_platform_driver;
662+
}
663+
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(40);
664+
pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
665+
666+
/*
667+
* Apply the same DMA configuration to the virtual etnaviv
668+
* device as the GPU we found. This assumes that all Vivante
669+
* GPUs in the system share the same DMA constraints.
670+
*/
671+
of_dma_configure(&pdev->dev, np, true);
672+
673+
ret = platform_device_add(pdev);
674+
if (ret) {
675+
platform_device_put(pdev);
662676
of_node_put(np);
663677
goto unregister_platform_driver;
664678
}
679+
665680
etnaviv_drm = pdev;
666681
of_node_put(np);
667682
break;

0 commit comments

Comments
 (0)