Commit 76efc245 authored by Akhil P Oommen's avatar Akhil P Oommen Committed by Rob Clark

drm/msm/gpu: Fix crash during system suspend after unbind

In adreno_unbind, we should clean up gpu device's drvdata to avoid
accessing a stale pointer during system suspend. Also, check for NULL
ptr in both system suspend/resume callbacks.
Signed-off-by: default avatarAkhil P Oommen <quic_akhilpo@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/505075/
Link: https://lore.kernel.org/r/20220928124830.2.I5ee0ac073ccdeb81961e5ec0cce5f741a7207a71@changeidSigned-off-by: default avatarRob Clark <robdclark@chromium.org>
parent ec8f1813
...@@ -679,6 +679,9 @@ static int adreno_system_suspend(struct device *dev) ...@@ -679,6 +679,9 @@ static int adreno_system_suspend(struct device *dev)
struct msm_gpu *gpu = dev_to_gpu(dev); struct msm_gpu *gpu = dev_to_gpu(dev);
int remaining, ret; int remaining, ret;
if (!gpu)
return 0;
suspend_scheduler(gpu); suspend_scheduler(gpu);
remaining = wait_event_timeout(gpu->retire_event, remaining = wait_event_timeout(gpu->retire_event,
...@@ -700,7 +703,12 @@ static int adreno_system_suspend(struct device *dev) ...@@ -700,7 +703,12 @@ static int adreno_system_suspend(struct device *dev)
static int adreno_system_resume(struct device *dev) static int adreno_system_resume(struct device *dev)
{ {
resume_scheduler(dev_to_gpu(dev)); struct msm_gpu *gpu = dev_to_gpu(dev);
if (!gpu)
return 0;
resume_scheduler(gpu);
return pm_runtime_force_resume(dev); return pm_runtime_force_resume(dev);
} }
......
...@@ -997,4 +997,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu) ...@@ -997,4 +997,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
} }
msm_devfreq_cleanup(gpu); msm_devfreq_cleanup(gpu);
platform_set_drvdata(gpu->pdev, NULL);
} }
...@@ -280,6 +280,10 @@ struct msm_gpu { ...@@ -280,6 +280,10 @@ struct msm_gpu {
static inline struct msm_gpu *dev_to_gpu(struct device *dev) static inline struct msm_gpu *dev_to_gpu(struct device *dev)
{ {
struct adreno_smmu_priv *adreno_smmu = dev_get_drvdata(dev); struct adreno_smmu_priv *adreno_smmu = dev_get_drvdata(dev);
if (!adreno_smmu)
return NULL;
return container_of(adreno_smmu, struct msm_gpu, adreno_smmu); return container_of(adreno_smmu, struct msm_gpu, adreno_smmu);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment