From patchwork Tue Nov 5 09:21:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11227347 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF790139A for ; Tue, 5 Nov 2019 09:21:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9663A20717 for ; Tue, 5 Nov 2019 09:21:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9663A20717 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AADC16E952; Tue, 5 Nov 2019 09:21:34 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59A4B89A32 for ; Tue, 5 Nov 2019 09:21:30 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 19084819-1500050 for multiple; Tue, 05 Nov 2019 09:21:16 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 5 Nov 2019 09:21:08 +0000 Message-Id: <20191105092115.11451-3-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191105092115.11451-1-chris@chris-wilson.co.uk> References: <20191105092115.11451-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 03/10] drm/i915/selftests: Mock the engine sorting for easy validation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To make exploration of different sorting orders and presentation of the engines via the uabi easier, wrap the basic engine registration into a mock (aka standalone) selftest. Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin --- drivers/gpu/drm/i915/gt/intel_engine_user.c | 4 + .../gpu/drm/i915/gt/selftest_engine_user.c | 86 +++++++++++++++++++ .../drm/i915/selftests/i915_mock_selftests.h | 3 +- 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/i915/gt/selftest_engine_user.c diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c index 7f7150a733f4..15bb05aa1986 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_user.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c @@ -293,3 +293,7 @@ unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915) return which; } + +#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST) +#include "selftest_engine_user.c" +#endif diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_user.c b/drivers/gpu/drm/i915/gt/selftest_engine_user.c new file mode 100644 index 000000000000..d11cc6a4af09 --- /dev/null +++ b/drivers/gpu/drm/i915/gt/selftest_engine_user.c @@ -0,0 +1,86 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright © 2019 Intel Corporation + */ + +#include "i915_drv.h" + +static void destroy_engines(struct drm_i915_private *i915) +{ + struct intel_engine_cs *engine, *next; + + rbtree_postorder_for_each_entry_safe(engine, next, + &i915->uabi_engines, uabi_node) + kfree(engine); +} + +static int mock_uabi_engines(void *arg) +{ + static const u8 limits[] = { + [RENDER_CLASS] = 1, + [COPY_ENGINE_CLASS] = 1, + [VIDEO_DECODE_CLASS] = I915_MAX_VCS, + [VIDEO_ENHANCEMENT_CLASS] = I915_MAX_VECS, + }; + struct intel_engine_cs *engine; + struct drm_i915_private *i915; + unsigned long num_engines; + unsigned long found; + int c, i; + int err = 0; + + i915 = kzalloc(sizeof(*i915), GFP_KERNEL); + if (!i915) + return -ENOMEM; + + num_engines = 0; + for (c = 0; c < ARRAY_SIZE(limits); c++) { + for (i = 0; i < limits[c]; i++) { + engine = kzalloc(sizeof(*engine), GFP_KERNEL); + if (!engine) + goto err; + + engine->i915 = i915; + + engine->class = c; + engine->instance = i; + + intel_engine_add_user(engine); + num_engines++; + } + } + +err: + /* Check as far as we got up to -- will explode if not quite right */ + intel_engines_driver_register(i915); + + found = 0; + for_each_uabi_engine(engine, i915) { + pr_info("%s (%d, %d) -> [%d, %d]\n", + engine->name, + engine->uabi_class, + engine->uabi_instance, + engine->class, + engine->instance); + found++; + } + if (found != num_engines) { + pr_err("Registered %lu engines; only found %lu uABI engines\n", + num_engines, found); + err = -EINVAL; + } + + destroy_engines(i915); + kfree(i915); + return err; +} + +int intel_engine_user_mock_selftests(void) +{ + static const struct i915_subtest tests[] = { + SUBTEST(mock_uabi_engines), + }; + + return i915_subtests(tests, NULL); +} diff --git a/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h b/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h index aa5a0e7f5d9e..9a2dd8350650 100644 --- a/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h +++ b/drivers/gpu/drm/i915/selftests/i915_mock_selftests.h @@ -14,7 +14,8 @@ selftest(fence, i915_sw_fence_mock_selftests) selftest(scatterlist, scatterlist_mock_selftests) selftest(syncmap, i915_syncmap_mock_selftests) selftest(uncore, intel_uncore_mock_selftests) -selftest(engine, intel_engine_cs_mock_selftests) +selftest(engine_cs, intel_engine_cs_mock_selftests) +selftest(engine_user, intel_engine_user_mock_selftests) selftest(timelines, intel_timeline_mock_selftests) selftest(requests, i915_request_mock_selftests) selftest(objects, i915_gem_object_mock_selftests)