[PATCH i-g-t] SRIOV: lib/igt_sriov_device: Cache xe device at open

Kamil Konieczny kamil.konieczny at linux.intel.com
Wed Mar 13 13:56:44 UTC 2024


Hi Marcin,
On 2024-03-13 at 12:59:11 +0100, Marcin Bernatowicz wrote:
> Be consistent with other drm_open_xxx functions.
s/xxx/*/

In subject, drop SRIOV:, s/SRIOV: lib/lib/

With that fixed,

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

> 
> Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz at linux.intel.com>
> ---
>  lib/igt_sriov_device.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/igt_sriov_device.c b/lib/igt_sriov_device.c
> index f20761669..f425a5ecf 100644
> --- a/lib/igt_sriov_device.c
> +++ b/lib/igt_sriov_device.c
> @@ -12,6 +12,7 @@
>  #include "igt_device.h"
>  #include "igt_sriov_device.h"
>  #include "igt_sysfs.h"
> +#include "xe/xe_query.h"
>  
>  /**
>   * igt_sriov_is_pf - Check if device is PF
> @@ -232,6 +233,7 @@ int igt_sriov_open_vf_drm_device(int pf, unsigned int vf_num)
>  	DIR *dir;
>  	struct dirent *de;
>  	bool found = false;
> +	int fd;
>  
>  	if (!vf_num)
>  		return -1;
> @@ -258,7 +260,11 @@ int igt_sriov_open_vf_drm_device(int pf, unsigned int vf_num)
>  	if (!found)
>  		return -1;
>  
> -	return __drm_open_device(dev_name, DRIVER_ANY);
> +	fd = __drm_open_device(dev_name, DRIVER_ANY);
> +	if (fd >= 0 && is_xe_device(fd))
> +		xe_device_get(fd);
> +
> +	return fd;
>  }
>  
>  /**
> -- 
> 2.31.1
> 


More information about the igt-dev mailing list