[PATCH] spmi: mtk-pmif: Add a WFVLDCLR specific timeout

DORMANTno replies

From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Date: 2023-05-04 11:39:56
Also in: linux-mediatek, lkml
Subsystem: spmi subsystem, the rest · Maintainers: Stephen Boyd, Linus Torvalds

At least on MT8195, in some instances, at cold-boot the PMIF seems to
get busy and slow, triggering a failure in pmif_spmi_read_cmd() with
"failed to wait for SWINF_WFVLDCLR" message: at least on the Tomato
Chromebook, this gives issues with the GPU power supply, resulting in
a probe failure for panfrost.

Through trial and error (rebooting the machine ~50 times), it was
found that a timeout of at least 50 milliseconds does effectively
mitigate this issue, hence add an "extended" timeout and use it for
the WFVLDCLR polling.

Fixes: b45b3ccef8c0 ("spmi: mediatek: Add support for MT6873/8192")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/spmi/spmi-mtk-pmif.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/spmi/spmi-mtk-pmif.c b/drivers/spmi/spmi-mtk-pmif.c
index b3c991e1ea40..a7b4b030929e 100644
--- a/drivers/spmi/spmi-mtk-pmif.c
+++ b/drivers/spmi/spmi-mtk-pmif.c
@@ -22,6 +22,7 @@
 
 #define PMIF_DELAY_US   10
 #define PMIF_TIMEOUT_US (10 * 1000)
+#define PMIF_WFVLDCLR_TIMEOUT_US (50 * 1000)
 
 #define PMIF_CHAN_OFFSET 0x5
 
@@ -357,7 +358,7 @@ static int pmif_spmi_read_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
 	 */
 	ret = readl_poll_timeout_atomic(arb->base + arb->data->regs[inf_reg->ch_sta],
 					data, GET_SWINF(data) == SWINF_WFVLDCLR,
-					PMIF_DELAY_US, PMIF_TIMEOUT_US);
+					PMIF_DELAY_US, PMIF_WFVLDCLR_TIMEOUT_US);
 	if (ret < 0) {
 		dev_err(&ctrl->dev, "failed to wait for SWINF_WFVLDCLR\n");
 		return ret;
-- 
2.40.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help