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 3/5] irqfd: equip irqfd with polarity
Date: Thu, 12 Sep 2013 13:24:51 +0800 [thread overview]
Message-ID: <1378963493-559-4-git-send-email-pingfank@linux.vnet.ibm.com> (raw)
In-Reply-To: <1378963493-559-1-git-send-email-pingfank@linux.vnet.ibm.com>
Equip irqfd with polarity, so it can emulate the low-active interrupt.
We take one extra bit in flags to pass this info to kernel and keep
the default value "zero" as high-active.
Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
The kernel will extend this interface correspondingly
---
hw/misc/vfio.c | 4 ++--
hw/virtio/virtio-pci.c | 2 +-
include/sysemu/kvm.h | 3 ++-
kvm-all.c | 14 ++++++++------
| 3 +++
5 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index a1c08fb..f1fb761 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -646,7 +646,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
vector->virq = msg ? kvm_irqchip_add_msi_route(kvm_state, *msg) : -1;
if (vector->virq < 0 ||
kvm_irqchip_add_irqfd_notifier(kvm_state, &vector->interrupt,
- NULL, vector->virq) < 0) {
+ NULL, vector->virq, 0) < 0) {
if (vector->virq >= 0) {
kvm_irqchip_release_virq(kvm_state, vector->virq);
vector->virq = -1;
@@ -814,7 +814,7 @@ retry:
vector->virq = kvm_irqchip_add_msi_route(kvm_state, msg);
if (vector->virq < 0 ||
kvm_irqchip_add_irqfd_notifier(kvm_state, &vector->interrupt,
- NULL, vector->virq) < 0) {
+ NULL, vector->virq, 0) < 0) {
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
vfio_msi_interrupt, NULL, vector);
}
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index f2c489b..a8dbb4f 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -508,7 +508,7 @@ static int kvm_virtio_pci_irqfd_use(VirtIOPCIProxy *proxy,
VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no);
EventNotifier *n = virtio_queue_get_guest_notifier(vq);
int ret;
- ret = kvm_irqchip_add_irqfd_notifier(kvm_state, n, NULL, irqfd->virq);
+ ret = kvm_irqchip_add_irqfd_notifier(kvm_state, n, NULL, irqfd->virq, 0);
return ret;
}
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 47cc012..a990db7 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -309,8 +309,9 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg);
int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg);
void kvm_irqchip_release_virq(KVMState *s, int virq);
+/* polarity: 0 high-active */
int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n,
- EventNotifier *rn, int virq);
+ EventNotifier *rn, int virq, int polarity);
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);
diff --git a/kvm-all.c b/kvm-all.c
index 875e32e..d0e457b 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1231,12 +1231,13 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
}
static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int rfd, int virq,
- bool assign)
+ bool assign, int polarity)
{
struct kvm_irqfd irqfd = {
.fd = fd,
.gsi = virq,
- .flags = assign ? 0 : KVM_IRQFD_FLAG_DEASSIGN,
+ .flags = (assign ? 0 : KVM_IRQFD_FLAG_DEASSIGN)
+ | (polarity ? 0 : KVM_IRQFD_FLAG_POLARITY),
};
if (rfd != -1) {
@@ -1271,7 +1272,8 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
return -ENOSYS;
}
-static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int virq, bool assign)
+static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int virq, bool assign,
+ int polarity)
{
abort();
}
@@ -1283,16 +1285,16 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
#endif /* !KVM_CAP_IRQ_ROUTING */
int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n,
- EventNotifier *rn, int virq)
+ EventNotifier *rn, int virq, int polarity)
{
return kvm_irqchip_assign_irqfd(s, event_notifier_get_fd(n),
- rn ? event_notifier_get_fd(rn) : -1, virq, true);
+ rn ? event_notifier_get_fd(rn) : -1, virq, true, polarity);
}
int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq)
{
return kvm_irqchip_assign_irqfd(s, event_notifier_get_fd(n), -1, virq,
- false);
+ false, 0);
}
static int kvm_irqchip_create(KVMState *s)
--git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index c614070..64afc8a 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -740,6 +740,9 @@ struct kvm_xen_hvm_config {
*/
#define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
+/* 0: high-active */
+#define KVM_IRQFD_FLAG_POLARITY (1<<2)
+
struct kvm_irqfd {
__u32 fd;
__u32 gsi;
--
1.8.1.4
next prev parent reply other threads:[~2013-09-12 5:26 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 ` [Qemu-devel] [PATCH 2/5] irq: implement route method of ioapic Liu Ping Fan
2013-09-12 5:24 ` Liu Ping Fan [this message]
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-4-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).