From patchwork Fri Apr 11 06:36:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harini Katakam X-Patchwork-Id: 3966211 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ED3E1BFF02 for ; Fri, 11 Apr 2014 06:36:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 319662080A for ; Fri, 11 Apr 2014 06:36:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BC0E2080B for ; Fri, 11 Apr 2014 06:36:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750861AbaDKGgf (ORCPT ); Fri, 11 Apr 2014 02:36:35 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:47373 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750817AbaDKGgf (ORCPT ); Fri, 11 Apr 2014 02:36:35 -0400 Received: by mail-pd0-f179.google.com with SMTP id w10so4908785pde.10 for ; Thu, 10 Apr 2014 23:36:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=Rxwdk8275SDohCUJsfF2G7683E37Y4Ibqg2POc9RgEk=; b=YvJWISaG8KpPa+FViSdurwDJMwc+N/Z8hActSBVP2qWAv4nU5lMYA4IXWl+SnNJL+N C7N6BEn7pBp44GjEEwTXYnOmvyGInRIPHZJzSgSww4iQBzdDOQFnthC+VvrA355AzrnX IgmXL3yaCozzSsey2mIlOfYE+CKKd0oMV9W944Y7FQp+iZYlpXjac0y1qy29quYpkZge ss7QmY9s3r4xImdVbPcHyTUpVe+aPl5ux0g3XPXs/SaxgV9DouOJjwzcYGNGGsfpjauL JPT03NARMf0FfrBFhFf4mcQdNvGlGsNSatGvlyfLSIcfbkToSkvVT8vhpNky17zFUQQC LDtg== X-Received: by 10.68.160.163 with SMTP id xl3mr25200323pbb.39.1397198194864; Thu, 10 Apr 2014 23:36:34 -0700 (PDT) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id au16sm31146495pac.27.2014.04.10.23.36.33 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 10 Apr 2014 23:36:34 -0700 (PDT) From: Harini Katakam To: broonie@kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: michals@xilinx.com, Harini Katakam Subject: [PATCH v2] spi: core: Increase timeout value Date: Fri, 11 Apr 2014 12:06:28 +0530 Message-Id: <1397198188-8602-1-git-send-email-harinik@xilinx.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The existing timeout value in wait_for_completion_timeout is calculated from the transfer length and speed with tolerance of 10msec. This is too low because this is used for error conditions such as hardware hang etc. The xfer->speed_hz considered may not be the actual speed set because the best clock divisor is chosen from a limited set such that the actual speed <= requested speed. This will lead to timeout being less than actual transfer time. Considering acceptable latencies, this timeout can be set to a value double the expected transfer plus 100 msecs. This patch adds the same in the core. Signed-off-by: Harini Katakam --- v2 changes: Decrease timeout - make it double of expected time + 100ms --- 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 4eb9bf0..f01cbb4 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -775,7 +775,7 @@ static int spi_transfer_one_message(struct spi_master *master, if (ret > 0) { ret = 0; ms = xfer->len * 8 * 1000 / xfer->speed_hz; - ms += 10; /* some tolerance */ + ms += ms + 100; /* some tolerance */ ms = wait_for_completion_timeout(&master->xfer_completion, msecs_to_jiffies(ms));