Commit 7c567bbf authored by Michal Wajdeczko's avatar Michal Wajdeczko Committed by Daniel Vetter

drm/i915/guc: Start protecting access to CTB descriptors

We want to stop using guc.send_mutex while sending CTB messages
so we have to start protecting access to CTB send descriptor.

For completeness protect also CTB receive descriptor.

Add spinlock to struct intel_guc_ct_buffer and start using it.
Signed-off-by: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210603051630.2635-15-matthew.brost@intel.com
parent df12d1c3
...@@ -89,6 +89,8 @@ static void ct_incoming_request_worker_func(struct work_struct *w); ...@@ -89,6 +89,8 @@ static void ct_incoming_request_worker_func(struct work_struct *w);
*/ */
void intel_guc_ct_init_early(struct intel_guc_ct *ct) void intel_guc_ct_init_early(struct intel_guc_ct *ct)
{ {
spin_lock_init(&ct->ctbs.send.lock);
spin_lock_init(&ct->ctbs.recv.lock);
spin_lock_init(&ct->requests.lock); spin_lock_init(&ct->requests.lock);
INIT_LIST_HEAD(&ct->requests.pending); INIT_LIST_HEAD(&ct->requests.pending);
INIT_LIST_HEAD(&ct->requests.incoming); INIT_LIST_HEAD(&ct->requests.incoming);
...@@ -473,17 +475,22 @@ static int ct_send(struct intel_guc_ct *ct, ...@@ -473,17 +475,22 @@ static int ct_send(struct intel_guc_ct *ct,
GEM_BUG_ON(len & ~GUC_CT_MSG_LEN_MASK); GEM_BUG_ON(len & ~GUC_CT_MSG_LEN_MASK);
GEM_BUG_ON(!response_buf && response_buf_size); GEM_BUG_ON(!response_buf && response_buf_size);
spin_lock_irqsave(&ct->ctbs.send.lock, flags);
fence = ct_get_next_fence(ct); fence = ct_get_next_fence(ct);
request.fence = fence; request.fence = fence;
request.status = 0; request.status = 0;
request.response_len = response_buf_size; request.response_len = response_buf_size;
request.response_buf = response_buf; request.response_buf = response_buf;
spin_lock_irqsave(&ct->requests.lock, flags); spin_lock(&ct->requests.lock);
list_add_tail(&request.link, &ct->requests.pending); list_add_tail(&request.link, &ct->requests.pending);
spin_unlock_irqrestore(&ct->requests.lock, flags); spin_unlock(&ct->requests.lock);
err = ct_write(ct, action, len, fence); err = ct_write(ct, action, len, fence);
spin_unlock_irqrestore(&ct->ctbs.send.lock, flags);
if (unlikely(err)) if (unlikely(err))
goto unlink; goto unlink;
...@@ -819,6 +826,7 @@ static int ct_handle_request(struct intel_guc_ct *ct, const u32 *msg) ...@@ -819,6 +826,7 @@ static int ct_handle_request(struct intel_guc_ct *ct, const u32 *msg)
void intel_guc_ct_event_handler(struct intel_guc_ct *ct) void intel_guc_ct_event_handler(struct intel_guc_ct *ct)
{ {
u32 msg[GUC_CT_MSG_LEN_MASK + 1]; /* one extra dw for the header */ u32 msg[GUC_CT_MSG_LEN_MASK + 1]; /* one extra dw for the header */
unsigned long flags;
int err = 0; int err = 0;
if (unlikely(!ct->enabled)) { if (unlikely(!ct->enabled)) {
...@@ -827,7 +835,9 @@ void intel_guc_ct_event_handler(struct intel_guc_ct *ct) ...@@ -827,7 +835,9 @@ void intel_guc_ct_event_handler(struct intel_guc_ct *ct)
} }
do { do {
spin_lock_irqsave(&ct->ctbs.recv.lock, flags);
err = ct_read(ct, msg); err = ct_read(ct, msg);
spin_unlock_irqrestore(&ct->ctbs.recv.lock, flags);
if (err) if (err)
break; break;
......
...@@ -27,11 +27,13 @@ struct intel_guc; ...@@ -27,11 +27,13 @@ struct intel_guc;
* record (command transport buffer descriptor) and the actual buffer which * record (command transport buffer descriptor) and the actual buffer which
* holds the commands. * holds the commands.
* *
* @lock: protects access to the commands buffer and buffer descriptor
* @desc: pointer to the buffer descriptor * @desc: pointer to the buffer descriptor
* @cmds: pointer to the commands buffer * @cmds: pointer to the commands buffer
* @size: size of the commands buffer * @size: size of the commands buffer
*/ */
struct intel_guc_ct_buffer { struct intel_guc_ct_buffer {
spinlock_t lock;
struct guc_ct_buffer_desc *desc; struct guc_ct_buffer_desc *desc;
u32 *cmds; u32 *cmds;
u32 size; u32 size;
......
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