aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorDave Gordon <david.s.gordon@intel.com>2016-09-12 16:19:37 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2016-09-15 05:56:07 -0400
commit7a9347f947757f6c5ea432b299a8ba33ef7b78c7 (patch)
tree5846ab237a83fa4ba43187f1a19f621aeedef86c /drivers/gpu/drm
parent0c5664e41728b6d0b39de37a17940ee5cd8a1a64 (diff)
drm/i915/guc: general tidying up (submission)
Renaming to more consistent scheme, and updating comments, mostly about i915_guc_wq_reserve(), aka i915_guc_wq_check_space(). Signed-off-by: Dave Gordon <david.s.gordon@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1473711577-11454-4-git-send-email-david.s.gordon@intel.com Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/i915/i915_guc_submission.c63
-rw-r--r--drivers/gpu/drm/i915/intel_guc.h2
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c2
3 files changed, 34 insertions, 33 deletions
diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
index 279a4d060288..43358e18d34c 100644
--- a/drivers/gpu/drm/i915/i915_guc_submission.c
+++ b/drivers/gpu/drm/i915/i915_guc_submission.c
@@ -59,7 +59,7 @@
59 * WQ_TYPE_INORDER is needed to support legacy submission via GuC, which 59 * WQ_TYPE_INORDER is needed to support legacy submission via GuC, which
60 * represents in-order queue. The kernel driver packs ring tail pointer and an 60 * represents in-order queue. The kernel driver packs ring tail pointer and an
61 * ELSP context descriptor dword into Work Item. 61 * ELSP context descriptor dword into Work Item.
62 * See guc_add_workqueue_item() 62 * See guc_wq_item_append()
63 * 63 *
64 */ 64 */
65 65
@@ -288,7 +288,7 @@ static uint32_t select_doorbell_cacheline(struct intel_guc *guc)
288/* 288/*
289 * Initialise the process descriptor shared with the GuC firmware. 289 * Initialise the process descriptor shared with the GuC firmware.
290 */ 290 */
291static void guc_init_proc_desc(struct intel_guc *guc, 291static void guc_proc_desc_init(struct intel_guc *guc,
292 struct i915_guc_client *client) 292 struct i915_guc_client *client)
293{ 293{
294 struct guc_process_desc *desc; 294 struct guc_process_desc *desc;
@@ -320,7 +320,7 @@ static void guc_init_proc_desc(struct intel_guc *guc,
320 * write queue, etc). 320 * write queue, etc).
321 */ 321 */
322 322
323static void guc_init_ctx_desc(struct intel_guc *guc, 323static void guc_ctx_desc_init(struct intel_guc *guc,
324 struct i915_guc_client *client) 324 struct i915_guc_client *client)
325{ 325{
326 struct drm_i915_private *dev_priv = guc_to_i915(guc); 326 struct drm_i915_private *dev_priv = guc_to_i915(guc);
@@ -399,7 +399,7 @@ static void guc_init_ctx_desc(struct intel_guc *guc,
399 sizeof(desc) * client->ctx_index); 399 sizeof(desc) * client->ctx_index);
400} 400}
401 401
402static void guc_fini_ctx_desc(struct intel_guc *guc, 402static void guc_ctx_desc_fini(struct intel_guc *guc,
403 struct i915_guc_client *client) 403 struct i915_guc_client *client)
404{ 404{
405 struct guc_context_desc desc; 405 struct guc_context_desc desc;
@@ -413,7 +413,7 @@ static void guc_fini_ctx_desc(struct intel_guc *guc,
413} 413}
414 414
415/** 415/**
416 * i915_guc_wq_check_space() - check that the GuC can accept a request 416 * i915_guc_wq_reserve() - reserve space in the GuC's workqueue
417 * @request: request associated with the commands 417 * @request: request associated with the commands
418 * 418 *
419 * Return: 0 if space is available 419 * Return: 0 if space is available
@@ -421,14 +421,14 @@ static void guc_fini_ctx_desc(struct intel_guc *guc,
421 * 421 *
422 * This function must be called (and must return 0) before a request 422 * This function must be called (and must return 0) before a request
423 * is submitted to the GuC via i915_guc_submit() below. Once a result 423 * is submitted to the GuC via i915_guc_submit() below. Once a result
424 * of 0 has been returned, it remains valid until (but only until) 424 * of 0 has been returned, it must be balanced by a corresponding
425 * the next call to submit(). 425 * call to submit().
426 * 426 *
427 * This precheck allows the caller to determine in advance that space 427 * Reservation allows the caller to determine in advance that space
428 * will be available for the next submission before committing resources 428 * will be available for the next submission before committing resources
429 * to it, and helps avoid late failures with complicated recovery paths. 429 * to it, and helps avoid late failures with complicated recovery paths.
430 */ 430 */
431int i915_guc_wq_check_space(struct drm_i915_gem_request *request) 431int i915_guc_wq_reserve(struct drm_i915_gem_request *request)
432{ 432{
433 const size_t wqi_size = sizeof(struct guc_wq_item); 433 const size_t wqi_size = sizeof(struct guc_wq_item);
434 struct i915_guc_client *gc = request->i915->guc.execbuf_client; 434 struct i915_guc_client *gc = request->i915->guc.execbuf_client;
@@ -451,8 +451,9 @@ int i915_guc_wq_check_space(struct drm_i915_gem_request *request)
451 return ret; 451 return ret;
452} 452}
453 453
454static void guc_add_workqueue_item(struct i915_guc_client *gc, 454/* Construct a Work Item and append it to the GuC's Work Queue */
455 struct drm_i915_gem_request *rq) 455static void guc_wq_item_append(struct i915_guc_client *gc,
456 struct drm_i915_gem_request *rq)
456{ 457{
457 /* wqi_len is in DWords, and does not include the one-word header */ 458 /* wqi_len is in DWords, and does not include the one-word header */
458 const size_t wqi_size = sizeof(struct guc_wq_item); 459 const size_t wqi_size = sizeof(struct guc_wq_item);
@@ -465,7 +466,7 @@ static void guc_add_workqueue_item(struct i915_guc_client *gc,
465 466
466 desc = gc->client_base + gc->proc_desc_offset; 467 desc = gc->client_base + gc->proc_desc_offset;
467 468
468 /* Free space is guaranteed, see i915_guc_wq_check_space() above */ 469 /* Free space is guaranteed, see i915_guc_wq_reserve() above */
469 freespace = CIRC_SPACE(gc->wq_tail, desc->head, gc->wq_size); 470 freespace = CIRC_SPACE(gc->wq_tail, desc->head, gc->wq_size);
470 GEM_BUG_ON(freespace < wqi_size); 471 GEM_BUG_ON(freespace < wqi_size);
471 472
@@ -575,14 +576,13 @@ static int guc_ring_doorbell(struct i915_guc_client *gc)
575 * Return: 0 on success, otherwise an errno. 576 * Return: 0 on success, otherwise an errno.
576 * (Note: nonzero really shouldn't happen!) 577 * (Note: nonzero really shouldn't happen!)
577 * 578 *
578 * The caller must have already called i915_guc_wq_check_space() above 579 * The caller must have already called i915_guc_wq_reserve() above with
579 * with a result of 0 (success) since the last request submission. This 580 * a result of 0 (success), guaranteeing that there is space in the work
580 * guarantees that there is space in the work queue for the new request, 581 * queue for the new request, so enqueuing the item cannot fail.
581 * so enqueuing the item cannot fail.
582 * 582 *
583 * Bad Things Will Happen if the caller violates this protocol e.g. calls 583 * Bad Things Will Happen if the caller violates this protocol e.g. calls
584 * submit() when check() says there's no space, or calls submit() multiple 584 * submit() when _reserve() says there's no space, or calls _submit()
585 * times with no intervening check(). 585 * a different number of times from (successful) calls to _reserve().
586 * 586 *
587 * The only error here arises if the doorbell hardware isn't functioning 587 * The only error here arises if the doorbell hardware isn't functioning
588 * as expected, which really shouln't happen. 588 * as expected, which really shouln't happen.
@@ -595,7 +595,7 @@ static void i915_guc_submit(struct drm_i915_gem_request *rq)
595 int b_ret; 595 int b_ret;
596 596
597 spin_lock(&client->wq_lock); 597 spin_lock(&client->wq_lock);
598 guc_add_workqueue_item(client, rq); 598 guc_wq_item_append(client, rq);
599 b_ret = guc_ring_doorbell(client); 599 b_ret = guc_ring_doorbell(client);
600 600
601 client->submissions[engine_id] += 1; 601 client->submissions[engine_id] += 1;
@@ -686,7 +686,7 @@ guc_client_free(struct drm_i915_private *dev_priv,
686 i915_vma_unpin_and_release(&client->vma); 686 i915_vma_unpin_and_release(&client->vma);
687 687
688 if (client->ctx_index != GUC_INVALID_CTX_ID) { 688 if (client->ctx_index != GUC_INVALID_CTX_ID) {
689 guc_fini_ctx_desc(guc, client); 689 guc_ctx_desc_fini(guc, client);
690 ida_simple_remove(&guc->ctx_ids, client->ctx_index); 690 ida_simple_remove(&guc->ctx_ids, client->ctx_index);
691 } 691 }
692 692
@@ -818,8 +818,8 @@ guc_client_alloc(struct drm_i915_private *dev_priv,
818 else 818 else
819 client->proc_desc_offset = (GUC_DB_SIZE / 2); 819 client->proc_desc_offset = (GUC_DB_SIZE / 2);
820 820
821 guc_init_proc_desc(guc, client); 821 guc_proc_desc_init(guc, client);
822 guc_init_ctx_desc(guc, client); 822 guc_ctx_desc_init(guc, client);
823 if (guc_init_doorbell(guc, client, db_id)) 823 if (guc_init_doorbell(guc, client, db_id))
824 goto err; 824 goto err;
825 825
@@ -835,7 +835,7 @@ err:
835 return NULL; 835 return NULL;
836} 836}
837 837
838static void guc_create_log(struct intel_guc *guc) 838static void guc_log_create(struct intel_guc *guc)
839{ 839{
840 struct i915_vma *vma; 840 struct i915_vma *vma;
841 unsigned long offset; 841 unsigned long offset;
@@ -875,7 +875,7 @@ static void guc_create_log(struct intel_guc *guc)
875 guc->log_flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags; 875 guc->log_flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags;
876} 876}
877 877
878static void init_guc_policies(struct guc_policies *policies) 878static void guc_policies_init(struct guc_policies *policies)
879{ 879{
880 struct guc_policy *policy; 880 struct guc_policy *policy;
881 u32 p, i; 881 u32 p, i;
@@ -897,7 +897,7 @@ static void init_guc_policies(struct guc_policies *policies)
897 policies->is_valid = 1; 897 policies->is_valid = 1;
898} 898}
899 899
900static void guc_create_ads(struct intel_guc *guc) 900static void guc_addon_create(struct intel_guc *guc)
901{ 901{
902 struct drm_i915_private *dev_priv = guc_to_i915(guc); 902 struct drm_i915_private *dev_priv = guc_to_i915(guc);
903 struct i915_vma *vma; 903 struct i915_vma *vma;
@@ -940,7 +940,7 @@ static void guc_create_ads(struct intel_guc *guc)
940 940
941 /* GuC scheduling policies */ 941 /* GuC scheduling policies */
942 policies = (void *)ads + sizeof(struct guc_ads); 942 policies = (void *)ads + sizeof(struct guc_ads);
943 init_guc_policies(policies); 943 guc_policies_init(policies);
944 944
945 ads->scheduler_policies = 945 ads->scheduler_policies =
946 i915_ggtt_offset(vma) + sizeof(struct guc_ads); 946 i915_ggtt_offset(vma) + sizeof(struct guc_ads);
@@ -971,9 +971,11 @@ static void guc_create_ads(struct intel_guc *guc)
971 */ 971 */
972int i915_guc_submission_init(struct drm_i915_private *dev_priv) 972int i915_guc_submission_init(struct drm_i915_private *dev_priv)
973{ 973{
974 const size_t ctxsize = sizeof(struct guc_context_desc);
975 const size_t poolsize = GUC_MAX_GPU_CONTEXTS * ctxsize;
976 const size_t gemsize = round_up(poolsize, PAGE_SIZE);
974 struct intel_guc *guc = &dev_priv->guc; 977 struct intel_guc *guc = &dev_priv->guc;
975 struct i915_vma *vma; 978 struct i915_vma *vma;
976 u32 size;
977 979
978 /* Wipe bitmap & delete client in case of reinitialisation */ 980 /* Wipe bitmap & delete client in case of reinitialisation */
979 bitmap_clear(guc->doorbell_bitmap, 0, GUC_MAX_DOORBELLS); 981 bitmap_clear(guc->doorbell_bitmap, 0, GUC_MAX_DOORBELLS);
@@ -985,15 +987,14 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv)
985 if (guc->ctx_pool_vma) 987 if (guc->ctx_pool_vma)
986 return 0; /* already allocated */ 988 return 0; /* already allocated */
987 989
988 size = PAGE_ALIGN(GUC_MAX_GPU_CONTEXTS*sizeof(struct guc_context_desc)); 990 vma = guc_allocate_vma(guc, gemsize);
989 vma = guc_allocate_vma(guc, size);
990 if (IS_ERR(vma)) 991 if (IS_ERR(vma))
991 return PTR_ERR(vma); 992 return PTR_ERR(vma);
992 993
993 guc->ctx_pool_vma = vma; 994 guc->ctx_pool_vma = vma;
994 ida_init(&guc->ctx_ids); 995 ida_init(&guc->ctx_ids);
995 guc_create_log(guc); 996 guc_log_create(guc);
996 guc_create_ads(guc); 997 guc_addon_create(guc);
997 998
998 return 0; 999 return 0;
999} 1000}
diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index 467845967e0b..b1ba86958811 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -159,7 +159,7 @@ extern int intel_guc_resume(struct drm_device *dev);
159/* i915_guc_submission.c */ 159/* i915_guc_submission.c */
160int i915_guc_submission_init(struct drm_i915_private *dev_priv); 160int i915_guc_submission_init(struct drm_i915_private *dev_priv);
161int i915_guc_submission_enable(struct drm_i915_private *dev_priv); 161int i915_guc_submission_enable(struct drm_i915_private *dev_priv);
162int i915_guc_wq_check_space(struct drm_i915_gem_request *rq); 162int i915_guc_wq_reserve(struct drm_i915_gem_request *rq);
163void i915_guc_submission_disable(struct drm_i915_private *dev_priv); 163void i915_guc_submission_disable(struct drm_i915_private *dev_priv);
164void i915_guc_submission_fini(struct drm_i915_private *dev_priv); 164void i915_guc_submission_fini(struct drm_i915_private *dev_priv);
165 165
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 16d7cdd11082..251143361f31 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -627,7 +627,7 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request
627 * going any further, as the i915_add_request() call 627 * going any further, as the i915_add_request() call
628 * later on mustn't fail ... 628 * later on mustn't fail ...
629 */ 629 */
630 ret = i915_guc_wq_check_space(request); 630 ret = i915_guc_wq_reserve(request);
631 if (ret) 631 if (ret)
632 return ret; 632 return ret;
633 } 633 }