diff mbox

[v6,1/3] PSCI: Add initial support for PSCIv0.2 functions

Message ID CAJ5Y-eZ=ugeav++ysMCbAUFnPMr5=WaCdrEdYojwLi1HTYX6rw@mail.gmail.com
State New
Headers show

Commit Message

Ashwin Chaugule April 22, 2014, 5:32 p.m. UTC
On 21 April 2014 02:23, Anup Patel <anup.patel@linaro.org> wrote:
> Hi Ashwin,
>
> Please include system reboot & shutdown implementation
> in this patch using PSCI v0.2 SYSTEM_OFF and
> SYSTEM_RESET functions.

hm, I had thought these relied on having the (optional) MIGRATE
function. But thats not the case.

So, how about this..

---------------------8<---------------------

Comments

Anup Patel April 23, 2014, 6:05 a.m. UTC | #1
On Tue, Apr 22, 2014 at 11:02 PM, Ashwin Chaugule
<ashwin.chaugule@linaro.org> wrote:
> On 21 April 2014 02:23, Anup Patel <anup.patel@linaro.org> wrote:
>> Hi Ashwin,
>>
>> Please include system reboot & shutdown implementation
>> in this patch using PSCI v0.2 SYSTEM_OFF and
>> SYSTEM_RESET functions.
>
> hm, I had thought these relied on having the (optional) MIGRATE
> function. But thats not the case.
>
> So, how about this..
>
> ---------------------8<---------------------
>
> diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
> index ead8cdb..5a54f2f 100644
> --- a/arch/arm/kernel/psci.c
> +++ b/arch/arm/kernel/psci.c
> @@ -17,6 +17,8 @@
>
>  #include <linux/init.h>
>  #include <linux/of.h>
> +#include <linux/reboot.h>
> +#include <linux/pm.h>
>  #include <uapi/linux/psci.h>
>
>  #include <asm/compiler.h>
> @@ -24,6 +26,7 @@
>  #include <asm/opcodes-sec.h>
>  #include <asm/opcodes-virt.h>
>  #include <asm/psci.h>
> +#include <asm/system_misc.h>
>
>  struct psci_operations psci_ops;
>
> @@ -196,6 +199,16 @@ static int get_set_conduit_method(struct device_node *np)
>   return 0;
>  }
>
> +static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
> +{
> + invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
> +}
> +
> +static void psci_sys_off(void)
> +{
> + invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
> +}
> +
>  /*
>   * PSCI Function IDs for v0.2+ are well defined so use
>   * standard values.
> @@ -249,6 +262,10 @@ static int psci_0_2_init(struct device_node *np)
>   PSCI_0_2_FN_MIGRATE_INFO_TYPE;
>   psci_ops.migrate_info_type = psci_migrate_info_type;
>
> + arm_pm_restart = psci_sys_reset;
> +
> + pm_power_off = psci_sys_off;
> +

Yes, I think this should work.

Thanks,
Anup

>  out_put_node:
>   of_node_put(np);
>   return err;
> diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
> index 63a7685..583b7c3 100644
> --- a/arch/arm64/kernel/psci.c
> +++ b/arch/arm64/kernel/psci.c
> @@ -18,6 +18,8 @@
>  #include <linux/init.h>
>  #include <linux/of.h>
>  #include <linux/smp.h>
> +#include <linux/reboot.h>
> +#include <linux/pm.h>
>  #include <uapi/linux/psci.h>
>
>  #include <asm/compiler.h>
> @@ -25,6 +27,7 @@
>  #include <asm/errno.h>
>  #include <asm/psci.h>
>  #include <asm/smp_plat.h>
> +#include <asm/system_misc.h>
>
>  #define PSCI_POWER_STATE_TYPE_STANDBY 0
>  #define PSCI_POWER_STATE_TYPE_POWER_DOWN 1
> @@ -217,6 +220,16 @@ static int get_set_conduit_method(struct device_node *np)
>   return 0;
>  }
>
> +static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
> +{
> + invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
> +}
> +
> +static void psci_sys_off(void)
> +{
> + invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
> +}
> +
>  /*
>   * PSCI Function IDs for v0.2+ are well defined so use
>   * standard values.
> @@ -270,6 +283,10 @@ static int psci_0_2_init(struct device_node *np)
>   PSCI_0_2_FN_MIGRATE_INFO_TYPE;
>   psci_ops.migrate_info_type = psci_migrate_info_type;
>
> + arm_pm_restart = psci_sys_reset;
> +
> + pm_power_off = psci_sys_off;
> +
>  out_put_node:
>   of_node_put(np);
>   return err;
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Rob Herring April 23, 2014, 1:16 p.m. UTC | #2
On Tue, Apr 22, 2014 at 12:32 PM, Ashwin Chaugule
<ashwin.chaugule@linaro.org> wrote:
> On 21 April 2014 02:23, Anup Patel <anup.patel@linaro.org> wrote:
>> Hi Ashwin,
>>
>> Please include system reboot & shutdown implementation
>> in this patch using PSCI v0.2 SYSTEM_OFF and
>> SYSTEM_RESET functions.
>
> hm, I had thought these relied on having the (optional) MIGRATE
> function. But thats not the case.
>
> So, how about this..
>
> ---------------------8<---------------------
>
> diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
> index ead8cdb..5a54f2f 100644
> --- a/arch/arm/kernel/psci.c
> +++ b/arch/arm/kernel/psci.c
> @@ -17,6 +17,8 @@
>
>  #include <linux/init.h>
>  #include <linux/of.h>
> +#include <linux/reboot.h>
> +#include <linux/pm.h>
>  #include <uapi/linux/psci.h>
>
>  #include <asm/compiler.h>
> @@ -24,6 +26,7 @@
>  #include <asm/opcodes-sec.h>
>  #include <asm/opcodes-virt.h>
>  #include <asm/psci.h>
> +#include <asm/system_misc.h>
>
>  struct psci_operations psci_ops;
>
> @@ -196,6 +199,16 @@ static int get_set_conduit_method(struct device_node *np)
>   return 0;
>  }
>
> +static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
> +{
> + invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
> +}
> +
> +static void psci_sys_off(void)

This is a bit terse. I would spell out system or use sys_poweroff
here. Otherwise,

Acked-by: Rob Herring <robh@kernel.org>

Rob
Ashwin Chaugule April 23, 2014, 2:19 p.m. UTC | #3
On 23 April 2014 09:16, Rob Herring <robherring2@gmail.com> wrote:
> On Tue, Apr 22, 2014 at 12:32 PM, Ashwin Chaugule
> <ashwin.chaugule@linaro.org> wrote:
>> On 21 April 2014 02:23, Anup Patel <anup.patel@linaro.org> wrote:
>>> Hi Ashwin,
>>>
>>> Please include system reboot & shutdown implementation
>>> in this patch using PSCI v0.2 SYSTEM_OFF and
>>> SYSTEM_RESET functions.
>>
>> hm, I had thought these relied on having the (optional) MIGRATE
>> function. But thats not the case.
>>
>> So, how about this..
>>
>> ---------------------8<---------------------
>>
>> diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
>> index ead8cdb..5a54f2f 100644
>> --- a/arch/arm/kernel/psci.c
>> +++ b/arch/arm/kernel/psci.c
>> @@ -17,6 +17,8 @@
>>
>>  #include <linux/init.h>
>>  #include <linux/of.h>
>> +#include <linux/reboot.h>
>> +#include <linux/pm.h>
>>  #include <uapi/linux/psci.h>
>>
>>  #include <asm/compiler.h>
>> @@ -24,6 +26,7 @@
>>  #include <asm/opcodes-sec.h>
>>  #include <asm/opcodes-virt.h>
>>  #include <asm/psci.h>
>> +#include <asm/system_misc.h>
>>
>>  struct psci_operations psci_ops;
>>
>> @@ -196,6 +199,16 @@ static int get_set_conduit_method(struct device_node *np)
>>   return 0;
>>  }
>>
>> +static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
>> +{
>> + invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
>> +}
>> +
>> +static void psci_sys_off(void)
>
> This is a bit terse. I would spell out system or use sys_poweroff
> here. Otherwise,
>
> Acked-by: Rob Herring <robh@kernel.org>
>

Thanks Rob. Are you okay with adding this Acked-by for this complete
patch [1/3]?

> Rob
Rob Herring April 23, 2014, 2:24 p.m. UTC | #4
On Wed, Apr 23, 2014 at 9:19 AM, Ashwin Chaugule
<ashwin.chaugule@linaro.org> wrote:
> On 23 April 2014 09:16, Rob Herring <robherring2@gmail.com> wrote:
>> On Tue, Apr 22, 2014 at 12:32 PM, Ashwin Chaugule
>> <ashwin.chaugule@linaro.org> wrote:
>>> On 21 April 2014 02:23, Anup Patel <anup.patel@linaro.org> wrote:
>>>> Hi Ashwin,
>>>>
>>>> Please include system reboot & shutdown implementation
>>>> in this patch using PSCI v0.2 SYSTEM_OFF and
>>>> SYSTEM_RESET functions.
>>>
>>> hm, I had thought these relied on having the (optional) MIGRATE
>>> function. But thats not the case.
>>>
>>> So, how about this..
>>>
>>> ---------------------8<---------------------
>>>
>>> diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
>>> index ead8cdb..5a54f2f 100644
>>> --- a/arch/arm/kernel/psci.c
>>> +++ b/arch/arm/kernel/psci.c
>>> @@ -17,6 +17,8 @@
>>>
>>>  #include <linux/init.h>
>>>  #include <linux/of.h>
>>> +#include <linux/reboot.h>
>>> +#include <linux/pm.h>
>>>  #include <uapi/linux/psci.h>
>>>
>>>  #include <asm/compiler.h>
>>> @@ -24,6 +26,7 @@
>>>  #include <asm/opcodes-sec.h>
>>>  #include <asm/opcodes-virt.h>
>>>  #include <asm/psci.h>
>>> +#include <asm/system_misc.h>
>>>
>>>  struct psci_operations psci_ops;
>>>
>>> @@ -196,6 +199,16 @@ static int get_set_conduit_method(struct device_node *np)
>>>   return 0;
>>>  }
>>>
>>> +static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
>>> +{
>>> + invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
>>> +}
>>> +
>>> +static void psci_sys_off(void)
>>
>> This is a bit terse. I would spell out system or use sys_poweroff
>> here. Otherwise,
>>
>> Acked-by: Rob Herring <robh@kernel.org>
>>
>
> Thanks Rob. Are you okay with adding this Acked-by for this complete
> patch [1/3]?

Yes. In fact, you can add Reviewed-by.

Rob
diff mbox

Patch

diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
index ead8cdb..5a54f2f 100644
--- a/arch/arm/kernel/psci.c
+++ b/arch/arm/kernel/psci.c
@@ -17,6 +17,8 @@ 

 #include <linux/init.h>
 #include <linux/of.h>
+#include <linux/reboot.h>
+#include <linux/pm.h>
 #include <uapi/linux/psci.h>

 #include <asm/compiler.h>
@@ -24,6 +26,7 @@ 
 #include <asm/opcodes-sec.h>
 #include <asm/opcodes-virt.h>
 #include <asm/psci.h>
+#include <asm/system_misc.h>

 struct psci_operations psci_ops;

@@ -196,6 +199,16 @@  static int get_set_conduit_method(struct device_node *np)
  return 0;
 }

+static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
+{
+ invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
+}
+
+static void psci_sys_off(void)
+{
+ invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
+}
+
 /*
  * PSCI Function IDs for v0.2+ are well defined so use
  * standard values.
@@ -249,6 +262,10 @@  static int psci_0_2_init(struct device_node *np)
  PSCI_0_2_FN_MIGRATE_INFO_TYPE;
  psci_ops.migrate_info_type = psci_migrate_info_type;

+ arm_pm_restart = psci_sys_reset;
+
+ pm_power_off = psci_sys_off;
+
 out_put_node:
  of_node_put(np);
  return err;
diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
index 63a7685..583b7c3 100644
--- a/arch/arm64/kernel/psci.c
+++ b/arch/arm64/kernel/psci.c
@@ -18,6 +18,8 @@ 
 #include <linux/init.h>
 #include <linux/of.h>
 #include <linux/smp.h>
+#include <linux/reboot.h>
+#include <linux/pm.h>
 #include <uapi/linux/psci.h>

 #include <asm/compiler.h>
@@ -25,6 +27,7 @@ 
 #include <asm/errno.h>
 #include <asm/psci.h>
 #include <asm/smp_plat.h>
+#include <asm/system_misc.h>

 #define PSCI_POWER_STATE_TYPE_STANDBY 0
 #define PSCI_POWER_STATE_TYPE_POWER_DOWN 1
@@ -217,6 +220,16 @@  static int get_set_conduit_method(struct device_node *np)
  return 0;
 }

+static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
+{
+ invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
+}
+
+static void psci_sys_off(void)
+{
+ invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
+}
+
 /*
  * PSCI Function IDs for v0.2+ are well defined so use
  * standard values.
@@ -270,6 +283,10 @@  static int psci_0_2_init(struct device_node *np)
  PSCI_0_2_FN_MIGRATE_INFO_TYPE;
  psci_ops.migrate_info_type = psci_migrate_info_type;

+ arm_pm_restart = psci_sys_reset;
+
+ pm_power_off = psci_sys_off;
+
 out_put_node:
  of_node_put(np);
  return err;