Skip to contentSkip to conversation

drm/msm: handle for EPROBE_DEFER for of_icc_get

PATCH Superseded Jonathan Marek 2 participants 4 messages Jul 9, 2020 – Jul 10, 2020

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/msm: handle for EPROBE_DEFER for of_icc_get

Check for errors instead of silently not using icc if the msm driver probes before the interconnect driver.

Allow ENODATA for ocmem path, as it is optional and this error is returned when "gfx-mem" path is provided but not "ocmem".

Remove the WARN_ON in msm_gpu_cleanup because INIT_LIST_HEAD won't have been called on the list yet when going through the defer error path.

Changes in v2:
* Changed to not only check for EPROBE_DEFER

---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 17 ++++++++++++++---
 drivers/gpu/drm/msm/msm_gpu.c           |  2 --
 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +14 -3
index 89673c7ed473..0f5217202eb5 100644
@@ -940,12 +940,20 @@ static int adreno_get_pwrlevels(struct device *dev,
 		 */
 		gpu->icc_path = of_icc_get(dev, NULL);
 	}
-	if (IS_ERR(gpu->icc_path))
+	if (IS_ERR(gpu->icc_path)) {
+		ret = PTR_ERR(gpu->icc_path);
 		gpu->icc_path = NULL;
+		return ret;
+	}
 
 	gpu->ocmem_icc_path = of_icc_get(dev, "ocmem");
-	if (IS_ERR(gpu->ocmem_icc_path))
+	if (IS_ERR(gpu->ocmem_icc_path)) {
+		ret = PTR_ERR(gpu->ocmem_icc_path);
 		gpu->ocmem_icc_path = NULL;
+		/* allow -ENODATA, ocmem icc is optional */
+		if (ret != -ENODATA)
+			return ret;
+	}
 
 	return 0;
 }
@@ -996,6 +1004,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
 	struct adreno_platform_config *config = pdev->dev.platform_data;
 	struct msm_gpu_config adreno_gpu_config  = { 0 };
 	struct msm_gpu *gpu = &adreno_gpu->base;
+	int ret;
 
 	adreno_gpu->funcs = funcs;
 	adreno_gpu->info = adreno_info(config->rev);
@@ -1007,7 +1016,9 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
 
 	adreno_gpu_config.nr_rings = nr_rings;
 
-	adreno_get_pwrlevels(&pdev->dev, gpu);
+	ret = adreno_get_pwrlevels(&pdev->dev, gpu);
+	if (ret)
+		return ret;
 
 	pm_runtime_set_autosuspend_delay(&pdev->dev,
 		adreno_gpu->info->inactive_period);
drivers/gpu/drm/msm/msm_gpu.c +0 -2
index a22d30622306..ccf9a0dd9706 100644
@@ -959,8 +959,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
 
 	DBG("%s", gpu->name);
 
-	WARN_ON(!list_empty(&gpu->active_list));
-
 	for (i = 0; i < ARRAY_SIZE(gpu->rb); i++) {
 		msm_ringbuffer_destroy(gpu->rb[i]);
 		gpu->rb[i] = NULL;
Signature · 1 line
2.26.1
#1 lore raw
Quoted 70 lines · Jonathan Marek

Check for errors instead of silently not using icc if the msm driver probes before the interconnect driver.

Allow ENODATA for ocmem path, as it is optional and this error is returned when "gfx-mem" path is provided but not "ocmem".

Remove the WARN_ON in msm_gpu_cleanup because INIT_LIST_HEAD won't have been called on the list yet when going through the defer error path.

Changes in v2:
* Changed to not only check for EPROBE_DEFER

---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 17 ++++++++++++++---
 drivers/gpu/drm/msm/msm_gpu.c           |  2 --
 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +14 -3
index 89673c7ed473..0f5217202eb5 100644
@@ -940,12 +940,20 @@ static int adreno_get_pwrlevels(struct device *dev,
                 */
                gpu->icc_path = of_icc_get(dev, NULL);
        }
-       if (IS_ERR(gpu->icc_path))
+       if (IS_ERR(gpu->icc_path)) {
+               ret = PTR_ERR(gpu->icc_path);
                gpu->icc_path = NULL;
+               return ret;
+       }
 
        gpu->ocmem_icc_path = of_icc_get(dev, "ocmem");
-       if (IS_ERR(gpu->ocmem_icc_path))
+       if (IS_ERR(gpu->ocmem_icc_path)) {
+               ret = PTR_ERR(gpu->ocmem_icc_path);
                gpu->ocmem_icc_path = NULL;
+               /* allow -ENODATA, ocmem icc is optional */
+               if (ret != -ENODATA)
+                       return ret;
+       }
 
        return 0;
 }
