Skip to content

Commit 76efc24

Browse files
Akhil P Oommenrobclark
authored andcommitted
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: Akhil P Oommen <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/505075/ Link: https://lore.kernel.org/r/20220928124830.2.I5ee0ac073ccdeb81961e5ec0cce5f741a7207a71@changeid Signed-off-by: Rob Clark <[email protected]>
1 parent ec8f181 commit 76efc24

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

drivers/gpu/drm/msm/adreno/adreno_device.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,9 @@ static int adreno_system_suspend(struct device *dev)
679679
struct msm_gpu *gpu = dev_to_gpu(dev);
680680
int remaining, ret;
681681

682+
if (!gpu)
683+
return 0;
684+
682685
suspend_scheduler(gpu);
683686

684687
remaining = wait_event_timeout(gpu->retire_event,
@@ -700,7 +703,12 @@ static int adreno_system_suspend(struct device *dev)
700703

701704
static int adreno_system_resume(struct device *dev)
702705
{
703-
resume_scheduler(dev_to_gpu(dev));
706+
struct msm_gpu *gpu = dev_to_gpu(dev);
707+
708+
if (!gpu)
709+
return 0;
710+
711+
resume_scheduler(gpu);
704712
return pm_runtime_force_resume(dev);
705713
}
706714

drivers/gpu/drm/msm/msm_gpu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,4 +997,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
997997
}
998998

999999
msm_devfreq_cleanup(gpu);
1000+
1001+
platform_set_drvdata(gpu->pdev, NULL);
10001002
}

drivers/gpu/drm/msm/msm_gpu.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,10 @@ struct msm_gpu {
280280
static inline struct msm_gpu *dev_to_gpu(struct device *dev)
281281
{
282282
struct adreno_smmu_priv *adreno_smmu = dev_get_drvdata(dev);
283+
284+
if (!adreno_smmu)
285+
return NULL;
286+
283287
return container_of(adreno_smmu, struct msm_gpu, adreno_smmu);
284288
}
285289

0 commit comments

Comments
 (0)