Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp706369pxk; Sun, 30 Aug 2020 20:48:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtT22DXK82Ls0jKRnrTNWIiDtB+xkq2lBnP+s9HiSB7TYnQ8NOh93+xcUw0qCkMwboBzKx X-Received: by 2002:a17:906:a88a:: with SMTP id ha10mr1881027ejb.532.1598845739689; Sun, 30 Aug 2020 20:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598845739; cv=none; d=google.com; s=arc-20160816; b=gfkdPdRsNvOA9A8R3m8raSemZchcv4vjTaYrHfsDKrB0Z/ApO94wPpHSqGS82yKFLH aqSQxWoiF768RTk82eBVE6V/zaeqmF6q0lV8eSqIVjfoUUMhTg2g9M6FKuNFXmo3flnb kBn9E0n//9whllnsg2n1sz8/o1zPhXyaX3I/2cYQ5qnYmZUbc/9IzNMM0wszW0fjfP/1 CR+Vua4kiz2rspQHI4FsUKYYqxYRDIy8q7n37CSh8AeJagA3s2vBHGb7sG7LtvcnCf9J 8qKVbLCqmMfJ0SaF4TqJ0NYhPSnSy4BPggfph2cBEvgCLPSCFTe30vhuHHC6QDHFcRwP 6org== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Es49Pktfv7cyRBR2isn8kE0O0ZV8xR4yhOVye/VQUrk=; b=hDqkxjPKKWAv5eVwpcGtZBxfQdiUedQ4tVL2rzmYD4nIhEv4buAkqJvin5Ioass8bZ ynf2V9NBJOa45nnMJLaUu9lUjlzxCFb9438ZIRlT0zOiSg9ODA5IG1BQMG+3kwr878bF THe9TjwW2HMlmK9RG9gpKSrDAGxCihId3CjUqevSzqhjUR4at018A32+dS3KiBmex1z/ 6LVHgY80JlCpVv0KjHc002dC5BVXhpARNX3zcuZXqHlQwwYexhhuOhkD9wkfKJvW9JtE e8hfS2YwxAtNecvzhiOMlZNSO/DuQ/KTEqz1u6TCy3fulTTxH09lI4epZ9AssK6LGwy2 zWqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jms.id.au header.s=google header.b=Np8eJ16y; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u23si265753edb.1.2020.08.30.20.48.20; Sun, 30 Aug 2020 20:48:59 -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; dkim=pass header.i=@jms.id.au header.s=google header.b=Np8eJ16y; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726584AbgHaDfx (ORCPT + 99 others); Sun, 30 Aug 2020 23:35:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726067AbgHaDfw (ORCPT ); Sun, 30 Aug 2020 23:35:52 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9405AC061573; Sun, 30 Aug 2020 20:35:51 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id ay8so4086690edb.8; Sun, 30 Aug 2020 20:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Es49Pktfv7cyRBR2isn8kE0O0ZV8xR4yhOVye/VQUrk=; b=Np8eJ16yZ5iMi3JnVsjqeMJX6+O7o5Ri0YyeWM6xIP2rHgwlMYXKwdrjJFPowbg/BA Qnr2rsfVzQudIyB4cK4lD/oNRmPcWdr8Tm3bCZG9DNxyK38R0k0EkF38KUbtIzV7ScCs 44b/yRnPTi24WZi3x+sC4lM5sLHPLrC56iNp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Es49Pktfv7cyRBR2isn8kE0O0ZV8xR4yhOVye/VQUrk=; b=NGfsUVZa9FUQ6OxsUJy2KpKcR+J8+eRIi7nzCFkji9gCERmr/Gw1vGuY69pclKrlUJ mt+KsfYM7I1hYEXnnJyxP4SzAOvF2XVWKtHvtbivkHVedW0hmOFjamiCfaMIoV87hDBh kvoU/XrD1FUimroG2PZ3KBAZMnTDQk7WD/wqpsWcJMDdQ/N9lD+YH8lxsdfhbiGxH/jt LUcBKdTvyhRW7pdGZbJpN6TNVWdh5pbPYkBz3oNGziO8b6hBQWaj06PCIJwrR1KbzLy8 x91f6sEtOkyTVp1vjL7GgWnTqoF/yiu7GxPw4NEReOxyO0oz4BqRT/02K4Dgpm3WRb9r QOqQ== X-Gm-Message-State: AOAM531++k0FHyjGzDtRowb/NteYSFtA/uOuWvXf8Xl9c99OTuhPsr9D iX1kUutSJRMNuFFamQO2A5udeTof0ZDtQfBloZs= X-Received: by 2002:a05:6402:ca7:: with SMTP id cn7mr1902945edb.143.1598844949735; Sun, 30 Aug 2020 20:35:49 -0700 (PDT) MIME-Version: 1.0 References: <20200830213121.239533-1-tali.perry1@gmail.com> In-Reply-To: <20200830213121.239533-1-tali.perry1@gmail.com> From: Joel Stanley Date: Mon, 31 Aug 2020 03:35:36 +0000 Message-ID: Subject: Re: [PATCH v3] i2c: npcm7xx: Fix timeout calculation To: Tali Perry Cc: Kun Yi , xqiu@google.com, Benjamin Fair , Avi Fishman , Tomer Maimon , Wolfram Sang , linux-i2c@vger.kernel.org, OpenBMC Maillist , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 30 Aug 2020 at 21:31, Tali Perry wrote: > > timeout_usec value calculation was wrong, the calculated value > was in msec instead of usec. > > Signed-off-by: Tali Perry > Reviewed-by: Avi Fishman Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver") Reviewed-by: Joel Stanley Cheers, Joel > --- > drivers/i2c/busses/i2c-npcm7xx.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c > index 75f07138a6fa..dfcf04e1967f 100644 > --- a/drivers/i2c/busses/i2c-npcm7xx.c > +++ b/drivers/i2c/busses/i2c-npcm7xx.c > @@ -2093,8 +2093,12 @@ 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) > + */ > + timeout_usec = (2 * 9 * USEC_PER_SEC / 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 >