drm/msm/gpu: Fix crash on devices without devfreq support (v2)
Avoid going down devfreq paths on devices where devfreq is not
initialized.
v2: Change has_devfreq() logic [Dmitry]
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Reported-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>
Fixes: 6aa89ae1fb
("drm/msm/gpu: Cancel idle/boost work on suspend")
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20220308184844.1121029-1-robdclark@gmail.com
This commit is contained in:
parent
aaa743d838
commit
05afd57f4d
|
@ -83,6 +83,12 @@ static struct devfreq_dev_profile msm_devfreq_profile = {
|
||||||
static void msm_devfreq_boost_work(struct kthread_work *work);
|
static void msm_devfreq_boost_work(struct kthread_work *work);
|
||||||
static void msm_devfreq_idle_work(struct kthread_work *work);
|
static void msm_devfreq_idle_work(struct kthread_work *work);
|
||||||
|
|
||||||
|
static bool has_devfreq(struct msm_gpu *gpu)
|
||||||
|
{
|
||||||
|
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
||||||
|
return !!df->devfreq;
|
||||||
|
}
|
||||||
|
|
||||||
void msm_devfreq_init(struct msm_gpu *gpu)
|
void msm_devfreq_init(struct msm_gpu *gpu)
|
||||||
{
|
{
|
||||||
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
||||||
|
@ -149,6 +155,9 @@ void msm_devfreq_cleanup(struct msm_gpu *gpu)
|
||||||
{
|
{
|
||||||
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
||||||
|
|
||||||
|
if (!has_devfreq(gpu))
|
||||||
|
return;
|
||||||
|
|
||||||
devfreq_cooling_unregister(gpu->cooling);
|
devfreq_cooling_unregister(gpu->cooling);
|
||||||
dev_pm_qos_remove_request(&df->boost_freq);
|
dev_pm_qos_remove_request(&df->boost_freq);
|
||||||
dev_pm_qos_remove_request(&df->idle_freq);
|
dev_pm_qos_remove_request(&df->idle_freq);
|
||||||
|
@ -156,16 +165,24 @@ void msm_devfreq_cleanup(struct msm_gpu *gpu)
|
||||||
|
|
||||||
void msm_devfreq_resume(struct msm_gpu *gpu)
|
void msm_devfreq_resume(struct msm_gpu *gpu)
|
||||||
{
|
{
|
||||||
gpu->devfreq.busy_cycles = 0;
|
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
||||||
gpu->devfreq.time = ktime_get();
|
|
||||||
|
|
||||||
devfreq_resume_device(gpu->devfreq.devfreq);
|
if (!has_devfreq(gpu))
|
||||||
|
return;
|
||||||
|
|
||||||
|
df->busy_cycles = 0;
|
||||||
|
df->time = ktime_get();
|
||||||
|
|
||||||
|
devfreq_resume_device(df->devfreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void msm_devfreq_suspend(struct msm_gpu *gpu)
|
void msm_devfreq_suspend(struct msm_gpu *gpu)
|
||||||
{
|
{
|
||||||
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
||||||
|
|
||||||
|
if (!has_devfreq(gpu))
|
||||||
|
return;
|
||||||
|
|
||||||
devfreq_suspend_device(df->devfreq);
|
devfreq_suspend_device(df->devfreq);
|
||||||
|
|
||||||
cancel_idle_work(df);
|
cancel_idle_work(df);
|
||||||
|
@ -185,6 +202,9 @@ void msm_devfreq_boost(struct msm_gpu *gpu, unsigned factor)
|
||||||
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
||||||
uint64_t freq;
|
uint64_t freq;
|
||||||
|
|
||||||
|
if (!has_devfreq(gpu))
|
||||||
|
return;
|
||||||
|
|
||||||
freq = get_freq(gpu);
|
freq = get_freq(gpu);
|
||||||
freq *= factor;
|
freq *= factor;
|
||||||
|
|
||||||
|
@ -207,7 +227,7 @@ void msm_devfreq_active(struct msm_gpu *gpu)
|
||||||
struct devfreq_dev_status status;
|
struct devfreq_dev_status status;
|
||||||
unsigned int idle_time;
|
unsigned int idle_time;
|
||||||
|
|
||||||
if (!df->devfreq)
|
if (!has_devfreq(gpu))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -253,7 +273,7 @@ void msm_devfreq_idle(struct msm_gpu *gpu)
|
||||||
{
|
{
|
||||||
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
struct msm_gpu_devfreq *df = &gpu->devfreq;
|
||||||
|
|
||||||
if (!df->devfreq)
|
if (!has_devfreq(gpu))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
msm_hrtimer_queue_work(&df->idle_work, ms_to_ktime(1),
|
msm_hrtimer_queue_work(&df->idle_work, ms_to_ktime(1),
|
||||||
|
|
Loading…
Reference in New Issue