From patchwork Sun Apr 16 23:38:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 9683267 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 4DF6E60138 for ; Sun, 16 Apr 2017 23:38:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 329B027BFF for ; Sun, 16 Apr 2017 23:38:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14CF727CF3; Sun, 16 Apr 2017 23:38: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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 29CF927BFF for ; Sun, 16 Apr 2017 23:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932279AbdDPXiO (ORCPT ); Sun, 16 Apr 2017 19:38:14 -0400 Received: from hauke-m.de ([5.39.93.123]:48292 "EHLO mail.hauke-m.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932220AbdDPXiN (ORCPT ); Sun, 16 Apr 2017 19:38:13 -0400 Received: from hauke-desktop.lan (p200300862815A4000448AFEC5571D1D9.dip0.t-ipconnect.de [IPv6:2003:86:2815:a400:448:afec:5571:d1d9]) by mail.hauke-m.de (Postfix) with ESMTPSA id 9F32E100310; Mon, 17 Apr 2017 01:38:09 +0200 (CEST) From: Hauke Mehrtens To: broonie@kernel.org Cc: linux-spi@vger.kernel.org, Hauke Mehrtens Subject: [PATCH] spi: double time out tolerance Date: Mon, 17 Apr 2017 01:38:05 +0200 Message-Id: <20170416233805.15973-1-hauke@hauke-m.de> X-Mailer: git-send-email 2.11.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The generic SPI code calculates how long the issued transfer would take and adds 100ms in addition to the timeout as tolerance. On my 500 MHz Lantiq Mips SoC I am getting timeouts from the SPI like this when the system boots up: m25p80 spi32766.4: SPI transfer timed out blk_update_request: I/O error, dev mtdblock3, sector 2 SQUASHFS error: squashfs_read_data failed to read block 0x6e After increasing the tolerance for the timeout to 200ms I haven't seen these SPI transfer time outs any more. The Lantiq SPI driver in use here has an extra work queue in between, which gets triggered when the controller send the last word and the hardware FIFOs used for reading and writing are only 8 words long. Signed-off-by: Hauke Mehrtens --- drivers/spi/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 90b5b2efafbf..b4a8bb7759b2 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1015,7 +1015,7 @@ static int spi_transfer_one_message(struct spi_master *master, ret = 0; ms = 8LL * 1000LL * xfer->len; do_div(ms, xfer->speed_hz); - ms += ms + 100; /* some tolerance */ + ms += ms + 200; /* some tolerance */ if (ms > UINT_MAX) ms = UINT_MAX;