Skip to content

Commit 64111a0

Browse files
larunbeSteven Price
authored andcommitted
drm/panfrost: Fix incorrect updating of current device frequency
It was noticed when setting the Panfrost's DVFS device to the performant governor, GPU frequency as reported by fdinfo had dropped to 0 permamently. There are two separate issues causing this behaviour: - Not initialising the device's current_frequency variable to its original value during device probe(). - Updating said variable in Panfrost devfreq's get_dev_status() rather than after the new OPP's frequency had been retrieved in target(), which meant the old frequency would be assigned instead. Signed-off-by: Adrián Larumbe <[email protected]> Fixes: f11b041 ("drm/panfrost: Add fdinfo support GPU load metrics") Reviewed-by: Steven Price <[email protected]> Signed-off-by: Steven Price <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 7701ce2 commit 64111a0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

drivers/gpu/drm/panfrost/panfrost_devfreq.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,20 @@ static void panfrost_devfreq_update_utilization(struct panfrost_devfreq *pfdevfr
2929
static int panfrost_devfreq_target(struct device *dev, unsigned long *freq,
3030
u32 flags)
3131
{
32+
struct panfrost_device *ptdev = dev_get_drvdata(dev);
3233
struct dev_pm_opp *opp;
34+
int err;
3335

3436
opp = devfreq_recommended_opp(dev, freq, flags);
3537
if (IS_ERR(opp))
3638
return PTR_ERR(opp);
3739
dev_pm_opp_put(opp);
3840

39-
return dev_pm_opp_set_rate(dev, *freq);
41+
err = dev_pm_opp_set_rate(dev, *freq);
42+
if (!err)
43+
ptdev->pfdevfreq.current_frequency = *freq;
44+
45+
return err;
4046
}
4147

4248
static void panfrost_devfreq_reset(struct panfrost_devfreq *pfdevfreq)
@@ -58,7 +64,6 @@ static int panfrost_devfreq_get_dev_status(struct device *dev,
5864
spin_lock_irqsave(&pfdevfreq->lock, irqflags);
5965

6066
panfrost_devfreq_update_utilization(pfdevfreq);
61-
pfdevfreq->current_frequency = status->current_frequency;
6267

6368
status->total_time = ktime_to_ns(ktime_add(pfdevfreq->busy_time,
6469
pfdevfreq->idle_time));
@@ -164,6 +169,14 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
164169

165170
panfrost_devfreq_profile.initial_freq = cur_freq;
166171

172+
/*
173+
* We could wait until panfrost_devfreq_target() to set this value, but
174+
* since the simple_ondemand governor works asynchronously, there's a
175+
* chance by the time someone opens the device's fdinfo file, current
176+
* frequency hasn't been updated yet, so let's just do an early set.
177+
*/
178+
pfdevfreq->current_frequency = cur_freq;
179+
167180
/*
168181
* Set the recommend OPP this will enable and configure the regulator
169182
* if any and will avoid a switch off by regulator_late_cleanup()

0 commit comments

Comments
 (0)