From patchwork Fri Apr 21 10:08:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 9692379 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 2773D60328 for ; Fri, 21 Apr 2017 10:14:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AD0B28111 for ; Fri, 21 Apr 2017 10:14:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FAC428614; Fri, 21 Apr 2017 10:14:03 +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=ham 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 BB1A328111 for ; Fri, 21 Apr 2017 10:14:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1037819AbdDUKOA (ORCPT ); Fri, 21 Apr 2017 06:14:00 -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 S1037763AbdDUKN6 (ORCPT ); Fri, 21 Apr 2017 06:13:58 -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:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,229,1488873600"; d="scan'208";a="848353384" Received: from ahunter-desktop.fi.intel.com ([10.237.72.168]) by FMSMGA003.fm.intel.com with ESMTP; 21 Apr 2017 03:13:56 -0700 From: Adrian Hunter To: Ulf Hansson Cc: linux-mmc , linux-pm , linux-acpi , "Rafael J. Wysocki" Subject: [PATCH RFC 4/4] mmc: sdhci-pci: Set MMC_CAP2_NO_SDIO_RESET if child has wake from S4 (hibernate) Date: Fri, 21 Apr 2017 13:08:08 +0300 Message-Id: <1492769288-7474-5-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 SDIO reset interferes with a SDIO function driver's restore from hibernation. Set MMC_CAP2_NO_SDIO_RESET if a child node has _S4W method which indicates a capability to wake from S4 (hibernate). Signed-off-by: Adrian Hunter --- drivers/mmc/host/sdhci-pci-core.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c index 57d6f50b73dc..cc9fc7d54570 100644 --- a/drivers/mmc/host/sdhci-pci-core.c +++ b/drivers/mmc/host/sdhci-pci-core.c @@ -597,11 +597,42 @@ static int ni_set_max_freq(struct sdhci_pci_slot *slot) return 0; } + +static bool __sdhci_pci_child_has_s4w(struct acpi_device *child) +{ + acpi_handle handle = child->handle; + unsigned long long ret; + + return ACPI_SUCCESS(acpi_evaluate_integer(handle, "_S4W", NULL, &ret)); +} + +static bool sdhci_pci_child_has_s4w(struct sdhci_pci_slot *slot) +{ + struct acpi_device *adev = ACPI_COMPANION(&slot->chip->pdev->dev); + struct acpi_device *child; + bool child_has_s4w = false; + + if (!adev) + return false; + + list_for_each_entry(child, &adev->children, node) + if (child->status.present && child->status.enabled) { + if (__sdhci_pci_child_has_s4w(child)) + child_has_s4w = true; + } + + return child_has_s4w; +} #else static inline int ni_set_max_freq(struct sdhci_pci_slot *slot) { return 0; } + +static bool sdhci_pci_child_has_s4w(struct sdhci_pci_slot *slot) +{ + return false; +} #endif static int ni_byt_sdio_probe_slot(struct sdhci_pci_slot *slot) @@ -1960,6 +1991,9 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot( host->ioaddr = pcim_iomap_table(pdev)[bar]; + if (sdhci_pci_child_has_s4w(slot)) + host->mmc->caps2 |= MMC_CAP2_NO_SDIO_RESET; + if (chip->fixes && chip->fixes->probe_slot) { ret = chip->fixes->probe_slot(slot); if (ret)