Quoting Tvrtko Ursulin (2019-01-31 10:47:51) > From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> > > We want to allow userspace to reconfigure the subslice configuration on a > per context basis. > > This is required for the functional requirement of shutting down non-VME > enabled sub-slices on Gen11 parts. > > To do so, we expose a context parameter to allow adjustment of the RPCS > register stored within the context image (and currently not accessible via > LRI). > > If the context is adjusted before first use or whilst idle, the adjustment > is for "free"; otherwise if the context is active we queue a request to do > so (using the kernel context), following all other activity by that > context, which is also marked as barrier for all following submission > against the same context. > > Since the overhead of device re-configuration during context switching can > be significant, especially in multi-context workloads, we limit this new > uAPI to only support the Gen11 VME use case. In this use case either the > device is fully enabled, and exactly one slice and half of the subslices > are enabled. > > Example usage: > > struct drm_i915_gem_context_param_sseu sseu = { }; > struct drm_i915_gem_context_param arg = { > .param = I915_CONTEXT_PARAM_SSEU, > .ctx_id = gem_context_create(fd), > .size = sizeof(sseu), > .value = to_user_pointer(&sseu) > }; > > /* Query device defaults. */ > gem_context_get_param(fd, &arg); > > /* Set VME configuration on a 1x6x8 part. */ > sseu.slice_mask = 0x1; > sseu.subslice_mask = 0xe0; > gem_context_set_param(fd, &arg); > > v2: Fix offset of CTX_R_PWR_CLK_STATE in intel_lr_context_set_sseu() > (Lionel) > > v3: Add ability to program this per engine (Chris) > > v4: Move most get_sseu() into i915_gem_context.c (Lionel) > > v5: Validate sseu configuration against the device's capabilities (Lionel) > > v6: Change context powergating settings through MI_SDM on kernel context > (Chris) > > v7: Synchronize the requests following a powergating setting change using > a global dependency (Chris) > Iterate timelines through dev_priv.gt.active_rings (Tvrtko) > Disable RPCS configuration setting for non capable users > (Lionel/Tvrtko) > > v8: s/union intel_sseu/struct intel_sseu/ (Lionel) > s/dev_priv/i915/ (Tvrtko) > Change uapi class/instance fields to u16 (Tvrtko) > Bump mask fields to 64bits (Lionel) > Don't return EPERM when dynamic sseu is disabled (Tvrtko) > > v9: Import context image into kernel context's ppgtt only when > reconfiguring powergated slice/subslices (Chris) > Use aliasing ppgtt when needed (Michel) > > Tvrtko Ursulin: > > v10: > * Update for upstream changes. > * Request submit needs a RPM reference. > * Reject on !FULL_PPGTT for simplicity. > * Pull out get/set param to helpers for readability and less indent. > * Use i915_request_await_dma_fence in add_global_barrier to skip waits > on the same timeline and avoid GEM_BUG_ON. > * No need to explicitly assign a NULL pointer to engine in legacy mode. > * No need to move gen8_make_rpcs up. > * Factored out global barrier as prep patch. > * Allow to only CAP_SYS_ADMIN if !Gen11. > > v11: > * Remove engine vfunc in favour of local helper. (Chris Wilson) > * Stop retiring requests before updates since it is not needed > (Chris Wilson) > * Implement direct CPU update path for idle contexts. (Chris Wilson) > * Left side dependency needs only be on the same context timeline. > (Chris Wilson) > * It is sufficient to order the timeline. (Chris Wilson) > * Reject !RCS configuration attempts with -ENODEV for now. > > v12: > * Rebase for make_rpcs. > > v13: > * Centralize SSEU normalization to make_rpcs. > * Type width checking (uAPI <-> implementation). > * Gen11 restrictions uAPI checks. > * Gen11 subslice count differences handling. > Chris Wilson: > * args->size handling fixes. > * Update context image from GGTT. > * Postpone context image update to pinning. > * Use i915_gem_active_raw instead of last_request_on_engine. > > v14: > * Add activity tracker on intel_context to fix the lifetime issues > and simplify the code. (Chris Wilson) > > v15: > * Fix context pin leak if no space in ring by simplifying the > context pinning sequence. > > v16: > * Rebase for context get/set param locking changes. > * Just -ENODEV on !Gen11. (Joonas) > > v17: > * Fix one Gen11 subslice enablement rule. > * Handle error from i915_sw_fence_await_sw_fence_gfp. (Chris Wilson) > > v18: > * Update commit message. (Joonas) > * Restrict uAPI to VME use case. (Joonas) > > v19: > * Rebase. > > v20: > * Rebase for ce->active_tracker. > > v21: > * Rebase for IS_GEN changes. > > v22: > * Reserve uAPI for flags straight away. (Chris Wilson) > > v23: > * Rebase for RUNTIME_INFO. > > v24: > * Added some headline docs for the uapi usage. (Joonas/Chris) > > v25: > * Renamed class/instance to engine_class/engine_instance to avoid clash > with C++ keyword. (Tony Ye) > > v26: > * Rebased for runtime pm api changes. > > v27: > * Rebased for intel_context_init. > * Wrap commit msg to 75. > > v28: > (Chris Wilson) > * Use i915_gem_ggtt. > * Use i915_request_await_dma_fence to show a better example. > > v29: > * i915_timeline_set_barrier can now fail. (Chris Wilson) > > v30: > * Capture some acks. > > v31: > * Drop the WARN_ON from use controllable paths. (Chris Wilson) > * Use overflows_type for all checks. > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100899 > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107634 > Issue: https://github.com/intel/media-driver/issues/267 > Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> > Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@xxxxxxxxx> > Cc: Dmitry Rogozhkin <dmitry.v.rogozhkin@xxxxxxxxx> > Cc: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> > Cc: Zhipeng Gong <zhipeng.gong@xxxxxxxxx> > Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx> > Cc: Tony Ye <tony.ye@xxxxxxxxx> > Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> > Reviewed-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> # v21 > Reviewed-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx> # v27 > Acked-by: Timo Aaltonen <timo.aaltonen@xxxxxxxxxxxxx> > Acked-by: Takashi Iwai <tiwai@xxxxxxx> Reviewed-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> > +static int get_sseu(struct i915_gem_context *ctx, > + struct drm_i915_gem_context_param *args) > +{ > + struct drm_i915_gem_context_param_sseu user_sseu; > + struct intel_engine_cs *engine; > + struct intel_context *ce; > + int ret; > + > + if (args->size == 0) > + goto out; > + else if (args->size < sizeof(user_sseu)) > + return -EINVAL; > + > + if (copy_from_user(&user_sseu, u64_to_user_ptr(args->value), > + sizeof(user_sseu))) > + return -EFAULT; > + > + if (user_sseu.flags || user_sseu.rsvd) > + return -EINVAL; > + > + engine = intel_engine_lookup_user(ctx->i915, > + user_sseu.engine_class, > + user_sseu.engine_instance); > + if (!engine) > + return -EINVAL; > + > + /* Only use for mutex here is to serialize get_param and set_param. */ > + ret = mutex_lock_interruptible(&ctx->i915->drm.struct_mutex); > + if (ret) > + return ret; > + > + ce = to_intel_context(ctx, engine); Reminder to check that this keeps working with veng. > + user_sseu.slice_mask = ce->sseu.slice_mask; > + user_sseu.subslice_mask = ce->sseu.subslice_mask; > + user_sseu.min_eus_per_subslice = ce->sseu.min_eus_per_subslice; > + user_sseu.max_eus_per_subslice = ce->sseu.max_eus_per_subslice; > + > + mutex_unlock(&ctx->i915->drm.struct_mutex); > + > + if (copy_to_user(u64_to_user_ptr(args->value), &user_sseu, > + sizeof(user_sseu))) > + return -EFAULT; > + > +out: > + args->size = sizeof(user_sseu); > + > + return 0; > +} _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx