spi: disable_depth > 0 when pm runtime get sync

when unit suspend, pm_runtime_disalbe() would be called. And
then dev.power.disable_depth number will +1. And its value
will be -1 when pm_runtime_enable() is called.
And if spi bus want to work as soon as system resume, it will call
pm_runtime_get_sync(), which would check the value of
disable_depth. If its value is not 0, spi operation will fail.
The sequence is as following:

runtime_suspend
pm_runtime_disable()-> disable_depth +1
rumtime_resume
pm_runtime_eanble() -> disable_depth -1
spi_sync()
pm_runtime_get_sync -> check the value of disable_depth

But for sometimes, spi operation will earlier than pm_runtime_enable()
called. Then spi_sync() will fail duel to non-zero disable_depth value.
So we add a checking logic before pm_runtime_get_sync() to make sure
disable_depth is 0.
(pick from https://gerrit.mot.com/#/c/1500296/)

Change-Id: I69a0ee3d728ffe3c13d95208f203bd9ed22249b2
Signed-off-by: wengjun1 <wengjun1@motorola.com>
Reviewed-on: https://gerrit.mot.com/1654438
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Haijian Ma 2020-02-19 16:59:08 +08:00 committed by caoqian4
parent 8d8f779621
commit 5fca917d89

View file

@ -934,6 +934,12 @@ static int spi_geni_prepare_transfer_hardware(struct spi_master *spi)
"%s: Error %d pinctrl_select_state\n", __func__, ret);
}
if (mas->dev->power.disable_depth > 0) {
dev_err(mas->dev, "%s:disable_depth not zero %d\n",
__func__, mas->dev->power.disable_depth);
pm_runtime_enable(mas->dev);
}
if (!mas->setup || !mas->shared_ee) {
ret = pm_runtime_get_sync(mas->dev);
if (ret < 0) {