Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp492228ybt; Fri, 26 Jun 2020 04:37:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwExsgEeBfPse4LLVAjOmsZBhJJcyQpmZkWFlzU51BpsngiT+tKEdR0PvJPiOdfxG0cvrzM X-Received: by 2002:aa7:cd52:: with SMTP id v18mr2727269edw.196.1593171453966; Fri, 26 Jun 2020 04:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593171453; cv=none; d=google.com; s=arc-20160816; b=nMhPyw4+OVYAdJ3Wac6LMGy0X1h7Z1IS2q2bOE6rSW17cUjX8wrYKfbmku5Aq99Ed+ e8kVzHHOARO2RyMFM9RLzaXxoBdUqTdqw4aCRkUe9IncHbmKIp+TknwVnqUGrVb3JySo v6zkyP7dLbisZtFYf6ZHy63zdIprXWA3uytdQtb4jaPKPAoK9flRVawfBgyVAZ5F7+3W FDQRicuf2qny9WlUyJLHBM+ew/s5wBn7LHgkC95PkK1VOJZB6wkFQbQnSpNsX++/XN7f pcK2Jzm5nO3KQuoCyMeki2S7JScxRM6gVJ2uLxswidr0n9fY/QbCFzPs+EX0hnUUGh+V opEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=vmwTtSgx1sCfT36+g9TzsoXake7NTyBmJYc2fA5P8fY=; b=BBP4GOFGwnwib3Z38mLXOk2mQxed/nbPqOqSgBojvfUN10RRPbTjSmXx2vkY5L38Qm J0jn6x3pFJkGvLK/ghzH9ZiccZAzvNak5lq9KqCmN+/l1QVv2z9dCG4vJ4v55f3QgCD7 4gf+Z4KxOFjtkaH6wbAzMJ4wKz21lnW5wzf7olnqqoXNRupdSt76cYvMZtzPG0rdYH25 vKyD4+tNIkqyLHCj6G3sD+e/v+k/bstamBZ861sqdBCqemlf5c2iQyNQ4a4HnW0StSk3 zdouS9QY1tG8iiT7B8hNclZCrgmjsh+MPQ4ykDXbUDI+XYWaKnoUmHhLQ+/cXUWgqWom yeZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m12si8847183ejr.298.2020.06.26.04.37.11; Fri, 26 Jun 2020 04:37:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726657AbgFZJcf (ORCPT + 99 others); Fri, 26 Jun 2020 05:32:35 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:17253 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726568AbgFZJcb (ORCPT ); Fri, 26 Jun 2020 05:32:31 -0400 X-IronPort-AV: E=Sophos;i="5.75,283,1589209200"; d="scan'208";a="50446472" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 26 Jun 2020 18:32:28 +0900 Received: from localhost.localdomain (unknown [10.166.252.89]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 7EC6E420331D; Fri, 26 Jun 2020 18:32:28 +0900 (JST) From: Yoshihiro Shimoda To: ulf.hansson@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH/RFC v4 3/4] mmc: core: Call mmc_poweroff_nofity() if regulators are disabled Date: Fri, 26 Jun 2020 18:32:21 +0900 Message-Id: <1593163942-5087-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593163942-5087-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1593163942-5087-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If regulator_is_enabled() of both vmmc and vqmmc returns false, _mmc_suspend() should call mmc_poweroff_nofity() instead of mmc_sleep(). Note that this is possible to happen when the regulator-fixed driver turns the vmmc and vqmmc off by firmware like PSCI while the system is suspended. Signed-off-by: Yoshihiro Shimoda --- drivers/mmc/core/mmc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 4203303..75df5f8 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -2022,6 +2023,18 @@ static void mmc_detect(struct mmc_host *host) } } +static bool mmc_regulators_are_disabled(struct mmc_host *host) +{ + if (IS_ERR(host->supply.vmmc) || + regulator_is_enabled(host->supply.vmmc)) + return false; + if (IS_ERR(host->supply.vqmmc) || + regulator_is_enabled(host->supply.vqmmc)) + return false; + + return true; +} + static int _mmc_suspend(struct mmc_host *host, bool is_suspend) { int err = 0; @@ -2038,7 +2051,8 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) goto out; if (mmc_can_poweroff_notify(host->card) && - ((host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) || !is_suspend)) + ((host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) || !is_suspend || + mmc_regulators_are_disabled(host))) err = mmc_poweroff_notify(host->card, notify_type); else if (mmc_can_sleep(host->card)) err = mmc_sleep(host); -- 2.7.4