]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
firmware: ti_sci: Convert CPU latency constraint from us to ms
authorKendall Willis <k-willis@ti.com>
Mon, 28 Apr 2025 20:53:36 +0000 (15:53 -0500)
committerNishanth Menon <nm@ti.com>
Tue, 6 May 2025 12:25:51 +0000 (07:25 -0500)
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

Cc: stable@vger.kernel.org
Fixes: a7a15754c7f7 ("firmware: ti_sci: add CPU latency constraint management")
Signed-off-by: Kendall Willis <k-willis@ti.com>
Link: https://lore.kernel.org/r/20250428205336.2947118-1-k-willis@ti.com
Signed-off-by: Nishanth Menon <nm@ti.com>
drivers/firmware/ti_sci.c

index 806a975fff22ae00ecb88587b2c47ba172120bc2..ae5fd1936ad322e5e3a94897cc042f6548f919e6 100644 (file)
@@ -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;
                }