From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, HK_RANDOM_FROM,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A449C2D0DB for ; Thu, 23 Jan 2020 14:48:30 +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 17FD22073A for ; Thu, 23 Jan 2020 14:48:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17FD22073A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com 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 7714A6FD3B; Thu, 23 Jan 2020 14:48:29 +0000 (UTC) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 869FB6FD3A; Thu, 23 Jan 2020 14:48:27 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2020 06:48:27 -0800 X-IronPort-AV: E=Sophos;i="5.70,354,1574150400"; d="scan'208";a="229855858" Received: from wmszyfel-mobl2.ger.corp.intel.com (HELO [10.252.10.247]) ([10.252.10.247]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 23 Jan 2020 06:48:25 -0800 To: Chris Wilson , igt-dev@lists.freedesktop.org References: <20200123124306.18857-1-tvrtko.ursulin@linux.intel.com> <157978404508.19995.12294352233320424183@skylake-alporthouse-com> <157978539009.19995.13535399102451802903@skylake-alporthouse-com> <8ddcfcb7-d701-01a1-e208-c18c207b21fa@linux.intel.com> <157978900463.19995.12327750600329302953@skylake-alporthouse-com> From: Tvrtko Ursulin Organization: Intel Corporation UK Plc Message-ID: <1b69e977-5597-217b-f3c8-ccb1e24fced5@linux.intel.com> Date: Thu, 23 Jan 2020 14:48:24 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <157978900463.19995.12327750600329302953@skylake-alporthouse-com> Content-Language: en-US Subject: Re: [Intel-gfx] [PATCH i-g-t] i915/gem_engine_topology: Introduce and use gem_context_clone_with_engines X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On 23/01/2020 14:16, Chris Wilson wrote: > Quoting Tvrtko Ursulin (2020-01-23 14:01:41) >> >> On 23/01/2020 13:16, Chris Wilson wrote: >>> Quoting Tvrtko Ursulin (2020-01-23 13:08:26) >>>> >>>> On 23/01/2020 12:54, Chris Wilson wrote: >>>>> Quoting Tvrtko Ursulin (2020-01-23 12:43:06) >>>>>> From: Tvrtko Ursulin >>>>>> >>>>>> In test cases which create new contexts and submit work against them using >>>>>> the passed in engine index we are sometimes unsure whether this engine >>>>>> index was potentially created based on a default context with engine map >>>>>> configured (such as when under the __for_each_physical_engine iterator. >>>>>> >>>>>> To simplify test code we add gem_context/queue_clone_with_engines which >>>>>> is to be used in such scenario instead of the current pattern of >>>>>> gem_context_create followed by gem_context_set_all_engines (which is also >>>>>> removed by the patch). >>>>>> >>>>>> Signed-off-by: Tvrtko Ursulin >>>>>> Suggested-by: Chris Wilson >>>>>> --- >>>>>> lib/i915/gem_context.c | 59 ++++++++++++++++++++++++++++++++++ >>>>>> lib/i915/gem_context.h | 4 +++ >>>>>> lib/i915/gem_engine_topology.c | 11 ------- >>>>>> lib/i915/gem_engine_topology.h | 2 -- >>>>>> tests/i915/gem_ctx_clone.c | 15 +-------- >>>>>> tests/i915/gem_ctx_switch.c | 19 ++++------- >>>>>> tests/i915/gem_exec_parallel.c | 3 +- >>>>>> tests/i915/gem_spin_batch.c | 11 +++---- >>>>>> tests/perf_pmu.c | 3 +- >>>>>> 9 files changed, 76 insertions(+), 51 deletions(-) >>>>>> >>>>>> diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c >>>>>> index 1fae5191f83f..f92d5ff3dfc5 100644 >>>>>> --- a/lib/i915/gem_context.c >>>>>> +++ b/lib/i915/gem_context.c >>>>>> @@ -372,6 +372,50 @@ uint32_t gem_context_clone(int i915, >>>>>> return ctx; >>>>>> } >>>>>> >>>>>> +bool gem_has_context_clone(int i915) >>>>>> +{ >>>>>> + struct drm_i915_gem_context_create_ext_clone ext = { >>>>>> + { .name = I915_CONTEXT_CREATE_EXT_CLONE }, >>>>>> + .clone_id = -1, >>>>>> + }; >>>>>> + struct drm_i915_gem_context_create_ext create = { >>>>>> + .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS, >>>>>> + .extensions = to_user_pointer(&ext), >>>>>> + }; >>>>>> + int err; >>>>>> + >>>>>> + err = 0; >>>>>> + if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, &create)) { >>>>>> + err = -errno; >>>>>> + igt_assume(err); >>>>>> + } >>>>>> + errno = 0; >>>>>> + >>>>>> + return err == -ENOENT; >>>>>> +} >>>>>> + >>>>>> +/** >>>>>> + * gem_context_clone_with_engines: >>>>>> + * @i915: open i915 drm file descriptor >>>>>> + * @src: i915 context id >>>>>> + * >>>>>> + * Special purpose wrapper to create a new context by cloning engines from @src. >>>>>> + * >>>>>> + * In can be called regardless of whether the kernel supports context cloning. >>>>>> + * >>>>>> + * Intended purpose is to use for creating contexts against which work will be >>>>>> + * submitted and the engine index came from external source, derived from a >>>>>> + * default context potentially configured with an engine map. >>>>>> + */ >>>>>> +uint32_t gem_context_clone_with_engines(int i915, uint32_t src) >>>>>> +{ >>>>>> + if (!gem_has_context_clone(i915)) >>>>>> + return gem_context_create(i915); >>>>> >>>>> Yes, that should cover us for older kernels and keep the for_each loops >>>>> happy. >>>>> >>>>>> + else >>>>>> + return gem_context_clone(i915, src, 0, >>>>>> + I915_CONTEXT_CLONE_ENGINES); >>>>> >>>>> 0 and CLONE are the wrong way around. >>>> >>>> Oopsie. >>>> >>>>> >>>>> I would have done >>>>> >>>>> int __gem_context_clone_with_engines(int i915, uint32_t src, uint32_t *out) >>>>> { >>>>> int err; >>>>> >>>>> err = __gem_context_clone(i915, src, CLONE_ENGINES, 0, out); >>>>> if (err && !gem_has_context_clone(i915)) >>>>> err = __gem_context_create(i915, out); >>>>> >>>>> return err; >>>>> } >>>>> >>>>> uint32_t gem_context_clone_with_engines(int i915, uint32_t src) >>>>> { >>>>> uint32_t ctx; >>>>> >>>>> igt_assert_eq(__gem_context_clone_with_engine(i915, src, &ctx), 0); >>>>> >>>>> return ctx; >>>>> } >>>> >>>> I think I prefer my version as it is a bit more explicit. >>> >>> I was hoping to do something more like >>> err = __clone() >>> if (err == ENOSYS) >>> err = __create() >>> >>> Either way, I would suggest doing >>> >>> int __gem_context_clone_with_engines(int i915, uint32_t src, uint32_t *out); >>> uint32_t gem_context_clone_with_engines(int i915, uint32_t src); >>> >>> as I prefer that style of error message. >> >> Error message? What do you mean? > > igt_assert_eq(__gem_context_clone_with_engine(i915, src, &ctx), 0); > is the nicest assert message without using igt_assert_f and writing an > information message by hand. But you will get that, either helper gem_context_clone_with_engines calls uses that style. >>> Nothing else to complain about, >>> Reviewed-by: Chris Wilson >> >> So this is conditional on rewriting it as above or not? > > Mere recommendations. Knowing full well that if at some point we need > __gem_context_clone_with_engines() the above will happen anyway :) Ack, leaving it for later. Now need to wait for the results here and then coordinate with at least three people who will need to adjust their patches. Regards, Tvrtko _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx