Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions drivers/gpu/drm/apple/iomfb_v26_6_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,17 @@ struct dcp_v26_event {
/* Called with the lock held. */
static void link_fail(struct dcp_v26_link *link)
{
struct dcp_v26_event *e, *next;

if (!link->failed)
dev_err(link->dev, "DCP link stopped; firmware buffers are kept until reboot\n");
link->failed = true;
/* Nothing dequeues events from a failed link. */
list_for_each_entry_safe(e, next, &link->events, list) {
list_del(&e->list);
kfree(e);
}
link->event_count = 0;
wake_up(&link->wait);
}

Expand Down Expand Up @@ -409,6 +417,7 @@ int dcp_v26_link_pump(struct dcp_v26_link *link, unsigned long timeout,
/*
* Calls @tag and handles the callbacks that arrive until its reply, and, for
* a non-zero @completion_id, until the swap-complete callback for that swap.
* A call that fails once submitted, including by timing out, stops the link.
* Must not be called concurrently with itself or dcp_v26_link_pump(), except
* from inside a callback handler.
*/
Expand Down Expand Up @@ -443,13 +452,18 @@ int dcp_v26_link_call(struct dcp_v26_link *link, u32 tag, const void *input,
ret = dcp_v26_link_pump(link, 0, callback, cookie);
if (ret) {
kfree(packet);
/* The caller gives up on the session: stop queueing. */
mutex_lock(&link->lock);
link_fail(link);
mutex_unlock(&link->lock);
return ret;
}
}
}
mutex_lock(&link->lock);
nested = link->callback_depth != 0;
if (nested && !link->callback_count) {
link_fail(link);
mutex_unlock(&link->lock);
kfree(packet);
return -EPROTO;
Expand All @@ -471,8 +485,10 @@ int dcp_v26_link_call(struct dcp_v26_link *link, u32 tag, const void *input,
struct dcp_v26_event *e = link_next_event(link, max_t(long, deadline - jiffies, 0));
struct apple_dcp_link_rpc_header *h;

if (IS_ERR(e))
return PTR_ERR(e);
if (IS_ERR(e)) {
ret = PTR_ERR(e);
goto abandon;
}
h = (void *)e->data;
if (e->kind == DCP_V26_EVENT_REPLY) {
if (replied || e->size != size || e->message != expected ||
Expand All @@ -494,9 +510,16 @@ int dcp_v26_link_call(struct dcp_v26_link *link, u32 tag, const void *input,
}
kfree(e);
if (ret)
return ret;
goto abandon;
if (replied && (!completion_id || completed == completion_id))
return 0;
}
return -ETIMEDOUT;
ret = -ETIMEDOUT;
abandon:
/* The firmware may still answer: queue nothing for a call nobody waits for. */
mutex_lock(&link->lock);
link->calls[nested].active = false;
link_fail(link);
mutex_unlock(&link->lock);
return ret;
}
Loading