From: Gregor Boirie <gregor.boirie@parrot.com>
To: Jonathan Cameron <jic23@kernel.org>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: <linux-iio@vger.kernel.org>, Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH v1 3/3] iio:pressure: initial zpa2326 barometer support
Date: Tue, 30 Aug 2016 18:18:12 +0200 [thread overview]
Message-ID: <57C5B1C4.8090509@parrot.com> (raw)
In-Reply-To: <8a47f701-1cff-7c5c-639b-ec2258c62025@kernel.org>
On 08/29/2016 09:01 PM, Jonathan Cameron wrote:
> On 25/08/16 15:45, Gregor Boirie wrote:
>> Answers inline
>>
>> On 08/25/2016 08:34 AM, Peter Meerwald-Stadler wrote:
>>
>>>> +
>>>> + zpa_init_runtime(slave);
>>>> +
>>>> + err = devm_iio_device_register(slave, indio_dev);
>>> can't use devm_ register if there is a non-empty remove()
>> Removal hooks are registered onto bus specific devices not onto
>> IIO ones. Enabling devm debug outputs a removal flow trace that
>> seems correct. Is this really wrong ?
> Yes. The unwind of devm_iio_device_register will occur after the
> whatever is in the remove function. As devm_iio_device_unregister
> is responsible for removal of the userspace and other interfaces
> until that happens they are still present.
>
> Hence whilst a remove is going on the device can be powered
> down but the interfaces still exposed. A read at that point
> is going to cause some an error to occur.
>
> Hence, using the devm form is fine if everything else is
> handled automatically, i.e. there is nothing in remove.
> Otherwise, you almost always have a race condition.
>
> It's a minor one given how often people remove modules, but
> worth cleaning up anyway!
Got it.
But something still makes me feel uncomfortable. Shouldn't we ensure the
bus specific driver (i.e., zpa2326_i2c or zpa2326_spi in this case) be
refcounted
upon entry into the IIO layer ? Using try_module_get()/module_put() would :
* prevent any attempt to remove module while being used
* prevent any attempt to use module while it is going away.
I'm not quite sure here because of possible race conditions however
(feels like
mixing devm_ and module layers).
Anyway, it seems quite strange module removal succeeds despite being
under use
by userspace. This leads to inconsistent system state where userspace
process
gets stuck in poll syscall, waiting for data that will never come since
modprobing
module again will in the end allocate an new IIO device, etc...
confused,
Grégor.
>
> Jonathan
>> Many thanks for the review. Regards,
>> Greg.
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-08-30 16:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 14:58 [PATCH v1 0/3] iio: devm helpers and Murata zpa2326 barometer support Gregor Boirie
2016-08-24 14:58 ` [PATCH v1 1/3] iio:trigger: add resource managed (un)register Gregor Boirie
2016-08-24 14:58 ` [PATCH v1 2/3] iio: add resource managed triggered buffer init helpers Gregor Boirie
2016-08-24 14:58 ` [PATCH v1 3/3] iio:pressure: initial zpa2326 barometer support Gregor Boirie
2016-08-25 6:34 ` Peter Meerwald-Stadler
2016-08-25 14:45 ` Gregor Boirie
2016-08-29 19:01 ` Jonathan Cameron
2016-08-30 16:18 ` Gregor Boirie [this message]
2016-09-03 16:46 ` Jonathan Cameron
2016-08-25 8:38 ` Linus Walleij
2016-08-26 16:27 ` Gregor Boirie
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=57C5B1C4.8090509@parrot.com \
--to=gregor.boirie@parrot.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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.