Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp917866pxk; Mon, 31 Aug 2020 05:08:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQykRYF14tzJwQfyyEW1Kd2zxj6WWufydCsD+4syQdH9Caa1rQivzNR4gvOlgeCtqN43kM X-Received: by 2002:a17:906:841a:: with SMTP id n26mr832701ejx.213.1598875693544; Mon, 31 Aug 2020 05:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598875693; cv=none; d=google.com; s=arc-20160816; b=MtBjNSMPYb41rG10RGhG9f1/Ddzpa87SXvAWsGQFSVF3kEx3xaVeAKFPCsEAqBbui6 f9YYd68xPiO4ry+ah/ABZN+vPl2/CFq9ZLuB1K5wjxp+4B9XNn/WfiAx4OZaVvrLZiEC +L9i0gbAAkoSdNt6wFL2pLtafDPO97Pt3YCpCuVoJqafx6DeqGHcEPSmSP57F2GqqvKJ r4E+0661rypsYvcPtpiBhmv2zYeuNSvGcHNpHuC6WYiHoPsvw5Ov2eXxcC+zj6Pxm6Ph BjhYROpRxPpZzQiBAo1IyIySJ/gbxrL4mvfU4uPVoGPKRIn1pLx/a9kMyhZu9AMSoi66 zk6g== 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=RVDQx/5Q8O0no/oayEfb/rYh2QGwLeWVgd4QIaQ9KVU=; b=is8rUtFibkh4g2E7dUZHBDe5vaZigDYKbosSKKJQTC0/vtIDBvekXlEyXBzPcTQXpY 4yr4X+8uW6iqw7kv719L5W+GF4aVCPA+UD7HNrXmSwccaAWWbQDXyfOqL5DG8UPj07MC s1hGBFNzBI21U3O4UgMctcmGO0FLRBvoJDk+FANWrH4xhMfyrF/EUDLon4RfJh+m38W9 qCd84mZldGZY8N6OOUCIRgsqmVJyX8DTjA/2kDeFTh/tkh4kC2f8AaPdP1De3jU41XtM 4+WPmBA+9CIQBYYPeTwNDyv5XUh0OFESHGsCpGdpVinGx5C4z4SqXwbNKbXQx36VU3G2 K+dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KOr9Qg+p; 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=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 m21si5413703ejl.493.2020.08.31.05.07.49; Mon, 31 Aug 2020 05:08:13 -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=@gmail.com header.s=20161025 header.b=KOr9Qg+p; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726468AbgHaMFD (ORCPT + 99 others); Mon, 31 Aug 2020 08:05:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726204AbgHaME5 (ORCPT ); Mon, 31 Aug 2020 08:04:57 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D166DC061573; Mon, 31 Aug 2020 05:04:56 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id w8so778004ilj.8; Mon, 31 Aug 2020 05:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RVDQx/5Q8O0no/oayEfb/rYh2QGwLeWVgd4QIaQ9KVU=; b=KOr9Qg+p497+M09E6ouEKz4/321jfNwRllwXVHV7s8tjWJdNSkoOqR7nAFYm7KzZlp 6sYFJ120y/KYbutta22YjS+bNwKkEY3vszYyEuv1LXnyOX28tLSaw2sEaNFovJZ1pVn7 hTwokk2isRbexxzrPGkC5J0iu0T/hv2fJCnwcj8300Jl2pR8KfwID7gJoU4Z+wgyLo5W fFHT0hSt/5+QVbHorqyIbEnSf1i1hVFSeiGp8G+LltQk3+N5PXh0Ks4yuV1Ki5wXgc+z 4x3KzQsm0OHZBZa/0wyac1ABifPbjpZs8fv+AsJzJxyz7/8d97ph4ZcaKNEV3Rjx+/ij EIBA== 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=RVDQx/5Q8O0no/oayEfb/rYh2QGwLeWVgd4QIaQ9KVU=; b=BDuHVxRA9oMTUbdRVbeMaZw6kQKtnKoPgiCA13YuDyc5/4TT8odwguPTzNtJUGHQNN SEAkMkHTpYmYbSd/5FMxmbFfcsbK2EqSk69hSAEEncXwVpyM/OiKZcza/9jnSzcXN4sn +m8VWKPJN+4QQdFsDj7cKJVFq8kIe2qblhi+vvMIpkDcfnEauVZDnHWSSiKbrQnPoYNH 28K9cK8M748treJfiJYe3/EKaq+y9JfTQgT96DsZH8CGXNWXz9yTM2Nmb3sgeyWYZXpb vSLgDQxJQ9FvhkPq6vujZaI284MtWOiDlA1OrzuDCOYB82LuNeop5okUxWnVW4o+2wHF 918g== X-Gm-Message-State: AOAM533ymwv6Z6QZY1DO+3y36UPzVanVmLjS9RqEgfaWT9e14fX0pkXG LbCJ7DmcwUpaJFGnTRJmSOtlrWyXWtmDsGMsCA== X-Received: by 2002:a92:d902:: with SMTP id s2mr968251iln.21.1598875496080; Mon, 31 Aug 2020 05:04:56 -0700 (PDT) MIME-Version: 1.0 References: <20200830122051.197892-1-tali.perry1@gmail.com> In-Reply-To: From: Avi Fishman Date: Mon, 31 Aug 2020 15:03:34 +0300 Message-ID: Subject: Re: [PATCH v2] i2c: npcm7xx: bug fix timeout (usec instead of msec) To: Andy Shevchenko Cc: Tali Perry , kunyi@google.com, xqiu@google.com, Benjamin Fair , Joel Stanley , Tomer Maimon , Wolfram Sang , linux-i2c , 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 Please ignore my last mail, Tali already sent v3. On Mon, Aug 31, 2020 at 10:57 AM Avi Fishman wrote: > > On Sun, Aug 30, 2020 at 9:01 PM Andy Shevchenko > wrote: > > > > On Sun, Aug 30, 2020 at 3:23 PM Tali Perry wrote: > > > > > > > > i2c: npcm7xx: bug fix timeout (usec instead of msec) > > > > This commit message is awful. Please read [1] as a tutorial how to > > write a commit messages. > > > > Would this be better: > i2c: npcm7xx: Fix microsecond timeout calculation > > Inside npcm_i2c_master_xfer() we calculate a timeout for the entire > transaction in microseconds, the calculation was wrong so big i2c > massages would timeout before they ended. > This commit fix that. > > > [1]: https://chris.beams.io/posts/git-commit/ > > > > ... > > > > > - /* 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 > > > > No need. See below. > > > > > + */ > > > > > + timeout_usec = (2 * 9 * 1000000 / bus->bus_freq) * (2 + nread + nwrite); > > > > USEC_PER_SEC > > OK > > > > > > 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); > > > > -- > > With Best Regards, > > Andy Shevchenko > > > > -- > Regards, > Avi -- Regards, Avi