drm/msm: Handle component bind failures a bit better
Subsystems (4)
cover drm/msm: Handle component bind failures a bit better
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(-)
Signature · 1 line
2.7.4
PATCH 1/3 drm/msm/dpu: Fix error recovery after failing to enable clocks
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.
---
drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c +3 -3
@@ -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 ; } }
Signature · 6 lines
2.7.4 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 2/3 drm/msm/dpu: Avoid a null de-ref while recovering from kms init fail
In reply to Jordan CrouseIn 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.
---
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +6 -3
@@ -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)
Signature · 6 lines
2.7.4 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
Re: [Freedreno] [PATCH 2/3] drm/msm/dpu: Avoid a null de-ref while recovering from kms init fail
Quoted 3 lines · Jordan Crouse
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
Quoted 3 lines
if needed.
Signed-off-by Jordan Crouse <[email protected]>
Quoted 48 lines
---
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +6
-4@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 3/3 drm/msm/adreno: Call pm_runtime_force_suspend() during unbind
In reply to Jordan CrouseThe 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.
---
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(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +1 -3
@@ -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);
drivers/gpu/drm/msm/adreno/adreno_device.c +1 -1
@@ -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 );
Signature · 6 lines
2.7.4 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno