diff mbox

[RFC,V3,5/7] hw/arm/virt: Use PSCI v0.2 function IDs when kernel supports it

Message ID 1397130414-5551-6-git-send-email-pranavkumar@linaro.org
State New
Headers show

Commit Message

PranavkumarSawargaonkar April 10, 2014, 11:46 a.m. UTC
If we have in-kernel emulation of PSCI v0.2 for KVM ARM/ARM64 then
we enable PSCI v0.2 for each VCPU at the time of VCPU init hence we
need to provide PSCI v0.2 function IDs via generated DTB.

This patch updates generated DTB to have PSCI v0.2 function IDs when
we have in-kernel emulation PSCI v0.2 for KVM ARM/ARM64.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 hw/arm/virt.c |   28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

Comments

Rob Herring April 25, 2014, 6:47 p.m. UTC | #1
On Thu, Apr 10, 2014 at 6:46 AM, Pranavkumar Sawargaonkar
<pranavkumar@linaro.org> wrote:
> If we have in-kernel emulation of PSCI v0.2 for KVM ARM/ARM64 then
> we enable PSCI v0.2 for each VCPU at the time of VCPU init hence we
> need to provide PSCI v0.2 function IDs via generated DTB.
>
> This patch updates generated DTB to have PSCI v0.2 function IDs when
> we have in-kernel emulation PSCI v0.2 for KVM ARM/ARM64.
>
> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  hw/arm/virt.c |   28 +++++++++++++++++++++++-----
>  1 file changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 2bbc931..cf6a774 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -187,11 +187,29 @@ static void create_fdt(VirtBoardInfo *vbi)
>          qemu_fdt_add_subnode(fdt, "/psci");
>          qemu_fdt_setprop_string(fdt, "/psci", "compatible", "arm,psci");

Read the binding document for psci 0.2 (not the PSCI spec example).
This needs to be "arm,psci-0.2".

The virt mach needs to provide either 0.1 only or 0.1 and 0.2 support.
Providing both means both compatible strings and the function IDs for
0.1.

>          qemu_fdt_setprop_string(fdt, "/psci", "method", "hvc");
> -        qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
> -                                  PSCI_FN_CPU_SUSPEND);
> -        qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off", PSCI_FN_CPU_OFF);
> -        qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on", PSCI_FN_CPU_ON);
> -        qemu_fdt_setprop_cell(fdt, "/psci", "migrate", PSCI_FN_MIGRATE);
> +        if (kvm_check_extension(kvm_state, KVM_CAP_ARM_PSCI_0_2)) {
> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
> +                                      QEMU_PSCI_0_2_FN_CPU_SUSPEND);

None of these are needed for 0.2 binding. The function IDs are fixed.

> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off",
> +                                      QEMU_PSCI_0_2_FN_CPU_OFF);
> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on",
> +                                      QEMU_PSCI_0_2_FN_CPU_ON);
> +            qemu_fdt_setprop_cell(fdt, "/psci", "migrate",
> +                                      QEMU_PSCI_0_2_FN_MIGRATE);
> +            qemu_fdt_setprop_cell(fdt, "/psci", "system_off",
> +                                      QEMU_PSCI_0_2_FN_SYSTEM_OFF);
> +            qemu_fdt_setprop_cell(fdt, "/psci", "system_reset",
> +                                      QEMU_PSCI_0_2_FN_SYSTEM_RESET);
> +        } else {
> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
> +                                      QEMU_PSCI_FN_CPU_SUSPEND);
> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off",
> +                                      QEMU_PSCI_FN_CPU_OFF);
> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on",
> +                                      QEMU_PSCI_FN_CPU_ON);
> +            qemu_fdt_setprop_cell(fdt, "/psci", "migrate",
> +                                      QEMU_PSCI_FN_MIGRATE);
> +        }
>      }
>  }
>
> --
> 1.7.9.5
>
> _______________________________________________
> kvmarm mailing list
> kvmarm@lists.cs.columbia.edu
> https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PranavkumarSawargaonkar April 28, 2014, 9:36 a.m. UTC | #2
Hi Rob,

