Skip to contentSkip to conversation

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

PATCH Applied Christian Hewitt 3 participants 6 messages Jan 27, 2021 – Feb 7, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 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]/

---
Change since v1: increased upthreshold from 20 to 30, with a soft dependency on Lukasz delayed timer patch [0]

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

 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 = 30;
+	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
Reviewed-by on v2 1/1
#1 lore raw
Quoted 54 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]/

---
Change since v1: increased upthreshold from 20 to 30, with a soft dependency on Lukasz delayed timer patch [0]

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

  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 = 30;
+	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 +1 -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>
 

drivers/gpu/drm/lima/lima_devfreq.h struct lima_devfreq { · line 25

Quoted 7 lines
drivers/gpu/drm/lima/lima_devfreq.h +1 -0
@@ -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;

It looks good.

Regards,
Lukasz

maintainer
#2 lore raw
In reply to Christian Hewitt

This patch gets minor improvement on glmark2 (160->162).

Seems there's no way for user to change this value, do we? Or there's work pending to expose it to sysfs?

Regards,
Qiang

Quoted 62 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]/

---
Change since v1: increased upthreshold from 20 to 30, with a soft dependency on Lukasz delayed timer patch [0]

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

 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 = 30;
+       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 -1
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;
--
Quoted 2 lines

2.17.1

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

#3 lore raw
Quoted 1 line · Qiang Yu

This patch gets minor improvement on glmark2 (160->162).

It has bigger impact when the load is changing and the frequency is stuck to min w/o this patch.

Quoted 3 lines

Seems there's no way for user to change this value, do we? Or there's work pending to expose it to sysfs?

True there is no user sysfs. I've proposed a patch to export these via sysfs. Chanwoo is going to work on it. When it will land mainline, it's probably a few months. So for now, the fix makes sense.

Regards,
Lukasz

maintainer Reviewed-by
#4 lore raw

OK, I see. Patch is also:

Regards,
Qiang

Quoted 13 lines · Lukasz Luba
Quoted 1 line · Qiang Yu

This patch gets minor improvement on glmark2 (160->162).

It has bigger impact when the load is changing and the frequency is stuck to min w/o this patch.

Quoted 3 lines

Seems there's no way for user to change this value, do we? Or there's work pending to expose it to sysfs?

Quoted 7 lines

True there is no user sysfs. I've proposed a patch to export these via sysfs. Chanwoo is going to work on it. When it will land mainline, it's probably a few months. So for now, the fix makes sense.

Regards,
Lukasz

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

maintainer Applied
#5 lore raw

Applied to drm-misc-next.

Regards,
Qiang

Quoted 28 lines · Qiang Yu

OK, I see. Patch is also:

Regards,
Qiang

Quoted 20 lines · Lukasz Luba
Quoted 1 line · Qiang Yu

This patch gets minor improvement on glmark2 (160->162).

It has bigger impact when the load is changing and the frequency is stuck to min w/o this patch.

Quoted 3 lines

Seems there's no way for user to change this value, do we? Or there's work pending to expose it to sysfs?

True there is no user sysfs. I've proposed a patch to export these via sysfs. Chanwoo is going to work on it. When it will land mainline, it's probably a few months. So for now, the fix makes sense.

Regards,
Lukasz

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