linux/drivers/dma
Michael Grzeschik 5a276fa6bd dmaengine: imx-dma: fix lockdep issue between irqhandler and tasklet
The tasklet and irqhandler are using spin_lock while other routines are
using spin_lock_irqsave/restore. This leads to lockdep issues as
described bellow. This patch is changing the code to use
spinlock_irq_save/restore in both code pathes.

As imxdma_xfer_desc always gets called with spin_lock_irqsave lock held,
this patch also removes the spare call inside the routine to avoid
double locking.

[  403.358162] =================================
[  403.362549] [ INFO: inconsistent lock state ]
[  403.366945] 3.10.0-20130823+ #904 Not tainted
[  403.371331] ---------------------------------
[  403.375721] inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
[  403.381769] swapper/0 [HC0[0]:SC1[1]:HE1:SE0] takes:
[  403.386762]  (&(&imxdma->lock)->rlock){?.-...}, at: [<c019d77c>] imxdma_tasklet+0x20/0x134
[  403.395201] {IN-HARDIRQ-W} state was registered at:
[  403.400108]   [<c004b264>] mark_lock+0x2a0/0x6b4
[  403.404798]   [<c004d7c8>] __lock_acquire+0x650/0x1a64
[  403.410004]   [<c004f15c>] lock_acquire+0x94/0xa8
[  403.414773]   [<c02f74e4>] _raw_spin_lock+0x54/0x8c
[  403.419720]   [<c019d094>] dma_irq_handler+0x78/0x254
[  403.424845]   [<c0061124>] handle_irq_event_percpu+0x38/0x1b4
[  403.430670]   [<c00612e4>] handle_irq_event+0x44/0x64
[  403.435789]   [<c0063a70>] handle_level_irq+0xd8/0xf0
[  403.440903]   [<c0060a20>] generic_handle_irq+0x28/0x38
[  403.446194]   [<c0009cc4>] handle_IRQ+0x68/0x8c
[  403.450789]   [<c0008714>] avic_handle_irq+0x3c/0x48
[  403.455811]   [<c0008f84>] __irq_svc+0x44/0x74
[  403.460314]   [<c0040b04>] cpu_startup_entry+0x88/0xf4
[  403.465525]   [<c02f00d0>] rest_init+0xb8/0xe0
[  403.470045]   [<c03e07dc>] start_kernel+0x28c/0x2d4
[  403.474986]   [<a0008040>] 0xa0008040
[  403.478709] irq event stamp: 50854
[  403.482140] hardirqs last  enabled at (50854): [<c001c6b8>] tasklet_action+0x38/0xdc
[  403.489954] hardirqs last disabled at (50853): [<c001c6a0>] tasklet_action+0x20/0xdc
[  403.497761] softirqs last  enabled at (50850): [<c001bc64>] _local_bh_enable+0x14/0x18
[  403.505741] softirqs last disabled at (50851): [<c001c268>] irq_exit+0x88/0xdc
[  403.513026]
[  403.513026] other info that might help us debug this:
[  403.519593]  Possible unsafe locking scenario:
[  403.519593]
[  403.525548]        CPU0
[  403.528020]        ----
[  403.530491]   lock(&(&imxdma->lock)->rlock);
[  403.534828]   <Interrupt>
[  403.537474]     lock(&(&imxdma->lock)->rlock);
[  403.541983]
[  403.541983]  *** DEADLOCK ***
[  403.541983]
[  403.547951] no locks held by swapper/0.
[  403.551813]
[  403.551813] stack backtrace:
[  403.556222] CPU: 0 PID: 0 Comm: swapper Not tainted 3.10.0-20130823+ #904
[  403.563039] Backtrace:
[  403.565581] [<c000b98c>] (dump_backtrace+0x0/0x10c) from [<c000bb28>] (show_stack+0x18/0x1c)
[  403.574054]  r6:00000000 r5:c05c51d8 r4:c040bd58 r3:00200000
[  403.579872] [<c000bb10>] (show_stack+0x0/0x1c) from [<c02f398c>] (dump_stack+0x20/0x28)
[  403.587955] [<c02f396c>] (dump_stack+0x0/0x28) from [<c02f29c8>] (print_usage_bug.part.28+0x224/0x28c)
[  403.597340] [<c02f27a4>] (print_usage_bug.part.28+0x0/0x28c) from [<c004b404>] (mark_lock+0x440/0x6b4)
[  403.606682]  r8:c004a41c r7:00000000 r6:c040bd58 r5:c040c040 r4:00000002
[  403.613566] [<c004afc4>] (mark_lock+0x0/0x6b4) from [<c004d844>] (__lock_acquire+0x6cc/0x1a64)
[  403.622244] [<c004d178>] (__lock_acquire+0x0/0x1a64) from [<c004f15c>] (lock_acquire+0x94/0xa8)
[  403.631010] [<c004f0c8>] (lock_acquire+0x0/0xa8) from [<c02f74e4>] (_raw_spin_lock+0x54/0x8c)
[  403.639614] [<c02f7490>] (_raw_spin_lock+0x0/0x8c) from [<c019d77c>] (imxdma_tasklet+0x20/0x134)
[  403.648434]  r6:c3847010 r5:c040e890 r4:c38470d4
[  403.653194] [<c019d75c>] (imxdma_tasklet+0x0/0x134) from [<c001c70c>] (tasklet_action+0x8c/0xdc)
[  403.662013]  r8:c0599160 r7:00000000 r6:00000000 r5:c040e890 r4:c3847114 r3:c019d75c
[  403.670042] [<c001c680>] (tasklet_action+0x0/0xdc) from [<c001bd4c>] (__do_softirq+0xe4/0x1f0)
[  403.678687]  r7:00000101 r6:c0402000 r5:c059919c r4:00000001
[  403.684498] [<c001bc68>] (__do_softirq+0x0/0x1f0) from [<c001c268>] (irq_exit+0x88/0xdc)
[  403.692652] [<c001c1e0>] (irq_exit+0x0/0xdc) from [<c0009cc8>] (handle_IRQ+0x6c/0x8c)
[  403.700514]  r4:00000030 r3:00000110
[  403.704192] [<c0009c5c>] (handle_IRQ+0x0/0x8c) from [<c0008714>] (avic_handle_irq+0x3c/0x48)
[  403.712664]  r5:c0403f28 r4:c0593ebc
[  403.716343] [<c00086d8>] (avic_handle_irq+0x0/0x48) from [<c0008f84>] (__irq_svc+0x44/0x74)
[  403.724733] Exception stack(0xc0403f28 to 0xc0403f70)
[  403.729841] 3f20:                   00000001 00000004 00000000 20000013 c0402000 c04104a8
[  403.738078] 3f40: 00000002 c0b69620 a0004000 41069264 a03fb5f4 c0403f7c c0403f40 c0403f70
[  403.746301] 3f60: c004b92c c0009e74 20000013 ffffffff
[  403.751383]  r6:ffffffff r5:20000013 r4:c0009e74 r3:c004b92c
[  403.757210] [<c0009e30>] (arch_cpu_idle+0x0/0x4c) from [<c0040b04>] (cpu_startup_entry+0x88/0xf4)
[  403.766161] [<c0040a7c>] (cpu_startup_entry+0x0/0xf4) from [<c02f00d0>] (rest_init+0xb8/0xe0)
[  403.774753] [<c02f0018>] (rest_init+0x0/0xe0) from [<c03e07dc>] (start_kernel+0x28c/0x2d4)
[  403.783051]  r6:c03fc484 r5:ffffffff r4:c040a0e0
[  403.787797] [<c03e0550>] (start_kernel+0x0/0x2d4) from [<a0008040>] (0xa0008040)

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
2013-10-04 14:34:54 +05:30
..
bestcomm Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2013-02-23 17:09:55 -08:00
dw Remove GENERIC_HARDIRQ config option 2013-09-13 15:09:52 +02:00
ioat ioatdma: silence GCC warnings 2013-08-23 00:21:44 -07:00
ipu dma: ipu: remove unnecessary platform_set_drvdata() 2013-08-25 14:37:13 +05:30
ppc4xx Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma 2013-07-07 11:11:43 -07:00
sh Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma 2013-09-10 13:37:36 -07:00
Kconfig dma/Kconfig: Make TI_EDMA select TI_PRIV_EDMA 2013-09-17 10:26:22 +05:30
Makefile Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma 2013-09-10 13:37:36 -07:00
TODO dmaengine: remove ste_dma40 from issue_pending TODO 2011-07-14 04:02:08 +05:30
acpi-dma.c acpi-dma: remove ugly conversion 2013-08-25 16:43:45 +05:30
amba-pl08x.c Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma 2013-09-10 13:37:36 -07:00
at_hdmac.c dmaengine: at_hdmac: prepare clk before calling enable 2013-07-05 11:40:57 +05:30
at_hdmac_regs.h DMA: AT91: Get residual bytes in dma buffer 2013-07-05 11:40:31 +05:30
coh901318.c coh901318: don't open-code simple_read_from_buffer() 2013-09-03 22:52:46 -04:00
coh901318.h dma: coh901318: merge header files 2013-01-07 17:36:37 +01:00
coh901318_lli.c Merge branch 'next' of git://git.infradead.org/users/vkoul/slave-dma 2013-02-26 09:24:48 -08:00
cppi41.c dma: cppi41: off by one in desc_to_chan() 2013-08-28 15:46:33 -07:00
dma-jz4740.c MIPS: jz4740: Remove custom DMA API 2013-07-05 11:40:52 +05:30
dmaengine.c Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma 2013-09-10 13:37:36 -07:00
dmaengine.h dmaengine: consolidate initialization of cookies 2012-03-13 11:37:22 +05:30
dmatest.c dmatest: print message on debug level in case of no error 2013-08-22 22:57:35 -07:00
edma.c edma: Update author email address 2013-09-17 09:19:46 +05:30
ep93xx_dma.c ep93xx_dma: remove useless use of lock 2013-08-05 09:32:24 +05:30
fsldma.c fsldma: remove useless use of lock 2013-08-05 09:32:24 +05:30
fsldma.h dmaengine: move last completed cookie into generic dma_chan structure 2012-03-13 11:36:06 +05:30
imx-dma.c dmaengine: imx-dma: fix lockdep issue between irqhandler and tasklet 2013-10-04 14:34:54 +05:30
imx-sdma.c dma: imx-sdma: Staticize sdma_driver_data structures 2013-09-02 12:00:02 +05:30
intel_mid_dma.c PM / Runtime: Rework the "runtime idle" helper routine 2013-06-03 21:49:52 +02:00
intel_mid_dma_regs.h dma: fix comments 2012-09-01 08:57:12 -07:00
iop-adma.c dma: use dev_get_platdata() 2013-08-13 16:56:41 +05:30
iovlock.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
k3dma.c dma: k3dma: use devm_ioremap_resource() instead of devm_request_and_ioremap() 2013-09-02 17:35:34 +05:30
mmp_pdma.c dma: mmp_pdma: set DMA_PRIVATE 2013-08-25 22:04:53 +05:30
mmp_tdma.c dma: mmp: simplify use of devm_ioremap_resource 2013-08-14 14:51:28 +05:30
mpc512x_dma.c mpc512x_dma: remove useless use of lock 2013-08-05 09:32:25 +05:30
mv_xor.c Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma 2013-09-10 13:37:36 -07:00
mv_xor.h mv_xor: support big endian systems using descriptor swap feature 2013-08-22 22:57:37 -07:00
mxs-dma.c dma: mxs-dma: remove code left from generic DMA binding conversion 2013-08-19 14:20:21 +05:30
of-dma.c dma: of: make error message more meaningful by adding the node name 2013-08-19 14:45:05 +05:30
omap-dma.c dmaengine: OMAP: Register SDMA controller with Device Tree DMA driver 2013-04-15 09:51:19 +05:30
pch_dma.c pch_dma: Add MODULE_DEVICE_TABLE 2013-09-02 11:59:58 +05:30
pl330.c Merge branch 'topic/api_caps' into for-linus 2013-09-04 18:36:53 +05:30
sa11x0-dma.c Drivers: dma: remove __dev* attributes. 2013-01-03 15:57:15 -08:00
sirf-dma.c dmaengine: sirf: add PM entries for sleep and runtime 2013-08-13 17:01:01 +05:30
ste_dma40.c dma: ste_dma40: Fix potential null pointer dereference 2013-09-02 17:36:00 +05:30
ste_dma40_ll.c dmaengine: ste_dma40_ll: Replace meaningless register set with comment 2013-06-04 11:12:10 +02:00
ste_dma40_ll.h dmaengine: ste_dma40: Remove unnecessary call to d40_phy_cfg() 2013-05-23 21:13:19 +02:00
tegra20-apb-dma.c tegra20-apb-dma: remove useless use of lock 2013-08-05 09:32:25 +05:30
timb_dma.c dma: use dev_get_platdata() 2013-08-13 16:56:41 +05:30
txx9dmac.c dma: use dev_get_platdata() 2013-08-13 16:56:41 +05:30
txx9dmac.h dmaengine: move last completed cookie into generic dma_chan structure 2012-03-13 11:36:06 +05:30
virt-dma.c dmaengine: virt-dma: add support for cyclic DMA periodic callbacks 2012-07-01 14:15:23 +01:00
virt-dma.h dmaengine: virt-dma: add support for cyclic DMA periodic callbacks 2012-07-01 14:15:23 +01:00