Skip to contentSkip to conversation

xen/arm: Add support for Huawei hip04-d01 platform

PATCH In review Frediano Ziglio 4 participants 36 messages Nov 3, 2014 – Feb 19, 2015

lore
Share & tools
lore
#0 lore raw

This set of patches add Xen support for hip04-d01 platform (see https://wiki.linaro.org/Boards/D01 for details).

The patch "xen/arm: Move vGIC registers on Hip04 platform" is actually a workaround and should have in the future a proper implementation in Xen (unfortunately not straightforward to do it).

#1 lore raw

PATCH 1/10 xen/arm: Implement hip04-d01 platform

Add this new platform to Xen.
This platform require specific code to initialize CPUs.

---
 xen/arch/arm/platforms/Makefile |   1 +
 xen/arch/arm/platforms/hip04.c  | 258 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 259 insertions(+)
 create mode 100644 xen/arch/arm/platforms/hip04.c
xen/arch/arm/platforms/Makefile +1 -0
index 8f47c16..d0b2d99 100644
@@ -5,4 +5,5 @@ obj-$(CONFIG_ARM_32) += midway.o
 obj-$(CONFIG_ARM_32) += omap5.o
 obj-$(CONFIG_ARM_32) += sunxi.o
 obj-$(CONFIG_ARM_64) += seattle.o
+obj-$(CONFIG_ARM_32) += hip04.o
 obj-$(CONFIG_ARM_64) += xgene-storm.o
xen/arch/arm/platforms/hip04.c new file +258 -0

258 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 01/10] xen/arm: Implement hip04-d01 platform

Hi Frediano,

Quoted 2 lines · Frediano Ziglio

Add this new platform to Xen.
This platform require specific code to initialize CPUs.

s/require/requires/

I guess your platform doesn't support PSCI?

Quoted 4 lines

---

[..]

Quoted 6 lines
xen/arch/arm/platforms/hip04.c new file +0 -0
new file mode 100644
index 0000000..bf38c23
@@ -0,0 +1,258 @@

[..]

xen/arch/arm/platforms/hip04.c

Quoted 2 lines
xen/arch/arm/platforms/hip04.c new file +2 -0
+
+struct hip04_secondary_cpu_data {

coding style:

struct hip04_secondary_cpu_data
{

Quoted 4 lines
xen/arch/arm/platforms/hip04.c new file +4 -0
+    u32 bootwrapper_phys;
+    u32 bootwrapper_size;
+    u32 bootwrapper_magic;
+    u32 relocation_entry;

xen/arch/arm/platforms/hip04.c line 62

Quoted 10 lines
xen/arch/arm/platforms/hip04.c new file +10 -0
+    u32 relocation_size;
+};
+
+static void __iomem *relocation, *sysctrl, *fabric;
+static int hip04_cpu_table[HIP04_MAX_CLUSTERS][HIP04_MAX_CPUS_PER_CLUSTER];
+static struct hip04_secondary_cpu_data hip04_boot;
+
+static void hip04_reset(void)
+{
+    /* TODO */

Why did you implement the reset in a separate patch rather than here?

xen/arch/arm/platforms/hip04.c line 69

Quoted 7 lines
xen/arch/arm/platforms/hip04.c new file +7 -0
+}
+
+static void hip04_set_snoop_filter(unsigned int cluster, unsigned int on)
+{
+    unsigned long data;
+
+    if (!fabric)

Coding style:

if ( !fabric )

xen/arch/arm/platforms/hip04.c line 72

Quoted 3 lines
xen/arch/arm/platforms/hip04.c new file +3 -0
+        return;
+    data = readl_relaxed(fabric + FAB_SF_MODE);
+    if (on)

if ( on )

xen/arch/arm/platforms/hip04.c line 77

Quoted 5 lines
xen/arch/arm/platforms/hip04.c new file +5 -0
+        data |= 1 << cluster;
+    else
+        data &= ~(1 << cluster);
+    writel_relaxed(data, fabric + FAB_SF_MODE);
+    while (1) {

while ( 1 )
{

Quoted 1 line

+ if (data == readl_relaxed(fabric + FAB_SF_MODE))

if ( ... )

xen/arch/arm/platforms/hip04.c

Quoted 2 lines
xen/arch/arm/platforms/hip04.c new file +2 -0
+            break;
+    }

The loop is turning in an infinite loop if the reading value is never correct.

xen/arch/arm/platforms/hip04.c line 92

Quoted 12 lines
xen/arch/arm/platforms/hip04.c new file +12 -0
+}
+
+static bool __init hip04_cpu_table_init(void)
+{
+    unsigned int mpidr, cpu, cluster;
+
+    mpidr = cpu_logical_map(smp_processor_id());
+    cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
+    cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
+
+    if (cluster >= HIP04_MAX_CLUSTERS ||
+        cpu >= HIP04_MAX_CPUS_PER_CLUSTER) {

if ( ...

     ... )

{

xen/arch/arm/platforms/hip04.c line 97

Quoted 5 lines
xen/arch/arm/platforms/hip04.c new file +5 -0
+        printk(XENLOG_ERR "%s: boot CPU is out of bound!\n", __func__);
+        return false;
+    }
+    hip04_set_snoop_filter(cluster, 1);
+    hip04_cpu_table[cluster][cpu] = 1;

Missing blank line

xen/arch/arm/platforms/hip04.c line 105

Quoted 8 lines
xen/arch/arm/platforms/hip04.c new file +8 -0
+    return true;
+}
+
+static bool hip04_cluster_down(unsigned int cluster)
+{
+    int i;
+
+    for (i = 0; i < HIP04_MAX_CPUS_PER_CLUSTER; i++)

for ( ... )

Quoted 1 line

+ if (hip04_cpu_table[cluster][i])

if ( ... )

xen/arch/arm/platforms/hip04.c line 115

Quoted 9 lines
xen/arch/arm/platforms/hip04.c new file +9 -0
+            return false;
+    return true;
+}
+
+static void hip04_cluster_up(unsigned int cluster)
+{
+    unsigned long data, mask;
+
+    if ( hip04_cluster_down(cluster) ) {

Wouldn't it be easier to return if the cluster is up? It will one layer of indentation.

Quoted 5 lines
xen/arch/arm/platforms/hip04.c new file +5 -0
+        data = CLUSTER_L2_RESET_BIT | CLUSTER_DEBUG_RESET_BIT;
+        writel_relaxed(data, sysctrl + SC_CPU_RESET_DREQ(cluster));
+        do {
+            mask = CLUSTER_L2_RESET_STATUS | \
+                   CLUSTER_DEBUG_RESET_STATUS;

xen/arch/arm/platforms/hip04.c line 130

Quoted 10 lines
xen/arch/arm/platforms/hip04.c new file +10 -0
+            data = readl_relaxed(sysctrl + \
+                         SC_CPU_RESET_STATUS(cluster));
+        } while (data & mask);
+        hip04_set_snoop_filter(cluster, 1);
+    }
+}
+
+static int __init hip04_smp_init(void)
+{
+    struct dt_device_node *np, *np_fab;

The device node are not modified so:

const struct

[..]

xen/arch/arm/platforms/hip04.c line 200

Quoted 8 lines
xen/arch/arm/platforms/hip04.c new file +8 -0
+    writel_relaxed(hip04_boot.bootwrapper_phys, relocation);
+    writel_relaxed(hip04_boot.bootwrapper_magic, relocation + 4);
+    writel_relaxed(__pa(init_secondary), relocation + 8);
+    writel_relaxed(0, relocation + 12);
+
+    return 0;
+
+err:

For consistence, you should unmap everything you mapped with ioremap_*

xen/arch/arm/platforms/hip04.c line 207

Quoted 7 lines
xen/arch/arm/platforms/hip04.c new file +7 -0
+    printk("%s", msg);
+    return -ENXIO;
+}
+
+static int hip04_cpu_up(int cpu)
+{
+    unsigned int cluster = cpu / 4;

The number 4 is confusing here, why not using the define you've created above? Such as HIP04_MAX_CPUS_PER_CLUSTER

Quoted 1 line

+ unsigned long data;

The coding style requires a blank line after the declarations block.

Quoted 1 line

+ cpu %= 4;

Ditto for the number 4.

Regards,

Signature · 1 line
Julien Grall
#3 lore raw

Re: [PATCH 01/10] xen/arm: Implement hip04-d01 platform

In reply to Frediano Ziglio
Quoted 2 lines · Frediano Ziglio

Add this new platform to Xen.
This platform require specific code to initialize CPUs.

What is the "bootwrapper"? Are you running this on real silicon or on an emulator? Can the platform be made to do PSCI instead?

Quoted 1 line

+ np_fab = dt_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric");

Please add a reference to the DT bindings document for these values.

linux/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt seems related but doesn't talk about most of these fields.

Quoted 28 lines
xen/arch/arm/platforms/hip04.c new file +28 -0
+    msg = "hisilicon,hip04-fabric missing in DT\n";
+    if ( !np_fab )
+        goto err;
+
+    msg = "failed to get bootwrapper-phys\n";
+    if ( !dt_property_read_u32(np, "bootwrapper-phys",
+                               &hip04_boot.bootwrapper_phys) )
+        goto err;
+
+    msg = "failed to get bootwrapper-size\n";
+    if ( !dt_property_read_u32(np, "bootwrapper-size",
+                               &hip04_boot.bootwrapper_size) )
+        goto err;
+
+    msg = "failed to get bootwrapper-magic\n";
+    if ( !dt_property_read_u32(np, "bootwrapper-magic",
+                               &hip04_boot.bootwrapper_magic) )
+        goto err;
+
+    msg = "failed to get relocation-entry\n";
+    if ( !dt_property_read_u32(np, "relocation-entry",
+                               &hip04_boot.relocation_entry) )
+        goto err;
+
+    msg = "failed to get relocation-size\n";
+    if ( !dt_property_read_u32(np, "relocation-size",
+                 &hip04_boot.relocation_size) )
+        goto err;
#4 lore raw

Re: [PATCH 01/10] xen/arm: Implement hip04-d01 platform

2015-01-13 11:58 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 7 lines · Frediano Ziglio
Quoted 2 lines

Add this new platform to Xen.
This platform require specific code to initialize CPUs.

What is the "bootwrapper"? Are you running this on real silicon or on an emulator? Can the platform be made to do PSCI instead?

Very real. It's actually on my desk and I'm not in Matrix :-) Has no PSCI support. Would be honestly very great. As we (as company) write the firmware could be technically doable. There is no plan. This piece of software is meant to bring the CPU from Secure mode to Unsecure Hypervisor mode before calling kernel/hypervisor code and provide supervisor calls.

Quoted 7 lines
Quoted 1 line

+ np_fab = dt_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric");

Please add a reference to the DT bindings document for these values.

linux/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt seems related but doesn't talk about most of these fields.

There are documentation in the Linaro kernel, see
https://git.linaro.org/kernel/linux-linaro-tracking.git/blob/HEAD:/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt.
I hope it will be merged soon.

Frediano

#5 lore raw

Re: [PATCH 01/10] xen/arm: Implement hip04-d01 platform

Quoted 10 lines · Frediano Ziglio

2015-01-13 11:58 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 7 lines · Frediano Ziglio
Quoted 2 lines

Add this new platform to Xen.
This platform require specific code to initialize CPUs.

What is the "bootwrapper"? Are you running this on real silicon or on an emulator? Can the platform be made to do PSCI instead?

Very real. It's actually on my desk and I'm not in Matrix :-)

OK. The choice of bootwrapper as a name is a bit unfortunate, since it is already used for something else, but oh well.

Quoted 5 lines

Has no PSCI support. Would be honestly very great. As we (as company) write the firmware could be technically doable. There is no plan. This piece of software is meant to bring the CPU from Secure mode to Unsecure Hypervisor mode before calling kernel/hypervisor code and provide supervisor calls.

Sounds a lot like PSCI to me, except non-standard ;-)

Quoted 11 lines
Quoted 7 lines
Quoted 1 line

+ np_fab = dt_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric");

Please add a reference to the DT bindings document for these values.

linux/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt seems related but doesn't talk about most of these fields.

There are documentation in the Linaro kernel, see
https://git.linaro.org/kernel/linux-linaro-tracking.git/blob/HEAD:/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt.
I hope it will be merged soon.

Thanks, but this doesn't seem to cover many of the properties used by the code you are adding, e.g. bootwrapper-{size,magic}, relocation-{entry,size} (in fact it suggests they are part of a boot-method array).

I get the feeling these might be legacy/deprecated. Perhaps we could get away without supporting such things?

Ian.

#6 lore raw

Re: [PATCH 01/10] xen/arm: Implement hip04-d01 platform

2015-01-13 14:42 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 40 lines · Frediano Ziglio
Quoted 10 lines

2015-01-13 11:58 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 7 lines · Frediano Ziglio
Quoted 2 lines

Add this new platform to Xen.
This platform require specific code to initialize CPUs.

What is the "bootwrapper"? Are you running this on real silicon or on an emulator? Can the platform be made to do PSCI instead?

Very real. It's actually on my desk and I'm not in Matrix :-)