On 26 April 2014 00:17, Rob Herring <robherring2@gmail.com> wrote:
> On Thu, Apr 10, 2014 at 6:46 AM, Pranavkumar Sawargaonkar
> <pranavkumar@linaro.org> wrote:
>> If we have in-kernel emulation of PSCI v0.2 for KVM ARM/ARM64 then
>> we enable PSCI v0.2 for each VCPU at the time of VCPU init hence we
>> need to provide PSCI v0.2 function IDs via generated DTB.
>>
>> This patch updates generated DTB to have PSCI v0.2 function IDs when
>> we have in-kernel emulation PSCI v0.2 for KVM ARM/ARM64.
>>
>> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
>> Signed-off-by: Anup Patel <anup.patel@linaro.org>
>> ---
>>  hw/arm/virt.c |   28 +++++++++++++++++++++++-----
>>  1 file changed, 23 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> index 2bbc931..cf6a774 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -187,11 +187,29 @@ static void create_fdt(VirtBoardInfo *vbi)
>>          qemu_fdt_add_subnode(fdt, "/psci");
>>          qemu_fdt_setprop_string(fdt, "/psci", "compatible", "arm,psci");
>
> Read the binding document for psci 0.2 (not the PSCI spec example).
> This needs to be "arm,psci-0.2".
>
> The virt mach needs to provide either 0.1 only or 0.1 and 0.2 support.
> Providing both means both compatible strings and the function IDs for
> 0.1.
>
>>          qemu_fdt_setprop_string(fdt, "/psci", "method", "hvc");
>> -        qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
>> -                                  PSCI_FN_CPU_SUSPEND);
>> -        qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off", PSCI_FN_CPU_OFF);
>> -        qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on", PSCI_FN_CPU_ON);
>> -        qemu_fdt_setprop_cell(fdt, "/psci", "migrate", PSCI_FN_MIGRATE);
>> +        if (kvm_check_extension(kvm_state, KVM_CAP_ARM_PSCI_0_2)) {
>> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
>> +                                      QEMU_PSCI_0_2_FN_CPU_SUSPEND);
>
> None of these are needed for 0.2 binding. The function IDs are fixed.

Yes I am aware that we should be using 0.2 bindings, I was just waiting
for Ashwin's patches for PSCI 0.2 bindings.

I will update and test this patch based on v8 patches from Ashwin.
(http://www.spinics.net/lists/arm-kernel/msg326044.html).

>
>> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off",
>> +                                      QEMU_PSCI_0_2_FN_CPU_OFF);
>> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on",
>> +                                      QEMU_PSCI_0_2_FN_CPU_ON);
>> +            qemu_fdt_setprop_cell(fdt, "/psci", "migrate",
>> +                                      QEMU_PSCI_0_2_FN_MIGRATE);
>> +            qemu_fdt_setprop_cell(fdt, "/psci", "system_off",
>> +                                      QEMU_PSCI_0_2_FN_SYSTEM_OFF);
>> +            qemu_fdt_setprop_cell(fdt, "/psci", "system_reset",
>> +                                      QEMU_PSCI_0_2_FN_SYSTEM_RESET);
>> +        } else {
>> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
>> +                                      QEMU_PSCI_FN_CPU_SUSPEND);
>> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off",
>> +                                      QEMU_PSCI_FN_CPU_OFF);
>> +            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on",
>> +                                      QEMU_PSCI_FN_CPU_ON);
>> +            qemu_fdt_setprop_cell(fdt, "/psci", "migrate",
>> +                                      QEMU_PSCI_FN_MIGRATE);
>> +        }
>>      }
>>  }
>>
>> --
>> 1.7.9.5
>>
>> _______________________________________________
>> kvmarm mailing list
>> kvmarm@lists.cs.columbia.edu
>> https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Thanks,
Pranav
diff mbox

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 2bbc931..cf6a774 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -187,11 +187,29 @@  static void create_fdt(VirtBoardInfo *vbi)
         qemu_fdt_add_subnode(fdt, "/psci");
         qemu_fdt_setprop_string(fdt, "/psci", "compatible", "arm,psci");
         qemu_fdt_setprop_string(fdt, "/psci", "method", "hvc");
-        qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
-                                  PSCI_FN_CPU_SUSPEND);
-        qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off", PSCI_FN_CPU_OFF);
-        qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on", PSCI_FN_CPU_ON);
-        qemu_fdt_setprop_cell(fdt, "/psci", "migrate", PSCI_FN_MIGRATE);
+        if (kvm_check_extension(kvm_state, KVM_CAP_ARM_PSCI_0_2)) {
+            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
+                                      QEMU_PSCI_0_2_FN_CPU_SUSPEND);
+            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off",
+                                      QEMU_PSCI_0_2_FN_CPU_OFF);
+            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on",
+                                      QEMU_PSCI_0_2_FN_CPU_ON);
+            qemu_fdt_setprop_cell(fdt, "/psci", "migrate",
+                                      QEMU_PSCI_0_2_FN_MIGRATE);
+            qemu_fdt_setprop_cell(fdt, "/psci", "system_off",
+                                      QEMU_PSCI_0_2_FN_SYSTEM_OFF);
+            qemu_fdt_setprop_cell(fdt, "/psci", "system_reset",
+                                      QEMU_PSCI_0_2_FN_SYSTEM_RESET);
+        } else {
+            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
+                                      QEMU_PSCI_FN_CPU_SUSPEND);
+            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off",
+                                      QEMU_PSCI_FN_CPU_OFF);
+            qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on",
+                                      QEMU_PSCI_FN_CPU_ON);
+            qemu_fdt_setprop_cell(fdt, "/psci", "migrate",
+                                      QEMU_PSCI_FN_MIGRATE);
+        }
     }
 }