From patchwork Sun May 7 08:59:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 9715469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5960960380 for ; Sun, 7 May 2017 21:53:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ACB823B24 for ; Sun, 7 May 2017 21:53:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FA4926E16; Sun, 7 May 2017 21:53:50 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDC7023B24 for ; Sun, 7 May 2017 21:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755034AbdEGVxg (ORCPT ); Sun, 7 May 2017 17:53:36 -0400 Received: from www.osadl.org ([62.245.132.105]:37121 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752144AbdEGVxe (ORCPT ); Sun, 7 May 2017 17:53:34 -0400 Received: from debian01.hofrr.at (92-243-34-74.adsl.nanet.at [92.243.34.74] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id v478xmuX003681; Sun, 7 May 2017 10:59:48 +0200 From: Nicholas Mc Guire To: Alan Tull Cc: Moritz Fischer , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH RFC V2] fpga: socfpga: handle interrupted case as non-success Date: Sun, 7 May 2017 10:59:40 +0200 Message-Id: <1494147580-1391-1-git-send-email-der.herr@hofr.at> X-Mailer: git-send-email 2.1.4 Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP wait_for_completion_interruptible_timeout() can return 0 (timeout) or -ERESTARTSYS when interrupted - the current code treats the interrupted case as success which is wrong and could lead to hard to reproduce errors. Fix this by returning non-0 in both cases to the calling side. This also changes the timeout variable to the proper type as wait_for_completion_interruptible_timeout() returns long not int. Fixes: commit fab6266e82a8 ("fpga manager: add driver for socfpga fpga manager") Signed-off-by: Nicholas Mc Guire --- V2: the patch was not yet compile tested as I wanted to clarify the below issue first - but it got picked up by kbuild-test anyway so here is a compile-tested (and fixed) version - but the key issue still is to clarify if the use of the interruptible version actually makes sense here at all - I think it should be dropped. It is not really clear to me why the _interruptible_ version of wait_for_completion is in use here - so maybe the proper mitigation is to simply change the call to wait_for_completion_timeout() and drop the interrupted case all together as the timeout of 10ms is not that long that waiting for timeout would be problematic. Someone that knows the intent of selecting the _interruptible_ call would need to check if this is a more reasonable solution. Patch was compile tested with: socfpga_defconfig (implies CONFIG_FPGA_MGR_SOCFPGA) Patch is against v4.11 (localversion-next is next-20170505) drivers/fpga/socfpga.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/socfpga.c b/drivers/fpga/socfpga.c index b6672e6..532abd6 100644 --- a/drivers/fpga/socfpga.c +++ b/drivers/fpga/socfpga.c @@ -312,7 +312,8 @@ static irqreturn_t socfpga_fpga_isr(int irq, void *dev_id) static int socfpga_fpga_wait_for_config_done(struct socfpga_fpga_priv *priv) { - int timeout, ret = 0; + int ret = 0; + long timeout; socfpga_fpga_disable_irqs(priv); init_completion(&priv->status_complete); @@ -323,6 +324,8 @@ static int socfpga_fpga_wait_for_config_done(struct socfpga_fpga_priv *priv) msecs_to_jiffies(10)); if (timeout == 0) ret = -ETIMEDOUT; + else if (timeout == -ERESTARTSYS) + ret = -ERESTARTSYS; socfpga_fpga_disable_irqs(priv); return ret;