mbox series

[v2,0/3] add support for power off check in suspend

Message ID 1546944944-13911-1-git-send-email-claudiu.beznea@microchip.com (mailing list archive)
Headers show
Series add support for power off check in suspend | expand

Message

Claudiu Beznea Jan. 8, 2019, 10:56 a.m. UTC
From: Claudiu Beznea <claudiu.beznea@microchip.com>

Hi,

AT91 platforms support a power saving mode where SoC's power is cut off (we call
it backup mode). The resume is done with the help of bootloaders. To be able to
suspend/resume Linux to/from this mode all the drivers suspend/resume callbacks
should save/restore the content of all the active registers. We have 2 problems
we are trying to solve:
- some of these drivers are shared with other non Microchip SoCs (e.g. macb
  driver) and we don't want to disturbe other users of corresponding IPs with
  all the register save/restore operations;
- the suspend/resume time for the rest of the power saving mode we are using
  could be improved if we would know in drivers the suspend mode the platform
  is switched to.

A solution that would have been solve our problems was proposed in [1] but in
the end it wasn't accepted. It ended up with the introduction of
pm_suspend_target_state variable that could be used along with the changes in
this series.

While the discussion of [1] progressed it has been proposed (in [2]) to
implement a function that would tell if the platform's power would be cut off
at the end of the suspend procedure.

The patches in this series does as follows:
1/3 - add a new member to platform_suspend_ops that will tell if platform's
      power will be cut off at the end of the suspend procedure; drivers could
      use it via platform_off_in_suspend()
2/3 - add a new function to regulator's core that could be used to check if a
      proper regulator has been configured (via DT) to be powered off in
      suspend. This is used on this series to check the CPU's regulator is
      properly configured in DT to be turned off in suspend.
3/3 - fill .off_in_suspend member of at91_pm_ops; the functionality in patch 2/3
      is used to double check CPU's regulator would be turned off in suspend.

Thank you,
Claudiu Beznea

[1] https://lkml.org/lkml/2017/6/22/938
[2] https://lkml.org/lkml/2017/7/16/457

Changes in v2:
- remove !! instruction in regulator_is_disabled_in_suspend() and
  at91_pm_state_allowed()
- s/weather/wether in patch 1/1

Claudiu Beznea (3):
  PM / Suspend: Add support to check if platform's power is off in
    suspend
  regulator: core: add helper to check if regulator is disabled in
    suspend
  ARM: at91: pm: add support for .off_in_suspend

 arch/arm/mach-at91/pm.c            | 61 +++++++++++++++++++++++++++++++++++---
 drivers/regulator/core.c           | 17 +++++++++++
 include/linux/regulator/consumer.h |  7 +++++
 include/linux/suspend.h            |  6 ++++
 kernel/power/suspend.c             | 13 ++++++++
 5 files changed, 100 insertions(+), 4 deletions(-)

Comments

Rafael J. Wysocki Jan. 8, 2019, 11:46 a.m. UTC | #1
On Tue, Jan 8, 2019 at 11:56 AM <Claudiu.Beznea@microchip.com> wrote:
>
> From: Claudiu Beznea <claudiu.beznea@microchip.com>
>
> Hi,
>
> AT91 platforms support a power saving mode where SoC's power is cut off (we call
> it backup mode). The resume is done with the help of bootloaders.

But still the contents of RAM are preserved?

That would require at least the memory controller to be under power AFAICS.

> To be able to
> suspend/resume Linux to/from this mode all the drivers suspend/resume callbacks
> should save/restore the content of all the active registers. We have 2 problems
> we are trying to solve:
> - some of these drivers are shared with other non Microchip SoCs (e.g. macb
>   driver) and we don't want to disturbe other users of corresponding IPs with
>   all the register save/restore operations;
> - the suspend/resume time for the rest of the power saving mode we are using
>   could be improved if we would know in drivers the suspend mode the platform
>   is switched to.
>
> A solution that would have been solve our problems was proposed in [1] but in
> the end it wasn't accepted. It ended up with the introduction of
> pm_suspend_target_state variable that could be used along with the changes in
> this series.
>
> While the discussion of [1] progressed it has been proposed (in [2]) to
> implement a function that would tell if the platform's power would be cut off
> at the end of the suspend procedure.
>
> The patches in this series does as follows:
> 1/3 - add a new member to platform_suspend_ops that will tell if platform's
>       power will be cut off at the end of the suspend procedure; drivers could
>       use it via platform_off_in_suspend()

I would rather avoid doing this if possible.

Thanks,
Rafael
Claudiu Beznea Jan. 8, 2019, 2:07 p.m. UTC | #2
On 08.01.2019 13:46, Rafael J. Wysocki wrote:
> On Tue, Jan 8, 2019 at 11:56 AM <Claudiu.Beznea@microchip.com> wrote:
>>
>> From: Claudiu Beznea <claudiu.beznea@microchip.com>
>>
>> Hi,
>>
>> AT91 platforms support a power saving mode where SoC's power is cut off (we call
>> it backup mode). The resume is done with the help of bootloaders.
> 
> But still the contents of RAM are preserved?

