diff mbox

[V1,19/29] xen/arm: Create a fake PSCI node in dom0 device tree

Message ID 1377701263-3319-20-git-send-email-julien.grall@linaro.org
State Superseded, archived
Headers show

Commit Message

Julien Grall Aug. 28, 2013, 2:47 p.m. UTC
Xen uses PSCI to bring up secondary cpus for the guest.

Signed-off-by: Julien Grall <julien.grall@linaro.org>

---
    Changes in v2:
        - Use fdt_property_cell
---
 xen/arch/arm/domain_build.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

Comments

Ian Campbell Sept. 9, 2013, 11:41 a.m. UTC | #1
On Wed, 2013-08-28 at 15:47 +0100, Julien Grall wrote:
> Xen uses PSCI to bring up secondary cpus for the guest.

Does this account for/incorporate the changes in "dt: update PSCI
binding documentation for v0.2" from Rob Herring? Msg-di
<1377564633-31638-1-git-send-email-robherring2@gmail.com>

That might require actual code changes in Xen too I suppose?

Ian.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> 
> ---
>     Changes in v2:
>         - Use fdt_property_cell
> ---
>  xen/arch/arm/domain_build.c |   38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 11f247b..4c936c1 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -13,6 +13,7 @@
>  #include <xen/guest_access.h>
>  #include <asm/setup.h>
>  #include <asm/platform.h>
> +#include <asm/psci.h>
>  
>  #include <asm/gic.h>
>  #include <xen/irq.h>
> @@ -306,6 +307,38 @@ static int make_hypervisor_node(void *fdt, const struct dt_device_node *parent)
>      return res;
>  }
>  
> +static int make_psci_node(void *fdt, const struct dt_device_node *parent)
> +{
> +    int res;
> +
> +    DPRINT("Create PSCI node\n");
> +
> +    /* See linux Documentation/devicetree/bindings/arm/psci.txt */
> +    res = fdt_begin_node(fdt, "psci");
> +    if ( res )
> +        return res;
> +
> +    res = fdt_property_string(fdt, "compatible", "arm,psci");
> +    if ( res )
> +        return res;
> +
> +    res = fdt_property_string(fdt, "method", "hvc");
> +    if ( res )
> +        return res;
> +
> +    res = fdt_property_cell(fdt, "cpu_off", __PSCI_cpu_off);
> +    if ( res )
> +        return res;
> +
> +    res = fdt_property_cell(fdt, "cpu_on", __PSCI_cpu_on);
> +    if ( res )
> +        return res;
> +
> +    res = fdt_end_node(fdt);
> +
> +    return res;
> +}
> +
>  /* Map the device in the domain */
>  static int map_device(struct domain *d, const struct dt_device_node *dev)
>  {
> @@ -393,6 +426,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
>      {
>          DT_MATCH_COMPATIBLE("xen,xen"),
>          DT_MATCH_COMPATIBLE("xen,multiboot-module"),
> +        DT_MATCH_COMPATIBLE("arm,psci"),
>          { /* sentinel */ },
>      };
>      const struct dt_device_node *child;
> @@ -458,6 +492,10 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
>          res = make_hypervisor_node(kinfo->fdt, np);
>          if ( res )
>              return res;
> +
> +        res = make_psci_node(kinfo->fdt, np);
> +        if ( res )
> +            return res;
>      }
>  
>      res = fdt_end_node(kinfo->fdt);
Julien Grall Sept. 9, 2013, 10:04 p.m. UTC | #2
On 09/09/2013 12:41 PM, Ian Campbell wrote:
> On Wed, 2013-08-28 at 15:47 +0100, Julien Grall wrote:
>> Xen uses PSCI to bring up secondary cpus for the guest.
>
> Does this account for/incorporate the changes in "dt: update PSCI
> binding documentation for v0.2" from Rob Herring? Msg-di
> <1377564633-31638-1-git-send-email-robherring2@gmail.com>
>
> That might require actual code changes in Xen too I suppose?

I don't think, the PSCI code in Xen is generic. We will only have to 
update the current patch.

Do you know if Linux supports PSCI 0.2?

