Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5099283imd; Tue, 30 Oct 2018 11:58:17 -0700 (PDT) X-Google-Smtp-Source: AJdET5dLwwYgtlJ1m/kDkN9RU7sxx2hlHEm2wZIWCU5A7f1eGOQe4pq4cbCt2NWRzK3RjNPsl38s X-Received: by 2002:a62:9109:: with SMTP id l9-v6mr680357pfe.154.1540925897609; Tue, 30 Oct 2018 11:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540925897; cv=none; d=google.com; s=arc-20160816; b=g47dnES7Vo2mFWyR6PN2rcz6ziMFCnyNo09sYqqg8cB56B01j2o5tyXi8x/mIvKmiw s9pZLe4miHm/9Cm6Rgee+zWmaPwECHA9wW6dCIuwhYFyQo6FgthHseqZ4wmpd/11KTnv OXBkytIOa62GmVteXYftgZliZqXr6XOd1E3CgKCcFasc8zhXojvORKV0bedVqWpm7LS0 3p1gqYJthMiAyIsrqxIz0ix0jsmBCegA6FkV/u2HfDRBuAeNXa5zRGTE5hz2/ma62DaH j7IVRTayZARaKJFTrebaY1aZt/MKtYLFk95jF/Vj0ockdIObbkpGU2VBDJtNav7nwyBW Nk8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=q5ic4oK+wlkGokdonwvrnJCY0aFe+pczfec2vFYGOJY=; b=Lp5iaUSNpOR3c6evzRodI2jjGAclxbmtkyTxz5VmGKi6IiebQ0SBPVNn/JV5j4GNry RW5RdmeR5ZQg9B32Xrjn9aYeVsi4K6bgU+TWdKvvUp8JdUJs4nXvFNDi4O1yKlWzxcxN aoyTPwr+frMo5Ktdvqg/nLAzDu/vh1XwQ5S1YTqHDkNQu6fd6oUoZTQvP2k8xCFx3JDP MbuV3OH+kIgTa+tyXGgUpWyatfdGy3Ma6OCvDfPHqqtC3smACaxqFmFvgaxLZ+gJM+ux V25jvjkEbBT6FbeVMXg976EpJJFGw8g/2KrYWVC4ao3tBRLrXkpElM8TCYpaXnb1QMUB P8xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g38-v6si20578587pgl.248.2018.10.30.11.57.43; Tue, 30 Oct 2018 11:58:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbeJaDGY (ORCPT + 99 others); Tue, 30 Oct 2018 23:06:24 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:35653 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727710AbeJaDGY (ORCPT ); Tue, 30 Oct 2018 23:06:24 -0400 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.167]) with ESMTPSA (Nemesis) id 0Lodqd-1fcPyU2d8V-00goTL; Tue, 30 Oct 2018 19:11:29 +0100 Received: from localhost.localdomain ([37.4.249.153]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.167]) with ESMTPSA (Nemesis) id 0Lodqd-1fcPyU2d8V-00goTL; Tue, 30 Oct 2018 19:11:29 +0100 From: Stefan Wahren To: Eric Anholt Cc: Arnd Bergmann , Florian Fainelli , linux-kernel@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH] firmware: raspberrypi: Define timeout for transactions Date: Tue, 30 Oct 2018 19:08:41 +0100 Message-Id: <1540922921-3653-1-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 2.7.4 X-Provags-ID: V03:K1:lSwBe9PbnboS7iat0lA9w6drv5kU3kjgJMIIrGKwzeCgcslTRqh +/7u+OZ4UwTmEvz/g63mI20Wb1fVW5n2uBCpC7sU9at2AQmjjHJtp2+kAoADyQgZOiUVHyP rTL0VfMsLz6Ar2UNRBIvoparyzxCtfHaU7k6broKQBef72BX7/u05jL0bTKKIGN/tu5FkDE 5rqEpidLOWU/wUvaEYw/A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V01:K0:6/mm5e1KIiA=:/vkzelrwI6HZ+dfGeYUpA8 ZTBrzuFzv3jNgGmjOJjLfuUy2JH6TTKqm6yUQJfeIvn1jLnri44wYPyB5W2KyXdCyaAsoUQVI c0OWFOKEkyVjh+LLZaDVJ4ahq61qgrD8MJW8vBfJFgLUQu+olmy5a89Qed4YjqEnNCQTu1TNC D+AMKEqfVte1TV1uZDxXVAnfX+mJPQMsWTQDHZSB3yOWXTZKFonfPu4kaorhNQzGFdQYmdaW8 UeBv17UljGklCLLS1w1kRyQ8kjz1KhVGUNZZKsnEGR1O9qQTZu/wdLgmI4v9uTE1F4KeuT1gh 3fBoCNSkvtopjXXf2QsuVpnY4y1sw5LyfI8JMiAKU0M28Un1VubwHXzNbpM1JBFOeTIh1k/cR E7Z9ye63BAUj+cp/+9CYWMjxDPY6aS5gNWEKYtwOeHco+ioIXy0EyFHhd9Iew6jn/Wa7LtSzf UckfyWvCVVewGTs+b1wcClHMYBoYbpxSfWc27NefrPUN2OF66UQ2XfZ3sS4abX+zxgPxrCMiO qhcJBgLnKWsECGYjvWusJESTkGxfSU6wx/yULMZ5fcOWmoCP7oiLOz/w3eQ0kmnk29Y5UW9GQ CaPEQE/sDeAtQ3HIqGixeG/gaTJP8TGOWF0tI3kr2jZCbIjCz7hn7Tqne3QA+0DeYubCefPzq maDfBSu45ZPU78w3KRe6YohmCjnCKHQRc53OQFWnh3YVn2P/Y1fAq2UN2717dcitXWD4= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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