LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] firmware: raspberrypi: Define timeout for transactions
@ 2018-10-30 18:08 Stefan Wahren
  2018-10-31 17:16 ` Eric Anholt
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Wahren @ 2018-10-30 18:08 UTC (permalink / raw)
  To: Eric Anholt
  Cc: Arnd Bergmann, Florian Fainelli, linux-kernel, linux-rpi-kernel,
	linux-arm-kernel, Stefan Wahren

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(-)

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);
 	}
-- 
2.7.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] firmware: raspberrypi: Define timeout for transactions
  2018-10-30 18:08 [PATCH] firmware: raspberrypi: Define timeout for transactions Stefan Wahren
@ 2018-10-31 17:16 ` Eric Anholt
  2018-11-06 18:13   ` Stefan Wahren
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Anholt @ 2018-10-31 17:16 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Arnd Bergmann, Florian Fainelli, linux-kernel, linux-rpi-kernel,
	linux-arm-kernel, Stefan Wahren

[-- Attachment #1: Type: text/plain, Size: 385 bytes --]

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>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] firmware: raspberrypi: Define timeout for transactions
  2018-10-31 17:16 ` Eric Anholt
@ 2018-11-06 18:13   ` Stefan Wahren
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Wahren @ 2018-11-06 18:13 UTC (permalink / raw)
  To: Eric Anholt
  Cc: Arnd Bergmann, Florian Fainelli, linux-kernel, linux-rpi-kernel,
	linux-arm-kernel

> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-06 18:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-30 18:08 [PATCH] firmware: raspberrypi: Define timeout for transactions Stefan Wahren
2018-10-31 17:16 ` Eric Anholt
2018-11-06 18:13   ` Stefan Wahren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).