linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] drm/msm: Handle component bind failures a bit better
@ 2019-05-07 19:18 Jordan Crouse
  2019-05-07 19:18 ` [PATCH 1/3] drm/msm/dpu: Fix error recovery after failing to enable clocks Jordan Crouse
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jordan Crouse @ 2019-05-07 19:18 UTC (permalink / raw)
  To: freedreno
  Cc: linux-arm-msm, Sean Paul, Chandan Uddaraju, Sharat Masetty,
	dri-devel, David Airlie, Daniel Mack, Gustavo A. R. Silva,
	Douglas Anderson, Rob Clark, Stephen Boyd, Jeykumar Sankaran,
	Andy Gross, Rajesh Yadav, Sravanthi Kollukuduru, Bruce Wang,
	Kees Cook, linux-kernel, Jonathan Marek, Mamta Shukla,
	Daniel Vetter

I somewhat accidently injected an error in the DPU KMS init that caused it to
fail and a handful of NULL deferences and errors ended up popping out. Here are
some fixes in the interest of robustness.

Jordan Crouse (3):
  drm/msm/dpu: Fix error recovery after failing to enable clocks
  drm/msm/dpu: Avoid a null de-ref while recovering from kms init fail
  drm/msm/adreno: Call pm_runtime_force_suspend() during unbind

 drivers/gpu/drm/msm/adreno/a6xx_gmu.c       | 4 +---
 drivers/gpu/drm/msm/adreno/adreno_device.c  | 2 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c | 6 +++---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c     | 9 ++++++---
 4 files changed, 11 insertions(+), 10 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] drm/msm/dpu: Fix error recovery after failing to enable clocks
  2019-05-07 19:18 [PATCH 0/3] drm/msm: Handle component bind failures a bit better Jordan Crouse
@ 2019-05-07 19:18 ` Jordan Crouse
  2019-05-07 19:18 ` [PATCH 2/3] drm/msm/dpu: Avoid a null de-ref while recovering from kms init fail Jordan Crouse
  2019-05-07 19:18 ` [PATCH 3/3] drm/msm/adreno: Call pm_runtime_force_suspend() during unbind Jordan Crouse
  2 siblings, 0 replies; 5+ messages in thread
From: Jordan Crouse @ 2019-05-07 19:18 UTC (permalink / raw)
  To: freedreno
  Cc: linux-arm-msm, Sean Paul, Kees Cook, Chandan Uddaraju,
	linux-kernel, dri-devel, Jeykumar Sankaran, Gustavo A. R. Silva,
	Rob Clark, David Airlie, Rajesh Yadav, Mamta Shukla,
	Daniel Vetter

If enabling clocks fails in msm_dss_enable_clk() the code to unwind the
settings starts at 'i' which is the clock that just failed. While this
isn't harmful it does result in a number of warnings from the clock
subsystem while trying to unpreare/disable the very clock that had
just failed to prepare/enable. Skip the current failed clock during
the unwind to to avoid the extra log spew.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---

 drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c
index 78833c2..a40a630 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c
@@ -114,9 +114,9 @@ int msm_dss_enable_clk(struct dss_clk *clk_arry, int num_clk, int enable)
 				rc = -EPERM;
 			}
 
-			if (rc) {
-				msm_dss_enable_clk(&clk_arry[i],
-					i, false);
+			if (rc && i) {
+				msm_dss_enable_clk(&clk_arry[i - 1],
+					i - 1, false);
 				break;
 			}
 		}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] drm/msm/dpu: Avoid a null de-ref while recovering from kms init fail
  2019-05-07 19:18 [PATCH 0/3] drm/msm: Handle component bind failures a bit better Jordan Crouse
  2019-05-07 19:18 ` [PATCH 1/3] drm/msm/dpu: Fix error recovery after failing to enable clocks Jordan Crouse
@ 2019-05-07 19:18 ` Jordan Crouse
  2019-05-09 15:44   ` [Freedreno] " Kristian Høgsberg
  2019-05-07 19:18 ` [PATCH 3/3] drm/msm/adreno: Call pm_runtime_force_suspend() during unbind Jordan Crouse
  2 siblings, 1 reply; 5+ messages in thread
From: Jordan Crouse @ 2019-05-07 19:18 UTC (permalink / raw)
  To: freedreno
  Cc: linux-arm-msm, Sean Paul, Bruce Wang, linux-kernel, dri-devel,
	Jeykumar Sankaran, Rob Clark, David Airlie,
	Sravanthi Kollukuduru, Daniel Vetter

In the failure path for dpu_kms_init() it is possible to get to the MMU
destroy function with uninitialized MMU structs. Check for NULl and skip
if needed.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---

 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 885bf88..1beaf29 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -56,7 +56,7 @@ static const char * const iommu_ports[] = {
 #define DPU_DEBUGFS_HWMASKNAME "hw_log_mask"
 
 static int dpu_kms_hw_init(struct msm_kms *kms);
-static int _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms);
+static void _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms);
 
 static unsigned long dpu_iomap_size(struct platform_device *pdev,
 				    const char *name)
@@ -725,17 +725,20 @@ static const struct msm_kms_funcs kms_funcs = {
 #endif
 };
 
