Re: [PATCH v3 2/2] soc: qcom: rpmh-rsc: Timeout after 1 second in write_tcs_reg_sync()

From: Maulik Shah
Date: Thu May 28 2020 - 07:44:51 EST


Hi Doug,

During suspend-resume with this change on sc7180 using latest linux-next, below warning was reported.

WARNING: CPU: 0 PID: 5324 at kernel/time/timekeeping.c:754 ktime_get+0x94/0x9c
Âktime_get+0x94/0x9c
Âwrite_tcs_reg_sync+0x4c/0x130
Âtcs_invalidate+0x64/0xa4
Ârpmh_rsc_invalidate+0x20/0x38
Ârpmh_flush+0x58/0x1ec
Ârpmh_rsc_cpu_pm_callback+0xe4/0x144
Ânotifier_call_chain+0x58/0x90
Â__atomic_notifier_call_chain+0x48/
Âcpu_pm_notify+0x40/0x6c
Âcpu_pm_enter+0x34/0x7c
Âcpu_pm_suspend+0x10/0x20
Âsyscore_suspend+0x128/0x2a4
Âsuspend_devices_and_enter+0x5e0/0x8a0

This seems to be because timekeeping is already suspend by this time.

Thanks,
Maulik

On 4/15/2020 10:30 PM, Douglas Anderson wrote:
If our data still isn't there after 1 second, shout and give up.

Reported-by: Joe Perches <joe@xxxxxxxxxxx>
Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
Reviewed-by: Stephen Boyd <swboyd@xxxxxxxxxxxx>
---

Changes in v3:
- The register should be hex.

Changes in v2:
- Patch ("Timeout after 1 second") new for v2.

drivers/soc/qcom/rpmh-rsc.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index ce39d8399312..e09d1ada0cd2 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -10,6 +10,7 @@
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
@@ -175,12 +176,13 @@ static void write_tcs_reg(const struct rsc_drv *drv, int reg, int tcs_id,
static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id,
u32 data)
{
+ u32 new_data;
+
writel(data, tcs_reg_addr(drv, reg, tcs_id));
- for (;;) {
- if (data == readl(tcs_reg_addr(drv, reg, tcs_id)))
- break;
- udelay(1);
- }
+ if (readl_poll_timeout_atomic(tcs_reg_addr(drv, reg, tcs_id), new_data,
+ new_data == data, 1, USEC_PER_SEC))
+ pr_err("%s: error writing %#x to %d:%#x\n", drv->name,
+ data, tcs_id, reg);
}
/**

--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation