From patchwork Wed Dec 4 02:48:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Tobias X-Patchwork-Id: 3280691 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 229BE9F377 for ; Wed, 4 Dec 2013 02:48:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CAA9F20445 for ; Wed, 4 Dec 2013 02:48:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD39220382 for ; Wed, 4 Dec 2013 02:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754800Ab3LDCsa (ORCPT ); Tue, 3 Dec 2013 21:48:30 -0500 Received: from mail-ob0-f173.google.com ([209.85.214.173]:52837 "EHLO mail-ob0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754888Ab3LDCs3 (ORCPT ); Tue, 3 Dec 2013 21:48:29 -0500 Received: by mail-ob0-f173.google.com with SMTP id gq1so15366847obb.4 for ; Tue, 03 Dec 2013 18:48:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=I9fnBysdvITU4I1DZNDKzcKPTBqyjvcZV3a8IWEu4HY=; b=iGZ/WiQSpW9bRGXlJK5dwy5UBbE9bqK4fPjpZHY2zZWbf1dU5WmVvHdM90toaDaIy+ 9hn5Baul5sFUEFIRdj/FnlwnFZcL4KvC8yBEG/y4q6K29F52Jgjwp/swo54G2w1cmlLh ok7CTXD7eDQ2kWIQwmbh+FYBCSC3uqSkSPeuifgxIGqe7taF3KuZ+AJH2mwNQzuYqFX2 lDIH7hHwFWTpVwP/9kKpNbvcytjs2FWf8lpMsOHcIxEyv3EyvN31HSllJAXmmsOhMbxh mNRe5QOct1xmcqtTnXFY+hmJl/c8j4FklWwonsAUG2wV4srtU3VLvEDbifYCGreaOYxP 4JEw== MIME-Version: 1.0 X-Received: by 10.60.68.135 with SMTP id w7mr63237286oet.9.1386125308724; Tue, 03 Dec 2013 18:48:28 -0800 (PST) Received: by 10.60.13.234 with HTTP; Tue, 3 Dec 2013 18:48:28 -0800 (PST) Date: Tue, 3 Dec 2013 18:48:28 -0800 Message-ID: Subject: [PATCH] mmc: sdhci: Resolved DEADLOCK From: John Tobias To: linux-mmc@vger.kernel.org, Shawn Guo , Fabio Estevam , Dong Aisheng , Chris Ball , Markus.Niebel@tqs.de, Ulf Hansson Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: John Tobias Remove the locking inside sdhci_execute_tuning to avoid the following warnings when an SDIO device is connected / enabled. @@ -1873,13 +1872,13 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) } if (host->ops->platform_execute_tuning) { - spin_unlock(&host->lock); enable_irq(host->irq); err = host->ops->platform_execute_tuning(host, opcode); sdhci_runtime_pm_put(host); return err; } + sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); /* @@ -1947,7 +1946,6 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) host->cmd = NULL; host->mrq = NULL; - spin_unlock(&host->lock); enable_irq(host->irq); /* Wait for Buffer Read Ready interrupt */ @@ -1955,7 +1953,6 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) (host->tuning_done == 1), msecs_to_jiffies(50)); disable_irq(host->irq); - spin_lock(&host->lock); if (!host->tuning_done) { pr_info(DRIVER_NAME ": Timeout waiting for " @@ -2030,7 +2027,6 @@ out: err = 0; sdhci_clear_set_irqs(host, SDHCI_INT_DATA_AVAIL, ier); - spin_unlock(&host->lock); enable_irq(host->irq); sdhci_runtime_pm_put(host); --- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ================================= [ INFO: inconsistent lock state ] 3.13.0-rc1 #12 Not tainted --------------------------------- inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. kworker/u2:1/13 [HC0[0]:SC0[0]:HE1:SE1] takes: (&(&host->lock)->rlock#2){?.-...}, at: [<80315ffc>] sdhci_execute_tuning+0x4c/0x710 {IN-HARDIRQ-W} state was registered at: [<8004d2f4>] mark_lock+0x170/0x684 [<8004e8d8>] __lock_acquire+0xafc/0x1bc4 [<80050140>] lock_acquire+0x70/0x84 [<8048a198>] _raw_spin_lock+0x30/0x40 [<80316dfc>] sdhci_irq+0x24/0xa74 [<80058c5c>] handle_irq_event_percpu+0x38/0x1a0 [<80058e08>] handle_irq_event+0x44/0x64 [<8005b7d0>] handle_fasteoi_irq+0x80/0x14c [<80058468>] generic_handle_irq+0x30/0x44 [<8000ed60>] handle_IRQ+0x38/0x8c [<80008534>] gic_handle_irq+0x30/0x5c [<800127e4>] __irq_svc+0x44/0x5c [<8024801c>] pin_get_from_name+0x58/0x80 [<8024a0d8>] pinconf_map_to_setting+0x70/0xb0 [<80247884>] pinctrl_get+0x210/0x43c [<80247ae0>] devm_pinctrl_get+0x30/0x70 [<8029aa6c>] pinctrl_bind_pins+0x34/0x100 [<802867cc>] driver_probe_device+0x60/0x234 [<80286a88>] __driver_attach+0x9c/0xa0 [<80284c94>] bus_for_each_dev+0x68/0x9c [<8028633c>] driver_attach+0x20/0x28 [<80285fc0>] bus_add_driver+0x148/0x1f4 [<802870d8>] driver_register+0x80/0x100 [<8028824c>] __platform_driver_register+0x50/0x64 [<80606f04>] sdhci_esdhc_imx_driver_init+0x18/0x20 [<800087a4>] do_one_initcall+0x108/0x16c [<805eabe8>] kernel_init_freeable+0xf8/0x1b8 [<80480144>] kernel_init+0x10/0x120 [<8000e528>] ret_from_fork+0x14/0x2c irq event stamp: 366717 hardirqs last enabled at (366717): [<8048a40c>] _raw_spin_unlock_irqrestore+0x38/0x4c hardirqs last disabled at (366716): [<8048a298>] _raw_spin_lock_irqsave+0x24/0x54 softirqs last enabled at (365438): [<80025880>] __do_softirq+0x194/0x258 softirqs last disabled at (365431): [<80025d20>] irq_exit+0xb0/0x108 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/u2:1/13: #0: (kmmcd){.+.+.+}, at: [<80036f64>] process_one_work+0x124/0x444 #1: ((&(&host->detect)->work)){+.+.+.}, at: [<80036f64>] process_one_work+0x124/0x444 stack backtrace: CPU: 0 PID: 13 Comm: kworker/u2:1 Not tainted 3.13.0-rc1 #12 Workqueue: kmmcd mmc_rescan Backtrace: [<8001197c>] (dump_backtrace+0x0/0x10c) from [<80011c54>] (show_stack+0x18/0x1c) r6:00000000 r5:807041a4 r4:bf866600 r3:bf866600 [<80011c3c>] (show_stack+0x0/0x1c) from [<80484758>] (dump_stack+0x20/0x28) [<80484738>] (dump_stack+0x0/0x28) from [<80482900>] (print_usage_bug.part.34+0x224/0x28c) [<804826dc>] (print_usage_bug.part.34+0x0/0x28c) from [<8004d380>] (mark_lock+0x1fc/0x684) r8:807041a4 r7:8062bc08 r6:bf866600 r5:bf866970 r4:00000002 [<8004d184>] (mark_lock+0x0/0x684) from [<8004e3cc>] (__lock_acquire+0x5f0/0x1bc4) [<8004dddc>] (__lock_acquire+0x0/0x1bc4) from [<80050140>] (lock_acquire+0x70/0x84) [<800500d0>] (lock_acquire+0x0/0x84) from [<8048a198>] (_raw_spin_lock+0x30/0x40) r7:00000004 r6:00000005 r5:bf34c000 r4:bf9ad568 [<8048a168>] (_raw_spin_lock+0x0/0x40) from [<80315ffc>] (sdhci_execute_tuning+0x4c/0x710) r4:bf9ad000 [<80315fb0>] (sdhci_execute_tuning+0x0/0x710) from [<8030badc>] (mmc_sdio_init_card+0xa74/0xab4) [<8030b068>] (mmc_sdio_init_card+0x0/0xab4) from [<8030be44>] (mmc_attach_sdio+0x80/0x364) [<8030bdc4>] (mmc_attach_sdio+0x0/0x364) from [<80304388>] (mmc_rescan+0x23c/0x2e4) [<8030414c>] (mmc_rescan+0x0/0x2e4) from [<80036fe0>] (process_one_work+0x1a0/0x444) r8:00000000 r7:bf94deb0 r6:bf84e800 r5:bf9ad2f8 r4:bf916900 r3:8030414c [<80036e40>] (process_one_work+0x0/0x444) from [<80037f08>] (worker_thread+0x118/0x3e0) [<80037df0>] (worker_thread+0x0/0x3e0) from [<8003da34>] (kthread+0xcc/0xe8) [<8003d968>] (kthread+0x0/0xe8) from [<8000e528>] (ret_from_fork+0x14/0x2c) r7:00000000 r6:00000000 r5:8003d968 r4:bf919200 diff --git a/linux-3.13-rc1/drivers/mmc/host/sdhci.c b/linux-3.13-rc1/drivers/mmc/host/sdhci.c index 6c06e61..02827ed 100644 --- a/linux-3.13-rc1/drivers/mmc/host/sdhci.c +++ b/linux-3.13-rc1/drivers/mmc/host/sdhci.c @@ -1846,7 +1846,6 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) sdhci_runtime_pm_get(host); disable_irq(host->irq); - spin_lock(&host->lock); ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);