linux/drivers/pinctrl/sunxi
Samuel Holland bac129dbc6 pinctrl: sunxi: Use unique lockdep classes for IRQs
This driver, like several others, uses a chained IRQ for each GPIO bank,
and forwards .irq_set_wake to the GPIO bank's upstream IRQ. As a result,
a call to irq_set_irq_wake() needs to lock both the upstream and
downstream irq_desc's. Lockdep considers this to be a possible deadlock
when the irq_desc's share lockdep classes, which they do by default:

 ============================================
 WARNING: possible recursive locking detected
 5.17.0-rc3-00394-gc849047c2473 #1 Not tainted
 --------------------------------------------
 init/307 is trying to acquire lock:
 c2dfe27c (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0x58/0xa0

 but task is already holding lock:
 c3c0ac7c (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0x58/0xa0

 other info that might help us debug this:
  Possible unsafe locking scenario:

        CPU0
        ----
   lock(&irq_desc_lock_class);
   lock(&irq_desc_lock_class);

  *** DEADLOCK ***

  May be due to missing lock nesting notation

 4 locks held by init/307:
  #0: c1f29f18 (system_transition_mutex){+.+.}-{3:3}, at: __do_sys_reboot+0x90/0x23c
  #1: c20f7760 (&dev->mutex){....}-{3:3}, at: device_shutdown+0xf4/0x224
  #2: c2e804d8 (&dev->mutex){....}-{3:3}, at: device_shutdown+0x104/0x224
  #3: c3c0ac7c (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0x58/0xa0

 stack backtrace:
 CPU: 0 PID: 307 Comm: init Not tainted 5.17.0-rc3-00394-gc849047c2473 #1
 Hardware name: Allwinner sun8i Family
  unwind_backtrace from show_stack+0x10/0x14
  show_stack from dump_stack_lvl+0x68/0x90
  dump_stack_lvl from __lock_acquire+0x1680/0x31a0
  __lock_acquire from lock_acquire+0x148/0x3dc
  lock_acquire from _raw_spin_lock_irqsave+0x50/0x6c
  _raw_spin_lock_irqsave from __irq_get_desc_lock+0x58/0xa0
  __irq_get_desc_lock from irq_set_irq_wake+0x2c/0x19c
  irq_set_irq_wake from irq_set_irq_wake+0x13c/0x19c
    [tail call from sunxi_pinctrl_irq_set_wake]
  irq_set_irq_wake from gpio_keys_suspend+0x80/0x1a4
  gpio_keys_suspend from gpio_keys_shutdown+0x10/0x2c
  gpio_keys_shutdown from device_shutdown+0x180/0x224
  device_shutdown from __do_sys_reboot+0x134/0x23c
  __do_sys_reboot from ret_fast_syscall+0x0/0x1c

However, this can never deadlock because the upstream and downstream
IRQs are never the same (nor do they even involve the same irqchip).

Silence this erroneous lockdep splat by applying what appears to be the
usual fix of moving the GPIO IRQs to separate lockdep classes.

Fixes: a59c99d9ea ("pinctrl: sunxi: Forward calls to irq_set_irq_wake")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220216040037.22730-1-samuel@sholland.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2022-02-28 23:53:19 +01:00
..
Kconfig pinctrl: sunxi: Add support for the Allwinner H616-R pin controller 2021-01-21 22:15:46 +01:00
Makefile pinctrl: sunxi: Add support for the Allwinner H616-R pin controller 2021-01-21 22:15:46 +01:00
pinctrl-sun4i-a10.c pinctrl: sunxi: fix a typo when merging A20 support to A10 driver 2017-12-28 15:06:01 +01:00
pinctrl-sun5i.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun6i-a31-r.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun6i-a31.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun8i-a23-r.c pinctrl: sunxi: handle probe defferal 2020-04-16 10:23:02 +02:00
pinctrl-sun8i-a23.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun8i-a33.c pinctrl: sunxi: change irq_bank_base to irq_bank_map 2018-03-27 15:07:49 +02:00
pinctrl-sun8i-a83t-r.c pinctrl: sunxi: Add support for A83T R_PIO 2017-06-09 11:20:32 +02:00
pinctrl-sun8i-a83t.c pinctrl: sunxi: a83t: Fix IRQ offset typo for PH11 2018-12-07 13:32:19 +01:00
pinctrl-sun8i-h3-r.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun8i-h3.c pinctrl: sunxi: Disable strict mode for old pinctrl drivers 2017-10-31 09:45:00 +01:00
pinctrl-sun8i-v3s.c pinctrl: sunxi: v3s: introduce support for V3 2019-08-05 12:35:29 +02:00
pinctrl-sun9i-a80-r.c pinctrl: sunxi: Prepare for alternative bias voltage setting methods 2019-04-23 12:29:21 +02:00
pinctrl-sun9i-a80.c pinctrl: sunxi: Prepare for alternative bias voltage setting methods 2019-04-23 12:29:21 +02:00
pinctrl-sun50i-a64-r.c pinctrl: sunxi: Add A64 R_PIO controller support 2017-03-14 14:42:24 +01:00
pinctrl-sun50i-a64.c pinctrl: sunxi: a64: Rename function ts0 to ts 2018-12-07 13:29:28 +01:00
pinctrl-sun50i-a100-r.c pinctrl: sunxi: add support for the Allwinner A100 pin controller 2020-09-12 12:35:42 +02:00
pinctrl-sun50i-a100.c pinctrl: sunxi: fix irq bank map for the Allwinner A100 pin controller 2020-11-24 09:40:03 +01:00
pinctrl-sun50i-h5.c pinctrl: sunxi: sun50i-h5 use platform_irq_count 2020-01-07 09:55:33 +01:00
pinctrl-sun50i-h6-r.c pinctrl: sunxi: h6-r: Add s_rsb pin functions 2021-01-06 21:10:04 +01:00
pinctrl-sun50i-h6.c pinctrl: sunxi: Support I/O bias voltage setting on H6 2019-04-23 12:31:42 +02:00
pinctrl-sun50i-h616-r.c pinctrl: sunxi: Add support for the Allwinner H616-R pin controller 2021-01-21 22:15:46 +01:00
pinctrl-sun50i-h616.c pinctrl: sunxi: Fix H616 I2S3 pin data 2022-01-24 01:12:46 +01:00
pinctrl-suniv-f1c100s.c pinctrl: sunxi: add support for suniv F1C100s (newer F-series SoCs) 2018-11-25 13:49:10 +01:00
pinctrl-sunxi.c pinctrl: sunxi: Use unique lockdep classes for IRQs 2022-02-28 23:53:19 +01:00
pinctrl-sunxi.h pinctrl: sunxi: v3s: introduce support for V3 2019-08-05 12:35:29 +02:00