@@ -195,11 +195,9 @@ static int guc_ring_doorbell(struct i915_guc_client *gc)
195
195
struct guc_process_desc * desc ;
196
196
union guc_doorbell_qw db_cmp , db_exc , db_ret ;
197
197
union guc_doorbell_qw * db ;
198
- void * base ;
199
198
int attempt = 2 , ret = - EAGAIN ;
200
199
201
- base = kmap_atomic (i915_gem_object_get_page (gc -> client_obj , 0 ));
202
- desc = base + gc -> proc_desc_offset ;
200
+ desc = gc -> client_base + gc -> proc_desc_offset ;
203
201
204
202
/* Update the tail so it is visible to GuC */
205
203
desc -> tail = gc -> wq_tail ;
@@ -215,7 +213,7 @@ static int guc_ring_doorbell(struct i915_guc_client *gc)
215
213
db_exc .cookie = 1 ;
216
214
217
215
/* pointer of current doorbell cacheline */
218
- db = base + gc -> doorbell_offset ;
216
+ db = gc -> client_base + gc -> doorbell_offset ;
219
217
220
218
while (attempt -- ) {
221
219
/* lets ring the doorbell */
@@ -244,10 +242,6 @@ static int guc_ring_doorbell(struct i915_guc_client *gc)
244
242
db_exc .cookie = 1 ;
245
243
}
246
244
247
- /* Finally, update the cached copy of the GuC's WQ head */
248
- gc -> wq_head = desc -> head ;
249
-
250
- kunmap_atomic (base );
251
245
return ret ;
252
246
}
253
247
@@ -341,10 +335,8 @@ static void guc_init_proc_desc(struct intel_guc *guc,
341
335
struct i915_guc_client * client )
342
336
{
343
337
struct guc_process_desc * desc ;
344
- void * base ;
345
338
346
- base = kmap_atomic (i915_gem_object_get_page (client -> client_obj , 0 ));
347
- desc = base + client -> proc_desc_offset ;
339
+ desc = client -> client_base + client -> proc_desc_offset ;
348
340
349
341
memset (desc , 0 , sizeof (* desc ));
350
342
@@ -361,8 +353,6 @@ static void guc_init_proc_desc(struct intel_guc *guc,
361
353
desc -> wq_size_bytes = client -> wq_size ;
362
354
desc -> wq_status = WQ_STATUS_ACTIVE ;
363
355
desc -> priority = client -> priority ;
364
-
365
- kunmap_atomic (base );
366
356
}
367
357
368
358
/*
@@ -474,25 +464,16 @@ static void guc_fini_ctx_desc(struct intel_guc *guc,
474
464
int i915_guc_wq_check_space (struct i915_guc_client * gc )
475
465
{
476
466
struct guc_process_desc * desc ;
477
- void * base ;
478
467
u32 size = sizeof (struct guc_wq_item );
479
468
int ret = - ETIMEDOUT , timeout_counter = 200 ;
480
469
481
470
if (!gc )
482
471
return 0 ;
483
472
484
- /* Quickly return if wq space is available since last time we cache the
485
- * head position. */
486
- if (CIRC_SPACE (gc -> wq_tail , gc -> wq_head , gc -> wq_size ) >= size )
487
- return 0 ;
488
-
489
- base = kmap_atomic (i915_gem_object_get_page (gc -> client_obj , 0 ));
490
- desc = base + gc -> proc_desc_offset ;
473
+ desc = gc -> client_base + gc -> proc_desc_offset ;
491
474
492
475
while (timeout_counter -- > 0 ) {
493
- gc -> wq_head = desc -> head ;
494
-
495
- if (CIRC_SPACE (gc -> wq_tail , gc -> wq_head , gc -> wq_size ) >= size ) {
476
+ if (CIRC_SPACE (gc -> wq_tail , desc -> head , gc -> wq_size ) >= size ) {
496
477
ret = 0 ;
497
478
break ;
498
479
}
@@ -501,24 +482,23 @@ int i915_guc_wq_check_space(struct i915_guc_client *gc)
501
482
usleep_range (1000 , 2000 );
502
483
};
503
484
504
- kunmap_atomic (base );
505
-
506
485
return ret ;
507
486
}
508
487
509
488
static int guc_add_workqueue_item (struct i915_guc_client * gc ,
510
489
struct drm_i915_gem_request * rq )
511
490
{
491
+ struct guc_process_desc * desc ;
512
492
struct guc_wq_item * wqi ;
513
- void * base ;
514
- u32 tail , wq_len , wq_off , space ;
493
+ u32 tail , wq_len , wqi_off , space ;
515
494
516
- space = CIRC_SPACE (gc -> wq_tail , gc -> wq_head , gc -> wq_size );
495
+ desc = gc -> client_base + gc -> proc_desc_offset ;
496
+ space = CIRC_SPACE (gc -> wq_tail , desc -> head , gc -> wq_size );
517
497
if (WARN_ON (space < sizeof (struct guc_wq_item )))
518
498
return - ENOSPC ; /* shouldn't happen */
519
499
520
500
/* postincrement WQ tail for next time */
521
- wq_off = gc -> wq_tail ;
501
+ wqi_off = gc -> wq_tail ;
522
502
gc -> wq_tail += sizeof (struct guc_wq_item );
523
503
gc -> wq_tail &= gc -> wq_size - 1 ;
524
504
@@ -530,13 +510,10 @@ static int guc_add_workqueue_item(struct i915_guc_client *gc,
530
510
* workqueue buffer dw by dw.
531
511
*/
532
512
WARN_ON (sizeof (struct guc_wq_item ) != 16 );
533
- WARN_ON (wq_off & 3 );
513
+ WARN_ON (wqi_off & 3 );
534
514
535
515
/* wq starts from the page after doorbell / process_desc */
536
- base = kmap_atomic (i915_gem_object_get_page (gc -> client_obj ,
537
- (wq_off + GUC_DB_SIZE ) >> PAGE_SHIFT ));
538
- wq_off &= PAGE_SIZE - 1 ;
539
- wqi = (struct guc_wq_item * )((char * )base + wq_off );
516
+ wqi = gc -> client_base + gc -> wq_offset + wqi_off ;
540
517
541
518
/* len does not include the header */
542
519
wq_len = sizeof (struct guc_wq_item ) / sizeof (u32 ) - 1 ;
@@ -553,8 +530,6 @@ static int guc_add_workqueue_item(struct i915_guc_client *gc,
553
530
wqi -> ring_tail = tail << WQ_RING_TAIL_SHIFT ;
554
531
wqi -> fence_id = 0 ; /*XXX: what fence to be here */
555
532
556
- kunmap_atomic (base );
557
-
558
533
return 0 ;
559
534
}
560
535
@@ -675,6 +650,8 @@ static void guc_client_free(struct drm_device *dev,
675
650
* Be sure to drop any locks
676
651
*/
677
652
653
+ vunmap (client -> client_base );
654
+
678
655
gem_release_guc_obj (client -> client_obj );
679
656
680
657
if (client -> ctx_index != GUC_INVALID_CTX_ID ) {
@@ -727,6 +704,8 @@ static struct i915_guc_client *guc_client_alloc(struct drm_device *dev,
727
704
if (!obj )
728
705
goto err ;
729
706
707
+ client -> client_base = i915_gem_object_vmap (obj , 0 , obj -> pages -> nents );
708
+
730
709
client -> client_obj = obj ;
731
710
client -> wq_offset = GUC_DB_SIZE ;
732
711
client -> wq_size = GUC_WQ_SIZE ;
0 commit comments