Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1236308pxk; Mon, 31 Aug 2020 13:41:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwu49Eg1XoGxkrLsxncOAZIM1lQgKhtKLtOjFR2erUWx4pmSU1n4QGwrJgqVuDWiwP8UR4C X-Received: by 2002:a50:fc87:: with SMTP id f7mr2720628edq.162.1598906489117; Mon, 31 Aug 2020 13:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598906489; cv=none; d=google.com; s=arc-20160816; b=dO93nJ4XdqRYTUE/BOMNBhRka2S7LK9P2SVkfvJcEJU3hmcQpI9EHzIuUKHlyxjLjY 1bWq0/2z80X3kasbt9X2owGbiERDYNlnSgDDIEt7UEJCTR7Sb3vIawMlMqh8CrB5JWIF F4A99RUvzkKtWeG3Sf6//F2zDHy56xFByJo7005k5TM1wAMNV8fnPUZBWWFVKEcvgOpo pHSiggKEoG19l2Axycg1UsdxtGNmX5qJnbUeopu0pd+wl1JK+Pk4lXPDZpNpPvTFmXpd vrRg2RNL8Y4zip4pfHS9TKm1zmwcZt8sxkT8xUmfLAe6B4fODXYSC1Jih0oQFLeYdHJ6 3TEg== 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=VjcOX+O6+Q0wVLVy5iOGuljY1HLUCKGrM2Zx4jaHF0E=; b=WWk97P092GHsYPZL0rzXUv5jEsX7Qi+cxZygQo+XsJUBQKY/YS0xjJSiShKe9nenD9 uFSVo4qqcdy+AlFCODVLxw4tlaxRQERc7yFUbAHtGlFtnteFj+Oxe+vOUD39v9KpQlki C8G0er4tf86SHcNa11ygxug4Oe+OM9MnbODpJ1lBShQxXEUJJV2R+UTlwFq+i70PFSuh hNCJOuU9qGmFqh9BR2gMsTp9BXUxVcd0kBMExkSCCjiWSA/IxAYiGVRd0lmzSs1xqsfF wdFtBiIqzpS9AZflqtaNeBZO69usq4rDiamFxxI5kZgnoHXtpWIXues3EDcXPgBsClDZ nC4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=vZaqRz6g; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si6142403ejf.419.2020.08.31.13.41.06; Mon, 31 Aug 2020 13:41:29 -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=@google.com header.s=20161025 header.b=vZaqRz6g; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729115AbgHaSKZ (ORCPT + 99 others); Mon, 31 Aug 2020 14:10:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728376AbgHaSKY (ORCPT ); Mon, 31 Aug 2020 14:10:24 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4139AC061575 for ; Mon, 31 Aug 2020 11:10:24 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id k20so6167971otr.1 for ; Mon, 31 Aug 2020 11:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VjcOX+O6+Q0wVLVy5iOGuljY1HLUCKGrM2Zx4jaHF0E=; b=vZaqRz6gPaztwYQyRjYHR8xtBaNnsakq7VS7gV1Jc2XbRTtD3KOy2/T7zfVrl7Ux41 m1n0QBSe07CxKazXvcJNC0qphB0ZM+F/RZjGclPdxPOyRIHHRotMD2u8Reilqq3Myt9t rgTYnm4TiWZ6QqaLHb5/J3a0tRHoXezu30kMr8imgBwyjdcnydc9nDu7FeRKyB6s3E4x 6/yDTDyrcJg7rJiR9v10GikVAZHmp/mz1hT3K8ZvwaEwHbrwDRLYkgVQop12EIUogMcO AvUJnuyQ5gFNW5MnufPLajm+bduenZYdgux9DfNckAmmArxY9lp3WMU2oFqRZAX56c5W ajvg== 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=VjcOX+O6+Q0wVLVy5iOGuljY1HLUCKGrM2Zx4jaHF0E=; b=osCfDILhMTqxpChL1fhpL1kbl8sKzGuBPMo1tcDo90bD5SmLmAlUHBRvdmxCS/UXg/ CnautafYHnIJgvFOEUGlK0SdSHMjzslTN+3iMkFlxKEF66MIA2W3OFiqdz2OWqzvMYZJ RBMqasboXc+gXe97WBgWSIpdTmbhv+CCPsZTo1xLia5SxZm/wnG7EjEp3DVMPcdQWZWf PmEfb5DaVP/N9dCXTwTyN6L8axUwKo7H1y1lhrwlbR2IeZdOiGg/UVq7vE492wfiL9Bz XkmQHokiToA25UVCV/zrs39JtVQt0M8qMz2iuKjDPMAuXmQKiPPVEjFC9OXcee5nZSJ2 /SkQ== X-Gm-Message-State: AOAM5319GpwL23djjz0I2ELWwsa27sROnh1vk24gkVhTZLAQ9pZUEPCc 8YO8InNze6iXINIOSVRYEPtvpdXOm3tJncvTUrumQA== X-Received: by 2002:a9d:7f06:: with SMTP id j6mr1714141otq.274.1598897423402; Mon, 31 Aug 2020 11:10:23 -0700 (PDT) MIME-Version: 1.0 References: <20200830213121.239533-1-tali.perry1@gmail.com> In-Reply-To: From: Alex Qiu Date: Mon, 31 Aug 2020 11:10:12 -0700 Message-ID: Subject: Re: [PATCH v3] i2c: npcm7xx: Fix timeout calculation To: Joel Stanley Cc: Tali Perry , Kun Yi , 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, Aug 30, 2020 at 8:35 PM Joel Stanley wrote: > > 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 Reviewed-by: Alex Qiu > > 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 > >