drm/i915: Select engines via class and instance in execbuffer2
Subsystems (3)
Tvrtko Ursulin
maintainerRFC 1/2 drm/i915: Select engines via class and instance in execbuffer2
From: Tvrtko Ursulin <[email protected]>
Building on top of the previous patch which exported the concept of engine classes and instances, we can also use this instead of the current awkward engine selection uAPI.
This is primarily interesting for the VCS engine selection which is a) currently done via disjoint set of flags, and b) the current I915_EXEC_BSD flags has different semantics depending on the underlying hardware which is bad.
Proposed idea here is to reserve 8-bits of flags, to pass in the engine instance, re-use the existing engine selection bits for the class selection, and a new flag named I915_EXEC_CLASS_INSTANCE to tell the kernel this new engine selection API is in use.
The new uAPI also removes access to the weak VCS engine balancing as currently existing in the driver.
Example usage to send a command to VCS0:
eb.flags = i915_execbuffer2_engine(I915_ENGINE_CLASS_VIDEO_DECODE, 0);
Or to send a command to VCS1:
eb.flags = i915_execbuffer2_engine(I915_ENGINE_CLASS_VIDEO_DECODE, 1);
v2:
* Fix unknown flags mask.
* Use I915_EXEC_RING_MASK for class. (Chris Wilson)
v3:
* Add a map for fast class-instance engine lookup. (Chris Wilson)
v4:
* Update commit to reflect v3.
* Export intel_engine_lookup for other users. (Chris Wilson)
* Split out some warns. (Chris Wilson)
v5:
* Fixed shift and mask logic.
* Rebased to be standalone.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gem_execbuffer.c | 27 +++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_reg.h | 3 +++ drivers/gpu/drm/i915/intel_engine_cs.c | 20 ++++++++++++++++++++ drivers/gpu/drm/i915/intel_ringbuffer.h | 3 +++ include/uapi/drm/i915_drm.h | 22 +++++++++++++++++++++- 6 files changed, 75 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -2137,6 +2137,7 @@ struct drm_i915_private {struct pci_dev *bridge_dev;struct i915_gem_context *kernel_context;struct intel_engine_cs *engine[I915_NUM_ENGINES ]; +struct intel_engine_cs *engine_class[MAX_ENGINE_CLASS +1 ][MAX_ENGINE_INSTANCE +1 ];struct i915_vma *semaphore;struct drm_dma_handle *status_page_dmah;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +27 -0
@@ -2049,6 +2049,30 @@ gen8_dispatch_bsd_engine(struct drm_i915_private *dev_priv,return file_priv->bsd_engine; } +static u8 user_class_map[I915_ENGINE_CLASS_MAX ] = { + [I915_ENGINE_CLASS_OTHER ] =OTHER_CLASS , + [I915_ENGINE_CLASS_RENDER ] =RENDER_CLASS , + [I915_ENGINE_CLASS_COPY ] =COPY_ENGINE_CLASS , + [I915_ENGINE_CLASS_VIDEO ] =VIDEO_DECODE_CLASS , + [I915_ENGINE_CLASS_VIDEO_ENHANCE ] =VIDEO_ENHANCEMENT_CLASS , +}; + +static struct intel_engine_cs * +eb_select_engine_class_instance (struct drm_i915_private *i915, +struct drm_i915_gem_execbuffer2 *args) +{ +u8 class = args->flags &I915_EXEC_RING_MASK ; +u8 instance; + +if (class >=ARRAY_SIZE (user_class_map)) +return NULL ; + + instance = (args->flags &I915_EXEC_INSTANCE_MASK ) >> +I915_EXEC_INSTANCE_SHIFT ; + +return intel_engine_lookup (i915, user_class_map[class], instance); +} +#define I915_USER_RINGS (4)static const enum intel_engine_id user_ring_map[I915_USER_RINGS +1 ] = {
@@ -2067,6 +2091,9 @@ eb_select_engine(struct drm_i915_private *dev_priv,unsigned int user_ring_id = args->flags &I915_EXEC_RING_MASK ;struct intel_engine_cs *engine; +if (args->flags &I915_EXEC_CLASS_INSTANCE ) +return eb_select_engine_class_instance (dev_priv, args); +if (user_ring_id >I915_USER_RINGS ) {DRM_DEBUG ("execbuf with unknown ring: %u\n" , user_ring_id);return NULL ;
drivers/gpu/drm/i915/i915_reg.h +3 -0
@@ -95,6 +95,9 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)#define VIDEO_ENHANCEMENT_CLASS 2#define COPY_ENGINE_CLASS 3#define OTHER_CLASS 4 +#define MAX_ENGINE_CLASS 4 + +#define MAX_ENGINE_INSTANCE 1/* PCI config space */
drivers/gpu/drm/i915/intel_engine_cs.c +20 -0
@@ -197,6 +197,15 @@ intel_engine_setup(struct drm_i915_private *dev_priv,GEM_BUG_ON (info->class >=ARRAY_SIZE (intel_engine_classes)); class_info = &intel_engine_classes[info->class]; +if (GEM_WARN_ON (info->class >MAX_ENGINE_CLASS )) +return -EINVAL ; + +if (GEM_WARN_ON (info->instance >MAX_ENGINE_INSTANCE )) +return -EINVAL ; + +if (GEM_WARN_ON (dev_priv->engine_class[info->class][info->instance])) +return -EINVAL ; +GEM_BUG_ON (dev_priv->engine[id]); engine =kzalloc (sizeof (*engine),GFP_KERNEL );if (!engine)
@@ -224,7 +233,9 @@ intel_engine_setup(struct drm_i915_private *dev_priv,ATOMIC_INIT_NOTIFIER_HEAD (&engine->context_status_notifier); + dev_priv->engine_class[info->class][info->instance] = engine; dev_priv->engine[id] = engine; +return 0 ; }
@@ -1332,6 +1343,15 @@ void intel_engines_mark_idle(struct drm_i915_private *i915) } } +struct intel_engine_cs * +intel_engine_lookup (struct drm_i915_private *i915,u8 class,u8 instance) +{ +if (class >MAX_ENGINE_CLASS || instance >MAX_ENGINE_INSTANCE ) +return NULL ; + +return i915->engine_class[class][instance]; +} +#if IS_ENABLED (CONFIG_DRM_I915_SELFTEST )#include "selftests/mock_engine.c" #endif
drivers/gpu/drm/i915/intel_ringbuffer.h +3 -0
@@ -735,4 +735,7 @@ bool intel_engines_are_idle(struct drm_i915_private *dev_priv);void intel_engines_mark_idle (struct drm_i915_private *i915);void intel_engines_reset_default_submission (struct drm_i915_private *i915); +struct intel_engine_cs * +intel_engine_lookup (struct drm_i915_private *i915,u8 class,u8 instance); +#endif /* _INTEL_RINGBUFFER_H_ */
include/uapi/drm/i915_drm.h +21 -1
@@ -927,7 +927,13 @@ struct drm_i915_gem_execbuffer2 {* element). */ #define I915_EXEC_BATCH_FIRST (1<<18) -#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_BATCH_FIRST<<1)) + +#define I915_EXEC_CLASS_INSTANCE (1<<19) + +#define I915_EXEC_INSTANCE_SHIFT (20) +#define I915_EXEC_INSTANCE_MASK (0xff << I915_EXEC_INSTANCE_SHIFT) + +#define __I915_EXEC_UNKNOWN_FLAGS (-((1 << 27) << 1))#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)#define i915_execbuffer2_set_context_id (eb2, context) \
@@ -935,6 +941,20 @@ struct drm_i915_gem_execbuffer2 {#define i915_execbuffer2_get_context_id (eb2) \ ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK) +enum drm_i915_gem_engine_class { +I915_ENGINE_CLASS_OTHER =0 , +I915_ENGINE_CLASS_RENDER =1 , +I915_ENGINE_CLASS_COPY =2 , +I915_ENGINE_CLASS_VIDEO =3 , +I915_ENGINE_CLASS_VIDEO_ENHANCE =4 , +I915_ENGINE_CLASS_MAX /* non-ABI */ +}; + +#define i915_execbuffer2_engine (class, instance) \ + (I915_EXEC_CLASS_INSTANCE | \ + (class) | \ + ((instance) << I915_EXEC_INSTANCE_SHIFT)) +struct drm_i915_gem_pin {/** Handle of the buffer to be pinned. */ __u32 handle;
Signature · 6 lines
2.9.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Tvrtko Ursulin
maintainerRFC 2/2 drm/i915: Engine capabilities uAPI
From: Tvrtko Ursulin <[email protected]>
This is a lighter-weight alternative to the previously posted RFC titled "drm/i915: Engine discovery uAPI" which still allows some engine configuration probing without depending on PCI ids.
--
Floating as an alternative to the heavier engine discovery API sent previously which did not manage to gain much interest from userspace clients.
With this one enumeration and feature discovery would be done by sending null batches to all engine instances. Downside is less extensibility if we are using a fixed and smaller number of eb flags.
--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 10 +++++++++- drivers/gpu/drm/i915/intel_engine_cs.c | 3 +++ drivers/gpu/drm/i915/intel_ringbuffer.h | 2 ++ include/uapi/drm/i915_drm.h | 17 ++++++++++++++++- 4 files changed, 30 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +9 -1
@@ -2062,6 +2062,9 @@ eb_select_engine_class_instance(struct drm_i915_private *i915, struct drm_i915_gem_execbuffer2 *args) {u8 class = args->flags &I915_EXEC_RING_MASK ; +u8 caps = (args->flags &I915_EXEC_ENGINE_CAP_MASK ) >> +I915_EXEC_ENGINE_CAP_SHIFT ; +struct intel_engine_cs *engine;u8 instance;if (class >=ARRAY_SIZE (user_class_map))
@@ -2070,7 +2073,12 @@ eb_select_engine_class_instance(struct drm_i915_private *i915, instance = (args->flags &I915_EXEC_INSTANCE_MASK ) >>I915_EXEC_INSTANCE_SHIFT ; -return intel_engine_lookup (i915, user_class_map[class], instance); + engine =intel_engine_lookup (i915, user_class_map[class], instance); + +if (!engine || ((caps & engine->caps) != caps)) +return NULL ; + +return engine; }#define I915_USER_RINGS (4)
drivers/gpu/drm/i915/intel_engine_cs.c +3 -0
@@ -222,6 +222,9 @@ intel_engine_setup(struct drm_i915_private *dev_priv, engine->irq_shift = info->irq_shift; engine->class = info->class; engine->instance = info->instance; +if (INTEL_GEN (dev_priv) >=8 && engine->class ==VIDEO_DECODE_CLASS && + engine->instance ==0 ) + engine->caps =I915_BSD_CAP_HEVC ; engine->context_size =__intel_engine_context_size (dev_priv, engine->class);
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -0
@@ -196,6 +196,8 @@ struct intel_engine_cs {u8 class;u8 instance; +u8 caps; +u32 context_size;u32 mmio_base;unsigned int irq_shift;
include/uapi/drm/i915_drm.h +16 -1
@@ -933,7 +933,18 @@ struct drm_i915_gem_execbuffer2 {#define I915_EXEC_INSTANCE_SHIFT (20)#define I915_EXEC_INSTANCE_MASK (0xff << I915_EXEC_INSTANCE_SHIFT) -#define __I915_EXEC_UNKNOWN_FLAGS (-((1 << 27) << 1)) +/* +* Inform the kernel of what engine capabilities this batch buffer +* requires. For example only the first VCS engine has the HEVC block. +* +* We reserve four bits for the capabilities where each can be shared +* between different engines. Eg. first bit can mean one feature for +* one engine and something else for the other. +*/ +#define I915_EXEC_ENGINE_CAP_SHIFT (28) +#define I915_EXEC_ENGINE_CAP_MASK (0xf << I915_EXEC_ENGINE_CAP_SHIFT) + +#define __I915_EXEC_UNKNOWN_FLAGS (-((1 << 31) << 1))#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)#define i915_execbuffer2_set_context_id (eb2, context) \
@@ -941,6 +952,10 @@ struct drm_i915_gem_execbuffer2 {#define i915_execbuffer2_get_context_id (eb2) \ ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK) +#define I915_BSD_CAP_HEVC (1 << 0) + +#define I915_ENGINE_CAP_FLAG (v) ((v) << I915_EXEC_ENGINE_CAP_SHIFT) +enum drm_i915_gem_engine_class {I915_ENGINE_CLASS_OTHER =0 ,I915_ENGINE_CLASS_RENDER =1 ,
Signature · 6 lines
2.9.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFC 2/2] drm/i915: Engine capabilities uAPI
Quoting Tvrtko Ursulin (2017-06-21 10:13:57)
Quoted 21 lines
From: Tvrtko Ursulin <[email protected]>
This is a lighter-weight alternative to the previously posted RFC titled "drm/i915: Engine discovery uAPI" which still allows some engine configuration probing without depending on PCI ids.
Signed-off-by Tvrtko Ursulin <[email protected]>Cc Ben Widawsky <[email protected]>Cc Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Jon Bloomfield <[email protected]>Cc "Rogozhkin, Dmitry V" <[email protected]>Cc Oscar Mateo <[email protected]>Cc "Gong, Zhipeng" <[email protected]>--
Floating as an alternative to the heavier engine discovery API sent previously which did not manage to gain much interest from userspace clients.
Quoted 4 lines
With this one enumeration and feature discovery would be done by sending null batches to all engine instances. Downside is less extensibility if we are using a fixed and smaller number of eb flags.
But we lose out on features? Just after you convinced me that features was what we wanted! :-p
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFC 2/2] drm/i915: Engine capabilities uAPI
Quoted 22 lines · Chris Wilson
Quoting Tvrtko Ursulin (2017-06-21 10:13:57)
Quoted 21 lines
From: Tvrtko Ursulin <[email protected]>
This is a lighter-weight alternative to the previously posted RFC titled "drm/i915: Engine discovery uAPI" which still allows some engine configuration probing without depending on PCI ids.
Signed-off-by Tvrtko Ursulin <[email protected]>Cc Ben Widawsky <[email protected]>Cc Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Jon Bloomfield <[email protected]>Cc "Rogozhkin, Dmitry V" <[email protected]>Cc Oscar Mateo <[email protected]>Cc "Gong, Zhipeng" <[email protected]>--
Floating as an alternative to the heavier engine discovery API sent previously which did not manage to gain much interest from userspace clients.
Quoted 7 lines
Quoted 4 lines
With this one enumeration and feature discovery would be done by sending null batches to all engine instances. Downside is less extensibility if we are using a fixed and smaller number of eb flags.
But we lose out on features? Just after you convinced me that features was what we wanted! :-p
We lose the features but get the capabilities :), if that was the joke!
Or a concern that we might really want more data about stuff when probing? We could still add that later if we wanted since it is really a different thing altogether.
This caps thing is actually 2nd part from another experiment I had, where the first part allowed userspace to tell us they do not care about the state, so we would be able to pick a VCS engine per-batch buffer, and not only statically per context.
Maybe I add that one to this series as well and then it all becomes even more useful?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [RFC 2/2] drm/i915: Engine capabilities uAPI
Quoting Tvrtko Ursulin (2017-06-23 12:58:19)
Quoted 38 lines · Chris Wilson
Quoted 22 lines
Quoting Tvrtko Ursulin (2017-06-21 10:13:57)
Quoted 21 lines
From: Tvrtko Ursulin <[email protected]>
This is a lighter-weight alternative to the previously posted RFC titled "drm/i915: Engine discovery uAPI" which still allows some engine configuration probing without depending on PCI ids.
Signed-off-by Tvrtko Ursulin <[email protected]>Cc Ben Widawsky <[email protected]>Cc Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Jon Bloomfield <[email protected]>Cc "Rogozhkin, Dmitry V" <[email protected]>Cc Oscar Mateo <[email protected]>Cc "Gong, Zhipeng" <[email protected]>--
Floating as an alternative to the heavier engine discovery API sent previously which did not manage to gain much interest from userspace clients.Quoted 7 lines
Quoted 4 lines
With this one enumeration and feature discovery would be done by sending null batches to all engine instances. Downside is less extensibility if we are using a fixed and smaller number of eb flags.
But we lose out on features? Just after you convinced me that features was what we wanted! :-p
We lose the features but get the capabilities :), if that was the joke!
Or a concern that we might really want more data about stuff when probing? We could still add that later if we wanted since it is really a different thing altogether.
Quoted 7 lines
This caps thing is actually 2nd part from another experiment I had, where the first part allowed userspace to tell us they do not care about the state, so we would be able to pick a VCS engine per-batch buffer, and not only statically per context.
Maybe I add that one to this series as well and then it all becomes even more useful?
My minimum requirement for testing execbuf is to be able to explicitly select an engine. So long as you do not exclude that possibility, I don't mind. I was also happy if that requires us to query the set of engines to figure out the mapping for the new interface.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [RFC,1/2] drm/i915: Select engines via class and instance in execbuffer2
In reply to Tvrtko Ursulin== Series Details ==
== Series Details ==
Series: series starting with [RFC,1/2] drm/i915: Select engines via class and instance in execbuffer2
URL : https://patchwork.freedesktop.org/series/26126/
State : success
== Summary ==
Series 26126v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/26126/revisions/1/mbox/
Test gem_exec_suspend:
Subgroup basic-s4-devices:
dmesg-warn -> PASS (fi-kbl-r) fdo#100125
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
pass -> DMESG-WARN (fi-byt-n2820) fdo#101516
Test prime_busy:
Subgroup basic-wait-after-default:
pass -> DMESG-WARN (fi-skl-6700hq) fdo#101515 +3fdo#100125 https://bugs.freedesktop.org/show_bug.cgi?id=100125
fdo#101516 https://bugs.freedesktop.org/show_bug.cgi?id=101516
fdo#101515 https://bugs.freedesktop.org/show_bug.cgi?id=101515
fi-bdw-5557u total:278 pass:267 dwarn:0 dfail:0 fail:0 skip:11 time:440s fi-bdw-gvtdvm total:278 pass:256 dwarn:8 dfail:0 fail:0 skip:14 time:427s fi-bsw-n3050 total:278 pass:241 dwarn:1 dfail:0 fail:0 skip:36 time:521s fi-bxt-j4205 total:278 pass:259 dwarn:0 dfail:0 fail:0 skip:19 time:508s fi-byt-j1900 total:278 pass:252 dwarn:2 dfail:0 fail:0 skip:24 time:489s fi-byt-n2820 total:278 pass:248 dwarn:2 dfail:0 fail:0 skip:28 time:478s fi-glk-2a total:278 pass:259 dwarn:0 dfail:0 fail:0 skip:19 time:589s fi-hsw-4770 total:278 pass:262 dwarn:0 dfail:0 fail:0 skip:16 time:437s fi-hsw-4770r total:278 pass:262 dwarn:0 dfail:0 fail:0 skip:16 time:414s fi-ilk-650 total:278 pass:228 dwarn:0 dfail:0 fail:0 skip:50 time:423s fi-ivb-3520m total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time:504s fi-ivb-3770 total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time:469s fi-kbl-7500u total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time:468s fi-kbl-7560u total:278 pass:268 dwarn:0 dfail:0 fail:0 skip:10 time:568s fi-kbl-r total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time:576s fi-skl-6260u total:278 pass:268 dwarn:0 dfail:0 fail:0 skip:10 time:458s fi-skl-6700hq total:278 pass:220 dwarn:3 dfail:0 fail:30 skip:24 time:337s fi-skl-6700k total:278 pass:256 dwarn:4 dfail:0 fail:0 skip:18 time:465s fi-skl-6770hq total:278 pass:268 dwarn:0 dfail:0 fail:0 skip:10 time:479s fi-skl-gvtdvm total:278 pass:265 dwarn:0 dfail:0 fail:0 skip:13 time:431s fi-snb-2520m total:278 pass:250 dwarn:0 dfail:0 fail:0 skip:28 time:538s fi-snb-2600 total:278 pass:248 dwarn:0 dfail:0 fail:1 skip:29 time:401s
bc07bd0717fe93acecc098863106b7e29fd84079 drm-tip: 2017y-06m-21d-09h-31m-50s UTC integration manifest 7882c7d drm/i915: Engine capabilities uAPI
6fdc1ca drm/i915: Select engines via class and instance in execbuffer2
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_5007/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx