From: Guenter Roeck <linux@roeck-us.net>
To: Marc Titinger <mtitinger@baylibre.com>, jdelvare@suse.com
Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
bcousson@baylibre.com, mturquette@baylibre.com
Subject: Re: [lm-sensors] [PATCH v2] hwmon: ina2xx: allow for actual measurement bandwidth above 160 Hz
Date: Tue, 20 Oct 2015 17:00:51 +0000 [thread overview]
Message-ID: <56267343.8060601@roeck-us.net> (raw)
In-Reply-To: <562645B8.80905@baylibre.com>
On 10/20/2015 06:46 AM, Marc Titinger wrote:
> On 20/10/2015 15:30, Guenter Roeck wrote:
>> On 10/20/2015 06:17 AM, Marc Titinger wrote:
>>> On 20/10/2015 14:54, Guenter Roeck wrote:
>>>> On 10/20/2015 01:20 AM, Marc Titinger wrote:
>>>>> With the current implementation, the driver will prevent a readout at a
>>>>> pace faster than the default conversion time (2ms) times the averaging
>>>>> setting, min AVG being 1:1.
>>>>>
>>>>> Any sysfs "show" read access from the client app faster than 500 Hz
>>>>> will be
>>>>> 'cached' by the driver, but actually since do_update reads all 8
>>>>> registers,
>>>>> the best achievable measurement rate is roughly 8*800 us (for the time
>>>>> spent in i2c-core) i.e. <= 156Hz with Beagle Bone Black.
>>>>>
>>>>> This change set uses a register mask to allow for the readout of a
>>>>> single
>>>>> i2c register at a time. Furthermore, performing subsequent reads on the
>>>>> same register will make use of the ability of the i2c chip to retain
>>>>> the
>>>>> last reg offset, hence use a shorter i2c message (roughly 400us
>>>>> instead of
>>>>> 800us spent in i2c-core.c).
>>>>>
>>>> That doesn't work. There could be accesses from other sources (such as
>>>> through
>>>> i2c-dev, or in multi-master systems) between two reads.
>>>
>>> Re-setting the register address with each read transaction will not
>>> prevent another master to change the configuration in your back, in
>>> this case. That sounds like a general issue of concurrent clients for
>>> one device, this is beyond just reading one register IMO.
>>>
>> That is an invasive change, though, not just a simple read. Sure, it is
>> a risk as well. But it is a different level of risk than someone using
>> i2cget or i2cdump while the driver is running.
>>
> Yes, I get your point.
>
>>>>
>>>>> The best readout rate for a single measurement is now around 2kHz. And
>>>>> for
>>>>> four measurements around (1/(4*800us) = 312 Hz. Since for any readout
>>>>> rate
>>>>> faster than 160 Hz the interval is set by the i2c transactions
>>>>> completion,
>>>>> the 'last-update' anti-flooding code will not have a limiting effect in
>>>>> practice. Hence I also remove the elapsed time checking in the hwmon
>>>>> driver
>>>>> for ina2xx.
>>>>>
>>>>> To summarize, the patch provides a max bandwidth improvement with hwmon
>>>>> client apps from ~160 Hz to ~320 Hz, and better in single-channel
>>>>> polling mode.
>>>>>
>>>> Overall your patch pretty much re-implements regmap. Since you drop
>>>> caching,
>>>> it is also unnecessary to read all registers at a time, so you can
>>>> just use
>>>> a function to read _one_ register and returns its value (with retries).
>>>> Or use regmap. Either case, do_update() and ina2xx_update_device()
>>>> are no
>>>> longer needed.
>>> Agreed.
>>>
>>>>
>>>> If you want to convert the driver to regmap, just look for 'regmap' in
>>>> drivers/hwmon for examples.
>>>
>>> Fair enough, but based on your comments, I may look into an iio driver
>>> instead for this device, given our application, rather than 'twisting'
>>> the hwmon interface.
>>>
>>
>> Sorry, you lost me there. How are you twisting the hwmon interface ?
>> Because I am concerned about multiple accesses from multiple sources ?
>> How is iio going to solve that problem ? By ignoring it ?
>
> Sure someone can still use i2c diag tools as you said, you have a point here. But similarly, someone can use /dev/mem to remap stuff and peek/poke mm registers, and to my knowledge we do not generally design drivers or subsystems with retries and feature limitations to cope with potential use of diag and debug facilities.
>
Depends on the system, and on the use case. Many systems I deal with
are multi-master, and user space does end up accessing chips using i2c-dev.
Drivers are (supposed to be) designed with as much multi-master access
safety as possible. I had patches rejected because they broke multi-master
support by sending two commands depending on each other in a sequence.
Using /dev/mem and peek/poke as counter-examples isn't really appropriate
here, so I won't comment further on it.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net>
To: Marc Titinger <mtitinger@baylibre.com>, jdelvare@suse.com
Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
bcousson@baylibre.com, mturquette@baylibre.com
Subject: Re: [PATCH v2] hwmon: ina2xx: allow for actual measurement bandwidth above 160 Hz
Date: Tue, 20 Oct 2015 10:00:51 -0700 [thread overview]
Message-ID: <56267343.8060601@roeck-us.net> (raw)
In-Reply-To: <562645B8.80905@baylibre.com>
On 10/20/2015 06:46 AM, Marc Titinger wrote:
> On 20/10/2015 15:30, Guenter Roeck wrote:
>> On 10/20/2015 06:17 AM, Marc Titinger wrote:
>>> On 20/10/2015 14:54, Guenter Roeck wrote:
>>>> On 10/20/2015 01:20 AM, Marc Titinger wrote:
>>>>> With the current implementation, the driver will prevent a readout at a
>>>>> pace faster than the default conversion time (2ms) times the averaging
>>>>> setting, min AVG being 1:1.
>>>>>
>>>>> Any sysfs "show" read access from the client app faster than 500 Hz
>>>>> will be
>>>>> 'cached' by the driver, but actually since do_update reads all 8
>>>>> registers,
>>>>> the best achievable measurement rate is roughly 8*800 us (for the time
>>>>> spent in i2c-core) i.e. <= 156Hz with Beagle Bone Black.
>>>>>
>>>>> This change set uses a register mask to allow for the readout of a
>>>>> single
>>>>> i2c register at a time. Furthermore, performing subsequent reads on the
>>>>> same register will make use of the ability of the i2c chip to retain
>>>>> the
>>>>> last reg offset, hence use a shorter i2c message (roughly 400us
>>>>> instead of
>>>>> 800us spent in i2c-core.c).
>>>>>
>>>> That doesn't work. There could be accesses from other sources (such as
>>>> through
>>>> i2c-dev, or in multi-master systems) between two reads.
>>>
>>> Re-setting the register address with each read transaction will not
>>> prevent another master to change the configuration in your back, in
>>> this case. That sounds like a general issue of concurrent clients for
>>> one device, this is beyond just reading one register IMO.
>>>
>> That is an invasive change, though, not just a simple read. Sure, it is
>> a risk as well. But it is a different level of risk than someone using
>> i2cget or i2cdump while the driver is running.
>>
> Yes, I get your point.
>
>>>>
>>>>> The best readout rate for a single measurement is now around 2kHz. And
>>>>> for
>>>>> four measurements around (1/(4*800us) = 312 Hz. Since for any readout
>>>>> rate
>>>>> faster than 160 Hz the interval is set by the i2c transactions
>>>>> completion,
>>>>> the 'last-update' anti-flooding code will not have a limiting effect in
>>>>> practice. Hence I also remove the elapsed time checking in the hwmon
>>>>> driver
>>>>> for ina2xx.
>>>>>
>>>>> To summarize, the patch provides a max bandwidth improvement with hwmon
>>>>> client apps from ~160 Hz to ~320 Hz, and better in single-channel
>>>>> polling mode.
>>>>>
>>>> Overall your patch pretty much re-implements regmap. Since you drop
>>>> caching,
>>>> it is also unnecessary to read all registers at a time, so you can
>>>> just use
>>>> a function to read _one_ register and returns its value (with retries).
>>>> Or use regmap. Either case, do_update() and ina2xx_update_device()
>>>> are no
>>>> longer needed.
>>> Agreed.
>>>
>>>>
>>>> If you want to convert the driver to regmap, just look for 'regmap' in
>>>> drivers/hwmon for examples.
>>>
>>> Fair enough, but based on your comments, I may look into an iio driver
>>> instead for this device, given our application, rather than 'twisting'
>>> the hwmon interface.
>>>
>>
>> Sorry, you lost me there. How are you twisting the hwmon interface ?
>> Because I am concerned about multiple accesses from multiple sources ?
>> How is iio going to solve that problem ? By ignoring it ?
>
> Sure someone can still use i2c diag tools as you said, you have a point here. But similarly, someone can use /dev/mem to remap stuff and peek/poke mm registers, and to my knowledge we do not generally design drivers or subsystems with retries and feature limitations to cope with potential use of diag and debug facilities.
>
Depends on the system, and on the use case. Many systems I deal with
are multi-master, and user space does end up accessing chips using i2c-dev.
Drivers are (supposed to be) designed with as much multi-master access
safety as possible. I had patches rejected because they broke multi-master
support by sending two commands depending on each other in a sequence.
Using /dev/mem and peek/poke as counter-examples isn't really appropriate
here, so I won't comment further on it.
Thanks,
Guenter
next prev parent reply other threads:[~2015-10-20 17:00 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-19 16:21 [lm-sensors] [RFC] hwmon: ina2xx: allow for actual measurement bandwidth above 160 Hz Marc Titinger
2015-10-19 16:21 ` Marc Titinger
2015-10-20 1:32 ` [lm-sensors] " Guenter Roeck
2015-10-20 1:32 ` Guenter Roeck
2015-10-20 7:58 ` [lm-sensors] " Marc Titinger
2015-10-20 7:58 ` Marc Titinger
2015-10-20 8:20 ` [lm-sensors] [PATCH v2] " Marc Titinger
2015-10-20 8:20 ` Marc Titinger
2015-10-20 12:54 ` [lm-sensors] " Guenter Roeck
2015-10-20 12:54 ` Guenter Roeck
2015-10-20 13:17 ` [lm-sensors] " Marc Titinger
2015-10-20 13:17 ` Marc Titinger
2015-10-20 13:30 ` [lm-sensors] " Guenter Roeck
2015-10-20 13:30 ` Guenter Roeck
2015-10-20 13:46 ` [lm-sensors] " Marc Titinger
2015-10-20 13:46 ` Marc Titinger
2015-10-20 17:00 ` Guenter Roeck [this message]
2015-10-20 17:00 ` Guenter Roeck
2015-10-21 7:46 ` [lm-sensors] " Marc Titinger
2015-10-21 7:46 ` Marc Titinger
2015-10-20 13:52 ` [lm-sensors] " Michael Turquette
2015-10-20 13:52 ` Michael Turquette
2015-10-23 16:13 ` [lm-sensors] [RFC] hwmon: ina2xx: port to using remap, improve bandwidth Marc Titinger
2015-10-23 16:13 ` Marc Titinger
2015-10-23 16:49 ` [lm-sensors] " kbuild test robot
2015-10-23 16:49 ` kbuild test robot
2015-10-23 16:52 ` [lm-sensors] " Guenter Roeck
2015-10-23 16:52 ` Guenter Roeck
2015-10-23 20:35 ` [lm-sensors] " Marc Titinger
2015-10-23 20:35 ` Marc Titinger
2015-10-24 2:21 ` [lm-sensors] " Guenter Roeck
2015-10-24 2:21 ` Guenter Roeck
2015-10-24 12:45 ` [lm-sensors] " Guenter Roeck
2015-10-24 12:45 ` Guenter Roeck
2015-10-26 16:24 ` [lm-sensors] [PATCH 0/2] hwmon: ina2xx: convert driver to using regmap Marc Titinger
2015-10-26 16:24 ` Marc Titinger
2015-10-26 16:24 ` [lm-sensors] [PATCH 1/2] " Marc Titinger
2015-10-26 16:24 ` Marc Titinger
2015-10-27 1:02 ` [lm-sensors] " Guenter Roeck
2015-10-27 1:02 ` Guenter Roeck
2015-10-27 1:12 ` [lm-sensors] " Guenter Roeck
2015-10-27 1:12 ` Guenter Roeck
2015-10-27 9:51 ` [lm-sensors] [PATCH v2 " Marc Titinger
2015-10-27 9:51 ` Marc Titinger
2015-10-27 9:51 ` [lm-sensors] [PATCH v2 2/2] hwmon: ina2xx: give precedence to DT over checking for platform data Marc Titinger
2015-10-27 9:51 ` Marc Titinger
2015-10-28 2:47 ` [lm-sensors] [PATCH v2 1/2] hwmon: ina2xx: convert driver to using regmap Guenter Roeck
2015-10-28 2:47 ` Guenter Roeck
2015-10-28 9:23 ` [lm-sensors] " Marc Titinger
2015-10-28 9:23 ` Marc Titinger
2015-10-26 16:24 ` [lm-sensors] [PATCH 2/2] hwmon: ina2xx: give precedence to DT over checking for platform data Marc Titinger
2015-10-26 16:24 ` Marc Titinger
2015-10-27 1:10 ` [lm-sensors] " Guenter Roeck
2015-10-27 1:10 ` Guenter Roeck
2015-10-23 16:55 ` [lm-sensors] [RFC] hwmon: ina2xx: port to using remap, improve bandwidth kbuild test robot
2015-10-23 16:55 ` kbuild test robot
2015-10-23 20:10 ` [lm-sensors] " kbuild test robot
2015-10-23 20:10 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56267343.8060601@roeck-us.net \
--to=linux@roeck-us.net \
--cc=bcousson@baylibre.com \
--cc=jdelvare@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=mtitinger@baylibre.com \
--cc=mturquette@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.