Skip to contentSkip to conversation

firmware: ti_sci: Convert CPU latency constraint from us to ms

PATCH Applied Kendall Willis 2 participants 2 messages Apr 28, 2025 – May 6, 2025 Texas instruments' system control interface (TISCI) protocol driver

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 firmware: ti_sci: Convert CPU latency constraint from us to ms

Fix CPU resume latency constraint units sent to device manager through the TI SCI API. The device manager expects CPU resume latency to be in msecs which is passed in with the TI SCI API [1]. CPU latency constraints are set in userspace using the PM QoS framework which uses usecs as the unit. Since PM QoS uses usecs for units and the device manager expects msecs as the unit, TI SCI needs to convert from usecs to msecs before passing to device manager.

[1] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/lpm.html#tisci-msg-lpm-set-latency-constraint

Fixes a7a15754c7f7 ("firmware: ti_sci: add CPU latency constraint management")

---
Link to v1:
https://lore.kernel.org/all/[email protected]/

Changes from v1 to v2:
- reworded commit message to clearer about TI SCI CPU resume latency API
- added comment about converting to msecs and rounding down for the device manager
- changed commit to be inline with stable kernel rules
- rebased on linux-next

Test log [2] shows entry to MCU Only low power mode by sending a CPU resume latency constraint of 100000 us using PM QoS. On line 860, MCU Only is shown to be entered by 0x1 as the printed mode [3].

[2] https://gist.github.com/kwillis01/4cf6e19893927d232e7faa0676ea2425
[3] https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/pm/lpm.html#supported-low-power-modes

---
 drivers/firmware/ti_sci.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/firmware/ti_sci.c +11 -3
index 806a975fff22..ae5fd1936ad3 100644
@@ -2,7 +2,7 @@
 /*
  * Texas Instruments System Control Interface Protocol Driver
  *
- * Copyright (C) 2015-2024 Texas Instruments Incorporated - https://www.ti.com/
+ * Copyright (C) 2015-2025 Texas Instruments Incorporated - https://www.ti.com/
  *	Nishanth Menon
  */
 
@@ -3670,6 +3670,7 @@ static int __maybe_unused ti_sci_suspend(struct device *dev)
 	struct ti_sci_info *info = dev_get_drvdata(dev);
 	struct device *cpu_dev, *cpu_dev_max = NULL;
 	s32 val, cpu_lat = 0;
+	u16 cpu_lat_ms;
 	int i, ret;
 
 	if (info->fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED) {
@@ -3682,9 +3683,16 @@ static int __maybe_unused ti_sci_suspend(struct device *dev)
 			}
 		}
 		if (cpu_dev_max) {
-			dev_dbg(cpu_dev_max, "%s: sending max CPU latency=%u\n", __func__, cpu_lat);
+			/*
+			 * PM QoS latency unit is usecs, device manager uses msecs.
+			 * Convert to msecs and round down for device manager.
+			 */
+			cpu_lat_ms = cpu_lat / USEC_PER_MSEC;
+			dev_dbg(cpu_dev_max, "%s: sending max CPU latency=%u ms\n", __func__,
+				cpu_lat_ms);
 			ret = ti_sci_cmd_set_latency_constraint(&info->handle,
-								cpu_lat, TISCI_MSG_CONSTRAINT_SET);
+								cpu_lat_ms,
+								TISCI_MSG_CONSTRAINT_SET);
 			if (ret)
 				return ret;
 		}

base-commit: 33035b665157558254b3c21c3f049fd728e72368

Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw

Hi Kendall Willis,

Quoted 9 lines · Kendall Willis

Fix CPU resume latency constraint units sent to device manager through the TI SCI API. The device manager expects CPU resume latency to be in msecs which is passed in with the TI SCI API [1]. CPU latency constraints are set in userspace using the PM QoS framework which uses usecs as the unit. Since PM QoS uses usecs for units and the device manager expects msecs as the unit, TI SCI needs to convert from usecs to msecs before passing to device manager.

[...]

I have applied the following to branch ti-drivers-soc-next on [1]. Thank you!

[1/1] firmware: ti_sci: Convert CPU latency constraint from us to ms

      commit: 9b808f7f395ae375a26e32046b680cf898dacc21

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent up the chain during the next merge window (or sooner if it is a relevant bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/ti/linux.git

Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D