From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@kernel.org>
Cc: Adrian Ambrozewicz <aambrozewicz@nvidia.com>, linux-gpio@vger.kernel.org
Subject: Re: [PATCH] gpiolib: cdev: don't record a line direction the driver refused
Date: Fri, 16 Oct 2026 17:14:20 +0800 [thread overview]
Message-ID: <20261016091420.GA63617@rigel> (raw)
In-Reply-To: <CAMRc=McOWzuqr9qcrbaL4U2_Y==-XfWYo44XVgTkB20JW_5EFw@mail.gmail.com>
On Fri, Oct 16, 2026 at 03:23:24AM -0500, Bartosz Golaszewski wrote:
> On Thu, 15 Oct 2026 17:37:14 +0200, Kent Gibson <warthog618@gmail.com> said:
> >
> >> We can't protect the flags with mutex or spinlock due to the multitude of
> >> issues that forced us to use SRCU. We could maybe consider atomic_t for the
> >> flags field and that would allow us to use various atomic ops and possibly it
> >> would be enough to cover all the read-modify-write cases we have. I need to
> >> think about it and will also ask the clanker for help.
> >>
> >
> > I was thinking along the lines of reverting to atomic bitops directly
> > on the flags, e.g. reverting b7adfb6076ff, without changing the
> > underlying type to atomic_t.
> > Given that most of the time we are operating on individual flags.
> >
>
> That's still two threads fighting over the flags effectively, right? Ideally
> we should modify the entire set of flags at once. If that proves to be
> impossible, going back to atomic bitops is probably the next best thing.
>
Yeah, that change wouldn't resolve that conflict - it is just about
deciding which framework you plan to use for the flags.
The IRQ flag problem, and any other flag contention lurking, needs to be
addressed separately either way.
> > With atomic_t you could also use xchg variants for bulk ops?
> >
>
> I'm not following, could you rephrase or give an example?
>
I mean atomic_xchg(), atomic_cmpxchg() etc.
I thought atomic_t was intended for counters, not bitmaps of flags, and
I don't have any example, but I expect the code to be pretty hideous -
You would need to READ_ONCE(), check the flags are in a suitable state,
update them, then atomic_try_cmpxchg() with your updated value.
Rinse and repeat if the try_cmpxchg fails.
> >>
> >> Definitely! I don't see why I would ever be against extending the test
> >> coverage. :)
> >>
> >
> > Ok, I'll try to give it some thought.
> >
>
> Please also take a look at gpiolib-kunit.c. It may be a better fit for this
> kind of testing.
Will do, but I was thinking of driving error paths in userspace libraries as
well.
Cheers,
Kent.
next prev parent reply other threads:[~2026-10-16 9:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 13:49 [PATCH] gpiolib: cdev: don't record a line direction the driver refused Adrian Ambrozewicz
2026-10-12 14:04 ` sashiko-bot
2026-10-14 4:36 ` Kent Gibson
2026-10-15 13:36 ` Bartosz Golaszewski
2026-10-15 15:37 ` Kent Gibson
2026-10-16 7:46 ` Adrian Ambrozewicz
2026-10-16 8:37 ` Kent Gibson
2026-10-16 8:57 ` Bartosz Golaszewski
2026-10-16 9:19 ` Adrian Ambrozewicz
2026-10-16 8:23 ` Bartosz Golaszewski
2026-10-16 9:14 ` Kent Gibson [this message]
2026-10-14 4:56 ` Kent Gibson
2026-10-16 7:46 ` Adrian Ambrozewicz
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=20261016091420.GA63617@rigel \
--to=warthog618@gmail.com \
--cc=aambrozewicz@nvidia.com \
--cc=brgl@kernel.org \
--cc=linux-gpio@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 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.