@@ -996,6 +1004,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
        struct adreno_platform_config *config = pdev->dev.platform_data;
        struct msm_gpu_config adreno_gpu_config  = { 0 };
        struct msm_gpu *gpu = &adreno_gpu->base;
+       int ret;
 
        adreno_gpu->funcs = funcs;
        adreno_gpu->info = adreno_info(config->rev);
@@ -1007,7 +1016,9 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
 
        adreno_gpu_config.nr_rings = nr_rings;
 
-       adreno_get_pwrlevels(&pdev->dev, gpu);
+       ret = adreno_get_pwrlevels(&pdev->dev, gpu);
+       if (ret)
+               return ret;
 
        pm_runtime_set_autosuspend_delay(&pdev->dev,
                adreno_gpu->info->inactive_period);
drivers/gpu/drm/msm/msm_gpu.c +0 -0
index a22d30622306..ccf9a0dd9706 100644

drivers/gpu/drm/msm/msm_gpu.c void msm_gpu_cleanup(struct msm_gpu *gpu) · line 963

Quoted 5 lines
drivers/gpu/drm/msm/msm_gpu.c +0 -2
@@ -959,8 +959,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
 
        DBG("%s", gpu->name);
 
-       WARN_ON(!list_empty(&gpu->active_list));
-

hmm, not a huge fan of removing the WARN_ON().. can we just init the list head earlier?

BR,
-R

Quoted 6 lines
drivers/gpu/drm/msm/msm_gpu.c +0 -1
        for (i = 0; i < ARRAY_SIZE(gpu->rb); i++) {
                msm_ringbuffer_destroy(gpu->rb[i]);
                gpu->rb[i] = NULL;
--

2.26.1

#2 lore raw
Quoted 72 lines · Rob Clark
Quoted 71 lines · Jonathan Marek

Check for errors instead of silently not using icc if the msm driver probes before the interconnect driver.

Allow ENODATA for ocmem path, as it is optional and this error is returned when "gfx-mem" path is provided but not "ocmem".

Remove the WARN_ON in msm_gpu_cleanup because INIT_LIST_HEAD won't have been called on the list yet when going through the defer error path.

Changes in v2:
* Changed to not only check for EPROBE_DEFER

---
  drivers/gpu/drm/msm/adreno/adreno_gpu.c | 17 ++++++++++++++---
  drivers/gpu/drm/msm/msm_gpu.c           |  2 --
  2 files changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +14 -3
index 89673c7ed473..0f5217202eb5 100644
@@ -940,12 +940,20 @@ static int adreno_get_pwrlevels(struct device *dev,
                  */
                 gpu->icc_path = of_icc_get(dev, NULL);
         }
-       if (IS_ERR(gpu->icc_path))
+       if (IS_ERR(gpu->icc_path)) {
+               ret = PTR_ERR(gpu->icc_path);
                 gpu->icc_path = NULL;
+               return ret;
+       }
 
         gpu->ocmem_icc_path = of_icc_get(dev, "ocmem");
-       if (IS_ERR(gpu->ocmem_icc_path))
+       if (IS_ERR(gpu->ocmem_icc_path)) {
+               ret = PTR_ERR(gpu->ocmem_icc_path);
                 gpu->ocmem_icc_path = NULL;
+               /* allow -ENODATA, ocmem icc is optional */
+               if (ret != -ENODATA)
+                       return ret;
+       }
 
         return 0;
  }
@@ -996,6 +1004,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
         struct adreno_platform_config *config = pdev->dev.platform_data;
         struct msm_gpu_config adreno_gpu_config  = { 0 };
         struct msm_gpu *gpu = &adreno_gpu->base;
+       int ret;
 
         adreno_gpu->funcs = funcs;
         adreno_gpu->info = adreno_info(config->rev);
@@ -1007,7 +1016,9 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
 
         adreno_gpu_config.nr_rings = nr_rings;
 
-       adreno_get_pwrlevels(&pdev->dev, gpu);
+       ret = adreno_get_pwrlevels(&pdev->dev, gpu);
+       if (ret)
+               return ret;
 
         pm_runtime_set_autosuspend_delay(&pdev->dev,
                 adreno_gpu->info->inactive_period);
drivers/gpu/drm/msm/msm_gpu.c +0 -0
index a22d30622306..ccf9a0dd9706 100644
@@ -959,8 +959,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
 
Quoted 8 lines

drivers/gpu/drm/msm/msm_gpu.c void msm_gpu_cleanup(struct msm_gpu *gpu) · line 963

Quoted 4 lines
drivers/gpu/drm/msm/msm_gpu.c +0 -2
         DBG("%s", gpu->name);
 
-       WARN_ON(!list_empty(&gpu->active_list));
-

hmm, not a huge fan of removing the WARN_ON().. can we just init the list head earlier?

There doesn't seem to be a nice way of doing that. Would it be reasonable to instead detect that msm_gpu_init wasn't called (checking if gpu->dev is NULL?), and just skip the msm_gpu_cleanup() call in adreno_gpu_cleanup() in that case?

Quoted 9 lines

BR,
-R

Quoted 6 lines
drivers/gpu/drm/msm/msm_gpu.c +0 -1
         for (i = 0; i < ARRAY_SIZE(gpu->rb); i++) {
                 msm_ringbuffer_destroy(gpu->rb[i]);
                 gpu->rb[i] = NULL;
--

2.26.1

#3 lore raw
Quoted 83 lines · Jonathan Marek
Quoted 72 lines · Rob Clark
Quoted 71 lines · Jonathan Marek

Check for errors instead of silently not using icc if the msm driver probes before the interconnect driver.

Allow ENODATA for ocmem path, as it is optional and this error is returned when "gfx-mem" path is provided but not "ocmem".

Remove the WARN_ON in msm_gpu_cleanup because INIT_LIST_HEAD won't have been called on the list yet when going through the defer error path.

Changes in v2:
* Changed to not only check for EPROBE_DEFER

---
  drivers/gpu/drm/msm/adreno/adreno_gpu.c | 17 ++++++++++++++---
  drivers/gpu/drm/msm/msm_gpu.c           |  2 --
  2 files changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +14 -3
index 89673c7ed473..0f5217202eb5 100644
@@ -940,12 +940,20 @@ static int adreno_get_pwrlevels(struct device *dev,
                  */
                 gpu->icc_path = of_icc_get(dev, NULL);
         }
-       if (IS_ERR(gpu->icc_path))
+       if (IS_ERR(gpu->icc_path)) {
+               ret = PTR_ERR(gpu->icc_path);
                 gpu->icc_path = NULL;
+               return ret;
+       }
 
         gpu->ocmem_icc_path = of_icc_get(dev, "ocmem");
-       if (IS_ERR(gpu->ocmem_icc_path))
+       if (IS_ERR(gpu->ocmem_icc_path)) {
+               ret = PTR_ERR(gpu->ocmem_icc_path);
                 gpu->ocmem_icc_path = NULL;
+               /* allow -ENODATA, ocmem icc is optional */
+               if (ret != -ENODATA)
+                       return ret;
+       }
 
         return 0;
  }
@@ -996,6 +1004,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
         struct adreno_platform_config *config = pdev->dev.platform_data;
         struct msm_gpu_config adreno_gpu_config  = { 0 };
         struct msm_gpu *gpu = &adreno_gpu->base;
+       int ret;
 
         adreno_gpu->funcs = funcs;
         adreno_gpu->info = adreno_info(config->rev);
@@ -1007,7 +1016,9 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
 
         adreno_gpu_config.nr_rings = nr_rings;
 
-       adreno_get_pwrlevels(&pdev->dev, gpu);
+       ret = adreno_get_pwrlevels(&pdev->dev, gpu);
+       if (ret)
+               return ret;
 
         pm_runtime_set_autosuspend_delay(&pdev->dev,
                 adreno_gpu->info->inactive_period);
drivers/gpu/drm/msm/msm_gpu.c +0 -0
index a22d30622306..ccf9a0dd9706 100644
@@ -959,8 +959,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
 
Quoted 8 lines

drivers/gpu/drm/msm/msm_gpu.c void msm_gpu_cleanup(struct msm_gpu *gpu) · line 963

Quoted 4 lines
drivers/gpu/drm/msm/msm_gpu.c +0 -2
         DBG("%s", gpu->name);
 
-       WARN_ON(!list_empty(&gpu->active_list));
-

hmm, not a huge fan of removing the WARN_ON().. can we just init the list head earlier?

Quoted 4 lines

There doesn't seem to be a nice way of doing that. Would it be reasonable to instead detect that msm_gpu_init wasn't called (checking if gpu->dev is NULL?), and just skip the msm_gpu_cleanup() call in adreno_gpu_cleanup() in that case?

Hmm, you can't just call msm_gpu_init() before looking up the icc path in adreno_gpu_init()?

BR,
-R

Quoted 10 lines
Quoted 10 lines

BR,
-R

Quoted 6 lines
drivers/gpu/drm/msm/msm_gpu.c +0 -1
         for (i = 0; i < ARRAY_SIZE(gpu->rb); i++) {
                 msm_ringbuffer_destroy(gpu->rb[i]);
                 gpu->rb[i] = NULL;
--

2.26.1