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

Laguna, Lukasz lukasz.laguna at intel.com
Wed Mar 13 12:46:33 UTC 2024


On 3/13/2024 12:59, Marcin Bernatowicz wrote:
> Be consistent with other drm_open_xxx functions.
>
> Signed-off-by: Marcin Bernatowicz<marcin.bernatowicz at linux.intel.com>


Reviewed-by: Lukasz Laguna <lukasz.laguna at intel.com 
<mailto:lukasz.laguna at 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;
>   }
>   
>   /**
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/igt-dev/attachments/20240313/013ba509/attachment.htm>


More information about the igt-dev mailing list