Skip to contentSkip to conversation

drm/lima: add governor data with pre-defined thresholds

PATCH Superseded Christian Hewitt 2 participants 5 messages Jan 25, 2021 – Jan 28, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/lima: add governor data with pre-defined thresholds

This patch adapts the panfrost pre-defined thresholds change [0] to the lima driver to improve real-world performance. The upthreshold value has been set to ramp GPU frequency to max freq faster (compared to panfrost) to compensate for the lower overall performance of utgard devices.

[0] https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/

---
I have been using Kodi as my test application. If you scroll in library views with hundreds of list items and the panfrost values the slow GPU ramp up is quite noticeable and the GUI feels sluggish. As everything lima runs on is inherently slower than panfrost using devices I believe it's better to ramp up to max freq quicker.

 drivers/gpu/drm/lima/lima_devfreq.c | 10 +++++++++-
 drivers/gpu/drm/lima/lima_devfreq.h |  2 ++
 2 files changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/lima/lima_devfreq.c +9 -1
index 5686ad4aaf7c..c9854315a0b5 100644
@@ -163,8 +163,16 @@ int lima_devfreq_init(struct lima_device *ldev)
 	lima_devfreq_profile.initial_freq = cur_freq;
 	dev_pm_opp_put(opp);
 
+	/*
+	 * Setup default thresholds for the simple_ondemand governor.
+	 * The values are chosen based on experiments.
+	 */
+	ldevfreq->gov_data.upthreshold = 20;
+	ldevfreq->gov_data.downdifferential = 5;
+
 	devfreq = devm_devfreq_add_device(dev, &lima_devfreq_profile,
-					  DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
+					  DEVFREQ_GOV_SIMPLE_ONDEMAND,
+					  &ldevfreq->gov_data);
 	if (IS_ERR(devfreq)) {
 		dev_err(dev, "Couldn't initialize GPU devfreq\n");
 		ret = PTR_ERR(devfreq);
drivers/gpu/drm/lima/lima_devfreq.h +2 -0
index 2d9b3008ce77..b0c7c736e81a 100644
@@ -4,6 +4,7 @@
 #ifndef __LIMA_DEVFREQ_H__
 #define __LIMA_DEVFREQ_H__
 
+#include <linux/devfreq.h>
 #include <linux/spinlock.h>
 #include <linux/ktime.h>
 
@@ -18,6 +19,7 @@ struct lima_devfreq {
 	struct opp_table *clkname_opp_table;
 	struct opp_table *regulators_opp_table;
 	struct thermal_cooling_device *cooling;
+	struct devfreq_simple_ondemand_data gov_data;
 
 	ktime_t busy_time;
 	ktime_t idle_time;
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Hi Christian,

Quoted 7 lines · Christian Hewitt

This patch adapts the panfrost pre-defined thresholds change [0] to the lima driver to improve real-world performance. The upthreshold value has been set to ramp GPU frequency to max freq faster (compared to panfrost) to compensate for the lower overall performance of utgard devices.

[0] https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/

Quoted 7 lines

---
I have been using Kodi as my test application. If you scroll in library views with hundreds of list items and the panfrost values the slow GPU ramp up is quite noticeable and the GUI feels sluggish. As everything lima runs on is inherently slower than panfrost using devices I believe it's better to ramp up to max freq quicker.

It's quite low value for the upthreshold, but I believe you have experimented and observed that a bit higher (30, 40?) don't work well. I don't know the Kodi system, though.

You can check if the other frequencies are also used in statistics for devfreq device:
cat /sys/class/devfreq/<your_gpu>/trans_stats

If they are also used, then it OK (better than stuck at min freq).

Regards,
Lukasz

#2 lore raw
Quoted 23 lines · Lukasz Luba

Hi Christian,

Quoted 8 lines · Christian Hewitt

This patch adapts the panfrost pre-defined thresholds change [0] to the lima driver to improve real-world performance. The upthreshold value has been set to ramp GPU frequency to max freq faster (compared to panfrost) to compensate for the lower overall performance of utgard devices.

[0] https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/

Quoted 7 lines

---
I have been using Kodi as my test application. If you scroll in library views with hundreds of list items and the panfrost values the slow GPU ramp up is quite noticeable and the GUI feels sluggish. As everything lima runs on is inherently slower than panfrost using devices I believe it's better to ramp up to max freq quicker.

It's quite low value for the upthreshold, but I believe you have experimented and observed that a bit higher (30, 40?) don't work well. I don't know the Kodi system, though.

Quoted 5 lines

You can check if the other frequencies are also used in statistics for devfreq device:
cat /sys/class/devfreq/<your_gpu>/trans_stats

If they are also used, then it OK (better than stuck at min freq).

I've just realized that your board might suffer a another issue. Please apply this patch [1] and run your experiments with upthresholds.

[1] https://lore.kernel.org/lkml/[email protected]/

#3 lore raw
Quoted 28 lines · Lukasz Luba
Quoted 16 lines · Lukasz Luba

Hi Christian,

Quoted 7 lines · Christian Hewitt

This patch adapts the panfrost pre-defined thresholds change [0] to the lima driver to improve real-world performance. The upthreshold value has been set to ramp GPU frequency to max freq faster (compared to panfrost) to compensate for the lower overall performance of utgard devices.

[0] https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/

Quoted 7 lines

---
I have been using Kodi as my test application. If you scroll in library views with hundreds of list items and the panfrost values the slow GPU ramp up is quite noticeable and the GUI feels sluggish. As everything lima runs on is inherently slower than panfrost using devices I believe it's better to ramp up to max freq quicker.

Quoted 7 lines

It's quite low value for the upthreshold, but I believe you have experimented and observed that a bit higher (30, 40?) don't work well. I don't know the Kodi system, though.
You can check if the other frequencies are also used in statistics for devfreq device:
cat /sys/class/devfreq/<your_gpu>/trans_stats
If they are also used, then it OK (better than stuck at min freq).

Quoted 4 lines

I've just realized that your board might suffer a another issue. Please apply this patch [1] and run your experiments with upthresholds.

[1] https://lore.kernel.org/lkml/[email protected]/

I’ve included the patch and with unscientific testing it feels snappier with a larger value than before. I did revert back to 45 first, but again this feels sluggish when navigating around the Kodi GUI. My main test is to enter ‘Movies’ in Kodi then start scrolling in a long list. When the GPU ramps up quickly the experience is snappy, but when it ramps more conservatively scrolling feels like it stutters, then (once you hit max freq) it becomes fluid.

WP2:~ # cat /sys/class/devfreq/d00c0000.gpu/trans_stat
From : To
: 125000000 250000000 285714285 400000000 500000000 666666666 744000000 time(ms)

* 125000000:         0         0         0         0         0         0       264     52720
  250000000:         9         0         0         0         0         0        36      3404
  285714285:         9         3         0         0         0         0        32      2628
  400000000:        18        20        13         0         0         0       191     21140
  500000000:        12        12         8        63         0         0        31     10068
  666666666:       179         5        16       133        66         0        24     29360

744000000: 37 5 7 46 60 423 0 46016

I’ll send v2 with the value set to 30.

Christian
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
Quoted 43 lines · Christian Hewitt
Quoted 28 lines · Lukasz Luba
Quoted 16 lines · Lukasz Luba

Hi Christian,

Quoted 7 lines · Christian Hewitt

This patch adapts the panfrost pre-defined thresholds change [0] to the lima driver to improve real-world performance. The upthreshold value has been set to ramp GPU frequency to max freq faster (compared to panfrost) to compensate for the lower overall performance of utgard devices.

[0] https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/

Quoted 7 lines

---
I have been using Kodi as my test application. If you scroll in library views with hundreds of list items and the panfrost values the slow GPU ramp up is quite noticeable and the GUI feels sluggish. As everything lima runs on is inherently slower than panfrost using devices I believe it's better to ramp up to max freq quicker.

Quoted 7 lines

It's quite low value for the upthreshold, but I believe you have experimented and observed that a bit higher (30, 40?) don't work well. I don't know the Kodi system, though.
You can check if the other frequencies are also used in statistics for devfreq device:
cat /sys/class/devfreq/<your_gpu>/trans_stats
If they are also used, then it OK (better than stuck at min freq).

Quoted 4 lines

I've just realized that your board might suffer a another issue. Please apply this patch [1] and run your experiments with upthresholds.

[1] https://lore.kernel.org/lkml/[email protected]/

I’ve included the patch and with unscientific testing it feels snappier with a larger value than before. I did revert back to 45 first, but again this feels sluggish when navigating around the Kodi GUI. My main test is to enter ‘Movies’ in Kodi then start scrolling in a long list. When the GPU ramps up quickly the experience is snappy, but when it ramps more conservatively scrolling feels like it stutters, then (once you hit max freq) it becomes fluid.

WP2:~ # cat /sys/class/devfreq/d00c0000.gpu/trans_stat
From : To
: 125000000 250000000 285714285 400000000 500000000 666666666 744000000 time(ms)
* 125000000: 0 0 0 0 0 0 264 52720

Quoted 8 lines
   250000000:         9         0         0         0         0         0        36      3404
   285714285:         9         3         0         0         0         0        32      2628
   400000000:        18        20        13         0         0         0       191     21140
   500000000:        12        12         8        63         0         0        31     10068
   666666666:       179         5        16       133        66         0        24     29360

744000000: 37 5 7 46 60 423 0 46016

I’ll send v2 with the value set to 30.

Thank you Christian for re-testing it and attaching the stats. It looks good. I'll add my reviewed-by for v2 patch.

Regards,
Lukasz