From patchwork Thu Aug 27 14:32:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 11740767 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68D8313B6 for ; Thu, 27 Aug 2020 14:33:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E0022087D for ; Thu, 27 Aug 2020 14:33:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O9YBfaWi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E0022087D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lucaceresoli.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=u/xR30qCzY9s/li920Nk49O732bHuLhGnD/vW9Jk/So=; b=O9YBfaWijO0nt61TNtF6Klf9Yd O0LJgqXxITdHKcxp/EW5rK9HXyzgFqe0eiDDNjnEfymQ52aR2Ei4js8It5n8kD8lbq788QVyadbRc swz+pVQ5J22hB2td4yrJegvxIHtGKrNgzSxB3zLIESFCRLgu5yE3Q1Wi3anmmiycdhpg7buiFDChL zyq1XmcUrgK/YIiOwjTDc6Jf1pNLUU3eTsO+NV2nKin1ozJnObyq4oohFkQGt1SiXxNfvuEZl5pQa ry+fm4KF/pWPLjT7B4E4wVOruW0+A3jxiDFZdOs+OoS2wkQeldoxY/N2ZT4Zgg/V4ubPn2GEo7jVS RT5Zp62g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBIxc-0002ZT-Ov; Thu, 27 Aug 2020 14:33:04 +0000 Received: from hostingweb31-40.netsons.net ([89.40.174.40]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBIxZ-0002Xg-P7 for linux-arm-kernel@lists.infradead.org; Thu, 27 Aug 2020 14:33:02 +0000 Received: from [78.134.86.56] (port=49228 helo=melee.fritz.box) by hostingweb31.netsons.net with esmtpa (Exim 4.93) (envelope-from ) id 1kBIxY-0006H2-J7; Thu, 27 Aug 2020 16:33:00 +0200 From: Luca Ceresoli To: linux-fpga@vger.kernel.org Subject: [PATCH v2 1/5] fpga manager: xilinx-spi: remove stray comment Date: Thu, 27 Aug 2020 16:32:45 +0200 Message-Id: <20200827143249.10973-1-luca@lucaceresoli.net> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca+lucaceresoli.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200827_103301_941328_E414E572 X-CRM114-Status: UNSURE ( 7.96 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [89.40.174.40 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Rix , Michal Simek , linux-kernel@vger.kernel.org, Moritz Fischer , Luca Ceresoli , Anatolij Gustschin , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Remove comment committed by mistake. Fixes: dd2784c01d93 ("fpga manager: xilinx-spi: check INIT_B pin during write_init") Signed-off-by: Luca Ceresoli --- Changes in v2: none. Note: Moritz replied "Applied to for-next", but it doesn't show up yet. --- drivers/fpga/xilinx-spi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/fpga/xilinx-spi.c b/drivers/fpga/xilinx-spi.c index 2967aa2a74e2..502fae0d1d85 100644 --- a/drivers/fpga/xilinx-spi.c +++ b/drivers/fpga/xilinx-spi.c @@ -57,7 +57,6 @@ static int wait_for_init_b(struct fpga_manager *mgr, int value, if (conf->init_b) { while (time_before(jiffies, timeout)) { - /* dump_state(conf, "wait for init_d .."); */ if (gpiod_get_value(conf->init_b) == value) return 0; usleep_range(100, 400); From patchwork Thu Aug 27 14:32:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 11740769 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D963109B for ; Thu, 27 Aug 2020 14:33:20 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 641C922B4E for ; Thu, 27 Aug 2020 14:33:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pC4bcIXW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 641C922B4E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lucaceresoli.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=Cvdea+sh8t3X1NQ1pIrDQLB59E2p9Qnx7sOdCT3H/0w=; b=pC4bcIXW14LPKQ/yEHOypjvGp /FUhyN2gCYMtNGFobkeWVoU/BdQiNTyxihlqjPiYfGgUw+kD//+ph8CAp6Gqx3nWiUJ6Kji3aekYf 1EEzHu3j4q+QW1AkBwvRkpFYaGp888LSvXFRskjUbfIi9CfC5CSXBCJOwABQgRfyvvdu8cqQSrJfr m2ShNVh2xlvrIq0HVdtac30r9ReP+2lm1q/zWpecemOMbm2gHv1j5GQOIAIo+5zgYyi31TwKyXBcQ JpjclsCK9eom+/FADRB8FWO9DEpcR94FD+6e9t1CskhxcZP1naK+JiG5LP9IGcb83QetXLkVt/Enf mgBWJCedA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBIxh-0002aJ-66; Thu, 27 Aug 2020 14:33:09 +0000 Received: from hostingweb31-40.netsons.net ([89.40.174.40]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBIxZ-0002Xi-SH for linux-arm-kernel@lists.infradead.org; Thu, 27 Aug 2020 14:33:02 +0000 Received: from [78.134.86.56] (port=49228 helo=melee.fritz.box) by hostingweb31.netsons.net with esmtpa (Exim 4.93) (envelope-from ) id 1kBIxY-0006H2-U4; Thu, 27 Aug 2020 16:33:01 +0200 From: Luca Ceresoli To: linux-fpga@vger.kernel.org Subject: [PATCH v2 2/5] fpga manager: xilinx-spi: remove final dot from dev_err() strings Date: Thu, 27 Aug 2020 16:32:46 +0200 Message-Id: <20200827143249.10973-2-luca@lucaceresoli.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200827143249.10973-1-luca@lucaceresoli.net> References: <20200827143249.10973-1-luca@lucaceresoli.net> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca+lucaceresoli.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200827_103302_041913_70DB0943 X-CRM114-Status: UNSURE ( 9.28 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [89.40.174.40 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Rix , Michal Simek , linux-kernel@vger.kernel.org, Moritz Fischer , Luca Ceresoli , Anatolij Gustschin , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Most dev_err messages in this file have no final dot. Remove the only two exceptions to make them consistent. Signed-off-by: Luca Ceresoli --- Changes in v2: - move before the "provide better diagnostics on programming failure" patch for clarity --- drivers/fpga/xilinx-spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/xilinx-spi.c b/drivers/fpga/xilinx-spi.c index 502fae0d1d85..01f494172379 100644 --- a/drivers/fpga/xilinx-spi.c +++ b/drivers/fpga/xilinx-spi.c @@ -77,7 +77,7 @@ static int xilinx_spi_write_init(struct fpga_manager *mgr, int err; if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) { - dev_err(&mgr->dev, "Partial reconfiguration not supported.\n"); + dev_err(&mgr->dev, "Partial reconfiguration not supported\n"); return -EINVAL; } @@ -169,7 +169,7 @@ static int xilinx_spi_write_complete(struct fpga_manager *mgr, return xilinx_spi_apply_cclk_cycles(conf); } - dev_err(&mgr->dev, "Timeout after config data transfer.\n"); + dev_err(&mgr->dev, "Timeout after config data transfer\n"); return -ETIMEDOUT; } From patchwork Thu Aug 27 14:32:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 11740787 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20F83109B for ; Thu, 27 Aug 2020 14:34:40 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED3F72177B for ; Thu, 27 Aug 2020 14:34:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Z34SCglD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED3F72177B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lucaceresoli.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=U51tVrROQ1tiRj5AEhjMJHQzst0kmpgut74TS7bkXQw=; b=Z34SCglDZmNmgUGafW6/gATiN d7/xG/D+UkMxie+ShJ1ACQiz1WFX5+H4tCjnG38QBHxBec7GreYZ+lzxLT0uf5Oh2VaVGJ18zWRz4 cFqd27F/MHSiND1UGxXy9m/kuSeD9hmsb7A6fec04m5lXEJw7QDMBiGkQ4Yr+iCkyu1XsUmkwMfgw cU0dZVXQmgS7xeUMyMwGHXkuWP9+FsDg5yTA+EVGvVjdzSuItwZpmLfGiyDifFcciiIBWpo8WVEMC iCTcB5Wc1xVZP7M5be9rED8h7VKGUIidBdubiAddwdh4k2M17qL0iLbRAHoIYFop9Pn70P/mJIuMJ 11JAlEirw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBIxk-0002bC-St; Thu, 27 Aug 2020 14:33:13 +0000 Received: from hostingweb31-40.netsons.net ([89.40.174.40]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBIxa-0002Xk-5A for linux-arm-kernel@lists.infradead.org; Thu, 27 Aug 2020 14:33:03 +0000 Received: from [78.134.86.56] (port=49228 helo=melee.fritz.box) by hostingweb31.netsons.net with esmtpa (Exim 4.93) (envelope-from ) id 1kBIxZ-0006H2-83; Thu, 27 Aug 2020 16:33:01 +0200 From: Luca Ceresoli To: linux-fpga@vger.kernel.org Subject: [PATCH v2 3/5] fpga manager: xilinx-spi: rework write_complete loop implementation Date: Thu, 27 Aug 2020 16:32:47 +0200 Message-Id: <20200827143249.10973-3-luca@lucaceresoli.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200827143249.10973-1-luca@lucaceresoli.net> References: <20200827143249.10973-1-luca@lucaceresoli.net> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca+lucaceresoli.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200827_103302_310503_4546A964 X-CRM114-Status: GOOD ( 10.62 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [89.40.174.40 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Rix , Michal Simek , linux-kernel@vger.kernel.org, Moritz Fischer , Luca Ceresoli , Anatolij Gustschin , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In preparation to add error checking for gpiod_get_value(), rework the loop to avoid the duplication of these lines: if (gpiod_get_value(conf->done)) return xilinx_spi_apply_cclk_cycles(conf); There is little advantage in this rework with current code. However error checking will expand these two lines to five, making code duplication more annoying. Signed-off-by: Luca Ceresoli --- This patch is new in v2 --- drivers/fpga/xilinx-spi.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/fpga/xilinx-spi.c b/drivers/fpga/xilinx-spi.c index 01f494172379..cfc933d70f52 100644 --- a/drivers/fpga/xilinx-spi.c +++ b/drivers/fpga/xilinx-spi.c @@ -151,22 +151,19 @@ static int xilinx_spi_write_complete(struct fpga_manager *mgr, struct fpga_image_info *info) { struct xilinx_spi_conf *conf = mgr->priv; - unsigned long timeout; + unsigned long timeout = jiffies + usecs_to_jiffies(info->config_complete_timeout_us); int ret; - if (gpiod_get_value(conf->done)) - return xilinx_spi_apply_cclk_cycles(conf); - - timeout = jiffies + usecs_to_jiffies(info->config_complete_timeout_us); + while (true) { + if (gpiod_get_value(conf->done)) + return xilinx_spi_apply_cclk_cycles(conf); - while (time_before(jiffies, timeout)) { + if (time_after(jiffies, timeout)) + break; ret = xilinx_spi_apply_cclk_cycles(conf); if (ret) return ret; - - if (gpiod_get_value(conf->done)) - return xilinx_spi_apply_cclk_cycles(conf); } dev_err(&mgr->dev, "Timeout after config data transfer\n"); From patchwork Thu Aug 27 14:32:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 11740779 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D75F13B6 for ; Thu, 27 Aug 2020 14:33:30 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4470F2087D for ; Thu, 27 Aug 2020 14:33:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BtdD028S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4470F2087D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lucaceresoli.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=yEsqoWX2cJRsmNOS7I5e9CqYPH4/1ftj5oV7YjL59c0=; b=BtdD028Sh2307bzNBYBIQ4jgq v2hHG3TBsfJl2bKG04eGWVisDjYD53MmZJze3ToK5zPhjRIKgdC816XKgKeK4hBGSOAD89irJvuLW 8ChwUNSShjtIzQ4+lQ7Gts1KrkUhoWW/OV6LoDvlY1fhQz9+s0U/QNGq934A2X2Z8rOzPX2eupbdz GJJPUth/ep9WevNoQaPYiWclgue7A9XGo0ftgpOQ7ZJpEoFHHBUNccRrp7EYHJXjjkSj5/JSSX60c gYFVRmTuhAxGjpiibwGzE9RiwcQDJAr3PVTiSCCgxPjBb93j2qax+qlFXSkly8uvKXZSv/IdJCaJF cCxiTARRg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBIxo-0002bu-T3; Thu, 27 Aug 2020 14:33:16 +0000 Received: from hostingweb31-40.netsons.net ([89.40.174.40]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBIxa-0002Xm-Fm for linux-arm-kernel@lists.infradead.org; Thu, 27 Aug 2020 14:33:03 +0000 Received: from [78.134.86.56] (port=49228 helo=melee.fritz.box) by hostingweb31.netsons.net with esmtpa (Exim 4.93) (envelope-from ) id 1kBIxZ-0006H2-HF; Thu, 27 Aug 2020 16:33:01 +0200 From: Luca Ceresoli To: linux-fpga@vger.kernel.org Subject: [PATCH v2 4/5] fpga manager: xilinx-spi: add error checking after gpiod_get_value() Date: Thu, 27 Aug 2020 16:32:48 +0200 Message-Id: <20200827143249.10973-4-luca@lucaceresoli.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200827143249.10973-1-luca@lucaceresoli.net> References: <20200827143249.10973-1-luca@lucaceresoli.net> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca+lucaceresoli.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200827_103302_737012_69EC4573 X-CRM114-Status: GOOD ( 13.37 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [89.40.174.40 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Rix , Michal Simek , linux-kernel@vger.kernel.org, Moritz Fischer , Luca Ceresoli , Anatolij Gustschin , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Current code calls gpiod_get_value() without error checking. Should the GPIO controller fail, execution would continue without any error message. Fix by checking for negative error values. Reported-by: Tom Rix Signed-off-by: Luca Ceresoli Reviewed-by: Tom Rix --- This patch is new in v2 --- drivers/fpga/xilinx-spi.c | 40 ++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/drivers/fpga/xilinx-spi.c b/drivers/fpga/xilinx-spi.c index cfc933d70f52..bcc740ec42f5 100644 --- a/drivers/fpga/xilinx-spi.c +++ b/drivers/fpga/xilinx-spi.c @@ -27,11 +27,22 @@ struct xilinx_spi_conf { struct gpio_desc *done; }; -static enum fpga_mgr_states xilinx_spi_state(struct fpga_manager *mgr) +static int get_done_gpio(struct fpga_manager *mgr) { struct xilinx_spi_conf *conf = mgr->priv; + int ret; + + ret = gpiod_get_value(conf->done); - if (!gpiod_get_value(conf->done)) + if (ret < 0) + dev_err(&mgr->dev, "Error reading DONE (%d)\n", ret); + + return ret; +} + +static enum fpga_mgr_states xilinx_spi_state(struct fpga_manager *mgr) +{ + if (!get_done_gpio(mgr)) return FPGA_MGR_STATE_RESET; return FPGA_MGR_STATE_UNKNOWN; @@ -57,10 +68,21 @@ static int wait_for_init_b(struct fpga_manager *mgr, int value, if (conf->init_b) { while (time_before(jiffies, timeout)) { - if (gpiod_get_value(conf->init_b) == value) + int ret = gpiod_get_value(conf->init_b); + + if (ret == value) return 0; + + if (ret < 0) { + dev_err(&mgr->dev, "Error reading INIT_B (%d)\n", ret); + return ret; + } + usleep_range(100, 400); } + + dev_err(&mgr->dev, "Timeout waiting for INIT_B to %s\n", + value ? "assert" : "deassert"); return -ETIMEDOUT; } @@ -85,7 +107,6 @@ static int xilinx_spi_write_init(struct fpga_manager *mgr, err = wait_for_init_b(mgr, 1, 1); /* min is 500 ns */ if (err) { - dev_err(&mgr->dev, "INIT_B pin did not go low\n"); gpiod_set_value(conf->prog_b, 0); return err; } @@ -93,12 +114,10 @@ static int xilinx_spi_write_init(struct fpga_manager *mgr, gpiod_set_value(conf->prog_b, 0); err = wait_for_init_b(mgr, 0, 0); - if (err) { - dev_err(&mgr->dev, "INIT_B pin did not go high\n"); + if (err) return err; - } - if (gpiod_get_value(conf->done)) { + if (get_done_gpio(mgr)) { dev_err(&mgr->dev, "Unexpected DONE pin state...\n"); return -EIO; } @@ -155,7 +174,10 @@ static int xilinx_spi_write_complete(struct fpga_manager *mgr, int ret; while (true) { - if (gpiod_get_value(conf->done)) + ret = get_done_gpio(mgr); + if (ret < 0) + return ret; + if (ret) return xilinx_spi_apply_cclk_cycles(conf); if (time_after(jiffies, timeout)) From patchwork Thu Aug 27 14:32:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 11740789 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5906109B for ; Thu, 27 Aug 2020 14:34:43 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D34E2177B for ; Thu, 27 Aug 2020 14:34:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="2q+RGZa8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D34E2177B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lucaceresoli.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=cu0U+M7C8ZJ0iJSoc/hl8C/EaY4NOKrGtMrkX/1cP0k=; b=2q+RGZa8aM5n9K6OJDz6Hyv0q yVJ/mMYVb7d2TD4Ha0SopD1H6uFiijR4lpCnIVmIxqNm0Dlg0p4kpOj2Pt8R99hJJu0h+dV+BW7fA QAttvxbhyBtfYMXKsNXS0O6TUMs9TRO6xDQuVKae3LpX244L4x4YTQ8DvXpQ5F3xJz4TO6vCTBJ2s UqUSfcT8UPQaNfibu+QPcn3jS5lnV4Wx3+Po91UaM7HjC640Zt0HJ6Oqrvh/qaDc7NG7Ti1Dc1FfT w4ks3WUKVZk0wusNyMIUYm3/Z5fbAQkF+1jrIAoa5ztR93YbF1kPD6jPO3CB2ynYta3aS+1RRJbc8 OF3l3craw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBIxv-0002dV-6z; Thu, 27 Aug 2020 14:33:23 +0000 Received: from hostingweb31-40.netsons.net ([89.40.174.40]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBIxa-0002Y9-Pw for linux-arm-kernel@lists.infradead.org; Thu, 27 Aug 2020 14:33:03 +0000 Received: from [78.134.86.56] (port=49228 helo=melee.fritz.box) by hostingweb31.netsons.net with esmtpa (Exim 4.93) (envelope-from ) id 1kBIxZ-0006H2-Ql; Thu, 27 Aug 2020 16:33:01 +0200 From: Luca Ceresoli To: linux-fpga@vger.kernel.org Subject: [PATCH v2 5/5] fpga manager: xilinx-spi: provide better diagnostics on programming failure Date: Thu, 27 Aug 2020 16:32:49 +0200 Message-Id: <20200827143249.10973-5-luca@lucaceresoli.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200827143249.10973-1-luca@lucaceresoli.net> References: <20200827143249.10973-1-luca@lucaceresoli.net> MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca+lucaceresoli.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200827_103302_984436_DCE6EAE4 X-CRM114-Status: GOOD ( 10.59 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [89.40.174.40 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Rix , Michal Simek , linux-kernel@vger.kernel.org, Moritz Fischer , Luca Ceresoli , Anatolij Gustschin , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When the DONE pin does not go high after programming to confirm programming success, the INIT_B pin provides some info on the reason. Use it if available to provide a more explanatory error message. Signed-off-by: Luca Ceresoli Reviewed-by: Tom Rix --- Changes in v2: - also check for gpiod_get_value() errors (Tom Rix) --- drivers/fpga/xilinx-spi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/xilinx-spi.c b/drivers/fpga/xilinx-spi.c index bcc740ec42f5..ea0351be8eee 100644 --- a/drivers/fpga/xilinx-spi.c +++ b/drivers/fpga/xilinx-spi.c @@ -188,7 +188,21 @@ static int xilinx_spi_write_complete(struct fpga_manager *mgr, return ret; } - dev_err(&mgr->dev, "Timeout after config data transfer\n"); + if (conf->init_b) { + ret = gpiod_get_value(conf->init_b); + + if (ret < 0) { + dev_err(&mgr->dev, "Error reading INIT_B (%d)\n", ret); + return ret; + } + + dev_err(&mgr->dev, + ret ? "CRC error or invalid device\n" + : "Missing sync word or incomplete bitstream\n"); + } else { + dev_err(&mgr->dev, "Timeout after config data transfer\n"); + } + return -ETIMEDOUT; }