From patchwork Fri Feb 28 11:49:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 25527 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6A15220543 for ; Fri, 28 Feb 2014 11:49:07 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i11sf13885599oag.8 for ; Fri, 28 Feb 2014 03:49:06 -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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=/eT3qusBKxy8qJizDoC1BuNhlnYux/67wOfmlkIRODQ=; b=e9Bx2RFOS5WGZma4G3R/0g4iD/uHDLrzWdCr4qYypz19/Vy5RCyVjGlXXuL6/Nfuq4 DYuvBu7gPJ95fyAMYn1m8/fzx2X29Tl8426mNL0U/IrQwq5arb57vT8eDOZaWjG8esse zjVniIsWkQcsXhH99H5fTXCFasNpNrSn4Mtw6jU0ep+iqbLSVkP4DJ48FsASvF4N5DFE 24bqEKTXgDD1BuLYWH9uW+SYCM2WI1XZUlj0/EI0BoZRHw0yDeIz4oD8qP6KGnv0voa5 aiOO1nyPdNY79CjU6QkYNw5QjCHqU8Bz41uNafDmoFsL/Op/GETmmo0tyy+e7DFsQ7wS 1tMQ== X-Gm-Message-State: ALoCoQl2wwBZ3gOtgOhlv8yRLK8fFM8u1Z/2Er9s8aUPNCy6CmYhYuSfC0aH0WHei9xZm834nwHf X-Received: by 10.50.8.3 with SMTP id n3mr3724450iga.0.1393588146926; Fri, 28 Feb 2014 03:49:06 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.86.51 with SMTP id o48ls1029090qgd.83.gmail; Fri, 28 Feb 2014 03:49:06 -0800 (PST) X-Received: by 10.220.133.80 with SMTP id e16mr2124498vct.13.1393588146818; Fri, 28 Feb 2014 03:49:06 -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 x3si1770927vcn.9.2014.02.28.03.49.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Feb 2014 03:49:06 -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 jy13so604514veb.37 for ; Fri, 28 Feb 2014 03:49:06 -0800 (PST) X-Received: by 10.52.30.167 with SMTP id t7mr5035547vdh.36.1393588146725; Fri, 28 Feb 2014 03:49:06 -0800 (PST) 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.130.193 with SMTP id u1csp47959vcs; Fri, 28 Feb 2014 03:49:06 -0800 (PST) X-Received: by 10.152.204.104 with SMTP id kx8mr1330438lac.60.1393588145706; Fri, 28 Feb 2014 03:49:05 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by mx.google.com with ESMTPS id pm4si3820799lbb.137.2014.02.28.03.49.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Feb 2014 03:49:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.49 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id mc6so2564037lab.8 for ; Fri, 28 Feb 2014 03:49:05 -0800 (PST) X-Received: by 10.152.190.135 with SMTP id gq7mr3017557lac.28.1393588144661; Fri, 28 Feb 2014 03:49:04 -0800 (PST) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id k1sm3608709lbc.5.2014.02.28.03.49.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Feb 2014 03:49:03 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: linux-kernel@vger.kernel.org, Ulf Hansson , Aaron Lu , NeilBrown , "Rafael J. Wysocki" Subject: [RFC PATCH] mmc: core: Invoke sdio func driver's PM callbacks from the sdio bus Date: Fri, 28 Feb 2014 12:49:00 +0100 Message-Id: <1393588140-20605-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.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 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: , The sdio func device is added to the driver model after the card device. This means the sdio func device will be suspend before the card device and thus resumed after. The consequence are the mmc core don't explicity need to protect itself from receiving sdio requests in suspended state. Instead that can be handled from the sdio bus, which is thus invokes the PM callbacks instead of old dummy function. In the case were the sdio func driver don't implement the PM callbacks the mmc core will in the early phase of system suspend, remove the card from the driver model and thus power off it. Cc: Aaron Lu Cc: NeilBrown Cc: Rafael J. Wysocki Signed-off-by: Ulf Hansson Tested-by: xiaoming wang Tested-by: Chuanxiao Dong --- Note, this patch has only been compile tested. Would appreciate if some with SDIO and a sdio func driver could help out to test this. Especially the libertas driver would be nice. --- drivers/mmc/core/sdio.c | 45 ++++--------------------------------------- drivers/mmc/core/sdio_bus.c | 14 +------------- 2 files changed, 5 insertions(+), 54 deletions(-) diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 4d721c6..9933e42 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -943,40 +943,21 @@ static int mmc_sdio_pre_suspend(struct mmc_host *host) */ static int mmc_sdio_suspend(struct mmc_host *host) { - int i, err = 0; - - for (i = 0; i < host->card->sdio_funcs; i++) { - struct sdio_func *func = host->card->sdio_func[i]; - if (func && sdio_func_present(func) && func->dev.driver) { - const struct dev_pm_ops *pmops = func->dev.driver->pm; - err = pmops->suspend(&func->dev); - if (err) - break; - } - } - while (err && --i >= 0) { - struct sdio_func *func = host->card->sdio_func[i]; - if (func && sdio_func_present(func) && func->dev.driver) { - const struct dev_pm_ops *pmops = func->dev.driver->pm; - pmops->resume(&func->dev); - } - } - - if (!err && mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) { + if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) { mmc_claim_host(host); sdio_disable_wide(host->card); mmc_release_host(host); } - if (!err && !mmc_card_keep_power(host)) + if (!mmc_card_keep_power(host)) mmc_power_off(host); - return err; + return 0; } static int mmc_sdio_resume(struct mmc_host *host) { - int i, err = 0; + int err = 0; BUG_ON(!host); BUG_ON(!host->card); @@ -1019,24 +1000,6 @@ static int mmc_sdio_resume(struct mmc_host *host) wake_up_process(host->sdio_irq_thread); mmc_release_host(host); - /* - * If the card looked to be the same as before suspending, then - * we proceed to resume all card functions. If one of them returns - * an error then we simply return that error to the core and the - * card will be redetected as new. It is the responsibility of - * the function driver to perform further tests with the extra - * knowledge it has of the card to confirm the card is indeed the - * same as before suspending (same MAC address for network cards, - * etc.) and return an error otherwise. - */ - for (i = 0; !err && i < host->card->sdio_funcs; i++) { - struct sdio_func *func = host->card->sdio_func[i]; - if (func && sdio_func_present(func) && func->dev.driver) { - const struct dev_pm_ops *pmops = func->dev.driver->pm; - err = pmops->resume(&func->dev); - } - } - host->pm_flags &= ~MMC_PM_KEEP_POWER; return err; } diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index 92d1ba8..4fa8fef9 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c @@ -197,20 +197,8 @@ static int sdio_bus_remove(struct device *dev) #ifdef CONFIG_PM -#ifdef CONFIG_PM_SLEEP -static int pm_no_operation(struct device *dev) -{ - /* - * Prevent the PM core from calling SDIO device drivers' suspend - * callback routines, which it is not supposed to do, by using this - * empty function as the bus type suspend callaback for SDIO. - */ - return 0; -} -#endif - static const struct dev_pm_ops sdio_bus_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_no_operation, pm_no_operation) + SET_SYSTEM_SLEEP_PM_OPS(pm_generic_suspend, pm_generic_resume) SET_RUNTIME_PM_OPS( pm_generic_runtime_suspend, pm_generic_runtime_resume,