Re: [PATCH v2 3/4] iio: accel: wsen-itds accel documentation
From: Jonathan Cameron
Date: Mon May 11 2020 - 13:31:08 EST
On Sun, 10 May 2020 20:11:55 +0200
Saravanan Sekar <saravanan@xxxxxxxxxxx> wrote:
> Hi Jonathan,
>
> On 03/05/20 2:01 pm, Jonathan Cameron wrote:
> > On Wed, 29 Apr 2020 15:39:42 +0200
> > Saravanan Sekar<saravanan@xxxxxxxxxxx> wrote:
> >
> >> Add documentation about device operating mode and output data range
> >> supported according to operating mode
> >>
> >> Signed-off-by: Saravanan Sekar<saravanan@xxxxxxxxxxx>
> >> ---
> >> .../ABI/testing/sysfs-bus-iio-wsen-itds | 23 +++++++++++++++++++
> >> 1 file changed, 23 insertions(+)
> >> create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-wsen-itds
> >>
> >> diff --git a/Documentation/ABI/testing/sysfs-bus-iio-wsen-itds b/Documentation/ABI/testing/sysfs-bus-iio-wsen-itds
> >> new file mode 100644
> >> index 000000000000..5979f2b8aa1a
> >> --- /dev/null
> >> +++ b/Documentation/ABI/testing/sysfs-bus-iio-wsen-itds
> >> @@ -0,0 +1,23 @@
> >> +What: /sys/bus/iio/devices/iio\:device0/in_accel_samp_freq_available
> >> +KernelVersion: 5.7
> >> +Contact: linux-iio@xxxxxxxxxxxxxxx
> >> +Description:
> >> + Reading gives range of sample frequencies available for current operating mode
> >> + after one data has generated.
> > This is standard ABI so should be the main docs, not here.
> > It also takes absolute precedence over the power modes (as mentioned below, no
> > standard userspace will be able to use those). So if the frequency is
> > only available in high perf mode, then we change to high perf mode.
> >
> >> +
> >> + Access: Read
> >> + Valid values: represented in Hz
> >> + - range [12.5, 1600] for high permormance mode
> >> + - range [1.6, 200] for normal/low power mode
> >> +
> >> +What: /sys/bus/iio/devices/iio\:device0/operating_mode
> >> +KernelVersion: 5.7
> >> +Contact: linux-iio@xxxxxxxxxxxxxxx
> >> +Description:
> >> + Represents the device operating mode. High performance mode gives high output
> >> + data rate and low noise compared to normal mode. Normal mode consumes less
> >> + current. In single shot device enters to lowpower after one data has
> >> + generated.
> >> +
> >> + Access: Read, Write
> >> + Valid values: "lowpower", "normal", "high_perf", "single_shot"
> > The issue with these sort of 'mode' interface is almost no userspace will ever use them.
> > They are too unpredictable across different types of devices.
> I don't understand how can we assume or say no one will use this. The
> device supports multiple features
> and my understanding is driver should support according to device, not
> reverse.
The aim of a subsystem and an ABI definition for such is to 'unify' and provide standard
ways of doing things. It is against that 'standard' that userspace code will generally
be written. So every time we define custom ABI for a device, we have basically written
something that the vast majority of userspace code will never use. The only exception
is code written for a particular device.
So we have two options for features like this:
1) Map them to existing ABI wherever possible - ensure the code people have written
already for userspace will do what they would expect. Here it's a case of providing
'reasonable' configuration for the full range of sampling frequencies. That may
miss some corners that are optimal but we may have to live with that.
2) Define new ABI that is 'generic' so that future user space code can use it.
The problem with power modes is they are extremely device specific, so this second
option is one we have never succeeded with. In theory you could define a set of
modes, but they would need to fully describing. As in you would need a record that
tells userspace every characteristic that is affected by each mode.
To put it bluntly software doesn't read data sheets. (nor for that matter to
most userspace code developers :)
> This is more or
> less device specific and no sure idea about bring all the device in one
> umbrella.
We have existing userspace code - quite a bit of it. That code should work for your device.
It doesn't know about your own magic interface, so it won't use it.
That's the point of standardization around one interface, we want it to work.
Note that the only way we make that happen is to review new ABI very carefully
and often block it entirely.
> > Some of these should also not be exposed to userspace anyway as they are about 'how'
> > you are using the driver. For example, if you aren't doing triggered capture then
> > single_shot is almost always the correct option. Annoyingly I see high performance
> > mode gives lower noise...
> >
> > So no need to expose single_shot to userspace.
> >
> > For the others we are just looking at different power vs speed and accuracy trade offs.
> > Those are better exposed by what they effect. Here the big control for that is
> > sampling frequency.
> >
> > So if we assume the user is never going to touch this control (if it's even there)
> > then we probably want to assume they want the best possible accuracy for whatever
> > frequency they are running at. So transition across the modes to provide that.
> >
> > Should we ever support low power mode? It sounds nice on paper, but in reality
> > userspace won't use so I suspect we should just drop it - certainly in an initial
> > patch submission (as it will hold up acceptance). Even if we did support
> > it, as mentioned above ABI controls will take precedence so we are looking
> > at a 'hint' not a control of mode.
> >
> > ABI is a pain, and we will put a lot of effort into not expanding it unless
> > there is a good usecase plus no way of mapping to existing ABI.
> Obviously without any reason or requirement device manufacture won't
> come-up these kind of feature.
Agreed, there are clear reasons for doing this, but until we understand the
target use case it is very hard to have a discussion about how an ABI will
be expanded.
> I will change the driver as you don't accept at least for initial version.
Great.
Thanks,
Jonathan
>
>
> Thanks,
> Saravanan
>