From patchwork Fri Sep 20 09:48:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 20473 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5977325DFC for ; Fri, 20 Sep 2013 09:48:53 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id ht10sf139953vcb.1 for ; Fri, 20 Sep 2013 02:48:52 -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:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=BTRQWjZX1nQcB04BWfatzadzRwwpdQvBjMvr9y7jPk0=; b=TtvyqI8DprQkRr5AkDF8TYIsF67KSGrAo2/30mb+0KhQvQ/IcnM+0WaMBULyorZRaO uRRwsHqMwai3OYjcCpcVW3/lJx3c3gEk6aNFb4VeWkrvuuzLt/1hqH2Yh9XIwxemTq34 StKg1Ac922CtI2LL9LjzX1hiBJcmvi3x4wTfwBoH0ZB2dpUyocS/BtnGZGHDVhcItccW NJdqVlmuFHHFHDABb0Y9OeDvadMdz45fC/8DDwfneS7feTUvOytkv3ofh+Do353dPOHo mnAfzst/AXebnG/hABSispdHDevvx83WjYCTlaZBY7178m2kOWnKjf70dQRIoCK8y6ib +Vkg== X-Gm-Message-State: ALoCoQlvzwySsdfXWWf98UD8SWmCqw3E1cJaDUrNLtPHlSYRVVxj6gfx8WvE3Evonu/LkWJ4ek2w X-Received: by 10.236.101.103 with SMTP id a67mr2181469yhg.25.1379670532445; Fri, 20 Sep 2013 02:48:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.5.9 with SMTP id o9ls177414qeo.49.gmail; Fri, 20 Sep 2013 02:48:52 -0700 (PDT) X-Received: by 10.220.249.67 with SMTP id mj3mr40230vcb.23.1379670532311; Fri, 20 Sep 2013 02:48:52 -0700 (PDT) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by mx.google.com with ESMTPS id s15si2881845vcn.29.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Sep 2013 02:48:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.45 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.45; Received: by mail-vb0-f45.google.com with SMTP id e15so117215vbg.32 for ; Fri, 20 Sep 2013 02:48:52 -0700 (PDT) X-Received: by 10.58.187.47 with SMTP id fp15mr401380vec.22.1379670532224; Fri, 20 Sep 2013 02:48:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp7522vcz; Fri, 20 Sep 2013 02:48:51 -0700 (PDT) X-Received: by 10.112.42.68 with SMTP id m4mr5809347lbl.4.1379670530799; Fri, 20 Sep 2013 02:48:50 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176]) by mx.google.com with ESMTPS id g2si5775025laa.2.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Sep 2013 02:48:50 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.217.176 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id y6so382137lbh.7 for ; Fri, 20 Sep 2013 02:48:50 -0700 (PDT) X-Received: by 10.152.3.201 with SMTP id e9mr5534281lae.24.1379670529926; Fri, 20 Sep 2013 02:48:49 -0700 (PDT) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id u20sm5736956lbh.7.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Sep 2013 02:48:49 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Ulf Hansson , San Mehat , Colin Cross , John Stultz , Zoran Markovic Subject: [RFC/PATCH] mmc: core: Signal wakeup event at card insert/removal Date: Fri, 20 Sep 2013 11:48:43 +0200 Message-Id: <1379670523-13229-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.45 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We want to give user space provision to fully consume a card insert/remove event, when the event was caused by a wakeup irq. By signaling the wakeup event for a time of 5 s for devices configured as wakeup capable, we likely will be prevent a sleep long enough to let user space consume the event. To enable this feature, host drivers must thus configure their devices as wakeup capable. This is a reworked implementation of the old wakelocks for the mmc subsystem, originally authored by Colin Cross and San Mehat for the Android kernel. Zoran Markovic shall also be given cred for recently re-trying to upstream this feature. Cc: San Mehat Cc: Colin Cross Cc: John Stultz Cc: Zoran Markovic Signed-off-by: Ulf Hansson --- This patch has just been compile tested, since I at very moment did not have a good board to test it on. I am working on that. Any help in testing this patch is thus greatly appreciated. While testing also don't forget to enable the host device as wakeup capable. Use "device_init_wakeup" from the host probe function. --- drivers/mmc/core/core.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index bf18b6b..3e8229e 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1723,6 +1724,28 @@ void mmc_detach_bus(struct mmc_host *host) mmc_bus_put(host); } +static void _mmc_detect_change(struct mmc_host *host, unsigned long delay, + bool cd_irq) +{ +#ifdef CONFIG_MMC_DEBUG + unsigned long flags; + spin_lock_irqsave(&host->lock, flags); + WARN_ON(host->removed); + spin_unlock_irqrestore(&host->lock, flags); +#endif + + /* + * If the device is configured as wakeup, we prevent a new sleep for + * 5 s to give provision for user space to consume the event. + */ + if (cd_irq && !(host->caps & MMC_CAP_NEEDS_POLL) && + device_can_wakeup(mmc_dev(host))) + pm_wakeup_event(mmc_dev(host), 5000); + + host->detect_change = 1; + mmc_schedule_delayed_work(&host->detect, delay); +} + /** * mmc_detect_change - process change of state on a MMC socket * @host: host which changed state. @@ -1735,16 +1758,8 @@ void mmc_detach_bus(struct mmc_host *host) */ void mmc_detect_change(struct mmc_host *host, unsigned long delay) { -#ifdef CONFIG_MMC_DEBUG - unsigned long flags; - spin_lock_irqsave(&host->lock, flags); - WARN_ON(host->removed); - spin_unlock_irqrestore(&host->lock, flags); -#endif - host->detect_change = 1; - mmc_schedule_delayed_work(&host->detect, delay); + _mmc_detect_change(host, delay, true); } - EXPORT_SYMBOL(mmc_detect_change); void mmc_init_erase(struct mmc_card *card) @@ -2423,7 +2438,7 @@ int mmc_detect_card_removed(struct mmc_host *host) * rescan handle the card removal. */ cancel_delayed_work(&host->detect); - mmc_detect_change(host, 0); + _mmc_detect_change(host, 0, false); } } @@ -2505,7 +2520,7 @@ void mmc_start_host(struct mmc_host *host) mmc_power_off(host); else mmc_power_up(host); - mmc_detect_change(host, 0); + _mmc_detect_change(host, 0, false); } void mmc_stop_host(struct mmc_host *host) @@ -2724,7 +2739,7 @@ int mmc_pm_notify(struct notifier_block *notify_block, spin_lock_irqsave(&host->lock, flags); host->rescan_disable = 0; spin_unlock_irqrestore(&host->lock, flags); - mmc_detect_change(host, 0); + _mmc_detect_change(host, 0, false); }