Commit a7a15754 authored by Kevin Hilman's avatar Kevin Hilman Committed by Nishanth Menon
Browse files

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: default avatarVibhore Vardhan <vibhore@ti.com>
Signed-off-by: default avatarVibhore Vardhan <vibhore@ti.com>
Reviewed-by: default avatarDhruva Gole <d-gole@ti.com>
Signed-off-by: default avatarDhruva Gole <d-gole@ti.com>
Signed-off-by: default avatarKevin Hilman <khilman@baylibre.com>
Tested-by: default avatarDhruva Gole <d-gole@ti.com>
Signed-off-by: default avatarMarkus Schneider-Pargmann <msp@baylibre.com>
Tested-by: default avatarKevin Hilman <khilman@baylibre.com>
Tested-by: default avatarRoger Quadros <rogerq@kernel.org>
Link: https://lore.kernel.org/r/20241007-tisci-syssuspendresume-v13-5-ed54cd659a49@baylibre.com


Signed-off-by: default avatarNishanth Menon <nm@ti.com>
parent 60357991
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#define pr_fmt(fmt) "%s: " fmt, __func__

#include <linux/bitmap.h>
#include <linux/cpu.h>
#include <linux/debugfs.h>
#include <linux/export.h>
#include <linux/io.h>
@@ -19,6 +20,7 @@
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_qos.h>
#include <linux/property.h>
#include <linux/semaphore.h>
#include <linux/slab.h>
@@ -3666,7 +3668,27 @@ static int ti_sci_prepare_system_suspend(struct ti_sci_info *info)
static int __maybe_unused ti_sci_suspend(struct device *dev)
{
	struct ti_sci_info *info = dev_get_drvdata(dev);
	int ret;
	struct device *cpu_dev, *cpu_dev_max = NULL;
	s32 val, cpu_lat = 0;
	int i, ret;

	if (info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED) {
		for_each_possible_cpu(i) {
			cpu_dev = get_cpu_device(i);
			val = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_RESUME_LATENCY);
			if (val != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) {
				cpu_lat = max(cpu_lat, val);
				cpu_dev_max = cpu_dev;
			}
		}
		if (cpu_dev_max) {
			dev_dbg(cpu_dev_max, "%s: sending max CPU latency=%u\n", __func__, cpu_lat);
			ret = ti_sci_cmd_set_latency_constraint(&info->handle,
								cpu_lat, TISCI_MSG_CONSTRAINT_SET);
			if (ret)
				return ret;
		}
	}

	ret = ti_sci_prepare_system_suspend(info);
	if (ret)