From patchwork Fri Apr 21 10:08:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 9692365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3414760328 for ; Fri, 21 Apr 2017 10:13:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27C1C28111 for ; Fri, 21 Apr 2017 10:13:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C7EF28614; Fri, 21 Apr 2017 10:13:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEBB828111 for ; Fri, 21 Apr 2017 10:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1037783AbdDUKNz (ORCPT ); Fri, 21 Apr 2017 06:13:55 -0400 Received: from mga02.intel.com ([134.134.136.20]:46651 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1037771AbdDUKNx (ORCPT ); Fri, 21 Apr 2017 06:13:53 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Apr 2017 03:13:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,229,1488873600"; d="scan'208";a="848353365" Received: from ahunter-desktop.fi.intel.com ([10.237.72.168]) by FMSMGA003.fm.intel.com with ESMTP; 21 Apr 2017 03:13:51 -0700 From: Adrian Hunter To: Ulf Hansson Cc: linux-mmc , linux-pm , linux-acpi , "Rafael J. Wysocki" Subject: [PATCH RFC 1/4] mmc: sdio: Keep card runtime resumed while adding function devices Date: Fri, 21 Apr 2017 13:08:05 +0300 Message-Id: <1492769288-7474-2-git-send-email-adrian.hunter@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1492769288-7474-1-git-send-email-adrian.hunter@intel.com> References: <1492769288-7474-1-git-send-email-adrian.hunter@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Drivers core will runtime suspend a device with no driver. That means the SDIO card will be runtime suspended as soon as it is added. It is then runtime resumed to add each function. That is entirely pointless, so add pm runtime get/put to keep the SDIO card runtime resumed until the function devices have been added. This also benefits the hibernation use-case whereby we want to avoid the SDIO reset that is done as part of runtime resume. In that case, the SDIO card state is preserved at boot time by avoiding loading any function drivers before restoring the hibernation image. Signed-off-by: Adrian Hunter --- drivers/mmc/core/sdio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index fae732c870a9..97bedde0610c 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -1110,6 +1110,8 @@ int mmc_attach_sdio(struct mmc_host *host) if (err) goto remove; + pm_runtime_get_noresume(&card->dev); + /* * Enable runtime PM for this card */ @@ -1129,7 +1131,7 @@ int mmc_attach_sdio(struct mmc_host *host) for (i = 0; i < funcs; i++, card->sdio_funcs++) { err = sdio_init_func(host->card, i + 1); if (err) - goto remove; + goto remove_get; /* * Enable Runtime PM for this func (if supported) @@ -1156,6 +1158,10 @@ int mmc_attach_sdio(struct mmc_host *host) } mmc_claim_host(host); + + if (host->caps & MMC_CAP_POWER_OFF_CARD) + pm_runtime_put(&card->dev); + return 0; @@ -1163,6 +1169,9 @@ int mmc_attach_sdio(struct mmc_host *host) /* Remove without lock if the device has been added. */ mmc_sdio_remove(host); mmc_claim_host(host); +remove_get: + if (host->caps & MMC_CAP_POWER_OFF_CARD) + pm_runtime_put(&card->dev); remove: /* And with lock if it hasn't been added. */ mmc_release_host(host);