[PATCH 6/8] drm/vram-helper: don't use ttm bo->offset v3

Christian König ckoenig.leichtzumerken at gmail.com
Thu Mar 5 14:34:56 UTC 2020


Am 05.03.20 um 15:35 schrieb Nirmoy:
>
>
> On 3/5/20 3:07 PM, Gerd Hoffmann wrote:
>> On Thu, Mar 05, 2020 at 02:29:08PM +0100, Nirmoy Das wrote:
>>> Calculate GEM VRAM bo's offset within vram-helper without depending on
>>> bo->offset.
>>>
>>> Signed-off-by: Nirmoy Das<nirmoy.das at amd.com>
>>> Reviewed-by: Daniel Vetter<daniel.vetter at ffwll.ch>
>>> ---
>>>   drivers/gpu/drm/drm_gem_vram_helper.c | 9 ++++++++-
>>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
>>> index 92a11bb42365..2749c2d25ac4 100644
>>> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
>>> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
>>> @@ -198,6 +198,13 @@ u64 drm_gem_vram_mmap_offset(struct drm_gem_vram_object *gbo)
>>>   }
>>>   EXPORT_SYMBOL(drm_gem_vram_mmap_offset);
>>>
>>> +static s64 drm_gem_vram_pg_offset(struct drm_gem_vram_object *gbo)
>>> +{
>>> +	if (WARN_ON_ONCE(!gbo->bo.mem.mm_node))
>>> +		return 0;
>> returns 0 on error.
>
> I am not sure if we should call this an error. This patch series 
> removes below offset calculation from ttm_bo.c.
>
> -	if (bo->mem.mm_node)
> -		bo->offset = (bo->mem.start << PAGE_SHIFT) +
> -		    bdev->man[bo->mem.mem_type].gpu_offset;
> -	else
> -		bo->offset = 0;
> -
>
> Most of the driver sets "bo->mem.mm_node". Thomas suggested to use 
> this "return 0" in case some driver depends on bo->offset = 0.
>

We should probably add a code comment here to explain why we do this.

Something like "Keep TTM behavior for now, remove when drivers are audited".

Regards,
Christian.

>>> +	return gbo->bo.mem.start;
>>> +}
>>> +
>>>   /**
>>>    * drm_gem_vram_offset() - \
>>>   	Returns a GEM VRAM object's offset in video memory
>>> @@ -214,7 +221,7 @@ s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo)
>>>   {
>>>   	if (WARN_ON_ONCE(!gbo->pin_count))
>>>   		return (s64)-ENODEV;
>> returns -errno on error.
>>
>>> -	return gbo->bo.offset;
>>> +	return drm_gem_vram_pg_offset(gbo) << PAGE_SHIFT;
>> And given that one calls the other behavior on error should better be
>> consistent ...
>>
>> cheers,
>>    Gerd
>>
>
> Regards,
>
> Nirmoy
>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20200305/d3b60295/attachment.htm>


More information about the amd-gfx mailing list