OK. The choice of bootwrapper as a name is a bit unfortunate, since it is already used for something else, but oh well.

Quoted 5 lines

Has no PSCI support. Would be honestly very great. As we (as company) write the firmware could be technically doable. There is no plan. This piece of software is meant to bring the CPU from Secure mode to Unsecure Hypervisor mode before calling kernel/hypervisor code and provide supervisor calls.

Sounds a lot like PSCI to me, except non-standard ;-)

Quoted 11 lines
Quoted 7 lines
Quoted 1 line

+ np_fab = dt_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric");

Please add a reference to the DT bindings document for these values.

linux/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt seems related but doesn't talk about most of these fields.

There are documentation in the Linaro kernel, see
https://git.linaro.org/kernel/linux-linaro-tracking.git/blob/HEAD:/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt.
I hope it will be merged soon.

Thanks, but this doesn't seem to cover many of the properties used by the code you are adding, e.g. bootwrapper-{size,magic}, relocation-{entry,size} (in fact it suggests they are part of a boot-method array).

Quoted 5 lines

I get the feeling these might be legacy/deprecated. Perhaps we could get away without supporting such things?

Ian.

No, this is the newest code. Yes, PSCI would be definitively much better and way more standard.

Frediano

#7 lore raw

Re: [PATCH 01/10] xen/arm: Implement hip04-d01 platform

Quoted 41 lines · Frediano Ziglio

2015-01-13 14:42 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 40 lines · Frediano Ziglio
Quoted 10 lines

2015-01-13 11:58 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 7 lines · Frediano Ziglio
Quoted 2 lines

Add this new platform to Xen.
This platform require specific code to initialize CPUs.

What is the "bootwrapper"? Are you running this on real silicon or on an emulator? Can the platform be made to do PSCI instead?

Very real. It's actually on my desk and I'm not in Matrix :-)

OK. The choice of bootwrapper as a name is a bit unfortunate, since it is already used for something else, but oh well.

Quoted 5 lines

Has no PSCI support. Would be honestly very great. As we (as company) write the firmware could be technically doable. There is no plan. This piece of software is meant to bring the CPU from Secure mode to Unsecure Hypervisor mode before calling kernel/hypervisor code and provide supervisor calls.

Sounds a lot like PSCI to me, except non-standard ;-)

Quoted 11 lines
Quoted 7 lines
Quoted 1 line

+ np_fab = dt_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric");

Please add a reference to the DT bindings document for these values.

linux/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt seems related but doesn't talk about most of these fields.

There are documentation in the Linaro kernel, see
https://git.linaro.org/kernel/linux-linaro-tracking.git/blob/HEAD:/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt.
I hope it will be merged soon.

Thanks, but this doesn't seem to cover many of the properties used by the code you are adding, e.g. bootwrapper-{size,magic}, relocation-{entry,size} (in fact it suggests they are part of a boot-method array).

Quoted 7 lines
Quoted 5 lines

I get the feeling these might be legacy/deprecated. Perhaps we could get away without supporting such things?

Ian.

No, this is the newest code.

So in this:

    if ( !dt_property_read_u32(np, "bootwrapper-phys",
                               &hip04_boot.bootwrapper_phys) ) {
[...read boot-method array...]
    }
    else
    {
[... read a bunch of separate properties...]
    }

Both sides of the if are used by non-legacy code? That's,... unfortunate.

I note that only the if case, not the else case, is covered by the hisilicon.txt bindings...

Ian.

#8 lore raw

Re: [PATCH 01/10] xen/arm: Implement hip04-d01 platform

2015-01-13 15:23 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 60 lines · Frediano Ziglio
Quoted 41 lines

2015-01-13 14:42 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 40 lines · Frediano Ziglio
Quoted 10 lines

2015-01-13 11:58 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 7 lines · Frediano Ziglio
Quoted 2 lines

Add this new platform to Xen.
This platform require specific code to initialize CPUs.

What is the "bootwrapper"? Are you running this on real silicon or on an emulator? Can the platform be made to do PSCI instead?

Very real. It's actually on my desk and I'm not in Matrix :-)

OK. The choice of bootwrapper as a name is a bit unfortunate, since it is already used for something else, but oh well.

Quoted 5 lines

Has no PSCI support. Would be honestly very great. As we (as company) write the firmware could be technically doable. There is no plan. This piece of software is meant to bring the CPU from Secure mode to Unsecure Hypervisor mode before calling kernel/hypervisor code and provide supervisor calls.

Sounds a lot like PSCI to me, except non-standard ;-)

Quoted 11 lines
Quoted 7 lines
Quoted 1 line

+ np_fab = dt_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric");

Please add a reference to the DT bindings document for these values.

linux/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt seems related but doesn't talk about most of these fields.

There are documentation in the Linaro kernel, see
https://git.linaro.org/kernel/linux-linaro-tracking.git/blob/HEAD:/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt.
I hope it will be merged soon.

Thanks, but this doesn't seem to cover many of the properties used by the code you are adding, e.g. bootwrapper-{size,magic}, relocation-{entry,size} (in fact it suggests they are part of a boot-method array).

Quoted 7 lines
Quoted 5 lines

I get the feeling these might be legacy/deprecated. Perhaps we could get away without supporting such things?

Ian.

No, this is the newest code.

So in this:

    if ( !dt_property_read_u32(np, "bootwrapper-phys",
                               &hip04_boot.bootwrapper_phys) ) {
[...read boot-method array...]
    }
    else
    {
[... read a bunch of separate properties...]
    }
Quoted 8 lines

Both sides of the if are used by non-legacy code? That's,... unfortunate.

I note that only the if case, not the else case, is covered by the hisilicon.txt bindings...

Ian.

Yes, you are right, there are actually two versions of these settings. Actually there has been a lot of bouncing between the two versions. We are also having some discussion on Linaro ML about implementing PSCI.

Frediano

#9 lore raw

Re: [PATCH 01/10] xen/arm: Implement hip04-d01 platform

2015-01-13 15:48 GMT+00:00 Frediano Ziglio <[email protected]>:

Quoted 67 lines

2015-01-13 15:23 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 66 lines · Frediano Ziglio
Quoted 41 lines

2015-01-13 14:42 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 40 lines · Frediano Ziglio
Quoted 10 lines

2015-01-13 11:58 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 7 lines · Frediano Ziglio
Quoted 2 lines

Add this new platform to Xen.
This platform require specific code to initialize CPUs.

What is the "bootwrapper"? Are you running this on real silicon or on an emulator? Can the platform be made to do PSCI instead?

Very real. It's actually on my desk and I'm not in Matrix :-)

OK. The choice of bootwrapper as a name is a bit unfortunate, since it is already used for something else, but oh well.

Quoted 5 lines

Has no PSCI support. Would be honestly very great. As we (as company) write the firmware could be technically doable. There is no plan. This piece of software is meant to bring the CPU from Secure mode to Unsecure Hypervisor mode before calling kernel/hypervisor code and provide supervisor calls.

Sounds a lot like PSCI to me, except non-standard ;-)

Quoted 11 lines
Quoted 7 lines
Quoted 1 line

+ np_fab = dt_find_compatible_node(NULL, NULL, "hisilicon,hip04-fabric");

Please add a reference to the DT bindings document for these values.

linux/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt seems related but doesn't talk about most of these fields.

There are documentation in the Linaro kernel, see
https://git.linaro.org/kernel/linux-linaro-tracking.git/blob/HEAD:/Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt.
I hope it will be merged soon.

Thanks, but this doesn't seem to cover many of the properties used by the code you are adding, e.g. bootwrapper-{size,magic}, relocation-{entry,size} (in fact it suggests they are part of a boot-method array).

Quoted 7 lines
Quoted 5 lines

I get the feeling these might be legacy/deprecated. Perhaps we could get away without supporting such things?

Ian.

No, this is the newest code.

So in this:

    if ( !dt_property_read_u32(np, "bootwrapper-phys",
                               &hip04_boot.bootwrapper_phys) ) {
[...read boot-method array...]
    }
    else
    {
[... read a bunch of separate properties...]
    }

Both sides of the if are used by non-legacy code? That's,... unfortunate.

I note that only the if case, not the else case, is covered by the hisilicon.txt bindings...

Quoted 7 lines
Quoted 2 lines

Ian.

Yes, you are right, there are actually two versions of these settings. Actually there has been a lot of bouncing between the two versions. We are also having some discussion on Linaro ML about implementing PSCI.

Hi,
I finally finish to do a PSCI implementation in the boot wrapper
for this platform. You can find it at
https://github.com/freddy77/bootwrapper/tree/psci. It works fine with Xen which is able to setup CPUs and reboot correctly without using platform code.

I actually wondering why the branch at
http://xenbits.xen.org/gitweb/?p=people/julieng/xen-unstable.git;a=shortlog;h=refs/heads/hisilicon-d01-v3
was not merged into the master branch after the release. Actually using the above boot wrapper I was able to remove two patches from the patchset. See https://github.com/freddy77/xen/commits/frediano/use_psci.

Why this patch was not integrated?
http://xenbits.xen.org/gitweb/?p=people/julieng/xen-unstable.git;a=commitdiff;h=612816078b81e3b244d61843f0c27830bbf3da69.
It was not related specifically to board and already discussed.

Frediano

#10 lore raw

Re: [PATCH 01/10] xen/arm: Implement hip04-d01 platform

Quoted 3 lines · Frediano Ziglio

I actually wondering why the branch at
http://xenbits.xen.org/gitweb/?p=people/julieng/xen-unstable.git;a=shortlog;h=refs/heads/hisilicon-d01-v3
was not merged into the master branch after the release.

Because AFAIK it hasn't been resubmitted as a patch series or pinged since the release.

It seems like it needs reworking to drop the old SMP code in favour of PSCI anyway.

Ian.

#11 lore raw

PATCH 2/10 xen/arm: Implement hip04-d01 board reboot

In reply to Frediano Ziglio
---
 xen/arch/arm/platforms/hip04.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
xen/arch/arm/platforms/hip04.c +16 -2
index bf38c23..62d2034 100644
@@ -27,6 +27,7 @@
 #include <xen/vmap.h>
 #include <asm/io.h>
 #include <asm/gic.h>
+#include <xen/delay.h>
 
 #define CORE_RESET_BIT(x)            (1 << x)
 #define NEON_RESET_BIT(x)            (1 << (x + 4))
@@ -53,13 +54,21 @@ struct hip04_secondary_cpu_data {
     u32 relocation_size;
 };
 
-static void __iomem *relocation, *sysctrl, *fabric;
+static void __iomem *relocation, *sysctrl, *fabric, *gb2;
 static int hip04_cpu_table[HIP04_MAX_CLUSTERS][HIP04_MAX_CPUS_PER_CLUSTER];
 static struct hip04_secondary_cpu_data hip04_boot;
 
 static void hip04_reset(void)
 {
-    /* TODO */
+    unsigned long data;
+
+    if ( !gb2 )
+        return;
+
+    data = readl_relaxed(gb2);
+    writel_relaxed(data & ~0x4000000u, gb2);
+
+    mdelay(10);
 }
 
 static void hip04_set_snoop_filter(unsigned int cluster, unsigned int on)
@@ -186,6 +195,11 @@ static int __init hip04_smp_init(void)
     if ( !fabric )
         goto err;
 
+    msg = "Error mapping GB2\n";
+    gb2 = ioremap_nocache(0xe4002000, 0x1000);
+    if ( !gb2 )
+        goto err;
+
     msg = "Error initializing SMP table\n";
     if ( !hip04_cpu_table_init() )
         goto err;
Signature · 1 line
1.9.1
#12 lore raw

Re: [PATCH 02/10] xen/arm: Implement hip04-d01 board reboot

Hi Frediano,

I would fold this patch in #1.

Regards,

Quoted 54 lines · Frediano Ziglio
---
 xen/arch/arm/platforms/hip04.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
xen/arch/arm/platforms/hip04.c +16 -2
index bf38c23..62d2034 100644
@@ -27,6 +27,7 @@
 #include <xen/vmap.h>
 #include <asm/io.h>
 #include <asm/gic.h>
