Skip to contentSkip to conversation

drm/msm: use compatible string to find mdp node

PATCH Superseded Krishna Manikandan 2 participants 2 messages Oct 5, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm: use compatible string to find mdp node

In the current implementation, substring comparison using device node name is used to find mdp node during driver probe. Use compatible string instead of node name to get mdp node from the parent mdss node.

---
 drivers/gpu/drm/msm/msm_drv.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +10 -3
index 2e6fc18..50a23cf 100644
@@ -1241,9 +1241,16 @@ static int add_components_mdp(struct device *mdp_dev,
 	return 0;
 }
 
-static int compare_name_mdp(struct device *dev, void *data)
+static int find_mdp_node(struct device *dev, void *data)
 {
-	return (strstr(dev_name(dev), "mdp") != NULL);
+	return of_device_is_compatible(dev->of_node, "qcom,mdp4") ||
+		of_device_is_compatible(dev->of_node, "qcom,mdp5") ||
+		of_device_is_compatible(dev->of_node, "qcom,mdss_mdp") ||
+		of_device_is_compatible(dev->of_node, "qcom,sdm845-dpu") ||
+		of_device_is_compatible(dev->of_node, "qcom,sm8150-dpu") ||
+		of_device_is_compatible(dev->of_node, "qcom,sm8250-dpu") ||
+		of_device_is_compatible(dev->of_node, "qcom,sc7180-dpu") ||
+		of_device_is_compatible(dev->of_node, "qcom,sc7280-dpu");
 }
 
 static int add_display_components(struct platform_device *pdev,
@@ -1268,7 +1275,7 @@ static int add_display_components(struct platform_device *pdev,
 			return ret;
 		}
 
-		mdp_dev = device_find_child(dev, NULL, compare_name_mdp);
+		mdp_dev = device_find_child(dev, NULL, find_mdp_node);
 		if (!mdp_dev) {
 			DRM_DEV_ERROR(dev, "failed to find MDSS MDP node\n");
 			of_platform_depopulate(dev);
Signature · 1 line
2.7.4
#1 lore raw

Quoting Krishna Manikandan (2021-10-05 02:44:31)

Quoted 15 lines

In the current implementation, substring comparison using device node name is used to find mdp node during driver probe. Use compatible string instead of node name to get mdp node from the parent mdss node.

---
 drivers/gpu/drm/msm/msm_drv.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +0 -0
index 2e6fc18..50a23cf 100644

drivers/gpu/drm/msm/msm_drv.c static int add_components_mdp(struct device *mdp_dev, · line 1246

Quoted 8 lines
drivers/gpu/drm/msm/msm_drv.c +2 -2
@@ -1241,9 +1241,16 @@ static int add_components_mdp(struct device *mdp_dev,
        return 0;
 }
 
-static int compare_name_mdp(struct device *dev, void *data)
+static int find_mdp_node(struct device *dev, void *data)
 {
-       return (strstr(dev_name(dev), "mdp") != NULL);
+       return of_device_is_compatible(dev->of_node, "qcom,mdp4") ||

Why do we care about mdp4? It looks like this function is only called if get_mdp_ver() returns 5 or DPU, in which case 4 isn't relevant?

drivers/gpu/drm/msm/msm_drv.c static int add_components_mdp(struct device *mdp_dev, · line 1253

Quoted 7 lines
drivers/gpu/drm/msm/msm_drv.c +7 -0
+               of_device_is_compatible(dev->of_node, "qcom,mdp5") ||
+               of_device_is_compatible(dev->of_node, "qcom,mdss_mdp") ||
+               of_device_is_compatible(dev->of_node, "qcom,sdm845-dpu") ||
+               of_device_is_compatible(dev->of_node, "qcom,sm8150-dpu") ||
+               of_device_is_compatible(dev->of_node, "qcom,sm8250-dpu") ||
+               of_device_is_compatible(dev->of_node, "qcom,sc7180-dpu") ||
+               of_device_is_compatible(dev->of_node, "qcom,sc7280-dpu");

Instead of this duplicate string check why not use canonical compatible lists?

	return of_match_node(dpu_dt_match, dev->of_node) ||
	       of_match_node(mdp5_dt_match, dev->of_node);

This way we're not constantly updating this list of compatibles in two places.

Quoted 12 lines
drivers/gpu/drm/msm/msm_drv.c +1 -1
 }
 
 static int add_display_components(struct platform_device *pdev,
@@ -1268,7 +1275,7 @@ static int add_display_components(struct platform_device *pdev,
                        return ret;
                }
 
-               mdp_dev = device_find_child(dev, NULL, compare_name_mdp);
+               mdp_dev = device_find_child(dev, NULL, find_mdp_node);
                if (!mdp_dev) {
                        DRM_DEV_ERROR(dev, "failed to find MDSS MDP node\n");
                        of_platform_depopulate(dev);