]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/msm/gpu: Fix crash during system suspend after unbind
authorAkhil P Oommen <quic_akhilpo@quicinc.com>
Wed, 28 Sep 2022 07:19:00 +0000 (12:49 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2022 08:27:13 +0000 (09:27 +0100)
[ Upstream commit 76efc2453d0e8e5d6692ef69981b183ad674edea ]

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 <quic_akhilpo@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/505075/
Link: https://lore.kernel.org/r/20220928124830.2.I5ee0ac073ccdeb81961e5ec0cce5f741a7207a71@changeid
Signed-off-by: Rob Clark <robdclark@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/msm/adreno/adreno_device.c
drivers/gpu/drm/msm/msm_gpu.c
drivers/gpu/drm/msm/msm_gpu.h

index 24b489b6129a00ac2930ddd29eb2e4cbc6d81ac1..628806423f7d2d162c4ffd6f1b34d61f1f94c1f0 100644 (file)
@@ -679,6 +679,9 @@ static int adreno_system_suspend(struct device *dev)
        struct msm_gpu *gpu = dev_to_gpu(dev);
        int remaining, ret;
 
+       if (!gpu)
+               return 0;
+
        suspend_scheduler(gpu);
 
        remaining = wait_event_timeout(gpu->retire_event,
@@ -700,7 +703,12 @@ out:
 
 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);
 }
 
index c2bfcf3f1f4038cfa3c32d30f714607622bfb280..01aae792ffa988d43be477dc27e0da66ed127d2f 100644 (file)
@@ -993,4 +993,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
        }
 
        msm_devfreq_cleanup(gpu);
+
+       platform_set_drvdata(gpu->pdev, NULL);
 }
index 4d935fedd2acc7593eb4fad1d71f9f031ea3e4ec..fd22cf4041af52d943a8fbdb191a4bad33d7302b 100644 (file)
@@ -282,6 +282,10 @@ struct msm_gpu {
 static inline struct msm_gpu *dev_to_gpu(struct device *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);
 }