[PATCH i-g-t 3/9] lib/igt_kmod: Share xe's unload logic with i915

Matt Roper matthew.d.roper at intel.com
Tue Nov 19 01:20:13 UTC 2024


On Mon, Nov 04, 2024 at 10:18:39PM -0800, Lucas De Marchi wrote:
> Now that xe unbind+unload logic is working, extend it to i915.
> Note that there was a buggy call igt_kmod_is_loaded("driver") that would
> never trigger: no point fixing that if we are dropping it though.
> 
> Another note that we can't still completely drop the old logic since a
> few tests rely on it. Example: tests/intel/perf_pmu.c checks for trying
> to remove the module with a perf event open and that being blocked by
> the module refcount. Doing unbind() first would succeed the module
> unload, but also crash the machine since perf doesn't work (yet) with
> unplugging the device. That will need to be fixed in the kernel first.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>

Reviewed-by: Matt Roper <matthew.d.roper at intel.com>

> ---
>  lib/igt_kmod.c | 36 +++---------------------------------
>  lib/igt_kmod.h |  6 ++++--
>  2 files changed, 7 insertions(+), 35 deletions(-)
> 
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index d031bfe18..0c093ec62 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -703,40 +703,10 @@ int igt_kmod_unbind(const char *mod_name)
>  int
>  igt_intel_driver_unload(const char *driver)
>  {
> -	char *who = NULL;
> -	int ret;
> -
> -	ret = __igt_intel_driver_unload(&who, driver);
> -	if (ret) {
> -		igt_warn("Could not unload %s\n", who);
> -		igt_kmod_list_loaded();
> -		igt_lsof("/dev/dri");
> -		igt_lsof("/dev/snd");
> -		free(who);
> -		return ret;
> -	}
> -	free(who);
> -
> -	if (igt_kmod_is_loaded("intel-gtt"))
> -		igt_kmod_unload("intel-gtt");
> -
> -	igt_kmod_unload("drm_kms_helper");
> -	igt_kmod_unload("drm");
> -
> -	if (igt_kmod_is_loaded("driver")) {
> -		igt_warn("%s.ko still loaded!\n", driver);
> -		return -EBUSY;
> -	}
> -
> -	return 0;
> -}
> -
> -int igt_xe_driver_unload(void)
> -{
> -	igt_kmod_unbind("xe");
> +	igt_kmod_unbind(driver);
>  
> -	igt_kmod_unload("xe");
> -	if (igt_kmod_is_loaded("xe"))
> +	igt_kmod_unload(driver);
> +	if (igt_kmod_is_loaded(driver))
>  		return IGT_EXIT_FAILURE;
>  
>  	return IGT_EXIT_SUCCESS;
> diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
> index 193b95627..88d4a51e6 100644
> --- a/lib/igt_kmod.h
> +++ b/lib/igt_kmod.h
> @@ -64,8 +64,10 @@ static inline int igt_xe_driver_load(const char *opts)
>  	return igt_intel_driver_load(opts, "xe");
>  }
>  
> -
> -int igt_xe_driver_unload(void);
> +static inline int igt_xe_driver_unload(void)
> +{
> +	return igt_intel_driver_unload("xe");
> +}
>  
>  int igt_amdgpu_driver_load(const char *opts);
>  int igt_amdgpu_driver_unload(void);
> -- 
> 2.47.0
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


More information about the igt-dev mailing list