Merge "soc: swr-mstr: Avoid race condition during device up"
diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c
index 3d1b080..af5adac 100644
--- a/soc/swr-mstr-ctrl.c
+++ b/soc/swr-mstr-ctrl.c
@@ -1191,6 +1191,7 @@
if (!port_req) {
dev_err(&master->dev, "%s:port not enabled : port %d\n",
__func__, portinfo->port_id[i]);
+ mutex_unlock(&swrm->mlock);
return -EINVAL;
}
port_req->req_ch &= ~portinfo->ch_en[i];
@@ -2108,29 +2109,20 @@
case SWR_DEVICE_UP:
dev_dbg(swrm->dev, "%s: swr master up called\n", __func__);
mutex_lock(&swrm->mlock);
+ pm_runtime_mark_last_busy(&pdev->dev);
+ pm_runtime_get_sync(&pdev->dev);
mutex_lock(&swrm->reslock);
- if (swrm->state == SWR_MSTR_UP) {
- dev_dbg(swrm->dev, "%s: SWR master is already UP: %d\n",
- __func__, swrm->state);
- list_for_each_entry(swr_dev, &mstr->devices, dev_list)
- swr_reset_device(swr_dev);
- } else {
- pm_runtime_mark_last_busy(&pdev->dev);
- mutex_unlock(&swrm->reslock);
- pm_runtime_get_sync(&pdev->dev);
- mutex_lock(&swrm->reslock);
- list_for_each_entry(swr_dev, &mstr->devices, dev_list) {
- ret = swr_reset_device(swr_dev);
- if (ret) {
- dev_err(swrm->dev,
- "%s: failed to reset swr device %d\n",
- __func__, swr_dev->dev_num);
- swrm_clk_request(swrm, false);
- }
+ list_for_each_entry(swr_dev, &mstr->devices, dev_list) {
+ ret = swr_reset_device(swr_dev);
+ if (ret) {
+ dev_err(swrm->dev,
+ "%s: failed to reset swr device %d\n",
+ __func__, swr_dev->dev_num);
+ swrm_clk_request(swrm, false);
}
- pm_runtime_mark_last_busy(&pdev->dev);
- pm_runtime_put_autosuspend(&pdev->dev);
}
+ pm_runtime_mark_last_busy(&pdev->dev);
+ pm_runtime_put_autosuspend(&pdev->dev);
mutex_unlock(&swrm->reslock);
mutex_unlock(&swrm->mlock);
break;