From patchwork Tue Oct 30 18:08:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 10661375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 497C214DE for ; Tue, 30 Oct 2018 18:12:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46F432AA2E for ; Tue, 30 Oct 2018 18:12:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 450D42AA35; Tue, 30 Oct 2018 18:12:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BEE682AA41 for ; Tue, 30 Oct 2018 18:12:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=eiEv9PZsHeOM8OUNZZrqF9HN1z+3m1Ecx3WvarpgT7Y=; b=tDR 0lMdSaXNxAUWHYWIrcA905vfeqpbPPWVVwpvPjdn3gFaSagDrPTmjSTD2PNtQngZ5+vDX90aEd9D3 +XgxO8ulcEbrS8EGeWk7U1Hte76c8cfkGywHjfoGtGQhKDcGM30N57u36vl+ZYXEukgfXPZO+64Hb VBVOMCXsEUU2c1wsY9nc8MzKHNv+3bac0acmZUOWrsI/SPhbkMvhbNAmkHAIUyh0YjpqkrnB638HX Qo2a84NlBg9JOEDxOm5UwpDjYXGqK57nH0KsvjU2gKVujQJ3biT2uZvy/RUjbXxdRotTQn4f/Vncf +ewbD08erqyVJu7KrEjmEXtqoTBxmvQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHYUp-0006T6-5F; Tue, 30 Oct 2018 18:12:07 +0000 Received: from mout.kundenserver.de ([212.227.126.133]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHYUX-0006MB-7a; Tue, 30 Oct 2018 18:11:52 +0000 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 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-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= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181030_111149_593422_8E3CF8D0 X-CRM114-Status: GOOD ( 13.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Wahren , Florian Fainelli , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); }