From: Andi Shyti <andi.shyti@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: IGT dev <igt-dev@lists.freedesktop.org>, Andi Shyti <andi@etezian.org>
Subject: Re: [igt-dev] [PATCH v13 6/9] lib/i915: add gem_engine_topology library
Date: Wed, 20 Mar 2019 13:13:16 +0200 [thread overview]
Message-ID: <20190320111316.GB1276@intel.intel> (raw)
In-Reply-To: <155307954524.8718.11135284483961823682@skylake-alporthouse-com>
On Wed, Mar 20, 2019 at 10:59:05AM +0000, Chris Wilson wrote:
> Quoting Andi Shyti (2019-03-20 10:49:13)
> > > > + uint8_t buff[SIZEOF_CTX_PARAM] = { };
> > > > + struct i915_context_param_engines *cengine =
> > > > + (struct i915_context_param_engines *) buff;
> > >
> > > Oi, noet. And just a single tab indent.
> >
> > Yes, I messed up a few things in this version and as I was writing
> > to Tvrtko, also the kernel I was running had some stuff that were
> > screwing up the ioctls values.
> >
> > > > + struct drm_i915_gem_context_param cparam = {
> > > > + .param = I915_CONTEXT_PARAM_ENGINES,
> > > > + .ctx_id = ctx_id,
> > > > + .size = SIZEOF_CTX_PARAM,
> > > > + .value = to_user_pointer(cengine),
> > > > + };
> > > > + int ret, i;
> > > > +
> > > > + cparam.value = to_user_pointer(cengine);
> > > > +
> > > > + ret = __gem_context_get_param(fd, &cparam);
> > > > +
> > > > + if (ret) {
> > > > + /* if kernel does not support engine/context mapping */
> > > > + const struct intel_execution_engine2 *e2;
> > >
> > > Hmm, how does this distinguish against too many engines (more than can
> > > fit into buf?). Both return -EINVAL iirc?
> >
> > I haven't found in the driver where we return -EINVAL for having
> > too many engines. Have I missed it somewhere?
>
> If we cannot fit the ctx->engines[] into the cparam.size we also report
> -EINVAL. I'm wondering if we should establish a different errno
> convention for that.
>
> > > > + dup_engine(&engine_data.engines[i], NULL,
> > > > + cengine->class_instance[i].engine_class,
> > > > + cengine->class_instance[i].engine_instance,
> > > > + i + 1);
> > >
> > > This seems very suspect. If class/instance doesn't map to a known
> > > engine, dup_engine() should be figuring it out, as the engine[] is
> > > entirely at the arbitrary whim of the user.
> >
> > it does, right? we know the list of engines and we assign
> > "unk<class>:<instance>" if the engine is not recognised.
> >
> > Am I missing something?
>
> I want to handle virtual engines somehow :)
>
> > In any case, I'm still going to change it and compare all class
> > instances against the intel_execution_engines2 array.
> >
> > Or do you mean that we shouldn't have the engine at all in the
> > list I am creating... at the end that's what comes from the
> > driver.
>
> Here I was just saying '+1' is obsolete.
>
> > > > +struct intel_engine_data {
> > > > + int fd;
> > > > + uint32_t ctx;
> > > > +
> > > > + uint32_t nengines;
> > > > + uint32_t n;
> > > > + struct intel_execution_engine2 engines[I915_EXEC_RING_MASK + 1];
> > > > +};
> > >
> > > This is the _iter. Pull the for_each_foo() into this patch so we can see
> > > how it is put together.
> > >
> > > At which point, do we need the (fd,ctx) here since they are parameters to
> > > the for_each() and so available later?
> >
> > they are useful for my functions... well... little advantage, no
> > need indeed.
> >
> > I didn't see this as an iter structure rather than a data
> > structure (just an 'n' that increments for helping the for_each),
> > that we could use in other occasions other than looping thorugh.
> >
> > > Missing _iter_fini. Polish the for_each_foo() a bit more.
> >
> > _iter_fini? You mean an iter_end to clean up things? Do we need
> > it? Is there anything to clean up?
>
> Did I not see asprintf? Anyway Tvrtko suggested that they can all be
> static names, so no, there shouldn't be much to clean up, but that is
> one huge struct to be passing around the stack!!!
in any case, I thought about the clean up, but it wouldn't fix
anything anyway, because if the for_each is interrupted, we would
never ever clean up and leak anything inside.
I somehow ignored asprintf because I always thought that pointing
to static names is not future proof enough (I considered that one
day we will get rid of intel_execution_engines2 array, while
this way we are binding to it even more. I don't know what is
worse :) ).
A solution is to expand the struct intel_execution_engine2, by
removing the "const" in front of the name so that we can have
more flexibility at assigning names.
Another solution would be having the engine_data structure as a
global structure that contains all informations and it's
allocated outside the for_each. We can have functions inside it
like init, get_next, and so on, instead of using it just as a
mere leaking iterator.
> -Chris
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-03-20 11:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 23:44 [igt-dev] [PATCH v13 0/9] new engine discovery interface Andi Shyti
2019-03-19 23:44 ` [igt-dev] [PATCH v13 1/9] lib/igt_gt: remove unnecessary argument Andi Shyti
2019-03-19 23:44 ` [igt-dev] [PATCH v13 2/9] lib: ioctl_wrappers: reach engines by index as well Andi Shyti
2019-03-20 9:14 ` Chris Wilson
2019-03-19 23:44 ` [igt-dev] [PATCH v13 3/9] lib: move gem_context_has_engine from ioctl_wrappers to gem_context Andi Shyti
2019-03-19 23:44 ` [igt-dev] [PATCH v13 4/9] include/drm-uapi: import i915_drm.h header file Andi Shyti
2019-03-19 23:44 ` [igt-dev] [PATCH v13 5/9] lib: igt_gt: use flags in intel_execution_engines2 Andi Shyti
2019-03-20 9:48 ` Tvrtko Ursulin
2019-03-19 23:44 ` [igt-dev] [PATCH v13 6/9] lib/i915: add gem_engine_topology library Andi Shyti
2019-03-20 9:47 ` Tvrtko Ursulin
2019-03-20 10:49 ` Andi Shyti
2019-03-20 11:10 ` Tvrtko Ursulin
2019-03-20 11:21 ` Andi Shyti
2019-03-20 9:56 ` Chris Wilson
2019-03-20 10:49 ` Andi Shyti
2019-03-20 10:59 ` Chris Wilson
2019-03-20 11:13 ` Andi Shyti [this message]
2019-03-20 11:18 ` Chris Wilson
2019-03-20 11:35 ` Andi Shyti
2019-03-19 23:44 ` [igt-dev] [PATCH v13 7/9] lib/igt_gt: use for_each_engine_class_instance to loop through active engines Andi Shyti
2019-03-20 10:04 ` Tvrtko Ursulin
2019-03-20 10:09 ` Chris Wilson
2019-03-20 10:33 ` Tvrtko Ursulin
2019-03-20 10:40 ` Chris Wilson
2019-03-19 23:44 ` [igt-dev] [PATCH v13 8/9] tests: perf_pmu: use the flag value embedded in intel_execution_engines2 Andi Shyti
2019-03-19 23:44 ` [igt-dev] [PATCH v13 9/9] tests: gem_exec_basic: add "exec-ctx" buffer execution demo test Andi Shyti
2019-03-20 0:13 ` [igt-dev] ✓ Fi.CI.BAT: success for new engine discovery interface Patchwork
2019-03-20 9:35 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
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=20190320111316.GB1276@intel.intel \
--to=andi.shyti@intel.com \
--cc=andi@etezian.org \
--cc=chris@chris-wilson.co.uk \
--cc=igt-dev@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