mbox series

[RFC,00/11] SBI system suspend (SUSP) extension

Message ID 20230106112209.441825-1-ajones@ventanamicro.com
Headers show
Series SBI system suspend (SUSP) extension | expand

Message

Andrew Jones Jan. 6, 2023, 11:21 a.m. UTC
This series implements the SBI system suspend support in OpenSBI
as-per the draft proposal for SBI system suspend which can be found at
https://github.com/jones-drew/riscv-sbi-doc/commit/d9e43e9a938fc3eb510e023c3f352462876f7785

The first half of the series are a few cleanups and fixes for HSM,
as system suspend makes use of some of its code and patterns. The
second half implements support for the extension and includes a patch
which allows testing to be enabled, even when low-level firmware does
not provide support. Regarding the test mode, it's currently enabled
by adding a 'system-suspend-test' DT property, but Anup has suggested
that FW_OPTION could also be used. I'm all ears for what people think
the best way to control test functionality in OpenSBI is and am happy
to switch it. To test with Linux the kernel must include the patch at
https://github.com/jones-drew/linux/commits/riscv/sbi-susp-rfc and
be built with CONFIG_SUSPEND enabled.

The patches are based on v1.2 and "treewide: Replace TRUE/FALSE
with true/false" and can also be found at
https://github.com/jones-drew/opensbi/commits/susp-rfc

Andrew Jones (11):
  lib: sbi_hsm: Factor out invalid state detection
  lib: sbi_hsm: Don't try to restore state on failed change
  lib: sbi_hsm: Ensure errors are consistent with spec
  lib: sbi_hsm: Move misplaced comment
  lib: sbi_hsm: Remove unnecessary include
  lib: sbi_hsm: Export some functions
  lib: sbi: Add system suspend skeleton
  lib: sbi: Add system_suspend_allowed domain property
  lib: sbi: Implement system suspend
  docs: Correct opensbi-domain property name
  platform: generic: Add system suspend test

 docs/domain_support.md            |  15 +++-
 include/sbi/sbi_domain.h          |   2 +
 include/sbi/sbi_ecall_interface.h |   8 +++
 include/sbi/sbi_hsm.h             |   4 ++
 include/sbi/sbi_system.h          |  18 +++++
 lib/sbi/Kconfig                   |   4 ++
 lib/sbi/objects.mk                |   3 +
 lib/sbi/sbi_domain.c              |   4 ++
 lib/sbi/sbi_ecall_hsm.c           |   4 +-
 lib/sbi/sbi_ecall_susp.c          |  48 +++++++++++++
 lib/sbi/sbi_hsm.c                 |  92 +++++++++++--------------
 lib/sbi/sbi_system.c              | 111 ++++++++++++++++++++++++++++++
 lib/utils/fdt/fdt_domain.c        |   7 ++
 platform/generic/platform.c       |  20 +++++-
 14 files changed, 283 insertions(+), 57 deletions(-)
 create mode 100644 lib/sbi/sbi_ecall_susp.c

Comments

Andrew Jones Jan. 6, 2023, 11:34 a.m. UTC | #1
On Fri, Jan 06, 2023 at 12:21:58PM +0100, Andrew Jones wrote:
> This series implements the SBI system suspend support in OpenSBI
> as-per the draft proposal for SBI system suspend which can be found at
> https://github.com/jones-drew/riscv-sbi-doc/commit/d9e43e9a938fc3eb510e023c3f352462876f7785

The extension proposal has been posted to tech-prs,
https://lists.riscv.org/g/tech-prs/message/75

> 
> The first half of the series are a few cleanups and fixes for HSM,
> as system suspend makes use of some of its code and patterns. The
> second half implements support for the extension and includes a patch
> which allows testing to be enabled, even when low-level firmware does
> not provide support. Regarding the test mode, it's currently enabled
> by adding a 'system-suspend-test' DT property, but Anup has suggested
> that FW_OPTION could also be used. I'm all ears for what people think
> the best way to control test functionality in OpenSBI is and am happy
> to switch it. To test with Linux the kernel must include the patch at
> https://github.com/jones-drew/linux/commits/riscv/sbi-susp-rfc and
> be built with CONFIG_SUSPEND enabled.

The linux patch has been posted,
https://lore.kernel.org/all/20230106113216.443057-1-ajones@ventanamicro.com/

