mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
853dafb62b
commit
6eb55818c0
|
@ -4148,8 +4148,8 @@ static void kvm_free_vcpus(struct kvm *kvm)
|
||||||
|
|
||||||
void kvm_arch_destroy_vm(struct kvm *kvm)
|
void kvm_arch_destroy_vm(struct kvm *kvm)
|
||||||
{
|
{
|
||||||
kvm_iommu_unmap_guest(kvm);
|
|
||||||
kvm_free_all_assigned_devices(kvm);
|
kvm_free_all_assigned_devices(kvm);
|
||||||
|
kvm_iommu_unmap_guest(kvm);
|
||||||
kvm_free_pit(kvm);
|
kvm_free_pit(kvm);
|
||||||
kfree(kvm->arch.vpic);
|
kfree(kvm->arch.vpic);
|
||||||
kfree(kvm->arch.vioapic);
|
kfree(kvm->arch.vioapic);
|
||||||
|
|
|
@ -152,6 +152,8 @@ static void kvm_free_assigned_device(struct kvm *kvm,
|
||||||
*/
|
*/
|
||||||
kvm_put_kvm(kvm);
|
kvm_put_kvm(kvm);
|
||||||
|
|
||||||
|
pci_reset_function(assigned_dev->dev);
|
||||||
|
|
||||||
pci_release_regions(assigned_dev->dev);
|
pci_release_regions(assigned_dev->dev);
|
||||||
pci_disable_device(assigned_dev->dev);
|
pci_disable_device(assigned_dev->dev);
|
||||||
pci_dev_put(assigned_dev->dev);
|
pci_dev_put(assigned_dev->dev);
|
||||||
|
@ -283,6 +285,9 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
|
||||||
__func__);
|
__func__);
|
||||||
goto out_disable;
|
goto out_disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pci_reset_function(dev);
|
||||||
|
|
||||||
match->assigned_dev_id = assigned_dev->assigned_dev_id;
|
match->assigned_dev_id = assigned_dev->assigned_dev_id;
|
||||||
match->host_busnr = assigned_dev->busnr;
|
match->host_busnr = assigned_dev->busnr;
|
||||||
match->host_devfn = assigned_dev->devfn;
|
match->host_devfn = assigned_dev->devfn;
|
||||||
|
|
Loading…
Reference in New Issue