+#include <xen/delay.h>
 
 #define CORE_RESET_BIT(x)            (1 << x)
 #define NEON_RESET_BIT(x)            (1 << (x + 4))
@@ -53,13 +54,21 @@ struct hip04_secondary_cpu_data {
     u32 relocation_size;
 };
 
-static void __iomem *relocation, *sysctrl, *fabric;
+static void __iomem *relocation, *sysctrl, *fabric, *gb2;
 static int hip04_cpu_table[HIP04_MAX_CLUSTERS][HIP04_MAX_CPUS_PER_CLUSTER];
 static struct hip04_secondary_cpu_data hip04_boot;
 
 static void hip04_reset(void)
 {
-    /* TODO */
+    unsigned long data;
+
+    if ( !gb2 )
+        return;
+
+    data = readl_relaxed(gb2);
+    writel_relaxed(data & ~0x4000000u, gb2);
+
+    mdelay(10);
 }
 
 static void hip04_set_snoop_filter(unsigned int cluster, unsigned int on)
@@ -186,6 +195,11 @@ static int __init hip04_smp_init(void)
     if ( !fabric )
         goto err;
 
+    msg = "Error mapping GB2\n";
+    gb2 = ioremap_nocache(0xe4002000, 0x1000);
+    if ( !gb2 )
+        goto err;
+
     msg = "Error initializing SMP table\n";
     if ( !hip04_cpu_table_init() )
         goto err;
Signature · 1 line
Julien Grall
#13 lore raw

PATCH 3/10 xen/arm: Define quirk for Hip04 GICv2 divergence

In reply to Frediano Ziglio

From: Zoltan Kiss <[email protected]>

---
 xen/arch/arm/platforms/hip04.c | 6 ++++++
 xen/include/asm-arm/platform.h | 5 +++++
 2 files changed, 11 insertions(+)
xen/arch/arm/platforms/hip04.c +6 -0
index 62d2034..024c8a0 100644
@@ -253,12 +253,18 @@ static const struct dt_device_match hip04_blacklist_dev[] __initconst =
     { /* sentinel */ },
 };
 
+static uint32_t hip04_quirks(void)
+{
+    return PLATFORM_QUIRK_GICV2_16_CPU;
+}
+
 
 PLATFORM_START(hip04, "HISILICON HIP04")
     .compatible = hip04_dt_compat,
     .smp_init = hip04_smp_init,
     .cpu_up = hip04_cpu_up,
     .reset = hip04_reset,
+    .quirks = hip04_quirks,
     .blacklist_dev = hip04_blacklist_dev,
 PLATFORM_END
 
xen/include/asm-arm/platform.h +5 -0
index eefaca6..537fba5 100644
@@ -60,6 +60,11 @@ struct platform_desc {
  */
 #define PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI       (1 << 1)
 
+/*
+ * Quirk for platforms where GICv2 has to handle 16 CPUs
+ */
+#define PLATFORM_QUIRK_GICV2_16_CPU       (1 << 2)
+
 void __init platform_init(void);
 int __init platform_init_time(void);
 int __init platform_specific_mapping(struct domain *d);
Signature · 1 line
1.9.1
#14 lore raw

Re: [PATCH 03/10] xen/arm: Define quirk for Hip04 GICv2 divergence

Hi Frediano,

This could be fold in #4.

Quoted 36 lines · Frediano Ziglio

From: Zoltan Kiss <[email protected]>

---
 xen/arch/arm/platforms/hip04.c | 6 ++++++
 xen/include/asm-arm/platform.h | 5 +++++
 2 files changed, 11 insertions(+)
xen/arch/arm/platforms/hip04.c +6 -0
index 62d2034..024c8a0 100644
@@ -253,12 +253,18 @@ static const struct dt_device_match hip04_blacklist_dev[] __initconst =
     { /* sentinel */ },
 };
 
+static uint32_t hip04_quirks(void)
+{
+    return PLATFORM_QUIRK_GICV2_16_CPU;
+}
+
 
 PLATFORM_START(hip04, "HISILICON HIP04")
     .compatible = hip04_dt_compat,
     .smp_init = hip04_smp_init,
     .cpu_up = hip04_cpu_up,
     .reset = hip04_reset,
+    .quirks = hip04_quirks,
     .blacklist_dev = hip04_blacklist_dev,
 PLATFORM_END
 
xen/include/asm-arm/platform.h +0 -0
index eefaca6..537fba5 100644

xen/include/asm-arm/platform.h struct platform_desc { · line 67

Quoted 8 lines
xen/include/asm-arm/platform.h +5 -0
@@ -60,6 +60,11 @@ struct platform_desc {
  */
 #define PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI       (1 << 1)
 
+/*
+ * Quirk for platforms where GICv2 has to handle 16 CPUs
+ */
+#define PLATFORM_QUIRK_GICV2_16_CPU       (1 << 2)
+

Actually you use the quirk to do hisilicon specific (mostly in patch #6). I would rename the quirk to show it's platform specific, something like:

PLATFORM_QUIRK_HISILICON_GICV2 or PLATFROM_QUIRK_HISILICON_GICV2_16_CPU.

Regards,

Signature · 1 line
Julien Grall
#15 lore raw

Re: [PATCH 03/10] xen/arm: Define quirk for Hip04 GICv2 divergence

Quoted 5 lines · Julien Grall

Actually you use the quirk to do hisilicon specific (mostly in patch #6). I would rename the quirk to show it's platform specific, something like:

PLATFORM_QUIRK_HISILICON_GICV2 or PLATFROM_QUIRK_HISILICON_GICV2_16_CPU.

I think this should be keyed of the DT compatible string, since there is one, it's not really a quirk, it's essentially implementing a different hardware spec.

Ian.

#16 lore raw

PATCH 4/10 xen/arm: Make gic-v2 code handle hip04-d01 platform

In reply to Frediano Ziglio

The GIC in this platform is mainly compatible with the standard GICv2 beside:
- ITARGET is extended to 16 bit to support 16 CPUs;
- SGI mask is extended to support 16 CPUs;
- maximum supported interrupt is 510.

---
 xen/arch/arm/gic-v2.c     | 70 ++++++++++++++++++++++++++++++++++++++---------
 xen/arch/arm/gic.c        |  5 +++-
 xen/include/asm-arm/gic.h |  4 ++-
 3 files changed, 64 insertions(+), 15 deletions(-)
xen/arch/arm/gic-v2.c +57 -13
index faad1ff..eef55ed 100644
@@ -79,16 +79,22 @@ static struct gic_info gicv2_info;
  * logical CPU numbering. Let's use mapping as returned by the GIC
  * itself
  */
-static DEFINE_PER_CPU(u8, gic_cpu_id);
+static DEFINE_PER_CPU(u16, gic_cpu_id);
 
 /* Maximum cpu interface per GIC */
-#define NR_GIC_CPU_IF 8
+static unsigned int nr_gic_cpu_if = 8;
+static unsigned int gic_cpu_mask = 0xff;
 
 static inline void writeb_gicd(uint8_t val, unsigned int offset)
 {
     writeb_relaxed(val, gicv2.map_dbase + offset);
 }
 
+static inline void writew_gicd(uint16_t val, unsigned int offset)
+{
+    writew_relaxed(val, gicv2.map_dbase + offset);
+}
+
 static inline void writel_gicd(uint32_t val, unsigned int offset)
 {
     writel_relaxed(val, gicv2.map_dbase + offset);
@@ -132,7 +138,7 @@ static unsigned int gicv2_cpu_mask(const cpumask_t *cpumask)
     cpumask_and(&possible_mask, cpumask, &cpu_possible_map);
     for_each_cpu( cpu, &possible_mask )
     {
-        ASSERT(cpu < NR_GIC_CPU_IF);
+        ASSERT(cpu < nr_gic_cpu_if);
         mask |= per_cpu(gic_cpu_id, cpu);
     }
 
@@ -203,6 +209,15 @@ static unsigned int gicv2_read_irq(void)
     return (readl_gicc(GICC_IAR) & GICC_IA_IRQ);
 }
 
+/* Set target CPU mask (RAZ/WI on uniprocessor) */
+static void gicv2_set_irq_mask(int irq, unsigned int mask)
+{
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+        writew_gicd(mask, GICD_ITARGETSR + irq * 2);
+    else
+        writeb_gicd(mask, GICD_ITARGETSR + irq);
+}
+
 /*
  * needs to be called with a valid cpu_mask, ie each cpu in the mask has
  * already called gic_cpu_init
@@ -230,7 +245,7 @@ static void gicv2_set_irq_properties(struct irq_desc *desc,
     writel_gicd(cfg, GICD_ICFGR + (irq / 16) * 4);
 
     /* Set target CPU mask (RAZ/WI on uniprocessor) */
-    writeb_gicd(mask, GICD_ITARGETSR + irq);
+    gicv2_set_irq_mask(irq, mask);
     /* Set priority */
     writeb_gicd(priority, GICD_IPRIORITYR + irq);
 
@@ -244,16 +259,22 @@ static void __init gicv2_dist_init(void)
     uint32_t gic_cpus;
     int i;
 
-    cpumask = readl_gicd(GICD_ITARGETSR) & 0xff;
-    cpumask |= cpumask << 8;
-    cpumask |= cpumask << 16;
+    cpumask = readl_gicd(GICD_ITARGETSR) & gic_cpu_mask;
 
     /* Disable the distributor */
     writel_gicd(0, GICD_CTLR);
 
     type = readl_gicd(GICD_TYPER);
     gicv2_info.nr_lines = 32 * ((type & GICD_TYPE_LINES) + 1);
-    gic_cpus = 1 + ((type & GICD_TYPE_CPUS) >> 5);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        gic_cpus = 16;
+        BUG_ON( gicv2_info.nr_lines > 510 );
+    }
+    else
+    {
+        gic_cpus = 1 + ((type & GICD_TYPE_CPUS) >> 5);
+    }
     printk("GICv2: %d lines, %d cpu%s%s (IID %8.8x).\n",
            gicv2_info.nr_lines, gic_cpus, (gic_cpus == 1) ? "" : "s",
            (type & GICD_TYPE_SEC) ? ", secure" : "",
@@ -264,8 +285,19 @@ static void __init gicv2_dist_init(void)
         writel_gicd(0x0, GICD_ICFGR + (i / 16) * 4);
 
     /* Route all global IRQs to this CPU */
-    for ( i = 32; i < gicv2_info.nr_lines; i += 4 )
-        writel_gicd(cpumask, GICD_ITARGETSR + (i / 4) * 4);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        cpumask |= cpumask << 16;
+        for ( i = 32; i < gicv2_info.nr_lines; i += 2 )
+            writel_gicd(cpumask, GICD_ITARGETSR + (i / 2) * 4);
+    }
+    else
+    {
+        cpumask |= cpumask << 8;
+        cpumask |= cpumask << 16;
+        for ( i = 32; i < gicv2_info.nr_lines; i += 4 )
+            writel_gicd(cpumask, GICD_ITARGETSR + (i / 4) * 4);
+    }
 
     /* Default priority for global interrupts */
     for ( i = 32; i < gicv2_info.nr_lines; i += 4 )
@@ -285,7 +317,7 @@ static void __cpuinit gicv2_cpu_init(void)
 {
     int i;
 
-    this_cpu(gic_cpu_id) = readl_gicd(GICD_ITARGETSR) & 0xff;
+    this_cpu(gic_cpu_id) = readl_gicd(GICD_ITARGETSR) & gic_cpu_mask;
 
     /* The first 32 interrupts (PPI and SGI) are banked per-cpu, so
      * even though they are controlled with GICD registers, they must
@@ -348,6 +380,11 @@ static int gicv2_secondary_cpu_init(void)
     return 0;
 }
 
+static inline unsigned gicd_sgi_target_shift(void)
+{
+    return 8 + 16 - nr_gic_cpu_if;
+}
+
 static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode,
                            const cpumask_t *cpu_mask)
 {
@@ -366,7 +403,7 @@ static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode,
         cpumask_and(&online_mask, cpu_mask, &cpu_online_map);
         mask = gicv2_cpu_mask(&online_mask);
         writel_gicd(GICD_SGI_TARGET_LIST |
-                    (mask << GICD_SGI_TARGET_SHIFT) | sgi,
+                    (mask << gicd_sgi_target_shift()) | sgi,
                     GICD_SGIR);
         break;
     default:
@@ -581,7 +618,7 @@ static void gicv2_irq_set_affinity(struct irq_desc *desc, const cpumask_t *cpu_m
     mask = gicv2_cpu_mask(cpu_mask);
 
     /* Set target CPU mask (RAZ/WI on uniprocessor) */
-    writeb_gicd(mask, GICD_ITARGETSR + desc->irq);
+    gicv2_set_irq_mask(desc->irq, mask);
 
     spin_unlock(&gicv2.lock);
 }
@@ -690,6 +727,12 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data)
 
     dt_device_set_used_by(node, DOMID_XEN);
 
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        nr_gic_cpu_if = 16;
+        gic_cpu_mask = 0xffff;
+    }
+
     res = dt_device_get_address(node, 0, &gicv2.dbase, NULL);
     if ( res || !gicv2.dbase || (gicv2.dbase & ~PAGE_MASK) )
         panic("GICv2: Cannot find a valid address for the distributor");
@@ -769,6 +812,7 @@ static const char * const gicv2_dt_compat[] __initconst =
     DT_COMPAT_GIC_CORTEX_A15,
     DT_COMPAT_GIC_CORTEX_A7,
     DT_COMPAT_GIC_400,
+    DT_COMPAT_GIC_HIP04,
     NULL
 };
 
