Received: by 10.223.176.5 with SMTP id f5csp325191wra; Sat, 3 Feb 2018 00:02:32 -0800 (PST) X-Google-Smtp-Source: AH8x225oCncF0Fn/cmYC31uE1VB3eW9XxH3EglcW8/VyyJ67S1F7MJsqHAfjOsfePjgEJz5yWVl5 X-Received: by 10.98.66.152 with SMTP id h24mr42355865pfd.13.1517644952735; Sat, 03 Feb 2018 00:02:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517644952; cv=none; d=google.com; s=arc-20160816; b=JPywfCOBJAtlkOf73vqdrPbz+XqrvFloMlXI7jPJj8lN/ry2jzJcZDfgE2RrdCnQzf BTOHEbp5tV5qkC5JGQUrNNrRBFrDTwZRZG4FBqvZASKg0qct+VInx2zjD65yiXXb5VWV r2E30LQchGMmWVk/MgVnTFgsHp6tXMJZbtgoKswBZk2wzF6sCvvCf1StREFt+7hJi9BV 194ilG5L2DwD1vHwNCoC/EFbxmBpHjw/X2g1NqJMTVfNrp/NO9yEwcn0Uz8cDuBavwoV APNsOXm2sSJC7WNv0kTIkxUkVKqkCJjYPF/L/JON2R/1xHQFlZOrXfPH8fmuurXDcW3H o1LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=SAHj5qUCXAkhiUnEnSHRT4p2BrEyQftchKENUW92TEQ=; b=0URyf4EBFLTvxxV0JjhGRFTEM7TVjDF2Z63CsxOp/FeE7pjyuNA5gxho6xmmIsdopW Xw/2HPtkkj3Tw58KLPnE7i0JPWe8VzzOj5BhDuvJZYYHObM/4QY0Hp9ujm4DE00T3tPr 4B5vrnTfOHBo+swSEhSXFl0y9eiU12h7L7FLkB3XiB3Fh1h1jRBmLAXD3FbOkZtnRKzu ThS5xyO7WORyXuKGDV6GwPAbthFiNwUylG6jg7qSxA7q5mtCYBu2E6njpRgDnBChmcTL me+bWuKlLGg60nXJgquAfHVl8mPTyEZZeKfPFyXpJyNDcVEhyzutW5uc+BB9rOGPqw/3 4PNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Wuzo0TWL; dkim=pass header.i=@codeaurora.org header.s=default header.b=Wuzo0TWL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o68si1345934pfk.327.2018.02.03.00.02.17; Sat, 03 Feb 2018 00:02:32 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=Wuzo0TWL; dkim=pass header.i=@codeaurora.org header.s=default header.b=Wuzo0TWL; 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 S1752444AbeBCIAU (ORCPT + 99 others); Sat, 3 Feb 2018 03:00:20 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:35738 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751990AbeBCH64 (ORCPT ); Sat, 3 Feb 2018 02:58:56 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 923976081C; Sat, 3 Feb 2018 07:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517644734; bh=gV1eZO2ojt2yjT1z9pwIpVLseowmQC2d0qINcLyECNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wuzo0TWLUwVqISvQVD5wG88Im43S/Oogzix8RL3iBmi6c2+YzWXf0+CiEsSk8unpz 7baxyTUoEFdsz3Qz+E4jPuf8fUQQ6cynpDW/yRFRmP463zZHuDen/s0aPcduDRHm1z n08a2yuY1NdiNWvyi2KQhEoofA0w+gttI8hkOI/g= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from absahu-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7A6DF6081C; Sat, 3 Feb 2018 07:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517644734; bh=gV1eZO2ojt2yjT1z9pwIpVLseowmQC2d0qINcLyECNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wuzo0TWLUwVqISvQVD5wG88Im43S/Oogzix8RL3iBmi6c2+YzWXf0+CiEsSk8unpz 7baxyTUoEFdsz3Qz+E4jPuf8fUQQ6cynpDW/yRFRmP463zZHuDen/s0aPcduDRHm1z n08a2yuY1NdiNWvyi2KQhEoofA0w+gttI8hkOI/g= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7A6DF6081C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: Andy Gross , Wolfram Sang Cc: David Brown , Sricharan R , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Abhishek Sahu Subject: [PATCH 08/12] i2c: qup: change completion timeout according to transfer length Date: Sat, 3 Feb 2018 13:28:13 +0530 Message-Id: <1517644697-30806-9-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1517644697-30806-1-git-send-email-absahu@codeaurora.org> References: <1517644697-30806-1-git-send-email-absahu@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the completion timeout is being taken according to maximum transfer length which is too high if SCL is operating in high frequency. This patch calculates timeout on the basis of one-byte transfer time and uses the same for completion timeout. Signed-off-by: Abhishek Sahu --- drivers/i2c/busses/i2c-qup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c index a91fc70..6df65ea 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c @@ -130,8 +130,8 @@ #define MX_TX_RX_LEN SZ_64K #define MX_BLOCKS (MX_TX_RX_LEN / QUP_READ_LIMIT) -/* Max timeout in ms for 32k bytes */ -#define TOUT_MAX 300 +/* Min timeout for i2c transfers */ +#define TOUT_MIN 2 /* Default values. Use these if FW query fails */ #define DEFAULT_CLK_FREQ 100000 @@ -172,6 +172,7 @@ struct qup_i2c_dev { int in_blk_sz; unsigned long one_byte_t; + unsigned long xfer_timeout; struct qup_i2c_block blk; struct i2c_msg *msg; @@ -845,7 +846,7 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, dma_async_issue_pending(qup->brx.dma); } - if (!wait_for_completion_timeout(&qup->xfer, TOUT_MAX * HZ)) { + if (!wait_for_completion_timeout(&qup->xfer, qup->xfer_timeout)) { dev_err(qup->dev, "normal trans timed out\n"); ret = -ETIMEDOUT; } @@ -1601,6 +1602,8 @@ static int qup_i2c_probe(struct platform_device *pdev) */ one_bit_t = (USEC_PER_SEC / clk_freq) + 1; qup->one_byte_t = one_bit_t * 9; + qup->xfer_timeout = TOUT_MIN * HZ + + usecs_to_jiffies(MX_TX_RX_LEN * qup->one_byte_t); dev_dbg(qup->dev, "IN:block:%d, fifo:%d, OUT:block:%d, fifo:%d\n", qup->in_blk_sz, qup->in_fifo_sz, -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation