@@ -4344,13 +4344,13 @@ static int live_lrc_state(void *arg)
4344
4344
return err ;
4345
4345
}
4346
4346
4347
- static int gpr_make_dirty (struct intel_engine_cs * engine )
4347
+ static int gpr_make_dirty (struct intel_context * ce )
4348
4348
{
4349
4349
struct i915_request * rq ;
4350
4350
u32 * cs ;
4351
4351
int n ;
4352
4352
4353
- rq = intel_engine_create_kernel_request ( engine );
4353
+ rq = intel_context_create_request ( ce );
4354
4354
if (IS_ERR (rq ))
4355
4355
return PTR_ERR (rq );
4356
4356
@@ -4362,53 +4362,54 @@ static int gpr_make_dirty(struct intel_engine_cs *engine)
4362
4362
4363
4363
* cs ++ = MI_LOAD_REGISTER_IMM (NUM_GPR_DW );
4364
4364
for (n = 0 ; n < NUM_GPR_DW ; n ++ ) {
4365
- * cs ++ = CS_GPR (engine , n );
4365
+ * cs ++ = CS_GPR (ce -> engine , n );
4366
4366
* cs ++ = STACK_MAGIC ;
4367
4367
}
4368
4368
* cs ++ = MI_NOOP ;
4369
4369
4370
4370
intel_ring_advance (rq , cs );
4371
+
4372
+ rq -> sched .attr .priority = I915_PRIORITY_BARRIER ;
4371
4373
i915_request_add (rq );
4372
4374
4373
4375
return 0 ;
4374
4376
}
4375
4377
4376
- static int __live_gpr_clear ( struct intel_engine_cs * engine ,
4377
- struct i915_vma * scratch )
4378
+ static struct i915_request *
4379
+ __gpr_read ( struct intel_context * ce , struct i915_vma * scratch , u32 * slot )
4378
4380
{
4379
- struct intel_context * ce ;
4381
+ const u32 offset =
4382
+ i915_ggtt_offset (ce -> engine -> status_page .vma ) +
4383
+ offset_in_page (slot );
4380
4384
struct i915_request * rq ;
4381
4385
u32 * cs ;
4382
4386
int err ;
4383
4387
int n ;
4384
4388
4385
- if (INTEL_GEN (engine -> i915 ) < 9 && engine -> class != RENDER_CLASS )
4386
- return 0 ; /* GPR only on rcs0 for gen8 */
4387
-
4388
- err = gpr_make_dirty (engine );
4389
- if (err )
4390
- return err ;
4391
-
4392
- ce = intel_context_create (engine );
4393
- if (IS_ERR (ce ))
4394
- return PTR_ERR (ce );
4395
-
4396
4389
rq = intel_context_create_request (ce );
4397
- if (IS_ERR (rq )) {
4398
- err = PTR_ERR (rq );
4399
- goto err_put ;
4400
- }
4390
+ if (IS_ERR (rq ))
4391
+ return rq ;
4401
4392
4402
- cs = intel_ring_begin (rq , 4 * NUM_GPR_DW );
4393
+ cs = intel_ring_begin (rq , 6 + 4 * NUM_GPR_DW );
4403
4394
if (IS_ERR (cs )) {
4404
- err = PTR_ERR (cs );
4405
4395
i915_request_add (rq );
4406
- goto err_put ;
4396
+ return ERR_CAST ( cs ) ;
4407
4397
}
4408
4398
4399
+ * cs ++ = MI_ARB_ON_OFF | MI_ARB_ENABLE ;
4400
+ * cs ++ = MI_NOOP ;
4401
+
4402
+ * cs ++ = MI_SEMAPHORE_WAIT |
4403
+ MI_SEMAPHORE_GLOBAL_GTT |
4404
+ MI_SEMAPHORE_POLL |
4405
+ MI_SEMAPHORE_SAD_NEQ_SDD ;
4406
+ * cs ++ = 0 ;
4407
+ * cs ++ = offset ;
4408
+ * cs ++ = 0 ;
4409
+
4409
4410
for (n = 0 ; n < NUM_GPR_DW ; n ++ ) {
4410
4411
* cs ++ = MI_STORE_REGISTER_MEM_GEN8 | MI_USE_GGTT ;
4411
- * cs ++ = CS_GPR (engine , n );
4412
+ * cs ++ = CS_GPR (ce -> engine , n );
4412
4413
* cs ++ = i915_ggtt_offset (scratch ) + n * sizeof (u32 );
4413
4414
* cs ++ = 0 ;
4414
4415
}
@@ -4421,9 +4422,59 @@ static int __live_gpr_clear(struct intel_engine_cs *engine,
4421
4422
4422
4423
i915_request_get (rq );
4423
4424
i915_request_add (rq );
4425
+ if (err ) {
4426
+ i915_request_put (rq );
4427
+ rq = ERR_PTR (err );
4428
+ }
4429
+
4430
+ return rq ;
4431
+ }
4432
+
4433
+ static int __live_lrc_gpr (struct intel_engine_cs * engine ,
4434
+ struct i915_vma * scratch ,
4435
+ bool preempt )
4436
+ {
4437
+ u32 * slot = memset32 (engine -> status_page .addr + 1000 , 0 , 4 );
4438
+ struct intel_context * ce ;
4439
+ struct i915_request * rq ;
4440
+ u32 * cs ;
4441
+ int err ;
4442
+ int n ;
4443
+
4444
+ if (INTEL_GEN (engine -> i915 ) < 9 && engine -> class != RENDER_CLASS )
4445
+ return 0 ; /* GPR only on rcs0 for gen8 */
4446
+
4447
+ err = gpr_make_dirty (engine -> kernel_context );
4448
+ if (err )
4449
+ return err ;
4450
+
4451
+ ce = intel_context_create (engine );
4452
+ if (IS_ERR (ce ))
4453
+ return PTR_ERR (ce );
4454
+
4455
+ rq = __gpr_read (ce , scratch , slot );
4456
+ if (IS_ERR (rq )) {
4457
+ err = PTR_ERR (rq );
4458
+ goto err_put ;
4459
+ }
4460
+
4461
+ err = wait_for_submit (engine , rq , HZ / 2 );
4424
4462
if (err )
4425
4463
goto err_rq ;
4426
4464
4465
+ if (preempt ) {
4466
+ err = gpr_make_dirty (engine -> kernel_context );
4467
+ if (err )
4468
+ goto err_rq ;
4469
+
4470
+ err = emit_semaphore_signal (engine -> kernel_context , slot );
4471
+ if (err )
4472
+ goto err_rq ;
4473
+ } else {
4474
+ slot [0 ] = 1 ;
4475
+ wmb ();
4476
+ }
4477
+
4427
4478
if (i915_request_wait (rq , 0 , HZ / 5 ) < 0 ) {
4428
4479
err = - ETIME ;
4429
4480
goto err_rq ;
@@ -4449,13 +4500,15 @@ static int __live_gpr_clear(struct intel_engine_cs *engine,
4449
4500
i915_gem_object_unpin_map (scratch -> obj );
4450
4501
4451
4502
err_rq :
4503
+ memset32 (& slot [0 ], -1 , 4 );
4504
+ wmb ();
4452
4505
i915_request_put (rq );
4453
4506
err_put :
4454
4507
intel_context_put (ce );
4455
4508
return err ;
4456
4509
}
4457
4510
4458
- static int live_gpr_clear (void * arg )
4511
+ static int live_lrc_gpr (void * arg )
4459
4512
{
4460
4513
struct intel_gt * gt = arg ;
4461
4514
struct intel_engine_cs * engine ;
@@ -4473,14 +4526,26 @@ static int live_gpr_clear(void *arg)
4473
4526
return PTR_ERR (scratch );
4474
4527
4475
4528
for_each_engine (engine , gt , id ) {
4476
- err = __live_gpr_clear (engine , scratch );
4529
+ unsigned long heartbeat ;
4530
+
4531
+ engine_heartbeat_disable (engine , & heartbeat );
4532
+
4533
+ err = __live_lrc_gpr (engine , scratch , false);
4534
+ if (err )
4535
+ goto err ;
4536
+
4537
+ err = __live_lrc_gpr (engine , scratch , true);
4538
+ if (err )
4539
+ goto err ;
4540
+
4541
+ err :
4542
+ engine_heartbeat_enable (engine , heartbeat );
4543
+ if (igt_flush_test (gt -> i915 ))
4544
+ err = - EIO ;
4477
4545
if (err )
4478
4546
break ;
4479
4547
}
4480
4548
4481
- if (igt_flush_test (gt -> i915 ))
4482
- err = - EIO ;
4483
-
4484
4549
i915_vma_unpin_and_release (& scratch , 0 );
4485
4550
return err ;
4486
4551
}
@@ -4779,7 +4844,7 @@ int intel_lrc_live_selftests(struct drm_i915_private *i915)
4779
4844
SUBTEST (live_lrc_layout ),
4780
4845
SUBTEST (live_lrc_fixed ),
4781
4846
SUBTEST (live_lrc_state ),
4782
- SUBTEST (live_gpr_clear ),
4847
+ SUBTEST (live_lrc_gpr ),
4783
4848
SUBTEST (live_lrc_timestamp ),
4784
4849
SUBTEST (live_pphwsp_runtime ),
4785
4850
};
0 commit comments