[PATCH] drm/i915/gvt: scan non-privileged batch buffer for debug purpose

Hang Yuan hang.yuan at linux.intel.com
Wed Mar 14 08:17:50 UTC 2018


On Wed, Mar 14, 2018 at 08:43:13AM +0800, Zhao Yan wrote:
>  
> @@ -1664,6 +1670,9 @@ static int perform_bb_shadow(struct parser_exec_state *s)
>  	unsigned long gma = 0;
>  	unsigned long bb_size;
>  	int ret = 0;
> +	unsigned long bb_offset = 0;
> +	struct intel_vgpu_mm *mm = (s->buf_addr_type == GTT_BUFFER) ?
> +		s->vgpu->gtt.ggtt_mm : s->workload->shadow_mm;
>  
>  	/* get the start gm address of the batch buffer */
>  	gma = get_gma_bb_from_cmd(s, 1);
> @@ -1678,8 +1687,12 @@ static int perform_bb_shadow(struct parser_exec_state *s)
>  	if (!bb)
>  		return -ENOMEM;
>  
> +	bb->ppgtt = (s->buf_addr_type == GTT_BUFFER) ? false : true;
> +	if (bb->ppgtt)
> +		bb_offset = gma & ~I915_GTT_PAGE_MASK;
> +
>  	bb->obj = i915_gem_object_create(s->vgpu->gvt->dev_priv,
> -					 roundup(bb_size, PAGE_SIZE));
> +				 roundup(bb_size + bb_offset, PAGE_SIZE));
Just curious why 'bb_offset' size of space is allocated but looks like not used later?

>  	if (IS_ERR(bb->obj)) {
>  		ret = PTR_ERR(bb->obj);
>  		goto err_free_bb;
> @@ -1700,9 +1713,9 @@ static int perform_bb_shadow(struct parser_exec_state *s)
>  		bb->clflush &= ~CLFLUSH_BEFORE;
>  	}
>  
> -	ret = copy_gma_to_hva(s->vgpu, s->vgpu->gtt.ggtt_mm,
> +	ret = copy_gma_to_hva(s->vgpu, mm,
>  			      gma, gma + bb_size,
> -			      bb->va);
> +			      bb->va + bb_offset);
>  	if (ret < 0) {
>  		gvt_vgpu_err("fail to copy guest ring buffer\n");
>  		ret = -EFAULT;


More information about the intel-gvt-dev mailing list