From patchwork Tue Nov 24 10:34:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 57219 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1995872lbb; Tue, 24 Nov 2015 02:34:31 -0800 (PST) X-Received: by 10.98.7.129 with SMTP id 1mr21851219pfh.70.1448361271345; Tue, 24 Nov 2015 02:34:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k10si25866290pfj.72.2015.11.24.02.34.31; Tue, 24 Nov 2015 02:34:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-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-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752927AbbKXKea (ORCPT + 1 other); Tue, 24 Nov 2015 05:34:30 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:46650 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752867AbbKXKe2 (ORCPT ); Tue, 24 Nov 2015 05:34:28 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id tAOAY4eb026246; Tue, 24 Nov 2015 04:34:04 -0600 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id tAOAY37k025672; Tue, 24 Nov 2015 04:34:04 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Tue, 24 Nov 2015 04:34:03 -0600 Received: from psplinux063.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id tAOAY1bl025547; Tue, 24 Nov 2015 04:34:02 -0600 From: Sekhar Nori To: Mark Brown CC: , , Linux ARM Mailing List Subject: [PATCH] spi: davinci: fix spurious i/o error Date: Tue, 24 Nov 2015 16:04:01 +0530 Message-ID: <108883742c4b44d338ea0816abeeb2901a2afcd5.1448361028.git.nsekhar@ti.com> X-Mailer: git-send-email 2.4.4.408.g16da57c MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.4.4.408.g16da57c -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 7d3af3eacf57..38026aa1afd7 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -703,7 +703,10 @@ 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) { + dev_err(&spi->dev, "spi transfer timeout\n"); + return -ETIMEDOUT; + } } else { while (dspi->rcount > 0 || dspi->wcount > 0) { errors = davinci_spi_process_events(dspi);