From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH i-g-t 08/17] tests/gem_reset_stat: Use new ctx helpers
Date: Tue, 10 Feb 2015 19:05:51 +0100 [thread overview]
Message-ID: <1423591560-9471-8-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1423591560-9471-1-git-send-email-daniel.vetter@ffwll.ch>
A bit more invasive since getting rid off all the places meant
to flatten some of the control flow with implicit igt_require.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
tests/gem_reset_stats.c | 117 +++++++++++-------------------------------------
1 file changed, 27 insertions(+), 90 deletions(-)
diff --git a/tests/gem_reset_stats.c b/tests/gem_reset_stats.c
index 646d6dac052e..faa209c1d28a 100644
--- a/tests/gem_reset_stats.c
+++ b/tests/gem_reset_stats.c
@@ -53,7 +53,6 @@
#define RS_UNKNOWN (1 << 2)
static uint32_t devid;
-static bool hw_contexts;
struct local_drm_i915_reset_stats {
__u32 ctx_id;
@@ -64,20 +63,8 @@ struct local_drm_i915_reset_stats {
__u32 pad;
};
-struct local_drm_i915_gem_context_create {
- __u32 ctx_id;
- __u32 pad;
-};
-
-struct local_drm_i915_gem_context_destroy {
- __u32 ctx_id;
- __u32 pad;
-};
-
#define MAX_FD 32
-#define CONTEXT_CREATE_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2d, struct local_drm_i915_gem_context_create)
-#define CONTEXT_DESTROY_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2e, struct local_drm_i915_gem_context_destroy)
#define GET_RESET_STATS_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x32, struct local_drm_i915_reset_stats)
#define LOCAL_I915_EXEC_VEBOX (4 << 0)
@@ -89,64 +76,32 @@ static bool gem_has_render(int fd)
return true;
}
-static bool has_context(const struct target_ring *ring);
-
static const struct target_ring {
uint32_t exec;
bool (*present)(int fd);
- bool (*contexts)(const struct target_ring *ring);
const char *name;
} rings[] = {
- { I915_EXEC_RENDER, gem_has_render, has_context, "render" },
- { I915_EXEC_BLT, gem_has_blt, has_context, "blt" },
- { I915_EXEC_BSD, gem_has_bsd, has_context, "bsd" },
- { LOCAL_I915_EXEC_VEBOX, gem_has_vebox, has_context, "vebox" },
+ { I915_EXEC_RENDER, gem_has_render, "render" },
+ { I915_EXEC_BLT, gem_has_blt, "blt" },
+ { I915_EXEC_BSD, gem_has_bsd, "bsd" },
+ { LOCAL_I915_EXEC_VEBOX, gem_has_vebox, "vebox" },
};
-static bool has_context(const struct target_ring *ring)
+static void check_context(const struct target_ring *ring)
{
- if (!hw_contexts)
- return false;
+ int fd = drm_open_any();
- if(ring->exec == I915_EXEC_RENDER)
- return true;
+ gem_context_destroy(fd,
+ gem_context_create(fd));
+ close(fd);
- return false;
+ igt_require(ring->exec == I915_EXEC_RENDER);
}
#define NUM_RINGS (sizeof(rings)/sizeof(struct target_ring))
static const struct target_ring *current_ring;
-static uint32_t context_create(int fd)
-{
- struct local_drm_i915_gem_context_create create;
- int ret;
-
- create.ctx_id = rand();
- create.pad = rand();
-
- ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create);
- igt_assert(ret == 0);
-
- return create.ctx_id;
-}
-
-static int context_destroy(int fd, uint32_t ctx_id)
-{
- int ret;
- struct local_drm_i915_gem_context_destroy destroy;
-
- destroy.ctx_id = ctx_id;
- destroy.pad = rand();
-
- ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
- if (ret != 0)
- return -errno;
-
- return 0;
-}
-
static int gem_reset_stats(int fd, int ctx_id,
struct local_drm_i915_reset_stats *rs)
{
@@ -450,7 +405,7 @@ static void test_rs_ctx(int num_fds, int num_ctx, int hang_index,
assert_reset_status(fd[i], 0, RS_NO_ERROR);
for (j = 0; j < num_ctx; j++) {
- ctx[i][j] = context_create(fd[i]);
+ ctx[i][j] = gem_context_create(fd[i]);
}
@@ -502,7 +457,7 @@ static void test_rs_ctx(int num_fds, int num_ctx, int hang_index,
for (i = 0; i < num_fds; i++) {
for (j = 0; j < num_ctx; j++) {
gem_close(fd[i], h[i][j]);
- igt_assert(context_destroy(fd[i], ctx[i][j]) == 0);
+ gem_context_destroy(fd[i], ctx[i][j]);
}
assert_reset_status(fd[i], 0, RS_NO_ERROR);
@@ -610,8 +565,8 @@ static void test_ban_ctx(void)
assert_reset_status(fd, 0, RS_NO_ERROR);
- ctx_good = context_create(fd);
- ctx_bad = context_create(fd);
+ ctx_good = gem_context_create(fd);
+ ctx_bad = gem_context_create(fd);
assert_reset_status(fd, 0, RS_NO_ERROR);
assert_reset_status(fd, ctx_good, RS_NO_ERROR);
@@ -681,8 +636,8 @@ static void test_ban_ctx(void)
igt_assert(h1 >= 0);
gem_close(fd, h1);
- igt_assert(context_destroy(fd, ctx_good) == 0);
- igt_assert(context_destroy(fd, ctx_bad) == 0);
+ gem_context_destroy(fd, ctx_good);
+ gem_context_destroy(fd, ctx_bad);
igt_assert(gem_reset_status(fd, ctx_good) < 0);
igt_assert(gem_reset_status(fd, ctx_bad) < 0);
igt_assert(exec_valid(fd, ctx_good) < 0);
@@ -701,8 +656,8 @@ static void test_unrelated_ctx(void)
fd2 = drm_open_any();
assert_reset_status(fd1, 0, RS_NO_ERROR);
assert_reset_status(fd2, 0, RS_NO_ERROR);
- ctx_guilty = context_create(fd1);
- ctx_unrelated = context_create(fd2);
+ ctx_guilty = gem_context_create(fd1);
+ ctx_unrelated = gem_context_create(fd2);
assert_reset_status(fd1, ctx_guilty, RS_NO_ERROR);
assert_reset_status(fd2, ctx_unrelated, RS_NO_ERROR);
@@ -721,8 +676,8 @@ static void test_unrelated_ctx(void)
gem_close(fd1, h1);
gem_close(fd2, h2);
- igt_assert(context_destroy(fd1, ctx_guilty) == 0);
- igt_assert(context_destroy(fd2, ctx_unrelated) == 0);
+ gem_context_destroy(fd1, ctx_guilty);
+ gem_context_destroy(fd2, ctx_unrelated);
close(fd1);
close(fd2);
@@ -746,14 +701,14 @@ static void test_close_pending_ctx(void)
uint32_t ctx;
fd = drm_open_any();
- ctx = context_create(fd);
+ ctx = gem_context_create(fd);
assert_reset_status(fd, ctx, RS_NO_ERROR);
h = inject_hang(fd, ctx);
igt_assert(h >= 0);
- igt_assert(context_destroy(fd, ctx) == 0);
- igt_assert(context_destroy(fd, ctx) == -ENOENT);
+ gem_context_destroy(fd, ctx);
+ igt_assert(__gem_context_destroy(fd, ctx) == -ENOENT);
gem_close(fd, h);
close(fd);
@@ -881,7 +836,7 @@ static void test_reset_count(const bool create_ctx)
fd = drm_open_any();
if (create_ctx)
- ctx = context_create(fd);
+ ctx = gem_context_create(fd);
else
ctx = 0;
@@ -915,7 +870,7 @@ static void test_reset_count(const bool create_ctx)
gem_close(fd, h);
if (create_ctx)
- context_destroy(fd, ctx);
+ gem_context_destroy(fd, ctx);
close(fd);
}
@@ -990,7 +945,7 @@ static void test_params_ctx(void)
int fd, ctx;
fd = drm_open_any();
- ctx = context_create(fd);
+ ctx = gem_context_create(fd);
_test_param(fd, ctx);
@@ -1047,22 +1002,6 @@ static void defer_hangcheck(int ring_num)
close(fd);
}
-static bool gem_has_hw_contexts(int fd)
-{
- struct local_drm_i915_gem_context_create create;
- int ret;
-
- memset(&create, 0, sizeof(create));
- ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create);
-
- if (ret == 0) {
- drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &create);
- return true;
- }
-
- return false;
-}
-
static bool gem_has_reset_stats(int fd)
{
struct local_drm_i915_reset_stats rs;
@@ -1109,9 +1048,8 @@ static void check_gpu_ok(void)
close(fd);
}
-#define RING_HAS_CONTEXTS (current_ring->contexts(current_ring))
#define RUN_TEST(...) do { check_gpu_ok(); __VA_ARGS__; check_gpu_ok(); } while (0)
-#define RUN_CTX_TEST(...) do { igt_skip_on(RING_HAS_CONTEXTS == false); RUN_TEST(__VA_ARGS__); } while (0)
+#define RUN_CTX_TEST(...) do { check_context(current_ring); RUN_TEST(__VA_ARGS__); } while (0)
igt_main
{
@@ -1124,7 +1062,6 @@ igt_main
fd = drm_open_any();
devid = intel_get_drm_devid(fd);
- hw_contexts = gem_has_hw_contexts(fd);
has_reset_stats = gem_has_reset_stats(fd);
close(fd);
--
2.1.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-02-10 18:04 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 18:05 [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 02/17] lib/ioctl: api polish for gem_context_has_param Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 03/17] lib/ioctl: gem_ prefix for igt_require_mmap_wc Daniel Vetter
2015-02-10 21:58 ` Chris Wilson
2015-02-11 8:37 ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 04/17] igt/ioctls: doc for gem_mmap Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 05/17] lib/ioctls: make gem_context_set/get_param infallible Daniel Vetter
2015-02-10 21:54 ` Chris Wilson
2015-02-11 8:42 ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 06/17] lib/ioctl: Add gem_context_destroy helpers Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 07/17] tests/gem_ctx_*: Use helpers Daniel Vetter
2015-02-10 18:05 ` Daniel Vetter [this message]
2015-02-10 18:05 ` [PATCH i-g-t 09/17] lib/ioctl: Document ctx param functions Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 10/17] tests: Add gem_ctx_param_basic Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 11/17] tests: Add invalid pad tests for ctx create/destroy Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 12/17] tests/gem_ppgtt: Start rcs before bcs for context tests Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 13/17] tests: Align subtest with naming convention Daniel Vetter
2015-02-10 21:53 ` Chris Wilson
2015-02-11 8:44 ` Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 14/17] lib/igt_aux: s/swap/igt_swap/ Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 15/17] tests/gem_wait: Adjust makefile Daniel Vetter
2015-02-10 18:05 ` [PATCH i-g-t 16/17] doc: Consolidate naming conventions into docbook Daniel Vetter
2015-02-10 18:06 ` [PATCH i-g-t 17/17] lib/igt_gt: Document and consolidate Daniel Vetter
2015-02-10 21:36 ` [PATCH i-g-t 01/17] lib/gt: api polish for igt_can_hang_ring Chris Wilson
2015-02-10 21:56 ` Daniel Vetter
2015-02-10 21:59 ` [PATCH i-g-t] lib/chipset: Cache devid Daniel Vetter
2015-02-10 22:28 ` Chris Wilson
2015-02-10 22:37 ` Daniel Vetter
2015-02-10 22:39 ` Daniel Vetter
2015-02-10 22:45 ` Daniel Vetter
2015-02-10 22:50 ` Chris Wilson
2015-02-11 8:49 ` Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1423591560-9471-8-git-send-email-daniel.vetter@ffwll.ch \
--to=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox