Skip to content

Commit

Permalink
drm/i915: New lock to serialize the Host2GuC actions
Browse files Browse the repository at this point in the history
With the addition of new Host2GuC actions related to GuC logging, there
is a need of a lock to serialize them, as they can execute concurrently
with each other and also with other existing actions.

v2: Use mutex in place of spinlock to serialize, as sleep can happen
    while waiting for the action's response from GuC. (Tvrtko)

v3: To conform to the general rules, acquire mutex before taking the
    forcewake. (Tvrtko)

Signed-off-by: Akash Goel <akash.goel@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
  • Loading branch information
Akash Goel authored and Tvrtko Ursulin committed Oct 25, 2016
1 parent f824083 commit 5dd7989
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/i915_guc_submission.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static int host2guc_action(struct intel_guc *guc, u32 *data, u32 len)
if (WARN_ON(len < 1 || len > 15))
return -EINVAL;

mutex_lock(&guc->action_lock);
intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);

dev_priv->guc.action_count += 1;
Expand Down Expand Up @@ -125,6 +126,7 @@ static int host2guc_action(struct intel_guc *guc, u32 *data, u32 len)
dev_priv->guc.action_status = status;

intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
mutex_unlock(&guc->action_lock);

return ret;
}
Expand Down Expand Up @@ -1366,6 +1368,7 @@ int i915_guc_submission_init(struct drm_i915_private *dev_priv)

guc->ctx_pool_vma = vma;
ida_init(&guc->ctx_ids);
mutex_init(&guc->action_lock);
guc_log_create(guc);
guc_addon_create(guc);

Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/intel_guc.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ struct intel_guc {

uint64_t submissions[I915_NUM_ENGINES];
uint32_t last_seqno[I915_NUM_ENGINES];

/* To serialize the Host2GuC actions */
struct mutex action_lock;
};

/* intel_guc_loader.c */
Expand Down

0 comments on commit 5dd7989

Please sign in to comment.