aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 63fd88209439..e41d39d6b0ef 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -200,14 +200,11 @@ static void kvm_assigned_dev_ack_irq(struct kvm_irq_ack_notifier *kian)
200 enable_irq(dev->host_irq); 200 enable_irq(dev->host_irq);
201} 201}
202 202
203static void kvm_free_assigned_device(struct kvm *kvm, 203static void kvm_free_assigned_irq(struct kvm *kvm,
204 struct kvm_assigned_dev_kernel 204 struct kvm_assigned_dev_kernel *assigned_dev)
205 *assigned_dev)
206{ 205{
207 if (irqchip_in_kernel(kvm) && assigned_dev->irq_requested_type) 206 if (!irqchip_in_kernel(kvm))
208 free_irq(assigned_dev->host_irq, (void *)assigned_dev); 207 return;
209 if (assigned_dev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)
210 pci_disable_msi(assigned_dev->dev);
211 208
212 kvm_unregister_irq_ack_notifier(&assigned_dev->ack_notifier); 209 kvm_unregister_irq_ack_notifier(&assigned_dev->ack_notifier);
213 210
@@ -215,12 +212,30 @@ static void kvm_free_assigned_device(struct kvm *kvm,
215 kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id); 212 kvm_free_irq_source_id(kvm, assigned_dev->irq_source_id);
216 assigned_dev->irq_source_id = -1; 213 assigned_dev->irq_source_id = -1;
217 214
215 if (!assigned_dev->irq_requested_type)
216 return;
217
218 if (cancel_work_sync(&assigned_dev->interrupt_work)) 218 if (cancel_work_sync(&assigned_dev->interrupt_work))
219 /* We had pending work. That means we will have to take 219 /* We had pending work. That means we will have to take
220 * care of kvm_put_kvm. 220 * care of kvm_put_kvm.
221 */ 221 */
222 kvm_put_kvm(kvm); 222 kvm_put_kvm(kvm);
223 223
224 free_irq(assigned_dev->host_irq, (void *)assigned_dev);
225
226 if (assigned_dev->irq_requested_type & KVM_ASSIGNED_DEV_HOST_MSI)
227 pci_disable_msi(assigned_dev->dev);
228
229 assigned_dev->irq_requested_type = 0;
230}
231
232
233static void kvm_free_assigned_device(struct kvm *kvm,
234 struct kvm_assigned_dev_kernel
235 *assigned_dev)
236{
237 kvm_free_assigned_irq(kvm, assigned_dev);
238
224 pci_reset_function(assigned_dev->dev); 239 pci_reset_function(assigned_dev->dev);
225 240
226 pci_release_regions(assigned_dev->dev); 241 pci_release_regions(assigned_dev->dev);