Received: by 10.192.165.148 with SMTP id m20csp3528082imm; Mon, 23 Apr 2018 08:03:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx48/vDqJEE4jtb+9NMmFuVsBPjy3C3hCA2npE50zP/5sKU7hN7VlshQLQ+o2C7a1yEUsT9lY X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr20908214plu.22.1524495805617; Mon, 23 Apr 2018 08:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524495805; cv=none; d=google.com; s=arc-20160816; b=ociT5perVYRLTwI9LQU1L7vtaufrL2DvW1UahhdXlxtgM0AEHe+CWs6CE8ZAr0Pm0q SmdPm0hx02jXqMgvHhO27JpnyYh7K0EzogEeqZ4WRh+DT85SXe8YBaEWRLHqBZvFcz0d bHOgLJPO7Zuef/ogimVE2dxfsIKMC5Kxmvi2eKSiR/N/YtG9wwhpIUE/gtr7RdXNHuyJ l9JT9JNbHgqa9fuJDJpo0h2N6hSWGw6cb9SHlQ6dOwxJWAFwJ3Ch15Q682SLpw0WnNMJ JZo6S//UUTt27Cf0rcbExqqWqX8BYjbgd5wzRjoDmco76BmEYhO0RzwuneNFOWyrLcu9 buWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=4dGvxJrXCVDHjTpds5DZWbllwOMi1iLQfxcJVruTjZI=; b=LG7Vbp5/K0fpVRW6IWbschqg15oVjASy5y2gjEZNaCqLnUrOr1iqjS4q8hA8NEMUc+ afm6sMrnR4R/d5mcav0usUp3Znw2ugQqOzZ24xGHhMm61O7hvpW1wsnk3/hiT32yYLSo ffHEtkUjoh+WZID9CMSSjJiiDDrHc1TftfoFRr+WON07iiCyY/R4jkNcAvwXMNoOLbc7 hnlB0ZMa1jgaWiXooMsAD2OQWlnh/73AD1pJmJw9JuRAXI9uJZsbvnNlzf9EXyswlajL npaczT8C2rw22cyLUYkGgmeRY6rh1NT5Uywiqd/dTxBqWgsY+LbTqkhmFgwgS/6SF1oe Qd8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Du9bdCtf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si4781831pgs.24.2018.04.23.08.03.04; Mon, 23 Apr 2018 08:03:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Du9bdCtf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755616AbeDWPBV (ORCPT + 99 others); Mon, 23 Apr 2018 11:01:21 -0400 Received: from mail-io0-f178.google.com ([209.85.223.178]:44843 "EHLO mail-io0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755580AbeDWPBQ (ORCPT ); Mon, 23 Apr 2018 11:01:16 -0400 Received: by mail-io0-f178.google.com with SMTP id d11-v6so10940171iof.11 for ; Mon, 23 Apr 2018 08:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=4dGvxJrXCVDHjTpds5DZWbllwOMi1iLQfxcJVruTjZI=; b=Du9bdCtftzLrA6SmLy0TEbOjGwdlvpdwrtYAaMQZnPDYSaWRPpjTgv0ypByCb8YRLJ vToQ2qn9Mq/x897xNxr08y8wGN315tEHMam17hbmvRBan0SLcJB78qRcQI46PrZluON2 BaK80jCQH8zu4a6223a9AEKTUd2eijvFW99ZE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=4dGvxJrXCVDHjTpds5DZWbllwOMi1iLQfxcJVruTjZI=; b=unrsAtRu4/WoDUtLT7XQV4zSEEq4wVWmHvpVjPWjJmqyDS1/dAREE2NiYGMD6eJV8l m/QLdZvW3/ldLwd1qmtqvoV7TO/SeZ5uTeTXqLNTEyebYgY1LWoh40xxdbAGvDY4gAvS +rQpGN2dZ3YU42nMt+3ie690Q6cODWc+juWudNkT0oTf5ZWFFzZPb/Mw1vAMdFGJcrd/ mBxPprgCL/pAjxil2YsVQs3oco9dGSbsgldIfjbWLPJrI1rDFxbf+1qE/xEmeU1WJC6M wwFVWSp/w2ebHyHANRhAURElV9PUXynTy2Ckjd7tCC+AaYfi9TOYAb27wi07RHpPf+Q2 790A== X-Gm-Message-State: ALQs6tCUUEg/AY/m1gmE0sJ/37zjx+OlYDLpHUS/MG+Rby2+KSeRJFm5 6UXSPIuDhu9Yqfx3nZwas4XlNNTD0M2B5VadC1+0QA== X-Received: by 2002:a6b:c9d8:: with SMTP id z207-v6mr22634603iof.266.1524495676045; Mon, 23 Apr 2018 08:01:16 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:734a:0:0:0:0:0 with HTTP; Mon, 23 Apr 2018 08:01:14 -0700 (PDT) In-Reply-To: <20180423161113.463d4f0e@jawa> References: <20180422213126.32756-1-lukma@denx.de> <20180423113619.6f557d8e@jawa> <20180423161113.463d4f0e@jawa> From: Ulf Hansson Date: Mon, 23 Apr 2018 17:01:14 +0200 Message-ID: Subject: Re: [PATCH] mmc: disable card sleep via device-tree To: Lukasz Majewski Cc: Linus Walleij , Linux Kernel Mailing List , Rob Herring , Mark Rutland , Adrian Hunter , Fabio Estevam , Wolfram Sang , Chanho Min , devicetree@vger.kernel.org, "linux-mmc@vger.kernel.org" , Stanislav Meduna Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23 April 2018 at 16:11, Lukasz Majewski wrote: > Hi Ulf, > >> On 23 April 2018 at 11:36, Lukasz Majewski wrote: >> > Hi Ulf, >> > >> >> On 22 April 2018 at 23:31, Lukasz Majewski wrote: >> >> > From: Stanislav Meduna >> >> > >> >> > On a TQMa53 module the mmc_sleep leaves the eMMC card in a state >> >> > that the imx53 rom boot code is unable to probe, resulting in >> >> > reboot hanging. Add a device tree property to disable sleeping >> >> > on suspend. >> >> > >> >> > For TQMa53 modules the exact commit to cause hang after reboot >> >> > (v3.10 -> v3.11): >> >> > commit 486fdbbc1483 ("mmc: core: Add shutdown callback for (e)MMC >> >> > bus_ops") >> >> > >> >> > [The exact discussion can be found here: >> >> > https://patchwork.kernel.org/patch/8881401/ >> >> > "i.MX53 restart via watchdog does not work" >> >> > >> >> > Signed-off-by: Stanislav Meduna >> >> > Signed-off-by: Lukasz Majewski >> >> > --- >> >> > Documentation/devicetree/bindings/mmc/mmc-card.txt | 4 ++++ >> >> > drivers/mmc/core/mmc.c | 7 +++++-- >> >> > include/linux/mmc/card.h | 2 +- >> >> > 3 files changed, 10 insertions(+), 3 deletions(-) >> >> > >> >> > diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.txt >> >> > b/Documentation/devicetree/bindings/mmc/mmc-card.txt index >> >> > 8d2d71758907..c3ee151edd7c 100644 --- >> >> > a/Documentation/devicetree/bindings/mmc/mmc-card.txt +++ >> >> > b/Documentation/devicetree/bindings/mmc/mmc-card.txt @@ -12,6 >> >> > +12,9 @@ Required properties: Optional properties: >> >> > -broken-hpi : Use this to indicate that the mmc-card has a >> >> > broken hpi implementation, and that hpi should not be used >> >> > +-no-sleep-on-suspend : Do not put the card to sleep when >> >> > suspending. >> >> > + There are boards with bootloaders that are unable >> >> > + to probe such card when rebooting. >> >> > >> >> > Example: >> >> > >> >> > @@ -26,5 +29,6 @@ Example: >> >> > reg = <0>; >> >> > compatible = "mmc-card"; >> >> > broken-hpi; >> >> > + no-sleep-on-suspend; >> >> > }; >> >> > }; >> >> > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c >> >> > index 208a762b87ef..a3b74b5c8893 100644 >> >> > --- a/drivers/mmc/core/mmc.c >> >> > +++ b/drivers/mmc/core/mmc.c >> >> > @@ -381,8 +381,11 @@ static int mmc_decode_ext_csd(struct >> >> > mmc_card *card, u8 *ext_csd) } >> >> > >> >> > np = mmc_of_find_child_device(card->host, 0); >> >> > - if (np && of_device_is_compatible(np, "mmc-card")) >> >> > + if (np && of_device_is_compatible(np, "mmc-card")) { >> >> > broken_hpi = of_property_read_bool(np, >> >> > "broken-hpi"); >> >> > + card->no_sleep_on_suspend = >> >> > + of_property_read_bool(np, >> >> > "no-sleep-on-suspend"); >> >> > + } >> >> > of_node_put(np); >> >> > >> >> > /* >> >> > @@ -1990,7 +1993,7 @@ static int _mmc_suspend(struct mmc_host >> >> > *host, bool is_suspend) if (mmc_can_poweroff_notify(host->card) >> >> > && ((host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) >> >> > || !is_suspend)) err = mmc_poweroff_notify(host->card, >> >> > notify_type); >> >> > - else if (mmc_can_sleep(host->card)) >> >> > + else if (mmc_can_sleep(host->card) >> >> > && !host->card->no_sleep_on_suspend) >> >> >> >> No, this is wrong. >> >> >> >> This means that the mmc_power_off() a few lines below would start >> >> to violate the eMMC spec. >> >> That via powering off the card, without first >> >> sending the sleep or power-off-notify command. >> >> You are probably just lucky, as your particular eMMC card still >> >> copes with this in-correct sequence (I know there are these kind >> >> of cards). >> >> >> >> Well, what is also interesting in this regards, is what is >> >> happening during mmc_power_off(). >> > >> > The mmc_power_off() -> mmc_pwrseq_power_off() -> here the *pwrseq is >> > null, so we do nothing with the power. >> > >> > In mmc_power_off() function we call mmc_set_initial_state(host); >> > >> >> Does your host driver cut power to VMMC and/or >> >> VQMMC? >> > >> > The esdhci3 controller uses 'vmm-supply' which is a >> > 'regulator-fixed' with 'regulator-always-on' attribute. >> >> Assume you mean vmmc-supply. >> >> Anyway, it seems a bit weird to have this regulator as fixed and >> always on. Of course it's possible, but it's more common to have vqmmc >> fixed and always on. Maybe double check the schematics. >> >> > >> > It seems like the eMMC is always powered with 3.3V. >> >> What about vqmmc then? > > It seems like the vqmmc is not added/used in dts (imx53.dtsi). Only the > vmmc-supply is used. My point is, that perhaps DTS is wrong or too simplified. Perhaps vmmc can be powered off/on? > >> >> > >> > Considering the above it seems like the card is still powered - the >> > HW design also supports some backup powering (so the voltage from >> > the board is not took immediately). >> >> I think you need to verify that the CMD5 (sleep) is actually sent and >> successfully completed. >> >> In regards to that, do your host support MMC_CAP_WAIT_WHILE_BUSY? > > No. This flag is not supported (set) on this host. Okay. One thing to remove from possible root causes. > >> If >> not, there is a delay (specific to the card) after the CMD5. > > Yes, the delay is used (mmc.c Line 1890). > The delay is 7ms (as read from card->ext_csd.sa_timeout). > > Increasing it by 10 (or 100) ms doesn't solve the problem. Okay. To really be sure, I would also try 1000ms. > >> >> So the support in your host driver for MMC_CAP_WAIT_WHILE_BUSY could >> be broken, or the delay may be too short. Perhaps forcing to use the >> delay and use a delay that for sure should work is worth to test. >> >> > >> > >> > To be even more strange the suspend to mem works without any issues >> > (without this patch). >> > With "reboot -f" it seems like we hang in imx53 BootROM (as I can >> > read it from my JTAG debugger). >> >> So clearly there is a difference during reboot. >> >> A wild guess... Probably vmmc supply is turned on/off in this path, >> while perhaps the CMD5 support has failed when the kernel issued >> it... > > This needs to be checked. > > It may be also possible that the BootROM expects that the eMMC would > not be in SLEEP state (after CMD5 issuing). Well, in principle that shouldn't matter. CMD0 is fine to use to wakeup the card from sleep state and that can be followed by a regular initialization sequence. This is the way the mmc core, during system resume does it. Another possible option is that the power to vqmmc becomes power cycled during reboot, while power to vmmc isn't. Hope my ideas to narrow down the problem are helping and not adding confusion. :-) Kind regards Uffe