[Intel-gfx] [PATCH i-g-t] igt/drv_module_reload: Revamp fault-injection

2018-07-12 Thread Chris Wilson
The current method of checking for a failed module load is flawed, as we
only report the error on probing it is not being reported back by
modprobe. So we have to dig inside the module_parameters while the
module is still loaded to discover the error.

v2: Expect i915.inject_load_failure to be zero on success
v3: Do a full i915 unload to ensure fbdev is unbound in cases where it
managed to bind itself before failure injection.
v4: Disable the display (temporary) to minimally fix up the test case
before more regressions slip by.

Signed-off-by: Chris Wilson 
Cc: Michał Winiarski 
Cc: Imre Deak 
Reviewed-by: Michał Winiarski  #v3
---
 tests/drv_module_reload.c | 52 +++
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --git a/tests/drv_module_reload.c b/tests/drv_module_reload.c
index 3046d8227..bb26368e7 100644
--- a/tests/drv_module_reload.c
+++ b/tests/drv_module_reload.c
@@ -234,6 +234,45 @@ reload(const char *opts_i915)
return err;
 }
 
+static int open_parameters(const char *module_name)
+{
+   char path[256];
+
+   snprintf(path, sizeof(path), "/sys/module/%s/parameters", module_name);
+   return open(path, O_RDONLY);
+}
+
+static int
+inject_fault(const char *module_name, const char *opt, int fault)
+{
+#define XXX_NO_DISPLAY "disable_display=1 "
+   char buf[1024];
+   int dir;
+
+   igt_assert(fault > 0);
+   snprintf(buf, sizeof(buf), XXX_NO_DISPLAY "%s=%d", opt, fault);
+
+   if (igt_kmod_load(module_name, buf)) {
+   igt_warn("Failed to load module '%s' with options '%s'\n",
+module_name, buf);
+   return 1;
+   }
+
+   dir = open_parameters(module_name);
+   igt_sysfs_scanf(dir, opt, "%d", );
+   close(dir);
+
+   igt_debug("Loaded '%s %s', result=%d\n", module_name, buf, fault);
+
+   if (strcmp(module_name, "i915")) /* XXX better ideas! */
+   igt_kmod_unload(module_name, 0);
+   else
+   igt_i915_driver_unload();
+
+   return fault;
+#undef XXX_NO_DISPLAY
+}
+
 static void
 gem_sanitycheck(void)
 {
@@ -320,12 +359,15 @@ igt_main
igt_assert_eq(reload("disable_display=1"), 0);
 
igt_subtest("basic-reload-inject") {
-   char buf[64];
int i = 0;
-   do {
-   snprintf(buf, sizeof(buf),
-"inject_load_failure=%d", ++i);
-   } while (reload(buf));
+
+   igt_i915_driver_unload();
+
+   while (inject_fault("i915", "inject_load_failure", ++i) == 0)
+   ;
+
+   /* We expect to hit at least one fault! */
+   igt_assert(i > 1);
}
 
igt_fixture {
-- 
2.18.0

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] igt/drv_module_reload: Revamp fault-injection

2018-07-12 Thread Chris Wilson
The current method of checking for a failed module load is flawed, as we
only report the error on probing it is not being reported back by
modprobe. So we have to dig inside the module_parameters while the
module is still loaded to discover the error.

v2: Expect i915.inject_load_failure to be zero on success
v3: Do a full i915 unload to ensure fbdev is unbound in cases where it
managed to bind itself before failure injection.
v4: Disable the display (temporary) to minimally fix up the test case
before more regressions slip by.

Signed-off-by: Chris Wilson 
Cc: Michał Winiarski 
Cc: Imre Deak 
Reviewed-by: Michał Winiarski  #v3
---
 tests/drv_module_reload.c | 52 +++
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --git a/tests/drv_module_reload.c b/tests/drv_module_reload.c
index 3046d8227..652bb3272 100644
--- a/tests/drv_module_reload.c
+++ b/tests/drv_module_reload.c
@@ -234,6 +234,45 @@ reload(const char *opts_i915)
return err;
 }
 
