@@ -68,7 +68,7 @@ int __intel_context_do_pin(struct intel_context *ce)
6868 goto err ;
6969
7070 GEM_TRACE ("%s context:%llx pin ring:{head:%04x, tail:%04x}\n" ,
71- ce -> engine -> name , ce -> ring -> timeline -> fence_context ,
71+ ce -> engine -> name , ce -> timeline -> fence_context ,
7272 ce -> ring -> head , ce -> ring -> tail );
7373
7474 i915_gem_context_get (ce -> gem_context ); /* for ctx->ppgtt */
@@ -98,7 +98,7 @@ void intel_context_unpin(struct intel_context *ce)
9898
9999 if (likely (atomic_dec_and_test (& ce -> pin_count ))) {
100100 GEM_TRACE ("%s context:%llx retire\n" ,
101- ce -> engine -> name , ce -> ring -> timeline -> fence_context );
101+ ce -> engine -> name , ce -> timeline -> fence_context );
102102
103103 ce -> ops -> unpin (ce );
104104
@@ -143,11 +143,12 @@ static void __intel_context_retire(struct i915_active *active)
143143 struct intel_context * ce = container_of (active , typeof (* ce ), active );
144144
145145 GEM_TRACE ("%s context:%llx retire\n" ,
146- ce -> engine -> name , ce -> ring -> timeline -> fence_context );
146+ ce -> engine -> name , ce -> timeline -> fence_context );
147147
148148 if (ce -> state )
149149 __context_unpin_state (ce -> state );
150150
151+ intel_timeline_unpin (ce -> timeline );
151152 intel_ring_unpin (ce -> ring );
152153 intel_context_put (ce );
153154}
@@ -163,15 +164,21 @@ static int __intel_context_active(struct i915_active *active)
163164 if (err )
164165 goto err_put ;
165166
167+ err = intel_timeline_pin (ce -> timeline );
168+ if (err )
169+ goto err_ring ;
170+
166171 if (!ce -> state )
167172 return 0 ;
168173
169174 err = __context_pin_state (ce -> state );
170175 if (err )
171- goto err_ring ;
176+ goto err_timeline ;
172177
173178 return 0 ;
174179
180+ err_timeline :
181+ intel_timeline_unpin (ce -> timeline );
175182err_ring :
176183 intel_ring_unpin (ce -> ring );
177184err_put :
@@ -218,6 +225,8 @@ intel_context_init(struct intel_context *ce,
218225
219226 ce -> gem_context = ctx ;
220227 ce -> vm = i915_vm_get (ctx -> vm ?: & engine -> gt -> ggtt -> vm );
228+ if (ctx -> timeline )
229+ ce -> timeline = intel_timeline_get (ctx -> timeline );
221230
222231 ce -> engine = engine ;
223232 ce -> ops = engine -> cops ;
@@ -235,6 +244,8 @@ intel_context_init(struct intel_context *ce,
235244
236245void intel_context_fini (struct intel_context * ce )
237246{
247+ if (ce -> timeline )
248+ intel_timeline_put (ce -> timeline );
238249 i915_vm_put (ce -> vm );
239250
240251 mutex_destroy (& ce -> pin_mutex );
@@ -279,7 +290,7 @@ void intel_context_exit_engine(struct intel_context *ce)
279290int intel_context_prepare_remote_request (struct intel_context * ce ,
280291 struct i915_request * rq )
281292{
282- struct intel_timeline * tl = ce -> ring -> timeline ;
293+ struct intel_timeline * tl = ce -> timeline ;
283294 int err ;
284295
285296 /* Only suitable for use in remotely modifying this context */
0 commit comments