@@ -436,8 +436,6 @@ __create_context(struct drm_i915_private *i915)
436436 i915_gem_context_set_bannable (ctx );
437437 i915_gem_context_set_recoverable (ctx );
438438
439- ctx -> ring_size = 4 * PAGE_SIZE ;
440-
441439 for (i = 0 ; i < ARRAY_SIZE (ctx -> hang_timestamp ); i ++ )
442440 ctx -> hang_timestamp [i ] = jiffies - CONTEXT_FAST_HANG_JIFFIES ;
443441
@@ -448,22 +446,34 @@ __create_context(struct drm_i915_private *i915)
448446 return ERR_PTR (err );
449447}
450448
449+ static void
450+ context_apply_all (struct i915_gem_context * ctx ,
451+ void (* fn )(struct intel_context * ce , void * data ),
452+ void * data )
453+ {
454+ struct i915_gem_engines_iter it ;
455+ struct intel_context * ce ;
456+
457+ for_each_gem_engine (ce , i915_gem_context_lock_engines (ctx ), it )
458+ fn (ce , data );
459+ i915_gem_context_unlock_engines (ctx );
460+ }
461+
462+ static void __apply_ppgtt (struct intel_context * ce , void * vm )
463+ {
464+ i915_vm_put (ce -> vm );
465+ ce -> vm = i915_vm_get (vm );
466+ }
467+
451468static struct i915_address_space *
452469__set_ppgtt (struct i915_gem_context * ctx , struct i915_address_space * vm )
453470{
454471 struct i915_address_space * old = ctx -> vm ;
455- struct i915_gem_engines_iter it ;
456- struct intel_context * ce ;
457472
458473 GEM_BUG_ON (old && i915_vm_is_4lvl (vm ) != i915_vm_is_4lvl (old ));
459474
460475 ctx -> vm = i915_vm_get (vm );
461-
462- for_each_gem_engine (ce , i915_gem_context_lock_engines (ctx ), it ) {
463- i915_vm_put (ce -> vm );
464- ce -> vm = i915_vm_get (vm );
465- }
466- i915_gem_context_unlock_engines (ctx );
476+ context_apply_all (ctx , __apply_ppgtt , vm );
467477
468478 return old ;
469479}
@@ -560,7 +570,6 @@ i915_gem_context_create_kernel(struct drm_i915_private *i915, int prio)
560570
561571 i915_gem_context_clear_bannable (ctx );
562572 ctx -> sched .priority = I915_USER_PRIORITY (prio );
563- ctx -> ring_size = PAGE_SIZE ;
564573
565574 GEM_BUG_ON (!i915_gem_context_is_kernel (ctx ));
566575
@@ -1544,6 +1553,7 @@ set_engines(struct i915_gem_context *ctx,
15441553 for (n = 0 ; n < num_engines ; n ++ ) {
15451554 struct i915_engine_class_instance ci ;
15461555 struct intel_engine_cs * engine ;
1556+ struct intel_context * ce ;
15471557
15481558 if (copy_from_user (& ci , & user -> engines [n ], sizeof (ci ))) {
15491559 __free_engines (set .engines , n );
@@ -1566,11 +1576,13 @@ set_engines(struct i915_gem_context *ctx,
15661576 return - ENOENT ;
15671577 }
15681578
1569- set . engines -> engines [ n ] = intel_context_create (ctx , engine );
1570- if (! set . engines -> engines [ n ] ) {
1579+ ce = intel_context_create (ctx , engine );
1580+ if (IS_ERR ( ce ) ) {
15711581 __free_engines (set .engines , n );
1572- return - ENOMEM ;
1582+ return PTR_ERR ( ce ) ;
15731583 }
1584+
1585+ set .engines -> engines [n ] = ce ;
15741586 }
15751587 set .engines -> num_engines = num_engines ;
15761588
0 commit comments