Re: [Intel-gfx] [PATCH i-g-t 2/3 v3] tests/drv_module_reload: Convert sh script to C version.

2016-10-26 Thread Chris Wilson
On Wed, Oct 26, 2016 at 04:54:40PM +0300, Marius Vlad wrote:
> +int main(void)
> +{
> + struct drm_i915_gem_sw_finish arg = { 0 };
> + int fd;
> +
> + signal(SIGALRM, SIG_IGN);
> +
> + fd = __drm_open_driver(DRIVER_INTEL);
> + if (fd < 0)
> + return IGT_EXIT_SKIP;
> +
> + alarm(1);
> + if (ioctl(fd, DRM_IOCTL_I915_GEM_SW_FINISH, ) == 0)
> + return IGT_EXIT_SKIP;

Hmm, good point. sw-finish work like this any more. The key was that we
used to wait on the struct_mutex before doing the lookup (and so we
could probe whether the driver was stuck on the reset, or just stuck).

Current candidate for replacement is the SET_CACHEING ioctl
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH i-g-t 2/3 v3] tests/drv_module_reload: Convert sh script to C version.

2016-10-26 Thread Marius Vlad
v3:
- fix passing boolean value as flags to igt_kmod_unload().

v2:
- embedded gem_alive and gem_exec_store into test (Chris Wilson)
- int main() to igt_main (Chris Wilson)
- moved tests/gem_alive -> tools/gem_info (Chris Wilson)
- added to intel-ci/fast-feedback.testlist (Petri Latvala)
- added hda_dynamic_debug() (Petri Latvala)
- renamed from tests/drv_module_reload_basic to tests/drv_module_reload
(all subtests are basic and have been added to fast-feedback.testlist)

Signed-off-by: Marius Vlad 

Fix igt kmod unload

Signed-off-by: Marius Vlad 
---
 tests/Makefile.am |   1 -
 tests/Makefile.sources|   2 +-
 tests/drv_module_reload.c | 394 ++
 tests/drv_module_reload_basic | 105 -
 tests/gem_alive.c |  35 ---
 tests/intel-ci/fast-feedback.testlist |  13 +-
 tools/Makefile.sources|   1 +
 tools/intel_gem_info.c|  35 +++
 8 files changed, 443 insertions(+), 143 deletions(-)
 create mode 100644 tests/drv_module_reload.c
 delete mode 100755 tests/drv_module_reload_basic
 delete mode 100644 tests/gem_alive.c
 create mode 100644 tools/intel_gem_info.c

diff --git a/tests/Makefile.am b/tests/Makefile.am
index a408126..14a41ae 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -26,7 +26,6 @@ noinst_PROGRAMS = \
$(NULL)
 
 pkglibexec_PROGRAMS = \
-   gem_alive \
gem_stress \
$(TESTS_progs) \
$(TESTS_progs_M) \
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 6d081c3..b1511c6 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -211,6 +211,7 @@ TESTS_progs = \
kms_pwrite_crc \
kms_sink_crc_basic \
prime_udl \
+   drv_module_reload \
$(NULL)
 
 # IMPORTANT: The ZZ_ tests need to be run last!
@@ -221,7 +222,6 @@ TESTS_scripts_M = \
 TESTS_scripts = \
debugfs_emon_crash \
drv_debugfs_reader \
-   drv_module_reload_basic \
kms_sysfs_edid_timing \
sysfs_l3_parity \
test_rte_check \
diff --git a/tests/drv_module_reload.c b/tests/drv_module_reload.c
new file mode 100644
index 000..c9bd9e3
--- /dev/null
+++ b/tests/drv_module_reload.c
@@ -0,0 +1,394 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+#include "igt.h"
+#include "igt_debugfs.h"
+#include "igt_aux.h"
+#include "igt_sysfs.h"
+#include "igt_core.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define LOCAL_I915_EXEC_BSD_SHIFT  (13)
+#define LOCAL_I915_EXEC_BSD_MASK   (3 << LOCAL_I915_EXEC_BSD_SHIFT)
+
+#define ENGINE_MASK  (I915_EXEC_RING_MASK | LOCAL_I915_EXEC_BSD_MASK)
+
+static void store_dword(int fd, unsigned ring)
+{
+   const int gen = intel_gen(intel_get_drm_devid(fd));
+   struct drm_i915_gem_exec_object2 obj[2];
+   struct drm_i915_gem_relocation_entry reloc;
+   struct drm_i915_gem_execbuffer2 execbuf;
+   uint32_t batch[16];
+   int i;
+
+   gem_require_ring(fd, ring);
+   igt_skip_on_f(gen == 6 && (ring & ~(3<<13)) == I915_EXEC_BSD,
+ "MI_STORE_DATA broken on gen6 bsd\n");
+
+   intel_detect_and_clear_missed_interrupts(fd);
+   memset(, 0, sizeof(execbuf));
+   execbuf.buffers_ptr = (uintptr_t)obj;
+   execbuf.buffer_count = 2;
+   execbuf.flags = ring;
+   if (gen < 6)
+   execbuf.flags |= I915_EXEC_SECURE;
+
+   memset(obj, 0, sizeof(obj));
+   obj[0].handle = gem_create(fd, 4096);
+   obj[1].handle = gem_create(fd, 4096);
+
+   memset(, 0, sizeof(reloc));
+   reloc.target_handle = obj[0].handle;
+   reloc.presumed_offset = 0;
+   reloc.offset = sizeof(uint32_t);
+   reloc.delta = 0;
+