STRUCT I915_GEM_PROTO_CONTEXT(9)
β¨ struct i915_gem_proto_context(9) β¨
okay so welcome to the Kernel API Manual, bestie β this is the entry for struct i915_gem_proto_context, and it is literally the βprototype contextβ era of an i915 context before the real one gets born. π«Ά
π NAME π
struct i915_gem_proto_context β prototype context.
β¨ SYNOPSIS β¨
struct i915_gem_proto_context {
struct drm_i915_file_private *fpriv;
struct i915_address_space *vm;
unsigned long user_flags;
struct i915_sched_attr sched;
int num_user_engines;
struct i915_gem_proto_engine *user_engines;
struct intel_sseu legacy_rcs_sseu;
bool single_timeline;
bool uses_protected_content;
intel_wakeref_t pxp_wakeref;
};
π Members π
fprivβ the client which creates the context.vmβ seei915_gem_context.vm.user_flagsβ seei915_gem_context.user_flags.schedβ seei915_gem_context.sched.num_user_enginesβ number of user-specified engines or-1.user_enginesβ user-specified engines.legacy_rcs_sseuβ client-set SSEU parameters for the legacy RCS.single_timelineβ See Seei915_gem_context.syncobj(the double βSeeβ is literally in the original, no cap π).uses_protected_contentβ seei915_gem_context.uses_protected_content.pxp_wakerefβ seei915_gem_context.pxp_wakeref.
π Description π
Okay so struct i915_gem_proto_context represents the creation parameters for a struct i915_gem_context. Itβs the little gather-everything-first spot for params that come in either through creation flags or via SET_CONTEXT_PARAM, so that when the final i915_gem_context gets created, those parameters can be immutable. Iconic, honestly. π₯
The context uAPI allows for two methods of setting context parameters: SET_CONTEXT_PARAM and CONTEXT_CREATE_EXT_SETPARAM. The former is allowed to be called at any time, while the latter happens as part of GEM_CONTEXT_CREATE. Back when these were initially added β and currently too β everything settable via one is settable via the other. Some params are fairly simple and setting them on a live context is harmless, such as the context priority. Others are far trickier, such as the VM or the set of engines. To avoid some truly nasty race conditions, we donβt allow setting the VM or the set of engines on live contexts. π«
The way we dealt with this without breaking older userspace that sets the VM or engine set via SET_CONTEXT_PARAM is to delay the creation of the actual context until after the client is done configuring it with SET_CONTEXT_PARAM. From the perspective of the client, it has the same u32 context ID the whole time. From the perspective of i915, however, itβs an i915_gem_proto_context right up until the point where we attempt to do something which the proto-context canβt handle β at which point the real context gets created. β¨
This is accomplished via a little xarray dance. π©° When GEM_CONTEXT_CREATE is called, we create a proto-context, reserve a slot in context_xa but leave it NULL, and put the proto-context in the corresponding slot in proto_context_xa. Then, whenever we go to look up a context, we first check context_xa. If itβs there, we return the i915_gem_context and weβre done. If itβs not, we look in proto_context_xa and, if we find it there, we create the actual context and kill the proto-context. π
At the time we made this change (April, 2021), we did a fairly complete audit of existing userspace to ensure this wouldnβt break anything:
- Mesa/i965 didnβt use the engines or VM APIs at all.
- Mesa/ANV used the engines API but via
CONTEXT_CREATE_EXT_SETPARAMand didnβt use the VM API. - Mesa/iris didnβt use the engines or VM APIs at all.
- The open-source compute-runtime didnβt yet use the engines API but did use the VM API via
SET_CONTEXT_PARAM. However,CONTEXT_SETPARAMwas always the second ioctl on that context, immediately followingGEM_CONTEXT_CREATE. - The media driver sets engines and bonding/balancing via
SET_CONTEXT_PARAM. However,CONTEXT_SETPARAMto set the VM was always the second ioctl on that context, immediately followingGEM_CONTEXT_CREATEand setting engines immediately followed that.
In order for this dance to work properly, any modification to an i915_gem_proto_context that is exposed to the client via drm_i915_file_private::proto_context_xa must be guarded by drm_i915_file_private::proto_context_lock. The exception is when a proto-context has not yet been exposed, such as when handling CONTEXT_CREATE_SET_PARAM during GEM_CONTEXT_CREATE. π
π SEE ALSO π
Kernel file ./drivers/gpu/drm/i915/gem/i915_gem_context_types.h struct i915_gem_engines(9), struct i915_gem_engines_iter(9), enum i915_gem_engine_type(9), struct i915_gem_proto_engine(9), struct i915_gem_context(9).
okay bestie, thatβs the whole page! this came from the source/version path ./drivers/gpu/drm/i915/gem, and the date on it is October 2026 β go off, calendar. ποΈπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms