Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp336730pxk; Sun, 30 Aug 2020 05:22:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJhFpvkLsmH6TjasM9/XJ1kh2pm4XXb/sibpOpuB5jSKlqBkYK00016kV51spOIFipQFBT X-Received: by 2002:aa7:db89:: with SMTP id u9mr6801174edt.267.1598790166012; Sun, 30 Aug 2020 05:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598790166; cv=none; d=google.com; s=arc-20160816; b=t97f+5l801jNVzykVRYF3wMYo+prf/2zcMehnF0oVzFfzZoTKnQyQeS1Hse+NVeiA9 OB0IetRU4XwNXbln2zTtMSaYciGGQdb1ifp1n92mHQ2nea1BLuxNylH60mBVFVBn9J9U tEZNvkau2uaMmQVX1QfzbKQnUk1DOLWZc+raw/xG6rT3J/eOnNGUdCaG8oK2ORmjSBZU Yge+Fn9M9WMGCfSuiTTOS7tm1goCcpWYtZyofj7TawPLDvvn8WjhhFy1eQL0vDdyxzAJ PEDS82mkTgw6x6j4BEsYOWpC+sU4RGTv9nBlPdO90QDSp9y5yjTBEetjTi9K6i0hvkqp YWrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=jnPtV680IV5B2xMtwBoc79lPKOUxOkHrfQbEekwbeQE=; b=I/9Wl8kfpQynMtqbmUJMSaTqJKm59DPs5oHkJlDlxrhGHxyh+uYlrWw7YlC0N2TvLs U4rgizI6YU2VB/TluJEF34ZfpUr6owAn+Wc7t3fbc5qr4CNp+JxHjJEvUjgt8RoIzr0S FJ1GNAm2T9WYPX+RBAXwD/eaByaSUPiT4C7yIb4u8whc9sfc6AHphdgvP0Y7usYURdoi Ot/wjzqKNFUz7l2sXsucur+r0dCo3R2tBO0KO/iLwFMLWEg8y05Qou9XY/JAg8f2D3OK uKLqnaFkW+qITt1SWN+cnE1mz/WLXqnuF307bY9W9NzCbh9GnezaCv5MdthdTmK9HAsb BcIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lf11si2491230ejb.48.2020.08.30.05.22.20; Sun, 30 Aug 2020 05:22:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728691AbgH3MVd (ORCPT + 99 others); Sun, 30 Aug 2020 08:21:33 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:53738 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726130AbgH3MV2 (ORCPT ); Sun, 30 Aug 2020 08:21:28 -0400 Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id 07UCKsfm000554; Sun, 30 Aug 2020 15:20:54 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 20088) id B9DDC639D3; Sun, 30 Aug 2020 15:20:54 +0300 (IDT) From: Tali Perry To: kunyi@google.com, xqiu@google.com, benjaminfair@google.com, avifishman70@gmail.com, joel@jms.id.au, tmaimon77@gmail.com, wsa@the-dreams.de Cc: linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Tali Perry Subject: [PATCH v2] i2c: npcm7xx: bug fix timeout (usec instead of msec) Date: Sun, 30 Aug 2020 15:20:51 +0300 Message-Id: <20200830122051.197892-1-tali.perry1@gmail.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org i2c: npcm7xx: bug fix timeout (usec instead of msec) Signed-off-by: Tali Perry --- drivers/i2c/busses/i2c-npcm7xx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 75f07138a6fa..abb334492a3d 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -2093,8 +2093,13 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, } } - /* Adaptive TimeOut: astimated time in usec + 100% margin */ - timeout_usec = (2 * 10000 / bus->bus_freq) * (2 + nread + nwrite); + /* + * Adaptive TimeOut: estimated time in usec + 100% margin: + * 2: double the timeout for clock stretching case + * 9: bits per transaction (including the ack/nack) + * 1000000: micro second in a second + */ + timeout_usec = (2 * 9 * 1000000 / bus->bus_freq) * (2 + nread + nwrite); timeout = max(msecs_to_jiffies(35), usecs_to_jiffies(timeout_usec)); if (nwrite >= 32 * 1024 || nread >= 32 * 1024) { dev_err(bus->dev, "i2c%d buffer too big\n", bus->num); base-commit: d012a7190fc1fd72ed48911e77ca97ba4521bccd -- 2.22.0