-static int _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms)
+static void _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms)
 {
 	struct msm_mmu *mmu;
 
+	if (!dpu_kms->base.aspace)
+		return;
+
 	mmu = dpu_kms->base.aspace->mmu;
 
 	mmu->funcs->detach(mmu, (const char **)iommu_ports,
 			ARRAY_SIZE(iommu_ports));
 	msm_gem_address_space_put(dpu_kms->base.aspace);
 
-	return 0;
+	dpu_kms->base.aspace = NULL;
 }
 
 static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] drm/msm/adreno: Call pm_runtime_force_suspend() during unbind
  2019-05-07 19:18 [PATCH 0/3] drm/msm: Handle component bind failures a bit better Jordan Crouse
  2019-05-07 19:18 ` [PATCH 1/3] drm/msm/dpu: Fix error recovery after failing to enable clocks Jordan Crouse
  2019-05-07 19:18 ` [PATCH 2/3] drm/msm/dpu: Avoid a null de-ref while recovering from kms init fail Jordan Crouse
@ 2019-05-07 19:18 ` Jordan Crouse
  2 siblings, 0 replies; 5+ messages in thread
From: Jordan Crouse @ 2019-05-07 19:18 UTC (permalink / raw)
  To: freedreno
  Cc: linux-arm-msm, Sean Paul, Stephen Boyd, Sharat Masetty,
	dri-devel, linux-kernel, Andy Gross, Douglas Anderson,
	David Airlie, Jonathan Marek, Rob Clark, Daniel Mack,
	Mamta Shukla, Daniel Vetter

The GPU specific pm_suspend code assumes that the hardware is active
when the function is called, which it usually is when called as part
of pm_runtime.  But during unbind, the pm_suspend functions are called
blindly resulting in a bit of a when the hardware wasn't already
active (or booted, in the case of the GMU).

Instead of calling the pm_suspend function directly, use
pm_runtime_force_suspend() which should check the correct state of
runtime and call the functions on our behalf or skip them if they are
not needed.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---

 drivers/gpu/drm/msm/adreno/a6xx_gmu.c      | 4 +---
 drivers/gpu/drm/msm/adreno/adreno_device.c | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 9155daf..447706d 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -1230,9 +1230,7 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
 	if (IS_ERR_OR_NULL(gmu->mmio))
 		return;
 
-	a6xx_gmu_stop(a6xx_gpu);
-
-	pm_runtime_disable(gmu->dev);
+	pm_runtime_force_suspend(gmu->dev);
 
 	if (!IS_ERR(gmu->gxpd)) {
 		pm_runtime_disable(gmu->gxpd);
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
index b907245..3dd90df 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -351,7 +351,7 @@ static void adreno_unbind(struct device *dev, struct device *master,
 {
 	struct msm_gpu *gpu = dev_get_drvdata(dev);
 
-	gpu->funcs->pm_suspend(gpu);
+	pm_runtime_force_suspend(dev);
 	gpu->funcs->destroy(gpu);
 
 	set_gpu_pdev(dev_get_drvdata(master), NULL);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Freedreno] [PATCH 2/3] drm/msm/dpu: Avoid a null de-ref while recovering from kms init fail
  2019-05-07 19:18 ` [PATCH 2/3] drm/msm/dpu: Avoid a null de-ref while recovering from kms init fail Jordan Crouse
@ 2019-05-09 15:44   ` Kristian Høgsberg
  0 siblings, 0 replies; 5+ messages in thread
From: Kristian Høgsberg @ 2019-05-09 15:44 UTC (permalink / raw)
  To: Jordan Crouse
  Cc: freedreno, David Airlie, linux-arm-msm, LKML, dri-devel,
	Bruce Wang, Rob Clark, Daniel Vetter, Jeykumar Sankaran,
	Sean Paul, Sravanthi Kollukuduru

On Tue, May 7, 2019 at 12:18 PM Jordan Crouse <jcrouse@codeaurora.org> wrote:
>
> In the failure path for dpu_kms_init() it is possible to get to the MMU
> destroy function with uninitialized MMU structs. Check for NULl and skip

s/NULl/NULL

> if needed.
>
> Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>

> ---
>
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> index 885bf88..1beaf29 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> @@ -56,7 +56,7 @@ static const char * const iommu_ports[] = {
>  #define DPU_DEBUGFS_HWMASKNAME "hw_log_mask"
>
>  static int dpu_kms_hw_init(struct msm_kms *kms);
> -static int _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms);
> +static void _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms);
>
>  static unsigned long dpu_iomap_size(struct platform_device *pdev,
>                                     const char *name)
> @@ -725,17 +725,20 @@ static const struct msm_kms_funcs kms_funcs = {
>  #endif
>  };
>
> -static int _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms)
> +static void _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms)
>  {
>         struct msm_mmu *mmu;
>
> +       if (!dpu_kms->base.aspace)
> +               return;
> +
>         mmu = dpu_kms->base.aspace->mmu;
>
>         mmu->funcs->detach(mmu, (const char **)iommu_ports,
>                         ARRAY_SIZE(iommu_ports));
>         msm_gem_address_space_put(dpu_kms->base.aspace);
>
> -       return 0;
> +       dpu_kms->base.aspace = NULL;
>  }
>
>  static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms)
> --
> 2.7.4
>
> _______________________________________________
> Freedreno mailing list
> Freedreno@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/freedreno

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-05-09 15:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-07 19:18 [PATCH 0/3] drm/msm: Handle component bind failures a bit better Jordan Crouse
2019-05-07 19:18 ` [PATCH 1/3] drm/msm/dpu: Fix error recovery after failing to enable clocks Jordan Crouse
2019-05-07 19:18 ` [PATCH 2/3] drm/msm/dpu: Avoid a null de-ref while recovering from kms init fail Jordan Crouse
2019-05-09 15:44   ` [Freedreno] " Kristian Høgsberg
2019-05-07 19:18 ` [PATCH 3/3] drm/msm/adreno: Call pm_runtime_force_suspend() during unbind Jordan Crouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).