Skip to contentSkip to conversation

xen: arm: X-Gene Storm check GIC DIST address for EOI quirk

PATCH Superseded Pranavkumar Sawargaonkar 5 participants 8 messages Apr 6, 2015 – Apr 16, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: arm: X-Gene Storm check GIC DIST address for EOI quirk

In old X-Gene Storm firmware and DT, secure mode addresses have been mentioned in GICv2 node. In this case maintenance interrupt is used instead of EOI HW method.

This patch checks the GIC Distributor Base Address to enable EOI quirk for old firmware.

Ref:
http://lists.xen.org/archives/html/xen-devel/2014-07/msg01263.html

---
 xen/arch/arm/platforms/xgene-storm.c |   37 +++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
xen/arch/arm/platforms/xgene-storm.c +36 -1
index eee650e..dd7cbfc 100644
@@ -22,6 +22,7 @@
 #include <asm/platform.h>
 #include <xen/stdbool.h>
 #include <xen/vmap.h>
+#include <xen/device_tree.h>
 #include <asm/io.h>
 #include <asm/gic.h>
 
@@ -35,9 +36,41 @@ static u64 reset_addr, reset_size;
 static u32 reset_mask;
 static bool reset_vals_valid = false;
 
+#define XGENE_SEC_GICV2_DIST_ADDR    0x78010000
+static u32 quirk_guest_pirq_need_eoi;
+
+static void xgene_check_pirq_eoi(void)
+{
+    struct dt_device_node *node;
+    int res;
+    paddr_t dbase;
+
+    dt_for_each_device_node( dt_host, node )
+    {
+        if ( !dt_get_property(node, "interrupt-controller", NULL) )
+            continue;
+
+        res = dt_device_get_address(node, 0, &dbase, NULL);
+        if ( !dbase )
+            panic("%s: Cannot find a valid address for the "
+                    "distributor", __func__);
+
+        /* 
+         * In old X-Gene Storm firmware and DT, secure mode addresses have
+         * been mentioned in GICv2 node. We have to use maintenance interrupt
+         * instead of EOI HW in this case. We check the GIC Distributor Base
+         * Address to maintain compatibility with older firmware.
+         */
+         if (dbase == XGENE_SEC_GICV2_DIST_ADDR)
+             quirk_guest_pirq_need_eoi = PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI;
+         else
+             quirk_guest_pirq_need_eoi = 0;
+    }
+}
+
 static uint32_t xgene_storm_quirks(void)
 {
-    return PLATFORM_QUIRK_GIC_64K_STRIDE|PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI;
+    return PLATFORM_QUIRK_GIC_64K_STRIDE| quirk_guest_pirq_need_eoi;
 }
 
 static int map_one_mmio(struct domain *d, const char *what,
@@ -216,6 +249,8 @@ static int xgene_storm_init(void)
     reset_mask = XGENE_RESET_MASK;
 
     reset_vals_valid = true;
+    xgene_check_pirq_eoi();
+
     return 0;
 }
 
Signature · 1 line
1.7.9.5
#1 lore raw

Hi Pranav,

Thank you for the patch.

Quoted 28 lines · Pranavkumar Sawargaonkar

In old X-Gene Storm firmware and DT, secure mode addresses have been mentioned in GICv2 node. In this case maintenance interrupt is used instead of EOI HW method.

This patch checks the GIC Distributor Base Address to enable EOI quirk for old firmware.

Ref:
http://lists.xen.org/archives/html/xen-devel/2014-07/msg01263.html

---
  xen/arch/arm/platforms/xgene-storm.c |   37 +++++++++++++++++++++++++++++++++-
  1 file changed, 36 insertions(+), 1 deletion(-)
xen/arch/arm/platforms/xgene-storm.c +1 -0
index eee650e..dd7cbfc 100644
@@ -22,6 +22,7 @@
  #include <asm/platform.h>
  #include <xen/stdbool.h>
  #include <xen/vmap.h>
+#include <xen/device_tree.h>
  #include <asm/io.h>
  #include <asm/gic.h>
 

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 40

Quoted 5 lines
xen/arch/arm/platforms/xgene-storm.c +2 -0
@@ -35,9 +36,41 @@ static u64 reset_addr, reset_size;
  static u32 reset_mask;
  static bool reset_vals_valid = false;
 
