From patchwork Thu Dec 10 16:29:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 58226 Delivered-To: patch@linaro.org Received: by 10.112.147.194 with SMTP id tm2csp600096lbb; Thu, 10 Dec 2015 08:29:40 -0800 (PST) X-Received: by 10.66.142.168 with SMTP id rx8mr17830570pab.16.1449764980458; Thu, 10 Dec 2015 08:29:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9si6840551pfi.198.2015.12.10.08.29.40; Thu, 10 Dec 2015 08:29:40 -0800 (PST) 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 S1753183AbbLJQ3i (ORCPT + 28 others); Thu, 10 Dec 2015 11:29:38 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:45072 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751511AbbLJQ3f (ORCPT ); Thu, 10 Dec 2015 11:29:35 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id tBAGTA86020333; Thu, 10 Dec 2015 10:29:10 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id tBAGTA5j029737; Thu, 10 Dec 2015 10:29:10 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Thu, 10 Dec 2015 10:29:10 -0600 Received: from psplinux063.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id tBAGT5H6000390; Thu, 10 Dec 2015 10:29:08 -0600 From: Sekhar Nori To: Mark Brown CC: Grygorii Strashko , , Linux ARM Mailing List , Subject: [PATCH v2 1/2] spi: davinci: fix spurious i/o error Date: Thu, 10 Dec 2015 21:59:04 +0530 Message-ID: X-Mailer: git-send-email 2.6.3 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org davinci_spi_bufs() uses wait_for_completion_interruptible() without bothering to handle -ERESTARTSYS. Due to this, sometime, it returns prematurely when a signal is received. Since the return value is never checked, userspace eventually receives a spurious -EIO. To fix this, use un-interruptible wait_for_completion_timeout(). Signed-off-by: Sekhar Nori --- drivers/spi/spi-davinci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 7d3af3eacf57..57d6960a6252 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -703,7 +703,8 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t) /* Wait for the transfer to complete */ if (spicfg->io_type != SPI_IO_TYPE_POLL) { - wait_for_completion_interruptible(&(dspi->done)); + if (wait_for_completion_timeout(&dspi->done, HZ) == 0) + errors = SPIFLG_TIMEOUT_MASK; } else { while (dspi->rcount > 0 || dspi->wcount > 0) { errors = davinci_spi_process_events(dspi);