summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuofei Ma <ruofeim@google.com>2022-04-27 00:10:32 +0000
committerAndroid Partner Code Review <android-gerrit-partner@google.com>2022-04-27 00:10:32 +0000
commit115b7be27c38908612871f65673cdb09fdba76fd (patch)
tree1e8604cd125f5c986d37ea36dae299a3e22a6fee
parent1aeb0b2be6cb6ba4d05a7ded6e456381286f7f48 (diff)
parent92c4f3604ce672275fe17de6fd988bf9c32140f1 (diff)
downloadgchips-115b7be27c38908612871f65673cdb09fdba76fd.tar.gz
Merge "Fix a potential thread dead lock issue" into android13-gs-pixel-5.10
-rw-r--r--bigo.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/bigo.c b/bigo.c
index 99e9edc..38fc62d 100644
--- a/bigo.c
+++ b/bigo.c
@@ -108,16 +108,11 @@ exit:
static inline void on_last_inst_close(struct bigo_core *core)
{
- int rc;
#if IS_ENABLED(CONFIG_PM)
if (pm_runtime_put_sync_suspend(core->dev))
pr_warn("failed to suspend\n");
#endif
bigo_pt_client_disable(core);
-
- rc = kthread_stop(core->worker_thread);
- if(rc)
- pr_err("failed to stop worker thread rc = %d\n", rc);
}
static inline int bigo_count_inst(struct bigo_core *core)
@@ -199,13 +194,8 @@ static void bigo_close(struct kref *ref)
return;
}
bigo_unmap_all(inst);
- mutex_lock(&core->lock);
- list_del(&inst->list);
kfree(inst->job.regs);
kfree(inst);
- if (list_empty(&core->instances))
- on_last_inst_close(core);
- mutex_unlock(&core->lock);
bigo_update_qos(core);
pr_info("closed instance\n");
}
@@ -213,10 +203,20 @@ static void bigo_close(struct kref *ref)
static int bigo_release(struct inode *inode, struct file *file)
{
struct bigo_inst *inst = file->private_data;
+ struct bigo_core *core = inst->core;
- if (!inst)
+ if (!inst || !core)
return -EINVAL;
+ mutex_lock(&core->lock);
+ list_del(&inst->list);
+ if (list_empty(&core->instances))
+ {
+ kthread_stop(core->worker_thread);
+ on_last_inst_close(core);
+ }
+ mutex_unlock(&core->lock);
+
kref_put(&inst->refcount, bigo_close);
return 0;
}