[igt-dev] [PATCH i-g-t v4 07/14] i915/gem_unref_active_buffers.c: Remove libdrm dependency

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Mon Oct 26 10:37:49 UTC 2020


On Fri, Oct 23, 2020 at 11:21:56AM +0200, Dominik Grzegorzek wrote:
> Use intel_bb / intel_buf to remove libdrm dependency.
> 
> Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  tests/i915/gem_unref_active_buffers.c | 60 +++++++++++++--------------
>  1 file changed, 29 insertions(+), 31 deletions(-)
> 
> diff --git a/tests/i915/gem_unref_active_buffers.c b/tests/i915/gem_unref_active_buffers.c
> index 75394794..361e947c 100644
> --- a/tests/i915/gem_unref_active_buffers.c
> +++ b/tests/i915/gem_unref_active_buffers.c
> @@ -29,8 +29,7 @@
>   * Testcase: Unreferencing of active buffers
>   *
>   * Execs buffers and immediately unreferences them, hence the kernel active list
> - * will be the last one to hold a reference on them. Usually libdrm bo caching
> - * prevents that by keeping another reference.
> + * will be the last one to hold a reference on them.
>   */
>  #include <stdlib.h>
>  #include <stdio.h>
> @@ -44,55 +43,54 @@
>  #include "drm.h"
>  #include "i915/gem.h"
>  #include "igt.h"
> -#include "intel_bufmgr.h"
>  
>  IGT_TEST_DESCRIPTION("Test unreferencing of active buffers.");
>  
> -static drm_intel_bufmgr *bufmgr;
> -struct intel_batchbuffer *batch;
> -static drm_intel_bo *load_bo;
> -
>  igt_simple_main
>  {
> +	struct intel_buf *load_bo;
> +	struct intel_bb *ibb;
> +	struct buf_ops *bops;
>  	int fd, i;
>  
>  	fd = drm_open_driver(DRIVER_INTEL);
>  	igt_require_gem(fd);
>  	gem_require_blitter(fd);
>  
> -	bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
> -	igt_assert(bufmgr);
> -	/* don't enable buffer reuse!! */
> -	//drm_intel_bufmgr_gem_enable_reuse(bufmgr);
> -
> -	batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
> -	igt_assert(batch);
> +	bops = buf_ops_create(fd);
> +	ibb = intel_bb_create_with_relocs(fd, 4096);
>  
>  	/* put some load onto the gpu to keep the light buffers active for long
>  	 * enough */
>  	for (i = 0; i < 1000; i++) {
> -		load_bo = drm_intel_bo_alloc(bufmgr, "target bo", 1024*4096, 4096);
> -		igt_assert(load_bo);
> +		load_bo = intel_buf_create(bops, 2048, 2048, 32, 0,
> +					   I915_TILING_NONE,
> +					   I915_COMPRESSION_NONE);
>  
> -		BLIT_COPY_BATCH_START(0);
> -		OUT_BATCH((3 << 24) | /* 32 bits */
> -			  (0xcc << 16) | /* copy ROP */
> -			  4096);
> -		OUT_BATCH(0); /* dst x1,y1 */
> -		OUT_BATCH((1024 << 16) | 512);
> -		OUT_RELOC_FENCED(load_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
> -		OUT_BATCH((0 << 16) | 512); /* src x1, y1 */
> -		OUT_BATCH(4096);
> -		OUT_RELOC_FENCED(load_bo, I915_GEM_DOMAIN_RENDER, 0, 0);
> -		ADVANCE_BATCH();
> +		intel_bb_add_intel_buf(ibb, load_bo, true);
> +		intel_bb_blit_start(ibb, 0);
> +		intel_bb_out(ibb, (3 << 24) | /* 32 bits */
> +			     (0xcc << 16) | /* copy ROP */
> +			     4096);
> +		intel_bb_out(ibb, 0); /* dst x1,y1 */
> +		intel_bb_out(ibb, (1024 << 16) | 512);
> +		intel_bb_emit_reloc_fenced(ibb, load_bo->handle,
> +					   I915_GEM_DOMAIN_RENDER,
> +					   I915_GEM_DOMAIN_RENDER, 0, 0x0);
> +		intel_bb_out(ibb, (0 << 16) | 512); /* src x1, y1 */
> +		intel_bb_out(ibb, 4096);
> +		intel_bb_emit_reloc_fenced(ibb, load_bo->handle,
> +					   I915_GEM_DOMAIN_RENDER,
> +					   0, 0, 0x0);
>  
> -		intel_batchbuffer_flush(batch);
> +		intel_bb_flush_blit(ibb);
>  
> -		drm_intel_bo_disable_reuse(load_bo);
> -		drm_intel_bo_unreference(load_bo);
> +		intel_buf_destroy(load_bo);
> +		intel_bb_reset(ibb, true);

Awaiting allocator code will remove such bo from intel_bb so in the
future reset(true) won't be required. 

>  	}
>  
> -	drm_intel_bufmgr_destroy(bufmgr);
> +	intel_bb_destroy(ibb);
> +	buf_ops_destroy(bops);
>  
>  	close(fd);
>  }
> -- 
> 2.20.1
>

LGTM. 

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
 


More information about the igt-dev mailing list