From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH 5/5] gpiolib: notify user-space about in-kernel line state changes
Date: Sat, 5 Oct 2024 17:54:36 +0800 [thread overview]
Message-ID: <20241005095436.GB238189@rigel> (raw)
In-Reply-To: <CAMRc=MdU5+AC4PyPjuXuG_S7R59OJ-DaaCdX2fZfoCcs5BveJg@mail.gmail.com>
On Sat, Oct 05, 2024 at 11:42:34AM +0200, Bartosz Golaszewski wrote:
> On Sat, Oct 5, 2024 at 9:46 AM Kent Gibson <warthog618@gmail.com> wrote:
> >
> > On Fri, Oct 04, 2024 at 04:43:26PM +0200, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > >
> > > There is a problem with gpiod_direction_output/input(), namely the fact
> > > that they can be called both from sleeping as well as atomic context. We
> > > cannot call the blocking notifier from atomic and we cannot switch to
> > > atomic notifier because the pinctrl functions we call higher up the stack
> > > take a mutex. Let's instead use a workqueue and schedule a task to emit
> > > the event from process context on the unbound system queue for minimal
> > > latencies.
> > >
> >
> > So now there is a race between the state of the desc changing and the
> > notified reading it?
> >
>
> Theoretically? Well, yes... In practice I don't think this would
> matter. But I understand the concern and won't insist if it's a
> deal-breaker for you.
>
I don't like that correctness depends on timing, so this is a deal
breaker for me as it stands. I would like to see the relevant state passed
via the notifier chain, rather than assuming it can be pulled from the desc
when the notifier is eventually called.
Cheers,
Kent.
> Ideally we'd switch to an atomic notifier but I don't have a good idea
> on how to handle pinctrl_gpio_can_use_line(). It digs deep into the
> pinctrl code and it's all synchronized with a mutex. Unlike GPIO, it
> doesn't make any sense to spend days converting pinctrl to SRCU for a
> single corner-case.
>
> I wanted to use in_atomic() to determine whether we can emit the event
> immediately or (if we're in interrupt or with a spinlock taken) we
> should use a workqueue as a fallback but checkpatch.pl is very adamant
> about it being an error (in capital reds).
>
> Bart
next prev parent reply other threads:[~2024-10-05 9:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 14:43 [PATCH 0/5] gpio: notify user-space about config changes in the kernel Bartosz Golaszewski
2024-10-04 14:43 ` [PATCH 1/5] gpiolib: use v2 defines for line state change events Bartosz Golaszewski
2024-10-04 14:43 ` [PATCH 2/5] gpiolib: unify two loops initializing GPIO descriptors Bartosz Golaszewski
2024-10-09 16:09 ` Linus Walleij
2024-10-04 14:43 ` [PATCH 3/5] gpio: cdev: update flags at once when reconfiguring from user-space Bartosz Golaszewski
2024-10-09 16:10 ` Linus Walleij
2024-10-04 14:43 ` [PATCH 4/5] gpiolib: simplify notifying user-space about line requests Bartosz Golaszewski
2024-10-05 3:46 ` Kent Gibson
2024-10-05 9:34 ` Bartosz Golaszewski
2024-10-05 9:49 ` Kent Gibson
2024-10-04 14:43 ` [PATCH 5/5] gpiolib: notify user-space about in-kernel line state changes Bartosz Golaszewski
2024-10-05 7:46 ` Kent Gibson
2024-10-05 9:42 ` Bartosz Golaszewski
2024-10-05 9:54 ` Kent Gibson [this message]
2024-10-05 18:45 ` Bartosz Golaszewski
2024-10-05 19:11 ` Kent Gibson
2024-10-06 13:29 ` [PATCH 0/5] gpio: notify user-space about config changes in the kernel Kent Gibson
2024-10-08 8:22 ` (subset) " Bartosz Golaszewski
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=20241005095436.GB238189@rigel \
--to=warthog618@gmail.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).