public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Kendall Willis <k-willis@ti.com>
To: <nm@ti.com>, <kristo@kernel.org>, <ssantosh@kernel.org>, <d-gole@ti.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <k-willis@ti.com>
Subject: [PATCH] firmware: ti_sci: Convert CPU latency constraint from us to ms
Date: Fri, 25 Apr 2025 10:37:54 -0500	[thread overview]
Message-ID: <20250425153754.2141984-1-k-willis@ti.com> (raw)

Fix CPU resume latency constraint units sent to TI SCI firmware.
CPU latency constraints are set using the PM QoS framework. The PM QoS
framework uses usecs as the units for latency whereas the device manager
uses msecs, so a conversion is needed before passing to device manager.

Signed-off-by: Kendall Willis <k-willis@ti.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
---
Test log [1] shows entry to MCU Only low power mode by sending a CPU
resume latency constraint of 100000 us using PM QoS. MCU Only is shown
to be entered by 0x1 as the printed mode.

[1] https://gist.github.com/kwillis01/059a2ca38232387b414bc6f4b87c7475
---
 drivers/firmware/ti_sci.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 806a975fff22..bc138a837430 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -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,13 @@ 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, TI SCI uses msecs */
+			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: 393d0c54cae31317deaa9043320c5fd9454deabc
-- 
2.34.1



             reply	other threads:[~2025-04-25 17:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-25 15:37 Kendall Willis [this message]
2025-04-25 19:08 ` [PATCH] firmware: ti_sci: Convert CPU latency constraint from us to ms Nishanth Menon
2025-04-28 19:15   ` Kendall Willis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250425153754.2141984-1-k-willis@ti.com \
    --to=k-willis@ti.com \
    --cc=d-gole@ti.com \
    --cc=kristo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=ssantosh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox