[Intel-xe] [PATCH] drm/xe: Fix splat during error dump

Matthew Brost matthew.brost at intel.com
Thu May 4 21:24:47 UTC 2023


On Thu, May 04, 2023 at 10:53:20PM +0200, Francois Dugast wrote:
> Allow xe_bo_addr without lock to print debug information, such
> as from xe_analyze_vm.
> 
> Signed-off-by: Francois Dugast <francois.dugast at intel.com>

Reviewed-by: Matthew Brost <matthew.brost at intel.com>

> ---
>  drivers/gpu/drm/xe/xe_bo.c | 19 +++++++++++++++----
>  drivers/gpu/drm/xe/xe_bo.h |  2 ++
>  drivers/gpu/drm/xe/xe_vm.c |  2 +-
>  3 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index 3ab404e33fae..c82e995df779 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -1545,15 +1545,18 @@ bool xe_bo_is_xe_bo(struct ttm_buffer_object *bo)
>  	return false;
>  }
>  
> -dma_addr_t xe_bo_addr(struct xe_bo *bo, u64 offset,
> +/*
> + * Resolve a BO address. There is no assert to check if the proper lock is held
> + * so it should only be used in cases where it is not fatal to get the wrong
> + * address, such as printing debug information, but not in cases where memory is
> + * written based on this result.
> + */
> +dma_addr_t __xe_bo_addr(struct xe_bo *bo, u64 offset,
>  		      size_t page_size, bool *is_vram)
>  {
>  	struct xe_res_cursor cur;
>  	u64 page;
>  
> -	if (!READ_ONCE(bo->ttm.pin_count))
> -		xe_bo_assert_held(bo);
> -
>  	XE_BUG_ON(page_size > PAGE_SIZE);
>  	page = offset >> PAGE_SHIFT;
>  	offset &= (PAGE_SIZE - 1);
> @@ -1575,6 +1578,14 @@ dma_addr_t xe_bo_addr(struct xe_bo *bo, u64 offset,
>  	}
>  }
>  
> +dma_addr_t xe_bo_addr(struct xe_bo *bo, u64 offset,
> +		      size_t page_size, bool *is_vram)
> +{
> +	if (!READ_ONCE(bo->ttm.pin_count))
> +		xe_bo_assert_held(bo);
> +	return __xe_bo_addr(bo, offset, page_size, is_vram);
> +}
> +
>  int xe_bo_vmap(struct xe_bo *bo)
>  {
>  	void *virtual;
> diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
> index 8354d05ccdf3..7e111332c35a 100644
> --- a/drivers/gpu/drm/xe/xe_bo.h
> +++ b/drivers/gpu/drm/xe/xe_bo.h
> @@ -199,6 +199,8 @@ static inline void xe_bo_unpin_map_no_vm(struct xe_bo *bo)
>  }
>  
>  bool xe_bo_is_xe_bo(struct ttm_buffer_object *bo);
> +dma_addr_t __xe_bo_addr(struct xe_bo *bo, u64 offset,
> +		      size_t page_size, bool *is_vram);
>  dma_addr_t xe_bo_addr(struct xe_bo *bo, u64 offset,
>  		      size_t page_size, bool *is_vram);
>  
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index 272f0f7f24fe..91576cec000d 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -3397,7 +3397,7 @@ int xe_analyze_vm(struct drm_printer *p, struct xe_vm *vm, int gt_id)
>  					&cur);
>  			addr = xe_res_dma(&cur);
>  		} else {
> -			addr = xe_bo_addr(vma->bo, 0, XE_PAGE_SIZE, &is_vram);
> +			addr = __xe_bo_addr(vma->bo, 0, XE_PAGE_SIZE, &is_vram);
>  		}
>  		drm_printf(p, " [%016llx-%016llx] S:0x%016llx A:%016llx %s\n",
>  			   vma->start, vma->end, vma->end - vma->start + 1ull,
> -- 
> 2.25.1
> 


More information about the Intel-xe mailing list