From: Stefan Wahren Date: Sat, 6 Oct 2018 11:31:56 +0000 (+0200) Subject: firmware: raspberrypi: Define timeout for transactions X-Git-Tag: accepted/tizen/unified/20191111.065916~139 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=709ecf46a7dea81a5b72e1a8d87a1cac51821c8c;p=platform%2Fkernel%2Flinux-rpi.git firmware: raspberrypi: Define timeout for transactions We should never assume to get a reply from the firmware otherwise the call could block forever and the user don't get informed. So define a timeout of 1 sec and print a stacktrace once in the unlikely case the timeout expired. Signed-off-by: Stefan Wahren Reviewed-by: Eric Anholt [jhoon20.kim: cherry picked from commit 0829187b17d8 for debugging booting issues] Signed-off-by: Junghoon Kim Change-Id: I2bb14167174662a84c6b2a8caaffc70485693816 --- diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index fcbfe5d..82c375e 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -59,8 +59,12 @@ rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data) reinit_completion(&fw->c); ret = mbox_send_message(fw->chan, &message); if (ret >= 0) { - wait_for_completion(&fw->c); - ret = 0; + if (wait_for_completion_timeout(&fw->c, HZ)) { + ret = 0; + } else { + ret = -ETIMEDOUT; + WARN_ONCE(1, "Firmware transaction timeout"); + } } else { dev_err(fw->cl.dev, "mbox_send_message returned %d\n", ret); }