From: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
To: Vladimir Barinov <vladimir.barinov@cogentembedded.com>,
Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Matt Ranostay <mranostay@gmail.com>,
Gregor Boirie <gregor.boirie@parrot.com>,
Sanchayan Maity <maitysanchayan@gmail.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Jeff White <Jeff.White@zii.aero>,
Chris Healy <Chris.Healy@zii.aero>
Subject: Re: [PATCH 2/4] iio: hi8435: avoid garbage event at first enable
Date: Tue, 23 May 2017 10:21:40 +0300 [thread overview]
Message-ID: <f4fca01f-97ea-2cfd-2ee3-b20188415fe9@cogentembedded.com> (raw)
In-Reply-To: <1df453fe-3ea4-a2fb-94e4-7462c2a2fad2@cogentembedded.com>
>> + int ret;
>> + u32 tmp;
>> +
>> + if (state) {
>> + ret = hi8435_readl(priv, HI8435_SO31_0_REG, &tmp);
>> + if (ret < 0)
>> + return ret;
>> + if (tmp & BIT(chan->channel))
>> + priv->event_prev_val |= BIT(chan->channel);
>> + else
>> + priv->event_prev_val &= ~BIT(chan->channel);
>> - priv->event_scan_mask &= ~BIT(chan->channel);
>> - if (state)
>> priv->event_scan_mask |= BIT(chan->channel);
>> + } else
>> + priv->event_scan_mask &= ~BIT(chan->channel);
>>
>
> This will race with hi8435_iio_push_event for priv->event_scan_mask.
I was under impression that mutual-exclusion is provided by core. Now I
see it is not. Will submit a fix soon.
> Since you adding raw access then it is reasonable to initialize
> priv->event_prev_val in hi8435_read_raw.
This will cause complex interdependency between events and raw access.
E.g. should we generate event if change was discovered while processing
raw access from user space? If we do, then we break semantics "events
generated only under trigger". If we don't, we need complex state handling.
> Then use the following sequence for your application:
> 1. read raw value
> 2. enable events
So what if:
- one application calls read raw,
- then, far later, signal changes,
- then, far later, other application enables events?
Should second application get notification of change that happened long
before in enabled events? I think no.
There is fundamental race between start-of-monitoring and
change-of-signal-near-start-of-monitoring. To avoid it, reading signal
must be either atomic with start of monitoring (which is not possible
with IIO API), or done after start of monitoring (which moves handling
of this race to user side).
Nikita
next prev parent reply other threads:[~2017-05-23 7:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-19 14:47 [PATCH 1/4] iio: hi8435: add raw access Nikita Yushchenko
2017-05-19 14:48 ` [PATCH 2/4] iio: hi8435: avoid garbage event at first enable Nikita Yushchenko
2017-05-20 16:34 ` Jonathan Cameron
2017-05-22 18:20 ` Vladimir Barinov
2017-05-23 7:21 ` Nikita Yushchenko [this message]
2017-05-19 14:48 ` [PATCH 3/4] iio: hi8435: make in_voltage_sensing_mode_available visible Nikita Yushchenko
2017-05-20 16:35 ` Jonathan Cameron
2017-05-19 14:48 ` [PATCH 4/4] iio: hi8435: cleanup reset gpio Nikita Yushchenko
2017-05-20 16:37 ` Jonathan Cameron
[not found] ` <18fc343b-d7a4-c5b8-84e6-702af6e94e44@cogentembedded.com>
2017-05-23 8:18 ` Nikita Yushchenko
2017-05-24 11:27 ` Vladimir Barinov
2017-05-24 19:38 ` Jonathan Cameron
2017-05-25 6:27 ` Nikita Yushchenko
2017-05-28 15:42 ` Jonathan Cameron
2017-05-29 7:57 ` Nikita Yushchenko
2017-05-29 17:08 ` Linus Walleij
2017-05-20 16:33 ` [PATCH 1/4] iio: hi8435: add raw access Jonathan Cameron
2017-05-22 17:27 ` Vladimir Barinov
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=f4fca01f-97ea-2cfd-2ee3-b20188415fe9@cogentembedded.com \
--to=nikita.yoush@cogentembedded.com \
--cc=Chris.Healy@zii.aero \
--cc=Jeff.White@zii.aero \
--cc=gregor.boirie@parrot.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maitysanchayan@gmail.com \
--cc=mranostay@gmail.com \
--cc=pmeerw@pmeerw.net \
--cc=vladimir.barinov@cogentembedded.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome