From 4365c84d258dc1dd5ea1a00773a0bc637d56e610 Mon Sep 17 00:00:00 2001 From: Maulik Shah Date: Tue, 27 Sep 2022 11:43:34 +0530 Subject: [PATCH] drivers: soc: qcom: crm: Add delay during channel switch Add udelay() between retries for channel switch to complete. While at this also fix the condition to check valid perf_ol data and correct MAX_SW_DRV_PWR_STATES value. Change-Id: I65e464ce2614f4461f438041ec5b50dfde2dba55 Signed-off-by: Maulik Shah --- drivers/soc/qcom/crm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/crm.c b/drivers/soc/qcom/crm.c index a1d764a9c496..694e1280c7af 100644 --- a/drivers/soc/qcom/crm.c +++ b/drivers/soc/qcom/crm.c @@ -5,6 +5,7 @@ #define pr_fmt(fmt) "%s " fmt, KBUILD_MODNAME +#include #include #include #include @@ -78,7 +79,7 @@ #define CHN_BEHAVE_BIT BIT(0) /* SW DRV has ACTIVE, SLEEP and WAKE PWR STATES */ -#define MAX_SW_DRV_PWR_STATES 2 +#define MAX_SW_DRV_PWR_STATES 3 /* Time out for ACTIVE Only PWR STATE completion IRQ */ #define CRM_TIMEOUT_MS 5000 @@ -391,6 +392,12 @@ int crm_channel_switch_complete(const struct crm_drv *drv, u32 ch) sts &= CH1_CHN_BUSY; retry--; + /* + * Wait till all the votes are applied to new + * channel during channel switch. + * Maximum delay of 5 msec. + */ + udelay(100); } while ((sts != BIT(ch)) && retry); if (!retry) @@ -695,7 +702,7 @@ static bool crm_is_invalid_cmd(struct crm_drv *drv, u32 vcd_type, const struct c ret = true; else if (vcd_type == BW_VOTE_VCD && !(data & BW_VOTE_VALID)) ret = true; - else if (vcd_type == PERF_OL_VCD && !(data & ~PERF_OL_VALUE_BITS)) + else if (vcd_type == PERF_OL_VCD && (data & ~PERF_OL_VALUE_BITS)) ret = true; else ret = false;