Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp563666pxk; Wed, 16 Sep 2020 10:52:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGb+NiZNAXTg9jJ5IIgBTQPkUKAjt+bOhElAyLr4ht6Hsum4FancApWhiv6/7EJMJdeqAt X-Received: by 2002:aa7:d059:: with SMTP id n25mr28788401edo.270.1600278749059; Wed, 16 Sep 2020 10:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600278749; cv=none; d=google.com; s=arc-20160816; b=hk5KRFMeXDKownUoRQEaTK9IRTuuII6En/9qHgh1yESi+nqgqP6He/IKVn+n/TZuq9 g8KSlzuHK1UWbT8YVg67tt70tOGg8jN7u/G9Ou+ylJSw4Ft9BVeZerYx2Kjs3S5AO3l0 Mf7TJENRZpCrdmsE0xluFRVFBpHgelxYI4GR3cu4YkYVQZj4WeNiK56xtYoDkCKYLvM9 9M7VpLgSAGIH3/CD7W74aRJtKBkesA5ZRNX9UgFhg0xv7wjjVxqGIPMKnxSa8wtHhiX0 vZ5rromRCSV0Ecgk+vBKuK3x8hWZN+Ptb3lPr32a3yxdmKaZMi05t3q/+cEjYTBd+F4O 8RcA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=g+bey1+PIn2cHhsoMC55hoyVfYzFGkxuLIHX30QP8JI=; b=0RWwKdqUmkK4O/kWvtbMrvrIE09P13jJiueXuMLm9IFeiTk7NchEuchF1qXqsDNUiF Wpgrbp8BfcmBe0yP+RCJDfvHFa28fPihhueyCAqHYzTz6VGrTpsYc6TeuGaolgztk9tL 0t+lxpzpU1FW5xcin98Tva/3dpD3PGb3Q7G7K34UG2gYTGfdyvsSOFUaNan8jr0w83sR 1qJL/ESLLOkR9yhm7i0gZmH4qPnxmwYUR73/37kvZarsInW8kMVYa/gHPFM3w7VvUda6 TyQZV4YaoImYswRjoBkYlUb3ZPunoy4jovUuj+XemfqKDamrS7CGMiQQ21A/i4DHQQJJ Cc1A== 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q23si12751143ejn.400.2020.09.16.10.52.05; Wed, 16 Sep 2020 10:52: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; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727552AbgIPRvQ (ORCPT + 99 others); Wed, 16 Sep 2020 13:51:16 -0400 Received: from mga09.intel.com ([134.134.136.24]:10142 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727555AbgIPRtx (ORCPT ); Wed, 16 Sep 2020 13:49:53 -0400 IronPort-SDR: gJC9KQrGz7PNLfiRC6j6+O5xRPn2eAsOz2+Ubns7jvVjezTjWDXLx4gYMVSKDI6BDw+u3be1Vj FxG6LtUuZoGQ== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="160395369" X-IronPort-AV: E=Sophos;i="5.76,433,1592895600"; d="scan'208";a="160395369" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2020 07:09:23 -0700 IronPort-SDR: f6lEK6rr61QfJLrKixbHM2tY184hPKA3gqXtKYIaZE5f5CnutmwPYL/Q6k3e7bQNOdG3KM3B+e IkN1W1Swyaug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,433,1592895600"; d="scan'208";a="331700580" Received: from mylly.fi.intel.com (HELO [10.237.72.153]) ([10.237.72.153]) by fmsmga004.fm.intel.com with ESMTP; 16 Sep 2020 07:09:19 -0700 Subject: Re: [PATCH v3] i2c: Squash of SMBus block read patchset to save power To: Sultan Alsawaf Cc: aaron.ma@canonical.com, admin@kryma.net, andriy.shevchenko@linux.intel.com, benjamin.tissoires@redhat.com, hdegoede@redhat.com, hn.chen@weidahitech.com, jikos@kernel.org, kai.heng.feng@canonical.com, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, mika.westerberg@linux.intel.com, vicamo.yang@canonical.com, wsa@kernel.org References: <20200914001523.3878-1-sultan@kerneltoast.com> <20200915174844.GA16807@sultan-box.localdomain> From: Jarkko Nikula Message-ID: <796a23d2-cb98-c431-3494-b59044189468@linux.intel.com> Date: Wed, 16 Sep 2020 17:09:18 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200915174844.GA16807@sultan-box.localdomain> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/15/20 8:48 PM, Sultan Alsawaf wrote: > On Tue, Sep 15, 2020 at 02:55:48PM +0300, Jarkko Nikula wrote: >> I tested this on top of fc4f28bb3daf ("Merge tag 'for-5.9-rc5-tag' of >> git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux") and seems to be >> working fine. What was the key change compared to previous version that was >> regressing for me? > > This change fixed your issue (and my issue with 5.8): > --- a/drivers/i2c/busses/i2c-designware-master.c > +++ b/drivers/i2c/busses/i2c-designware-master.c > @@ -395,8 +395,9 @@ i2c_dw_recv_len(struct dw_i2c_dev *dev, u8 len) > * Adjust the buffer length and mask the flag > * after receiving the first byte. > */ > - len += (flags & I2C_CLIENT_PEC) ? 2 : 1; > - dev->tx_buf_len = len - min_t(u8, len, dev->rx_outstanding); > + if (flags & I2C_CLIENT_PEC) > + len++; > + dev->tx_buf_len = len - min_t(u8, len - 1, dev->rx_outstanding); > msgs[dev->msg_read_idx].len = len; > msgs[dev->msg_read_idx].flags &= ~I2C_M_RECV_LEN; > > I've attributed this change with the following commit message: > "i2c: designware: Ensure tx_buf_len is nonzero for SMBus block reads > > The point of adding a byte to len in i2c_dw_recv_len() is to make sure > that tx_buf_len is nonzero, so that i2c_dw_xfer_msg() can let the i2c > controller know that the i2c transaction can end. Otherwise, the i2c > controller will think that the transaction can never end for block > reads, which results in the stop-detection bit never being set and thus > the transaction timing out. > > Adding a byte to len is not a reliable way to do this though; sometimes > it lets tx_buf_len become zero, which results in the scenario described > above. Therefore, just directly ensure tx_buf_len cannot be zero to fix > the issue." > Ok, nice that you found it. > Does the patch series look good to submit? > Yes, go ahead. Jarkko