[Intel-gfx] [PATCH v4 04/29] drm/i915/gvt: Don't try to unpin an empty page range

Wang, Zhi A zhi.a.wang at intel.com
Tue Aug 1 11:18:43 UTC 2023


On 7/29/2023 4:35 AM, Sean Christopherson wrote:
> From: Yan Zhao <yan.y.zhao at intel.com>
> 
> Attempt to unpin pages in the error path of gvt_pin_guest_page() if and
> only if at least one page was successfully pinned.  Unpinning doesn't
> cause functional problems, but vfio_device_container_unpin_pages()
> rightfully warns about being asked to unpin zero pages.
> 
> Signed-off-by: Yan Zhao <yan.y.zhao at intel.com>
> [sean: write changelog]
> Signed-off-by: Sean Christopherson <seanjc at google.com>
> ---
>   drivers/gpu/drm/i915/gvt/kvmgt.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index 429f0f993a13..0366a699baf5 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -172,7 +172,8 @@ static int gvt_pin_guest_page(struct intel_vgpu *vgpu, unsigned long gfn,
>   	*page = base_page;
>   	return 0;
>   err:
> -	gvt_unpin_guest_page(vgpu, gfn, npage * PAGE_SIZE);
> +	if (npage)
> +		gvt_unpin_guest_page(vgpu, gfn, npage * PAGE_SIZE);
>   	return ret;
>   }
>
Reviewed-by: Zhi Wang <zhi.a.wang at intel.com>




More information about the Intel-gfx mailing list