Skip to contentSkip to conversation

drm/msm: Upgrade gxpd checks to IS_ERR_OR_NULL

PATCH In review Sean Paul 3 participants 4 messages May 15, 2019 3 messages not in the archive

Subsystems (4)
lore
Share & tools
lore

Sean Paul

author
#0 lore raw

PATCH 1/1 drm/msm: Upgrade gxpd checks to IS_ERR_OR_NULL

From: Sean Paul <[email protected]>

dev_pm_domain_attach_by_name() can return NULL, so we should check for that case when we're about to dereference gxpd.

Fixes 9325d4266afd ("drm/msm/gpu: Attach to the GPU GX power domain")
Cc Jordan Crouse <[email protected]>
Cc Rob Clark <[email protected]>
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +3 -3
index 9155dafae2a90..38e2cfa9cec79 100644
@@ -747,7 +747,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
 	 * will make sure that the refcounting is correct in case we need to
 	 * bring down the GX after a GMU failure
 	 */
-	if (!IS_ERR(gmu->gxpd))
+	if (!IS_ERR_OR_NULL(gmu->gxpd))
 		pm_runtime_get(gmu->gxpd);
 
 out:
@@ -863,7 +863,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
 	 * domain. Usually the GMU does this but only if the shutdown sequence
 	 * was successful
 	 */
-	if (!IS_ERR(gmu->gxpd))
+	if (!IS_ERR_OR_NULL(gmu->gxpd))
 		pm_runtime_put_sync(gmu->gxpd);
 
 	clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks);
@@ -1234,7 +1234,7 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
 
 	pm_runtime_disable(gmu->dev);
 
-	if (!IS_ERR(gmu->gxpd)) {
+	if (!IS_ERR_OR_NULL(gmu->gxpd)) {
 		pm_runtime_disable(gmu->gxpd);
 		dev_pm_domain_detach(gmu->gxpd, false);
 	}
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): 20190515170104.155525-1-sean-p7yTbzM4H96eqtR555YLDQ@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 9 lines · Sean Paul

From: Sean Paul <[email protected]>

dev_pm_domain_attach_by_name() can return NULL, so we should check for that case when we're about to dereference gxpd.

Fixes 9325d4266afd ("drm/msm/gpu: Attach to the GPU GX power domain")
Cc Jordan Crouse <[email protected]>
Cc Rob Clark <[email protected]>
Quoted 38 lines
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +3 -3
index 9155dafae2a90..38e2cfa9cec79 100644
@@ -747,7 +747,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
 	 * will make sure that the refcounting is correct in case we need to
 	 * bring down the GX after a GMU failure
 	 */
-	if (!IS_ERR(gmu->gxpd))
+	if (!IS_ERR_OR_NULL(gmu->gxpd))
 		pm_runtime_get(gmu->gxpd);
 
 out:
@@ -863,7 +863,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
 	 * domain. Usually the GMU does this but only if the shutdown sequence
 	 * was successful
 	 */
-	if (!IS_ERR(gmu->gxpd))
+	if (!IS_ERR_OR_NULL(gmu->gxpd))
 		pm_runtime_put_sync(gmu->gxpd);
 
 	clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks);
@@ -1234,7 +1234,7 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
 
 	pm_runtime_disable(gmu->dev);
 
-	if (!IS_ERR(gmu->gxpd)) {
+	if (!IS_ERR_OR_NULL(gmu->gxpd)) {
 		pm_runtime_disable(gmu->gxpd);
 		dev_pm_domain_detach(gmu->gxpd, false);
 	}
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
Signature · 6 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): 20190515193904.GE24137-p/[email protected]

author
#4 lore raw
Quoted 7 lines · Jordan Crouse
Quoted 5 lines · Sean Paul

From: Sean Paul <[email protected]>

dev_pm_domain_attach_by_name() can return NULL, so we should check for that case when we're about to dereference gxpd.

