gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register()
PATCH 1/1 gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register()
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/0x5cThis 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.
--- drivers/gpio/gpiolib-cdev.c | 2 -- drivers/gpio/gpiolib-sysfs.c | 2 -- 2 files changed, 4 deletions(-)
drivers/gpio/gpiolib-cdev.c +0 -2
@@ -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);
drivers/gpio/gpiolib-sysfs.c +0 -2
@@ -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
Signature · 1 line
2.51.0
Bartosz Golaszewski
maintainerQuoted 28 lines · Tzung-Bi Shih
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/0x5cThis is because the SRCU wasn't held in
gpiolib_cdev_register()when the caller is fromgpiochip_add_data_with_key()instead ofgpiochip_setup_devs().gpiochip_sysfs_register()shares the similar concern.Given that both
gpiolib_cdev_register()andgpiochip_sysfs_register()are only called from gpiolib but no external users. Remove the lockdep checks to fix the warnings.
Quoted 5 lines
Reported-by Marek Szyprowski <[email protected]>Fixes cf674f1a0c98 ("gpio: Ensure struct gpio_chip for gpiochip_setup_dev()")Signed-off-by Tzung-Bi Shih <[email protected]>---
Marek: could you please leave your T-b if this fixes the issue?
Bart
Quoted 23 lines · Tzung-Bi Shih
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/0x5cThis is because the SRCU wasn't held in
gpiolib_cdev_register()when the caller is fromgpiochip_add_data_with_key()instead ofgpiochip_setup_devs().gpiochip_sysfs_register()shares the similar concern.
Quoted 8 lines
Given that both
gpiolib_cdev_register()andgpiochip_sysfs_register()are only called from gpiolib but no external users. Remove the lockdep checks to fix the warnings.Reported-by Marek Szyprowski <[email protected]>Fixes cf674f1a0c98 ("gpio: Ensure struct gpio_chip for gpiochip_setup_dev()")Signed-off-by Tzung-Bi Shih <[email protected]>
Quoted 23 lines
--- drivers/gpio/gpiolib-cdev.c | 2 -- drivers/gpio/gpiolib-sysfs.c | 2 -- 2 files changed, 4 deletions(-)drivers/gpio/gpiolib-cdev.c +0
-2@@ -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);drivers/gpio/gpiolib-sysfs.c +0
-0
drivers/gpio/gpiolib-sysfs.c int gpiochip_sysfs_register(struct gpio_chip *gc) · line 995
Quoted 8 lines
drivers/gpio/gpiolib-sysfs.c +0
-2@@ -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
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Bartosz Golaszewski
AppliedQuoted 18 lines · Tzung-Bi Shih
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
Quoted 1 line
[...]
Applied, thanks!
[1/1] gpio: Fix lockdep warnings in gpiolib_{cdev,sysfs}_register()
https://git.kernel.org/brgl/c/fdfe3e72a228b74da21939c47ebd6f5ad4969d5f
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>