[Intel-xe] [PATCH] fixup! drm/xe/bo: Evict VRAM to TT rather than to system

Rodrigo Vivi rodrigo.vivi at intel.com
Wed Sep 20 19:43:10 UTC 2023


On Wed, Sep 20, 2023 at 10:22:17AM +0200, Thomas Hellström wrote:
> The dma-buf kunit test and to some extent the dma-buf code assumed
> that all bos were evicted to system. Fix this by having the dma-buf
> code not assume anything about eviction placement and the test
> code assume that VRAM bos are evicted to TT.

I believe that we should minimize the fixup patches now and use that
only for the display ones that still need a lot of work.

This could be a simple Fixes: case. And even the commit message is
very good for a standalone patch.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

> 
> The patch applies using automerge conflict resolution.
> 
> This fixes the following errors:
> 
> [  102.102086]     KTAP version 1
> [  102.102102]     # Subtest: xe_dma_buf
> [  102.102113]     1..1
> [  102.102377]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.106167]     # xe_dma_buf_kunit: EXPECTATION FAILED at drivers/gpu/drm/xe/tests/xe_dma_buf.c:76
>                Importer wasn't properly evicted.
> [  102.106327]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.107136]     # xe_dma_buf_kunit: EXPECTATION FAILED at drivers/gpu/drm/xe/tests/xe_dma_buf.c:98
>                    Expected xe_bo_is_mem_type(exported, mem_type) to be true, but is false
> [  102.107691]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.108099]     # xe_dma_buf_kunit: EXPECTATION FAILED at drivers/gpu/drm/xe/tests/xe_dma_buf.c:76
>                Importer wasn't properly evicted.
> [  102.108158]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.108294]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.108742]     # xe_dma_buf_kunit: EXPECTATION FAILED at drivers/gpu/drm/xe/tests/xe_dma_buf.c:76
>                Importer wasn't properly evicted.
> [  102.108800]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.108908]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.109080]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.109842]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.109941]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.110131]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.110236]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.110402]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.110731]     # xe_dma_buf_kunit: EXPECTATION FAILED at drivers/gpu/drm/xe/tests/xe_dma_buf.c:76
>                Importer wasn't properly evicted.
> [  102.110790]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.111498]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.111793]     # xe_dma_buf_kunit: EXPECTATION FAILED at drivers/gpu/drm/xe/tests/xe_dma_buf.c:76
>                Importer wasn't properly evicted.
> [  102.111851]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.112302]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.112580]     # xe_dma_buf_kunit: EXPECTATION FAILED at drivers/gpu/drm/xe/tests/xe_dma_buf.c:76
>                Importer wasn't properly evicted.
> [  102.112638]     # xe_dma_buf_kunit: running xe_test_dmabuf_import_same_driver
> [  102.113292]     not ok 1 xe_dma_buf_kunit
> [  102.113296] not ok 1 xe_dma_buf
> 
> Signed-off-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
> ---
>  drivers/gpu/drm/xe/tests/xe_dma_buf.c |  5 ++---
>  drivers/gpu/drm/xe/xe_dma_buf.c       | 11 ++++-------
>  2 files changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/tests/xe_dma_buf.c b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> index 1c3f4bc72b99..1c4d8751be69 100644
> --- a/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> +++ b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> @@ -72,7 +72,7 @@ static void check_residency(struct kunit *test, struct xe_bo *exported,
>  	}
>  
>  	/* Verify that also importer has been evicted to SYSTEM */
> -	if (!xe_bo_is_mem_type(imported, XE_PL_SYSTEM)) {
> +	if (exported != imported && !xe_bo_is_mem_type(imported, XE_PL_SYSTEM)) {
>  		KUNIT_FAIL(test, "Importer wasn't properly evicted.\n");
>  		return;
>  	}
> @@ -91,8 +91,7 @@ static void check_residency(struct kunit *test, struct xe_bo *exported,
>  	 * possible, saving a migration step as the transfer is just
>  	 * likely as fast from system memory.
>  	 */
> -	if (params->force_different_devices &&
> -	    params->mem_mask & XE_BO_CREATE_SYSTEM_BIT)
> +	if (params->mem_mask & XE_BO_CREATE_SYSTEM_BIT)
>  		KUNIT_EXPECT_TRUE(test, xe_bo_is_mem_type(exported, XE_PL_TT));
>  	else
>  		KUNIT_EXPECT_TRUE(test, xe_bo_is_mem_type(exported, mem_type));
> diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_buf.c
> index bd8d51e7f93f..cfde3be3b0dc 100644
> --- a/drivers/gpu/drm/xe/xe_dma_buf.c
> +++ b/drivers/gpu/drm/xe/xe_dma_buf.c
> @@ -98,13 +98,10 @@ static struct sg_table *xe_dma_buf_map(struct dma_buf_attachment *attach,
>  		return ERR_PTR(-EOPNOTSUPP);
>  
>  	if (!xe_bo_is_pinned(bo)) {
> -		if (!attach->peer2peer ||
> -		    bo->ttm.resource->mem_type == XE_PL_SYSTEM) {
> -			if (xe_bo_can_migrate(bo, XE_PL_TT))
> -				r = xe_bo_migrate(bo, XE_PL_TT);
> -			else
> -				r = xe_bo_validate(bo, NULL, false);
> -		}
> +		if (!attach->peer2peer)
> +			r = xe_bo_migrate(bo, XE_PL_TT);
> +		else
> +			r = xe_bo_validate(bo, NULL, false);
>  		if (r)
>  			return ERR_PTR(r);
>  	}
> -- 
> 2.41.0
> 


More information about the Intel-xe mailing list