Quoted 7 lines
Quoted 4 lines
Fixes 9325d4266afd ("drm/msm/gpu: Attach to the GPU GX power domain")
Cc Jordan Crouse <[email protected]>
Cc Rob Clark <[email protected]>

Thanks for the review, I've applied it to -misc-next-fixes with the other msm fixes for 5.2

Sean

Quoted 30 lines
Quoted 30 lines
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +2 -2
index 9155dafae2a90..38e2cfa9cec79 100644
@@ -747,7 +747,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
       * will make sure that the refcounting is correct in case we need to
       * bring down the GX after a GMU failure
       */
-     if (!IS_ERR(gmu->gxpd))
+     if (!IS_ERR_OR_NULL(gmu->gxpd))
              pm_runtime_get(gmu->gxpd);
 
 out:
@@ -863,7 +863,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
       * domain. Usually the GMU does this but only if the shutdown sequence
       * was successful
       */
-     if (!IS_ERR(gmu->gxpd))
+     if (!IS_ERR_OR_NULL(gmu->gxpd))
              pm_runtime_put_sync(gmu->gxpd);
 
      clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks);
@@ -1234,7 +1234,7 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
 
      pm_runtime_disable(gmu->dev);
 
Quoted 12 lines
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +1 -2
-     if (!IS_ERR(gmu->gxpd)) {
+     if (!IS_ERR_OR_NULL(gmu->gxpd)) {
              pm_runtime_disable(gmu->gxpd);
              dev_pm_domain_detach(gmu->gxpd, false);
      }
--

Sean Paul, Software Engineer, Google / Chromium OS

--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): CAMavQKKxUDX-tOLULDfZxcizysWOr63VvBBT8fNa-VB=v8jvVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 13 lines · Sean Paul
Quoted 12 lines · Jordan Crouse
Quoted 9 lines · Sean Paul

From: Sean Paul <[email protected]>

dev_pm_domain_attach_by_name() can return NULL, so we should check for that case when we're about to dereference gxpd.

Fixes 9325d4266afd ("drm/msm/gpu: Attach to the GPU GX power domain")
Cc Jordan Crouse <[email protected]>
Cc Rob Clark <[email protected]>
Quoted 6 lines
Quoted 2 lines

Thanks for the review, I've applied it to -misc-next-fixes with the other msm fixes for 5.2

Thanks for fixing this.

I hadn't published my for-next-next branch when I spotted this, so the addition of the GPU in the dts was amended to include the gxpd - and will show up on -next after -rc1.

Regards,
Bjorn

Quoted 45 lines

Sean

Quoted 42 lines
Quoted 36 lines
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +3 -4
index 9155dafae2a90..38e2cfa9cec79 100644
@@ -747,7 +747,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
       * will make sure that the refcounting is correct in case we need to
       * bring down the GX after a GMU failure
       */
-     if (!IS_ERR(gmu->gxpd))
+     if (!IS_ERR_OR_NULL(gmu->gxpd))
              pm_runtime_get(gmu->gxpd);
 
 out:
@@ -863,7 +863,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
       * domain. Usually the GMU does this but only if the shutdown sequence
       * was successful
       */
-     if (!IS_ERR(gmu->gxpd))
+     if (!IS_ERR_OR_NULL(gmu->gxpd))
              pm_runtime_put_sync(gmu->gxpd);
 
      clk_bulk_disable_unprepare(gmu->nr_clocks, gmu->clocks);
@@ -1234,7 +1234,7 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
 
      pm_runtime_disable(gmu->dev);
 
-     if (!IS_ERR(gmu->gxpd)) {
+     if (!IS_ERR_OR_NULL(gmu->gxpd)) {
              pm_runtime_disable(gmu->gxpd);
              dev_pm_domain_detach(gmu->gxpd, false);
      }
--
Quoted 2 lines

Sean Paul, Software Engineer, Google / Chromium OS

--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno