[PATCH] drm/i915/gvt: decrease the refcount when failing to create the shadow pgtable

zhi.wang.linux at gmail.com zhi.wang.linux at gmail.com
Sun Jun 11 13:19:35 UTC 2023


From: Zhi Wang <zhi.a.wang at intel.com>

Decrease the refcount in intel_vgpu_pin_mm() when failing to create the
shadow GPU pgtable in the shadow pgtable pinning path.

Intel GVT-g tracks the usage of a GPU shadow pgtable via manipulating the
refcount of a shadow pgtable.

However, the refcount was not correctly decreased when failing to create
a shadow pgtable in the intel_vgpu_pin_mm() in 'commit 2707e4446688
("drm/i915/gvt: vGPU graphics memory virtualization")'.

Decrease the mm->pincount in intel_vgpu_pin_mm() when shadow_ppgtt_mm()
fails.

Fixes: 2707e4446688 ("drm/i915/gvt: vGPU graphics memory virtualization")
Cc: Zhenyu Wang <zhenyuw at linux.intel.com>
Cc: intel-gvt-dev at lists.freedesktop.org
Reported-by: Dan Carpenter <dan.carpenter at linaro.org>
Link: https://lists.freedesktop.org/archives/intel-gvt-dev/2023-June/013750.html
Signed-off-by: Zhi Wang <zhi.a.wang at intel.com>
---
 drivers/gpu/drm/i915/gvt/gtt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
index 4ec85308379a..0f5e6125c0f0 100644
--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -2048,8 +2048,10 @@ int intel_vgpu_pin_mm(struct intel_vgpu_mm *mm)
 
 	if (mm->type == INTEL_GVT_MM_PPGTT) {
 		ret = shadow_ppgtt_mm(mm);
-		if (ret)
+		if (ret) {
+			atomic_dec(&mm->pincount);
 			return ret;
+		}
 
 		mutex_lock(&mm->vgpu->gvt->gtt.ppgtt_mm_lock);
 		list_move_tail(&mm->ppgtt_mm.lru_list,
-- 
2.25.1



More information about the intel-gvt-dev mailing list