Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [CI i-g-t] don't look
@ 2018-03-01 16:48 Tvrtko Ursulin
  2018-03-01 17:31 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Tvrtko Ursulin @ 2018-03-01 16:48 UTC (permalink / raw)
  To: igt-dev; +Cc: Intel-gfx

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

1.
We need to tell the compiler mmio access cannot be optimized away
(volatile).

2.
We need to ensure we don't exit with forcewake left on. Signal threads
to exit in a controlled fashion and install atexit handler just in case.

v2: HACK

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 tests/gen7_forcewake_mt.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/tests/gen7_forcewake_mt.c b/tests/gen7_forcewake_mt.c
index 07320ef9e8ac..04a93afc839f 100644
--- a/tests/gen7_forcewake_mt.c
+++ b/tests/gen7_forcewake_mt.c
@@ -30,6 +30,8 @@
  *
  */
 
+#pragma GCC optimize ("O0")
+
 #include "igt.h"
 #include <sys/types.h>
 #include <pthread.h>
@@ -44,6 +46,7 @@ IGT_TEST_DESCRIPTION("Exercise a suspect workaround required for"
 
 struct thread {
 	pthread_t thread;
+	bool run;
 	void *mmio;
 	int fd;
 	int bit;
@@ -106,10 +109,11 @@ static void *igfx_get_mmio(void)
 static void *thread(void *arg)
 {
 	struct thread *t = arg;
-	uint32_t *forcewake_mt = (uint32_t *)((char *)t->mmio + FORCEWAKE_MT);
+	volatile uint32_t *forcewake_mt =
+		(uint32_t *)((char *)t->mmio + FORCEWAKE_MT);
 	uint32_t bit = 1 << t->bit;
 
-	while (1) {
+	while (t->run) {
 		*forcewake_mt = bit << 16 | bit;
 		igt_assert(*forcewake_mt & bit);
 		*forcewake_mt = bit << 16;
@@ -121,13 +125,33 @@ static void *thread(void *arg)
 
 #define MI_STORE_REGISTER_MEM                   (0x24<<23)
 
+static void *mmio_base;
+
+static void cleanup(int sig)
+{
+	volatile uint32_t *forcewake_mt =
+		(uint32_t *)((char *)mmio_base + FORCEWAKE_MT);
+	unsigned int bit;
+
+	for (bit = 2; bit < 16; bit++) {
+		*forcewake_mt = (1 << bit) << 16;
+		if (*forcewake_mt & (1 << bit))
+			igt_warn("Failed to restore bit %u!\n", bit);
+	}
+}
+
 igt_simple_main
 {
 	struct thread t[16];
 	int i;
 
+	mmio_base = igfx_get_mmio();
+
 	t[0].fd = drm_open_driver(DRIVER_INTEL);
-	t[0].mmio = igfx_get_mmio();
+	t[0].run = true;
+	t[0].mmio = mmio_base;
+
+	igt_install_exit_handler(cleanup);
 
 	for (i = 2; i < 16; i++) {
 		t[i] = t[0];
@@ -201,4 +225,10 @@ igt_simple_main
 
 		usleep(1000);
 	}
+
+	for (i = 2; i < 16; i++)
+		t[i].run = false;
+
+	for (i = 2; i < 16; i++)
+		pthread_join(t[i].thread, NULL);
 }
-- 
2.14.1

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-03-02 21:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-01 16:48 [Intel-gfx] [CI i-g-t] don't look Tvrtko Ursulin
2018-03-01 17:31 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-03-02  2:49 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2018-03-02  8:49 ` [igt-dev] [CI i-g-t v3] " Tvrtko Ursulin
2018-03-02 18:04 ` [igt-dev] ✓ Fi.CI.BAT: success for don't look (rev2) Patchwork
2018-03-02 21:46 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox