From patchwork Thu Mar 6 04:25:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Mayer X-Patchwork-Id: 25775 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 09D21203C3 for ; Thu, 6 Mar 2014 04:26:26 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf4759815pdb.1 for ; Wed, 05 Mar 2014 20:26:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=iortP9fSGD8LuxAVMFPvnXuzqb1woVg4Qu+JyC0VmRE=; b=Ec9mSaL15axjZALw7iL4mmeTdlEjBPtf9WSuU7SLXOs8X+yynxk02x+OvlqibU8wwB EdAeLzuVIWBhlO4fTeJdKhiJFi3UeeocaMVWTjo0pM7VId/IB9sNjyw48SuHzaJeVsS4 OITiputKFa/6OvRfMxp6YZ0AvB4nN41EdUydaFxXo6sLNmraBa78eSrHiqlFaxXh/5rD EQd9OluuRgbsBjHQVNxhJkrvK0IPjtCu0qvWvIuHG1vsiwRusNxoRjX+Tam73i0gwi7Y rR0Qm/QxK/t83WXdSPoqAIZkx5Rjf8GtI33H5nxFufMN7ILgulzYx6YxI+FvmG1kYdxh eZlQ== X-Gm-Message-State: ALoCoQlyGu53KQiV3PH7ieoeYr63lD4qac1zHUhqC/PLlSJkZZemen6wsPL2NopxEXwLjiq0ir7K X-Received: by 10.67.21.145 with SMTP id hk17mr4364670pad.35.1394079986151; Wed, 05 Mar 2014 20:26:26 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.115 with SMTP id b106ls651604qgd.97.gmail; Wed, 05 Mar 2014 20:26:26 -0800 (PST) X-Received: by 10.53.9.107 with SMTP id dr11mr6231584vdd.1.1394079986015; Wed, 05 Mar 2014 20:26:26 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id cz20si808226veb.53.2014.03.05.20.26.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Mar 2014 20:26:26 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so2116308veb.9 for ; Wed, 05 Mar 2014 20:26:25 -0800 (PST) X-Received: by 10.52.248.138 with SMTP id ym10mr6408978vdc.18.1394079985925; Wed, 05 Mar 2014 20:26:25 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp10020vck; Wed, 5 Mar 2014 20:26:25 -0800 (PST) X-Received: by 10.66.180.200 with SMTP id dq8mr11793702pac.104.1394079984958; Wed, 05 Mar 2014 20:26:24 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yn4si4057326pab.23.2014.03.05.20.26.24; Wed, 05 Mar 2014 20:26:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754741AbaCFE0O (ORCPT + 26 others); Wed, 5 Mar 2014 23:26:14 -0500 Received: from smtp2.macau.ctm.net ([202.175.3.60]:50214 "EHLO smtp2.macau.ctm.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751573AbaCFE0J (ORCPT ); Wed, 5 Mar 2014 23:26:09 -0500 Received: from smtp2.macau.ctm.net (localhost.localdomain [127.0.0.1]) by localhost.macau.ctm.net (Postfix) with ESMTP id 69DA210809E; Thu, 6 Mar 2014 12:26:06 +0800 (HKT) Received: from mmayer-lnx.ric.broadcom.com (z88l218.static.ctm.net [202.175.88.218]) by smtp2.macau.ctm.net (Postfix) with ESMTP id A96761080A1; Thu, 6 Mar 2014 12:26:02 +0800 (HKT) From: Markus Mayer To: Chris Ball , Matt Porter , Christian Daudt Cc: Linux MMC List , Linux Kernel Mailing List Subject: [PATCH] mmc: sdhci-bcm-kona: Fix locking in sdhci_bcm_kona_sd_card_emulate() Date: Thu, 6 Mar 2014 12:25:58 +0800 Message-Id: <1394079958-11697-1-git-send-email-markus.mayer@linaro.org> X-Mailer: git-send-email 1.9.0 X-TM-AS-MML: No X-TM-AS-Product-Ver: IMSS-7.1.0.1392-7.5.0.1017-20548.004 X-TM-AS-Result: No--0.062-7.0-31-10 X-imss-scan-details: No--0.062-7.0-31-10;No--0.062-7.0-31-10 X-TMASE-MatchedRID: mLU5UzDdkUfC5N8cNUn/Xu9VsdrlGzy3QZXZg2I8JaYAhmnHHeGnvXIr z4haHlKCVLAa8KXwKt6xU5UDu7afsFMLIXMANKM1hMGTNuQTHbP6Vf9FxCgbYVfgf8AdlMAqwxS q3hNHjOpp2AbuTNMCFE9OrKiVC6JMLEOiOYXcCR0VglQa/gMvfH0tCKdnhB589yM15V5aWpj6C0 ePs7A07aLm79W+wVodQPDH2x9UZpQxg7HOq8LCmSrJZXAidgVb/NuPbD6UeWeMKFZvGDkwiuhyA 9ubzvtOBL7xAmYvNQtNViyaL0htgdJsOPD/RP5o8gwWDQic4+rPmACeZqO85TioKJ2WPUxTLS4A EOLjtwA= Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: markus.mayer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Since sdhci_bcm_kona_sd_card_emulate() can be called from interrupt context, we must use a spinlock instead of a mutex. This change essentially restores the way things worked before the change to mutexes in http://www.spinics.net/lists/linux-mmc/msg20276.html. Without this change, we see "scheduling while atomic" errors. Signed-off-by: Markus Mayer --- drivers/mmc/host/sdhci-bcm-kona.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c index 7a190fe..f1b0a62 100644 --- a/drivers/mmc/host/sdhci-bcm-kona.c +++ b/drivers/mmc/host/sdhci-bcm-kona.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Broadcom Corporation + * Copyright (C) 2013-2014 Broadcom Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -53,7 +53,7 @@ #define KONA_MMC_AUTOSUSPEND_DELAY (50) struct sdhci_bcm_kona_dev { - struct mutex write_lock; /* protect back to back writes */ + spinlock_t write_lock; /* protect back to back writes */ }; @@ -135,7 +135,7 @@ static int sdhci_bcm_kona_sd_card_emulate(struct sdhci_host *host, int insert) * insert-removal. * We keep 20uS */ - mutex_lock(&kona_dev->write_lock); + spin_lock_bh(&kona_dev->write_lock); udelay(20); val = sdhci_readl(host, KONA_SDHOST_CORESTAT); @@ -153,7 +153,7 @@ static int sdhci_bcm_kona_sd_card_emulate(struct sdhci_host *host, int insert) val &= ~KONA_SDHOST_CD_SW; sdhci_writel(host, val, KONA_SDHOST_CORESTAT); } - mutex_unlock(&kona_dev->write_lock); + spin_unlock_bh(&kona_dev->write_lock); return 0; } @@ -247,7 +247,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev) pltfm_priv = sdhci_priv(host); kona_dev = sdhci_pltfm_priv(pltfm_priv); - mutex_init(&kona_dev->write_lock); + spin_lock_init(&kona_dev->write_lock); mmc_of_parse(host->mmc);