aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/kvm_host.h1
-rw-r--r--virt/kvm/assigned-dev.c18
2 files changed, 15 insertions, 4 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index ab428552af8e..9272db03a3e5 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -513,6 +513,7 @@ struct kvm_assigned_dev_kernel {
513 struct kvm *kvm; 513 struct kvm *kvm;
514 spinlock_t intx_lock; 514 spinlock_t intx_lock;
515 char irq_name[32]; 515 char irq_name[32];
516 struct pci_saved_state *pci_saved_state;
516}; 517};
517 518
518struct kvm_irq_mask_notifier { 519struct kvm_irq_mask_notifier {
diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c
index ae72ae604c89..6cc4b97ec458 100644
--- a/virt/kvm/assigned-dev.c
+++ b/virt/kvm/assigned-dev.c
@@ -197,8 +197,13 @@ static void kvm_free_assigned_device(struct kvm *kvm,
197{ 197{
198 kvm_free_assigned_irq(kvm, assigned_dev); 198 kvm_free_assigned_irq(kvm, assigned_dev);
199 199
200 __pci_reset_function(assigned_dev->dev); 200 pci_reset_function(assigned_dev->dev);
201 pci_restore_state(assigned_dev->dev); 201 if (pci_load_and_free_saved_state(assigned_dev->dev,
202 &assigned_dev->pci_saved_state))
203 printk(KERN_INFO "%s: Couldn't reload %s saved state\n",
204 __func__, dev_name(&assigned_dev->dev->dev));
205 else
206 pci_restore_state(assigned_dev->dev);
202 207
203 pci_release_regions(assigned_dev->dev); 208 pci_release_regions(assigned_dev->dev);
204 pci_disable_device(assigned_dev->dev); 209 pci_disable_device(assigned_dev->dev);
@@ -516,7 +521,10 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
516 521
517 pci_reset_function(dev); 522 pci_reset_function(dev);
518 pci_save_state(dev); 523 pci_save_state(dev);
519 524 match->pci_saved_state = pci_store_saved_state(dev);
525 if (!match->pci_saved_state)
526 printk(KERN_DEBUG "%s: Couldn't store %s saved state\n",
527 __func__, dev_name(&dev->dev));
520 match->assigned_dev_id = assigned_dev->assigned_dev_id; 528 match->assigned_dev_id = assigned_dev->assigned_dev_id;
521 match->host_segnr = assigned_dev->segnr; 529 match->host_segnr = assigned_dev->segnr;
522 match->host_busnr = assigned_dev->busnr; 530 match->host_busnr = assigned_dev->busnr;
@@ -546,7 +554,9 @@ out:
546 mutex_unlock(&kvm->lock); 554 mutex_unlock(&kvm->lock);
547 return r; 555 return r;
548out_list_del: 556out_list_del:
549 pci_restore_state(dev); 557 if (pci_load_and_free_saved_state(dev, &match->pci_saved_state))
558 printk(KERN_INFO "%s: Couldn't reload %s saved state\n",
559 __func__, dev_name(&dev->dev));
550 list_del(&match->list); 560 list_del(&match->list);
551 pci_release_regions(dev); 561 pci_release_regions(dev);
552out_disable: 562out_disable: