[igt-dev] [PATCH i-g-t 1/2] i915/gem_caching: Remove libdrm dependency

Chris Wilson chris at chris-wilson.co.uk
Mon Jul 6 17:42:28 UTC 2020


Quoting Dominik Grzegorzek (2020-07-06 08:21:17)
> Thanks to intel_bb we are able to remove libdrm from gem_caching.
> 
> Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  tests/i915/gem_caching.c | 176 ++++++++++++++++++++++++---------------
>  1 file changed, 107 insertions(+), 69 deletions(-)
> 
> diff --git a/tests/i915/gem_caching.c b/tests/i915/gem_caching.c
> index 0ffffa05..0f83d0d6 100644
> --- a/tests/i915/gem_caching.c
> +++ b/tests/i915/gem_caching.c
> @@ -39,7 +39,6 @@
>  
>  #include "i915/gem.h"
>  #include "igt.h"
> -#include "intel_bufmgr.h"
>  
>  IGT_TEST_DESCRIPTION("Test snoop consistency when touching partial"
>                      " cachelines.");
> @@ -49,50 +48,83 @@ IGT_TEST_DESCRIPTION("Test snoop consistency when touching partial"
>   *
>   */
>  
> -static drm_intel_bufmgr *bufmgr;
> -struct intel_batchbuffer *batch;
> -
> -drm_intel_bo *scratch_bo;
> -drm_intel_bo *staging_bo;
>  #define BO_SIZE (4*4096)
> -uint32_t devid;
> -int fd;
> +#define PAGE_SIZE 4096
> +
> +typedef struct {
> +       int fd;
> +       uint32_t devid;
> +       struct buf_ops *bops;
> +} data_t;
> +
> +
> +static void *__try_gtt_map_first(data_t *data, struct intel_buf *buf,
> +                                int write_enable)
> +{
> +       uint8_t *ptr;
> +       unsigned int prot = PROT_READ | (write_enable ? PROT_WRITE : 0);
> +
> +       ptr = __gem_mmap__gtt(data->fd, buf->handle, buf->size, prot);
> +       if (!ptr) {
> +               ptr = gem_mmap__device_coherent(data->fd, buf->handle,
> +                                         0, buf->size,  prot);
> +       }
> +       return ptr;
> +}

So I had to think whether or not this was worth keeping [gtt first,
rather than just use device_coherent]. And in the end the peculiarity of
GTT vs caching won out, so I agree better to keep trying gtt if it's
there.

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the igt-dev mailing list