public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Dhruva Gole <d-gole@ti.com>
To: Kevin Hilman <khilman@kernel.org>
Cc: Andrew Davis <afd@ti.com>, Nishanth Menon <nm@ti.com>,
	Tero Kristo <kristo@kernel.org>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	"Praneeth Bajjuri" <praneeth@ti.com>,
	Tony Lindgren <tony@atomide.com>, Dave Gerlach <d-gerlach@ti.com>,
	Vibhore Vardhan <vibhore@ti.com>, Georgi Vlaev <g-vlaev@ti.com>
Subject: Re: [PATCH V6 4/4] firmware: ti_sci: Introduce system suspend resume support
Date: Tue, 8 Aug 2023 17:24:03 +0530	[thread overview]
Message-ID: <20230808115403.dkz6ev5vc6bhcmzh@dhruva> (raw)
In-Reply-To: <7ho7jifrda.fsf@baylibre.com>

Kevin,

Thanks for the suggestion. I have a rough proposal inline, please can
you take a look? I will test those changes and respin this series
accordingly

On Aug 07, 2023 at 14:57:05 -0700, Kevin Hilman wrote:
> Dhruva Gole <d-gole@ti.com> writes:
> 
> > On Aug 03, 2023 at 11:00:11 -0500, Andrew Davis wrote:
> >> On 8/3/23 10:55 AM, Dhruva Gole wrote:
> >> > On Aug 03, 2023 at 10:26:32 -0500, Andrew Davis wrote:
> >> > > On 8/3/23 1:42 AM, Dhruva Gole wrote:
> >> > > > Introduce system suspend resume calls that will allow the ti_sci
> >> > > > driver to support deep sleep low power mode when the user space issues a
> >> > > > suspend to mem.
> >> > > > 
> >> > > > Also, write a ti_sci_prepare_system_suspend call to be used in the driver
> >> > > > suspend handler to allow the system to identify the low power mode being
> >> > > > entered and if necessary, send TISCI_MSG_PREPARE_SLEEP with information
> >> > > > about the mode is being entered and the address for allocated memory for
> >> > > > storing the context during Deep Sleep.
> >> > > > 
> >> > > > We're using "pm_suspend_target_state" to map the kernel's target suspend
> >> > > > state to SysFW low power mode. Make sure this is available only when
> >> > > > CONFIG_SUSPEND is enabled.
> >> > > > 
> >> > > > Co-developed-by: Dave Gerlach <d-gerlach@ti.com>
> >> > > > Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> >> > > > Signed-off-by: Vibhore Vardhan <vibhore@ti.com>
> >> > > > Signed-off-by: Georgi Vlaev <g-vlaev@ti.com>
> >> > > > Signed-off-by: Dhruva Gole <d-gole@ti.com>
> >> > > > ---
> >> > > >    drivers/firmware/ti_sci.c | 63 +++++++++++++++++++++++++++++++++++++++
> >> > > >    1 file changed, 63 insertions(+)
> >> > > > 
> >> > [..snip..]
> >> > > > +static int ti_sci_suspend(struct device *dev)
> >> > > > +{
> >> > > > +	struct ti_sci_info *info = dev_get_drvdata(dev);
> >> > > > +	int ret;
> >> > > > +
> >> > > > +	ret = ti_sci_cmd_set_io_isolation(&info->handle, TISCI_MSG_VALUE_IO_ENABLE);
> >> > > 
> >> > > After this the will the IOs be in isolation? Or does the firmware wait
> >> > > until power down begins later?
> >> > 
> >> >  From what I understand,
> >> > IOs will be in isolation immediately
> >> > 
> >> 
> >> That is what I understand too, so then any device that may need to do some
> >> external communication for its suspend will not function, this must be the
> >> last driver _suspend() the system calls, how do you enforce that?
> >
> > I will make use of .suspend_noirq callbacks in that case. Does that
> > sound better, or is there anything else I may not be aware of?
> 
> Using _noirq just moves the problem.  What if other drivers are also
> using _noirq callbacks and run after the SCI driver?  You still cannot

True, this thought occurred to me as well which is why I was thinking
that moving it to ATF might be a better choice.

> guarantee ordering.
> 
> It seems to me that the IO isolation stuff is a system-wide operation,
> and should probably be handled at the platform suspend_ops level
> (e.g. suspend_ops->prepare_late()).   This would ensure that it runs

I must have missed this approach! Are you suggesting something like what
was done for am335?

static const struct platform_suspend_ops am33xx_pm_ops

have a similar code for tisci..?

static const struct platform_suspend_ops tisci_pm_ops = {
	.prepare_late = tisci_set_io_isolation
	};

And then while resuming we may want the pinctrl driver to scan for the
wk_evt bit[0] before the isolation is disabled, so we want the
tisci_resume/ remove isolation to be called later than that.

So I a wondering if the code below makes sense?

static const struct platform_suspend_ops tisci_pm_ops = {
	.prepare_late = tisci_suspend // also includes set isolation
	.end = tisci_resume 	// Disables isolation
	};

However a minor drawback here maybe that the serial logs on the resume
path may not appear when using a serial console for example. However
they should be able to easily access using dmesg.

> *after* all the driver hooks (even driver _noirq hooks.) and right
> before the full suspend (or s2idle.)
> 
> Now, all that being said, I noticed that in v7, you didn't move this to
> _noirq, but instead suggested that this be handled by TF-A.  I suppose
> that's an option also, but my suggestion above should work also.

Thanks for the pointer! I do believe it will make more sense to do it
from linux itself unless we have no way to do it in linux.

> 
> Kevin


[0] Table 5-517. Description Of The Pad Configuration Register Bits
https://www.ti.com/lit/pdf/spruid7

NOTE: The hardware works in such a way that as soon as the IO isolation
is disabled the wake_evt information is lost so the pinctrl-single
driver won't be able to know what pin woke it up if we disable io
isolation before it has the chance to look at the padconf registers

-- 
Best regards,
Dhruva Gole <d-gole@ti.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-08-08 11:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03  6:42 [PATCH V6 0/4] firmware: ti_sci: Introduce system suspend support Dhruva Gole
2023-08-03  6:42 ` [PATCH V6 1/4] firmware: ti_sci: Introduce Power Management Ops Dhruva Gole
2023-08-03 15:14   ` Andrew Davis
2023-08-03 15:42     ` Dhruva Gole
2023-08-03 15:57       ` Andrew Davis
2023-08-03  6:42 ` [PATCH V6 2/4] firmware: ti_sci: Add support for querying the firmware caps Dhruva Gole
2023-08-03 15:21   ` Andrew Davis
2023-08-03  6:42 ` [PATCH V6 3/4] firmware: ti_sci: Allocate memory for Low Power Modes Dhruva Gole
2023-08-03 15:23   ` Andrew Davis
2023-08-03 15:57     ` Dhruva Gole
2023-08-03  6:42 ` [PATCH V6 4/4] firmware: ti_sci: Introduce system suspend resume support Dhruva Gole
2023-08-03 15:26   ` Andrew Davis
2023-08-03 15:55     ` Dhruva Gole
2023-08-03 16:00       ` Andrew Davis
2023-08-03 16:08         ` Dhruva Gole
2023-08-07 21:57           ` Kevin Hilman
2023-08-08 11:54             ` Dhruva Gole [this message]
2023-08-09  0:20               ` Kevin Hilman
2023-08-09  7:23                 ` Tony Lindgren
2023-08-09 17:37                   ` Kevin Hilman
2023-08-03 15:18 ` [PATCH V6 0/4] firmware: ti_sci: Introduce system suspend support Andrew Davis

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=20230808115403.dkz6ev5vc6bhcmzh@dhruva \
    --to=d-gole@ti.com \
    --cc=afd@ti.com \
    --cc=d-gerlach@ti.com \
    --cc=g-vlaev@ti.com \
    --cc=khilman@kernel.org \
    --cc=kristo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=praneeth@ti.com \
    --cc=ssantosh@kernel.org \
    --cc=tony@atomide.com \
    --cc=vibhore@ti.com \
    --cc=viresh.kumar@linaro.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