[PATCH 1/3] drm/etnaviv: add generic compatible for the GPU subsystem node

Rob Herring robh at kernel.org
Mon Jan 22 17:23:30 UTC 2018


On Fri, Jan 19, 2018 at 01:06:32PM +0100, Lucas Stach wrote:
> With different SoCs gaining support for etnaviv it doesn't make much sense
> to add specific compatibles for the generic GPU subsystem node, which is
> only used to find all GPU core nodes.

How many other SoC families? Is it really more than a couple? The 
strings are already pretty generic. Plus the real GPU nodes already have 
completely generic compatibles. If you ever need to do something SoC 
specific, that leaves you with looking at the top-level compatible or 
SOL.

> 
> Add a generic compatible, that can be used by all new implementations.
> 
> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
> ---
>  Documentation/devicetree/bindings/display/etnaviv/etnaviv-drm.txt | 1 +
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c                             | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/display/etnaviv/etnaviv-drm.txt b/Documentation/devicetree/bindings/display/etnaviv/etnaviv-drm.txt
> index 05176f1ae108..c6f4e023c34a 100644
> --- a/Documentation/devicetree/bindings/display/etnaviv/etnaviv-drm.txt
> +++ b/Documentation/devicetree/bindings/display/etnaviv/etnaviv-drm.txt
> @@ -8,6 +8,7 @@ Required properties:
>  - compatible: Should be one of
>      "fsl,imx-gpu-subsystem"
>      "marvell,dove-gpu-subsystem"
> +    "vivante,gpu-subsystem"

I'd prefer to get rid of this fake node altogether. It exists 
entirely because somewhere in the stack wants 2D and 3D gpus 
exposed as a single DRM device. That's not really my problem 
from a DT perspective. 

Something like the patch below would solve the problem. It does break 
module auto loading, but that could be fixed by moving the device 
creation to the platforms (sometimes you just need platform specific 
code).

Note, I probably don't have node ref counting right and the 
of_device_is_available checking should really be in the core code.

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 491eddf9b150..fc62827055a8 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -662,16 +662,11 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
 
 	if (node) {
 		struct device_node *core_node;
-		int i;
 
-		for (i = 0; ; i++) {
-			core_node = of_parse_phandle(node, "cores", i);
-			if (!core_node)
-				break;
-
-			drm_of_component_match_add(&pdev->dev, &match,
-						   compare_of, core_node);
-			of_node_put(core_node);
+		for_each_compatible_node(core_node, NULL, "vivante,gc") {
+			if (of_device_is_available(core_node))
+				drm_of_component_match_add(&pdev->dev, &match,
+							   compare_of, core_node);
 		}
 	} else if (dev->platform_data) {
 		char **names = dev->platform_data;
@@ -691,28 +686,27 @@ static int etnaviv_pdev_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id dt_match[] = {
-	{ .compatible = "fsl,imx-gpu-subsystem" },
-	{ .compatible = "marvell,dove-gpu-subsystem" },
-	{}
-};
-MODULE_DEVICE_TABLE(of, dt_match);
-
 static struct platform_driver etnaviv_platform_driver = {
 	.probe      = etnaviv_pdev_probe,
 	.remove     = etnaviv_pdev_remove,
 	.driver     = {
 		.name   = "etnaviv",
-		.of_match_table = dt_match,
 	},
 };
 
 static int __init etnaviv_init(void)
 {
 	int ret;
+	struct device_node *node;
 
 	etnaviv_validate_init();
 
+	node = of_find_compatible_node(NULL, "vivante,gc");
+	if (node && of_device_is_available(node)) {
+		platform_device_register_simple("etnaviv", -1, NULL, 0);
+		of_node_put(node);
+	}
+
 	ret = platform_driver_register(&etnaviv_gpu_driver);
 	if (ret != 0)
 		return ret;


More information about the etnaviv mailing list