Commit bd00e73e authored by Chris Wilson's avatar Chris Wilson

drm/i915/guc: Refactor the retrieval of guc_process_desc

Move the common "client->vaddr + client->proc_desc_offset" to its own
function, __get_process_desc() to match the newly established pattern.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/20170323230000.20786-1-chris@chris-wilson.co.ukReviewed-by: default avatarMichał Winiarski <michal.winiarski@intel.com>
parent 2e70b8c6
...@@ -280,6 +280,12 @@ static unsigned long __select_cacheline(struct intel_guc* guc) ...@@ -280,6 +280,12 @@ static unsigned long __select_cacheline(struct intel_guc* guc)
return offset; return offset;
} }
static inline struct guc_process_desc *
__get_process_desc(struct i915_guc_client *client)
{
return client->vaddr + client->proc_desc_offset;
}
/* /*
* Initialise the process descriptor shared with the GuC firmware. * Initialise the process descriptor shared with the GuC firmware.
*/ */
...@@ -288,9 +294,7 @@ static void guc_proc_desc_init(struct intel_guc *guc, ...@@ -288,9 +294,7 @@ static void guc_proc_desc_init(struct intel_guc *guc,
{ {
struct guc_process_desc *desc; struct guc_process_desc *desc;
desc = client->vaddr + client->proc_desc_offset; desc = memset(__get_process_desc(client), 0, sizeof(*desc));
memset(desc, 0, sizeof(*desc));
/* /*
* XXX: pDoorbell and WQVBaseAddress are pointers in process address * XXX: pDoorbell and WQVBaseAddress are pointers in process address
...@@ -422,8 +426,7 @@ int i915_guc_wq_reserve(struct drm_i915_gem_request *request) ...@@ -422,8 +426,7 @@ 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 *client = request->i915->guc.execbuf_client; struct i915_guc_client *client = request->i915->guc.execbuf_client;
struct guc_process_desc *desc = client->vaddr + struct guc_process_desc *desc = __get_process_desc(client);
client->proc_desc_offset;
u32 freespace; u32 freespace;
int ret; int ret;
...@@ -468,12 +471,10 @@ static void guc_wq_item_append(struct i915_guc_client *client, ...@@ -468,12 +471,10 @@ static void guc_wq_item_append(struct i915_guc_client *client,
const size_t wqi_size = sizeof(struct guc_wq_item); const size_t wqi_size = sizeof(struct guc_wq_item);
const u32 wqi_len = wqi_size/sizeof(u32) - 1; const u32 wqi_len = wqi_size/sizeof(u32) - 1;
struct intel_engine_cs *engine = rq->engine; struct intel_engine_cs *engine = rq->engine;
struct guc_process_desc *desc; struct guc_process_desc *desc = __get_process_desc(client);
struct guc_wq_item *wqi; struct guc_wq_item *wqi;
u32 freespace, tail, wq_off; u32 freespace, tail, wq_off;
desc = client->vaddr + client->proc_desc_offset;
/* Free space is guaranteed, see i915_guc_wq_reserve() above */ /* Free space is guaranteed, see i915_guc_wq_reserve() above */
freespace = CIRC_SPACE(client->wq_tail, desc->head, client->wq_size); freespace = CIRC_SPACE(client->wq_tail, desc->head, client->wq_size);
GEM_BUG_ON(freespace < wqi_size); GEM_BUG_ON(freespace < wqi_size);
...@@ -519,8 +520,7 @@ static void guc_wq_item_append(struct i915_guc_client *client, ...@@ -519,8 +520,7 @@ static void guc_wq_item_append(struct i915_guc_client *client,
static void guc_reset_wq(struct i915_guc_client *client) static void guc_reset_wq(struct i915_guc_client *client)
{ {
struct guc_process_desc *desc = client->vaddr + struct guc_process_desc *desc = __get_process_desc(client);
client->proc_desc_offset;
desc->head = 0; desc->head = 0;
desc->tail = 0; desc->tail = 0;
...@@ -530,13 +530,11 @@ static void guc_reset_wq(struct i915_guc_client *client) ...@@ -530,13 +530,11 @@ static void guc_reset_wq(struct i915_guc_client *client)
static int guc_ring_doorbell(struct i915_guc_client *client) static int guc_ring_doorbell(struct i915_guc_client *client)
{ {
struct guc_process_desc *desc; struct guc_process_desc *desc = __get_process_desc(client);
union guc_doorbell_qw db_cmp, db_exc, db_ret; union guc_doorbell_qw db_cmp, db_exc, db_ret;
union guc_doorbell_qw *db; union guc_doorbell_qw *db;
int attempt = 2, ret = -EAGAIN; int attempt = 2, ret = -EAGAIN;
desc = client->vaddr + client->proc_desc_offset;
/* Update the tail so it is visible to GuC */ /* Update the tail so it is visible to GuC */
desc->tail = client->wq_tail; desc->tail = client->wq_tail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment