From: Andi Shyti via igt-dev <igt-dev@lists.freedesktop.org>
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] [RFC PATCH v9 2/5] lib/i915: add gem_query library
Date: Thu, 14 Feb 2019 15:02:58 +0200 [thread overview]
Message-ID: <20190214130258.GB990@intel.intel> (raw)
In-Reply-To: <155013737042.14276.16193705802949147203@skylake-alporthouse-com>
Hi Chris,
> > +/*
> > + * HACK: the '2 * sizeof(__u16)' is the size required for the flexible array
> > + * inside 'struct i915_context_param_engines' that doesn't have a name and
> > + * therefore cannot be referenced. It needs a name in the uapi.
> > + */
>
> It's not going to get one until you raise the point in review of the
> uAPI. It doesn't though, you can use sizeof on the unnamed member.
>
> > +#define SIZEOF_CTX_PARAM sizeof(struct i915_context_param_engines) + \
> > + I915_EXEC_RING_MASK * \
> > + 2 * sizeof(__u16)
>
> For example:
>
> SIZEOF_CTX_PARAM offsetofend(struct i915_context_param_engines,
> class_instance[I915_EXEC_RING_MASK + 1])
>
> To make it generic though, it needs __attribute__((packed))
yeah! makes sense.
> (If the maximum index is I915_EXEC_RING_MASK, we need
> I915_EXEC_RING_MASK + 1 storage.)
Yes, I didn't add the '+ 1' because in the driver you do:
if (set.nengine == 0 || set.nengine > I915_EXEC_RING_MASK)
return -EINVAL;
> > +#define SIZEOF_QUERY sizeof(struct drm_i915_query_engine_info) + \
> > + I915_EXEC_RING_MASK * \
> > + sizeof(struct drm_i915_engine_info)
> > +
> > +struct intel_execution_engine2 *intel_active_engines2;
> > +
> > +static int __gem_query(int fd, struct drm_i915_query *q)
> > +{
> > + int err = 0;
> > +
> > + if(igt_ioctl(fd, DRM_IOCTL_I915_QUERY, q))
> ^ kernel coding style applies (missed space)
yes :) I didn't notice, it should be some late night coding
leftover, we should add checkpatch.
> > +bool gem_can_query(void)
>
> Still nothing to do with query per-se...
>
> gem_has_engine_topology() ?
OK, sure.
> > +void __set_ctx_engine_map(int fd, uint32_t ctx_id)
>
> We've drifted out of the domain of i915/gem_query.c into
> i915/gem_engine.c You could even argue we want to keep gem_engine.c for
> lower level interactions, and say gem_engine_topology.c for the details of
> the layout. Hmm, I like?
OK, I can add a new API
> > +{
> > + int i;
>
> Kernel coding style is to order variable lines by length, longest first;
> unless there is a clear reason why not to.
It's a community based preference, each maintainer has his own
opinion on variable ordering. I just place it in the order that
they come to my mind, until the maintainer dictates the rule.
> > + __u8 ctx_param_buffer[SIZEOF_CTX_PARAM] = { };
>
> s/__u8/uint8_t/
>
> It just a boring stack buf, so call it buf.
OK.
> > + ctx_param.ctx_id = ctx_id;
> > + ctx_param.param = I915_CONTEXT_PARAM_ENGINES;
> > + ctx_param.size = SIZEOF_CTX_PARAM;
>
> Not quite; size is used to determine the number of engines, this makes a
> large array with upto 5 real engines followed by rcs0 repeated ~60
> times. Interesting ;)
yes, need to save the engine count somewhere. In a previous
series I was 'for(...);' but then removed it...
> > + ctx_engine->extensions = 0;
> > + for (i = 0, e2 = intel_active_engines2; e2->name; i++, e2++) {
>
> You should at least have an assert you don't overflow your assumptions.
yes, this happened quite many times last night while I was fixing
the code and i promised myself to add the assert, but eventually
I forgot.
> > + ctx_engine->class_instance[i].engine_class = e2->class;
> > + ctx_engine->class_instance[i].engine_instance = e2->instance;
> > + }
>
> > + ctx_param.value = to_user_pointer(ctx_engine);
> ctx_param.size = offsetof(typeof(*ctx_engine), class_instance[i]);
>
> * quickly adds the packed attribute
... neat!
> > + ret = __gem_context_get_param(fd, &ctx_param);
> > + if (ret) {
> > + if (ret == -EINVAL) {
>
> Just
>
> if (__gem_context_get_param()) {
> intel_active_engines2 = intel_execution_engines2;
> return -ENODEV;
> }
>
> This be library code, so you define the interface; as opposed to test
> code where we demand certain responses from the kernel.
we don't need other -errnos? OK!
> > + for (i = 0; i < query_engine->num_engines; i++) {
> > + char *name;
> > + int class = query_engine->engines[i].class;
> > + int instance = query_engine->engines[i].instance;
> > +
> > + igt_assert(class < ARRAY_SIZE(class_names) && class >= 0);
> > + igt_assert(class_names[class]);
>
> Be future proof;
>
> if ((unsigned)class >= ARRAY_SIZE() || !class_names[class])
> tmpl = "xxx"; // or "unk" I think I've seen Tvrtko use
> else
> tmpl = class_names[class];
>
> Bonus points to include class-id in tmpl in case there's more than one!
OK.
> > + intel_active_engines2[i].class = class;
> > + intel_active_engines2[i].instance = instance;
> > +
> > + igt_assert(asprintf(&name, "%s%d",
> > + class_names[class], instance) > 0);
> > + intel_active_engines2[i].name = name;
> > + }
> > +
> > + /* '0' value sentinel */
> Which bit?
> class_instance = (0, 0) is valid (rcs0)
>
> /* Use .name=NULL as a sentinel */
Sure.
> > +#ifndef GEM_QUERY_H
> > +#define GEM_QUERY_H
> > +
> > +#include "igt_gt.h"
>
> For intel_execution_engine2?
>
> Just a forward decl will do.
>
> > +void __set_ctx_engine_map(int fd, uint32_t ctx_id);
>
> One day you'll find a more fitting name. Hint, this isn't part of the
> "set" infrastructure.
>
> > +bool gem_can_query(void);
> > +void gem_query(int fd, struct drm_i915_query *q);
> > +
> > +void igt_require_gem_engine_list(int fd);
> > +
> > +extern struct intel_execution_engine2 *intel_active_engines2;
>
> But I'm voting this extern should be in gem_engine_topology.[ch]
OK, I will add the gem_engine_topology.[ch]
Thanks,
Andi
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-02-14 13:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-14 0:44 [igt-dev] [RFC PATCH v9 0/5] new engine discovery interface Andi Shyti via igt-dev
2019-02-14 0:44 ` [igt-dev] [RFC PATCH v9 1/5] include/drm-uapi: import i915_drm.h header file Andi Shyti via igt-dev
2019-02-14 0:44 ` [igt-dev] [RFC PATCH v9 2/5] lib/i915: add gem_query library Andi Shyti via igt-dev
2019-02-14 9:42 ` Chris Wilson
2019-02-14 13:02 ` Andi Shyti via igt-dev [this message]
2019-02-14 13:08 ` Chris Wilson
2019-02-15 9:59 ` Petri Latvala via igt-dev
2019-02-15 15:09 ` Chris Wilson
2019-02-14 0:44 ` [igt-dev] [RFC PATCH v9 3/5] lib/igt_gt: use for_each_engine2 to loop through engines Andi Shyti via igt-dev
2019-02-14 9:49 ` Chris Wilson
2019-02-14 0:44 ` [igt-dev] [RFC PATCH v9 4/5] lib: ioctl_wrappers: reach engines by index as well Andi Shyti via igt-dev
2019-02-14 9:52 ` Chris Wilson
2019-02-14 13:06 ` Andi Shyti via igt-dev
2019-02-14 0:44 ` [igt-dev] [RFC PATCH v9 5/5] tests: gem_exec_basic: add "exec-ctx" buffer execution demo test Andi Shyti via igt-dev
2019-02-14 9:56 ` Chris Wilson
2019-02-14 10:14 ` [igt-dev] ✗ Fi.CI.BAT: failure for new engine discovery interface 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=20190214130258.GB990@intel.intel \
--to=igt-dev@lists.freedesktop.org \
--cc=andi.shyti@intel.com \
--cc=andi@etezian.org \
--cc=chris@chris-wilson.co.uk \
/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