xen/arch/arm/gic.c +4 -1
index 70d10d6..cd934cf 100644
@@ -563,12 +563,15 @@ static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)
 void gic_interrupt(struct cpu_user_regs *regs, int is_fiq)
 {
     unsigned int irq;
+    unsigned int max_irq = platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) ?
+                           510 :
+                           1021;
 
     do  {
         /* Reading IRQ will ACK it */
         irq = gic_hw_ops->read_irq();
 
-        if ( likely(irq >= 16 && irq < 1021) )
+        if ( likely(irq >= 16 && irq < max_irq) )
         {
             local_irq_enable();
             do_IRQ(regs, irq, is_fiq);
xen/include/asm-arm/gic.h +3 -1
index 187dc46..5adb628 100644
@@ -155,10 +155,12 @@
 #define DT_COMPAT_GIC_400            "arm,gic-400"
 #define DT_COMPAT_GIC_CORTEX_A15     "arm,cortex-a15-gic"
 #define DT_COMPAT_GIC_CORTEX_A7      "arm,cortex-a7-gic"
+#define DT_COMPAT_GIC_HIP04          "hisilicon,hip04-gic"
 
 #define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \
                         DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \
-                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400)
+                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400), \
+                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04)
 
 #define DT_COMPAT_GIC_V3             "arm,gic-v3"
 
Signature · 1 line
1.9.1
#17 lore raw

Re: [PATCH 04/10] xen/arm: Make gic-v2 code handle hip04-d01 platform

Hi Frediano,

Quoted 21 lines · Frediano Ziglio

/*
* needs to be called with a valid cpu_mask, ie each cpu in the mask has
* already called gic_cpu_init

xen/arch/arm/gic-v2.c +2 -4
@@ -230,7 +245,7 @@ static void gicv2_set_irq_properties(struct irq_desc *desc,
     writel_gicd(cfg, GICD_ICFGR + (irq / 16) * 4);
 
     /* Set target CPU mask (RAZ/WI on uniprocessor) */
-    writeb_gicd(mask, GICD_ITARGETSR + irq);
+    gicv2_set_irq_mask(irq, mask);
     /* Set priority */
     writeb_gicd(priority, GICD_IPRIORITYR + irq);
 
@@ -244,16 +259,22 @@ static void __init gicv2_dist_init(void)
     uint32_t gic_cpus;
     int i;
 
-    cpumask = readl_gicd(GICD_ITARGETSR) & 0xff;
-    cpumask |= cpumask << 8;
-    cpumask |= cpumask << 16;
+    cpumask = readl_gicd(GICD_ITARGETSR) & gic_cpu_mask;
 

xen/arch/arm/gic-v2.c static void __init gicv2_dist_init(void) · line 272

Quoted 10 lines
xen/arch/arm/gic-v2.c +4 -1
     /* Disable the distributor */
     writel_gicd(0, GICD_CTLR);
 
     type = readl_gicd(GICD_TYPER);
     gicv2_info.nr_lines = 32 * ((type & GICD_TYPE_LINES) + 1);
-    gic_cpus = 1 + ((type & GICD_TYPE_CPUS) >> 5);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        gic_cpus = 16;
+        BUG_ON( gicv2_info.nr_lines > 510 );

Could you add a define for this value and add a comment. It would avoid to scratch his head trying to understand why 510.

[..]

Quoted 9 lines
xen/arch/arm/gic-v2.c +5 -0
+static inline unsigned gicd_sgi_target_shift(void)
+{
+    return 8 + 16 - nr_gic_cpu_if;
+}
+
 static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode,
                            const cpumask_t *cpu_mask)
 {

xen/arch/arm/gic-v2.c static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode, · line 406

Quoted 5 lines
xen/arch/arm/gic-v2.c +1 -1
@@ -366,7 +403,7 @@ static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode,
         cpumask_and(&online_mask, cpu_mask, &cpu_online_map);
         mask = gicv2_cpu_mask(&online_mask);
         writel_gicd(GICD_SGI_TARGET_LIST |
-                    (mask << GICD_SGI_TARGET_SHIFT) | sgi,
+                    (mask << gicd_sgi_target_shift()) | sgi,

gicv2_send_SGI is heavily used, it's not acceptable to compute the value of the shift every time. Hence this always give you the same value. You should define a static and initialize it during the initialization.

Quoted 26 lines
xen/arch/arm/gic-v2.c +7 -0
@@ -690,6 +727,12 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data)
 
     dt_device_set_used_by(node, DOMID_XEN);
 
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        nr_gic_cpu_if = 16;
+        gic_cpu_mask = 0xffff;
+    }
+
     res = dt_device_get_address(node, 0, &gicv2.dbase, NULL);
     if ( res || !gicv2.dbase || (gicv2.dbase & ~PAGE_MASK) )
         panic("GICv2: Cannot find a valid address for the distributor");
@@ -769,6 +812,7 @@ static const char * const gicv2_dt_compat[] __initconst =
     DT_COMPAT_GIC_CORTEX_A15,
     DT_COMPAT_GIC_CORTEX_A7,
     DT_COMPAT_GIC_400,
+    DT_COMPAT_GIC_HIP04,
     NULL
 };
 
xen/arch/arm/gic.c +0 -0
index 70d10d6..cd934cf 100644

xen/arch/arm/gic.c static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi) · line 567

Quoted 5 lines
xen/arch/arm/gic.c +2 -0
@@ -563,12 +563,15 @@ static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)
 void gic_interrupt(struct cpu_user_regs *regs, int is_fiq)
 {
     unsigned int irq;
+    unsigned int max_irq = platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) ?
+                           510 :

Ditto for the 510.

xen/arch/arm/gic.c static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi) · line 568

Quoted 1 line
xen/arch/arm/gic.c +1 -0
+                           1021;

gic_interrupt is called thousand time per second, anything that never changes should define only once during initialization.

Rather than using hardcoding the max number, I would use gicv2_info.nr_lines which contains the maximum number of IRQ used by this GIC. Any value above this value is already an error.

That would require either a separate patch or adding a comment in the commit message.

Regards,

Signature · 1 line
Julien Grall
#18 lore raw

Re: [PATCH 04/10] xen/arm: Make gic-v2 code handle hip04-d01 platform

In reply to Frediano Ziglio
Quoted 5 lines · Frediano Ziglio

The GIC in this platform is mainly compatible with the standard GICv2 beside:
- ITARGET is extended to 16 bit to support 16 CPUs;
- SGI mask is extended to support 16 CPUs;
- maximum supported interrupt is 510.

I'm not super keen on sprinkling all of these platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) and the related de-constification throughout this driver. In reality your interrupt controller might be "gic-like" but it is not actually a gic v2, it's something custom.

I see that the Linux side has gone the route of making this an entirely separate driver. Since we have the gic_hw_operations abstraction these days I am inclined towards suggesting we go a similar route in Xen (so far the abstraction has supported gic v2 and v3, so you might find that you want to refactor slight, e.g. by hoisting or pushing down some functionality). The same goes for the GICH changes later on.

I'm even less keen on the related changes made to the vgic. My overwhelming preference is for guests to only ever see the architecturally standardised gic v2, v3 (and in the future v4 etc). This would mean that on your platform a single guest could only make use of 8 CPUs, but as a whole the host would be able to use all 16. I think that's an acceptable tradeoff.

(Hrm, looking a second time I don't really understand the patches you are doing to the vgic and to what extent they contradict or support what I say above, just moving the registers with no other changes seems odd to me. In any case please just use the standard vgic)

Ian.

Quoted 219 lines
---
 xen/arch/arm/gic-v2.c     | 70 ++++++++++++++++++++++++++++++++++++++---------
 xen/arch/arm/gic.c        |  5 +++-
 xen/include/asm-arm/gic.h |  4 ++-
 3 files changed, 64 insertions(+), 15 deletions(-)
xen/arch/arm/gic-v2.c +57 -13
index faad1ff..eef55ed 100644
@@ -79,16 +79,22 @@ static struct gic_info gicv2_info;
  * logical CPU numbering. Let's use mapping as returned by the GIC
  * itself
  */
-static DEFINE_PER_CPU(u8, gic_cpu_id);
+static DEFINE_PER_CPU(u16, gic_cpu_id);
 
 /* Maximum cpu interface per GIC */
-#define NR_GIC_CPU_IF 8
+static unsigned int nr_gic_cpu_if = 8;
+static unsigned int gic_cpu_mask = 0xff;
 
 static inline void writeb_gicd(uint8_t val, unsigned int offset)
 {
     writeb_relaxed(val, gicv2.map_dbase + offset);
 }
 
+static inline void writew_gicd(uint16_t val, unsigned int offset)
+{
+    writew_relaxed(val, gicv2.map_dbase + offset);
+}
+
 static inline void writel_gicd(uint32_t val, unsigned int offset)
 {
     writel_relaxed(val, gicv2.map_dbase + offset);
@@ -132,7 +138,7 @@ static unsigned int gicv2_cpu_mask(const cpumask_t *cpumask)
     cpumask_and(&possible_mask, cpumask, &cpu_possible_map);
     for_each_cpu( cpu, &possible_mask )
     {
-        ASSERT(cpu < NR_GIC_CPU_IF);
+        ASSERT(cpu < nr_gic_cpu_if);
         mask |= per_cpu(gic_cpu_id, cpu);
     }
 
@@ -203,6 +209,15 @@ static unsigned int gicv2_read_irq(void)
     return (readl_gicc(GICC_IAR) & GICC_IA_IRQ);
 }
 
+/* Set target CPU mask (RAZ/WI on uniprocessor) */
+static void gicv2_set_irq_mask(int irq, unsigned int mask)
+{
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+        writew_gicd(mask, GICD_ITARGETSR + irq * 2);
+    else
+        writeb_gicd(mask, GICD_ITARGETSR + irq);
+}
+
 /*
  * needs to be called with a valid cpu_mask, ie each cpu in the mask has
  * already called gic_cpu_init
@@ -230,7 +245,7 @@ static void gicv2_set_irq_properties(struct irq_desc *desc,
     writel_gicd(cfg, GICD_ICFGR + (irq / 16) * 4);
 
     /* Set target CPU mask (RAZ/WI on uniprocessor) */
-    writeb_gicd(mask, GICD_ITARGETSR + irq);
+    gicv2_set_irq_mask(irq, mask);
     /* Set priority */
     writeb_gicd(priority, GICD_IPRIORITYR + irq);
 
@@ -244,16 +259,22 @@ static void __init gicv2_dist_init(void)
     uint32_t gic_cpus;
     int i;
 
-    cpumask = readl_gicd(GICD_ITARGETSR) & 0xff;
-    cpumask |= cpumask << 8;
-    cpumask |= cpumask << 16;
+    cpumask = readl_gicd(GICD_ITARGETSR) & gic_cpu_mask;
 
     /* Disable the distributor */
     writel_gicd(0, GICD_CTLR);
 
     type = readl_gicd(GICD_TYPER);
     gicv2_info.nr_lines = 32 * ((type & GICD_TYPE_LINES) + 1);
-    gic_cpus = 1 + ((type & GICD_TYPE_CPUS) >> 5);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        gic_cpus = 16;
+        BUG_ON( gicv2_info.nr_lines > 510 );
+    }
+    else
+    {
+        gic_cpus = 1 + ((type & GICD_TYPE_CPUS) >> 5);
+    }
     printk("GICv2: %d lines, %d cpu%s%s (IID %8.8x).\n",
            gicv2_info.nr_lines, gic_cpus, (gic_cpus == 1) ? "" : "s",
            (type & GICD_TYPE_SEC) ? ", secure" : "",
@@ -264,8 +285,19 @@ static void __init gicv2_dist_init(void)
         writel_gicd(0x0, GICD_ICFGR + (i / 16) * 4);
 
     /* Route all global IRQs to this CPU */
-    for ( i = 32; i < gicv2_info.nr_lines; i += 4 )
-        writel_gicd(cpumask, GICD_ITARGETSR + (i / 4) * 4);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        cpumask |= cpumask << 16;
+        for ( i = 32; i < gicv2_info.nr_lines; i += 2 )
+            writel_gicd(cpumask, GICD_ITARGETSR + (i / 2) * 4);
+    }
+    else
+    {
+        cpumask |= cpumask << 8;
+        cpumask |= cpumask << 16;
+        for ( i = 32; i < gicv2_info.nr_lines; i += 4 )
+            writel_gicd(cpumask, GICD_ITARGETSR + (i / 4) * 4);
+    }
 
     /* Default priority for global interrupts */
     for ( i = 32; i < gicv2_info.nr_lines; i += 4 )
@@ -285,7 +317,7 @@ static void __cpuinit gicv2_cpu_init(void)
 {
     int i;
 
-    this_cpu(gic_cpu_id) = readl_gicd(GICD_ITARGETSR) & 0xff;
+    this_cpu(gic_cpu_id) = readl_gicd(GICD_ITARGETSR) & gic_cpu_mask;
 
     /* The first 32 interrupts (PPI and SGI) are banked per-cpu, so
      * even though they are controlled with GICD registers, they must
@@ -348,6 +380,11 @@ static int gicv2_secondary_cpu_init(void)
     return 0;
 }
 
+static inline unsigned gicd_sgi_target_shift(void)
+{
+    return 8 + 16 - nr_gic_cpu_if;
+}
+
 static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode,
                            const cpumask_t *cpu_mask)
 {
@@ -366,7 +403,7 @@ static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode,
         cpumask_and(&online_mask, cpu_mask, &cpu_online_map);
         mask = gicv2_cpu_mask(&online_mask);
         writel_gicd(GICD_SGI_TARGET_LIST |
-                    (mask << GICD_SGI_TARGET_SHIFT) | sgi,
+                    (mask << gicd_sgi_target_shift()) | sgi,
                     GICD_SGIR);
         break;
     default:
@@ -581,7 +618,7 @@ static void gicv2_irq_set_affinity(struct irq_desc *desc, const cpumask_t *cpu_m
     mask = gicv2_cpu_mask(cpu_mask);
 
     /* Set target CPU mask (RAZ/WI on uniprocessor) */
-    writeb_gicd(mask, GICD_ITARGETSR + desc->irq);
+    gicv2_set_irq_mask(desc->irq, mask);
 
     spin_unlock(&gicv2.lock);
 }
@@ -690,6 +727,12 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data)
 
     dt_device_set_used_by(node, DOMID_XEN);
 
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        nr_gic_cpu_if = 16;
+        gic_cpu_mask = 0xffff;
+    }
+
     res = dt_device_get_address(node, 0, &gicv2.dbase, NULL);
     if ( res || !gicv2.dbase || (gicv2.dbase & ~PAGE_MASK) )
         panic("GICv2: Cannot find a valid address for the distributor");
@@ -769,6 +812,7 @@ static const char * const gicv2_dt_compat[] __initconst =
     DT_COMPAT_GIC_CORTEX_A15,
     DT_COMPAT_GIC_CORTEX_A7,
     DT_COMPAT_GIC_400,
+    DT_COMPAT_GIC_HIP04,
     NULL
 };
 
xen/arch/arm/gic.c +4 -1
index 70d10d6..cd934cf 100644
@@ -563,12 +563,15 @@ static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)
 void gic_interrupt(struct cpu_user_regs *regs, int is_fiq)
 {
     unsigned int irq;
+    unsigned int max_irq = platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) ?
+                           510 :
+                           1021;
 
     do  {
         /* Reading IRQ will ACK it */
         irq = gic_hw_ops->read_irq();
 
-        if ( likely(irq >= 16 && irq < 1021) )
+        if ( likely(irq >= 16 && irq < max_irq) )
         {
             local_irq_enable();
             do_IRQ(regs, irq, is_fiq);
xen/include/asm-arm/gic.h +3 -1
index 187dc46..5adb628 100644
@@ -155,10 +155,12 @@
 #define DT_COMPAT_GIC_400            "arm,gic-400"
 #define DT_COMPAT_GIC_CORTEX_A15     "arm,cortex-a15-gic"
 #define DT_COMPAT_GIC_CORTEX_A7      "arm,cortex-a7-gic"
+#define DT_COMPAT_GIC_HIP04          "hisilicon,hip04-gic"
 
 #define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \
                         DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \
-                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400)
+                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400), \
+                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04)
 
 #define DT_COMPAT_GIC_V3             "arm,gic-v3"
 
#19 lore raw

Re: [PATCH 04/10] xen/arm: Make gic-v2 code handle hip04-d01 platform

2015-01-13 11:54 GMT+00:00 Ian Campbell <[email protected]>:

Quoted 7 lines · Frediano Ziglio
Quoted 5 lines

The GIC in this platform is mainly compatible with the standard GICv2 beside:
- ITARGET is extended to 16 bit to support 16 CPUs;
- SGI mask is extended to support 16 CPUs;
- maximum supported interrupt is 510.

Quoted 6 lines

I'm not super keen on sprinkling all of these platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) and the related de-constification throughout this driver. In reality your interrupt controller might be "gic-like" but it is not actually a gic v2, it's something custom.

The quirk part was removed, Julien imported v3 in
http://xenbits.xen.org/gitweb/?p=people/julieng/xen-unstable.git;a=shortlog;h=refs/heads/hisilicon-d01-v3

Quoted 7 lines

I see that the Linux side has gone the route of making this an entirely separate driver. Since we have the gic_hw_operations abstraction these days I am inclined towards suggesting we go a similar route in Xen (so far the abstraction has supported gic v2 and v3, so you might find that you want to refactor slight, e.g. by hoisting or pushing down some functionality). The same goes for the GICH changes later on.

Do you think would be better to have another GIC driver instead. It would be mostly a copy&paste job. Yes, I didn't understand the reason behind changing GICH registers either but now the changes are in the silicon.

Quoted 7 lines

I'm even less keen on the related changes made to the vgic. My overwhelming preference is for guests to only ever see the architecturally standardised gic v2, v3 (and in the future v4 etc). This would mean that on your platform a single guest could only make use of 8 CPUs, but as a whole the host would be able to use all 16. I think that's an acceptable tradeoff.

Quoted 7 lines

(Hrm, looking a second time I don't really understand the patches you are doing to the vgic and to what extent they contradict or support what I say above, just moving the registers with no other changes seems odd to me. In any case please just use the standard vgic)

Ian.

Yes, there is no change in vgic. The GICV is 100% compatible to standard GICv2 and a normal GICv2 is presented to the guest.

Frediano

Quoted 226 lines
Quoted 209 lines
---
 xen/arch/arm/gic-v2.c     | 70 ++++++++++++++++++++++++++++++++++++++---------
 xen/arch/arm/gic.c        |  5 +++-
 xen/include/asm-arm/gic.h |  4 ++-
 3 files changed, 64 insertions(+), 15 deletions(-)
xen/arch/arm/gic-v2.c +57 -13
index faad1ff..eef55ed 100644
@@ -79,16 +79,22 @@ static struct gic_info gicv2_info;
  * logical CPU numbering. Let's use mapping as returned by the GIC
  * itself
  */
-static DEFINE_PER_CPU(u8, gic_cpu_id);
+static DEFINE_PER_CPU(u16, gic_cpu_id);
 
 /* Maximum cpu interface per GIC */
-#define NR_GIC_CPU_IF 8
+static unsigned int nr_gic_cpu_if = 8;
+static unsigned int gic_cpu_mask = 0xff;
 
 static inline void writeb_gicd(uint8_t val, unsigned int offset)
 {
     writeb_relaxed(val, gicv2.map_dbase + offset);
 }
 
+static inline void writew_gicd(uint16_t val, unsigned int offset)
+{
+    writew_relaxed(val, gicv2.map_dbase + offset);
+}
+
 static inline void writel_gicd(uint32_t val, unsigned int offset)
 {
     writel_relaxed(val, gicv2.map_dbase + offset);
@@ -132,7 +138,7 @@ static unsigned int gicv2_cpu_mask(const cpumask_t *cpumask)
     cpumask_and(&possible_mask, cpumask, &cpu_possible_map);
     for_each_cpu( cpu, &possible_mask )
     {
-        ASSERT(cpu < NR_GIC_CPU_IF);
+        ASSERT(cpu < nr_gic_cpu_if);
         mask |= per_cpu(gic_cpu_id, cpu);
     }
 
@@ -203,6 +209,15 @@ static unsigned int gicv2_read_irq(void)
     return (readl_gicc(GICC_IAR) & GICC_IA_IRQ);
 }
 
+/* Set target CPU mask (RAZ/WI on uniprocessor) */
+static void gicv2_set_irq_mask(int irq, unsigned int mask)
+{
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+        writew_gicd(mask, GICD_ITARGETSR + irq * 2);
+    else
+        writeb_gicd(mask, GICD_ITARGETSR + irq);
+}
+
 /*
  * needs to be called with a valid cpu_mask, ie each cpu in the mask has
  * already called gic_cpu_init
@@ -230,7 +245,7 @@ static void gicv2_set_irq_properties(struct irq_desc *desc,
     writel_gicd(cfg, GICD_ICFGR + (irq / 16) * 4);
 
     /* Set target CPU mask (RAZ/WI on uniprocessor) */
-    writeb_gicd(mask, GICD_ITARGETSR + irq);
+    gicv2_set_irq_mask(irq, mask);
     /* Set priority */
     writeb_gicd(priority, GICD_IPRIORITYR + irq);
 
@@ -244,16 +259,22 @@ static void __init gicv2_dist_init(void)
     uint32_t gic_cpus;
     int i;
 
-    cpumask = readl_gicd(GICD_ITARGETSR) & 0xff;
-    cpumask |= cpumask << 8;
-    cpumask |= cpumask << 16;
+    cpumask = readl_gicd(GICD_ITARGETSR) & gic_cpu_mask;
 
     /* Disable the distributor */
     writel_gicd(0, GICD_CTLR);
 
     type = readl_gicd(GICD_TYPER);
     gicv2_info.nr_lines = 32 * ((type & GICD_TYPE_LINES) + 1);
-    gic_cpus = 1 + ((type & GICD_TYPE_CPUS) >> 5);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        gic_cpus = 16;
+        BUG_ON( gicv2_info.nr_lines > 510 );
+    }
+    else
+    {
+        gic_cpus = 1 + ((type & GICD_TYPE_CPUS) >> 5);
+    }
     printk("GICv2: %d lines, %d cpu%s%s (IID %8.8x).\n",
            gicv2_info.nr_lines, gic_cpus, (gic_cpus == 1) ? "" : "s",
            (type & GICD_TYPE_SEC) ? ", secure" : "",
@@ -264,8 +285,19 @@ static void __init gicv2_dist_init(void)
         writel_gicd(0x0, GICD_ICFGR + (i / 16) * 4);
 
     /* Route all global IRQs to this CPU */
-    for ( i = 32; i < gicv2_info.nr_lines; i += 4 )
-        writel_gicd(cpumask, GICD_ITARGETSR + (i / 4) * 4);
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        cpumask |= cpumask << 16;
+        for ( i = 32; i < gicv2_info.nr_lines; i += 2 )
+            writel_gicd(cpumask, GICD_ITARGETSR + (i / 2) * 4);
+    }
+    else
+    {
+        cpumask |= cpumask << 8;
+        cpumask |= cpumask << 16;
+        for ( i = 32; i < gicv2_info.nr_lines; i += 4 )
+            writel_gicd(cpumask, GICD_ITARGETSR + (i / 4) * 4);
+    }
 
     /* Default priority for global interrupts */
     for ( i = 32; i < gicv2_info.nr_lines; i += 4 )
