slim-msm-ngd: Prevent race condition for suspend and SSR

Prevents the possible race condition between slimbus suspend
and slimbus SSR function execution. When SSR callback function
takes mutex lock ahead of suspend function, it results in qmi
NULL pointer dereference in suspend function as SSR function
execution makes it NULL.

Change-Id: I87ed0ecaeda9627552b6061f6b135740da067774
Signed-off-by: Prudhvi Yarlagadda <pyarlaga@codeaurora.org>
This commit is contained in:
Prudhvi Yarlagadda 2019-03-14 18:30:38 +05:30
parent 8fa5b27a5a
commit 0455a225da

View file

@ -2095,7 +2095,18 @@ static int ngd_slim_runtime_suspend(struct device *device)
int ret = 0;
mutex_lock(&dev->tx_lock);
ret = ngd_slim_power_down(dev);
if (dev->qmi.handle != NULL) {
ret = ngd_slim_power_down(dev);
} else {
if (dev->state == MSM_CTRL_DOWN)
SLIM_INFO(dev, "SB rt suspend in SSR: %d\n",
dev->state);
else
SLIM_INFO(dev, "SB rt suspend bad state: %d\n",
dev->state);
mutex_unlock(&dev->tx_lock);
return ret;
}
if (ret && ret != -EBUSY)
SLIM_INFO(dev, "slim resource not idle:%d\n", ret);
if (!ret || ret == -ETIMEDOUT)