From: Liu Ping Fan <qemulist@gmail.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Anthony Liguori <anthony@codemonkey.ws>,
Jan Kiszka <jan.kiszka@siemens.com>
Subject: [Qemu-devel] [PATCH 2/5] irq: implement route method of ioapic
Date: Thu, 12 Sep 2013 13:24:50 +0800 [thread overview]
Message-ID: <1378963493-559-3-git-send-email-pingfank@linux.vnet.ibm.com> (raw)
In-Reply-To: <1378963493-559-1-git-send-email-pingfank@linux.vnet.ibm.com>
Implement the routing of PC's interrupt gpio to intc, and
retrieve the gsi.
Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
hw/core/qdev.c | 8 ++++++++
hw/i386/kvm/i8259.c | 8 +++++++-
hw/i386/kvm/ioapic.c | 21 ++++++++++++++++++++-
hw/i386/pc_q35.c | 4 ++--
include/hw/qdev-core.h | 2 ++
include/sysemu/kvm.h | 1 +
6 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 758de9f..63605d1 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -312,6 +312,14 @@ void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n)
dev->num_gpio_in += n;
}
+void qdev_init_gpio_in_2(DeviceState *dev, qemu_irq_handler handler,
+ qemu_irq_route route, int n)
+{
+ dev->gpio_in = qemu_extend_irqs_2(dev->gpio_in, dev->num_gpio_in, handler,
+ route, dev, n);
+ dev->num_gpio_in += n;
+}
+
void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n)
{
assert(dev->num_gpio_out == 0);
diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c
index 53e3ca8..1193b54 100644
--- a/hw/i386/kvm/i8259.c
+++ b/hw/i386/kvm/i8259.c
@@ -106,6 +106,11 @@ static void kvm_pic_reset(DeviceState *dev)
kvm_pic_put(s);
}
+static int kvm_pic_route_gsi(void *opaque, int irq)
+{
+ return irq;
+}
+
static void kvm_pic_set_irq(void *opaque, int irq, int level)
{
int delivered;
@@ -130,7 +135,8 @@ qemu_irq *kvm_i8259_init(ISABus *bus)
i8259_init_chip(TYPE_KVM_I8259, bus, true);
i8259_init_chip(TYPE_KVM_I8259, bus, false);
- return qemu_allocate_irqs(kvm_pic_set_irq, NULL, ISA_NUM_IRQS);
+ return qemu_extend_irqs_2(NULL, 0, kvm_pic_set_irq, kvm_pic_route_gsi,
+ NULL, ISA_NUM_IRQS);
}
static void kvm_i8259_class_init(ObjectClass *klass, void *data)
diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c
index f11a540..1e6ff0b 100644
--- a/hw/i386/kvm/ioapic.c
+++ b/hw/i386/kvm/ioapic.c
@@ -44,6 +44,19 @@ void kvm_pc_setup_irq_routing(bool pci_enabled)
}
}
+int kvm_pc_route_gsi(void *opaque, int n)
+{
+ GSIState *s = opaque;
+ int gsi;
+
+ if (n < ISA_NUM_IRQS) {
+ gsi = qemu_irq_route_gsi(s->i8259_irq[n]);
+ } else {
+ gsi = qemu_irq_route_gsi(s->ioapic_irq[n]);
+ }
+ return gsi;
+}
+
void kvm_pc_gsi_handler(void *opaque, int n, int level)
{
GSIState *s = opaque;
@@ -127,11 +140,17 @@ static void kvm_ioapic_set_irq(void *opaque, int irq, int level)
apic_report_irq_delivered(delivered);
}
+static int kvm_ioapic_route_irq(void *opaque, int irq)
+{
+ return irq;
+}
+
static void kvm_ioapic_init(IOAPICCommonState *s, int instance_no)
{
memory_region_init_reservation(&s->io_memory, NULL, "kvm-ioapic", 0x1000);
- qdev_init_gpio_in(DEVICE(s), kvm_ioapic_set_irq, IOAPIC_NUM_PINS);
+ qdev_init_gpio_in_2(DEVICE(s), kvm_ioapic_set_irq, kvm_ioapic_route_irq,
+ IOAPIC_NUM_PINS);
}
static Property kvm_ioapic_properties[] = {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 198c785..df1deb3 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -120,8 +120,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
gsi_state = g_malloc0(sizeof(*gsi_state));
if (kvm_irqchip_in_kernel()) {
kvm_pc_setup_irq_routing(pci_enabled);
- gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
- GSI_NUM_PINS);
+ gsi = qemu_extend_irqs_2(NULL, 0, kvm_pc_gsi_handler,
+ kvm_pc_route_gsi, gsi_state, GSI_NUM_PINS);
} else {
gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
}
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 46972f4..4b8eb35 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -252,6 +252,8 @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
/* Register device properties. */
/* GPIO inputs also double as IRQ sinks. */
void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
+void qdev_init_gpio_in_2(DeviceState *dev, qemu_irq_handler handler,
+ qemu_irq_route route, int n);
void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
BusState *qdev_get_parent_bus(DeviceState *dev);
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 8e76685..47cc012 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -312,6 +312,7 @@ void kvm_irqchip_release_virq(KVMState *s, int virq);
int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n,
EventNotifier *rn, int virq);
int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq);
+int kvm_pc_route_gsi(void *opaque, int n);
void kvm_pc_gsi_handler(void *opaque, int n, int level);
void kvm_pc_setup_irq_routing(bool pci_enabled);
void kvm_init_irq_routing(KVMState *s);
--
1.8.1.4
next prev parent reply other threads:[~2013-09-12 5:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-12 5:24 [Qemu-devel] [RFC 0/5] run hpet on a dedicated thread Liu Ping Fan
2013-09-12 5:24 ` [Qemu-devel] [PATCH 1/5] irq: introduce route method in IRQState to get gsi Liu Ping Fan
2013-09-12 5:24 ` Liu Ping Fan [this message]
2013-09-12 5:24 ` [Qemu-devel] [PATCH 3/5] irqfd: equip irqfd with polarity Liu Ping Fan
2013-09-12 5:24 ` [Qemu-devel] [PATCH 4/5] hpet: deliver irq by irqfd when in dedicated thread mode Liu Ping Fan
2013-09-12 5:24 ` [Qemu-devel] [PATCH 5/5] hpet: run on dedicate thread Liu Ping Fan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1378963493-559-3-git-send-email-pingfank@linux.vnet.ibm.com \
--to=qemulist@gmail.com \
--cc=anthony@codemonkey.ws \
--cc=jan.kiszka@siemens.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).