Skip to content
Merged
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
23 changes: 8 additions & 15 deletions drivers/misc/fastrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ struct fastrpc_invoke_ctx {
bool is_work_done;
/* process updates poll memory instead of glink response */
bool is_polled;
/* set once put_work has been scheduled for this ctx, guarded by fl->lock */
bool put_work_scheduled;
/* set once put_work is queued; atomic as it's set from IRQ context */
atomic_t put_work_scheduled;
struct kref refcount;
struct list_head node; /* list of ctxs */
struct completion work;
Expand Down Expand Up @@ -680,17 +680,13 @@ static void fastrpc_context_put_wq(struct work_struct *work)
fastrpc_context_put(ctx);
}

/* Ensures put_work is scheduled at most once per ctx; racing callers may both try. */
/*
* Schedules put_work at most once per ctx. Must stay lock-free: it runs from
* the glink rx hard-IRQ and from fastrpc_notify_users() with fl->lock held.
*/
static void fastrpc_context_schedule_put_work(struct fastrpc_invoke_ctx *ctx)
{
bool do_schedule;

spin_lock(&ctx->fl->lock);
do_schedule = !ctx->put_work_scheduled;
ctx->put_work_scheduled = true;
spin_unlock(&ctx->fl->lock);

if (do_schedule)
if (!atomic_xchg(&ctx->put_work_scheduled, 1))
schedule_work(&ctx->put_work);
}

Expand Down Expand Up @@ -3084,10 +3080,7 @@ static void fastrpc_notify_users(struct fastrpc_user *user)
list_for_each_entry(ctx, &user->interrupted, node) {
ctx->retval = -EPIPE;
complete(&ctx->work);
if (!ctx->put_work_scheduled) {
ctx->put_work_scheduled = true;
schedule_work(&ctx->put_work);
}
fastrpc_context_schedule_put_work(ctx);
}
spin_unlock(&user->lock);
}
Expand Down
Loading