diff mbox series

[kvm-unit-tests,4/7] lib: arm: Implement PSCI SYSTEM_OFF in psci_system_off()

Message ID 20190124111634.4727-5-alexandru.elisei@arm.com (mailing list archive)
State New, archived
Headers show
Series arm/arm64: Add support for running under kvmtool | expand

Commit Message

Alexandru Elisei Jan. 24, 2019, 11:16 a.m. UTC
A new function psci_system_off() is added which implements the PSCI
SYSTEM_OFF function. A call causes the hypervisor to terminate the virtual
machine.

Consumers for the function will be added in a later patch.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 lib/arm/asm/psci.h | 1 +
 lib/arm/psci.c     | 6 ++++++
 2 files changed, 7 insertions(+)

Comments

Andrew Jones Jan. 24, 2019, 1:01 p.m. UTC | #1
On Thu, Jan 24, 2019 at 11:16:31AM +0000, Alexandru Elisei wrote:
> A new function psci_system_off() is added which implements the PSCI
> SYSTEM_OFF function. A call causes the hypervisor to terminate the virtual
> machine.
> 
> Consumers for the function will be added in a later patch.
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
>  lib/arm/asm/psci.h | 1 +
>  lib/arm/psci.c     | 6 ++++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/lib/arm/asm/psci.h b/lib/arm/asm/psci.h
> index ed51708fd265..93409996349a 100644
> --- a/lib/arm/asm/psci.h
> +++ b/lib/arm/asm/psci.h
> @@ -9,5 +9,6 @@ extern int psci_cpu_on(unsigned long cpuid, unsigned long entry_point);
>  extern void psci_sys_reset(void);
>  extern int cpu_psci_cpu_boot(unsigned int cpu);
>  extern void cpu_psci_cpu_die(void);
> +extern void psci_system_off(void);
>  
>  #endif /* _ASMARM_PSCI_H_ */
> diff --git a/lib/arm/psci.c b/lib/arm/psci.c
> index 119f74e57e91..d8dc428e8e8b 100644
> --- a/lib/arm/psci.c
> +++ b/lib/arm/psci.c
> @@ -48,6 +48,12 @@ void cpu_psci_cpu_die(void)
>  	printf("CPU%d unable to power off (error = %d)\n", smp_processor_id(), err);
>  }
>  
> +void psci_system_off(void)
> +{
> +	int err = psci_invoke(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
> +	printf("CPU%d unable to do system off (error = %d)\n", smp_processor_id(), err);
> +}
> +
>  void psci_sys_reset(void)
>  {
>  	psci_invoke(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
> -- 
> 2.17.0
>

We should either rename psci_sys_reset to psci_system_reset or name this
new function with the psci_sys_* pattern.

Thanks,
drew
Alexandru Elisei Jan. 25, 2019, 2:08 p.m. UTC | #2
On 1/24/19 1:01 PM, Andrew Jones wrote:
> On Thu, Jan 24, 2019 at 11:16:31AM +0000, Alexandru Elisei wrote:
>> A new function psci_system_off() is added which implements the PSCI
>> SYSTEM_OFF function. A call causes the hypervisor to terminate the virtual
>> machine.
>>
>> Consumers for the function will be added in a later patch.
>>
>> Signed-off-by: Alexandru Elisei<alexandru.elisei@arm.com>
>> ---
>>   lib/arm/asm/psci.h | 1 +
>>   lib/arm/psci.c     | 6 ++++++
>>   2 files changed, 7 insertions(+)
>>
>> diff --git a/lib/arm/asm/psci.h b/lib/arm/asm/psci.h
>> index ed51708fd265..93409996349a 100644
>> --- a/lib/arm/asm/psci.h
>> +++ b/lib/arm/asm/psci.h
>> @@ -9,5 +9,6 @@ extern int psci_cpu_on(unsigned long cpuid, unsigned long entry_point);
>>   extern void psci_sys_reset(void);
>>   extern int cpu_psci_cpu_boot(unsigned int cpu);
>>   extern void cpu_psci_cpu_die(void);
>> +extern void psci_system_off(void);
>>   
>>   #endif /* _ASMARM_PSCI_H_ */
>> diff --git a/lib/arm/psci.c b/lib/arm/psci.c
>> index 119f74e57e91..d8dc428e8e8b 100644
>> --- a/lib/arm/psci.c
>> +++ b/lib/arm/psci.c
>> @@ -48,6 +48,12 @@ void cpu_psci_cpu_die(void)
>>   	printf("CPU%d unable to power off (error = %d)\n", smp_processor_id(), err);
>>   }
>>   
>> +void psci_system_off(void)
>> +{
>> +	int err = psci_invoke(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
>> +	printf("CPU%d unable to do system off (error = %d)\n", smp_processor_id(), err);
>> +}
>> +
>>   void psci_sys_reset(void)
>>   {
>>   	psci_invoke(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
>> -- 
>> 2.17.0
>>
> We should either rename psci_sys_reset to psci_system_reset or name this
> new function with the psci_sys_* pattern.
>
> Thanks,
> drew
I am thinking we should rename psci_sys_reset() to match the PSCI specification 
function name, which is SYSTEM_OFF. If you're ok with it, I'll do the rename in 
the next patch set version.
Andrew Jones Jan. 25, 2019, 2:25 p.m. UTC | #3
On Fri, Jan 25, 2019 at 02:08:45PM +0000, Alexandru Elisei wrote:
> 
> On 1/24/19 1:01 PM, Andrew Jones wrote:
> > On Thu, Jan 24, 2019 at 11:16:31AM +0000, Alexandru Elisei wrote:
> > > A new function psci_system_off() is added which implements the PSCI
> > > SYSTEM_OFF function. A call causes the hypervisor to terminate the virtual
> > > machine.
> > > 
> > > Consumers for the function will be added in a later patch.
> > > 
> > > Signed-off-by: Alexandru Elisei<alexandru.elisei@arm.com>
> > > ---
> > >   lib/arm/asm/psci.h | 1 +
> > >   lib/arm/psci.c     | 6 ++++++
> > >   2 files changed, 7 insertions(+)
> > > 
> > > diff --git a/lib/arm/asm/psci.h b/lib/arm/asm/psci.h
> > > index ed51708fd265..93409996349a 100644
> > > --- a/lib/arm/asm/psci.h
> > > +++ b/lib/arm/asm/psci.h
> > > @@ -9,5 +9,6 @@ extern int psci_cpu_on(unsigned long cpuid, unsigned long entry_point);
> > >   extern void psci_sys_reset(void);
> > >   extern int cpu_psci_cpu_boot(unsigned int cpu);
> > >   extern void cpu_psci_cpu_die(void);
> > > +extern void psci_system_off(void);
> > >   #endif /* _ASMARM_PSCI_H_ */
> > > diff --git a/lib/arm/psci.c b/lib/arm/psci.c
> > > index 119f74e57e91..d8dc428e8e8b 100644
> > > --- a/lib/arm/psci.c
> > > +++ b/lib/arm/psci.c
> > > @@ -48,6 +48,12 @@ void cpu_psci_cpu_die(void)
> > >   	printf("CPU%d unable to power off (error = %d)\n", smp_processor_id(), err);
> > >   }
> > > +void psci_system_off(void)
> > > +{
> > > +	int err = psci_invoke(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
> > > +	printf("CPU%d unable to do system off (error = %d)\n", smp_processor_id(), err);
> > > +}
> > > +
> > >   void psci_sys_reset(void)
> > >   {
> > >   	psci_invoke(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
> > > -- 
> > > 2.17.0
> > > 
> > We should either rename psci_sys_reset to psci_system_reset or name this
> > new function with the psci_sys_* pattern.
> > 
> > Thanks,
> > drew
> I am thinking we should rename psci_sys_reset() to match the PSCI
> specification function name, which is SYSTEM_OFF. If you're ok with it, I'll
> do the rename in the next patch set version.

Yup, I'm fine with the renaming.

Thanks,
drew
diff mbox series

Patch

diff --git a/lib/arm/asm/psci.h b/lib/arm/asm/psci.h
index ed51708fd265..93409996349a 100644
--- a/lib/arm/asm/psci.h
+++ b/lib/arm/asm/psci.h
@@ -9,5 +9,6 @@  extern int psci_cpu_on(unsigned long cpuid, unsigned long entry_point);
 extern void psci_sys_reset(void);
 extern int cpu_psci_cpu_boot(unsigned int cpu);
 extern void cpu_psci_cpu_die(void);
+extern void psci_system_off(void);
 
 #endif /* _ASMARM_PSCI_H_ */
diff --git a/lib/arm/psci.c b/lib/arm/psci.c
index 119f74e57e91..d8dc428e8e8b 100644
--- a/lib/arm/psci.c
+++ b/lib/arm/psci.c
@@ -48,6 +48,12 @@  void cpu_psci_cpu_die(void)
 	printf("CPU%d unable to power off (error = %d)\n", smp_processor_id(), err);
 }
 
+void psci_system_off(void)
+{
+	int err = psci_invoke(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
+	printf("CPU%d unable to do system off (error = %d)\n", smp_processor_id(), err);
+}
+
 void psci_sys_reset(void)
 {
 	psci_invoke(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);