Skip to contentSkip to conversation

arm_gic: Improve handling of GICD_ICFGR

PATCH In review Adam Lackorzynski 2 participants 8 messages Aug 16, 2014 – Aug 18, 2014

lore
Share & tools
lore
#0 lore raw

cover arm_gic: Improve handling of GICD_ICFGR

The following patches address the behavior of the GICD_ICFGR register in the ARM GIC.

Changes to previous version:
- Setting of model mode only for old GIC revisions
- Less invasive change for PPI settings

Adam Lackorzynski (3):
arm_gic: Fix read of GICD_ICFGR
arm_gic: GICD_ICFGR: Write model only for pre v1 GICs
arm_gic: Do not force PPIs to edge-triggered mode

 hw/intc/arm_gic.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
Signature · 1 line
2.1.0.rc1
#1 lore raw

PATCH 1/3 arm_gic: Fix read of GICD_ICFGR

The GICD_ICFGR register covers 4 interrupts per byte.

---
 hw/intc/arm_gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gic.c +1 -1
index 1532ef9..d2b1aaf 100644
@@ -372,7 +372,7 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset)
         }
     } else if (offset < 0xf00) {
         /* Interrupt Configuration.  */
-        irq = (offset - 0xc00) * 2 + GIC_BASE_IRQ;
+        irq = (offset - 0xc00) * 4 + GIC_BASE_IRQ;
         if (irq >= s->num_irq)
             goto bad_reg;
         res = 0;
Signature · 1 line
2.1.0.rc1
#2 lore raw

PATCH 2/3 arm_gic: GICD_ICFGR: Write model only for pre v1 GICs

In reply to Adam Lackorzynski

Setting the model is only available in pre-v1 GIC models.

---
 hw/intc/arm_gic.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
hw/intc/arm_gic.c +6 -4
index d2b1aaf..e546647 100644
@@ -561,10 +561,12 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
         if (irq < GIC_INTERNAL)
             value |= 0xaa;
         for (i = 0; i < 4; i++) {
-            if (value & (1 << (i * 2))) {
-                GIC_SET_MODEL(irq + i);
-            } else {
-                GIC_CLEAR_MODEL(irq + i);
+            if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {
+                if (value & (1 << (i * 2))) {
+                    GIC_SET_MODEL(irq + i);
+                } else {
+                    GIC_CLEAR_MODEL(irq + i);
+                }
             }
             if (value & (2 << (i * 2))) {
                 GIC_SET_EDGE_TRIGGER(irq + i);
Signature · 1 line
2.1.0.rc1
Acked-by on v1 2/3
#3 lore raw

Re: [Qemu-devel] [PATCH 2/3] arm_gic: GICD_ICFGR: Write model only for pre v1 GICs

Quoted 29 lines · Adam Lackorzynski

Setting the model is only available in pre-v1 GIC models.

---
 hw/intc/arm_gic.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
hw/intc/arm_gic.c +6 -4
index d2b1aaf..e546647 100644
@@ -561,10 +561,12 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
         if (irq < GIC_INTERNAL)
             value |= 0xaa;
         for (i = 0; i < 4; i++) {
-            if (value & (1 << (i * 2))) {
-                GIC_SET_MODEL(irq + i);
-            } else {
-                GIC_CLEAR_MODEL(irq + i);
+            if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {
+                if (value & (1 << (i * 2))) {
+                    GIC_SET_MODEL(irq + i);
+                } else {
+                    GIC_CLEAR_MODEL(irq + i);
+                }
             }
             if (value & (2 << (i * 2))) {
                 GIC_SET_EDGE_TRIGGER(irq + i);
Signature · 1 line
2.1.0.rc1

looks good,

#4 lore raw

PATCH 3/3 arm_gic: Do not force PPIs to edge-triggered mode

In reply to Adam Lackorzynski

Only SGIs must be WI, done by forcing them to their default (edge-triggered).

---
 hw/intc/arm_gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gic.c +1 -1
index e546647..55019c9 100644
@@ -558,7 +558,7 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
         irq = (offset - 0xc00) * 4 + GIC_BASE_IRQ;
         if (irq >= s->num_irq)
             goto bad_reg;
-        if (irq < GIC_INTERNAL)
+        if (irq < GIC_NR_SGIS)
             value |= 0xaa;
         for (i = 0; i < 4; i++) {
             if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {
Signature · 1 line
2.1.0.rc1
#5 lore raw

Re: [Qemu-devel] [PATCH 3/3] arm_gic: Do not force PPIs to edge-triggered mode

Quoted 24 lines · Adam Lackorzynski

Only SGIs must be WI, done by forcing them to their default (edge-triggered).

---
 hw/intc/arm_gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gic.c +1 -1
index e546647..55019c9 100644
@@ -558,7 +558,7 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
         irq = (offset - 0xc00) * 4 + GIC_BASE_IRQ;
         if (irq >= s->num_irq)
             goto bad_reg;
-        if (irq < GIC_INTERNAL)
+        if (irq < GIC_NR_SGIS)
             value |= 0xaa;
         for (i = 0; i < 4; i++) {
             if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {
Signature · 1 line
2.1.0.rc1

where do we ensure that the SGIs are actually configured as edge-triggered when creating the gic?

-Christoffer

#6 lore raw

Re: [Qemu-devel] [PATCH 3/3] arm_gic: Do not force PPIs to edge-triggered mode

Quoted 20 lines · Christoffer Dall
Quoted 19 lines · Adam Lackorzynski

Only SGIs must be WI, done by forcing them to their default (edge-triggered).

---
 hw/intc/arm_gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gic.c +1 -1
index e546647..55019c9 100644
@@ -558,7 +558,7 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
         irq = (offset - 0xc00) * 4 + GIC_BASE_IRQ;
         if (irq >= s->num_irq)
             goto bad_reg;
-        if (irq < GIC_INTERNAL)
+        if (irq < GIC_NR_SGIS)
             value |= 0xaa;
Quoted 8 lines
Quoted 5 lines
hw/intc/arm_gic.c +0 -0
         for (i = 0; i < 4; i++) {
             if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {
Signature · 1 line
2.1.0.rc1

where do we ensure that the SGIs are actually configured as edge-triggered when creating the gic?

It's setup in arm_gic_common_reset() in arm_gic_common.c. (Looks like I should add another change to use GIC_NR_SGIS there too.)

Adam

Signature · 2 lines
Adam                 [email protected]
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/
#7 lore raw

Re: [Qemu-devel] [PATCH 3/3] arm_gic: Do not force PPIs to edge-triggered mode

Quoted 30 lines · Adam Lackorzynski
Quoted 20 lines · Christoffer Dall
Quoted 19 lines · Adam Lackorzynski

Only SGIs must be WI, done by forcing them to their default (edge-triggered).

---
 hw/intc/arm_gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gic.c +1 -1
index e546647..55019c9 100644
@@ -558,7 +558,7 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,
         irq = (offset - 0xc00) * 4 + GIC_BASE_IRQ;
         if (irq >= s->num_irq)
             goto bad_reg;
-        if (irq < GIC_INTERNAL)
+        if (irq < GIC_NR_SGIS)
             value |= 0xaa;
Quoted 8 lines
Quoted 5 lines
hw/intc/arm_gic.c +0 -0
         for (i = 0; i < 4; i++) {
             if (s->revision == REV_11MPCORE || s->revision == REV_NVIC) {
Signature · 1 line
2.1.0.rc1

where do we ensure that the SGIs are actually configured as edge-triggered when creating the gic?

Quoted 3 lines

It's setup in arm_gic_common_reset() in arm_gic_common.c. (Looks like I should add another change to use GIC_NR_SGIS there too.)

That would be good, for this patch:

Thanks!