Commit 3c9fd44b authored by Sean Christopherson's avatar Sean Christopherson Committed by Zhenyu Wang
Browse files

drm/i915/gvt: Unconditionally put reference to KVM when detaching vGPU



Always put the KVM reference when closing a vCPU device, as
intel_vgpu_open_device() succeeds if and only if the KVM pointer is
valid and a reference to KVM is acquired.  And if that doesn't hold true,
the call to kvm_page_track_unregister_notifier() a few lines earlier is
doomed.

Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20221111002225.2418386-3-seanjc@google.com
parent 9ed1fdee
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -714,15 +714,14 @@ static void intel_vgpu_close_device(struct vfio_device *vfio_dev)

	kvm_page_track_unregister_notifier(vgpu->vfio_device.kvm,
					   &vgpu->track_node);
	kvm_put_kvm(vgpu->vfio_device.kvm);

	kvmgt_protect_table_destroy(vgpu);
	gvt_cache_destroy(vgpu);

	intel_vgpu_release_msi_eventfd_ctx(vgpu);

	vgpu->attached = false;

	if (vgpu->vfio_device.kvm)
		kvm_put_kvm(vgpu->vfio_device.kvm);
}

static u64 intel_vgpu_get_bar_addr(struct intel_vgpu *vgpu, int bar)