提交 7a9347f9 编写于 作者: D Dave Gordon 提交者: Chris Wilson

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: NDave Gordon <david.s.gordon@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1473711577-11454-4-git-send-email-david.s.gordon@intel.comReviewed-by: NTvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
上级 0c5664e4
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
* WQ_TYPE_INORDER is needed to support legacy submission via GuC, which * WQ_TYPE_INORDER is needed to support legacy submission via GuC, which
* represents in-order queue. The kernel driver packs ring tail pointer and an * represents in-order queue. The kernel driver packs ring tail pointer and an
* ELSP context descriptor dword into Work Item. * ELSP context descriptor dword into Work Item.
* See guc_add_workqueue_item() * See guc_wq_item_append()
* *
*/ */
...@@ -288,7 +288,7 @@ static uint32_t select_doorbell_cacheline(struct intel_guc *guc) ...@@ -288,7 +288,7 @@ static uint32_t select_doorbell_cacheline(struct intel_guc *guc)
/* /*
* Initialise the process descriptor shared with the GuC firmware. * Initialise the process descriptor shared with the GuC firmware.
*/ */
static void guc_init_proc_desc(struct intel_guc *guc, static void guc_proc_desc_init(struct intel_guc *guc,
struct i915_guc_client *client) struct i915_guc_client *client)
{ {
struct guc_process_desc *desc; struct guc_process_desc *desc;
...@@ -320,7 +320,7 @@ static void guc_init_proc_desc(struct intel_guc *guc, ...@@ -320,7 +320,7 @@ static void guc_init_proc_desc(struct intel_guc *guc,
* write queue, etc). * write queue, etc).
*/ */
static void guc_init_ctx_desc(struct intel_guc *guc, static void guc_ctx_desc_init(struct intel_guc *guc,
struct i915_guc_client *client) struct i915_guc_client *client)
{ {
struct drm_i915_private *dev_priv = guc_to_i915(guc); 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,7 +399,7 @@ static void guc_init_ctx_desc(struct intel_guc *guc,
sizeof(desc) * client->ctx_index); sizeof(desc) * client->ctx_index);
} }
static void guc_fini_ctx_desc(struct intel_guc *guc, static void guc_ctx_desc_fini(struct intel_guc *guc,
struct i915_guc_client *client) struct i915_guc_client *client)
{ {
struct guc_context_desc desc; struct guc_context_desc desc;
...@@ -413,7 +413,7 @@ static void guc_fini_ctx_desc(struct intel_guc *guc, ...@@ -413,7 +413,7 @@ static void guc_fini_ctx_desc(struct intel_guc *guc,
} }
/** /**
* i915_guc_wq_check_space() - check that the GuC can accept a request * i915_guc_wq_reserve() - reserve space in the GuC's workqueue
* @request: request associated with the commands * @request: request associated with the commands
* *
* Return: 0 if space is available * Return: 0 if space is available
...@@ -421,14 +421,14 @@ static void guc_fini_ctx_desc(struct intel_guc *guc, ...@@ -421,14 +421,14 @@ static void guc_fini_ctx_desc(struct intel_guc *guc,
* *
* This function must be called (and must return 0) before a request * This function must be called (and must return 0) before a request
* is submitted to the GuC via i915_guc_submit() below. Once a result * is submitted to the GuC via i915_guc_submit() below. Once a result
* of 0 has been returned, it remains valid until (but only until) * of 0 has been returned, it must be balanced by a corresponding
* the next call to submit(). * call to submit().
* *
* This precheck allows the caller to determine in advance that space * Reservation allows the caller to determine in advance that space
* will be available for the next submission before committing resources * will be available for the next submission before committing resources
* to it, and helps avoid late failures with complicated recovery paths. * to it, and helps avoid late failures with complicated recovery paths.
*/ */
int i915_guc_wq_check_space(struct drm_i915_gem_request *request) int i915_guc_wq_reserve(struct drm_i915_gem_request *request)
{ {
const size_t wqi_size = sizeof(struct guc_wq_item); const size_t wqi_size = sizeof(struct guc_wq_item);
struct i915_guc_client *gc = request->i915->guc.execbuf_client; 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,8 +451,9 @@ int i915_guc_wq_check_space(struct drm_i915_gem_request *request)
return ret; return ret;
} }
static void guc_add_workqueue_item(struct i915_guc_client *gc, /* Construct a Work Item and append it to the GuC's Work Queue */
struct drm_i915_gem_request *rq) static void guc_wq_item_append(struct i915_guc_client *gc,
struct drm_i915_gem_request *rq)
{ {
/* wqi_len is in DWords, and does not include the one-word header */ /* wqi_len is in DWords, and does not include the one-word header */
const size_t wqi_size = sizeof(struct guc_wq_item); 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,7 +466,7 @@ static void guc_add_workqueue_item(struct i915_guc_client *gc,
desc = gc->client_base + gc->proc_desc_offset; desc = gc->client_base + gc->proc_desc_offset;
/* Free space is guaranteed, see i915_guc_wq_check_space() above */ /* Free space is guaranteed, see i915_guc_wq_reserve() above */
freespace = CIRC_SPACE(gc->wq_tail, desc->head, gc->wq_size); freespace = CIRC_SPACE(gc->wq_tail, desc->head, gc->wq_size);
GEM_BUG_ON(freespace < wqi_size); GEM_BUG_ON(freespace < wqi_size);
...@@ -575,14 +576,13 @@ static int guc_ring_doorbell(struct i915_guc_client *gc) ...@@ -575,14 +576,13 @@ static int guc_ring_doorbell(struct i915_guc_client *gc)
* Return: 0 on success, otherwise an errno. * Return: 0 on success, otherwise an errno.
* (Note: nonzero really shouldn't happen!) * (Note: nonzero really shouldn't happen!)
* *
* The caller must have already called i915_guc_wq_check_space() above * The caller must have already called i915_guc_wq_reserve() above with
* with a result of 0 (success) since the last request submission. This * a result of 0 (success), guaranteeing that there is space in the work
* guarantees that there is space in the work queue for the new request, * queue for the new request, so enqueuing the item cannot fail.
* so enqueuing the item cannot fail.
* *
* Bad Things Will Happen if the caller violates this protocol e.g. calls * Bad Things Will Happen if the caller violates this protocol e.g. calls
* submit() when check() says there's no space, or calls submit() multiple * submit() when _reserve() says there's no space, or calls _submit()
* times with no intervening check(). * a different number of times from (successful) calls to _reserve().
* *
* The only error here arises if the doorbell hardware isn't functioning * The only error here arises if the doorbell hardware isn't functioning
* as expected, which really shouln't happen. * as expected, which really shouln't happen.
...@@ -595,7 +595,7 @@ static void i915_guc_submit(struct drm_i915_gem_request *rq) ...@@ -595,7 +595,7 @@ static void i915_guc_submit(struct drm_i915_gem_request *rq)
int b_ret; int b_ret;
spin_lock(&client->wq_lock); spin_lock(&client->wq_lock);
guc_add_workqueue_item(client, rq); guc_wq_item_append(client, rq);
b_ret = guc_ring_doorbell(client); b_ret = guc_ring_doorbell(client);
client->submissions[engine_id] += 1; client->submissions[engine_id] += 1;
...@@ -686,7 +686,7 @@ guc_client_free(struct drm_i915_private *dev_priv, ...@@ -686,7 +686,7 @@ guc_client_free(struct drm_i915_private *dev_priv,
i915_vma_unpin_and_release(&client->vma); i915_vma_unpin_and_release(&client->vma);
if (client->ctx_index != GUC_INVALID_CTX_ID) { if (client->ctx_index != GUC_INVALID_CTX_ID) {
guc_fini_ctx_desc(guc, client); guc_ctx_desc_fini(guc, client);
ida_simple_remove(&guc->ctx_ids, client->ctx_index); ida_simple_remove(&guc->ctx_ids, client->ctx_index);
} }
...@@ -818,8 +818,8 @@ guc_client_alloc(struct drm_i915_private *dev_priv, ...@@ -818,8 +818,8 @@ guc_client_alloc(struct drm_i915_private *dev_priv,
else else
client->proc_desc_offset = (GUC_DB_SIZE / 2); client->proc_desc_offset = (GUC_DB_SIZE / 2);
guc_init_proc_desc(guc, client); guc_proc_desc_init(guc, client);
guc_init_ctx_desc(guc, client); guc_ctx_desc_init(guc, client);
if (guc_init_doorbell(guc, client, db_id)) if (guc_init_doorbell(guc, client, db_id))
goto err; goto err;
...@@ -835,7 +835,7 @@ guc_client_alloc(struct drm_i915_private *dev_priv, ...@@ -835,7 +835,7 @@ guc_client_alloc(struct drm_i915_private *dev_priv,
return NULL; return NULL;
} }
static void guc_create_log(struct intel_guc *guc) static void guc_log_create(struct intel_guc *guc)
{ {
struct i915_vma *vma; struct i915_vma *vma;
unsigned long offset; unsigned long offset;
...@@ -875,7 +875,7 @@ static void guc_create_log(struct intel_guc *guc) ...@@ -875,7 +875,7 @@ static void guc_create_log(struct intel_guc *guc)
guc->log_flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags; guc->log_flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags;
} }
static void init_guc_policies(struct guc_policies *policies) static void guc_policies_init(struct guc_policies *policies)
{ {
struct guc_policy *policy; struct guc_policy *policy;
u32 p, i; u32 p, i;
...@@ -897,7 +897,7 @@ static void init_guc_policies(struct guc_policies *policies) ...@@ -897,7 +897,7 @@ static void init_guc_policies(struct guc_policies *policies)
policies->is_valid = 1; policies->is_valid = 1;
} }
static void guc_create_ads(struct intel_guc *guc) static void guc_addon_create(struct intel_guc *guc)
{ {
struct drm_i915_private *dev_priv = guc_to_i915(guc); struct drm_i915_private *dev_priv = guc_to_i915(guc);
struct i915_vma *vma; struct i915_vma *vma;
...@@ -940,7 +940,7 @@ static void guc_create_ads(struct intel_guc *guc) ...@@ -940,7 +940,7 @@ static void guc_create_ads(struct intel_guc *guc)
/* GuC scheduling policies */ /* GuC scheduling policies */
policies = (void *)ads + sizeof(struct guc_ads); policies = (void *)ads + sizeof(struct guc_ads);
init_guc_policies(policies); guc_policies_init(policies);
ads->scheduler_policies = ads->scheduler_policies =
i915_ggtt_offset(vma) + sizeof(struct guc_ads); i915_ggtt_offset(vma) + sizeof(struct guc_ads);
...@@ -971,9 +971,11 @@ static void guc_create_ads(struct intel_guc *guc) ...@@ -971,9 +971,11 @@ static void guc_create_ads(struct intel_guc *guc)
*/ */
int i915_guc_submission_init(struct drm_i915_private *dev_priv) int i915_guc_submission_init(struct drm_i915_private *dev_priv)
{ {
const size_t ctxsize = sizeof(struct guc_context_desc);
const size_t poolsize = GUC_MAX_GPU_CONTEXTS * ctxsize;
const size_t gemsize = round_up(poolsize, PAGE_SIZE);
struct intel_guc *guc = &dev_priv->guc; struct intel_guc *guc = &dev_priv->guc;
struct i915_vma *vma; struct i915_vma *vma;
u32 size;
/* Wipe bitmap & delete client in case of reinitialisation */ /* Wipe bitmap & delete client in case of reinitialisation */
bitmap_clear(guc->doorbell_bitmap, 0, GUC_MAX_DOORBELLS); 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,15 +987,14 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv)
if (guc->ctx_pool_vma) if (guc->ctx_pool_vma)
return 0; /* already allocated */ return 0; /* already allocated */
size = PAGE_ALIGN(GUC_MAX_GPU_CONTEXTS*sizeof(struct guc_context_desc)); vma = guc_allocate_vma(guc, gemsize);
vma = guc_allocate_vma(guc, size);
if (IS_ERR(vma)) if (IS_ERR(vma))
return PTR_ERR(vma); return PTR_ERR(vma);
guc->ctx_pool_vma = vma; guc->ctx_pool_vma = vma;
ida_init(&guc->ctx_ids); ida_init(&guc->ctx_ids);
guc_create_log(guc); guc_log_create(guc);
guc_create_ads(guc); guc_addon_create(guc);
return 0; return 0;
} }
......
...@@ -159,7 +159,7 @@ extern int intel_guc_resume(struct drm_device *dev); ...@@ -159,7 +159,7 @@ extern int intel_guc_resume(struct drm_device *dev);
/* i915_guc_submission.c */ /* i915_guc_submission.c */
int i915_guc_submission_init(struct drm_i915_private *dev_priv); int i915_guc_submission_init(struct drm_i915_private *dev_priv);
int i915_guc_submission_enable(struct drm_i915_private *dev_priv); int i915_guc_submission_enable(struct drm_i915_private *dev_priv);
int i915_guc_wq_check_space(struct drm_i915_gem_request *rq); int i915_guc_wq_reserve(struct drm_i915_gem_request *rq);
void i915_guc_submission_disable(struct drm_i915_private *dev_priv); void i915_guc_submission_disable(struct drm_i915_private *dev_priv);
void i915_guc_submission_fini(struct drm_i915_private *dev_priv); void i915_guc_submission_fini(struct drm_i915_private *dev_priv);
......
...@@ -627,7 +627,7 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request ...@@ -627,7 +627,7 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request
* going any further, as the i915_add_request() call * going any further, as the i915_add_request() call
* later on mustn't fail ... * later on mustn't fail ...
*/ */
ret = i915_guc_wq_check_space(request); ret = i915_guc_wq_reserve(request);
if (ret) if (ret)
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册