>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>>
>> ---
>>      Changes in v2:
>>          - Use fdt_property_cell
>> ---
>>   xen/arch/arm/domain_build.c |   38 ++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 38 insertions(+)
>>
>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> index 11f247b..4c936c1 100644
>> --- a/xen/arch/arm/domain_build.c
>> +++ b/xen/arch/arm/domain_build.c
>> @@ -13,6 +13,7 @@
>>   #include <xen/guest_access.h>
>>   #include <asm/setup.h>
>>   #include <asm/platform.h>
>> +#include <asm/psci.h>
>>
>>   #include <asm/gic.h>
>>   #include <xen/irq.h>
>> @@ -306,6 +307,38 @@ static int make_hypervisor_node(void *fdt, const struct dt_device_node *parent)
>>       return res;
>>   }
>>
>> +static int make_psci_node(void *fdt, const struct dt_device_node *parent)
>> +{
>> +    int res;
>> +
>> +    DPRINT("Create PSCI node\n");
>> +
>> +    /* See linux Documentation/devicetree/bindings/arm/psci.txt */
>> +    res = fdt_begin_node(fdt, "psci");
>> +    if ( res )
>> +        return res;
>> +
>> +    res = fdt_property_string(fdt, "compatible", "arm,psci");
>> +    if ( res )
>> +        return res;
>> +
>> +    res = fdt_property_string(fdt, "method", "hvc");
>> +    if ( res )
>> +        return res;
>> +
>> +    res = fdt_property_cell(fdt, "cpu_off", __PSCI_cpu_off);
>> +    if ( res )
>> +        return res;
>> +
>> +    res = fdt_property_cell(fdt, "cpu_on", __PSCI_cpu_on);
>> +    if ( res )
>> +        return res;
>> +
>> +    res = fdt_end_node(fdt);
>> +
>> +    return res;
>> +}
>> +
>>   /* Map the device in the domain */
>>   static int map_device(struct domain *d, const struct dt_device_node *dev)
>>   {
>> @@ -393,6 +426,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
>>       {
>>           DT_MATCH_COMPATIBLE("xen,xen"),
>>           DT_MATCH_COMPATIBLE("xen,multiboot-module"),
>> +        DT_MATCH_COMPATIBLE("arm,psci"),
>>           { /* sentinel */ },
>>       };
>>       const struct dt_device_node *child;
>> @@ -458,6 +492,10 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
>>           res = make_hypervisor_node(kinfo->fdt, np);
>>           if ( res )
>>               return res;
>> +
>> +        res = make_psci_node(kinfo->fdt, np);
>> +        if ( res )
>> +            return res;
>>       }
>>
>>       res = fdt_end_node(kinfo->fdt);
>
>
Ian Campbell Sept. 10, 2013, 9:04 a.m. UTC | #3
On Mon, 2013-09-09 at 23:04 +0100, Julien Grall wrote:
> On 09/09/2013 12:41 PM, Ian Campbell wrote:
> > On Wed, 2013-08-28 at 15:47 +0100, Julien Grall wrote:
> >> Xen uses PSCI to bring up secondary cpus for the guest.
> >
> > Does this account for/incorporate the changes in "dt: update PSCI
> > binding documentation for v0.2" from Rob Herring? Msg-di
> > <1377564633-31638-1-git-send-email-robherring2@gmail.com>
> >
> > That might require actual code changes in Xen too I suppose?
> 
> I don't think, the PSCI code in Xen is generic. We will only have to 
> update the current patch.

Stefano can probably remember the details but there were some meaningful
changes in PSCI 0.2, and in particular the calling mechanism and how it
is described in DTB has been improved.

> Do you know if Linux supports PSCI 0.2?

If it doesn't then it will very soon I expect.

> 
> >>
> >> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> >>
> >> ---
> >>      Changes in v2:
> >>          - Use fdt_property_cell
> >> ---
> >>   xen/arch/arm/domain_build.c |   38 ++++++++++++++++++++++++++++++++++++++
> >>   1 file changed, 38 insertions(+)
> >>
> >> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> >> index 11f247b..4c936c1 100644
> >> --- a/xen/arch/arm/domain_build.c
> >> +++ b/xen/arch/arm/domain_build.c
> >> @@ -13,6 +13,7 @@
> >>   #include <xen/guest_access.h>
> >>   #include <asm/setup.h>
> >>   #include <asm/platform.h>
> >> +#include <asm/psci.h>
> >>
> >>   #include <asm/gic.h>
> >>   #include <xen/irq.h>
> >> @@ -306,6 +307,38 @@ static int make_hypervisor_node(void *fdt, const struct dt_device_node *parent)
> >>       return res;
> >>   }
> >>
> >> +static int make_psci_node(void *fdt, const struct dt_device_node *parent)
> >> +{
> >> +    int res;
> >> +
> >> +    DPRINT("Create PSCI node\n");
> >> +
> >> +    /* See linux Documentation/devicetree/bindings/arm/psci.txt */
> >> +    res = fdt_begin_node(fdt, "psci");
> >> +    if ( res )
> >> +        return res;
> >> +
> >> +    res = fdt_property_string(fdt, "compatible", "arm,psci");
> >> +    if ( res )
> >> +        return res;
> >> +
> >> +    res = fdt_property_string(fdt, "method", "hvc");
> >> +    if ( res )
> >> +        return res;
> >> +
> >> +    res = fdt_property_cell(fdt, "cpu_off", __PSCI_cpu_off);
> >> +    if ( res )
> >> +        return res;
> >> +
> >> +    res = fdt_property_cell(fdt, "cpu_on", __PSCI_cpu_on);
> >> +    if ( res )
> >> +        return res;
> >> +
> >> +    res = fdt_end_node(fdt);
> >> +
> >> +    return res;
> >> +}
> >> +
> >>   /* Map the device in the domain */
> >>   static int map_device(struct domain *d, const struct dt_device_node *dev)
> >>   {
> >> @@ -393,6 +426,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
> >>       {
> >>           DT_MATCH_COMPATIBLE("xen,xen"),
> >>           DT_MATCH_COMPATIBLE("xen,multiboot-module"),
> >> +        DT_MATCH_COMPATIBLE("arm,psci"),
> >>           { /* sentinel */ },
> >>       };
> >>       const struct dt_device_node *child;
> >> @@ -458,6 +492,10 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
> >>           res = make_hypervisor_node(kinfo->fdt, np);
> >>           if ( res )
> >>               return res;
> >> +
> >> +        res = make_psci_node(kinfo->fdt, np);
> >> +        if ( res )
> >> +            return res;
> >>       }
> >>
> >>       res = fdt_end_node(kinfo->fdt);
> >
> >
>
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 11f247b..4c936c1 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -13,6 +13,7 @@ 
 #include <xen/guest_access.h>
 #include <asm/setup.h>
 #include <asm/platform.h>
+#include <asm/psci.h>
 
 #include <asm/gic.h>
 #include <xen/irq.h>
@@ -306,6 +307,38 @@  static int make_hypervisor_node(void *fdt, const struct dt_device_node *parent)
     return res;
 }
 
+static int make_psci_node(void *fdt, const struct dt_device_node *parent)
+{
+    int res;
+
+    DPRINT("Create PSCI node\n");
+
+    /* See linux Documentation/devicetree/bindings/arm/psci.txt */
+    res = fdt_begin_node(fdt, "psci");
+    if ( res )
+        return res;
+
+    res = fdt_property_string(fdt, "compatible", "arm,psci");
+    if ( res )
+        return res;
+
+    res = fdt_property_string(fdt, "method", "hvc");
+    if ( res )
+        return res;
+
+    res = fdt_property_cell(fdt, "cpu_off", __PSCI_cpu_off);
+    if ( res )
+        return res;
+
+    res = fdt_property_cell(fdt, "cpu_on", __PSCI_cpu_on);
+    if ( res )
+        return res;
+
+    res = fdt_end_node(fdt);
+
+    return res;
+}
+
 /* Map the device in the domain */
 static int map_device(struct domain *d, const struct dt_device_node *dev)
 {
@@ -393,6 +426,7 @@  static int handle_node(struct domain *d, struct kernel_info *kinfo,
     {
         DT_MATCH_COMPATIBLE("xen,xen"),
         DT_MATCH_COMPATIBLE("xen,multiboot-module"),
+        DT_MATCH_COMPATIBLE("arm,psci"),
         { /* sentinel */ },
     };
     const struct dt_device_node *child;
@@ -458,6 +492,10 @@  static int handle_node(struct domain *d, struct kernel_info *kinfo,
         res = make_hypervisor_node(kinfo->fdt, np);
         if ( res )
             return res;
+
+        res = make_psci_node(kinfo->fdt, np);
+        if ( res )
+            return res;
     }
 
     res = fdt_end_node(kinfo->fdt);