From: Sean Christopherson <seanjc@google.com>
To: Zhenyu Wang <zhenyuw@linux.intel.com>, Zhi Wang <zhi.a.wang@intel.com>
Cc: Sean Christopherson <seanjc@google.com>,
intel-gfx@lists.freedesktop.org,
intel-gvt-dev@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: [Intel-gfx] [PATCH 2/2] drm/i915/gvt: Unconditionally put reference to KVM when detaching vGPU
Date: Fri, 11 Nov 2022 00:22:25 +0000 [thread overview]
Message-ID: <20221111002225.2418386-3-seanjc@google.com> (raw)
In-Reply-To: <20221111002225.2418386-1-seanjc@google.com>
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.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
drivers/gpu/drm/i915/gvt/kvmgt.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index e67d5267fde0..714221f9a131 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -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)
--
2.38.1.431.g37b22c650d-goog
next prev parent reply other threads:[~2022-11-21 15:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 0:22 [Intel-gfx] [PATCH 0/2] drm/i915/gvt: Fix for KVM refcounting bug Sean Christopherson
2022-11-11 0:22 ` [Intel-gfx] [PATCH 1/2] drm/i915/gvt: Get reference to KVM iff attachment to VM is successful Sean Christopherson
2022-11-11 2:49 ` Tian, Kevin
2022-11-11 0:22 ` Sean Christopherson [this message]
2022-11-11 2:50 ` [Intel-gfx] [PATCH 2/2] drm/i915/gvt: Unconditionally put reference to KVM when detaching vGPU Tian, Kevin
2022-11-11 5:16 ` [Intel-gfx] [PATCH 0/2] drm/i915/gvt: Fix for KVM refcounting bug Zhenyu Wang
2022-11-21 21:34 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for " Patchwork
2022-11-21 21:58 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-11-22 2:49 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221111002225.2418386-3-seanjc@google.com \
--to=seanjc@google.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zhenyuw@linux.intel.com \
--cc=zhi.a.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox