From: Russell King Date: Fri, 25 Apr 2014 11:59:10 +0000 (+0100) Subject: mmc: sdhci-esdhc-imx: fix lockdep splat upon tuning X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cb399da401c64f527ced132179f66ac022e63d7b;p=linux-beck.git mmc: sdhci-esdhc-imx: fix lockdep splat upon tuning ================================= [ INFO: inconsistent lock state ] 3.14.0-rc1+ #490 Not tainted --------------------------------- inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. kworker/u8:0/6 [HC0[0]:SC0[0]:HE1:SE1] takes: (&(&host->lock)->rlock#2){?.-...}, at: [] esdhc_send_tuning_cmd+0x104/0x14c {IN-HARDIRQ-W} state was registered at: [] mark_lock+0x15c/0x6f8 [] __lock_acquire+0xabc/0x1ca0 [] lock_acquire+0xa0/0x130 [] _raw_spin_lock+0x34/0x44 [] sdhci_irq+0x20/0xa40 [] handle_irq_event_percpu+0x74/0x284 [] handle_irq_event+0x44/0x64 [] handle_fasteoi_irq+0xac/0x140 [] generic_handle_irq+0x28/0x38 [] handle_IRQ+0x40/0x98 [] gic_handle_irq+0x30/0x64 [] __irq_svc+0x44/0x58 [] irq_exit+0xc0/0x120 [] handle_IRQ+0x44/0x98 [] gic_handle_irq+0x30/0x64 [] __irq_svc+0x44/0x58 [] printk+0x3c/0x44 [] _regulator_get+0x1b4/0x1e0 [] regulator_get+0x18/0x1c [] mmc_add_host+0x30/0x1c0 [] sdhci_add_host+0x804/0xbbc [] sdhci_esdhc_imx_probe+0x380/0x674 [] platform_drv_probe+0x20/0x50 [] driver_probe_device+0x120/0x234 [] __driver_attach+0x9c/0xa0 [] bus_for_each_dev+0x5c/0x90 [] driver_attach+0x24/0x28 [] bus_add_driver+0xe4/0x1d8 [] driver_register+0x80/0xfc [] __platform_driver_register+0x50/0x64 [] sdhci_esdhc_imx_driver_init+0x18/0x20 [] do_one_initcall+0x3c/0x164 [] kernel_init_freeable+0x104/0x1d0 [] kernel_init+0x10/0x118 [] ret_from_fork+0x14/0x2c irq event stamp: 5933 hardirqs last enabled at (5933): [] _raw_spin_unlock_irqrestore+0x38/0x4c hardirqs last disabled at (5932): [] _raw_spin_lock_irqsave+0x24/0x60 softirqs last enabled at (5914): [] __do_softirq+0x260/0x360 softirqs last disabled at (5909): [] irq_exit+0xc0/0x120 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(&(&host->lock)->rlock#2); lock(&(&host->lock)->rlock#2); *** DEADLOCK *** 2 locks held by kworker/u8:0/6: #0: (kmmcd){.+.+.+}, at: [] process_one_work+0x134/0x4e8 #1: ((&(&host->detect)->work)){+.+.+.}, at: [] process_one_work+0x134/0x4e8 stack backtrace: CPU: 2 PID: 6 Comm: kworker/u8:0 Not tainted 3.14.0-rc1+ #490 Workqueue: kmmcd mmc_rescan Backtrace: [] (dump_backtrace) from [] (show_stack+0x18/0x1c) [] (show_stack) from [] (dump_stack+0x70/0x8c) [] (dump_stack) from [] (print_usage_bug+0x274/0x2e4) [] (print_usage_bug) from [] (mark_lock+0x5d4/0x6f8) [] (mark_lock) from [] (__lock_acquire+0x5d4/0x1ca0) [] (__lock_acquire) from [] (lock_acquire+0xa0/0x130) [] (lock_acquire) from [] (_raw_spin_lock+0x34/0x44) [] (_raw_spin_lock) from [] (esdhc_send_tuning_cmd+0x104/0x14c) [] (esdhc_send_tuning_cmd) from [] (esdhc_executing_tuning+0x40/0x100) [] (esdhc_executing_tuning) from [] (sdhci_execute_tuning+0xcc/0x754) [] (sdhci_execute_tuning) from [] (mmc_sd_init_card+0x65c/0x694) [] (mmc_sd_init_card) from [] (mmc_attach_sd+0xb0/0x184) [] (mmc_attach_sd) from [] (mmc_rescan+0x26c/0x2e8) [] (mmc_rescan) from [] (process_one_work+0x1b8/0x4e8) [] (process_one_work) from [] (worker_thread+0x13c/0x3f8) [] (worker_thread) from [] (kthread+0xcc/0xe8) [] (kthread) from [] (ret_from_fork+0x14/0x2c) Signed-off-by: Russell King Tested-by: Markus Pargmann Tested-by: Stephen Warren Signed-off-by: Ulf Hansson Signed-off-by: Chris Ball --- diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index eb7a13796bcb..dfed2c37ab3f 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -738,14 +738,12 @@ static int esdhc_send_tuning_cmd(struct sdhci_host *host, u32 opcode, mrq.done = esdhc_request_done; init_completion(&(mrq.completion)); - disable_irq(host->irq); - spin_lock(&host->lock); + spin_lock_irq(&host->lock); host->mrq = &mrq; sdhci_send_command(host, mrq.cmd); - spin_unlock(&host->lock); - enable_irq(host->irq); + spin_unlock_irq(&host->lock); wait_for_completion(&mrq.completion);