[PATCH 9/9] cmd: test_enter_suspend: Add test_enter_suspend command

Thomas Richard thomas.richard at bootlin.com
Thu Oct 19 11:46:32 CEST 2023


On 10/16/23 20:14, Heinrich Schuchardt wrote:
> On 10/16/23 16:11, Thomas Richard wrote:
>> From: Gregory CLEMENT <gregory.clement at bootlin.com>
>>
>> Add test_enter_suspend command using PSCI.
>> This command is only to test suspend sequence from U-Boot.
>> The resume will not work.
>>
>> Signed-off-by: Gregory CLEMENT <gregory.clement at bootlin.com>
>> Signed-off-by: Thomas Richard <thomas.richard at bootlin.com>
>>
>> ---
>>
>>   cmd/Kconfig             |  7 +++++++
>>   cmd/boot.c              |  8 ++++++++
>>   drivers/firmware/psci.c | 23 +++++++++++++++++++++++
>>   include/command.h       |  2 ++
>>   4 files changed, 40 insertions(+)
>>
>> diff --git a/cmd/Kconfig b/cmd/Kconfig
>> index 43ca10f69c..54e7d4b0e6 100644
>> --- a/cmd/Kconfig
>> +++ b/cmd/Kconfig
>> @@ -1450,6 +1450,13 @@ config CMD_POWEROFF
>>       help
>>         Poweroff/Shutdown the system
>>
>> +config CMD_TEST_ENTER_SUSPEND
>> +    bool "test enter suspend"
>> +    depends on ARM
>> +    select ARM_SMCCC
>> +    help
>> +      Command to test the suspend sequence (only for test)
>> +
>>   config CMD_READ
>>       bool "read - Read binary data from a partition"
>>       help
>> diff --git a/cmd/boot.c b/cmd/boot.c
>> index 14839c1ced..609c07a5a5 100644
>> --- a/cmd/boot.c
>> +++ b/cmd/boot.c
>> @@ -70,3 +70,11 @@ U_BOOT_CMD(
>>       ""
>>   );
>>   #endif
>> +
>> +#if IS_ENABLED(CONFIG_CMD_TEST_ENTER_SUSPEND)
>> +U_BOOT_CMD(
>> +    test_enter_suspend, 1, 0, do_test_enter_suspend,
>> +    "Test the enter SUSPEND sequence of the device",
>> +    ""
>> +);
>> +#endif
>> diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
>> index c6b9efab41..591ad1869d 100644
>> --- a/drivers/firmware/psci.c
>> +++ b/drivers/firmware/psci.c
>> @@ -23,6 +23,9 @@
>>   #include <linux/libfdt.h>
>>   #include <linux/printk.h>
>>   #include <linux/psci.h>
>> +#if IS_ENABLED(CONFIG_CMD_TEST_ENTER_SUSPEND)
>> +#include <cpu_func.h>
>> +#endif
>>
>>   #define DRIVER_NAME "psci"
>>
>> @@ -303,6 +306,26 @@ int do_poweroff(struct cmd_tbl *cmdtp, int flag,
>> int argc, char *const argv[])
>>   }
>>   #endif
>>
>> +#if IS_ENABLED(CONFIG_CMD_TEST_ENTER_SUSPEND)
>> +int do_test_enter_suspend(struct cmd_tbl *cmdtp, int flag, int argc,
>> char *const argv[])
>> +{
>> +    do_psci_probe();
>> +
>> +    puts("suspend ...\n");
>> +    puts("disable dcache\n");
>> +
>> +    dcache_disable();
>> +
>> +    /* ARM_PSCI_1_0_FN64_SYSTEM_SUSPEND */
>> +    invoke_psci_fn(PSCI_0_2_FN64(14), (unsigned
>> long)do_test_enter_suspend, 0, 0);
> 
> Suspend exists on other architectures, too. E.g. OpenSBI provides an
> implementation for RISC-V. It would be preferable to add suspend as a
> value to enum enum sysreset_t. Then that functionality can be
> implemented in sysreset_psci.c sysreset_sbi.c, and others.
> 
> The command should simply be called 'suspend'.

This command is only for development/test purpose.
As-is, the resume will not work.
We wrote this command to help during the development, and test our
suspend sequence without booting a Linux.
We didn't plan to support suspend/resume from U-Boot.
So I will remove this patch.

Best Regards,

Thomas

> 
> Best regards
> 
> Heinrich
> 


More information about the U-Boot mailing list