Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp802260pxk; Mon, 31 Aug 2020 01:02:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7h7fhZlwX8FQyaWq4nfk2E+kbAdP47w3gyUdV1klpAixIf9hpV+/q8aeFDO5A22V3WyDO X-Received: by 2002:a17:906:36c2:: with SMTP id b2mr32484ejc.238.1598860934932; Mon, 31 Aug 2020 01:02:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598860934; cv=none; d=google.com; s=arc-20160816; b=REPXFE4l6yrudgbk+sY0WR7mZRdH7c4GwOcSYLzj8rt5F7L33xZ7tBlo6GW45mkI9A 3zqNYTb5Vt787x6N9wi5/mmybiXPMXtZABqk+iYO2RDg76DCuOQPxjRqxh6mnQjNMRrN yfLKlHkeW8c+Ox6YPyKDKEJU02f1S4YYza+NKHW6zxK9vip4zK8ezzYKFje/UIPk5ale W0juzfImAfr7QHg2z0btCoU+H+9tted52uvvSIerU/DVfc2J9N+CXdz9IAYlDsAsKPhw FPqNigFydtgMJ02S9Ediar+IAbPRpW33SRzc/5T4aCRKRUcG7RVcxr8zIKjKKsR5DwiL qluA== 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=ZGpi+5qwZTXlfGi+xb+oDjdA7kPA3G9h6znjI9BQew0=; b=R7CtVX8V9N8holtka3Q2zgLhE3hxum7WgPde+SKYeC9dD9+iL2q0HembYA1BfCGtiv Y2Fz1oE4uOxc65t5kYMnhJHf2gPGFFVJIBhx5uDDThkp9rpZXTSnFDbeBtLZVxlcXZ7g cbTJx7zj0Snq41XZUJnxqoh6DAruabeijXMJedU+Lw00GBnR5vfbt1dWHuB0Wu3M/sp/ x+M9MEsQ3WxskZNVIJkqk5IcDHGyfGcNXT/zP9uHLDEs8jT8WMt6eKDyxUXO/brR9Vwn j3Auv2IdpQWiBHDd20mBdWsshaxVRn8sq5AiMnS2SVowd5Puqy9BqBWS0DbpVW2mUGRV 942Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AOdCeQxT; 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 p26si4527394edt.197.2020.08.31.01.01.52; Mon, 31 Aug 2020 01:02:14 -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=AOdCeQxT; 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 S1728047AbgHaH7I (ORCPT + 99 others); Mon, 31 Aug 2020 03:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728197AbgHaH6z (ORCPT ); Mon, 31 Aug 2020 03:58:55 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A17BCC061573; Mon, 31 Aug 2020 00:58:53 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id g128so4902639iof.11; Mon, 31 Aug 2020 00:58:53 -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=ZGpi+5qwZTXlfGi+xb+oDjdA7kPA3G9h6znjI9BQew0=; b=AOdCeQxT2jAza4/PKUwlGY32t9Nu7VJ5ktqVkH9a1b+k0F12J3MfmkECzbTg4jufCA jCLvQ2XJtHbIS7gI8U9W7STv4m4hPisAQzGqLu7M/q/P0enBWtyOWHIHtgGAufrSB7dg tBqkJuASBrVp+c5X0GQPi5qcvxUNK7P/wxe4Vkx+HCr6visW3UrptXnjGezadJCgGNwe /W6hhR4r5K9nnR3Rvj9IhbSYddF5UfI0wyYgXi4vjl5iID0mdpVHCiB82Z9WXdLmZvhQ eP8hGLezFV+mc0u9s8IQQdaMS43NOxx+B/DkjqKmXCoN3P2VLa1bEwwm+iD/z9qZ3DP+ d0Ww== 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=ZGpi+5qwZTXlfGi+xb+oDjdA7kPA3G9h6znjI9BQew0=; b=tsoctX4Z9NqCE3TYx8pMoknJpAwrcbDBHX2QajuwKxOMB+OhfkNhawsmi8RyQsgPjp dYTCAwH1+of1cZnFTEtWEQsu64pJ1PKoiHCnWOvFWqEJJLh9FS/Y5K0SeBsz5Btb6He7 jbZw0XZeR5hCVQQLis0WljOBxuI6thvPaIcy3ePbkcjRh2WUUIvMyBM6HmxTm14/dLAd C1oYPmcqzj95ftChu3koiwvyZiEtLa2bYESNRJTDmLx025OLlJoSFYrS8P7IkhOVmfZ+ S8P49pPUcKK4ruiLHLaBgE6Jc2aVCGuhg4fRwNI4MihBNCJrj26t/ygaEklBSnMv4LDU KvJA== X-Gm-Message-State: AOAM530K5ffCsnWUyq6d7FEIadEEmFo6pKPAGAyv6xb9h0NONuBihbSe /OzqUs60B3Yrr1dA3w3ACa51qJOU8hZGtYyol2fnV6nMcg== X-Received: by 2002:a5d:954f:: with SMTP id a15mr361144ios.53.1598860733041; Mon, 31 Aug 2020 00:58:53 -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 10:57:31 +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 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