> 
> The patches are based on v1.2 and "treewide: Replace TRUE/FALSE
> with true/false" and can also be found at
> https://github.com/jones-drew/opensbi/commits/susp-rfc
> 
> Andrew Jones (11):
>   lib: sbi_hsm: Factor out invalid state detection
>   lib: sbi_hsm: Don't try to restore state on failed change
>   lib: sbi_hsm: Ensure errors are consistent with spec
>   lib: sbi_hsm: Move misplaced comment
>   lib: sbi_hsm: Remove unnecessary include
>   lib: sbi_hsm: Export some functions
>   lib: sbi: Add system suspend skeleton
>   lib: sbi: Add system_suspend_allowed domain property
>   lib: sbi: Implement system suspend
>   docs: Correct opensbi-domain property name
>   platform: generic: Add system suspend test
> 
>  docs/domain_support.md            |  15 +++-
>  include/sbi/sbi_domain.h          |   2 +
>  include/sbi/sbi_ecall_interface.h |   8 +++
>  include/sbi/sbi_hsm.h             |   4 ++
>  include/sbi/sbi_system.h          |  18 +++++
>  lib/sbi/Kconfig                   |   4 ++
>  lib/sbi/objects.mk                |   3 +
>  lib/sbi/sbi_domain.c              |   4 ++
>  lib/sbi/sbi_ecall_hsm.c           |   4 +-
>  lib/sbi/sbi_ecall_susp.c          |  48 +++++++++++++
>  lib/sbi/sbi_hsm.c                 |  92 +++++++++++--------------
>  lib/sbi/sbi_system.c              | 111 ++++++++++++++++++++++++++++++
>  lib/utils/fdt/fdt_domain.c        |   7 ++
>  platform/generic/platform.c       |  20 +++++-
>  14 files changed, 283 insertions(+), 57 deletions(-)
>  create mode 100644 lib/sbi/sbi_ecall_susp.c
> 
> -- 
> 2.39.0
>
Anup Patel Jan. 17, 2023, 3:54 a.m. UTC | #2
On Fri, Jan 6, 2023 at 4:52 PM Andrew Jones <ajones@ventanamicro.com> wrote:
>
> This series implements the SBI system suspend support in OpenSBI
> as-per the draft proposal for SBI system suspend which can be found at
> https://github.com/jones-drew/riscv-sbi-doc/commit/d9e43e9a938fc3eb510e023c3f352462876f7785
>
> The first half of the series are a few cleanups and fixes for HSM,
> as system suspend makes use of some of its code and patterns. The
> second half implements support for the extension and includes a patch
> which allows testing to be enabled, even when low-level firmware does
> not provide support. Regarding the test mode, it's currently enabled
> by adding a 'system-suspend-test' DT property, but Anup has suggested
> that FW_OPTION could also be used. I'm all ears for what people think
> the best way to control test functionality in OpenSBI is and am happy
> to switch it. To test with Linux the kernel must include the patch at
> https://github.com/jones-drew/linux/commits/riscv/sbi-susp-rfc and
> be built with CONFIG_SUSPEND enabled.
>
> The patches are based on v1.2 and "treewide: Replace TRUE/FALSE
> with true/false" and can also be found at
> https://github.com/jones-drew/opensbi/commits/susp-rfc
>
> Andrew Jones (11):
>   lib: sbi_hsm: Factor out invalid state detection
>   lib: sbi_hsm: Don't try to restore state on failed change
>   lib: sbi_hsm: Ensure errors are consistent with spec
>   lib: sbi_hsm: Move misplaced comment
>   lib: sbi_hsm: Remove unnecessary include
>   lib: sbi_hsm: Export some functions
>   lib: sbi: Add system suspend skeleton
>   lib: sbi: Add system_suspend_allowed domain property
>   lib: sbi: Implement system suspend
>   docs: Correct opensbi-domain property name
>   platform: generic: Add system suspend test

I must say that this is pretty neatly done. Great work !!!

Could you please add a boot print for suspend device in
sbi_boot_print_general() ?

Regards,
Anup

