diff mbox series

firmware: raspberrypi: Define timeout for transactions

Message ID 1540922921-3653-1-git-send-email-stefan.wahren@i2se.com (mailing list archive)
State New, archived
Headers show
Series firmware: raspberrypi: Define timeout for transactions | expand

Commit Message

Stefan Wahren Oct. 30, 2018, 6:08 p.m. UTC
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 <stefan.wahren@i2se.com>
---
 drivers/firmware/raspberrypi.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Eric Anholt Oct. 31, 2018, 5:16 p.m. UTC | #1
Stefan Wahren <stefan.wahren@i2se.com> writes:

> 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 <stefan.wahren@i2se.com>

Reviewed-by: Eric Anholt <eric@anholt.net>
Stefan Wahren Nov. 6, 2018, 6:13 p.m. UTC | #2
> Eric Anholt <eric@anholt.net> hat am 31. Oktober 2018 um 18:16 geschrieben:
> 
> 
> Stefan Wahren <stefan.wahren@i2se.com> writes:
> 
> > 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 <stefan.wahren@i2se.com>
> 
> Reviewed-by: Eric Anholt <eric@anholt.net>

Applied to bcm2835-soc-next
diff mbox series

Patch

diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index a200a21..bf45ac4 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -56,8 +56,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);
 	}