From patchwork Mon Jan 20 15:03:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Rakity X-Patchwork-Id: 3513221 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 4F9039F2D6 for ; Mon, 20 Jan 2014 15:04:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D3AC20161 for ; Mon, 20 Jan 2014 15:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 521F22015E for ; Mon, 20 Jan 2014 15:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751887AbaATPD6 (ORCPT ); Mon, 20 Jan 2014 10:03:58 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:12937 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751740AbaATPD6 convert rfc822-to-8bit (ORCPT ); Mon, 20 Jan 2014 10:03:58 -0500 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Mon, 20 Jan 2014 07:04:07 -0800 Received: from hqemhub01.nvidia.com ([172.20.12.94]) by hqnvupgp07.nvidia.com (PGP Universal service); Mon, 20 Jan 2014 07:03:20 -0800 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 20 Jan 2014 07:03:20 -0800 Received: from HQMAIL102.nvidia.com (172.18.146.10) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server (TLS) id 8.3.327.1; Mon, 20 Jan 2014 07:03:57 -0800 Received: from HQMAIL102.nvidia.com (172.18.146.10) by HQMAIL102.nvidia.com (172.18.146.10) with Microsoft SMTP Server (TLS) id 15.0.775.38; Mon, 20 Jan 2014 07:03:57 -0800 Received: from deemhub02.nvidia.com (10.21.69.138) by HQMAIL102.nvidia.com (172.18.146.10) with Microsoft SMTP Server (TLS) id 15.0.775.38 via Frontend Transport; Mon, 20 Jan 2014 07:03:56 -0800 Received: from DEMAIL01.nvidia.com ([10.21.69.140]) by deemhub02.nvidia.com ([10.21.69.138]) with mapi; Mon, 20 Jan 2014 16:03:48 +0100 From: Philip Rakity To: Chris Ball CC: "linux-mmc@vger.kernel.org" Date: Mon, 20 Jan 2014 16:03:48 +0100 Subject: Re: [PATCH] mmc: sdhci: fix possible scheduling while atomic Thread-Topic: [PATCH] mmc: sdhci: fix possible scheduling while atomic Thread-Index: Ac8V8NK7coGzdDOPQWOgV3++73wYEg== Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Content-Language: en-US Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 I have no way to test this problem but I was thinking along the lines of regards, Philip On Jan 20, 2014, at 9:51 AM, Philip Rakity wrote: > > Chris, > > The suggested fix can lock out interrupts for up to 150ms. There needs to be another way. > So, I would strongly recommend we find another solution. > > Philip > > On Jan 17, 2014, at 7:57 PM, Andrew Bresticker wrote: > >> sdhci_execute_tuning() takes host->lock without disabling interrupts. >> Use spin_lock_irq{save,restore} instead so that we avoid taking an >> interrupt and scheduling while holding host->lock. >> >> Signed-off-by: Andrew Bresticker >> --- >> drivers/mmc/host/sdhci.c | 13 +++++++------ >> 1 file changed, 7 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c >> index ec3eb30..84c80e7 100644 >> --- a/drivers/mmc/host/sdhci.c >> +++ b/drivers/mmc/host/sdhci.c >> @@ -1857,12 +1857,13 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) >> unsigned long timeout; >> int err = 0; >> bool requires_tuning_nonuhs = false; >> + unsigned long flags; >> >> host = mmc_priv(mmc); >> >> sdhci_runtime_pm_get(host); >> disable_irq(host->irq); >> - spin_lock(&host->lock); >> + spin_lock_irqsave(&host->lock, flags); > > > The disable_irq() call stops the controller from doing interrupts. > Please explain what problem you are seeing > >> >> ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); >> >> @@ -1882,14 +1883,14 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) >> requires_tuning_nonuhs) >> ctrl |= SDHCI_CTRL_EXEC_TUNING; >> else { >> - spin_unlock(&host->lock); >> + spin_unlock_irqrestore(&host->lock, flags); >> enable_irq(host->irq); >> sdhci_runtime_pm_put(host); >> return 0; >> } >> >> if (host->ops->platform_execute_tuning) { >> - spin_unlock(&host->lock); >> + spin_unlock_irqrestore(&host->lock, flags); >> enable_irq(host->irq); >> err = host->ops->platform_execute_tuning(host, opcode); >> sdhci_runtime_pm_put(host); >> @@ -1963,7 +1964,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) >> host->cmd = NULL; >> host->mrq = NULL; >> >> - spin_unlock(&host->lock); >> + spin_unlock_irqrestore(&host->lock, flags); >> enable_irq(host->irq); >> >> /* Wait for Buffer Read Ready interrupt */ >> @@ -1971,7 +1972,7 @@ 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); >> + spin_lock_irqsave(&host->lock, flags); >> >> if (!host->tuning_done) { >> pr_info(DRIVER_NAME ": Timeout waiting for " >> @@ -2046,7 +2047,7 @@ out: >> err = 0; >> >> sdhci_clear_set_irqs(host, SDHCI_INT_DATA_AVAIL, ier); >> - spin_unlock(&host->lock); >> + spin_unlock_irqrestore(&host->lock, flags); >> enable_irq(host->irq); >> sdhci_runtime_pm_put(host); >> >> -- >> 1.8.5.2 >> >> -- >> 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 ----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. ----------------------------------------------------------------------------------- --- 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 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1862,6 +1862,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 sdhci_runtime_pm_get(host); disable_irq(host->irq); + sdhci_disable_card_detection(host); spin_lock(&host->lock); ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); @@ -1883,6 +1884,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 ctrl |= SDHCI_CTRL_EXEC_TUNING; else { spin_unlock(&host->lock); + sdhci_enable_card_detection(host); enable_irq(host->irq); sdhci_runtime_pm_put(host); return 0; @@ -1890,6 +1892,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 if (host->ops->platform_execute_tuning) { spin_unlock(&host->lock); + sdhci_enable_card_detection(host); enable_irq(host->irq); err = host->ops->platform_execute_tuning(host, opcode); sdhci_runtime_pm_put(host); @@ -2047,6 +2050,7 @@ out: sdhci_clear_set_irqs(host, SDHCI_INT_DATA_AVAIL, ier); spin_unlock(&host->lock); + sdhci_enable_card_detection(host); enable_irq(host->irq); sdhci_runtime_pm_put(host);