[Intel-xe] [PATCH v3] drm/xe/bo: Return object bo size on create

Thomas Hellström thomas.hellstrom at linux.intel.com
Mon Jun 26 16:16:06 UTC 2023


On 6/26/23 17:22, Zbigniew Kempczyński wrote:
> On Mon, Jun 26, 2023 at 04:55:29PM +0200, Thomas Hellström wrote:
>> Hi, Zbigniew,
>>
>> On 6/26/23 16:42, Zbigniew Kempczyński wrote:
>>> Driver may alter bo size requested by the user. Return real object
>>> size to make userspace aware how to arrange vm bindings.
>> I think for Xe VM_BIND, the space needed for a bo with given size must be
>>
>> ALIGN_TO(bo->size, xe_get_default_alignment())
>>
>> (xe_get_default_alignment() being an igt xe lib function).
> You mean I can't glue 4K system object with 64K one after another,
> for example:
>
> * bo on system: offset = 0x1000, size 0x1000
> * bo on vram:   offset = 0x2000, size 0x10000
>
> This won't work as vram object should be aligned on vm to 0x10000?

Yes that won't work, since a VRAM-capable bo needs 64K alignment.

Although the explanation above ignores that system-only bo objects 
appears to always allow 4K offset and size, which of course can be 
discussed.

So with the current uAPI, it appears the bind alignment and size could 
always be calculated using:

if (bo_has_VRAM_placement() && xe_get_default_alignment() > 4K) {
    bind_size = ALIGN_TO(bo->size, xe_get_default_alignment());
    offset_alignment = xe_get_default_alignment();
} else {
    bind_size = bo->size;
    offset_alignment = 4K;
}

What I'm a bit afraid of is that if we return a size different from 
bo->size, then UMD might start using that extra size for data, while it 
really shouldn't. Would it be possible to return an alignment instead 
that needs to be used by UMD for bind offset and bind size?

/Thomas

>
> --
> Zbigniew
>
>> Even the padded bo->size returned with this patch is lower than the value
>> above. If you use that value, will the value assigned below still be needed.
>>
>> /Thomas
>>
>>> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
>>> Reviewed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura at intel.com>
>>> Reviewed-by: Matthew Brost <matthew.brost at intel.com>
>>> ---
>>>    drivers/gpu/drm/xe/xe_bo.c | 1 +
>>>    1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
>>> index 71a14e1f25be..55dbb374a787 100644
>>> --- a/drivers/gpu/drm/xe/xe_bo.c
>>> +++ b/drivers/gpu/drm/xe/xe_bo.c
>>> @@ -1744,6 +1744,7 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
>>>    		return err;
>>>    	args->handle = handle;
>>> +	args->size = bo->size;
>>>    	return 0;
>>>    }


More information about the Intel-xe mailing list