[igt-dev] [PATCH i-g-t] igt/amd_prime: Link an amdgpu bo into i915 and try to shrink it

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Wed Aug 8 12:49:15 UTC 2018


On 07/08/2018 16:57, Chris Wilson wrote:
> Create and export an amdgpu bo into i915 so that we can try and
> invalidate the i915_bo->pages from inside the shrinker, teaching lockdep
> about that linkage.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Cc: Daniel Vetter <daniel at ffwll.ch>
> ---
>   tests/amdgpu/amd_prime.c | 32 ++++++++++++++++++++++++++++++++
>   1 file changed, 32 insertions(+)
> 
> diff --git a/tests/amdgpu/amd_prime.c b/tests/amdgpu/amd_prime.c
> index 9bf298a41..bda0ce83d 100644
> --- a/tests/amdgpu/amd_prime.c
> +++ b/tests/amdgpu/amd_prime.c
> @@ -392,6 +392,35 @@ static void amd_to_i915(int i915, int amd, amdgpu_device_handle device)
>   				 ib_result_mc_address, 4096);
>   }
>   
> +static void shrink(int i915, int amd, amdgpu_device_handle device)
> +{
> +	struct amdgpu_bo_alloc_request request = {
> +		.alloc_size = 1024 * 1024 * 4,
> +		.phys_alignment = 4096,
> +		.preferred_heap = AMDGPU_GEM_DOMAIN_GTT,
> +	};
> +	amdgpu_bo_handle bo;
> +	uint32_t handle;
> +	int dmabuf;
> +
> +	igt_assert_eq(amdgpu_bo_alloc(device, &request, &bo), 0);
> +	amdgpu_bo_export(bo,
> +			 amdgpu_bo_handle_type_dma_buf_fd,
> +			 (uint32_t *)&dmabuf);
> +	amdgpu_bo_free(bo);
> +
> +	handle = prime_fd_to_handle(i915, dmabuf);
> +	close(dmabuf);
> +
> +	/* Populate the i915_bo->pages. */
> +	gem_set_domain(i915, handle, I915_GEM_DOMAIN_GTT, 0);
> +
> +	/* Now evict them, establishing the link from i915:shrinker to amd. */
> +	igt_drop_caches_set(i915, DROP_SHRINK_ALL);
> +
> +	gem_close(i915, handle);
> +}
> +
>   igt_main
>   {
>   	amdgpu_device_handle device;
> @@ -420,6 +449,9 @@ igt_main
>   	igt_subtest("amd-to-i915")
>   		amd_to_i915(i915, amd, device);
>   
> +	igt_subtest("shrink")
> +		shrink(i915, amd, device);
> +
>   	igt_fixture {
>   		amdgpu_device_deinitialize(device);
>   		close(amd);
> 

Well, I am not familiar with the admgpu API, but it looks believable and 
knowing you got a Hades Canyon I trust it works.

Acked-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Regards,

Tvrtko


More information about the igt-dev mailing list