>
>  docs/domain_support.md            |  15 +++-
>  include/sbi/sbi_domain.h          |   2 +
>  include/sbi/sbi_ecall_interface.h |   8 +++
>  include/sbi/sbi_hsm.h             |   4 ++
>  include/sbi/sbi_system.h          |  18 +++++
>  lib/sbi/Kconfig                   |   4 ++
>  lib/sbi/objects.mk                |   3 +
>  lib/sbi/sbi_domain.c              |   4 ++
>  lib/sbi/sbi_ecall_hsm.c           |   4 +-
>  lib/sbi/sbi_ecall_susp.c          |  48 +++++++++++++
>  lib/sbi/sbi_hsm.c                 |  92 +++++++++++--------------
>  lib/sbi/sbi_system.c              | 111 ++++++++++++++++++++++++++++++
>  lib/utils/fdt/fdt_domain.c        |   7 ++
>  platform/generic/platform.c       |  20 +++++-
>  14 files changed, 283 insertions(+), 57 deletions(-)
>  create mode 100644 lib/sbi/sbi_ecall_susp.c
>
> --
> 2.39.0
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
Andrew Jones Jan. 17, 2023, 9:33 a.m. UTC | #3
On Tue, Jan 17, 2023 at 09:24:11AM +0530, Anup Patel wrote:
> On Fri, Jan 6, 2023 at 4:52 PM Andrew Jones <ajones@ventanamicro.com> wrote:
> >
> > This series implements the SBI system suspend support in OpenSBI
> > as-per the draft proposal for SBI system suspend which can be found at
> > https://github.com/jones-drew/riscv-sbi-doc/commit/d9e43e9a938fc3eb510e023c3f352462876f7785
> >
> > The first half of the series are a few cleanups and fixes for HSM,
> > as system suspend makes use of some of its code and patterns. The
> > second half implements support for the extension and includes a patch
> > which allows testing to be enabled, even when low-level firmware does
> > not provide support. Regarding the test mode, it's currently enabled
> > by adding a 'system-suspend-test' DT property, but Anup has suggested
> > that FW_OPTION could also be used. I'm all ears for what people think
> > the best way to control test functionality in OpenSBI is and am happy
> > to switch it. To test with Linux the kernel must include the patch at
> > https://github.com/jones-drew/linux/commits/riscv/sbi-susp-rfc and
> > be built with CONFIG_SUSPEND enabled.
> >
> > The patches are based on v1.2 and "treewide: Replace TRUE/FALSE
> > with true/false" and can also be found at
> > https://github.com/jones-drew/opensbi/commits/susp-rfc
> >
> > Andrew Jones (11):
> >   lib: sbi_hsm: Factor out invalid state detection
> >   lib: sbi_hsm: Don't try to restore state on failed change
> >   lib: sbi_hsm: Ensure errors are consistent with spec
> >   lib: sbi_hsm: Move misplaced comment
> >   lib: sbi_hsm: Remove unnecessary include
> >   lib: sbi_hsm: Export some functions
> >   lib: sbi: Add system suspend skeleton
> >   lib: sbi: Add system_suspend_allowed domain property
> >   lib: sbi: Implement system suspend
> >   docs: Correct opensbi-domain property name
> >   platform: generic: Add system suspend test
> 
> I must say that this is pretty neatly done. Great work !!!

Thank you, Anup!

> 
> Could you please add a boot print for suspend device in
> sbi_boot_print_general() ?

Will do.

Thanks,
drew

> 
> Regards,
> Anup
> 
> >
> >  docs/domain_support.md            |  15 +++-
> >  include/sbi/sbi_domain.h          |   2 +
> >  include/sbi/sbi_ecall_interface.h |   8 +++
> >  include/sbi/sbi_hsm.h             |   4 ++
> >  include/sbi/sbi_system.h          |  18 +++++
> >  lib/sbi/Kconfig                   |   4 ++
> >  lib/sbi/objects.mk                |   3 +
> >  lib/sbi/sbi_domain.c              |   4 ++
> >  lib/sbi/sbi_ecall_hsm.c           |   4 +-
> >  lib/sbi/sbi_ecall_susp.c          |  48 +++++++++++++
> >  lib/sbi/sbi_hsm.c                 |  92 +++++++++++--------------
> >  lib/sbi/sbi_system.c              | 111 ++++++++++++++++++++++++++++++
> >  lib/utils/fdt/fdt_domain.c        |   7 ++
> >  platform/generic/platform.c       |  20 +++++-
> >  14 files changed, 283 insertions(+), 57 deletions(-)
> >  create mode 100644 lib/sbi/sbi_ecall_susp.c
> >
> > --
> > 2.39.0
> >
> >
> > --
> > opensbi mailing list
> > opensbi@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/opensbi