+static int open_parameters(const char *module_name)
+{
+   char path[256];
+
+   snprintf(path, sizeof(path), "/sys/module/%s/parameters", module_name);
+   return open(path, O_RDONLY);
+}
+
+static int
+inject_fault(const char *module_name, const char *opt, int fault)
+{
+#define XXX_NO_DISPLAY "disable_display=1"
+   char buf[1024];
+   int dir;
+
+   igt_assert(fault > 0);
+   snprintf(buf, sizeof(buf), XXX_NO_DISPLAY "%s=%d", opt, fault);
+
+   if (igt_kmod_load(module_name, buf)) {
+   igt_warn("Failed to load module '%s' with options '%s'\n",
+module_name, buf);
+   return 1;
+   }
+
+   dir = open_parameters(module_name);
+   igt_sysfs_scanf(dir, opt, "%d", );
+   close(dir);
+
+   igt_debug("Loaded '%s %s', result=%d\n", module_name, buf, fault);
+
+   if (strcmp(module_name, "i915")) /* XXX better ideas! */
+   igt_kmod_unload(module_name, 0);
+   else
+   igt_i915_driver_unload();
+
+   return fault;
+#undef XXX_NO_DISPLAY
+}
+
 static void
 gem_sanitycheck(void)
 {
@@ -320,12 +359,15 @@ igt_main
igt_assert_eq(reload("disable_display=1"), 0);
 
igt_subtest("basic-reload-inject") {
-   char buf[64];
int i = 0;
-   do {
-   snprintf(buf, sizeof(buf),
-"inject_load_failure=%d", ++i);
-   } while (reload(buf));
+
+   igt_i915_driver_unload();
+
+   while (inject_fault("i915", "inject_load_failure", ++i) == 0)
+   ;
+
+   /* We expect to hit at least one fault! */
+   igt_assert(i > 1);
}
 
igt_fixture {
-- 
2.18.0

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] igt/drv_module_reload: Revamp fault-injection

2018-06-27 Thread Chris Wilson
The current method of checking for a failed module load is flawed, as we
only report the error on probing it is not being reported back by
modprobe. So we have to dig inside the module_parameters while the
module is still loaded to discover the error.

v2: Expect i915.inject_load_failure to be zero on success

Signed-off-by: Chris Wilson 
Cc: Michał Winiarski 
Cc: Imre Deak 
Reviewed-by: Michał Winiarski 
---
 tests/drv_module_reload.c | 47 ++-
 1 file changed, 42 insertions(+), 5 deletions(-)

diff --git a/tests/drv_module_reload.c b/tests/drv_module_reload.c
index 3046d8227..57e5b50ec 100644
--- a/tests/drv_module_reload.c
+++ b/tests/drv_module_reload.c
@@ -234,6 +234,40 @@ reload(const char *opts_i915)
return err;
 }
 
+static int open_parameters(const char *module_name)
+{
+   char path[256];
+
+   snprintf(path, sizeof(path), "/sys/module/%s/parameters", module_name);
+   return open(path, O_RDONLY);
+}
+
+static int
+inject_fault(const char *module_name, const char *opt, int fault)
+{
+   char buf[1024];
+   int dir;
+
+   igt_assert(fault > 0);
+   snprintf(buf, sizeof(buf), "%s=%d", opt, fault);
+
+   if (igt_kmod_load(module_name, buf)) {
+   igt_warn("Failed to load module '%s' with options '%s'\n",
+module_name, buf);
+   return 1;
+   }
+
+   dir = open_parameters(module_name);
+   igt_sysfs_scanf(dir, opt, "%d", );
+   close(dir);
+
+   igt_debug("Loaded '%s %s', result=%d\n", module_name, buf, fault);
+
+   igt_kmod_unload(module_name, 0);
+
+   return fault;
+}
+
 static void
 gem_sanitycheck(void)
 {
@@ -320,12 +354,15 @@ igt_main
igt_assert_eq(reload("disable_display=1"), 0);
 
igt_subtest("basic-reload-inject") {
-   char buf[64];
int i = 0;
-   do {
-   snprintf(buf, sizeof(buf),
-"inject_load_failure=%d", ++i);
-   } while (reload(buf));
+
+   igt_i915_driver_unload();
+
+   while (inject_fault("i915", "inject_load_failure", ++i) == 0)
+   ;
+
+   /* We expect to hit at least one fault! */
+   igt_assert(i > 1);
}
 
igt_fixture {
-- 
2.18.0

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] igt/drv_module_reload: Revamp fault-injection

2018-06-07 Thread Chris Wilson
The current method of checking for a failed module load is flawed, as we
only report the error on probing it is not being reported back by
modprobe. So we have to dig inside the module_parameters while the
module is still loaded to discover the error.

v2: Expect i915.inject_load_failure to be zero on success

Signed-off-by: Chris Wilson 
Cc: Michał Winiarski 
Cc: Imre Deak 
Reviewed-by: Michał Winiarski 
---
 tests/drv_module_reload.c | 47 ++-
 1 file changed, 42 insertions(+), 5 deletions(-)

diff --git a/tests/drv_module_reload.c b/tests/drv_module_reload.c
index 3046d8227..57e5b50ec 100644
--- a/tests/drv_module_reload.c
+++ b/tests/drv_module_reload.c
@@ -234,6 +234,40 @@ reload(const char *opts_i915)
return err;
 }
 
+static int open_parameters(const char *module_name)
+{
+   char path[256];
+
+   snprintf(path, sizeof(path), "/sys/module/%s/parameters", module_name);
+   return open(path, O_RDONLY);
+}
+
+static int
+inject_fault(const char *module_name, const char *opt, int fault)
+{
+   char buf[1024];
+   int dir;
+
+   igt_assert(fault > 0);
+   snprintf(buf, sizeof(buf), "%s=%d", opt, fault);
+
+   if (igt_kmod_load(module_name, buf)) {
+   igt_warn("Failed to load module '%s' with options '%s'\n",
+module_name, buf);
+   return 1;
+   }
+
+   dir = open_parameters(module_name);
+   igt_sysfs_scanf(dir, opt, "%d", );
+   close(dir);
+
+   igt_debug("Loaded '%s %s', result=%d\n", module_name, buf, fault);
+
+   igt_kmod_unload(module_name, 0);
+
+   return fault;
+}
+
 static void
 gem_sanitycheck(void)
 {
@@ -320,12 +354,15 @@ igt_main
igt_assert_eq(reload("disable_display=1"), 0);
 
igt_subtest("basic-reload-inject") {
-   char buf[64];
int i = 0;
-   do {
-   snprintf(buf, sizeof(buf),
-"inject_load_failure=%d", ++i);
-   } while (reload(buf));
+
+   igt_i915_driver_unload();
+
+   while (inject_fault("i915", "inject_load_failure", ++i) == 0)
+   ;
+
+   /* We expect to hit at least one fault! */
+   igt_assert(i > 1);
}
 
igt_fixture {
-- 
2.17.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] igt/drv_module_reload: Revamp fault-injection

2018-06-07 Thread Chris Wilson
The current method of checking for a failed module load is flawed, as we
only report the error on probing it is not being reported back by
modprobe. So we have to dig inside the module_parameters while the
module is still loaded to discover the error.

v2: Expect i915.inject_load_failure to be zero on success

Signed-off-by: Chris Wilson 
Cc: Michał Winiarski 
Cc: Imre Deak 
Reviewed-by: Michał Winiarski 
---
 tests/drv_module_reload.c | 45 ++-
 1 file changed, 40 insertions(+), 5 deletions(-)

diff --git a/tests/drv_module_reload.c b/tests/drv_module_reload.c
index 3046d8227..5d6680b0b 100644
--- a/tests/drv_module_reload.c
+++ b/tests/drv_module_reload.c
@@ -234,6 +234,38 @@ reload(const char *opts_i915)
return err;
 }
 
