Skip to content

Commit f969eca

Browse files
committed
drm/i915/gvt: Put the page reference obtained by KVM's gfn_to_pfn()
Put the struct page reference acquired by gfn_to_pfn(), KVM's API is that the caller is ultimately responsible for dropping any reference. Note, kvm_release_pfn_clean() ensures the pfn is actually a refcounted struct page before trying to put any references. Fixes: b901b25 ("drm/i915/gvt: Add 2M huge gtt support") Reviewed-by: Yan Zhao <yan.y.zhao@intel.com> Tested-by: Yongwei Ma <yongwei.ma@intel.com> Reviewed-by: Zhi Wang <zhi.a.wang@intel.com> Link: https://lore.kernel.org/r/20230729013535.1070024-6-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 6a718c5 commit f969eca

File tree

1 file changed

+4
-1
lines changed
  • drivers/gpu/drm/i915/gvt

1 file changed

+4
-1
lines changed

drivers/gpu/drm/i915/gvt/gtt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ static int is_2MB_gtt_possible(struct intel_vgpu *vgpu,
11581158
{
11591159
const struct intel_gvt_gtt_pte_ops *ops = vgpu->gvt->gtt.pte_ops;
11601160
kvm_pfn_t pfn;
1161+
int ret;
11611162

11621163
if (!HAS_PAGE_SIZES(vgpu->gvt->gt->i915, I915_GTT_PAGE_SIZE_2M))
11631164
return 0;
@@ -1171,7 +1172,9 @@ static int is_2MB_gtt_possible(struct intel_vgpu *vgpu,
11711172
if (!pfn_valid(pfn))
11721173
return -EINVAL;
11731174

1174-
return PageTransHuge(pfn_to_page(pfn));
1175+
ret = PageTransHuge(pfn_to_page(pfn));
1176+
kvm_release_pfn_clean(pfn);
1177+
return ret;
11751178
}
11761179

11771180
static int split_2MB_gtt_entry(struct intel_vgpu *vgpu,

0 commit comments

Comments
 (0)