aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kvm/x86.c2
-rw-r--r--virt/kvm/kvm_main.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 38f79b6aaf1e..9a4a39cfe6ef 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4148,8 +4148,8 @@ static void kvm_free_vcpus(struct kvm *kvm)
4148 4148
4149void kvm_arch_destroy_vm(struct kvm *kvm) 4149void kvm_arch_destroy_vm(struct kvm *kvm)
4150{ 4150{
4151 kvm_iommu_unmap_guest(kvm);
4152 kvm_free_all_assigned_devices(kvm); 4151 kvm_free_all_assigned_devices(kvm);
4152 kvm_iommu_unmap_guest(kvm);
4153 kvm_free_pit(kvm); 4153 kvm_free_pit(kvm);
4154 kfree(kvm->arch.vpic); 4154 kfree(kvm->arch.vpic);
4155 kfree(kvm->arch.vioapic); 4155 kfree(kvm->arch.vioapic);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 4f43abe198e4..1838052f3c9e 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -152,6 +152,8 @@ static void kvm_free_assigned_device(struct kvm *kvm,
152 */ 152 */
153 kvm_put_kvm(kvm); 153 kvm_put_kvm(kvm);
154 154
155 pci_reset_function(assigned_dev->dev);
156
155 pci_release_regions(assigned_dev->dev); 157 pci_release_regions(assigned_dev->dev);
156 pci_disable_device(assigned_dev->dev); 158 pci_disable_device(assigned_dev->dev);
157 pci_dev_put(assigned_dev->dev); 159 pci_dev_put(assigned_dev->dev);
@@ -283,6 +285,9 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
283 __func__); 285 __func__);
284 goto out_disable; 286 goto out_disable;
285 } 287 }
288
289 pci_reset_function(dev);
290
286 match->assigned_dev_id = assigned_dev->assigned_dev_id; 291 match->assigned_dev_id = assigned_dev->assigned_dev_id;
287 match->host_busnr = assigned_dev->busnr; 292 match->host_busnr = assigned_dev->busnr;
288 match->host_devfn = assigned_dev->devfn; 293 match->host_devfn = assigned_dev->devfn;