linux_dsm_epyc7002/drivers/gpio
Grygorii Strashko a0a8bcf467 gpiolib: irqchip: use different lockdep class for each gpio irqchip
Since IRQ chip helpers were introduced drivers lose ability to
register separate lockdep classes for each registered GPIO IRQ
chip and the gpiolib now is using shared lockdep class for
all GPIO IRQ chips (gpiochip_irq_lock_class).
As result, lockdep will produce warning when there are min two
stacked GPIO chips and all of them are interrupt controllers.

HW configuration which generates lockdep warning (TI dra7-evm):

[SOC GPIO bankA.gpioX]
  <- irq - [pcf875x.gpioY]
            <- irq - DevZ.enable_irq_wake(pcf_gpioY_irq);
The issue was reported in [1] and discussed [2].

=============================================
[ INFO: possible recursive locking detected ]
4.2.0-rc6-00013-g5d050ed-dirty #55 Not tainted
---------------------------------------------
sh/63 is trying to acquire lock:
 (class){......}, at: [<c009b91c>] __irq_get_desc_lock+0x50/0x94

but task is already holding lock:
 (class){......}, at: [<c009b91c>] __irq_get_desc_lock+0x50/0x94

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

       CPU0
       ----
  lock(class);
  lock(class);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

7 locks held by sh/63:
 #0:  (sb_writers#4){.+.+.+}, at: [<c016bbb8>] vfs_write+0x13c/0x164
 #1:  (&of->mutex){+.+.+.}, at: [<c01debf4>] kernfs_fop_write+0x4c/0x1a0
 #2:  (s_active#36){.+.+.+}, at: [<c01debfc>] kernfs_fop_write+0x54/0x1a0
 #3:  (pm_mutex){+.+.+.}, at: [<c009758c>] pm_suspend+0xec/0x4c4
 #4:  (&dev->mutex){......}, at: [<c03f77f8>] __device_suspend+0xd4/0x398
 #5:  (&gpio->lock){+.+.+.}, at: [<c009b940>] __irq_get_desc_lock+0x74/0x94
 #6:  (class){......}, at: [<c009b91c>] __irq_get_desc_lock+0x50/0x94

stack backtrace:
CPU: 0 PID: 63 Comm: sh Not tainted 4.2.0-rc6-00013-g5d050ed-dirty #55
Hardware name: Generic DRA74X (Flattened Device Tree)
[<c0016e24>] (unwind_backtrace) from [<c0013338>] (show_stack+0x10/0x14)
[<c0013338>] (show_stack) from [<c05f6b24>] (dump_stack+0x84/0x9c)
[<c05f6b24>] (dump_stack) from [<c00903f4>] (__lock_acquire+0x19c0/0x1e20)
[<c00903f4>] (__lock_acquire) from [<c0091098>] (lock_acquire+0xa8/0x128)
[<c0091098>] (lock_acquire) from [<c05fd61c>] (_raw_spin_lock_irqsave+0x38/0x4c)
[<c05fd61c>] (_raw_spin_lock_irqsave) from [<c009b91c>] (__irq_get_desc_lock+0x50/0x94)
[<c009b91c>] (__irq_get_desc_lock) from [<c009c4f4>] (irq_set_irq_wake+0x20/0xfc)
[<c009c4f4>] (irq_set_irq_wake) from [<c0393ac4>] (pcf857x_irq_set_wake+0x24/0x54)
[<c0393ac4>] (pcf857x_irq_set_wake) from [<c009c560>] (irq_set_irq_wake+0x8c/0xfc)
[<c009c560>] (irq_set_irq_wake) from [<c04a02ac>] (gpio_keys_suspend+0x70/0xd4)
[<c04a02ac>] (gpio_keys_suspend) from [<c03f6a00>] (dpm_run_callback+0x50/0x124)
[<c03f6a00>] (dpm_run_callback) from [<c03f7830>] (__device_suspend+0x10c/0x398)
[<c03f7830>] (__device_suspend) from [<c03f90f0>] (dpm_suspend+0x134/0x2f4)
[<c03f90f0>] (dpm_suspend) from [<c0096e20>] (suspend_devices_and_enter+0xa8/0x728)
[<c0096e20>] (suspend_devices_and_enter) from [<c00977cc>] (pm_suspend+0x32c/0x4c4)
[<c00977cc>] (pm_suspend) from [<c0096060>] (state_store+0x64/0xb8)
[<c0096060>] (state_store) from [<c01dec64>] (kernfs_fop_write+0xbc/0x1a0)
[<c01dec64>] (kernfs_fop_write) from [<c016b280>] (__vfs_write+0x20/0xd8)
[<c016b280>] (__vfs_write) from [<c016bb0c>] (vfs_write+0x90/0x164)
[<c016bb0c>] (vfs_write) from [<c016c330>] (SyS_write+0x44/0x9c)
[<c016c330>] (SyS_write) from [<c000f500>] (ret_fast_syscall+0x0/0x54)

