Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2308587pxk; Mon, 14 Sep 2020 09:49:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx58wTFSvCBQUze2kjK8wnJg6EruLIOnQA/jpkaRU6QawtlF9qPGT/JTPJhoRRZtK0e0oVT X-Received: by 2002:a50:fd0a:: with SMTP id i10mr17837973eds.277.1600102177826; Mon, 14 Sep 2020 09:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600102177; cv=none; d=google.com; s=arc-20160816; b=A+Q0VWXVmlOI9LX8wH8fFSF0vBQmLbu2aFjh5RuJ1pfWT3/DczkGPr5dGfXvNAgFfJ huB6jghso50sx837htUKJzzKtlydRhoaYd0Gf40vLGxg0ceMIc6k2HPj/xbnI5JCyT3N icD/QEph7Iqd4J7sxdTcozZRIgkDNgVu8DsbJKy8DZdwcVWVoXa2BB4csh+wjhOl4cbD WXXOspWbej3zxdvs74YxC0G/c/5+VpfOlKZYcx8A8s6H3DgWVUaarNxlzyMG/wAhfFpx J2JY6QfPZQKN62llSf1PufdGyQtTr6MYNxSeXzAxzu4xyp3N/Gb9rUZVAE2MQth1lvAv Wh0g== 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:autocrypt:from:references:cc:to:subject:dkim-signature; bh=lXMk4QeQIMhGNoMx4cVDajUP7rFeHi/N5faNXUWz4B8=; b=QcJj4CmdUiCN8DsWEsjJ7pNoGxhS3tLhuxTl0rszutGdJmlNhUOV3Brv10cLFw1Qq1 C0iH+9Q1eDNCVB2B+519NWrc4F/9wfepVIi8SfXDHeTJWdBe9WPtJZc+fVhkoPm/0g/o qiRXBgKPTr7GGRCZwpCqP5A8833fk0HNiFgWO84a/n1659uYjIBDi421eyqVgMykmI7c J9qRYQLX8wHA0xchJ4ddqb1N1EjkwZ7vsFek3sFbFxmyQ55DzyLgbUrGTHmxiNdukn0T cuXpl3GabGWoOgR673EF9fZ2rAWuIDUwFOPN3wRBs7hS3uZnWFnCaisCxgvzRyhWPowu 0fsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="fhkF0ai/"; 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 i11si7567978ejv.148.2020.09.14.09.49.15; Mon, 14 Sep 2020 09:49:37 -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=fail header.i=@gmail.com header.s=20161025 header.b="fhkF0ai/"; 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 S1726022AbgINQqg (ORCPT + 99 others); Mon, 14 Sep 2020 12:46:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbgINQoG (ORCPT ); Mon, 14 Sep 2020 12:44:06 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FB31C06174A; Mon, 14 Sep 2020 09:43:43 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id i17so516864oig.10; Mon, 14 Sep 2020 09:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lXMk4QeQIMhGNoMx4cVDajUP7rFeHi/N5faNXUWz4B8=; b=fhkF0ai/iqsFgS5J0BSy3VjIz0gdC22qT46YgH3DCATOjggT4rXpOAv0Rbw0BbkhcI UdCwm8nMkjg0d94M2F07TCZXlz+n62fvzLs0gxwKvpF+srZI8D1UMkL6Yci0CDpGs6bf KG56cmwEXNo3f1K9asd3qMLXcjP+CCWexbJ7+5Udj9fCnsrTSsw8Qy4O4RjlbIQyFQpZ /DFHa0xZHUVpDYEZNRcZ13Ee/lLrB3mbVZ0iR31T7fbge+487e+5+BoqwlvcvN6q8IUW jyQxhlnNq8U51NYZmytctqTrfZJyH3L9cMS5iiUTzLVV8l6Ey9LzGuM8TGm4qEawp+KU o9+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=lXMk4QeQIMhGNoMx4cVDajUP7rFeHi/N5faNXUWz4B8=; b=jK+IINQe+jrl/0liyMq5lBe5ipluMFy3bv9ADPSh1eEVfTzxoeJVJdZo7TXvxrPZLf JErJofHvligp6QgK4ccXbmHOljGV0OKPIttd42DPiXRKoZLUCfvd7Jbh0JX66HZndKgX ip97dNrZTSwJDRMPy17mJuNafUuf4yI2tZL67MnxbLBGrUyOkHlwz9fN4Kzdzvj5Qcsr UFl26p0Pi+5Jj+rEmTATOTXsX05iGKFJnqLY3mNAHhtE6rP+AaYYYh2xHM9gBOAjA78Z zQexqfwguraUd9/s+B4xl2ThZmzaNVGaQdFoxtdqBWKyaDZDejIS+54Ox7slRN8G1pzu eYBg== X-Gm-Message-State: AOAM530YPmmne/9mRCBGnSabu3VhwgC7sq+XFwUY18hLzoH340H5S73Y ecY2hL8g6PK94tyRbzuStQkb4C1I6Bk= X-Received: by 2002:aca:c7d6:: with SMTP id x205mr161324oif.51.1600101822235; Mon, 14 Sep 2020 09:43:42 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id v7sm3951468oie.9.2020.09.14.09.43.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 09:43:41 -0700 (PDT) Subject: Re: [RFC PATCH 0/2] Throttle I2C transfers to UCD9000 devices To: Andrew Jeffery , linux-hwmon@vger.kernel.org, linux-i2c@vger.kernel.org Cc: jdelvare@suse.com, wsa@kernel.org, joel@jms.id.au, linux-kernel@vger.kernel.org References: <20200914122811.3295678-1-andrew@aj.id.au> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CMS7ID9Lc8FaL1ROIN/W8Vk BIsJMaWOhks//7d92Uf3EArDlDShw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rSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= Message-ID: Date: Mon, 14 Sep 2020 09:43:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200914122811.3295678-1-andrew@aj.id.au> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/14/20 5:28 AM, Andrew Jeffery wrote: > Hello, > > While working with system designs making use of TI's UCD90320 Power > Sequencer we've found that communication with the device isn't terribly > reliable. > > It appears that back-to-back transfers where commands addressed to the > device are put onto the bus with intervals between STOP and START in the > neighbourhood of 250us or less can cause bad behaviour. This primarily > happens during driver probe while scanning the device to determine its > capabilities. > > We have observed the device causing excessive clock stretches and bus > lockups, and also corruption of the device's volatile state (requiring it > to be reset). The latter is particularly disruptive in that the controlled > rails are brought down either by: > > 1. The corruption causing a fault condition, or > 2. Asserting the device's reset line to recover > > A further observation is that pacing transfers to the device appears to > mitigate the bad behaviour. We're in discussion with TI to better > understand the limitations and at least get the behaviour documented. > > This short series implements the mitigation in terms of a throttle in the > i2c_client associated with the device's driver. Before the first > communication with the device in the probe() of ucd9000 we configure the > i2c_client to throttle transfers with a minimum of a 1ms delay (with the > delay exposed as a module parameter). > > The series is RFC for several reasons: > > The first is to sus out feelings on the general direction. The problem is > pretty unfortunate - are there better ways to implement the mitigation? > > If there aren't, then: > > I'd like thoughts on whether we want to account for i2c-dev clients. > Implementing throttling in i2c_client feels like a solution-by-proxy as the > throttling is really a property of the targeted device, but we don't have a > coherent representation between platform devices and devices associated > with i2c-dev clients. At the moment we'd have to resort to address-based > lookups for platform data stashed in the transfer functions. > > Next is that I've only implemented throttling for SMBus devices. I don't > yet have a use-case for throttling non-SMBus devices so I'm not sure it's > worth poking at it, but would appreciate thoughts there. > > Further, I've had a bit of a stab at dealing with atomic transfers that's > not been tested. Hopefully it makes sense. > > Finally I'm also interested in feedback on exposing the control in a little > more general manner than having to implement a module parameter in all > drivers that want to take advantage of throttling. This isn't a big problem > at the moment, but if anyone has thoughts there then I'm happy to poke at > those too. > As mentioned in patch 2/2, I don't think a module parameter is a good idea. I think this should be implemented on driver level, similar to zl6100.c, it should be limited to affected devices and not be user controllable. In respect to implementation in the i2c core vs in drivers: So far we encountered this problem for some Zilker labs devices and for some LTC devices. While the solution needed here looks similar to the solution implemented for Zilker labs devices, the solution for LTC devices is different. I am not sure if an implementation in the i2c core is desirable. It looks quite invasive to me, and it won't solve the problem for all devices since it isn't always a simple "wait microseconds between accesses". For example, some devices may require a wait after a write but not after a read, or a wait only after certain commands (such as commands writing to an EEPROM). Other devices may require a mechanism different to "wait a certain period of time". It seems all but impossible to implement a generic mechanism on i2c level. Thanks, Guenter > Please review! > > Andrew > > Andrew Jeffery (2): > i2c: smbus: Allow throttling of transfers to client devices > hwmon: (pmbus/ucd9000) Throttle SMBus transfers to avoid poor > behaviour > > drivers/hwmon/pmbus/ucd9000.c | 6 ++ > drivers/i2c/i2c-core-base.c | 8 +- > drivers/i2c/i2c-core-smbus.c | 149 +++++++++++++++++++++++++++------- > drivers/i2c/i2c-core.h | 22 +++++ > include/linux/i2c.h | 3 + > 5 files changed, 157 insertions(+), 31 deletions(-) >