msm: cvp: Fix a CVP SSR deadlock

When CVP SSR is triggred by debug node, CVP is still working,
such as sending HFI MSG back to kernel driver. While kernel
driver handles HFI MSG, there is dealock in acquiring CVP
core mutex and device mutex. They are also acquired by SSR handler.

Change-Id: I28060312f8f239dfa3ac36c5bb8c7a5b720abdc2
Signed-off-by: George Shen <sqiao@codeaurora.org>
This commit is contained in:
George Shen 2020-05-30 16:07:54 -07:00
commit 297ef03399
2 changed files with 19 additions and 8 deletions

View file

@ -2138,17 +2138,20 @@ static int iris_hfi_core_trigger_ssr(void *device,
}
dev = device;
mutex_lock(&dev->lock);
if (mutex_trylock(&dev->lock)) {
rc = call_hfi_pkt_op(dev, ssr_cmd, type, &pkt);
if (rc) {
dprintk(CVP_ERR, "%s: failed to create packet\n",
__func__);
goto err_create_pkt;
}
rc = call_hfi_pkt_op(dev, ssr_cmd, type, &pkt);
if (rc) {
dprintk(CVP_ERR, "%s: failed to create packet\n", __func__);
goto err_create_pkt;
if (__iface_cmdq_write(dev, &pkt))
rc = -ENOTEMPTY;
} else {
return -EAGAIN;
}
if (__iface_cmdq_write(dev, &pkt))
rc = -ENOTEMPTY;
err_create_pkt:
mutex_unlock(&dev->lock);
return rc;

View file

@ -1397,6 +1397,7 @@ void msm_cvp_ssr_handler(struct work_struct *work)
return;
}
send_again:
mutex_lock(&core->lock);
if (core->state == CVP_CORE_INIT_DONE) {
dprintk(CVP_WARN, "%s: ssr type %d\n", __func__,
@ -1411,6 +1412,13 @@ void msm_cvp_ssr_handler(struct work_struct *work)
rc = call_hfi_op(hdev, core_trigger_ssr,
hdev->hfi_device_data, core->ssr_type);
if (rc) {
if (rc == -EAGAIN) {
core->trigger_ssr = false;
mutex_unlock(&core->lock);
usleep_range(500, 1000);
dprintk(CVP_WARN, "Retry ssr\n");
goto send_again;
}
dprintk(CVP_ERR, "%s: trigger_ssr failed\n",
__func__);
core->trigger_ssr = false;