Lets fix it by using separate lockdep class for each registered GPIO
IRQ Chip. This is done by wrapping gpiochip_irqchip_add call into macros.

The implementation of this patch inspired by solution done by Nicolas
Boichat for regmap [3]

[1] http://www.spinics.net/lists/linux-gpio/msg05844.html
[2] http://www.spinics.net/lists/linux-gpio/msg06021.html
[3] http://www.spinics.net/lists/arm-kernel/msg429834.html

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roger Quadros <rogerq@ti.com>
Reported-by: Roger Quadros <rogerq@ti.com>
Tested-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-08-17 15:32:03 +02:00
..
devres.c gpio: make flags mandatory for gpiod_get functions 2015-07-06 10:39:24 +02:00
gpio-74x164.c
gpio-74xx-mmio.c gpio: 74xx: Fix build warning about void to integer cast 2015-07-16 13:59:47 +02:00
gpio-adnp.c
gpio-adp5520.c
gpio-adp5588.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-altera.c gpio: altera: use of_mm_gpiochip_remove() to fix memory leak 2015-07-16 00:11:03 +02:00
gpio-amd8111.c
gpio-arizona.c This is the bulk of GPIO changes for the v4.1 development 2015-04-18 08:22:10 -04:00
gpio-bcm-kona.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-brcmstb.c Linux 4.2-rc4 2015-08-13 14:42:55 +02:00
gpio-bt8xx.c
gpio-clps711x.c
gpio-crystalcove.c gpio: Fix checkpatch.pl issues 2015-06-16 11:00:06 +02:00
gpio-cs5535.c
gpio-da9052.c gpio: use (!foo) instead of (foo == NULL) 2015-04-08 09:54:21 +02:00
gpio-da9055.c gpio: use (!foo) instead of (foo == NULL) 2015-04-08 09:54:21 +02:00
gpio-davinci.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-dln2.c gpio: dln2: fix build breakage 2015-05-13 10:02:12 +02:00
gpio-dwapb.c gpio: Use irq_desc_get_xxx() to avoid redundant lookup of irq_desc 2015-07-14 12:12:20 +02:00
gpio-em.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-ep93xx.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-etraxfs.c gpio: etraxfs: add interrupt support 2015-08-03 10:57:04 +02:00
gpio-f7188x.c gpio: Fix checkpatch.pl issues 2015-06-16 11:00:06 +02:00
gpio-ge.c gpio: ge: Convert to use devm_kstrdup 2015-01-29 10:33:15 +01:00
gpio-generic.c gpio: generic: support input-only chips 2015-07-27 15:01:05 +02:00
gpio-grgpio.c gpio/grgpio: fix deadlock in grgpio_irq_unmap() 2015-08-17 10:56:24 +02:00
gpio-ich.c gpio: ich: Implement get_direction function 2015-04-08 09:54:27 +02:00
gpio-intel-mid.c
gpio-iop.c
gpio-it8761e.c gpio: Fix checkpatch.pl issues 2015-06-16 11:00:06 +02:00
gpio-janz-ttl.c
gpio-kempld.c gpio: gpio-kempld: Fix get_direction return value 2015-05-12 13:49:13 +02:00
gpio-ks8695.c
gpio-loongson.c gpio: loongson: Add Loongson-3A/3B GPIO driver support 2015-04-08 09:53:42 +02:00
gpio-lp3943.c
gpio-lpc18xx.c gpio: add lpc18xx gpio driver 2015-05-05 17:50:07 +02:00
gpio-lpc32xx.c
gpio-lynxpoint.c Drivers: gpio: Fix spelling errors 2015-05-19 16:52:30 +02:00
gpio-max730x.c
gpio-max732x.c gpio: max732x: Add missing dev reference to gpiochip 2015-07-16 13:42:46 +02:00
gpio-max7300.c gpio: max7300: remove 'ret' variable 2015-04-08 09:54:10 +02:00
gpio-max7301.c
gpio-mb86s7x.c gpio: mb86s70: Return error if requesting an already assigned gpio 2015-03-02 15:35:41 +01:00
gpio-mc9s08dz60.c
gpio-mc33880.c gpio: use (!foo) instead of (foo == NULL) 2015-04-08 09:54:21 +02:00
gpio-mcp23s08.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-ml-ioh.c
gpio-mm-lantiq.c
gpio-moxart.c gpio: moxart: get value of output gpio from generic driver 2015-05-11 11:51:29 +02:00
gpio-mpc8xxx.c gpio: mpc8xxx: Convert mpc8xxx_gpio_chip.lock to raw_spinlock 2015-07-28 14:40:11 +02:00
gpio-mpc5200.c
gpio-msic.c gpio/msic: Fix race in installing chained IRQ handler 2015-06-25 11:56:50 +02:00
gpio-msm-v2.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-mvebu.c gpio/mvebu: Prepare mvebu_gpio_irq_handler for irq argument removal 2015-07-14 12:12:20 +02:00
gpio-mxc.c gpio: mxc: fix section mismatch warning 2015-08-13 15:37:04 +02:00
gpio-mxs.c gpio: Use irq_desc_get_xxx() to avoid redundant lookup of irq_desc 2015-07-14 12:12:20 +02:00
gpio-octeon.c
gpio-omap.c gpio: omap: Fix missing raw locks conversion 2015-08-13 14:43:23 +02:00
gpio-palmas.c
gpio-pca953x.c gpio: pca953x: fix nested irqs rescheduling 2015-07-16 14:40:08 +02:00
gpio-pcf857x.c gpio: pcf857x: get rid of slock spinlock 2015-07-16 10:44:57 +02:00
gpio-pch.c gpio/pch: Use irq_set_handler_locked() 2015-07-14 12:12:20 +02:00
gpio-pl061.c
gpio-pxa.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-rc5t583.c
gpio-rcar.c gpio: rcar: Add r8a7795 (R-Car H3) support 2015-07-27 14:51:40 +02:00
gpio-rdc321x.c
gpio-sa1100.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-samsung.c
gpio-sch311x.c
gpio-sch.c Revert "gpio: sch: use uapi/linux/pci_ids.h directly" 2015-04-10 11:35:45 +02:00
gpio-sodaville.c gpio: Constify irq_domain_ops 2015-05-06 15:33:48 +02:00
gpio-spear-spics.c
gpio-sta2x11.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-stmpe.c
gpio-stp-xway.c gpio: stp-xway: Use the of_property_read_u32 helper 2015-06-02 11:22:02 +02:00
gpio-sx150x.c gpio: sx150x: fixup OF support 2015-01-22 09:45:24 +01:00
gpio-syscon.c gpio: syscon: reduce message level when direction reg offset not in dt 2015-03-27 11:17:08 +01:00
gpio-tb10x.c gpio: tb10x: Drop unneeded free_irq() call 2015-06-02 11:25:42 +02:00
gpio-tc3589x.c mfd: tc3589x: Enforce device-tree only mode 2015-03-26 14:20:17 +00:00
gpio-tegra.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-timberdale.c gpio: kill off set_irq_flags usage 2015-07-28 09:45:39 +02:00
gpio-tps6586x.c
gpio-tps65910.c
gpio-tps65912.c gpio: tps65912: fix wrong container_of arguments 2015-02-23 15:40:32 +01:00
gpio-ts5500.c gpio: Constify platform_device_id 2015-05-12 09:41:28 +02:00
gpio-twl4030.c
gpio-twl6040.c
gpio-tz1090-pdc.c gpio: tz1090-pdc: Use resource_size to fix off-by-one resource size calculation 2015-01-29 10:34:13 +01:00
gpio-tz1090.c gpio/tz1090: Consolidate chained IRQ handler install/remove 2015-07-14 12:12:19 +02:00
gpio-ucb1400.c
gpio-vf610.c gpio: Use irq_desc_get_xxx() to avoid redundant lookup of irq_desc 2015-07-14 12:12:20 +02:00
gpio-viperboard.c
gpio-vr41xx.c
gpio-vx855.c
gpio-wm831x.c
gpio-wm8350.c
gpio-wm8994.c
gpio-xgene-sb.c gpio: xgene: add ACPI support for APM X-Gene GPIO standby driver 2015-06-02 14:52:00 +02:00
gpio-xgene.c
gpio-xilinx.c gpio/xilinx: Use correct address when setting initial values. 2015-07-16 13:28:33 +02:00
gpio-xlp.c gpio: xlp: Add missing .owner and .label settings for gpio_chip 2015-05-12 13:23:24 +02:00
gpio-xtensa.c
gpio-zevio.c
gpio-zx.c gpio: zx: Add ZTE zx296702 GPIO support 2015-07-16 10:14:45 +02:00
gpio-zynq.c Linux 4.2-rc4 2015-08-13 14:42:55 +02:00
gpiolib-acpi.c gpio / ACPI: Return -EPROBE_DEFER if the gpiochip was not found 2015-06-11 10:17:32 +02:00
gpiolib-legacy.c
gpiolib-of.c gpio: defer probe if pinctrl cannot be found 2015-07-28 13:55:36 +02:00
gpiolib-sysfs.c gpio: sysfs: move irq trigger flags to class-device data 2015-05-12 10:47:57 +02:00
gpiolib.c gpiolib: irqchip: use different lockdep class for each gpio irqchip 2015-08-17 15:32:03 +02:00
gpiolib.h gpio: sysfs: move irq trigger flags to class-device data 2015-05-12 10:47:57 +02:00
Kconfig gpio: brcmstb: Add interrupt and wakeup source support 2015-08-13 13:13:26 +02:00
Makefile gpio: zx: Add ZTE zx296702 GPIO support 2015-07-16 10:14:45 +02:00