linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@baylibre.com>
To: Dhruva Gole <d-gole@ti.com>,
	Markus Schneider-Pargmann <msp@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>, Tero Kristo <kristo@kernel.org>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	Vibhore Vardhan <vibhore@ti.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v9 4/4] firmware: ti_sci: add CPU latency constraint management
Date: Mon, 12 Aug 2024 13:51:14 -0700	[thread overview]
Message-ID: <7hfrr9pirh.fsf@baylibre.com> (raw)
In-Reply-To: <20240812101148.wpybfhqkd2kponp7@lcpd911>

Dhruva Gole <d-gole@ti.com> writes:

> Hello,
>
> On Aug 09, 2024 at 15:53:47 +0200, Markus Schneider-Pargmann wrote:
>> From: Kevin Hilman <khilman@baylibre.com>
>> 
>> 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>
>> Signed-off-by: Kevin Hilman <khilman@baylibre.com>
>> Reviewed-by: Dhruva Gole <d-gole@ti.com>
>> Signed-off-by: Dhruva Gole <d-gole@ti.com>
>> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
>> ---
>>  drivers/firmware/ti_sci.c | 22 +++++++++++++++++++++-
>>  1 file changed, 21 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
>> index 5cbeca5df313..481b7649fde1 100644
>> --- a/drivers/firmware/ti_sci.c
>> +++ b/drivers/firmware/ti_sci.c
>> @@ -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>
>> @@ -3639,7 +3641,25 @@ static int ti_sci_prepare_system_suspend(struct ti_sci_info *info)
>>  static int ti_sci_suspend(struct device *dev)
>>  {
>>  	struct ti_sci_info *info = dev_get_drvdata(dev);
>> -	int ret;
>> +	struct device *cpu_dev;
>> +	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);
>> +		}
>> +		if (cpu_lat && cpu_lat != PM_QOS_RESUME_LATENCY_NO_CONSTRAINT) {
>> +			dev_dbg(cpu_dev, "%s: sending max CPU latency=%u\n", __func__, cpu_lat);
>
> An interesting observation was made which caused us to suspect this
> code, the CPU on which the latency was actually being set was not being
> printed here. It was always the cpu3
>
> cpu cpu3: ti_sci_suspend: sending max CPU latency=100
>
> If you look at how this print comes, it's always after all the cpu
> indices have run, so by then the cpu_dev value will have always become
> = nproc in the system. This makes debugging it confusing.

Good catch.  That's definitely a debug bug.  :)

Will fix in the next version.

Thanks for the review & testing,

Kevin



  reply	other threads:[~2024-08-12 21:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09 13:53 [PATCH v9 0/4] firmware: ti_sci: Introduce system suspend support Markus Schneider-Pargmann
2024-08-09 13:53 ` [PATCH v9 1/4] firmware: ti_sci: Add support for querying the firmware caps Markus Schneider-Pargmann
2024-08-09 13:53 ` [PATCH v9 2/4] firmware: ti_sci: Add system suspend and resume call Markus Schneider-Pargmann
2024-08-09 13:53 ` [PATCH v9 3/4] firmware: ti_sci: Introduce Power Management Ops Markus Schneider-Pargmann
2024-08-12  5:47   ` Dhruva Gole
2024-08-12 21:16     ` Kevin Hilman
2024-08-13  3:49       ` Dhruva Gole
2024-08-13 11:21         ` a0230503
2024-08-13 22:19           ` Kevin Hilman
2024-08-09 13:53 ` [PATCH v9 4/4] firmware: ti_sci: add CPU latency constraint management Markus Schneider-Pargmann
2024-08-12 10:11   ` Dhruva Gole
2024-08-12 20:51     ` Kevin Hilman [this message]
2024-08-12  5:43 ` [PATCH v9 0/4] firmware: ti_sci: Introduce system suspend support Dhruva Gole

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=7hfrr9pirh.fsf@baylibre.com \
    --to=khilman@baylibre.com \
    --cc=d-gole@ti.com \
    --cc=kristo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=msp@baylibre.com \
    --cc=nm@ti.com \
    --cc=ssantosh@kernel.org \
    --cc=vibhore@ti.com \
    /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;
as well as URLs for NNTP newsgroup(s).