+static int open_parameters(const char *module_name)
+{
+   char path[256];
+
+   snprintf(path, sizeof(path), "/sys/module/%s/parameters", module_name);
+   return open(path, O_RDONLY);
+}
+
+static int
+inject_fault(const char *module_name, const char *opt, int fault)
+{
+   char buf[1024];
+   int dir;
+
+   igt_assert(fault > 0);
+   snprintf(buf, sizeof(buf), "%s=%d", opt, fault);
+
+   if (igt_kmod_load(module_name, buf)) {
+   igt_warn("Failed to load module '%s' with options '%s'\n",
+module_name, buf);
+   return 1;
+   }
+
+   dir = open_parameters(module_name);
+   igt_sysfs_scanf(dir, opt, "%d", );
+   close(dir);
+
+   igt_kmod_unload(module_name, 0);
+
+   return fault;
+}
+
 static void
 gem_sanitycheck(void)
 {
@@ -320,12 +352,15 @@ igt_main
igt_assert_eq(reload("disable_display=1"), 0);
 
igt_subtest("basic-reload-inject") {
-   char buf[64];
int i = 0;
-   do {
-   snprintf(buf, sizeof(buf),
-"inject_load_failure=%d", ++i);
-   } while (reload(buf));
+
+   igt_i915_driver_unload();
+
+   while (inject_fault("i915", "inject_load_failure", ++i) == 0)
+   ;
+
+   /* We expect to hit at least one fault! */
+   igt_assert(i > 1);
}
 
igt_fixture {
-- 
2.17.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH i-g-t] igt/drv_module_reload: Revamp fault-injection

2018-06-06 Thread Chris Wilson
Quoting Michał Winiarski (2018-06-06 15:18:14)
> On Wed, Jun 06, 2018 at 02:09:16PM +0100, Chris Wilson wrote:
> > The current method of checking for a failed module load is flawed, as we
> > only report the error on probing it is not being reported back by
> > modprobe. So we have to dig inside the module_parameters while the
> > module is still loaded to discover the error.
> > 
> > Signed-off-by: Chris Wilson 
> > Cc: Michał Winiarski 
> > Cc: Imre Deak 
> 
> That also works.
> 
> Reviewed-by: Michał Winiarski 
> 
> Should we push now? Or delay until we fix i915?

We wait a bit to fix i915. But the corresponding kernel patch should be
clean to go (well hopefully v2!).
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH i-g-t] igt/drv_module_reload: Revamp fault-injection

2018-06-06 Thread Michał Winiarski
On Wed, Jun 06, 2018 at 02:09:16PM +0100, Chris Wilson wrote:
> The current method of checking for a failed module load is flawed, as we
> only report the error on probing it is not being reported back by
> modprobe. So we have to dig inside the module_parameters while the
> module is still loaded to discover the error.
> 
> Signed-off-by: Chris Wilson 
> Cc: Michał Winiarski 
> Cc: Imre Deak 

That also works.

Reviewed-by: Michał Winiarski 

Should we push now? Or delay until we fix i915?

-Michał

> ---
>  tests/drv_module_reload.c | 48 +++
>  1 file changed, 43 insertions(+), 5 deletions(-)
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t] igt/drv_module_reload: Revamp fault-injection

2018-06-06 Thread Chris Wilson
The current method of checking for a failed module load is flawed, as we
only report the error on probing it is not being reported back by
modprobe. So we have to dig inside the module_parameters while the
module is still loaded to discover the error.

Signed-off-by: Chris Wilson 
Cc: Michał Winiarski 
Cc: Imre Deak 
---
 tests/drv_module_reload.c | 48 +++
 1 file changed, 43 insertions(+), 5 deletions(-)

diff --git a/tests/drv_module_reload.c b/tests/drv_module_reload.c
index 092982960..e6bc354b6 100644
--- a/tests/drv_module_reload.c
+++ b/tests/drv_module_reload.c
@@ -234,6 +234,41 @@ reload(const char *opts_i915)
return err;
 }
 
+static int open_parameters(const char *module_name)
+{
+   char path[256];
+
+   snprintf(path, sizeof(path), "/sys/module/%s/parameters", module_name);
+   return open(path, O_RDONLY);
+}
+
+static int
+inject_fault(const char *module_name, const char *opt, int fault)
+{
+   char buf[1024];
+   int dir, err;
+
+   snprintf(buf, sizeof(buf), "%s=%d", opt, fault);
+
+   if (igt_kmod_load(module_name, buf)) {
+   igt_warn("Failed to load module '%s' with options '%s'\n",
+module_name, buf);
+   return 1;
+   }
+
+   err = 1;
+   dir = open_parameters(module_name);
+   igt_sysfs_scanf(dir, opt, "%d", );
+   close(dir);
+
+   igt_kmod_unload(module_name, 0);
+
+   if (err < 0)
+   return err;
+
+   return 0;
+}
+
 static void
 gem_sanitycheck(void)
 {
@@ -323,12 +358,15 @@ igt_main
igt_assert_eq(reload("disable_display=1"), 0);
 
igt_subtest("basic-reload-inject") {
-   char buf[64];
int i = 0;
-   do {
-   snprintf(buf, sizeof(buf),
-"inject_load_failure=%d", ++i);
-   } while (reload(buf));
+
+   igt_i915_driver_unload();
+
+   while (inject_fault("i915", "inject_load_failure", ++i) < 0)
+   ;
+
+   /* We expect to hit at least one fault! */
+   igt_assert(i > 1);
}
 
igt_fixture {
-- 
2.17.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx