drm/msm/gpu: Fix idle_work time
Subsystems (4)
PATCH 1/2 drm/msm/gpu: Fix idle_work time
From: Rob Clark <[email protected]>
This was supposed to be a relative timer, not absolute.
--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gpu_devfreq.c +1 -1
@@ -228,5 +228,5 @@ void msm_devfreq_idle(struct msm_gpu *gpu)struct msm_gpu_devfreq *df = &gpu->devfreq;msm_hrtimer_queue_work (&df->idle_work,ms_to_ktime (1 ), -HRTIMER_MODE_ABS ); +HRTIMER_MODE_REL ); }
Signature · 1 line
2.33.1
PATCH 2/2 drm/msm/gpu: Respect PM QoS constraints
From: Rob Clark <[email protected]>
Re-work the boost and idle clamping to use PM QoS requests instead, so they get aggreggated with other requests (such as cooling device).
This does have the minor side-effect that devfreq sysfs min_freq/ max_freq files now reflect the boost and idle clamping, as they show (despite what they are documented to show) the aggregated min/max freq. Fixing that in devfreq does not look straightforward after considering that OPPs can be dynamically added/removed. However writes to the sysfs files still behave as expected.
--- drivers/gpu/drm/msm/msm_gpu.h | 33 +++++++---- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 82 ++++++++++++++------------- 2 files changed, 66 insertions(+), 49 deletions(-)
drivers/gpu/drm/msm/msm_gpu.h +23 -10
@@ -87,6 +87,21 @@ struct msm_gpu_devfreq {/** devfreq: devfreq instance */ struct devfreq *devfreq; +/** +* idle_constraint: +* +* A PM QoS constraint to limit max freq while the GPU is idle. +*/ +struct dev_pm_qos_request idle_freq; + +/** +* boost_constraint: +* +* A PM QoS constraint to boost min freq for a period of time +* until the boost expires. +*/ +struct dev_pm_qos_request boost_freq; +/** * busy_cycles: *
@@ -103,22 +118,19 @@ struct msm_gpu_devfreq {ktime_t idle_time;/** -* idle_freq: +* idle_work: * -* Shadow frequency used while the GPU is idle. From the PoV of -* the devfreq governor, we are continuing to sample busyness and -* adjust frequency while the GPU is idle, but we use this shadow -* value as the GPU is actually clamped to minimum frequency while -* it is inactive. +* Used to delay clamping to idle freq on active->idle transition. */ -unsigned long idle_freq; +struct msm_hrtimer_work idle_work;/** -* idle_work: +* boost_work: * -* Used to delay clamping to idle freq on active->idle transition. +* Used to reset the boost_constraint after the boost period has +* elapsed */ -struct msm_hrtimer_work idle_work; +struct msm_hrtimer_work boost_work; };struct msm_gpu {
@@ -498,6 +510,7 @@ void msm_devfreq_init(struct msm_gpu *gpu);void msm_devfreq_cleanup (struct msm_gpu *gpu);void msm_devfreq_resume (struct msm_gpu *gpu);void msm_devfreq_suspend (struct msm_gpu *gpu); +void msm_devfreq_boost (struct msm_gpu *gpu,unsigned factor);void msm_devfreq_active (struct msm_gpu *gpu);void msm_devfreq_idle (struct msm_gpu *gpu);
drivers/gpu/drm/msm/msm_gpu_devfreq.c +43 -39
168 lines not on this page · raw message
Signature · 1 line
2.33.1
Re: [PATCH 2/2] drm/msm/gpu: Respect PM QoS constraints
Hi,
drivers/gpu/drm/msm/msm_gpu_devfreq.c void msm_devfreq_suspend(struct msm_gpu *gpu) · line 170
Quoted 9 lines · Rob Clark
drivers/gpu/drm/msm/msm_gpu_devfreq.c +8
-0+void msm_devfreq_boost (struct msm_gpu *gpu,unsigned factor) +{ +struct msm_gpu_devfreq *df = &gpu->devfreq; +unsigned long freq; + + freq =get_freq (gpu); + freq *= factor; + freq /=HZ_PER_KHZ ;
Should it do the divide first? I don't know for sure, but it feels like GPU frequency could conceivably be near-ish the u32 overflow? (~4 GHz). Better to be safe and do the / 1000 first?
drivers/gpu/drm/msm/msm_gpu_devfreq.c static void msm_devfreq_idle_work(struct kthread_work *work) · line 222
Quoted 8 lines
drivers/gpu/drm/msm/msm_gpu_devfreq.c +0
-1@@ -201,26 +217,14 @@ static void msm_devfreq_idle_work(struct kthread_work *work)struct msm_gpu_devfreq *df =container_of (work, struct msm_gpu_devfreq, idle_work.work); struct msm_gpu *gpu = container_of(df, struct msm_gpu, devfreq); -unsigned long idle_freq, target_freq =0 ;if (!df->devfreq)return ;
Why does the msm_devfreq_idle_work() need a check for "!df->devfreq" but the boost work doesn't? Maybe you don't need it anymore now that you're not reaching into the mutex? ...or maybe the boost work does need it?
...and if "df->devfreq" is NULL then doesn't it mean that msm_hrtimer_work_init() was never called? That seems bad...
-Doug
Re: [PATCH 2/2] drm/msm/gpu: Respect PM QoS constraints
Quoted 5 lines · Doug Anderson
Hi,
Quoted 1 line · Rob Clark
Quoted 13 lines
drivers/gpu/drm/msm/msm_gpu_devfreq.c void msm_devfreq_suspend(struct msm_gpu *gpu) · line 170
Quoted 8 lines
drivers/gpu/drm/msm/msm_gpu_devfreq.c +8
-0+void msm_devfreq_boost (struct msm_gpu *gpu,unsigned factor) +{ +struct msm_gpu_devfreq *df = &gpu->devfreq; +unsigned long freq; + + freq =get_freq (gpu); + freq *= factor; + freq /=HZ_PER_KHZ ;Should it do the divide first? I don't know for sure, but it feels like GPU frequency could conceivably be near-ish the u32 overflow? (~4 GHz). Better to be safe and do the / 1000 first?
It looks like on 8998 we have some GPU OPPs that are not integer # of KHz.. although that would not change the integer math result unless factor > 10.
We are a bit aways for 32b overflow (highest freq for current things is 825MHz, but I guess we could see things closer to 1GHz in the future.. generally GPUs aren't clocked nearly as high as CPUs.. slow but wide, and all that).. but maybe this should just be 64b math instead to be safe?
Quoted 15 lines
drivers/gpu/drm/msm/msm_gpu_devfreq.c static void msm_devfreq_idle_work(struct kthread_work *work) · line 222
Quoted 9 lines
drivers/gpu/drm/msm/msm_gpu_devfreq.c +0
-1@@ -201,26 +217,14 @@ static void msm_devfreq_idle_work(struct kthread_work *work)struct msm_gpu_devfreq *df =container_of (work, struct msm_gpu_devfreq, idle_work.work); struct msm_gpu *gpu = container_of(df, struct msm_gpu, devfreq); -unsigned long idle_freq, target_freq =0 ;if (!df->devfreq)return ;Why does the
msm_devfreq_idle_work()need a check for "!df->devfreq" but the boost work doesn't? Maybe you don't need it anymore now that you're not reaching into the mutex? ...or maybe the boost work does need it?
Quoted 2 lines
...and if "
df->devfreq" is NULL then doesn't it mean thatmsm_hrtimer_work_init()was never called? That seems bad...
Looks like 658f4c829688 ("drm/msm/devfreq: Add 1ms delay before clamping freq") was badly rebased on top of efb8a170a367 ("drm/msm:
Fix devfreq NULL pointer dereference on a3xx").. I'll send a separate patch to fix that
BR,
-R
Quoted 5 lines · Rob Clark
From: Rob Clark <[email protected]>
This was supposed to be a relative timer, not absolute.
Quoted 19 lines
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/msm/msm_gpu_devfreq.c +1
-2@@ -228,5 +228,5 @@ void msm_devfreq_idle(struct msm_gpu *gpu)struct msm_gpu_devfreq *df = &gpu->devfreq;msm_hrtimer_queue_work (&df->idle_work,ms_to_ktime (1 ), -HRTIMER_MODE_ABS ); +HRTIMER_MODE_REL ); } --2.33.1
Hi,
Quoted 9 lines · Rob Clark
From: Rob Clark <[email protected]>
This was supposed to be a relative timer, not absolute.
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)