1616
1717#include "gem/i915_gem_ioctls.h"
1818#include "gt/intel_context.h"
19+ #include "gt/intel_engine_pool.h"
1920#include "gt/intel_gt.h"
2021#include "gt/intel_gt_pm.h"
2122
@@ -1198,25 +1199,26 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
11981199 unsigned int len )
11991200{
12001201 struct reloc_cache * cache = & eb -> reloc_cache ;
1201- struct drm_i915_gem_object * obj ;
1202+ struct intel_engine_pool_node * pool ;
12021203 struct i915_request * rq ;
12031204 struct i915_vma * batch ;
12041205 u32 * cmd ;
12051206 int err ;
12061207
1207- obj = i915_gem_batch_pool_get (& eb -> engine -> batch_pool , PAGE_SIZE );
1208- if (IS_ERR (obj ))
1209- return PTR_ERR (obj );
1208+ pool = intel_engine_pool_get (& eb -> engine -> pool , PAGE_SIZE );
1209+ if (IS_ERR (pool ))
1210+ return PTR_ERR (pool );
12101211
1211- cmd = i915_gem_object_pin_map (obj ,
1212+ cmd = i915_gem_object_pin_map (pool -> obj ,
12121213 cache -> has_llc ?
12131214 I915_MAP_FORCE_WB :
12141215 I915_MAP_FORCE_WC );
1215- i915_gem_object_unpin_pages (obj );
1216- if (IS_ERR (cmd ))
1217- return PTR_ERR (cmd );
1216+ if (IS_ERR (cmd )) {
1217+ err = PTR_ERR (cmd );
1218+ goto out_pool ;
1219+ }
12181220
1219- batch = i915_vma_instance (obj , vma -> vm , NULL );
1221+ batch = i915_vma_instance (pool -> obj , vma -> vm , NULL );
12201222 if (IS_ERR (batch )) {
12211223 err = PTR_ERR (batch );
12221224 goto err_unmap ;
@@ -1232,6 +1234,10 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
12321234 goto err_unpin ;
12331235 }
12341236
1237+ err = intel_engine_pool_mark_active (pool , rq );
1238+ if (err )
1239+ goto err_request ;
1240+
12351241 err = reloc_move_to_gpu (rq , vma );
12361242 if (err )
12371243 goto err_request ;
@@ -1257,7 +1263,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
12571263 cache -> rq_size = 0 ;
12581264
12591265 /* Return with batch mapping (cmd) still pinned */
1260- return 0 ;
1266+ goto out_pool ;
12611267
12621268skip_request :
12631269 i915_request_skip (rq , err );
@@ -1266,7 +1272,9 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
12661272err_unpin :
12671273 i915_vma_unpin (batch );
12681274err_unmap :
1269- i915_gem_object_unpin_map (obj );
1275+ i915_gem_object_unpin_map (pool -> obj );
1276+ out_pool :
1277+ intel_engine_pool_put (pool );
12701278 return err ;
12711279}
12721280
@@ -2010,18 +2018,17 @@ static int i915_reset_gen7_sol_offsets(struct i915_request *rq)
20102018
20112019static struct i915_vma * eb_parse (struct i915_execbuffer * eb , bool is_master )
20122020{
2013- struct drm_i915_gem_object * shadow_batch_obj ;
2021+ struct intel_engine_pool_node * pool ;
20142022 struct i915_vma * vma ;
20152023 int err ;
20162024
2017- shadow_batch_obj = i915_gem_batch_pool_get (& eb -> engine -> batch_pool ,
2018- PAGE_ALIGN (eb -> batch_len ));
2019- if (IS_ERR (shadow_batch_obj ))
2020- return ERR_CAST (shadow_batch_obj );
2025+ pool = intel_engine_pool_get (& eb -> engine -> pool , eb -> batch_len );
2026+ if (IS_ERR (pool ))
2027+ return ERR_CAST (pool );
20212028
20222029 err = intel_engine_cmd_parser (eb -> engine ,
20232030 eb -> batch -> obj ,
2024- shadow_batch_obj ,
2031+ pool -> obj ,
20252032 eb -> batch_start_offset ,
20262033 eb -> batch_len ,
20272034 is_master );
@@ -2030,21 +2037,24 @@ static struct i915_vma *eb_parse(struct i915_execbuffer *eb, bool is_master)
20302037 vma = NULL ;
20312038 else
20322039 vma = ERR_PTR (err );
2033- goto out ;
2040+ goto err ;
20342041 }
20352042
2036- vma = i915_gem_object_ggtt_pin (shadow_batch_obj , NULL , 0 , 0 , 0 );
2043+ vma = i915_gem_object_ggtt_pin (pool -> obj , NULL , 0 , 0 , 0 );
20372044 if (IS_ERR (vma ))
2038- goto out ;
2045+ goto err ;
20392046
20402047 eb -> vma [eb -> buffer_count ] = i915_vma_get (vma );
20412048 eb -> flags [eb -> buffer_count ] =
20422049 __EXEC_OBJECT_HAS_PIN | __EXEC_OBJECT_HAS_REF ;
20432050 vma -> exec_flags = & eb -> flags [eb -> buffer_count ];
20442051 eb -> buffer_count ++ ;
20452052
2046- out :
2047- i915_gem_object_unpin_pages (shadow_batch_obj );
2053+ vma -> private = pool ;
2054+ return vma ;
2055+
2056+ err :
2057+ intel_engine_pool_put (pool );
20482058 return vma ;
20492059}
20502060
@@ -2588,6 +2598,8 @@ i915_gem_do_execbuffer(struct drm_device *dev,
25882598 * to explicitly hold another reference here.
25892599 */
25902600 eb .request -> batch = eb .batch ;
2601+ if (eb .batch -> private )
2602+ intel_engine_pool_mark_active (eb .batch -> private , eb .request );
25912603
25922604 trace_i915_request_queue (eb .request , eb .batch_flags );
25932605 err = eb_submit (& eb );
@@ -2612,6 +2624,8 @@ i915_gem_do_execbuffer(struct drm_device *dev,
26122624err_batch_unpin :
26132625 if (eb .batch_flags & I915_DISPATCH_SECURE )
26142626 i915_vma_unpin (eb .batch );
2627+ if (eb .batch -> private )
2628+ intel_engine_pool_put (eb .batch -> private );
26152629err_vma :
26162630 if (eb .exec )
26172631 eb_release_vmas (& eb );
0 commit comments