[PATCH 02/23] drm/radeon/ttm: don't store driver copy of device pointer.

Daniel Vetter daniel at ffwll.ch
Tue Sep 1 11:53:19 UTC 2020


On Wed, Aug 26, 2020 at 11:44:07AM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> This can be gotten back from bdev.
> 
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  drivers/gpu/drm/radeon/radeon_ttm.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index f6311f404db8..0923a8601112 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -412,7 +412,6 @@ static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_reso
>   */
>  struct radeon_ttm_tt {
>  	struct ttm_dma_tt		ttm;
> -	struct radeon_device		*rdev;

At least for amdgpu the drm_device embedding stuff landed, so I think we
can drop a lot more of these all over because upcasting from a struct
drm_device * to tha adev is just a container_of.

Entirely separate bikeshed cleanup, but I think it'd help to make ttm feel
a bit more like a helper for gpu drivers than it's entirely separate world
:-)

Cheers, Daniel

>  	u64				offset;
>  
>  	uint64_t			userptr;
> @@ -515,6 +514,7 @@ static int radeon_ttm_backend_bind(struct ttm_tt *ttm,
>  				   struct ttm_resource *bo_mem)
>  {
>  	struct radeon_ttm_tt *gtt = (void*)ttm;
> +	struct radeon_device *rdev = radeon_get_rdev(ttm->bdev);
>  	uint32_t flags = RADEON_GART_PAGE_VALID | RADEON_GART_PAGE_READ |
>  		RADEON_GART_PAGE_WRITE;
>  	int r;
> @@ -531,7 +531,7 @@ static int radeon_ttm_backend_bind(struct ttm_tt *ttm,
>  	}
>  	if (ttm->caching_state == tt_cached)
>  		flags |= RADEON_GART_PAGE_SNOOP;
> -	r = radeon_gart_bind(gtt->rdev, gtt->offset, ttm->num_pages,
> +	r = radeon_gart_bind(rdev, gtt->offset, ttm->num_pages,
>  			     ttm->pages, gtt->ttm.dma_address, flags);
>  	if (r) {
>  		DRM_ERROR("failed to bind %lu pages at 0x%08X\n",
> @@ -544,8 +544,9 @@ static int radeon_ttm_backend_bind(struct ttm_tt *ttm,
>  static void radeon_ttm_backend_unbind(struct ttm_tt *ttm)
>  {
>  	struct radeon_ttm_tt *gtt = (void *)ttm;
> +	struct radeon_device *rdev = radeon_get_rdev(ttm->bdev);
>  
> -	radeon_gart_unbind(gtt->rdev, gtt->offset, ttm->num_pages);
> +	radeon_gart_unbind(rdev, gtt->offset, ttm->num_pages);
>  
>  	if (gtt->userptr)
>  		radeon_ttm_tt_unpin_userptr(ttm);
> @@ -584,7 +585,6 @@ static struct ttm_tt *radeon_ttm_tt_create(struct ttm_buffer_object *bo,
>  		return NULL;
>  	}
>  	gtt->ttm.ttm.func = &radeon_backend_func;
> -	gtt->rdev = rdev;
>  	if (ttm_dma_tt_init(&gtt->ttm, bo, page_flags)) {
>  		kfree(gtt);
>  		return NULL;
> -- 
> 2.27.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list