From patchwork Wed Mar 19 07:22:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Daudt X-Patchwork-Id: 3857871 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 3E0E29F334 for ; Wed, 19 Mar 2014 18:06:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 60416200DC for ; Wed, 19 Mar 2014 18:06:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 762832021F for ; Wed, 19 Mar 2014 18:06:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753380AbaCSHaR (ORCPT ); Wed, 19 Mar 2014 03:30:17 -0400 Received: from mail-qg0-f44.google.com ([209.85.192.44]:51642 "EHLO mail-qg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751468AbaCSHaR (ORCPT ); Wed, 19 Mar 2014 03:30:17 -0400 Received: by mail-qg0-f44.google.com with SMTP id a108so24600073qge.3 for ; Wed, 19 Mar 2014 00:30:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=QLfDFtpEf7DA8FLkNTHlcARgrIOmCcOJ0CBFD17TkUo=; b=DcSCvc8bHDnXOAAzToorN+EKPLj/i3/eUyTDs1vfpxu6cWEQ1X7+6OVatxDBvnzVEO BfQjDlfaEkg1BqLof4NijKVFxYeIOzTp02ziIgU4W5s4+mDZQWyKH5FIi//PIDutmt2L 8UE1aBQFNJjPM8TsISXwstaWLfZG1zqckezCTkpnVPW8JPNQzGvC9NdjQFCb8E/ZD4SW qKB7wHXEBdMHMe4A3pE7MW25ztK0TeuHKMuBL1wIib/FUN8UKsLDT0NJ1RE9t/Yx/7w4 VyRbrAbzMjcvv5tBtIdr2O2HXalbVG/GqE13XBbzNFiIjHqf7mL7G9cdsj++kEND5WSj kuCQ== X-Gm-Message-State: ALoCoQnBLrQKJ4ptteDodTEb9z2zeKQFRkBBEcKhyslm/wZf2JWXUFRsQHLw9GvPGpQjeBhvoyKr MIME-Version: 1.0 X-Received: by 10.140.38.168 with SMTP id t37mr38992474qgt.33.1395213725157; Wed, 19 Mar 2014 00:22:05 -0700 (PDT) Received: by 10.140.102.131 with HTTP; Wed, 19 Mar 2014 00:22:04 -0700 (PDT) In-Reply-To: <1394079958-11697-1-git-send-email-markus.mayer@linaro.org> References: <1394079958-11697-1-git-send-email-markus.mayer@linaro.org> Date: Wed, 19 Mar 2014 00:22:04 -0700 Message-ID: Subject: Re: [PATCH] mmc: sdhci-bcm-kona: Fix locking in sdhci_bcm_kona_sd_card_emulate() From: Christian Daudt To: Markus Mayer Cc: Chris Ball , Matt Porter , Linux MMC List , Linux Kernel Mailing List 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 On Wed, Mar 5, 2014 at 8:25 PM, Markus Mayer wrote: > 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 > --- So digging back in memory (since I no longer have the broadcom-internal email threads on this topic), I think I recall what the problem is. card_event is being called directly from mmc_gpio_cd_irqt, which is atomic context. My plan for this was to delay the card_event callback into the mmc_rescan worker, as that would have 2 nice results: remove the callback from atomic context which it doesn't need to be in, and put it in line with the debounced rescan (which I think it should be). I made mention of that option in this thread (https://lkml.org/lkml/2013/8/19/539) but seems I never followed up with code... Something along the lines of the (untested) code below might do the trick: Of course there are (a few) more users of card_event callback than bcm_kona that need to be confirmed ok such a change Thanks, csd --- 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 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 098374b..d4ffba8 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2421,6 +2421,11 @@ void mmc_rescan(struct work_struct *work) container_of(work, struct mmc_host, detect.work); int i; + if (host->trigger_card_event && host->ops->card_event) { + host->ops->card_event(host); + host->trigger_card_event = 0; + } + if (host->rescan_disable) return; diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 46596b71..fc648ae 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -29,9 +29,7 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) /* Schedule a card detection after a debounce timeout */ struct mmc_host *host = dev_id; - if (host->ops->card_event) - host->ops->card_event(host); - + host->trigger_card_event = 1; mmc_detect_change(host, msecs_to_jiffies(200)); return IRQ_HANDLED; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 99f5709..0b6bddf 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -322,6 +322,8 @@ struct mmc_host { int rescan_disable; /* disable card detection */ int rescan_entered; /* used with nonremovable devices */ + int trigger_card_event; /* card_event necessary */ + struct mmc_card *card; /* device attached to this host */ wait_queue_head_t wq;