From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
linus.walleij@linaro.org, andy@kernel.org
Subject: Re: [PATCH 0/4] gpiolib: cdev: relocate debounce_period_us
Date: Wed, 13 Dec 2023 07:58:04 +0800 [thread overview]
Message-ID: <ZXjzjOtKFoMRhKA-@rigel> (raw)
In-Reply-To: <CAMRc=Me90Lu7Duc8-4xSfDcHQd6M7+0t0O8FAa6jiizp-OO5=Q@mail.gmail.com>
On Tue, Dec 12, 2023 at 06:09:00PM +0100, Bartosz Golaszewski wrote:
> On Tue, Dec 12, 2023 at 6:43 AM Kent Gibson <warthog618@gmail.com> wrote:
> >
> > This series contains minor improvements to gpiolib-cdev.
> >
> > The banner change is relocating the debounce_period_us from gpiolib's
> > struct gpio_desc to cdev's struct line. The first patch stores the
> > field locally in cdev. The second removes the now unused field from
> > gpiolib.
> >
> > The third patch is somewhat related and removes a FIXME from
> > gpio_desc_to_lineinfo(). The FIXME relates to a race condition in
> > the calculation of the used flag, but I would assert that from
> > the userspace perspective the read operation itself is inherently racy.
> > The line being reported as unused in the info provides no guarantee -
> > it just an indicator that requesting the line is likely to succeed -
> > assuming the line is not otherwise requested in the meantime.
> > Give the overall operation is racy, trying to stamp out an unlikely
> > race within the operation is pointless. Accept it as a possibility
> > that has negligible side-effects and reduce the number of locks held
> > simultaneously and the duration that the gpio_lock is held.
> >
> > The fourth patch is unrelated to debounce or info, but addresses Andy's
> > recent assertion that the linereq get/set values functions are confusing
> > and under documented. Figured I may as well add that while I was in
> > there.
> >
> > Kent Gibson (4):
> > gpiolib: cdev: relocate debounce_period_us from struct gpio_desc
> > gpiolib: remove debounce_period_us from struct gpio_desc
> > gpiolib: cdev: reduce locking in gpio_desc_to_lineinfo()
> > gpiolib: cdev: improve documentation of get/set values
> >
> > drivers/gpio/gpiolib-cdev.c | 257 ++++++++++++++++++++++++++++--------
> > drivers/gpio/gpiolib.c | 3 -
> > drivers/gpio/gpiolib.h | 5 -
> > 3 files changed, 201 insertions(+), 64 deletions(-)
> >
> > --
> > 2.39.2
> >
>
> Patches 2-4 look fine, I was about to review patch 1 in detail but I
> thought I'd just throw this one in here before we commit to a specific
> solution.
>
> For some reason I thought this would not work but I'm now considering
> it as an alternative approach: is there anything wrong with adding
> struct kref to struct line, allocating it separately per-line when
> gpio_chardev_data is created, referencing it from struct linereq when
> the line is being requested, and dropping the reference from
> gpio_chardev_data and linereq when either is being removed? Other than
> the increased number of allocations?
>
The collection of struct line always has to be global, right, as both
gpio_chardev_data and linereq are ephemeral. e.g. if one process requests
a line and another checks the lineinfo, those will have distinct
gpio_chardev_data.
But the key issue is that the linereq and struct line lifetimes are
strictly tied - a struct line does not live beyond the containing linereq.
Leaving the struct line alive after the linereq is released is just wrong.
The line has been released back to gpiolib so there can be no
supplemental info left.
If you want any such info to persist beyond the line release then it
should be located in gpiolib itself, not cdev.
Cheers,
Kent.
next prev parent reply other threads:[~2023-12-12 23:58 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 5:42 [PATCH 0/4] gpiolib: cdev: relocate debounce_period_us Kent Gibson
2023-12-12 5:42 ` [PATCH 1/4] gpiolib: cdev: relocate debounce_period_us from struct gpio_desc Kent Gibson
2023-12-13 13:54 ` Andy Shevchenko
2023-12-13 14:27 ` Kent Gibson
2023-12-13 15:40 ` Bartosz Golaszewski
2023-12-13 15:59 ` Kent Gibson
2023-12-13 16:12 ` Andy Shevchenko
2023-12-13 16:15 ` Bartosz Golaszewski
2023-12-13 16:29 ` Andy Shevchenko
2023-12-13 19:03 ` Bartosz Golaszewski
2023-12-13 20:07 ` Andy Shevchenko
2023-12-14 0:18 ` Kent Gibson
2023-12-14 2:15 ` Kent Gibson
2023-12-14 9:40 ` Bartosz Golaszewski
2023-12-14 14:35 ` Andy Shevchenko
2023-12-14 14:47 ` Kent Gibson
2023-12-13 16:14 ` Bartosz Golaszewski
2023-12-13 16:15 ` Kent Gibson
2023-12-13 16:16 ` Bartosz Golaszewski
2023-12-13 16:27 ` Andy Shevchenko
2023-12-12 5:42 ` [PATCH 2/4] gpiolib: remove " Kent Gibson
2023-12-12 5:42 ` [PATCH 3/4] gpiolib: cdev: reduce locking in gpio_desc_to_lineinfo() Kent Gibson
2023-12-13 13:56 ` Andy Shevchenko
2023-12-13 14:07 ` Kent Gibson
2023-12-13 15:05 ` Andy Shevchenko
2023-12-13 15:11 ` Kent Gibson
2023-12-13 15:28 ` Andy Shevchenko
2023-12-12 5:42 ` [PATCH 4/4] gpiolib: cdev: improve documentation of get/set values Kent Gibson
2023-12-12 17:09 ` [PATCH 0/4] gpiolib: cdev: relocate debounce_period_us Bartosz Golaszewski
2023-12-12 23:58 ` Kent Gibson [this message]
2023-12-13 10:03 ` Bartosz Golaszewski
2023-12-13 13:17 ` Kent Gibson
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=ZXjzjOtKFoMRhKA-@rigel \
--to=warthog618@gmail.com \
--cc=andy@kernel.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).