diff mbox

[i-g-t,1/2] lib/kmod: Fail if the module is already loaded

Message ID 20180711084619.27634-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson July 11, 2018, 8:46 a.m. UTC
If we want to set new module options, we must load the module or die
trying. We may want to always fail if the module if already loaded, but
for now, take the small incremental step and insist that the options are
set if requested.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_kmod.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Michał Winiarski July 11, 2018, 8:58 a.m. UTC | #1
On Wed, Jul 11, 2018 at 09:46:18AM +0100, Chris Wilson wrote:
> If we want to set new module options, we must load the module or die
> trying. We may want to always fail if the module if already loaded, but
> for now, take the small incremental step and insist that the options are
> set if requested.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>

-Michał

> ---
>  lib/igt_kmod.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index 4f70e30d9..f3f34a62d 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -141,7 +141,13 @@ out:
>  
>  static int modprobe(struct kmod_module *kmod, const char *options)
>  {
> -	return kmod_module_probe_insert_module(kmod, 0, options,
> +	unsigned int flags;
> +
> +	flags = 0;
> +	if (options) /* force a fresh load to set the new options */
> +		flags |= KMOD_PROBE_FAIL_ON_LOADED;
> +
> +	return kmod_module_probe_insert_module(kmod, flags, options,
>  					       NULL, NULL, NULL);
>  }
>  
> -- 
> 2.18.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 4f70e30d9..f3f34a62d 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -141,7 +141,13 @@  out:
 
 static int modprobe(struct kmod_module *kmod, const char *options)
 {
-	return kmod_module_probe_insert_module(kmod, 0, options,
+	unsigned int flags;
+
+	flags = 0;
+	if (options) /* force a fresh load to set the new options */
+		flags |= KMOD_PROBE_FAIL_ON_LOADED;
+
+	return kmod_module_probe_insert_module(kmod, flags, options,
 					       NULL, NULL, NULL);
 }