@@ -285,7 +317,7 @@ static void __cpuinit gicv2_cpu_init(void)
 {
     int i;
 
-    this_cpu(gic_cpu_id) = readl_gicd(GICD_ITARGETSR) & 0xff;
+    this_cpu(gic_cpu_id) = readl_gicd(GICD_ITARGETSR) & gic_cpu_mask;
 
     /* The first 32 interrupts (PPI and SGI) are banked per-cpu, so
      * even though they are controlled with GICD registers, they must
@@ -348,6 +380,11 @@ static int gicv2_secondary_cpu_init(void)
     return 0;
 }
 
+static inline unsigned gicd_sgi_target_shift(void)
+{
+    return 8 + 16 - nr_gic_cpu_if;
+}
+
 static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode,
                            const cpumask_t *cpu_mask)
 {
@@ -366,7 +403,7 @@ static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode,
         cpumask_and(&online_mask, cpu_mask, &cpu_online_map);
         mask = gicv2_cpu_mask(&online_mask);
         writel_gicd(GICD_SGI_TARGET_LIST |
-                    (mask << GICD_SGI_TARGET_SHIFT) | sgi,
+                    (mask << gicd_sgi_target_shift()) | sgi,
                     GICD_SGIR);
         break;
     default:
@@ -581,7 +618,7 @@ static void gicv2_irq_set_affinity(struct irq_desc *desc, const cpumask_t *cpu_m
     mask = gicv2_cpu_mask(cpu_mask);
 
     /* Set target CPU mask (RAZ/WI on uniprocessor) */
-    writeb_gicd(mask, GICD_ITARGETSR + desc->irq);
+    gicv2_set_irq_mask(desc->irq, mask);
 
     spin_unlock(&gicv2.lock);
 }
@@ -690,6 +727,12 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data)
 
     dt_device_set_used_by(node, DOMID_XEN);
 
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        nr_gic_cpu_if = 16;
+        gic_cpu_mask = 0xffff;
+    }
+
     res = dt_device_get_address(node, 0, &gicv2.dbase, NULL);
     if ( res || !gicv2.dbase || (gicv2.dbase & ~PAGE_MASK) )
         panic("GICv2: Cannot find a valid address for the distributor");
@@ -769,6 +812,7 @@ static const char * const gicv2_dt_compat[] __initconst =
     DT_COMPAT_GIC_CORTEX_A15,
     DT_COMPAT_GIC_CORTEX_A7,
     DT_COMPAT_GIC_400,
+    DT_COMPAT_GIC_HIP04,
     NULL
 };
 
xen/arch/arm/gic.c +4 -1
index 70d10d6..cd934cf 100644
@@ -563,12 +563,15 @@ static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)
 void gic_interrupt(struct cpu_user_regs *regs, int is_fiq)
 {
     unsigned int irq;
+    unsigned int max_irq = platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) ?
+                           510 :
+                           1021;
 
     do  {
         /* Reading IRQ will ACK it */
         irq = gic_hw_ops->read_irq();
 
-        if ( likely(irq >= 16 && irq < 1021) )
+        if ( likely(irq >= 16 && irq < max_irq) )
         {
             local_irq_enable();
             do_IRQ(regs, irq, is_fiq);
xen/include/asm-arm/gic.h +0 -0
index 187dc46..5adb628 100644
@@ -155,10 +155,12 @@
 #define DT_COMPAT_GIC_400            "arm,gic-400"
 #define DT_COMPAT_GIC_CORTEX_A15     "arm,cortex-a15-gic"
 #define DT_COMPAT_GIC_CORTEX_A7      "arm,cortex-a7-gic"

xen/include/asm-arm/gic.h line 166

Quoted 10 lines
xen/include/asm-arm/gic.h +3 -1
+#define DT_COMPAT_GIC_HIP04          "hisilicon,hip04-gic"
 
 #define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \
                         DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \
-                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400)
+                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400), \
+                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04)
 
 #define DT_COMPAT_GIC_V3             "arm,gic-v3"
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#20 lore raw

PATCH 5/10 xen/arm: Add support for DTBs with strange names of Hip04 GICv2

In reply to Frediano Ziglio

From: Zoltan Kiss <[email protected]>

This name can appear in some Linux kernel repos. Not very fortunate, but to avoid others spending an hour to spot that few characters difference it worth to work around it.

---
 xen/arch/arm/gic-v2.c     | 1 +
 xen/include/asm-arm/gic.h | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
xen/arch/arm/gic-v2.c +1 -0
index eef55ed..85c7f11 100644
@@ -813,6 +813,7 @@ static const char * const gicv2_dt_compat[] __initconst =
     DT_COMPAT_GIC_CORTEX_A7,
     DT_COMPAT_GIC_400,
     DT_COMPAT_GIC_HIP04,
+    DT_COMPAT_GIC_HIP04_2,
     NULL
 };
 
xen/include/asm-arm/gic.h +3 -1
index 5adb628..3d2b3db 100644
@@ -156,11 +156,13 @@
 #define DT_COMPAT_GIC_CORTEX_A15     "arm,cortex-a15-gic"
 #define DT_COMPAT_GIC_CORTEX_A7      "arm,cortex-a7-gic"
 #define DT_COMPAT_GIC_HIP04          "hisilicon,hip04-gic"
+#define DT_COMPAT_GIC_HIP04_2        "hisilicon,hip04-intc"
 
 #define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \
                         DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \
                         DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400), \
-                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04)
+                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04), \
+                        DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04_2)
 
 #define DT_COMPAT_GIC_V3             "arm,gic-v3"
 
Signature · 1 line
1.9.1
#21 lore raw

PATCH 6/10 xen/arm: handle GICH register changes for hip04-d01 platform

In reply to Frediano Ziglio

The GICH in this platform is mainly compatible with the standard GICv2 beside APR and LR register offsets.

---
 xen/arch/arm/gic-v2.c     | 24 ++++++++++++++----------
 xen/include/asm-arm/gic.h |  2 ++
 2 files changed, 16 insertions(+), 10 deletions(-)
xen/arch/arm/gic-v2.c +14 -10
index 85c7f11..e7bf331 100644
@@ -84,6 +84,8 @@ static DEFINE_PER_CPU(u16, gic_cpu_id);
 /* Maximum cpu interface per GIC */
 static unsigned int nr_gic_cpu_if = 8;
 static unsigned int gic_cpu_mask = 0xff;
+static unsigned int gich_apr = GICH_APR;
+static unsigned int gich_lr = GICH_LR;
 
 static inline void writeb_gicd(uint8_t val, unsigned int offset)
 {
@@ -154,9 +156,9 @@ static void gicv2_save_state(struct vcpu *v)
      * accessed simultaneously by another pCPU.
      */
     for ( i = 0; i < gicv2_info.nr_lrs; i++ )
-        v->arch.gic.v2.lr[i] = readl_gich(GICH_LR + i * 4);
+        v->arch.gic.v2.lr[i] = readl_gich(gich_lr + i * 4);
 
-    v->arch.gic.v2.apr = readl_gich(GICH_APR);
+    v->arch.gic.v2.apr = readl_gich(gich_apr);
     v->arch.gic.v2.vmcr = readl_gich(GICH_VMCR);
     /* Disable until next VCPU scheduled */
     writel_gich(0, GICH_HCR);
@@ -167,9 +169,9 @@ static void gicv2_restore_state(const struct vcpu *v)
     int i;
 
     for ( i = 0; i < gicv2_info.nr_lrs; i++ )
-        writel_gich(v->arch.gic.v2.lr[i], GICH_LR + i * 4);
+        writel_gich(v->arch.gic.v2.lr[i], gich_lr + i * 4);
 
-    writel_gich(v->arch.gic.v2.apr, GICH_APR);
+    writel_gich(v->arch.gic.v2.apr, gich_apr);
     writel_gich(v->arch.gic.v2.vmcr, GICH_VMCR);
     writel_gich(GICH_HCR_EN, GICH_HCR);
 }
@@ -182,7 +184,7 @@ static void gicv2_dump_state(const struct vcpu *v)
     {
         for ( i = 0; i < gicv2_info.nr_lrs; i++ )
             printk("   HW_LR[%d]=%x\n", i,
-                   readl_gich(GICH_LR + i * 4));
+                   readl_gich(gich_lr + i * 4));
     }
     else
     {
@@ -442,12 +444,12 @@ static void gicv2_update_lr(int lr, const struct pending_irq *p,
                             << GICH_V2_LR_PHYSICAL_SHIFT);
     }
 
-    writel_gich(lr_reg, GICH_LR + lr * 4);
+    writel_gich(lr_reg, gich_lr + lr * 4);
 }
 
 static void gicv2_clear_lr(int lr)
 {
-    writel_gich(0, GICH_LR + lr * 4);
+    writel_gich(0, gich_lr + lr * 4);
 }
 
 static int gicv2v_setup(struct domain *d)
@@ -497,7 +499,7 @@ static void gicv2_read_lr(int lr, struct gic_lr *lr_reg)
 {
     uint32_t lrv;
 
-    lrv          = readl_gich(GICH_LR + lr * 4);
+    lrv          = readl_gich(gich_lr + lr * 4);
     lr_reg->pirq = (lrv >> GICH_V2_LR_PHYSICAL_SHIFT) & GICH_V2_LR_PHYSICAL_MASK;
     lr_reg->virq = (lrv >> GICH_V2_LR_VIRTUAL_SHIFT) & GICH_V2_LR_VIRTUAL_MASK;
     lr_reg->priority = (lrv >> GICH_V2_LR_PRIORITY_SHIFT) & GICH_V2_LR_PRIORITY_MASK;
@@ -520,7 +522,7 @@ static void gicv2_write_lr(int lr, const struct gic_lr *lr_reg)
                                        << GICH_V2_LR_HW_SHIFT)  |
           ((uint32_t)(lr_reg->grp & GICH_V2_LR_GRP_MASK) << GICH_V2_LR_GRP_SHIFT) );
 
-    writel_gich(lrv, GICH_LR + lr * 4);
+    writel_gich(lrv, gich_lr + lr * 4);
 }
 
 static void gicv2_hcr_status(uint32_t flag, bool_t status)
@@ -543,7 +545,7 @@ static unsigned int gicv2_read_vmcr_priority(void)
 
 static unsigned int gicv2_read_apr(int apr_reg)
 {
-   return readl_gich(GICH_APR);
+   return readl_gich(gich_apr);
 }
 
 static void gicv2_irq_enable(struct irq_desc *desc)
@@ -731,6 +733,8 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data)
     {
         nr_gic_cpu_if = 16;
         gic_cpu_mask = 0xffff;
+        gich_apr = HIP04_GICH_APR;
+        gich_lr = HIP04_GICH_LR;
     }
 
     res = dt_device_get_address(node, 0, &gicv2.dbase, NULL);
xen/include/asm-arm/gic.h +2 -0
index 3d2b3db..804bf24 100644
@@ -88,6 +88,8 @@
 #define GICH_ELSR1      (0x34)
 #define GICH_APR        (0xF0)
 #define GICH_LR         (0x100)
+#define HIP04_GICH_APR  (0x70)
+#define HIP04_GICH_LR   (0x80)
 
 /* Register bits */
 #define GICD_CTL_ENABLE 0x1
Signature · 1 line
1.9.1
#22 lore raw

Re: [PATCH 06/10] xen/arm: handle GICH register changes for hip04-d01 platform

Hi Frediano,

Quoted 15 lines · Frediano Ziglio

static void gicv2_irq_enable(struct irq_desc *desc)

xen/arch/arm/gic-v2.c +2 -0
@@ -731,6 +733,8 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data)
     {
         nr_gic_cpu_if = 16;
         gic_cpu_mask = 0xffff;
+        gich_apr = HIP04_GICH_APR;
+        gich_lr = HIP04_GICH_LR;
     }
 
     res = dt_device_get_address(node, 0, &gicv2.dbase, NULL);
xen/include/asm-arm/gic.h +0 -0
index 3d2b3db..804bf24 100644

xen/include/asm-arm/gic.h line 92

Quoted 5 lines
xen/include/asm-arm/gic.h +2 -0
@@ -88,6 +88,8 @@
 #define GICH_ELSR1      (0x34)
 #define GICH_APR        (0xF0)
 #define GICH_LR         (0x100)
+#define HIP04_GICH_APR  (0x70)
+#define HIP04_GICH_LR   (0x80)

Please move thoses define in gic-v2.c. The header gic.h should only contains value that needs to be shared with the vgic and/or the other GIC drivers.

Regards,

Signature · 1 line
Julien Grall
#23 lore raw

PATCH 7/10 xen/arm: Force domains to use normal GICv2 driver on Hip04 platform

In reply to Frediano Ziglio

Until vGIC support is not implemented and tested, this will prevent guest kernels to use their Hip04 driver, or crash when they don't have any.

---
 xen/arch/arm/gic-v2.c | 6 ++++++
 1 file changed, 6 insertions(+)
xen/arch/arm/gic-v2.c +6 -0
index e7bf331..d92e2c0 100644
@@ -641,6 +641,12 @@ static int gicv2_make_dt_node(const struct domain *d,
         return -FDT_ERR_XEN(ENOENT);
     }
 
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        compatible = DT_COMPAT_GIC_CORTEX_A15;
+        len = strlen((char*) compatible) + 1;
+    }
+
     res = fdt_begin_node(fdt, "interrupt-controller");
     if ( res )
         return res;
Signature · 1 line
1.9.1
#24 lore raw

Re: [PATCH 07/10] xen/arm: Force domains to use normal GICv2 driver on Hip04 platform

Hi Frediano,

FYI, this is only force DOM0 to use the normal GICv2 drivers.

Do you have any plan to support hi-silicon vGIC in Xen? This would allow guest running with more than 8 cores.

Regards,

Quoted 27 lines · Frediano Ziglio

Until vGIC support is not implemented and tested, this will prevent guest kernels to use their Hip04 driver, or crash when they don't have any.

---
 xen/arch/arm/gic-v2.c | 6 ++++++
 1 file changed, 6 insertions(+)
xen/arch/arm/gic-v2.c +6 -0
index e7bf331..d92e2c0 100644
@@ -641,6 +641,12 @@ static int gicv2_make_dt_node(const struct domain *d,
         return -FDT_ERR_XEN(ENOENT);
     }
 
+    if ( platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU) )
+    {
+        compatible = DT_COMPAT_GIC_CORTEX_A15;
+        len = strlen((char*) compatible) + 1;
+    }
+
     res = fdt_begin_node(fdt, "interrupt-controller");
     if ( res )
         return res;
Signature · 1 line
Julien Grall
#25 lore raw

Re: [PATCH 07/10] xen/arm: Force domains to use normal GICv2 driver on Hip04 platform

Quoted 6 lines · Julien Grall

Hi Frediano,

FYI, this is only force DOM0 to use the normal GICv2 drivers.

Do you have any plan to support hi-silicon vGIC in Xen? This would allow guest running with more than 8 cores.

I'm against exposing any non-standardised vGIC to guests. So long as the host can use all processors I think it is OK to constrain the guests in this way. I don't want to end up having loads of custom vGIC drivers for every time a silicon vendor deviates from the architecturally specified components.

#26 lore raw

PATCH 8/10 xen/arm: Move vGIC registers on Hip04 platform

In reply to Frediano Ziglio
---
 xen/arch/arm/gic-v2.c     | 15 +++++++++++++--
 xen/include/asm-arm/gic.h |  2 ++
 2 files changed, 15 insertions(+), 2 deletions(-)
xen/arch/arm/gic-v2.c +13 -2
index d92e2c0..330157b 100644
@@ -671,8 +671,19 @@ static int gicv2_make_dt_node(const struct domain *d,
         return -FDT_ERR_XEN(ENOMEM);
 
     tmp = new_cells;
-    dt_set_range(&tmp, node, d->arch.vgic.dbase, PAGE_SIZE);
-    dt_set_range(&tmp, node, d->arch.vgic.cbase, PAGE_SIZE * 2);
+
+    if (platform_has_quirk(PLATFORM_QUIRK_GICV2_16_CPU))
+    {
+        dt_set_range(&tmp, node, d->arch.vgic.dbase - HIP04_VGIC_REG_OFFSET,
+                     PAGE_SIZE);
+        dt_set_range(&tmp, node, d->arch.vgic.cbase - HIP04_VGIC_REG_OFFSET,
+                     PAGE_SIZE * 2);
+    }
+    else
+    {
+        dt_set_range(&tmp, node, d->arch.vgic.dbase, PAGE_SIZE);
+        dt_set_range(&tmp, node, d->arch.vgic.cbase, PAGE_SIZE * 2);
+    }
 
     res = fdt_property(fdt, "reg", new_cells, len);
     xfree(new_cells);
xen/include/asm-arm/gic.h +2 -0
index 804bf24..c748791 100644
@@ -149,6 +149,8 @@
 #define GICH_LR_PENDING         1
 #define GICH_LR_ACTIVE          2
 
+#define HIP04_VGIC_REG_OFFSET   0xe0000000
+
 #ifndef __ASSEMBLY__
 #include <xen/device_tree.h>
 #include <xen/irq.h>
Signature · 1 line
1.9.1
#27 lore raw

PATCH 9/10 xen/device_tree: Add new helper to read arrays from a DTB

In reply to Frediano Ziglio

From: Zoltan Kiss <[email protected]>

---
 xen/common/device_tree.c      | 14 ++++++++++----
 xen/include/xen/device_tree.h | 11 +++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)
