Skip to content

Commit a7a1575

Browse files
khilmannmenon
authored andcommitted
firmware: ti_sci: add CPU latency constraint management
During system-wide suspend, check if any of the CPUs have PM QoS resume latency constraints set. If so, set TI SCI constraint. TI SCI has a single system-wide latency constraint, so use the max of any of the CPU latencies as the system-wide value. Note: DM firmware clears all constraints at resume time, so constraints need to be checked/updated/sent at each system suspend. Co-developed-by: Vibhore Vardhan <vibhore@ti.com> Signed-off-by: Vibhore Vardhan <vibhore@ti.com> Reviewed-by: Dhruva Gole <d-gole@ti.com> Signed-off-by: Dhruva Gole <d-gole@ti.com> Signed-off-by: Kevin Hilman <khilman@baylibre.com> Tested-by: Dhruva Gole <d-gole@ti.com> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> Tested-by: Kevin Hilman <khilman@baylibre.com> Tested-by: Roger Quadros <rogerq@kernel.org> Link: https://lore.kernel.org/r/20241007-tisci-syssuspendresume-v13-5-ed54cd659a49@baylibre.com Signed-off-by: Nishanth Menon <nm@ti.com>
1 parent 6035799 commit a7a1575

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

drivers/firmware/ti_sci.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define pr_fmt(fmt) "%s: " fmt, __func__
1010

1111
#include <linux/bitmap.h>
12+
#include <linux/cpu.h>
1213
#include <linux/debugfs.h>
1314
#include <linux/export.h>
1415
#include <linux/io.h>
@@ -19,6 +20,7 @@
1920
#include <linux/of.h>
2021
#include <linux/of_platform.h>
2122
#include <linux/platform_device.h>
23+
#include <linux/pm_qos.h>
2224
#include <linux/property.h>
2325
#include <linux/semaphore.h>
2426
#include <linux/slab.h>
@@ -3666,7 +3668,27 @@ static int ti_sci_prepare_system_suspend(struct ti_sci_info *info)
36663668
static int __maybe_unused ti_sci_suspend(struct device *dev)
36673669
{
36683670
struct ti_sci_info *info = dev_get_drvdata(dev);
3669-
int ret;
3671+
struct device *cpu_dev, *cpu_dev_max = NULL;
3672+
s32 val, cpu_lat = 0;
3673+
int i, ret;
3674+
3675+
if (info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED) {
3676+
for_each_possible_cpu(i) {
3677+
cpu_dev = get_cpu_device(i);
3678+
val = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_RESUME_LATENCY);
3679+
if (val != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) {
3680+
cpu_lat = max(cpu_lat, val);
3681+
cpu_dev_max = cpu_dev;
3682+
}
3683+
}
3684+
if (cpu_dev_max) {
3685+
dev_dbg(cpu_dev_max, "%s: sending max CPU latency=%u\n", __func__, cpu_lat);
3686+
ret = ti_sci_cmd_set_latency_constraint(&info->handle,
3687+
cpu_lat, TISCI_MSG_CONSTRAINT_SET);
3688+
if (ret)
3689+
return ret;
3690+
}
3691+
}
36703692

36713693
ret = ti_sci_prepare_system_suspend(info);
36723694
if (ret)

0 commit comments

Comments
 (0)