Skip to content

Commit 3b84bf3

Browse files
Ulf Hanssonrafaeljw
authored andcommitted
PM: domains: Measure suspend/resume latencies in genpd based on governor
The QoS latency measurements for devices in genpd_runtime_suspend|resume() are superfluous, unless the corresponding genpd has a governor assigned to it, which would make use of the data. Therefore, let's improve the behaviour in genpd by making the measurements conditional, based upon if there's a governor assigned. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 9c74f2a commit 3b84bf3

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

drivers/base/power/domain.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ static int genpd_runtime_suspend(struct device *dev)
881881
struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev);
882882
struct gpd_timing_data *td = gpd_data->td;
883883
bool runtime_pm = pm_runtime_enabled(dev);
884-
ktime_t time_start;
884+
ktime_t time_start = 0;
885885
s64 elapsed_ns;
886886
int ret;
887887

@@ -902,8 +902,7 @@ static int genpd_runtime_suspend(struct device *dev)
902902
return -EBUSY;
903903

904904
/* Measure suspend latency. */
905-
time_start = 0;
906-
if (runtime_pm)
905+
if (td && runtime_pm)
907906
time_start = ktime_get();
908907

909908
ret = __genpd_runtime_suspend(dev);
@@ -917,9 +916,9 @@ static int genpd_runtime_suspend(struct device *dev)
917916
}
918917

919918
/* Update suspend latency value if the measured time exceeds it. */
920-
if (runtime_pm) {
919+
if (td && runtime_pm) {
921920
elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
922-
if (td && (elapsed_ns > td->suspend_latency_ns)) {
921+
if (elapsed_ns > td->suspend_latency_ns) {
923922
td->suspend_latency_ns = elapsed_ns;
924923
dev_dbg(dev, "suspend latency exceeded, %lld ns\n",
925924
elapsed_ns);
@@ -956,11 +955,10 @@ static int genpd_runtime_resume(struct device *dev)
956955
struct generic_pm_domain *genpd;
957956
struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev);
958957
struct gpd_timing_data *td = gpd_data->td;
959-
bool runtime_pm = pm_runtime_enabled(dev);
960-
ktime_t time_start;
958+
bool timed = td && pm_runtime_enabled(dev);
959+
ktime_t time_start = 0;
961960
s64 elapsed_ns;
962961
int ret;
963-
bool timed = true;
964962

965963
dev_dbg(dev, "%s()\n", __func__);
966964

@@ -988,8 +986,7 @@ static int genpd_runtime_resume(struct device *dev)
988986

989987
out:
990988
/* Measure resume latency. */
991-
time_start = 0;
992-
if (timed && runtime_pm)
989+
if (timed)
993990
time_start = ktime_get();
994991

995992
ret = genpd_start_dev(genpd, dev);
@@ -1001,9 +998,9 @@ static int genpd_runtime_resume(struct device *dev)
1001998
goto err_stop;
1002999

10031000
/* Update resume latency value if the measured time exceeds it. */
1004-
if (timed && runtime_pm) {
1001+
if (timed) {
10051002
elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
1006-
if (td && (elapsed_ns > td->resume_latency_ns)) {
1003+
if (elapsed_ns > td->resume_latency_ns) {
10071004
td->resume_latency_ns = elapsed_ns;
10081005
dev_dbg(dev, "resume latency exceeded, %lld ns\n",
10091006
elapsed_ns);

0 commit comments

Comments
 (0)