xen/common/device_tree.c +10 -4
index f72b2e9..e97c28b 100644
@@ -160,19 +160,25 @@ const void *dt_get_property(const struct dt_device_node *np,
 bool_t dt_property_read_u32(const struct dt_device_node *np,
                          const char *name, u32 *out_value)
 {
-    u32 len;
+    return dt_property_read_u32_array(np, name, out_value, 1);
+}
+
+bool_t dt_property_read_u32_array(const struct dt_device_node *np,
+                                  const char *name, u32 *out_value, u16 out_len)
+{
+    u32 len, i;
     const __be32 *val;
 
     val = dt_get_property(np, name, &len);
-    if ( !val || len < sizeof(*out_value) )
+    if ( !val || len < sizeof(*out_value) * out_len )
         return 0;
 
-    *out_value = be32_to_cpup(val);
+    for ( i = 0; i < out_len; i++, val++ )
+        out_value[i] = be32_to_cpup(val);
 
     return 1;
 }
 
-
 bool_t dt_property_read_u64(const struct dt_device_node *np,
                          const char *name, u64 *out_value)
 {
xen/include/xen/device_tree.h +11 -0
index 08db8bc..5fcd9c4 100644
@@ -346,6 +346,17 @@ const struct dt_property *dt_find_property(const struct dt_device_node *np,
 bool_t dt_property_read_u32(const struct dt_device_node *np,
                             const char *name, u32 *out_value);
 /**
+ * dt_property_read_u32_array - Helper to read a u32 array property.
+ * @np: node to get the value
+ * @name: name of the property
+ * @out_value: pointer to return value
+ * @out_len: lenght of the array
+ *
+ * Return true if get the desired value.
+ */
+bool_t dt_property_read_u32_array(const struct dt_device_node *np,
+                                  const char *name, u32 *out_value, u16 out_len);
+/**
  * dt_property_read_u64 - Helper to read a u64 property.
  * @np: node to get the value
  * @name: name of the property
Signature · 1 line
1.9.1
Reviewed-by on v1 9/10
#28 lore raw

Re: [PATCH 09/10] xen/device_tree: Add new helper to read arrays from a DTB

Hi Frediano,

Quoted 3 lines · Frediano Ziglio

From: Zoltan Kiss <[email protected]>

Regards,

Quoted 62 lines
---
 xen/common/device_tree.c      | 14 ++++++++++----
 xen/include/xen/device_tree.h | 11 +++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)
xen/common/device_tree.c +10 -4
index f72b2e9..e97c28b 100644
@@ -160,19 +160,25 @@ const void *dt_get_property(const struct dt_device_node *np,
 bool_t dt_property_read_u32(const struct dt_device_node *np,
                          const char *name, u32 *out_value)
 {
-    u32 len;
+    return dt_property_read_u32_array(np, name, out_value, 1);
+}
+
+bool_t dt_property_read_u32_array(const struct dt_device_node *np,
+                                  const char *name, u32 *out_value, u16 out_len)
+{
+    u32 len, i;
     const __be32 *val;
 
     val = dt_get_property(np, name, &len);
-    if ( !val || len < sizeof(*out_value) )
+    if ( !val || len < sizeof(*out_value) * out_len )
         return 0;
 
-    *out_value = be32_to_cpup(val);
+    for ( i = 0; i < out_len; i++, val++ )
+        out_value[i] = be32_to_cpup(val);
 
     return 1;
 }
 
-
 bool_t dt_property_read_u64(const struct dt_device_node *np,
                          const char *name, u64 *out_value)
 {
xen/include/xen/device_tree.h +11 -0
index 08db8bc..5fcd9c4 100644
@@ -346,6 +346,17 @@ const struct dt_property *dt_find_property(const struct dt_device_node *np,
 bool_t dt_property_read_u32(const struct dt_device_node *np,
                             const char *name, u32 *out_value);
 /**
+ * dt_property_read_u32_array - Helper to read a u32 array property.
+ * @np: node to get the value
+ * @name: name of the property
+ * @out_value: pointer to return value
+ * @out_len: lenght of the array
+ *
+ * Return true if get the desired value.
+ */
+bool_t dt_property_read_u32_array(const struct dt_device_node *np,
+                                  const char *name, u32 *out_value, u16 out_len);
+/**
  * dt_property_read_u64 - Helper to read a u64 property.
  * @np: node to get the value
  * @name: name of the property
Signature · 1 line
Julien Grall
#29 lore raw

Re: [PATCH 09/10] xen/device_tree: Add new helper to read arrays from a DTB

In reply to Frediano Ziglio

Sorry I forgot the 2 NITs (see below)

Quoted 29 lines · Frediano Ziglio

From: Zoltan Kiss <[email protected]>

---
 xen/common/device_tree.c      | 14 ++++++++++----
 xen/include/xen/device_tree.h | 11 +++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)
xen/common/device_tree.c +8 -2
index f72b2e9..e97c28b 100644
@@ -160,19 +160,25 @@ const void *dt_get_property(const struct dt_device_node *np,
 bool_t dt_property_read_u32(const struct dt_device_node *np,
                          const char *name, u32 *out_value)
 {
-    u32 len;
+    return dt_property_read_u32_array(np, name, out_value, 1);
+}
+
+bool_t dt_property_read_u32_array(const struct dt_device_node *np,
+                                  const char *name, u32 *out_value, u16 out_len)
+{
+    u32 len, i;
     const __be32 *val;
 
     val = dt_get_property(np, name, &len);
-    if ( !val || len < sizeof(*out_value) )
+    if ( !val || len < sizeof(*out_value) * out_len )

xen/common/device_tree.c const void *dt_get_property(const struct dt_device_node *np, · line 175

Quoted 10 lines
xen/common/device_tree.c +2 -2
         return 0;
 
-    *out_value = be32_to_cpup(val);
+    for ( i = 0; i < out_len; i++, val++ )
+        out_value[i] = be32_to_cpup(val);
 
     return 1;
 }
 
-

Spurious change.

Quoted 8 lines
xen/common/device_tree.c +0 -0
 bool_t dt_property_read_u64(const struct dt_device_node *np,
                          const char *name, u64 *out_value)
 {
xen/include/xen/device_tree.h +0 -0
index 08db8bc..5fcd9c4 100644

xen/include/xen/device_tree.h const struct dt_property *dt_find_property(const struct dt_device_node *np, · line 353

Quoted 8 lines
xen/include/xen/device_tree.h +5 -0
@@ -346,6 +346,17 @@ const struct dt_property *dt_find_property(const struct dt_device_node *np,
 bool_t dt_property_read_u32(const struct dt_device_node *np,
                             const char *name, u32 *out_value);
 /**
+ * dt_property_read_u32_array - Helper to read a u32 array property.
+ * @np: node to get the value
+ * @name: name of the property
+ * @out_value: pointer to return value
+ * @out_len: lenght of the array

s/lenght/length/

Regards,

Signature · 1 line
Julien Grall
#30 lore raw

PATCH 10/10 xen/arm: Handle different bootwrapper locations for Hip04 platform

In reply to Frediano Ziglio

From: Zoltan Kiss <[email protected]>

---
 xen/arch/arm/platforms/hip04.c | 63 ++++++++++++++++++++++++++----------------
 1 file changed, 39 insertions(+), 24 deletions(-)
xen/arch/arm/platforms/hip04.c +39 -24
index 024c8a0..dec4984 100644
@@ -136,7 +136,7 @@ static void hip04_cluster_up(unsigned int cluster)
 
 static int __init hip04_smp_init(void)
 {
-    struct dt_device_node *np, *np_fab;
+    struct dt_device_node *np, *np_fab, *bw;
     const char *msg;
     u64 addr, size;
 
@@ -150,30 +150,45 @@ static int __init hip04_smp_init(void)
     if ( !np_fab )
         goto err;
 
-    msg = "failed to get bootwrapper-phys\n";
     if ( !dt_property_read_u32(np, "bootwrapper-phys",
-                               &hip04_boot.bootwrapper_phys) )
-        goto err;
-
-    msg = "failed to get bootwrapper-size\n";
-    if ( !dt_property_read_u32(np, "bootwrapper-size",
-                               &hip04_boot.bootwrapper_size) )
-        goto err;
-
-    msg = "failed to get bootwrapper-magic\n";
-    if ( !dt_property_read_u32(np, "bootwrapper-magic",
-                               &hip04_boot.bootwrapper_magic) )
-        goto err;
-
-    msg = "failed to get relocation-entry\n";
-    if ( !dt_property_read_u32(np, "relocation-entry",
-                               &hip04_boot.relocation_entry) )
-        goto err;
-
-    msg = "failed to get relocation-size\n";
-    if ( !dt_property_read_u32(np, "relocation-size",
-                 &hip04_boot.relocation_size) )
-        goto err;
+                               &hip04_boot.bootwrapper_phys) ) {
+        u32 boot_method[4];
+        bw = dt_find_compatible_node(NULL, NULL, "hisilicon,hip04-bootwrapper");
+        msg = "hisilicon,hip04-bootwrapper missing in DT\n";
+        if ( !bw )
+            goto err;
+
+        msg = "failed to get boot-method\n";
+        if ( !dt_property_read_u32_array(bw, "boot-method", boot_method, 4) )
+            goto err;
+        hip04_boot.bootwrapper_phys = boot_method[0];
+        hip04_boot.bootwrapper_size = boot_method[1];
+        hip04_boot.bootwrapper_magic = 0xa5a5a5a5;
+        hip04_boot.relocation_entry = boot_method[2];
+        hip04_boot.relocation_size = boot_method[3];
+    }
+    else
+    {
+        msg = "failed to get bootwrapper-size\n";
+        if ( !dt_property_read_u32(np, "bootwrapper-size",
+                                   &hip04_boot.bootwrapper_size) )
+            goto err;
+
+        msg = "failed to get bootwrapper-magic\n";
+        if ( !dt_property_read_u32(np, "bootwrapper-magic",
+                                   &hip04_boot.bootwrapper_magic) )
+            goto err;
+
+        msg = "failed to get relocation-entry\n";
+        if ( !dt_property_read_u32(np, "relocation-entry",
+                                   &hip04_boot.relocation_entry) )
+            goto err;
+
+        msg = "failed to get relocation-size\n";
+        if ( !dt_property_read_u32(np, "relocation-size",
+                                   &hip04_boot.relocation_size) )
+            goto err;
+    }
 
     relocation = ioremap_nocache(hip04_boot.relocation_entry,
                                  hip04_boot.relocation_size);
Signature · 1 line
1.9.1
#31 lore raw

Re: [PATCH 10/10] xen/arm: Handle different bootwrapper locations for Hip04 platform

Hi Frediano,

This could be merged in #1.

Regards,

Quoted 90 lines · Frediano Ziglio

From: Zoltan Kiss <[email protected]>

---
 xen/arch/arm/platforms/hip04.c | 63 ++++++++++++++++++++++++++----------------
 1 file changed, 39 insertions(+), 24 deletions(-)
xen/arch/arm/platforms/hip04.c +39 -24
index 024c8a0..dec4984 100644
@@ -136,7 +136,7 @@ static void hip04_cluster_up(unsigned int cluster)
 
 static int __init hip04_smp_init(void)
 {
-    struct dt_device_node *np, *np_fab;
+    struct dt_device_node *np, *np_fab, *bw;
     const char *msg;
     u64 addr, size;
 
@@ -150,30 +150,45 @@ static int __init hip04_smp_init(void)
     if ( !np_fab )
         goto err;
 
-    msg = "failed to get bootwrapper-phys\n";
     if ( !dt_property_read_u32(np, "bootwrapper-phys",
-                               &hip04_boot.bootwrapper_phys) )
-        goto err;
-
-    msg = "failed to get bootwrapper-size\n";
-    if ( !dt_property_read_u32(np, "bootwrapper-size",
-                               &hip04_boot.bootwrapper_size) )
-        goto err;
-
-    msg = "failed to get bootwrapper-magic\n";
-    if ( !dt_property_read_u32(np, "bootwrapper-magic",
-                               &hip04_boot.bootwrapper_magic) )
-        goto err;
-
-    msg = "failed to get relocation-entry\n";
-    if ( !dt_property_read_u32(np, "relocation-entry",
-                               &hip04_boot.relocation_entry) )
-        goto err;
-
-    msg = "failed to get relocation-size\n";
-    if ( !dt_property_read_u32(np, "relocation-size",
-                 &hip04_boot.relocation_size) )
-        goto err;
+                               &hip04_boot.bootwrapper_phys) ) {
+        u32 boot_method[4];
+        bw = dt_find_compatible_node(NULL, NULL, "hisilicon,hip04-bootwrapper");
+        msg = "hisilicon,hip04-bootwrapper missing in DT\n";
+        if ( !bw )
+            goto err;
+
+        msg = "failed to get boot-method\n";
+        if ( !dt_property_read_u32_array(bw, "boot-method", boot_method, 4) )
+            goto err;
+        hip04_boot.bootwrapper_phys = boot_method[0];
+        hip04_boot.bootwrapper_size = boot_method[1];
+        hip04_boot.bootwrapper_magic = 0xa5a5a5a5;
+        hip04_boot.relocation_entry = boot_method[2];
+        hip04_boot.relocation_size = boot_method[3];
+    }
+    else
+    {
+        msg = "failed to get bootwrapper-size\n";
+        if ( !dt_property_read_u32(np, "bootwrapper-size",
+                                   &hip04_boot.bootwrapper_size) )
+            goto err;
+
+        msg = "failed to get bootwrapper-magic\n";
+        if ( !dt_property_read_u32(np, "bootwrapper-magic",
+                                   &hip04_boot.bootwrapper_magic) )
+            goto err;
+
+        msg = "failed to get relocation-entry\n";
+        if ( !dt_property_read_u32(np, "relocation-entry",
+                                   &hip04_boot.relocation_entry) )
+            goto err;
+
+        msg = "failed to get relocation-size\n";
+        if ( !dt_property_read_u32(np, "relocation-size",
+                                   &hip04_boot.relocation_size) )
+            goto err;
+    }
 
     relocation = ioremap_nocache(hip04_boot.relocation_entry,
                                  hip04_boot.relocation_size);
Signature · 1 line
Julien Grall
#32 lore raw

Re: [PATCH 10/10] xen/arm: Handle different bootwrapper locations for Hip04 platform

Quoted 7 lines

Hi Frediano,

This could be merged in #1.

Regards,

No, as it require the patch just before it so merging to #1 cause a commit that does not compile

Frediano

Quoted 97 lines · Frediano Ziglio
Quoted 41 lines

From: Zoltan Kiss <[email protected]>

---
 xen/arch/arm/platforms/hip04.c | 63
++++++++++++++++++++++++++----------------
 1 file changed, 39 insertions(+), 24 deletions(-)
(quoted diff) +0 -0

b/xen/arch/arm/platforms/hip04.c index 024c8a0..dec4984 100644

xen/arch/arm/platforms/hip04.c +1 -17
@@ -136,7 +136,7 @@ static void hip04_cluster_up(unsigned int cluster)
 
 static int __init hip04_smp_init(void)  {
-    struct dt_device_node *np, *np_fab;
+    struct dt_device_node *np, *np_fab, *bw;
     const char *msg;
     u64 addr, size;
 
@@ -150,30 +150,45 @@ static int __init hip04_smp_init(void)
     if ( !np_fab )
         goto err;
 
-    msg = "failed to get bootwrapper-phys\n";
     if ( !dt_property_read_u32(np, "bootwrapper-phys",
-                               &hip04_boot.bootwrapper_phys) )
-        goto err;
-
-    msg = "failed to get bootwrapper-size\n";
-    if ( !dt_property_read_u32(np, "bootwrapper-size",
-                               &hip04_boot.bootwrapper_size) )
-        goto err;
-
-    msg = "failed to get bootwrapper-magic\n";
-    if ( !dt_property_read_u32(np, "bootwrapper-magic",
-                               &hip04_boot.bootwrapper_magic) )
-        goto err;
-
-    msg = "failed to get relocation-entry\n";
-    if ( !dt_property_read_u32(np, "relocation-entry",

xen/arch/arm/platforms/hip04.c static int __init hip04_smp_init(void) · line 156

Quoted 10 lines
xen/arch/arm/platforms/hip04.c +3 -7
-                               &hip04_boot.relocation_entry) )
-        goto err;
-
-    msg = "failed to get relocation-size\n";
-    if ( !dt_property_read_u32(np, "relocation-size",
-                 &hip04_boot.relocation_size) )
-        goto err;
+                               &hip04_boot.bootwrapper_phys) ) {
+        u32 boot_method[4];
+        bw = dt_find_compatible_node(NULL, NULL, "hisilicon,hip04-

bootwrapper");

xen/arch/arm/platforms/hip04.c static int __init hip04_smp_init(void)

Quoted 6 lines
xen/arch/arm/platforms/hip04.c +6 -0
+        msg = "hisilicon,hip04-bootwrapper missing in DT\n";
+        if ( !bw )
+            goto err;
+
+        msg = "failed to get boot-method\n";
+        if ( !dt_property_read_u32_array(bw, "boot-method",

boot_method, 4) )

Quoted 23 lines
xen/arch/arm/platforms/hip04.c +22 -0
+            goto err;
+        hip04_boot.bootwrapper_phys = boot_method[0];
+        hip04_boot.bootwrapper_size = boot_method[1];
+        hip04_boot.bootwrapper_magic = 0xa5a5a5a5;
+        hip04_boot.relocation_entry = boot_method[2];
+        hip04_boot.relocation_size = boot_method[3];
+    }
+    else
+    {
+        msg = "failed to get bootwrapper-size\n";
+        if ( !dt_property_read_u32(np, "bootwrapper-size",
+                                   &hip04_boot.bootwrapper_size) )
+            goto err;
+
+        msg = "failed to get bootwrapper-magic\n";
+        if ( !dt_property_read_u32(np, "bootwrapper-magic",
+                                   &hip04_boot.bootwrapper_magic) )
+            goto err;
+
+        msg = "failed to get relocation-entry\n";
+        if ( !dt_property_read_u32(np, "relocation-entry",
+                                   &hip04_boot.relocation_entry) )

xen/arch/arm/platforms/hip04.c static int __init hip04_smp_init(void) · line 194

Quoted 10 lines
xen/arch/arm/platforms/hip04.c +7 -0
+            goto err;
+
+        msg = "failed to get relocation-size\n";
+        if ( !dt_property_read_u32(np, "relocation-size",
+                                   &hip04_boot.relocation_size) )
+            goto err;
+    }
 
     relocation = ioremap_nocache(hip04_boot.relocation_entry,
                                  hip04_boot.relocation_size);

--
Julien Grall

#33 lore raw

Re: [PATCH 10/10] xen/arm: Handle different bootwrapper locations for Hip04 platform

Quoted 9 lines · Frediano Ziglio
Quoted 7 lines

Hi Frediano,

This could be merged in #1.

Regards,

No, as it require the patch just before it so merging to #1 cause a commit that does not compile

Why don't you move the patch #9 earlier in the patch series too?

Regards,

Signature · 1 line
Julien Grall
#34 lore raw

Re: [PATCH 10/10] xen/arm: Handle different bootwrapper locations for Hip04 platform

Quoted 9 lines · Frediano Ziglio
Quoted 8 lines
Quoted 7 lines

Hi Frediano,

This could be merged in #1.

Regards,

Quoted 7 lines
Quoted 1 line

No, as it require the patch just before it so merging to #1 cause a

commit that does not compile

Why don't you move the patch #9 earlier in the patch series too?

Regards,

So move patch #9 and #10 in another position? Looks ok, which position?

I did most of changes you requested. I was thinking to post another version with this last change.

The change suggested by Ian (do not use a quirk) is still in my TODO list as could be quite big.

I don't know which constant I should use for the 510 number.

Frediano

#35 lore raw

Re: [PATCH 10/10] xen/arm: Handle different bootwrapper locations for Hip04 platform

Quoted 10 lines · Frediano Ziglio
Quoted 10 lines · Frediano Ziglio
Quoted 9 lines
Quoted 7 lines

Hi Frediano,

This could be merged in #1.

Regards,

No, as it require the patch just before it so merging to #1 cause a

Quoted 8 lines
Quoted 6 lines

commit that does not compile

Why don't you move the patch #9 earlier in the patch series too?

Regards,

So move patch #9 and #10 in another position? Looks ok, which position?

I would move #9 to the top of the list and merge #10 in the current #1.

Quoted 5 lines

I did most of changes you requested. I was thinking to post another version with this last change.

The change suggested by Ian (do not use a quirk) is still in my TODO list as could be quite big.

I don't know which constant I should use for the 510 number.

The first one is not useful as it will catch buggy hardware, the second could be replace by nr_lines.

So you could even drop the 2 510.

Signature · 1 line
Julien Grall