[igt-dev] [i-g-t 2/6] lib: Cache xe_device at driver open/close level

Kamil Konieczny kamil.konieczny at linux.intel.com
Tue May 9 09:31:31 UTC 2023


On 2023-05-04 at 10:27:22 +0530, Bhanuprakash Modem wrote:
> Instead of caching the xe_device struct at subtest level, cache
> just after opening the driver. And remove from the cache just
> before closing the driver.
> 
> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>

Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

> ---
>  lib/drmtest.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 03b5239b2..f6cd8e500 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -63,6 +63,7 @@
>  #include "intel_reg.h"
>  #include "ioctl_wrappers.h"
>  #include "igt_dummyload.h"
> +#include "xe/xe_query.h"
>  
>  /**
>   * SECTION:drmtest
> @@ -601,6 +602,10 @@ int drm_open_driver(int chipset)
>  		}
>  	}
>  
> +	/* Cache xe_device struct. */
> +	if (is_xe_device(fd))
> +		xe_device_get(fd);
> +
>  	return fd;
>  }
>  
> @@ -618,6 +623,10 @@ int drm_close_driver(int fd)
>  	if (fd < 3)
>  		return -1;
>  
> +	/* Remove xe_device from cache. */
> +	if (is_xe_device(fd))
> +		xe_device_put(fd);
> +
>  	return close(fd);
>  }
>  
> -- 
> 2.40.0
> 


More information about the igt-dev mailing list