From: Linus Walleij <linus.walleij@linaro.org>
To: Johan Korsnes <johan.korsnes@remarkable.no>
Cc: linux-gpio@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
Haibo Chen <haibo.chen@nxp.com>
Subject: Re: [PATCH] gpio: vf610: add locking to gpio direction functions
Date: Thu, 6 Feb 2025 19:29:22 +0100 [thread overview]
Message-ID: <CACRpkdaNDJrGZ4Y2PPUWQfm6BprfNACYWD7srs3sYHMEsdX1Ew@mail.gmail.com> (raw)
In-Reply-To: <20250206181714.417433-1-johan.korsnes@remarkable.no>
Hi Johan,
thanks for your patch!
On Thu, Feb 6, 2025 at 7:17 PM Johan Korsnes
<johan.korsnes@remarkable.no> wrote:
> Add locking to `vf610_gpio_direction_input|output()` functions. Without
> this locking, a race condition exists between concurrent calls to these
> functions, potentially leading to incorrect GPIO direction settings.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> Cc: Haibo Chen <haibo.chen@nxp.com>
> Signed-off-by: Johan Korsnes <johan.korsnes@remarkable.no>
Looks correct to me, verified by looking at the most tested
driver gpio-mmio.c and seeing there is a lock there indeed.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> where after a couple of reboots the race was confirmed. I.e., one user
> had to wait before acquiring the lock. With this patch the race has not
> been encountered. It's worth mentioning that any type of debugging
> (printing, tracing, etc.) would "resolve" the issue.
Typical. I would include this in the commit message, people care.
Looking at the driver it seems vf610_gpio_irq_mask()/vf610_gpio_irq_unmask()
could have a similar issue, both write the same register.
Both issues could be fixed by converting the driver to use
gpio-mmio() with bgpio_init() which would also implement
get/set_multiple support for free.
I have no idea why this driver isn't using gpio-mmio.
Not your fault though, just pointing out obvious improvement
opportunities.
Yours,
Linus Walleij
next prev parent reply other threads:[~2025-02-06 18:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 18:17 [PATCH] gpio: vf610: add locking to gpio direction functions Johan Korsnes
2025-02-06 18:23 ` Bartosz Golaszewski
2025-02-06 18:29 ` Linus Walleij [this message]
2025-02-07 6:21 ` Bough Chen
2025-02-10 8:52 ` Johan Korsnes
2025-02-10 9:35 ` Bough Chen
2025-02-13 6:12 ` Johan Korsnes
2025-02-13 6:39 ` Bough Chen
2025-02-13 21:45 ` Linus Walleij
2025-02-13 23:08 ` Linus Walleij
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=CACRpkdaNDJrGZ4Y2PPUWQfm6BprfNACYWD7srs3sYHMEsdX1Ew@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=haibo.chen@nxp.com \
--cc=johan.korsnes@remarkable.no \
--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 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).