Skip to contentSkip to conversation

irq: introduce qemu_irq_proxy()

PATCH Applied Avi Kivity 3 participants 4 messages Sep 18, 2011 – Sep 23, 2011

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 irq: introduce qemu_irq_proxy()

In some cases we have a circular dependency involving irqs - the irq controller depends on a bus, which in turn depends on the irq controller. Add qemu_irq_proxy() which acts as a passthrough, except that the target irq may be set later on.

---

Turns out the circular dependency i8259->isa->pci->i8259 is widespread, so introduce a general means of fixing it up. I'll update the patchset to make use of it everywhere it occurs.

 hw/irq.c |   14 ++++++++++++++
 hw/irq.h |    5 +++++
 2 files changed, 19 insertions(+), 0 deletions(-)
hw/irq.c +14 -0
index 60eabe8..62f766e 100644
@@ -90,3 +90,17 @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2)
     s[1] = irq2;
     return qemu_allocate_irqs(qemu_splitirq, s, 1)[0];
 }
+
+static void proxy_irq_handler(void *opaque, int n, int level)
+{
+    qemu_irq **target = opaque;
+
+    if (*target) {
+        qemu_set_irq((*target)[n], level);
+    }
+}
+
+qemu_irq *qemu_irq_proxy(qemu_irq **target, int n)
+{
+    return qemu_allocate_irqs(proxy_irq_handler, target, n);
+}
hw/irq.h +5 -0
index 389ed7a..64da2fd 100644
@@ -33,4 +33,9 @@ qemu_irq qemu_irq_invert(qemu_irq irq);
 /* Returns a new IRQ which feeds into both the passed IRQs */
 qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2);
 
+/* Returns a new IRQ set which connects 1:1 to another IRQ set, which
+ * may be set later.
+ */
+qemu_irq *qemu_irq_proxy(qemu_irq **target, int n);
+
 #endif
Signature · 1 line
1.7.6.3
author
#1 lore raw
Quoted 11 lines · Avi Kivity

In some cases we have a circular dependency involving irqs - the irq controller depends on a bus, which in turn depends on the irq controller. Add qemu_irq_proxy() which acts as a passthrough, except that the target irq may be set later on.

---

Turns out the circular dependency i8259->isa->pci->i8259 is widespread, so introduce a general means of fixing it up. I'll update the patchset to make use of it everywhere it occurs.

In fact the other cases were solved without qemu_irq_proxy(), but I think qemu_irq_proxy() is nicer than the previous patch, so I'll keep it if no one objects.

Signature · 1 line
error compiling committee.c: too many arguments to function
Reviewed-by on v1 1/1
#2 lore raw
In reply to Avi Kivity
Quoted 6 lines · Avi Kivity

In some cases we have a circular dependency involving irqs - the irq controller depends on a bus, which in turn depends on the irq controller. Add qemu_irq_proxy() which acts as a passthrough, except that the target irq may be set later on.

Quoted 46 lines

---

Turns out the circular dependency i8259->isa->pci->i8259 is widespread, so introduce a general means of fixing it up. I'll update the patchset to make use of it everywhere it occurs.

 hw/irq.c |   14 ++++++++++++++
 hw/irq.h |    5 +++++
 2 files changed, 19 insertions(+), 0 deletions(-)
hw/irq.c +14 -0
index 60eabe8..62f766e 100644
@@ -90,3 +90,17 @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2)
     s[1] = irq2;
     return qemu_allocate_irqs(qemu_splitirq, s, 1)[0];
 }
+
+static void proxy_irq_handler(void *opaque, int n, int level)
+{
+    qemu_irq **target = opaque;
+
+    if (*target) {
+        qemu_set_irq((*target)[n], level);
+    }
+}
+
+qemu_irq *qemu_irq_proxy(qemu_irq **target, int n)
+{
+    return qemu_allocate_irqs(proxy_irq_handler, target, n);
+}
hw/irq.h +5 -0
index 389ed7a..64da2fd 100644
@@ -33,4 +33,9 @@ qemu_irq qemu_irq_invert(qemu_irq irq);
 /* Returns a new IRQ which feeds into both the passed IRQs */
 qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2);
 
+/* Returns a new IRQ set which connects 1:1 to another IRQ set, which
+ * may be set later.
+ */
+qemu_irq *qemu_irq_proxy(qemu_irq **target, int n);
+
 #endif
#3 lore raw
In reply to Avi Kivity
Quoted 6 lines · Avi Kivity

In some cases we have a circular dependency involving irqs - the irq controller depends on a bus, which in turn depends on the irq controller. Add qemu_irq_proxy() which acts as a passthrough, except that the target irq may be set later on.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 46 lines

---

Turns out the circular dependency i8259->isa->pci->i8259 is widespread, so introduce a general means of fixing it up. I'll update the patchset to make use of it everywhere it occurs.

  hw/irq.c |   14 ++++++++++++++
  hw/irq.h |    5 +++++
  2 files changed, 19 insertions(+), 0 deletions(-)
hw/irq.c +14 -0
index 60eabe8..62f766e 100644
@@ -90,3 +90,17 @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2)
      s[1] = irq2;
      return qemu_allocate_irqs(qemu_splitirq, s, 1)[0];
  }
+
+static void proxy_irq_handler(void *opaque, int n, int level)
+{
+    qemu_irq **target = opaque;
+
+    if (*target) {
+        qemu_set_irq((*target)[n], level);
+    }
+}
+
+qemu_irq *qemu_irq_proxy(qemu_irq **target, int n)
+{
+    return qemu_allocate_irqs(proxy_irq_handler, target, n);
+}
hw/irq.h +5 -0
index 389ed7a..64da2fd 100644
@@ -33,4 +33,9 @@ qemu_irq qemu_irq_invert(qemu_irq irq);
  /* Returns a new IRQ which feeds into both the passed IRQs */
  qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2);
 
+/* Returns a new IRQ set which connects 1:1 to another IRQ set, which
+ * may be set later.
+ */
+qemu_irq *qemu_irq_proxy(qemu_irq **target, int n);
+
  #endif