soc: swr-mstr-ctrl: allow runtime suspend first before system suspend

Allow the swrm to runtime suspend first before entering system
suspend. This will prevent suspend being blocked for about 700ms.

Change-Id: I8f90a9f1ba4f6af0decc256cace2f3bd2295dece
Šī revīzija ir iekļauta:
Phani Kumar Uppalapati
2022-07-06 15:36:49 -07:00
revīziju iesūtīja Gerrit - the friendly Code Review server
vecāks 6c35de32f9
revīzija 42f2072808

Parādīt failu

@@ -3957,7 +3957,21 @@ static int swrm_suspend(struct device *dev)
dev_dbg(swrm->dev, "%s: suspending system, state %d, wlock %d\n",
__func__, swrm->pm_state,
swrm->wlock_holders);
swrm->pm_state = SWRM_PM_ASLEEP;
/*
* before updating the pm_state to ASLEEP, check if device is
* runtime suspended or not. If it is not, then first make it
* runtime suspend, and then update the pm_state to ASLEEP.
*/
mutex_unlock(&swrm->pm_lock); /* release pm_lock before dev suspend */
swrm_device_suspend(swrm->dev); /* runtime suspend the device */
mutex_lock(&swrm->pm_lock); /* acquire pm_lock and update state */
if (swrm->pm_state == SWRM_PM_SLEEPABLE) {
swrm->pm_state = SWRM_PM_ASLEEP;
} else if (swrm->pm_state == SWRM_PM_AWAKE) {
ret = -EBUSY;
mutex_unlock(&swrm->pm_lock);
goto check_ebusy;
}
} else if (swrm->pm_state == SWRM_PM_AWAKE) {
/*
* unlock to wait for pm_state == SWRM_PM_SLEEPABLE
@@ -4010,6 +4024,7 @@ static int swrm_suspend(struct device *dev)
pm_runtime_enable(dev);
}
}
check_ebusy:
if (ret == -EBUSY) {
/*
* There is a possibility that some audio stream is active