Yes, the RAM is kept alive, in self-refresh (forgot to mention).
Besides this, there is the so called backup area which contains RTC
shutdown controller, RC oscillator which remains powered. The rest is off.

> 
> That would require at least the memory controller to be under power AFAICS.

Yes, this is powered by a different regulator.

> 
>> To be able to
>> suspend/resume Linux to/from this mode all the drivers suspend/resume callbacks
>> should save/restore the content of all the active registers. We have 2 problems
>> we are trying to solve:
>> - some of these drivers are shared with other non Microchip SoCs (e.g. macb
>>   driver) and we don't want to disturbe other users of corresponding IPs with
>>   all the register save/restore operations;
>> - the suspend/resume time for the rest of the power saving mode we are using
>>   could be improved if we would know in drivers the suspend mode the platform
>>   is switched to.
>>
>> A solution that would have been solve our problems was proposed in [1] but in
>> the end it wasn't accepted. It ended up with the introduction of
>> pm_suspend_target_state variable that could be used along with the changes in
>> this series.
>>
>> While the discussion of [1] progressed it has been proposed (in [2]) to
>> implement a function that would tell if the platform's power would be cut off
>> at the end of the suspend procedure.
>>
>> The patches in this series does as follows:
>> 1/3 - add a new member to platform_suspend_ops that will tell if platform's
>>       power will be cut off at the end of the suspend procedure; drivers could
>>       use it via platform_off_in_suspend()
> 
> I would rather avoid doing this if possible.

Having this mechanism as part of platform_suspend_ops? Or this mechanism at
all?
Could you give me some hints on how would you prefer to do it, if any?

Thank you,
Claudiu Beznea

> 
> Thanks,
> Rafael
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
Claudiu Beznea Jan. 28, 2019, 9:50 a.m. UTC | #3
Hi Pavel, Rafael,

Do you have some other hints I could follow in order to solve the
scenario I tried to cover with these patches, if these are not
a proper fit for the current code?

Thank you,
Claudiu Beznea

On 08.01.2019 12:56, Claudiu Beznea - M18063 wrote:
> From: Claudiu Beznea <claudiu.beznea@microchip.com>
> 
> Hi,
> 
> AT91 platforms support a power saving mode where SoC's power is cut off (we call
> it backup mode). The resume is done with the help of bootloaders. To be able to
> suspend/resume Linux to/from this mode all the drivers suspend/resume callbacks
> should save/restore the content of all the active registers. We have 2 problems
> we are trying to solve:
> - some of these drivers are shared with other non Microchip SoCs (e.g. macb
>   driver) and we don't want to disturbe other users of corresponding IPs with
>   all the register save/restore operations;
> - the suspend/resume time for the rest of the power saving mode we are using
>   could be improved if we would know in drivers the suspend mode the platform
>   is switched to.
> 
> A solution that would have been solve our problems was proposed in [1] but in
> the end it wasn't accepted. It ended up with the introduction of
> pm_suspend_target_state variable that could be used along with the changes in
> this series.
> 
> While the discussion of [1] progressed it has been proposed (in [2]) to
> implement a function that would tell if the platform's power would be cut off
> at the end of the suspend procedure.
> 
> The patches in this series does as follows:
> 1/3 - add a new member to platform_suspend_ops that will tell if platform's
>       power will be cut off at the end of the suspend procedure; drivers could
>       use it via platform_off_in_suspend()
> 2/3 - add a new function to regulator's core that could be used to check if a
>       proper regulator has been configured (via DT) to be powered off in
>       suspend. This is used on this series to check the CPU's regulator is
>       properly configured in DT to be turned off in suspend.
> 3/3 - fill .off_in_suspend member of at91_pm_ops; the functionality in patch 2/3
>       is used to double check CPU's regulator would be turned off in suspend.
> 
> Thank you,
> Claudiu Beznea
> 
> [1] https://lkml.org/lkml/2017/6/22/938
> [2] https://lkml.org/lkml/2017/7/16/457
> 
> Changes in v2:
> - remove !! instruction in regulator_is_disabled_in_suspend() and
>   at91_pm_state_allowed()
> - s/weather/wether in patch 1/1
> 
> Claudiu Beznea (3):
>   PM / Suspend: Add support to check if platform's power is off in
>     suspend
>   regulator: core: add helper to check if regulator is disabled in
>     suspend
>   ARM: at91: pm: add support for .off_in_suspend
> 
>  arch/arm/mach-at91/pm.c            | 61 +++++++++++++++++++++++++++++++++++---
>  drivers/regulator/core.c           | 17 +++++++++++
>  include/linux/regulator/consumer.h |  7 +++++
>  include/linux/suspend.h            |  6 ++++
>  kernel/power/suspend.c             | 13 ++++++++
>  5 files changed, 100 insertions(+), 4 deletions(-)
>