diff options
author | Sheng Yang <sheng@linux.intel.com> | 2008-10-31 00:37:41 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2008-12-31 09:51:49 -0500 |
commit | 6eb55818c043b097c83828da8430fcb9a02fdb89 (patch) | |
tree | 8bdd77fa9fb110e50905093c746c3f70e62cb2ba /virt/kvm | |
parent | 853dafb62b386a3a75808483a120998e734eb6e1 (diff) |
KVM: Enable Function Level Reset for assigned device
Ideally, every assigned device should in a clear condition before and after
assignment, so that the former state of device won't affect later work.
Some devices provide a mechanism named Function Level Reset, which is
defined in PCI/PCI-e document. We should execute it before and after device
assignment.
(But sadly, the feature is new, and most device on the market now don't
support it. We are considering using D0/D3hot transmit to emulate it later,
but not that elegant and reliable as FLR itself.)
[Update: Reminded by Xiantao, execute FLR after we ensure that the device can
be assigned to the guest.]
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r-- | virt/kvm/kvm_main.c | 5 |
1 files changed, 5 insertions, 0 deletions
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; |