+#define XGENE_SEC_GICV2_DIST_ADDR    0x78010000
+static u32 quirk_guest_pirq_need_eoi;

This variable will mostly be read. So, I would add __read_mostly.

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 42

Quoted 2 lines
xen/arch/arm/platforms/xgene-storm.c +2 -0
+
+static void xgene_check_pirq_eoi(void)

If I'm not mistaken, this function is only called during Xen initialization. So, I would add __init.

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 49

Quoted 7 lines
xen/arch/arm/platforms/xgene-storm.c +7 -0
+{
+    struct dt_device_node *node;
+    int res;
+    paddr_t dbase;
+
+    dt_for_each_device_node( dt_host, node )
+    {

It would be better to create a new callback for platform specific GIC initialization and use dt_interrupt_controller.

This would avoid to have this loop and rely on there is always only one interrupt controller in the DT.

Quoted 5 lines
xen/arch/arm/platforms/xgene-storm.c +5 -0
+        if ( !dt_get_property(node, "interrupt-controller", NULL) )
+            continue;
+
+        res = dt_device_get_address(node, 0, &dbase, NULL);
+        if ( !dbase )

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 64

Quoted 10 lines
xen/arch/arm/platforms/xgene-storm.c +10 -0
+            panic("%s: Cannot find a valid address for the "
+                    "distributor", __func__);
+
+        /*
+         * In old X-Gene Storm firmware and DT, secure mode addresses have
+         * been mentioned in GICv2 node. We have to use maintenance interrupt
+         * instead of EOI HW in this case. We check the GIC Distributor Base
+         * Address to maintain compatibility with older firmware.
+         */
+         if (dbase == XGENE_SEC_GICV2_DIST_ADDR)

Coding style:

if ( ... )

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 67

Quoted 3 lines
xen/arch/arm/platforms/xgene-storm.c +3 -0
+             quirk_guest_pirq_need_eoi = PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI;
+         else
+             quirk_guest_pirq_need_eoi = 0;

I would print a warning in order to notify the user that his platform would be slow/buggy...

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 73

Quoted 7 lines
xen/arch/arm/platforms/xgene-storm.c +4 -1
+    }
+}
+
  static uint32_t xgene_storm_quirks(void)
  {
-    return PLATFORM_QUIRK_GIC_64K_STRIDE|PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI;
+    return PLATFORM_QUIRK_GIC_64K_STRIDE| quirk_guest_pirq_need_eoi;

This function is called every time Xen injects a physical IRQ to a guest (i.e very often). It might be better to create a variable quirks which will contain PLATFORM_QUIRK_GIC_64K_STRIDE and, when necessary, PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI.

That would avoid the "or" at each call.

Regards,

Signature · 1 line
Julien Grall
#2 lore raw
Quoted 60 lines · Julien Grall

Hi Pranav,

Thank you for the patch.

Quoted 30 lines · Pranavkumar Sawargaonkar

In old X-Gene Storm firmware and DT, secure mode addresses have been mentioned in GICv2 node. In this case maintenance interrupt is used instead of EOI HW method.

This patch checks the GIC Distributor Base Address to enable EOI quirk for old firmware.

Ref:
http://lists.xen.org/archives/html/xen-devel/2014-07/msg01263.html

---
  xen/arch/arm/platforms/xgene-storm.c |   37
+++++++++++++++++++++++++++++++++-
  1 file changed, 36 insertions(+), 1 deletion(-)
xen/arch/arm/platforms/xgene-storm.c +1 -0
index eee650e..dd7cbfc 100644
@@ -22,6 +22,7 @@
  #include <asm/platform.h>
  #include <xen/stdbool.h>
  #include <xen/vmap.h>
+#include <xen/device_tree.h>
  #include <asm/io.h>
  #include <asm/gic.h>
 

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 40

Quoted 5 lines
xen/arch/arm/platforms/xgene-storm.c +2 -0
@@ -35,9 +36,41 @@ static u64 reset_addr, reset_size;
  static u32 reset_mask;
  static bool reset_vals_valid = false;
 
+#define XGENE_SEC_GICV2_DIST_ADDR    0x78010000
+static u32 quirk_guest_pirq_need_eoi;

This variable will mostly be read. So, I would add __read_mostly.

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 42

Quoted 2 lines
xen/arch/arm/platforms/xgene-storm.c +2 -0
+
+static void xgene_check_pirq_eoi(void)

If I'm not mistaken, this function is only called during Xen initialization. So, I would add __init.

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 49

Quoted 7 lines
xen/arch/arm/platforms/xgene-storm.c +7 -0
+{
+    struct dt_device_node *node;
+    int res;
+    paddr_t dbase;
+
+    dt_for_each_device_node( dt_host, node )
+    {

It would be better to create a new callback for platform specific GIC initialization and use dt_interrupt_controller.

Quoted 2 lines

This would avoid to have this loop and rely on there is always only one interrupt controller in the DT.

That is true, however we do know that on this SoC there is only one GIC, so it might be acceptable to rely on this knowledge: this is already very platform specific code.

Quoted 22 lines
Quoted 14 lines
xen/arch/arm/platforms/xgene-storm.c +11 -0
+        if ( !dt_get_property(node, "interrupt-controller", NULL) )
+            continue;
+
+        res = dt_device_get_address(node, 0, &dbase, NULL);
+        if ( !dbase )
+            panic("%s: Cannot find a valid address for the "
+                    "distributor", __func__);
+
+        /*
+         * In old X-Gene Storm firmware and DT, secure mode addresses have
+         * been mentioned in GICv2 node. We have to use maintenance

interrupt
+ * instead of EOI HW in this case. We check the GIC Distributor
Base

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 64

Quoted 3 lines
xen/arch/arm/platforms/xgene-storm.c +3 -0
+         * Address to maintain compatibility with older firmware.
+         */
+         if (dbase == XGENE_SEC_GICV2_DIST_ADDR)

Coding style:

if ( ... )

Quoted 7 lines

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 67

Quoted 4 lines

+ quirk_guest_pirq_need_eoi =
PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI;

xen/arch/arm/platforms/xgene-storm.c +2 -0
+         else
+             quirk_guest_pirq_need_eoi = 0;

I would print a warning in order to notify the user that his platform would be slow/buggy...

Good idea.

Quoted 21 lines
Quoted 8 lines
xen/arch/arm/platforms/xgene-storm.c +3 -1
+    }
+}
+
  static uint32_t xgene_storm_quirks(void)
  {
-    return

PLATFORM_QUIRK_GIC_64K_STRIDE|PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI;
+ return PLATFORM_QUIRK_GIC_64K_STRIDE| quirk_guest_pirq_need_eoi;

This function is called every time Xen injects a physical IRQ to a guest (i.e very often). It might be better to create a variable quirks which will contain PLATFORM_QUIRK_GIC_64K_STRIDE and, when necessary, PLATFORM_QUIRK_GUEST_PIRQ_NEED_EOI.

That would avoid the "or" at each call.

Regards,

Signature · 1 line
Julien Grall
#3 lore raw

Hi Stefano,

Quoted 61 lines · Stefano Stabellini
Quoted 60 lines · Julien Grall

Hi Pranav,

Thank you for the patch.

Quoted 30 lines · Pranavkumar Sawargaonkar

In old X-Gene Storm firmware and DT, secure mode addresses have been mentioned in GICv2 node. In this case maintenance interrupt is used instead of EOI HW method.

This patch checks the GIC Distributor Base Address to enable EOI quirk for old firmware.

Ref:
http://lists.xen.org/archives/html/xen-devel/2014-07/msg01263.html

---
   xen/arch/arm/platforms/xgene-storm.c |   37
+++++++++++++++++++++++++++++++++-
   1 file changed, 36 insertions(+), 1 deletion(-)
xen/arch/arm/platforms/xgene-storm.c +1 -0
index eee650e..dd7cbfc 100644
@@ -22,6 +22,7 @@
   #include <asm/platform.h>
   #include <xen/stdbool.h>
   #include <xen/vmap.h>
+#include <xen/device_tree.h>
   #include <asm/io.h>
   #include <asm/gic.h>
 

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 40

Quoted 5 lines
xen/arch/arm/platforms/xgene-storm.c +2 -0
@@ -35,9 +36,41 @@ static u64 reset_addr, reset_size;
   static u32 reset_mask;
   static bool reset_vals_valid = false;
 
+#define XGENE_SEC_GICV2_DIST_ADDR    0x78010000
+static u32 quirk_guest_pirq_need_eoi;

This variable will mostly be read. So, I would add __read_mostly.

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 42

Quoted 2 lines
xen/arch/arm/platforms/xgene-storm.c +2 -0
+
+static void xgene_check_pirq_eoi(void)

If I'm not mistaken, this function is only called during Xen initialization. So, I would add __init.

xen/arch/arm/platforms/xgene-storm.c static u64 reset_addr, reset_size; · line 49

Quoted 7 lines
xen/arch/arm/platforms/xgene-storm.c +7 -0
+{
+    struct dt_device_node *node;
+    int res;
+    paddr_t dbase;
+
+    dt_for_each_device_node( dt_host, node )
+    {

It would be better to create a new callback for platform specific GIC initialization and use dt_interrupt_controller.

Quoted 6 lines
Quoted 2 lines

This would avoid to have this loop and rely on there is always only one interrupt controller in the DT.

That is true, however we do know that on this SoC there is only one GIC, so it might be acceptable to rely on this knowledge: this is already very platform specific code.

If we keep the loop, I would add a comment on the above the loop explaining that we rely on there is always only GIC.

Although, I was wondering if we could simply rely on the node path to get the DT node?

Regards,

Signature · 1 line
Julien Grall
#4 lore raw
Quoted 7 lines · Julien Grall
Quoted 6 lines
Quoted 2 lines

This would avoid to have this loop and rely on there is always only one interrupt controller in the DT.

That is true, however we do know that on this SoC there is only one GIC, so it might be acceptable to rely on this knowledge: this is already very platform specific code.

Quoted 5 lines

If we keep the loop, I would add a comment on the above the loop explaining that we rely on there is always only GIC.

Although, I was wondering if we could simply rely on the node path to get the DT node?

If we know that all $OLD firmwares used the same path (or small set of paths) then that could work.

Or the loop could be replaced with dt_find_interrupt_controller, passing the known compatible value for the systems in question.

Ian.

#5 lore raw

Hi Ian,

Quoted 11 lines · Ian Campbell
Quoted 10 lines · Julien Grall
Quoted 6 lines
Quoted 2 lines

This would avoid to have this loop and rely on there is always only one interrupt controller in the DT.

That is true, however we do know that on this SoC there is only one GIC, so it might be acceptable to rely on this knowledge: this is already very platform specific code.

If we keep the loop, I would add a comment on the above the loop explaining that we rely on there is always only GIC.

Quoted 8 lines
Quoted 2 lines

Although, I was wondering if we could simply rely on the node path to get the DT node?

If we know that all $OLD firmwares used the same path (or small set of paths) then that could work.

Or the loop could be replaced with dt_find_interrupt_controller, passing the known compatible value for the systems in question.

Yeah that is good option as there is no change in the path between firmware revisions.

Thanks,
Pranav

Quoted 3 lines

Ian.

Tested-by on v1 1/1
#6 lore raw
In reply to Pranavkumar Sawargaonkar

Hi Pranav,

Quoted 11 lines · Pranavkumar Sawargaonkar

In old X-Gene Storm firmware and DT, secure mode addresses have been mentioned in GICv2 node. In this case maintenance interrupt is used instead of EOI HW method.

This patch checks the GIC Distributor Base Address to enable EOI quirk for old firmware.

Ref:
http://lists.xen.org/archives/html/xen-devel/2014-07/msg01263.html

I have tested this on the m400 cluster and can confirm that it prevents the issue with ab trashing the machine:

#7 lore raw
Quoted 13 lines · Christoffer Dall

Hi Pranav,

Quoted 10 lines · Pranavkumar Sawargaonkar

In old X-Gene Storm firmware and DT, secure mode addresses have been mentioned in GICv2 node. In this case maintenance interrupt is used instead of EOI HW method.

This patch checks the GIC Distributor Base Address to enable EOI quirk for old firmware.

Ref:
http://lists.xen.org/archives/html/xen-devel/2014-07/msg01263.html

Quoted 6 lines
Quoted 1 line

I have tested this on the m400 cluster and can confirm that it prevents the issue with ab trashing the machine:

Thanks Christoffer for cross checking.
will sent out a new revision of the patch with comments addressed.

Thanks,
Pranav