Received: by 10.213.65.68 with SMTP id h4csp46705imn; Mon, 12 Mar 2018 06:18:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELsEl6FaeEsAiXRkDZLg75Uh3l+Lyw+AFSLXt9aSM9KM0UE2YXyKAQn/1R56c8Iw12q5HSzd X-Received: by 10.98.18.143 with SMTP id 15mr8094483pfs.104.1520860702021; Mon, 12 Mar 2018 06:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520860701; cv=none; d=google.com; s=arc-20160816; b=EWK5hFjpXs69Vr9r/VcLWJ4cUQ3Z/w5NVvNqWKuX0RN4ZHzNdbwVWpsZTQemNbhude nBXqQ3iTop/05mfMhsI0G8qg+I/UnOWmCw9EDjqjd9spTDHHvgWZLDNOHEPsj/C8cL/a HN6k7M9Y4xshmGQIXrxVNnKa5WIWnaXfFOa5ahj1+4DDuwtImBEuNao9rfTDbKp4Hkta RXNgY1FZf1XAf9jSEzyX/sC5tGCImL361/Gp53GdtIFy83+3l8Olu1RP+oElHLrH8iQW TxVxsp/TM1Q2eskFn8+xY3ONbeRAeXffq3VqcmqWZ5DH3YLC+Cx7MY9YOXW+bFjLP2np ITdQ== 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=iRh9bfJuycA93QNOOJldKrlf3zkDUhuWo5E0ACjYO8M=; b=oPgoF/6dI8pG9aTwHq5fSgM8Wz6VfEE+t7sbAVFpxg4b/K3d7S763uUznnUR2hjD/R +QMip+wxzxpE93G76YMhcIenjMjbWdq1+wiNPp7sOrXmM133J5Zw8EceDCrCxO7i3Sv5 lyUwJ52CmGzQ9jvxf5jfp5N1dzq4tfmUG0bsLH1NeuUZ3RSGziLnpBKVns2PMHorAJtv WVDn3CvhD4dSd3jLZ5r4IqWFKSnNbF0zUcuuEuY5ImC9fU5T95q3NFymFPEMieTVJkph w1oeL+UUsq3d4SvQfYv3f/+jPL3JDY6N6Zsyh3ike1/1xBfy3UlCEgn5vKSFnYqBsT3g WYrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=PdzquOKs; dkim=pass header.i=@codeaurora.org header.s=default header.b=k3czAZjm; 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 t1si4935617pgv.668.2018.03.12.06.18.07; Mon, 12 Mar 2018 06:18:21 -0700 (PDT) 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=PdzquOKs; dkim=pass header.i=@codeaurora.org header.s=default header.b=k3czAZjm; 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 S932385AbeCLNP7 (ORCPT + 99 others); Mon, 12 Mar 2018 09:15:59 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:42184 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932333AbeCLNPx (ORCPT ); Mon, 12 Mar 2018 09:15:53 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5C5BB60590; Mon, 12 Mar 2018 13:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520860553; bh=Jtcaff9UeqTOHsqqROrxeYLAPCHW5dbMo9cP/uvNdII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PdzquOKslr0Av29XLzjNE7f+uUw6Id8fzCI+JW5oyB0nJKCPTSrfrBXXb6FD2UbTt GAdXyNqQPKPIoCWOwXcq58rXYdj17k8Bk0GkSZuxX+6ZPMNayEqNXwDKBhrUIAgn1N zyKon7OJwIDISZ4CQpwQUPHnMdCK0xamXRWjqGv0= 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 EDC3F60817; Mon, 12 Mar 2018 13:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520860552; bh=Jtcaff9UeqTOHsqqROrxeYLAPCHW5dbMo9cP/uvNdII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k3czAZjmBsVFfrDrxOWqxCI+2OFb99+J2OuMW7ECbXKBG2ySLWX82ZBBvG4UdWmql MpdMGimCsfh4++D6HN/ULaw2YgOBNPZwVzkfPiba6BcNZfHbZVaC+xFQrTtlKDidVW cODafalXSyve0ZHBtTSbwrhI/WdFxTU9hTmY9UgI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org EDC3F60817 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 , Austin Christ , 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 v2 09/13] i2c: qup: change completion timeout according to transfer length Date: Mon, 12 Mar 2018 18:44:58 +0530 Message-Id: <1520860502-14886-10-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520860502-14886-1-git-send-email-absahu@codeaurora.org> References: <1520860502-14886-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 Reviewed-by: Andy Gross --- * Changes from v1: 1. Added comments to explain TOUT_MIN drivers/i2c/busses/i2c-qup.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c index bf1b7ee..13c751e 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c @@ -121,8 +121,12 @@ #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 +/* + * Minimum transfer timeout for i2c transfers in seconds. It will be added on + * the top of maximum transfer time calculated from i2c bus speed to compensate + * the overheads. + */ +#define TOUT_MIN 2 /* Default values. Use these if FW query fails */ #define DEFAULT_CLK_FREQ 100000 @@ -163,6 +167,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; @@ -849,7 +854,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; } @@ -1605,6 +1610,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