From: Andreas Kemnade <andreas@kemnade.info>
To: linus.walleij@linaro.org, brgl@bgdev.pl,
christophe.leroy@csgroup.eu, andy.shevchenko@gmail.com,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
": Tony Lindgren" <tony@atomide.com>,
Aaro Koskinen <aaro.koskinen@iki.fi>,
linux-omap@vger.kernel.org
Cc: Andreas Kemnade <andreas@kemnade.info>
Subject: [PATCH] gpiolib: fix allocation of mixed dynamic/static GPIOs
Date: Thu, 27 Apr 2023 00:03:38 +0200 [thread overview]
Message-ID: <20230426220338.430638-1-andreas@kemnade.info> (raw)
If static allocation and dynamic allocation GPIOs are present,
dynamic allocation pollutes the numberspace for static allocation,
causing static allocation to fail.
Enfore dynamic allocation above GPIO_DYNAMIC_BASE.
Seen on a GTA04 when omap-gpio (static) and twl-gpio (dynamic)
raced.
On that device it is fixed invasively by
commit 92bf78b33b0b4 ("gpio: omap: use dynamic allocation of base")
but lets also fix that for devices where there is still
a mixture of static and dynamic allocation.
Fixes: 7b61212f2a07 ("gpiolib: Get rid of ARCH_NR_GPIOS")
Suggested-by: andy.shevchenko@gmail.com
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
drivers/gpio/gpiolib.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 19bd23044b017..18b68d0aec7db 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -188,6 +188,10 @@ static int gpiochip_find_base(int ngpio)
int base = GPIO_DYNAMIC_BASE;
list_for_each_entry(gdev, &gpio_devices, list) {
+ /* do not pollute area for static allocation */
+ if (gdev->base < GPIO_DYNAMIC_BASE)
+ continue;
+
/* found a free space? */
if (gdev->base >= base + ngpio)
break;
--
2.39.2
next reply other threads:[~2023-04-26 22:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 22:03 Andreas Kemnade [this message]
2023-04-27 5:40 ` [PATCH] gpiolib: fix allocation of mixed dynamic/static GPIOs Christophe Leroy
2023-04-27 6:00 ` Andy Shevchenko
2023-04-27 6:20 ` Christophe Leroy
2023-04-27 10:37 ` Andreas Kemnade
2023-04-27 10:46 ` Andy Shevchenko
2023-04-27 10:55 ` Christophe Leroy
2023-04-27 11:01 ` Andy Shevchenko
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=20230426220338.430638-1-andreas@kemnade.info \
--to=andreas@kemnade.info \
--cc=aaro.koskinen@iki.fi \
--cc=andy.shevchenko@gmail.com \
--cc=brgl@bgdev.pl \
--cc=christophe.leroy@csgroup.eu \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
/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).