]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
firmware: raspberrypi: Define timeout for transactions
authorStefan Wahren <stefan.wahren@i2se.com>
Sat, 6 Oct 2018 11:31:56 +0000 (13:31 +0200)
committerStefan Wahren <stefan.wahren@i2se.com>
Wed, 14 Nov 2018 19:46:18 +0000 (20:46 +0100)
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>
drivers/firmware/raspberrypi.c

index a200a217461191b796105682e599582bb736683e..bf45ac4509544564bce6c5474d865366c45b65d0 100644 (file)
@@ -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);
        }