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

Zhao, Yan Y yan.y.zhao at intel.com
Thu Mar 15 01:47:19 UTC 2018



On 3/14/2018 4:17 PM, Hang Yuan wrote:
> 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?
or you mean why bb->obj is not used later? because it's referenced by 
bb->va. For scan it, we use s->ip_va, and s->ip_gma
>
>>   	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);
bb_offset is used here. I add bb_offset is to make shadowed BB looks the 
same as original BB, so if later we want to change PPGTT's mapping of 
the BB's gma to shadowed BB's physical address, it still works.
>>   	if (ret < 0) {
>>   		gvt_vgpu_err("fail to copy guest ring buffer\n");
>>   		ret = -EFAULT;



More information about the intel-gvt-dev mailing list