* [PATCH v2 1/3] gpio: shared: assign the correct firmware node for reset-gpio use-case
2026-01-06 9:34 [PATCH v2 0/3] gpio: shared: another set of small fixes Bartosz Golaszewski
@ 2026-01-06 9:34 ` Bartosz Golaszewski
2026-01-06 9:34 ` [PATCH v2 2/3] gpio: shared: fix a race condition Bartosz Golaszewski
` (4 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2026-01-06 9:34 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Marek Szyprowski
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
When we defer probe due to unlucky timing of adding the lookup table, we
assign the matching firmware node to the shared reference for the future
probing. However, the fwnode we assign is wrong so fix it and assign the
one associated with the reset-gpio device.
Fixes: 49416483a953 ("gpio: shared: allow sharing a reset-gpios pin between reset-gpio and gpiolib")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Closes: https://lore.kernel.org/all/00107523-7737-4b92-a785-14ce4e93b8cb@samsung.com/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpio/gpiolib-shared.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index baf7e07a3bb887dab8155078666a15779e304409..a68af06a6cc4e1e33946d7f200cecd4d3dc066af 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -417,7 +417,7 @@ static bool gpio_shared_dev_is_reset_gpio(struct device *consumer,
* Reuse the fwnode of the real device, next time we'll use it
* in the normal path.
*/
- ref->fwnode = fwnode_handle_get(real_ref->fwnode);
+ ref->fwnode = fwnode_handle_get(reset_fwnode);
return true;
}
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v2 2/3] gpio: shared: fix a race condition
2026-01-06 9:34 [PATCH v2 0/3] gpio: shared: another set of small fixes Bartosz Golaszewski
2026-01-06 9:34 ` [PATCH v2 1/3] gpio: shared: assign the correct firmware node for reset-gpio use-case Bartosz Golaszewski
@ 2026-01-06 9:34 ` Bartosz Golaszewski
2026-01-06 9:34 ` [PATCH v2 3/3] gpio: shared: don't allocate the lookup table until we really need it Bartosz Golaszewski
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2026-01-06 9:34 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Marek Szyprowski
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
When matching the reset-gpio reference with the actual firmware node
consuming the GPIO, we also need to lock the structure associated with
the latter as it can change while we're doing it.
Due to triggering lockdep false-positives, we need to use a per-reference
lockdep class but accidentally, this also allows us to remove the
previous lockdep workaround for cleaner code.
Fixes: 49416483a953 ("gpio: shared: allow sharing a reset-gpios pin between reset-gpio and gpiolib")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Closes: https://lore.kernel.org/all/00107523-7737-4b92-a785-14ce4e93b8cb@samsung.com/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpio/gpiolib-shared.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index a68af06a6cc4e1e33946d7f200cecd4d3dc066af..4c57b0928760c3f9f251ca88cfc54ee5887d50c9 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -38,6 +38,7 @@ struct gpio_shared_ref {
int dev_id;
/* Protects the auxiliary device struct and the lookup table. */
struct mutex lock;
+ struct lock_class_key lock_key;
struct auxiliary_device adev;
struct gpiod_lookup_table *lookup;
};
@@ -99,7 +100,8 @@ static struct gpio_shared_ref *gpio_shared_make_ref(struct fwnode_handle *fwnode
ref->flags = flags;
ref->con_id = no_free_ptr(con_id_cpy);
ref->fwnode = fwnode;
- mutex_init(&ref->lock);
+ lockdep_register_key(&ref->lock_key);
+ mutex_init_with_key(&ref->lock, &ref->lock_key);
return no_free_ptr(ref);
}
@@ -378,6 +380,11 @@ static bool gpio_shared_dev_is_reset_gpio(struct device *consumer,
* arguments match the ones from this consumer's node.
*/
list_for_each_entry(real_ref, &entry->refs, list) {
+ if (real_ref == ref)
+ continue;
+
+ guard(mutex)(&real_ref->lock);
+
if (!real_ref->fwnode)
continue;
@@ -568,15 +575,6 @@ void gpio_device_teardown_shared(struct gpio_device *gdev)
if (!device_match_fwnode(&gdev->dev, entry->fwnode))
continue;
- /*
- * For some reason if we call synchronize_srcu() in GPIO core,
- * descent here and take this mutex and then recursively call
- * synchronize_srcu() again from gpiochip_remove() (which is
- * totally fine) called after gpio_shared_remove_adev(),
- * lockdep prints a false positive deadlock splat. Disable
- * lockdep here.
- */
- lockdep_off();
list_for_each_entry(ref, &entry->refs, list) {
guard(mutex)(&ref->lock);
@@ -589,7 +587,6 @@ void gpio_device_teardown_shared(struct gpio_device *gdev)
gpio_shared_remove_adev(&ref->adev);
}
- lockdep_on();
}
}
@@ -685,6 +682,7 @@ static void gpio_shared_drop_ref(struct gpio_shared_ref *ref)
{
list_del(&ref->list);
mutex_destroy(&ref->lock);
+ lockdep_unregister_key(&ref->lock_key);
kfree(ref->con_id);
ida_free(&gpio_shared_ida, ref->dev_id);
fwnode_handle_put(ref->fwnode);
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH v2 3/3] gpio: shared: don't allocate the lookup table until we really need it
2026-01-06 9:34 [PATCH v2 0/3] gpio: shared: another set of small fixes Bartosz Golaszewski
2026-01-06 9:34 ` [PATCH v2 1/3] gpio: shared: assign the correct firmware node for reset-gpio use-case Bartosz Golaszewski
2026-01-06 9:34 ` [PATCH v2 2/3] gpio: shared: fix a race condition Bartosz Golaszewski
@ 2026-01-06 9:34 ` Bartosz Golaszewski
2026-01-06 13:22 ` [PATCH v2 0/3] gpio: shared: another set of small fixes Mark Brown
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2026-01-06 9:34 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Marek Szyprowski
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
We allocate memory for the GPIO lookup table at the top of
gpio_shared_add_proxy_lookup() but we don't use it until the very end.
Depending on the timing, we may return earlier. Move the allocation
towards the end.
Fixes: a060b8c511ab ("gpiolib: implement low-level, shared GPIO support")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpio/gpiolib-shared.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index 4c57b0928760c3f9f251ca88cfc54ee5887d50c9..076d8642675c2723c8938cbd22b1b51014c23871 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -443,14 +443,10 @@ int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id,
unsigned long lflags)
{
const char *dev_id = dev_name(consumer);
+ struct gpiod_lookup_table *lookup;
struct gpio_shared_entry *entry;
struct gpio_shared_ref *ref;
- struct gpiod_lookup_table *lookup __free(kfree) =
- kzalloc(struct_size(lookup, table, 2), GFP_KERNEL);
- if (!lookup)
- return -ENOMEM;
-
list_for_each_entry(entry, &gpio_shared_list, list) {
list_for_each_entry(ref, &entry->refs, list) {
guard(mutex)(&ref->lock);
@@ -482,6 +478,10 @@ int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id,
if (!key)
return -ENOMEM;
+ lookup = kzalloc(struct_size(lookup, table, 2), GFP_KERNEL);
+ if (!lookup)
+ return -ENOMEM;
+
pr_debug("Adding machine lookup entry for a shared GPIO for consumer %s, with key '%s' and con_id '%s'\n",
dev_id, key, ref->con_id ?: "none");
@@ -489,7 +489,7 @@ int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id,
lookup->table[0] = GPIO_LOOKUP(no_free_ptr(key), 0,
ref->con_id, lflags);
- ref->lookup = no_free_ptr(lookup);
+ ref->lookup = lookup;
gpiod_add_lookup_table(ref->lookup);
return 0;
--
2.47.3
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2 0/3] gpio: shared: another set of small fixes
2026-01-06 9:34 [PATCH v2 0/3] gpio: shared: another set of small fixes Bartosz Golaszewski
` (2 preceding siblings ...)
2026-01-06 9:34 ` [PATCH v2 3/3] gpio: shared: don't allocate the lookup table until we really need it Bartosz Golaszewski
@ 2026-01-06 13:22 ` Mark Brown
2026-01-07 8:31 ` Bartosz Golaszewski
2026-01-08 12:13 ` Cosmin Tanislav
5 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2026-01-06 13:22 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, Bartosz Golaszewski, Marek Szyprowski, linux-gpio,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 274 bytes --]
On Tue, Jan 06, 2026 at 10:34:20AM +0100, Bartosz Golaszewski wrote:
> Here are three more patches fixing issues reported with shared GPIO
> management.
This fixes the problems I'm seeing on at least
k3-am625-verdin-wifi-mallow:
Tested-by: Mark Brown <broonie@kernel.org>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2 0/3] gpio: shared: another set of small fixes
2026-01-06 9:34 [PATCH v2 0/3] gpio: shared: another set of small fixes Bartosz Golaszewski
` (3 preceding siblings ...)
2026-01-06 13:22 ` [PATCH v2 0/3] gpio: shared: another set of small fixes Mark Brown
@ 2026-01-07 8:31 ` Bartosz Golaszewski
2026-01-08 12:13 ` Cosmin Tanislav
5 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2026-01-07 8:31 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Marek Szyprowski,
Bartosz Golaszewski
Cc: linux-gpio, linux-kernel
On Tue, 06 Jan 2026 10:34:20 +0100, Bartosz Golaszewski wrote:
> Here are three more patches fixing issues reported with shared GPIO
> management.
>
>
Applied, thanks!
[1/3] gpio: shared: assign the correct firmware node for reset-gpio use-case
commit: 0fe50631791bd3504dc7f32af6421bd4041f14aa
[2/3] gpio: shared: fix a race condition
commit: 476e44d06fc107f8cd99695d8e4f1c792dfc3379
[3/3] gpio: shared: don't allocate the lookup table until we really need it
commit: a80208072df8f4ceb53cd905c1f4362f84ce397f
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2 0/3] gpio: shared: another set of small fixes
2026-01-06 9:34 [PATCH v2 0/3] gpio: shared: another set of small fixes Bartosz Golaszewski
` (4 preceding siblings ...)
2026-01-07 8:31 ` Bartosz Golaszewski
@ 2026-01-08 12:13 ` Cosmin Tanislav
2026-01-08 12:18 ` Bartosz Golaszewski
2026-01-08 12:22 ` Marek Szyprowski
5 siblings, 2 replies; 10+ messages in thread
From: Cosmin Tanislav @ 2026-01-08 12:13 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij, Bartosz Golaszewski,
Marek Szyprowski
Cc: linux-gpio, linux-kernel
On 1/6/26 11:34 AM, Bartosz Golaszewski wrote:
> Here are three more patches fixing issues reported with shared GPIO
> management.
>
I'm still getting some intermittent failures on today's next (which
contains this series).
This does not seem to happen on every boot, so it might be some race.
[ 2.169655] Mem abort info:
[ 2.169663] ESR = 0x0000000096000004
[ 2.169670] EC = 0x25: DABT (current EL), IL = 32 bits
[ 2.176773] ehci-platform 92040100.usb: irq 64, io mem 0x92040100
[ 2.186626] SET = 0, FnV = 0
[ 2.204264] renesas_sdhi_internal_dmac 92090000.mmc: mmc1 base at
0x0000000092090000, max clock rate 200 MHz
[ 2.204308] ehci-platform 92040100.usb: USB 2.0 started, EHCI 1.10
[ 2.208714] hub 2-0:1.0: USB hub found
[ 2.214345] EA = 0, S1PTW = 0
[ 2.222949] hub 2-0:1.0: 1 port detected
[ 2.231502] FSC = 0x04: level 0 translation fault
[ 2.239779] hub 1-0:1.0: USB hub found
[ 2.248022] Data abort info:
[ 2.256579] hub 1-0:1.0: 1 port detected
[ 2.264724] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
[ 2.487291] CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[ 2.493148] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[ 2.499300] [0000000000000000] user address but active_mm is swapper
[ 2.506556] Internal error: Oops: 0000000096000004 [#1] SMP
[ 2.513092] Modules linked in:
[ 2.516610] CPU: 3 UID: 0 PID: 48 Comm: kworker/u16:2 Not tainted
6.19.0-rc4-next-20260108+ #246 PREEMPT
[ 2.527564] Hardware name: Renesas RZ/T2H EVK Board based on
r9a09g077m44 (DT)
[ 2.535903] Workqueue: async async_run_entry_fn
[ 2.541141] pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS
BTYPE=--)
[ 2.549076] pc : gpiod_direction_input_nonotify+0x18/0x22c
[ 2.555408] lr : gpiod_configure_flags+0x1c4/0x380
[ 2.560835] sp : ffff8000830e38c0
[ 2.564530] x29: ffff8000830e38c0 x28: ffff80008243894f x27:
ffff0001808f6410
[ 2.572773] x26: ffff800081e77160 x25: 0000000000000000 x24:
0000000000000000
[ 2.580914] x23: 0000000000000000 x22: ffff800081e77160 x21:
ffff80008243892f
[ 2.589054] x20: 0000000000000000 x19: 0000000000000000 x18:
000000000000000a
[ 2.597101] x17: ffff80007fffffff x16: ffff000180054480 x15:
0000000000000000
[ 2.605345] x14: 0000000000000000 x13: ffff800080ed7600 x12:
0000000000000000
[ 2.613485] x11: 0000000000000000 x10: 00007fff01adbb48 x9 :
0000000000000005
[ 2.621626] x8 : 0101010101010101 x7 : fffffdffc6009b00 x6 :
051573657480ffff
[ 2.629869] x5 : 0000000000000138 x4 : 0000000000000000 x3 :
0000000000000001
[ 2.638113] x2 : 0000000000000000 x1 : 0000000000000000 x0 :
0000000000000000
[ 2.646254] Call trace:
[ 2.648968] gpiod_direction_input_nonotify+0x18/0x22c (P)
[ 2.655299] gpiod_configure_flags+0x1c4/0x380
[ 2.660428] gpiod_find_and_request+0x14c/0x524
[ 2.665650] gpiod_get_index+0x58/0x7c
[ 2.669874] devm_gpiod_get_index+0x20/0x90
[ 2.674695] mmc_gpiod_request_ro+0x30/0xb0
[ 2.679525] mmc_of_parse+0x100/0x688
[ 2.683749] tmio_mmc_host_alloc+0x80/0x110
[ 2.688571] renesas_sdhi_probe+0x150/0x760
[ 2.693392] renesas_sdhi_internal_dmac_probe+0x64/0x80
[ 2.699357] platform_probe+0x5c/0xa4
[ 2.703581] really_probe+0xbc/0x2ac
[ 2.707703] __driver_probe_device+0x78/0x118
[ 2.712728] driver_probe_device+0x3c/0x178
[ 2.717550] __device_attach_driver+0xb8/0x140
[ 2.722678] bus_for_each_drv+0x88/0xe8
[ 2.727099] __device_attach_async_helper+0xb0/0xd4
[ 2.732526] async_run_entry_fn+0x34/0xe0
[ 2.737048] process_one_work+0x150/0x290
[ 2.741673] worker_thread+0x18c/0x300
[ 2.745915] kthread+0x118/0x124
[ 2.749635] ret_from_fork+0x10/0x20
[ 2.753762] Code: 910003fd a90153f3 aa0003f4 a9025bf5 (f9400013)
[ 2.760790] ---[ end trace 0000000000000000 ]---
After running ./scripts/decode_stacktrace.sh
[ 2.169655] Mem abort info:
[ 2.169663] ESR = 0x0000000096000004
[ 2.169670] EC = 0x25: DABT (current EL), IL = 32 bits
[ 2.176773] ehci-platform 92040100.usb: irq 64, io mem 0x92040100
[ 2.186626] SET = 0, FnV = 0
[ 2.204264] renesas_sdhi_internal_dmac 92090000.mmc: mmc1 base at
0x0000000092090000, max clock rate 200 MHz
[ 2.204308] ehci-platform 92040100.usb: USB 2.0 started, EHCI 1.10
[ 2.208714] hub 2-0:1.0: USB hub found
[ 2.214345] EA = 0, S1PTW = 0
[ 2.222949] hub 2-0:1.0: 1 port detected
[ 2.231502] FSC = 0x04: level 0 translation fault
[ 2.239779] hub 1-0:1.0: USB hub found
[ 2.248022] Data abort info:
[ 2.256579] hub 1-0:1.0: 1 port detected
[ 2.264724] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
[ 2.487291] CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[ 2.493148] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[ 2.499300] [0000000000000000] user address but active_mm is swapper
[ 2.506556] Internal error: Oops: 0000000096000004 [#1] SMP
[ 2.513092] Modules linked in:
[ 2.527564] Hardware name: Renesas RZ/T2H EVK Board based on
r9a09g077m44 (DT)
[ 2.535903] Workqueue: async async_run_entry_fn
[ 2.541141] pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS
BTYPE=--)
[ 2.549076] pc : gpiod_direction_input_nonotify
(drivers/gpio/gpiolib.h:231 (discriminator 1)
drivers/gpio/gpiolib.c:2863 (discriminator 1))
[ 2.555408] lr : gpiod_configure_flags (drivers/gpio/gpiolib.c:4956)
[ 2.560835] sp : ffff8000830e38c0
[ 2.564530] x29: ffff8000830e38c0 x28: ffff80008243894f x27:
ffff0001808f6410
[ 2.572773] x26: ffff800081e77160 x25: 0000000000000000 x24:
0000000000000000
[ 2.580914] x23: 0000000000000000 x22: ffff800081e77160 x21:
ffff80008243892f
[ 2.589054] x20: 0000000000000000 x19: 0000000000000000 x18:
000000000000000a
[ 2.597101] x17: ffff80007fffffff x16: ffff000180054480 x15:
0000000000000000
[ 2.605345] x14: 0000000000000000 x13: ffff800080ed7600 x12:
0000000000000000
[ 2.613485] x11: 0000000000000000 x10: 00007fff01adbb48 x9 :
0000000000000005
[ 2.621626] x8 : 0101010101010101 x7 : fffffdffc6009b00 x6 :
051573657480ffff
[ 2.629869] x5 : 0000000000000138 x4 : 0000000000000000 x3 :
0000000000000001
[ 2.638113] x2 : 0000000000000000 x1 : 0000000000000000 x0 :
0000000000000000
[ 2.646254] Call trace:
[ 2.648968] gpiod_direction_input_nonotify
(drivers/gpio/gpiolib.h:231 (discriminator 1)
drivers/gpio/gpiolib.c:2863 (discriminator 1)) (P)
[ 2.655299] gpiod_configure_flags (drivers/gpio/gpiolib.c:4956)
[ 2.660428] gpiod_find_and_request (drivers/gpio/gpiolib.c:4774)
[ 2.665650] gpiod_get_index (drivers/gpio/gpiolib.c:4986)
[ 2.669874] devm_gpiod_get_index (drivers/gpio/gpiolib-devres.c:102)
[ 2.674695] mmc_gpiod_request_ro (drivers/mmc/core/slot-gpio.c:255)
[ 2.679525] mmc_of_parse (drivers/mmc/core/host.c:348)
[ 2.683749] tmio_mmc_host_alloc (drivers/mmc/host/tmio_mmc_core.c:1149)
[ 2.688571] renesas_sdhi_probe
(drivers/mmc/host/renesas_sdhi_core.c:1119)
[ 2.693392] renesas_sdhi_internal_dmac_probe
(drivers/mmc/host/renesas_sdhi_internal_dmac.c:599)
[ 2.699357] platform_probe (drivers/base/platform.c:1449
(discriminator 1))
[ 2.703581] really_probe (drivers/base/dd.c:581 drivers/base/dd.c:659)
[ 2.707703] __driver_probe_device (drivers/base/dd.c:801)
[ 2.712728] driver_probe_device (drivers/base/dd.c:831)
[ 2.717550] __device_attach_driver (drivers/base/dd.c:960)
[ 2.722678] bus_for_each_drv (drivers/base/bus.c:500)
[ 2.727099] __device_attach_async_helper
(include/linux/pm_runtime.h:447 drivers/base/dd.c:991)
[ 2.732526] async_run_entry_fn (kernel/async.c:136 (discriminator 3))
[ 2.737048] process_one_work (kernel/workqueue.c:3290 (discriminator 1))
[ 2.741673] worker_thread (kernel/workqueue.c:3356 (discriminator 2)
kernel/workqueue.c:3443 (discriminator 2))
[ 2.745915] kthread (kernel/kthread.c:467)
[ 2.749635] ret_from_fork (arch/arm64/kernel/entry.S:861)
[ 2.753762] Code: 910003fd a90153f3 aa0003f4 a9025bf5 (f9400013)
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
> Changes in v2:
> - Fix mutex deadlock
> - Fix lockdep false-positives
> - Add a patch reducing the number of memory allocations
> - Link to v1: https://lore.kernel.org/r/20260105-gpio-shared-fixes-v1-0-76d6ff0afcd8@oss.qualcomm.com
>
> ---
> Bartosz Golaszewski (3):
> gpio: shared: assign the correct firmware node for reset-gpio use-case
> gpio: shared: fix a race condition
> gpio: shared: don't allocate the lookup table until we really need it
>
> drivers/gpio/gpiolib-shared.c | 34 ++++++++++++++++------------------
> 1 file changed, 16 insertions(+), 18 deletions(-)
> ---
> base-commit: 19fb766a1e5ed5943a62fc671c09d45352a81b1d
> change-id: 20260105-gpio-shared-fixes-40a8ec3b6b25
>
> Best regards,
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2 0/3] gpio: shared: another set of small fixes
2026-01-08 12:13 ` Cosmin Tanislav
@ 2026-01-08 12:18 ` Bartosz Golaszewski
2026-01-08 13:47 ` Cosmin Tanislav
2026-01-08 12:22 ` Marek Szyprowski
1 sibling, 1 reply; 10+ messages in thread
From: Bartosz Golaszewski @ 2026-01-08 12:18 UTC (permalink / raw)
To: Cosmin Tanislav
Cc: Bartosz Golaszewski, Linus Walleij, Marek Szyprowski, linux-gpio,
linux-kernel
On Thu, Jan 8, 2026 at 1:13 PM Cosmin Tanislav <demonsingur@gmail.com> wrote:
>
> On 1/6/26 11:34 AM, Bartosz Golaszewski wrote:
> > Here are three more patches fixing issues reported with shared GPIO
> > management.
> >
>
> I'm still getting some intermittent failures on today's next (which
> contains this series).
>
> This does not seem to happen on every boot, so it might be some race.
>
Should be fixed by:
https://lore.kernel.org/all/20260108102314.18816-1-bartosz.golaszewski@oss.qualcomm.com/
Please give it a try and I'll queue it shortly.
Bart
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] gpio: shared: another set of small fixes
2026-01-08 12:18 ` Bartosz Golaszewski
@ 2026-01-08 13:47 ` Cosmin Tanislav
0 siblings, 0 replies; 10+ messages in thread
From: Cosmin Tanislav @ 2026-01-08 13:47 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Bartosz Golaszewski, Linus Walleij, Marek Szyprowski, linux-gpio,
linux-kernel
On 1/8/26 2:18 PM, Bartosz Golaszewski wrote:
> On Thu, Jan 8, 2026 at 1:13 PM Cosmin Tanislav <demonsingur@gmail.com> wrote:
>>
>> On 1/6/26 11:34 AM, Bartosz Golaszewski wrote:
>>> Here are three more patches fixing issues reported with shared GPIO
>>> management.
>>>
>>
>> I'm still getting some intermittent failures on today's next (which
>> contains this series).
>>
>> This does not seem to happen on every boot, so it might be some race.
>>
>
> Should be fixed by:
> https://lore.kernel.org/all/20260108102314.18816-1-bartosz.golaszewski@oss.qualcomm.com/
>
> Please give it a try and I'll queue it shortly.
>
Thank you, I can't seem to hit the issue anymore.
> Bart
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] gpio: shared: another set of small fixes
2026-01-08 12:13 ` Cosmin Tanislav
2026-01-08 12:18 ` Bartosz Golaszewski
@ 2026-01-08 12:22 ` Marek Szyprowski
1 sibling, 0 replies; 10+ messages in thread
From: Marek Szyprowski @ 2026-01-08 12:22 UTC (permalink / raw)
To: Cosmin Tanislav, Bartosz Golaszewski, Linus Walleij, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel
On 08.01.2026 13:13, Cosmin Tanislav wrote:
> On 1/6/26 11:34 AM, Bartosz Golaszewski wrote:
>> Here are three more patches fixing issues reported with shared GPIO
>> management.
>>
>
> I'm still getting some intermittent failures on today's next (which
> contains this series).
Please check this fix:
https://lore.kernel.org/all/20260108102314.18816-1-bartosz.golaszewski@oss.qualcomm.com/
Looks exactly like the issue I've observed and finally debugged
yesterday on TM2e board.
>
> This does not seem to happen on every boot, so it might be some race.
>
> [ 2.169655] Mem abort info:
> [ 2.169663] ESR = 0x0000000096000004
> [ 2.169670] EC = 0x25: DABT (current EL), IL = 32 bits
> [ 2.176773] ehci-platform 92040100.usb: irq 64, io mem 0x92040100
> [ 2.186626] SET = 0, FnV = 0
> [ 2.204264] renesas_sdhi_internal_dmac 92090000.mmc: mmc1 base at
> 0x0000000092090000, max clock rate 200 MHz
> [ 2.204308] ehci-platform 92040100.usb: USB 2.0 started, EHCI 1.10
> [ 2.208714] hub 2-0:1.0: USB hub found
> [ 2.214345] EA = 0, S1PTW = 0
> [ 2.222949] hub 2-0:1.0: 1 port detected
> [ 2.231502] FSC = 0x04: level 0 translation fault
> [ 2.239779] hub 1-0:1.0: USB hub found
> [ 2.248022] Data abort info:
> [ 2.256579] hub 1-0:1.0: 1 port detected
> [ 2.264724] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
> [ 2.487291] CM = 0, WnR = 0, TnD = 0, TagAccess = 0
> [ 2.493148] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
> [ 2.499300] [0000000000000000] user address but active_mm is swapper
> [ 2.506556] Internal error: Oops: 0000000096000004 [#1] SMP
> [ 2.513092] Modules linked in:
> [ 2.516610] CPU: 3 UID: 0 PID: 48 Comm: kworker/u16:2 Not tainted
> 6.19.0-rc4-next-20260108+ #246 PREEMPT
> [ 2.527564] Hardware name: Renesas RZ/T2H EVK Board based on
> r9a09g077m44 (DT)
> [ 2.535903] Workqueue: async async_run_entry_fn
> [ 2.541141] pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS
> BTYPE=--)
> [ 2.549076] pc : gpiod_direction_input_nonotify+0x18/0x22c
> [ 2.555408] lr : gpiod_configure_flags+0x1c4/0x380
> [ 2.560835] sp : ffff8000830e38c0
> [ 2.564530] x29: ffff8000830e38c0 x28: ffff80008243894f x27:
> ffff0001808f6410
> [ 2.572773] x26: ffff800081e77160 x25: 0000000000000000 x24:
> 0000000000000000
> [ 2.580914] x23: 0000000000000000 x22: ffff800081e77160 x21:
> ffff80008243892f
> [ 2.589054] x20: 0000000000000000 x19: 0000000000000000 x18:
> 000000000000000a
> [ 2.597101] x17: ffff80007fffffff x16: ffff000180054480 x15:
> 0000000000000000
> [ 2.605345] x14: 0000000000000000 x13: ffff800080ed7600 x12:
> 0000000000000000
> [ 2.613485] x11: 0000000000000000 x10: 00007fff01adbb48 x9 :
> 0000000000000005
> [ 2.621626] x8 : 0101010101010101 x7 : fffffdffc6009b00 x6 :
> 051573657480ffff
> [ 2.629869] x5 : 0000000000000138 x4 : 0000000000000000 x3 :
> 0000000000000001
> [ 2.638113] x2 : 0000000000000000 x1 : 0000000000000000 x0 :
> 0000000000000000
> [ 2.646254] Call trace:
> [ 2.648968] gpiod_direction_input_nonotify+0x18/0x22c (P)
> [ 2.655299] gpiod_configure_flags+0x1c4/0x380
> [ 2.660428] gpiod_find_and_request+0x14c/0x524
> [ 2.665650] gpiod_get_index+0x58/0x7c
> [ 2.669874] devm_gpiod_get_index+0x20/0x90
> [ 2.674695] mmc_gpiod_request_ro+0x30/0xb0
> [ 2.679525] mmc_of_parse+0x100/0x688
> [ 2.683749] tmio_mmc_host_alloc+0x80/0x110
> [ 2.688571] renesas_sdhi_probe+0x150/0x760
> [ 2.693392] renesas_sdhi_internal_dmac_probe+0x64/0x80
> [ 2.699357] platform_probe+0x5c/0xa4
> [ 2.703581] really_probe+0xbc/0x2ac
> [ 2.707703] __driver_probe_device+0x78/0x118
> [ 2.712728] driver_probe_device+0x3c/0x178
> [ 2.717550] __device_attach_driver+0xb8/0x140
> [ 2.722678] bus_for_each_drv+0x88/0xe8
> [ 2.727099] __device_attach_async_helper+0xb0/0xd4
> [ 2.732526] async_run_entry_fn+0x34/0xe0
> [ 2.737048] process_one_work+0x150/0x290
> [ 2.741673] worker_thread+0x18c/0x300
> [ 2.745915] kthread+0x118/0x124
> [ 2.749635] ret_from_fork+0x10/0x20
> [ 2.753762] Code: 910003fd a90153f3 aa0003f4 a9025bf5 (f9400013)
> [ 2.760790] ---[ end trace 0000000000000000 ]---
>
> After running ./scripts/decode_stacktrace.sh
>
> [ 2.169655] Mem abort info:
> [ 2.169663] ESR = 0x0000000096000004
> [ 2.169670] EC = 0x25: DABT (current EL), IL = 32 bits
> [ 2.176773] ehci-platform 92040100.usb: irq 64, io mem 0x92040100
> [ 2.186626] SET = 0, FnV = 0
> [ 2.204264] renesas_sdhi_internal_dmac 92090000.mmc: mmc1 base at
> 0x0000000092090000, max clock rate 200 MHz
> [ 2.204308] ehci-platform 92040100.usb: USB 2.0 started, EHCI 1.10
> [ 2.208714] hub 2-0:1.0: USB hub found
> [ 2.214345] EA = 0, S1PTW = 0
> [ 2.222949] hub 2-0:1.0: 1 port detected
> [ 2.231502] FSC = 0x04: level 0 translation fault
> [ 2.239779] hub 1-0:1.0: USB hub found
> [ 2.248022] Data abort info:
> [ 2.256579] hub 1-0:1.0: 1 port detected
> [ 2.264724] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
> [ 2.487291] CM = 0, WnR = 0, TnD = 0, TagAccess = 0
> [ 2.493148] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
> [ 2.499300] [0000000000000000] user address but active_mm is swapper
> [ 2.506556] Internal error: Oops: 0000000096000004 [#1] SMP
> [ 2.513092] Modules linked in:
> [ 2.527564] Hardware name: Renesas RZ/T2H EVK Board based on
> r9a09g077m44 (DT)
> [ 2.535903] Workqueue: async async_run_entry_fn
> [ 2.541141] pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS
> BTYPE=--)
> [ 2.549076] pc : gpiod_direction_input_nonotify
> (drivers/gpio/gpiolib.h:231 (discriminator 1)
> drivers/gpio/gpiolib.c:2863 (discriminator 1))
> [ 2.555408] lr : gpiod_configure_flags (drivers/gpio/gpiolib.c:4956)
> [ 2.560835] sp : ffff8000830e38c0
> [ 2.564530] x29: ffff8000830e38c0 x28: ffff80008243894f x27:
> ffff0001808f6410
> [ 2.572773] x26: ffff800081e77160 x25: 0000000000000000 x24:
> 0000000000000000
> [ 2.580914] x23: 0000000000000000 x22: ffff800081e77160 x21:
> ffff80008243892f
> [ 2.589054] x20: 0000000000000000 x19: 0000000000000000 x18:
> 000000000000000a
> [ 2.597101] x17: ffff80007fffffff x16: ffff000180054480 x15:
> 0000000000000000
> [ 2.605345] x14: 0000000000000000 x13: ffff800080ed7600 x12:
> 0000000000000000
> [ 2.613485] x11: 0000000000000000 x10: 00007fff01adbb48 x9 :
> 0000000000000005
> [ 2.621626] x8 : 0101010101010101 x7 : fffffdffc6009b00 x6 :
> 051573657480ffff
> [ 2.629869] x5 : 0000000000000138 x4 : 0000000000000000 x3 :
> 0000000000000001
> [ 2.638113] x2 : 0000000000000000 x1 : 0000000000000000 x0 :
> 0000000000000000
> [ 2.646254] Call trace:
> [ 2.648968] gpiod_direction_input_nonotify
> (drivers/gpio/gpiolib.h:231 (discriminator 1)
> drivers/gpio/gpiolib.c:2863 (discriminator 1)) (P)
> [ 2.655299] gpiod_configure_flags (drivers/gpio/gpiolib.c:4956)
> [ 2.660428] gpiod_find_and_request (drivers/gpio/gpiolib.c:4774)
> [ 2.665650] gpiod_get_index (drivers/gpio/gpiolib.c:4986)
> [ 2.669874] devm_gpiod_get_index (drivers/gpio/gpiolib-devres.c:102)
> [ 2.674695] mmc_gpiod_request_ro (drivers/mmc/core/slot-gpio.c:255)
> [ 2.679525] mmc_of_parse (drivers/mmc/core/host.c:348)
> [ 2.683749] tmio_mmc_host_alloc
> (drivers/mmc/host/tmio_mmc_core.c:1149)
> [ 2.688571] renesas_sdhi_probe
> (drivers/mmc/host/renesas_sdhi_core.c:1119)
> [ 2.693392] renesas_sdhi_internal_dmac_probe
> (drivers/mmc/host/renesas_sdhi_internal_dmac.c:599)
> [ 2.699357] platform_probe (drivers/base/platform.c:1449
> (discriminator 1))
> [ 2.703581] really_probe (drivers/base/dd.c:581
> drivers/base/dd.c:659)
> [ 2.707703] __driver_probe_device (drivers/base/dd.c:801)
> [ 2.712728] driver_probe_device (drivers/base/dd.c:831)
> [ 2.717550] __device_attach_driver (drivers/base/dd.c:960)
> [ 2.722678] bus_for_each_drv (drivers/base/bus.c:500)
> [ 2.727099] __device_attach_async_helper
> (include/linux/pm_runtime.h:447 drivers/base/dd.c:991)
> [ 2.732526] async_run_entry_fn (kernel/async.c:136 (discriminator 3))
> [ 2.737048] process_one_work (kernel/workqueue.c:3290
> (discriminator 1))
> [ 2.741673] worker_thread (kernel/workqueue.c:3356 (discriminator
> 2) kernel/workqueue.c:3443 (discriminator 2))
> [ 2.745915] kthread (kernel/kthread.c:467)
> [ 2.749635] ret_from_fork (arch/arm64/kernel/entry.S:861)
> [ 2.753762] Code: 910003fd a90153f3 aa0003f4 a9025bf5 (f9400013)
>
>> Signed-off-by: Bartosz Golaszewski
>> <bartosz.golaszewski@oss.qualcomm.com>
>> ---
>> Changes in v2:
>> - Fix mutex deadlock
>> - Fix lockdep false-positives
>> - Add a patch reducing the number of memory allocations
>> - Link to v1:
>> https://lore.kernel.org/r/20260105-gpio-shared-fixes-v1-0-76d6ff0afcd8@oss.qualcomm.com
>>
>> ---
>> Bartosz Golaszewski (3):
>> gpio: shared: assign the correct firmware node for reset-gpio
>> use-case
>> gpio: shared: fix a race condition
>> gpio: shared: don't allocate the lookup table until we really
>> need it
>>
>> drivers/gpio/gpiolib-shared.c | 34 ++++++++++++++++------------------
>> 1 file changed, 16 insertions(+), 18 deletions(-)
>> ---
>> base-commit: 19fb766a1e5ed5943a62fc671c09d45352a81b1d
>> change-id: 20260105-gpio-shared-fixes-40a8ec3b6b25
>>
>
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 10+ messages in thread