diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2011-09-12 12:57:56 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-09-25 12:52:45 -0400 |
commit | cc0793968a602c9b40f7b99c401674750aa99e06 (patch) | |
tree | 9ffe6978abe91b4e8cc330e530204e08844e194c /virt/kvm/assigned-dev.c | |
parent | 9bc5791d4aa78b72abd76f506c0a391a54abc4d1 (diff) |
KVM: Split up MSI-X assigned device IRQ handler
The threaded IRQ handler for MSI-X has almost nothing in common with the
INTx/MSI handler. Move its code into a dedicated handler.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'virt/kvm/assigned-dev.c')
-rw-r--r-- | virt/kvm/assigned-dev.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c index 84ead5489650..7debe8c9e10e 100644 --- a/virt/kvm/assigned-dev.c +++ b/virt/kvm/assigned-dev.c | |||
@@ -58,8 +58,6 @@ static int find_index_from_host_irq(struct kvm_assigned_dev_kernel | |||
58 | static irqreturn_t kvm_assigned_dev_thread(int irq, void *dev_id) | 58 | static irqreturn_t kvm_assigned_dev_thread(int irq, void *dev_id) |
59 | { | 59 | { |
60 | struct kvm_assigned_dev_kernel *assigned_dev = dev_id; | 60 | struct kvm_assigned_dev_kernel *assigned_dev = dev_id; |
61 | u32 vector; | ||
62 | int index; | ||
63 | 61 | ||
64 | if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_HOST_INTX) { | 62 | if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_HOST_INTX) { |
65 | spin_lock(&assigned_dev->intx_lock); | 63 | spin_lock(&assigned_dev->intx_lock); |
@@ -68,20 +66,28 @@ static irqreturn_t kvm_assigned_dev_thread(int irq, void *dev_id) | |||
68 | spin_unlock(&assigned_dev->intx_lock); | 66 | spin_unlock(&assigned_dev->intx_lock); |
69 | } | 67 | } |
70 | 68 | ||
71 | if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_HOST_MSIX) { | 69 | kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id, |
72 | index = find_index_from_host_irq(assigned_dev, irq); | 70 | assigned_dev->guest_irq, 1); |
73 | if (index >= 0) { | 71 | |
74 | vector = assigned_dev-> | 72 | return IRQ_HANDLED; |
75 | guest_msix_entries[index].vector; | 73 | } |
76 | kvm_set_irq(assigned_dev->kvm, | 74 | |
77 | assigned_dev->irq_source_id, vector, 1); | 75 | #ifdef __KVM_HAVE_MSIX |
78 | } | 76 | static irqreturn_t kvm_assigned_dev_thread_msix(int irq, void *dev_id) |
79 | } else | 77 | { |
78 | struct kvm_assigned_dev_kernel *assigned_dev = dev_id; | ||
79 | int index = find_index_from_host_irq(assigned_dev, irq); | ||
80 | u32 vector; | ||
81 | |||
82 | if (index >= 0) { | ||
83 | vector = assigned_dev->guest_msix_entries[index].vector; | ||
80 | kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id, | 84 | kvm_set_irq(assigned_dev->kvm, assigned_dev->irq_source_id, |
81 | assigned_dev->guest_irq, 1); | 85 | vector, 1); |
86 | } | ||
82 | 87 | ||
83 | return IRQ_HANDLED; | 88 | return IRQ_HANDLED; |
84 | } | 89 | } |
90 | #endif | ||
85 | 91 | ||
86 | /* Ack the irq line for an assigned device */ | 92 | /* Ack the irq line for an assigned device */ |
87 | static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian) | 93 | static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian) |
@@ -279,7 +285,7 @@ static int assigned_device_enable_host_msix(struct kvm *kvm, | |||
279 | 285 | ||
280 | for (i = 0; i < dev->entries_nr; i++) { | 286 | for (i = 0; i < dev->entries_nr; i++) { |
281 | r = request_threaded_irq(dev->host_msix_entries[i].vector, | 287 | r = request_threaded_irq(dev->host_msix_entries[i].vector, |
282 | NULL, kvm_assigned_dev_thread, | 288 | NULL, kvm_assigned_dev_thread_msix, |
283 | 0, dev->irq_name, dev); | 289 | 0, dev->irq_name, dev); |
284 | if (r) | 290 | if (r) |
285 | goto err; | 291 | goto err; |