* [PATCH] gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register()
@ 2026-02-28 13:14 ` Tzung-Bi Shih
2026-03-02 8:42 ` Bartosz Golaszewski
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tzung-Bi Shih @ 2026-02-28 13:14 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij
Cc: tzungbi, linux-gpio, linux-kernel, Marek Szyprowski
A lockdep warning is reported in gpiolib-cdev driver:
WARNING: drivers/gpio/gpiolib-cdev.c:2735 at
gpiolib_cdev_register+0x114/0x140, CPU#1: swapper/0/1
Modules linked in:
CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted
7.0.0-rc1-next-20260227-00065-g6af4b9cfeded #12259 PREEMPT
Hardware name: Samsung Exynos (Flattened Device Tree)
Call trace:
unwind_backtrace from show_stack+0x10/0x14
show_stack from dump_stack_lvl+0x68/0x88
dump_stack_lvl from __warn+0x94/0x210
__warn from warn_slowpath_fmt+0x1b0/0x1bc
warn_slowpath_fmt from gpiolib_cdev_register+0x114/0x140
gpiolib_cdev_register from gpiochip_setup_dev+0x4c/0xd0
gpiochip_setup_dev from gpiochip_add_data_with_key+0x960/0xad4
gpiochip_add_data_with_key from devm_gpiochip_add_data_with_key+0x20/0x5c
This is because the SRCU wasn't held in gpiolib_cdev_register() when the
caller is from gpiochip_add_data_with_key() instead of
gpiochip_setup_devs(). gpiochip_sysfs_register() shares the similar
concern.
Given that both gpiolib_cdev_register() and gpiochip_sysfs_register()
are only called from gpiolib but no external users. Remove the lockdep
checks to fix the warnings.
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Closes: https://lore.kernel.org/all/506ce9b3-d492-4fce-9d02-330e411911e2@samsung.com/
Fixes: cf674f1a0c98 ("gpio: Ensure struct gpio_chip for gpiochip_setup_dev()")
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
drivers/gpio/gpiolib-cdev.c | 2 --
drivers/gpio/gpiolib-sysfs.c | 2 --
2 files changed, 4 deletions(-)
diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index 7ebdb4993a74..f36b7c06996d 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -2732,8 +2732,6 @@ int gpiolib_cdev_register(struct gpio_chip *gc, dev_t devt)
struct gpio_device *gdev = gc->gpiodev;
int ret;
- lockdep_assert_held(&gdev->srcu);
-
cdev_init(&gdev->chrdev, &gpio_fileops);
gdev->chrdev.owner = THIS_MODULE;
gdev->dev.devt = MKDEV(MAJOR(devt), gdev->id);
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 748a3eb1bf35..fc06b0c2881b 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -990,8 +990,6 @@ int gpiochip_sysfs_register(struct gpio_chip *gc)
struct device *parent;
int err;
- lockdep_assert_held(&gdev->srcu);
-
/*
* Many systems add gpio chips for SOC support very early,
* before driver model support is available. In those cases we
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register()
2026-02-28 13:14 ` [PATCH] gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register() Tzung-Bi Shih
@ 2026-03-02 8:42 ` Bartosz Golaszewski
2026-03-02 9:08 ` Marek Szyprowski
2026-03-02 9:11 ` Bartosz Golaszewski
2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-03-02 8:42 UTC (permalink / raw)
To: Tzung-Bi Shih, Marek Szyprowski; +Cc: Linus Walleij, linux-gpio, linux-kernel
On Sat, Feb 28, 2026 at 2:14 PM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
>
> A lockdep warning is reported in gpiolib-cdev driver:
>
> WARNING: drivers/gpio/gpiolib-cdev.c:2735 at
> gpiolib_cdev_register+0x114/0x140, CPU#1: swapper/0/1
> Modules linked in:
> CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted
> 7.0.0-rc1-next-20260227-00065-g6af4b9cfeded #12259 PREEMPT
> Hardware name: Samsung Exynos (Flattened Device Tree)
> Call trace:
> unwind_backtrace from show_stack+0x10/0x14
> show_stack from dump_stack_lvl+0x68/0x88
> dump_stack_lvl from __warn+0x94/0x210
> __warn from warn_slowpath_fmt+0x1b0/0x1bc
> warn_slowpath_fmt from gpiolib_cdev_register+0x114/0x140
> gpiolib_cdev_register from gpiochip_setup_dev+0x4c/0xd0
> gpiochip_setup_dev from gpiochip_add_data_with_key+0x960/0xad4
> gpiochip_add_data_with_key from devm_gpiochip_add_data_with_key+0x20/0x5c
>
> This is because the SRCU wasn't held in gpiolib_cdev_register() when the
> caller is from gpiochip_add_data_with_key() instead of
> gpiochip_setup_devs(). gpiochip_sysfs_register() shares the similar
> concern.
>
> Given that both gpiolib_cdev_register() and gpiochip_sysfs_register()
> are only called from gpiolib but no external users. Remove the lockdep
> checks to fix the warnings.
>
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Closes: https://lore.kernel.org/all/506ce9b3-d492-4fce-9d02-330e411911e2@samsung.com/
> Fixes: cf674f1a0c98 ("gpio: Ensure struct gpio_chip for gpiochip_setup_dev()")
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
> ---
Marek: could you please leave your T-b if this fixes the issue?
Bart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register()
2026-02-28 13:14 ` [PATCH] gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register() Tzung-Bi Shih
2026-03-02 8:42 ` Bartosz Golaszewski
@ 2026-03-02 9:08 ` Marek Szyprowski
2026-03-02 9:11 ` Bartosz Golaszewski
2 siblings, 0 replies; 4+ messages in thread
From: Marek Szyprowski @ 2026-03-02 9:08 UTC (permalink / raw)
To: Tzung-Bi Shih, Bartosz Golaszewski, Linus Walleij
Cc: linux-gpio, linux-kernel
On 28.02.2026 14:14, Tzung-Bi Shih wrote:
> A lockdep warning is reported in gpiolib-cdev driver:
>
> WARNING: drivers/gpio/gpiolib-cdev.c:2735 at
> gpiolib_cdev_register+0x114/0x140, CPU#1: swapper/0/1
> Modules linked in:
> CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted
> 7.0.0-rc1-next-20260227-00065-g6af4b9cfeded #12259 PREEMPT
> Hardware name: Samsung Exynos (Flattened Device Tree)
> Call trace:
> unwind_backtrace from show_stack+0x10/0x14
> show_stack from dump_stack_lvl+0x68/0x88
> dump_stack_lvl from __warn+0x94/0x210
> __warn from warn_slowpath_fmt+0x1b0/0x1bc
> warn_slowpath_fmt from gpiolib_cdev_register+0x114/0x140
> gpiolib_cdev_register from gpiochip_setup_dev+0x4c/0xd0
> gpiochip_setup_dev from gpiochip_add_data_with_key+0x960/0xad4
> gpiochip_add_data_with_key from devm_gpiochip_add_data_with_key+0x20/0x5c
>
> This is because the SRCU wasn't held in gpiolib_cdev_register() when the
> caller is from gpiochip_add_data_with_key() instead of
> gpiochip_setup_devs(). gpiochip_sysfs_register() shares the similar
> concern.
>
> Given that both gpiolib_cdev_register() and gpiochip_sysfs_register()
> are only called from gpiolib but no external users. Remove the lockdep
> checks to fix the warnings.
>
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Closes: https://lore.kernel.org/all/506ce9b3-d492-4fce-9d02-330e411911e2@samsung.com/
> Fixes: cf674f1a0c98 ("gpio: Ensure struct gpio_chip for gpiochip_setup_dev()")
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> drivers/gpio/gpiolib-cdev.c | 2 --
> drivers/gpio/gpiolib-sysfs.c | 2 --
> 2 files changed, 4 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> index 7ebdb4993a74..f36b7c06996d 100644
> --- a/drivers/gpio/gpiolib-cdev.c
> +++ b/drivers/gpio/gpiolib-cdev.c
> @@ -2732,8 +2732,6 @@ int gpiolib_cdev_register(struct gpio_chip *gc, dev_t devt)
> struct gpio_device *gdev = gc->gpiodev;
> int ret;
>
> - lockdep_assert_held(&gdev->srcu);
> -
> cdev_init(&gdev->chrdev, &gpio_fileops);
> gdev->chrdev.owner = THIS_MODULE;
> gdev->dev.devt = MKDEV(MAJOR(devt), gdev->id);
> diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
> index 748a3eb1bf35..fc06b0c2881b 100644
> --- a/drivers/gpio/gpiolib-sysfs.c
> +++ b/drivers/gpio/gpiolib-sysfs.c
> @@ -990,8 +990,6 @@ int gpiochip_sysfs_register(struct gpio_chip *gc)
> struct device *parent;
> int err;
>
> - lockdep_assert_held(&gdev->srcu);
> -
> /*
> * Many systems add gpio chips for SOC support very early,
> * before driver model support is available. In those cases we
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register()
2026-02-28 13:14 ` [PATCH] gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register() Tzung-Bi Shih
2026-03-02 8:42 ` Bartosz Golaszewski
2026-03-02 9:08 ` Marek Szyprowski
@ 2026-03-02 9:11 ` Bartosz Golaszewski
2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-03-02 9:11 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij, Tzung-Bi Shih
Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, Marek Szyprowski
On Sat, 28 Feb 2026 21:14:30 +0800, Tzung-Bi Shih wrote:
> A lockdep warning is reported in gpiolib-cdev driver:
>
> WARNING: drivers/gpio/gpiolib-cdev.c:2735 at
> gpiolib_cdev_register+0x114/0x140, CPU#1: swapper/0/1
> Modules linked in:
> CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted
> 7.0.0-rc1-next-20260227-00065-g6af4b9cfeded #12259 PREEMPT
> Hardware name: Samsung Exynos (Flattened Device Tree)
> Call trace:
> unwind_backtrace from show_stack+0x10/0x14
> show_stack from dump_stack_lvl+0x68/0x88
> dump_stack_lvl from __warn+0x94/0x210
> __warn from warn_slowpath_fmt+0x1b0/0x1bc
> warn_slowpath_fmt from gpiolib_cdev_register+0x114/0x140
> gpiolib_cdev_register from gpiochip_setup_dev+0x4c/0xd0
> gpiochip_setup_dev from gpiochip_add_data_with_key+0x960/0xad4
> gpiochip_add_data_with_key from devm_gpiochip_add_data_with_key+0x20/0x5c
>
> [...]
Applied, thanks!
[1/1] gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register()
https://git.kernel.org/brgl/c/fdfe3e72a228b74da21939c47ebd6f5ad4969d5f
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-02 9:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20260228131459eucas1p1b5deb465c52d0990a6920b0d8981975f@eucas1p1.samsung.com>
2026-02-28 13:14 ` [PATCH] gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register() Tzung-Bi Shih
2026-03-02 8:42 ` Bartosz Golaszewski
2026-03-02 9:08 ` Marek Szyprowski
2026-03-02 9:11 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®