From patchwork Tue Dec 12 10:49:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 10106621 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 AE850602B3 for ; Tue, 12 Dec 2017 10:49:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B96B229B6E for ; Tue, 12 Dec 2017 10:49:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE44D29B7D; Tue, 12 Dec 2017 10:49:12 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 1C20629B6E for ; Tue, 12 Dec 2017 10:49:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751503AbdLLKtK (ORCPT ); Tue, 12 Dec 2017 05:49:10 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:43986 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751643AbdLLKtH (ORCPT ); Tue, 12 Dec 2017 05:49:07 -0500 Received: by mail-wm0-f67.google.com with SMTP id n138so19790011wmg.2 for ; Tue, 12 Dec 2017 02:49:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=jIXBtKHevUpQLHu2Q9vEsJmHyUeFaumWNgDpSKPD3nw=; b=l16P7dwgue8gNrYYqwWeTuO/tZgPJtnW4KCcA9i5dGZ96WgEUi8aEN0rcMxcVAqBaj PyZwW/vXepBg0PurRrYHitXnIcUVXOjT+Svk2mp8n+qem6ftl6OtvLyqvLBK1zAGcFI6 0rblfWM86vUR58KixIKLZh85B14Z/akFivoSjHFLDnRpSpbPJgGIbZK9L4jmTac1uckY JqQP8wIaLy4BI1/25SBUoCOFpU9jlnCIVoAqmwd5znaXZjzkLdRqF5CTSVH9NMsGy5qw tsIyjqulAJeEQDSEgp+PZ0D+0TOcpUn6x0LxfMRPQJprgMNaioyVsaSCoQmakZ9Qen0x R+4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jIXBtKHevUpQLHu2Q9vEsJmHyUeFaumWNgDpSKPD3nw=; b=GgUOxpoJvCB9/1vBbiYonaAQ5ciZhGQ3k5t3FB17Cl1wE3yaoM43uz1Yv/4XgDN3U0 kAQmG1mMSX0GS93qa1Pv2gxs/TwZhyJk2lp+Fps4UlxEoKNAF8KLx4iJJ5XbX28H/E/S 5haSUQqtWGLZbOQcnHNXyCwlcQfFg6+UZtfIgO7ybAyyXMrdshGonLHgJU/EbDeYkFxs T9F+RqGJov1rFQKcCpm1yO4/eGxdeM8WDFOv9qJX2yklOlhf0FJUlfQGFpO8wk4L9tx6 AiFcG0rZNQVpbcx93Ii6tFysb663+x5pCyL1Bqx9RB/bhtizVOyPGvSb3AkVOm2Z5zle /HRg== X-Gm-Message-State: AKGB3mJtiuv1scBFHILgNJpP5Am/p8ARI7kQEks6EPEdzOb3KtBqOVrC UdekI2+EQ8lbxHUcxNkl4Ny1cQ== X-Google-Smtp-Source: ACJfBov2rb2Cyg7+BTDdhcV77n1R1Ol26zksgCfy01poWcxX8Mg7iIa9CNy+/2gPhyBCpnAFd68WFw== X-Received: by 10.28.185.68 with SMTP id j65mr1258664wmf.135.1513075746265; Tue, 12 Dec 2017 02:49:06 -0800 (PST) Received: from limbo.default ([95.144.108.70]) by smtp.gmail.com with ESMTPSA id c12sm12074805wmi.43.2017.12.12.02.49.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 02:49:05 -0800 (PST) From: Daniel Drake To: ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux@endlessm.com, matthew.leeds@endlessm.com Subject: [PATCH] mmc: avoid removing non-removable hosts during suspend Date: Tue, 12 Dec 2017 10:49:02 +0000 Message-Id: <20171212104902.11793-1-drake@endlessm.com> X-Mailer: git-send-email 2.14.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Weibu F3C MiniPC has an onboard AP6255 module, presenting two SDIO functions on a single MMC host (Bluetooth/btsdio and WiFi/brcmfmac), and the mmc layer correctly detects this as non-removable. After suspend/resume, the wifi and bluetooth interfaces disappear and do not get probed again. The conditions here are: 1. During suspend, we reach mmc_pm_notify() 2. mmc_pm_notify() calls mmc_sdio_pre_suspend() to see if we can suspend the SDIO host. However, mmc_sdio_pre_suspend() returns -ENOSYS because btsdio_driver does not have a suspend method. 3. mmc_pm_notify() proceeds to remove the card 4. Upon resume, mmc_rescan() does nothing with this host, because of the rescan_entered check which aims to only scan a non-removable device a single time (i.e. during boot). Fix the loss of functionality by detecting that we are unable to suspend a non-removable host, so avoid the forced removal in that case. The comment above this function already indicates that this code was only intended for removable devices. Signed-off-by: Daniel Drake --- drivers/mmc/core/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) Replaces previous approach: [PATCH] mmc: allow rescan of non-removable hosts on resume diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 26431267a3e2..6f815a264285 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2763,6 +2763,14 @@ static int mmc_pm_notify(struct notifier_block *notify_block, if (!err) break; + if (!mmc_card_is_removable(host)) { + dev_warn(mmc_dev(host), + "pre_suspend failed for non-removable host: " + "%d\n", err); + /* Avoid removing non-removable hosts */ + break; + } + /* Calling bus_ops->remove() with a claimed host can deadlock */ host->bus_ops->remove(host); mmc_claim_host(host);