Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp692294ybi; Tue, 16 Jul 2019 03:54:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqygTiKFZUucU2NxUGNxNPw3fk8hyGBMJ/D8FzcPeHpqqLTqCWVedwi5t03r3oiznNMFUgWQ X-Received: by 2002:a17:902:6a87:: with SMTP id n7mr33822031plk.336.1563274444000; Tue, 16 Jul 2019 03:54:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563274443; cv=none; d=google.com; s=arc-20160816; b=kIcBlJl9Zhpec1nre6eE2nU+HDaO+47p6513yakH381bBQVZ1UHHisekBnX85Q+YVM wTqlRuhmLyB6cUd9DkGO8vOB+ZHauV8N1iC0V8KHMopFYABH0px2ey4Upnla4iEFeYKq 3YsDTpwEM1IWZWmFOY2UGd6xJp3VPgoWWwTF21SsmnZNbHe/NCITiCm0S11Lrm2lpOqj 6bHdEjb6KM/2ckL67hZKszWRMxduw82hpDMvuxygjCWfA9BSdXktBnOSiwCaxn7dd1og k1USeEulDkWd1AsBwA0Xtg5grnbe9FMaLKpef6RQYsrONPK4P++Cevx6TlZOhuIElVjo bQlw== 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 :in-reply-to:references:mime-version:dkim-signature; bh=yV7fHha/1uJLdSPSLwZnz/qgIkyl6ozZw75QGiLZaR8=; b=Pc0efq/ez3UFGr4cnu+WQT2t2URwJPZwAazaTfuK/eLH/4YYcJceuHCzdNrA7sup8f Da0eS17bOnKEgQEyKmWKVxSH3nFFf+v3ThjNtepPqGpqWPS7d176EjkUnwna3OJafB7U y3OmboDeco0inmq+SRCL7UyqziKWn5sa37hlnbMdTgvnM3qH0SLZMgV1CXiRLXM0aqU9 wBgKolrFh+MiwOOjS5K5H6FjTAGmrMQfWAiDtK4+fMKTHWpDaI+LzX0q4VMvGxOCnv7O 9qyr6NkFQZ/fbBZa1huzjOc/kVNdoL8AE1POAmpGjH3Gz1bDfNLrdeUgZIHCDo/7we8p bP4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HywDJG1M; 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 n13si17654915plp.354.2019.07.16.03.53.47; Tue, 16 Jul 2019 03:54:03 -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=HywDJG1M; 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 S1733307AbfGPKwu (ORCPT + 99 others); Tue, 16 Jul 2019 06:52:50 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:34568 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733037AbfGPKwu (ORCPT ); Tue, 16 Jul 2019 06:52:50 -0400 Received: by mail-ot1-f66.google.com with SMTP id n5so20578789otk.1 for ; Tue, 16 Jul 2019 03:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yV7fHha/1uJLdSPSLwZnz/qgIkyl6ozZw75QGiLZaR8=; b=HywDJG1MdyScI+QJh7uYxU0Y/TqPUTLcWM3yrU9WLg2RGudW3/NGg6pnZaO+TVtzo9 crMGl5dF8alxyA7rakyiWn5L3uaVLis/vspDk5q4aLpPXdtzrGKZ8OE0nN6dPE+I1adb l7Lbl2YNi5PE66lm7ahBd7dK1Sqr02DkHPfE1G/SJgX37ey1bwcPdwi4zW9uKtGUu8M/ jsnatodL16JvUDo8Y9FPPg+xHf6CI/9cD6lHZWZvmHmvZe9CCzo16icPeNDSJypFT0o/ oUFUoFEXfBjitw3pO8Ji1ZXgFUNy3C0oweqiG6KYpaC5/SIgroINeXpQsFzLeYPCxlUr eHiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yV7fHha/1uJLdSPSLwZnz/qgIkyl6ozZw75QGiLZaR8=; b=I2JKVMOxqBeXtIhIjU8D1R2KDWS6kVvXlMEMZk9eNh8F1tLwxue3zpIaVyd3XhjMXx KkPK6xioAucKWvSltT/EDYkiAMCQbBAXedJdQule3aqjbp3bJSG32rT8jyh1oAtEAtOe WjM/zD1FEf+0Y0EMly4FDFH6GOzAS0/0810IyvQrgHfoy6EMFakJwiv0d205t9TmBvw0 ddmlnlzqowwH4B+6bXRZJV/JPvknguMOrjgZHC3IbcjPwL/OxFDSaegDysKff7cStISr QIVXN8BRuXsRGC89NHvalbyC50DC6sJpaC1Lem0VrmqARRoc1c+cGsKM07ZMkgsMAyVo tsrQ== X-Gm-Message-State: APjAAAUImuXQLgWW97UCXF+LJsxUihoGkzdE+WWCQyV8gn0eSBPLIa9B YLa2Wu54iOf0cOVD2FKt6oIAlIhRredPZtanHk8MHw== X-Received: by 2002:a05:6830:13c2:: with SMTP id e2mr24139721otq.123.1563274369381; Tue, 16 Jul 2019 03:52:49 -0700 (PDT) MIME-Version: 1.0 References: <7ab490e5b311f6cb057c4663d69ef7cbe3318dae.1563266066.git.baolin.wang@linaro.org> <07e348a0-6a80-e176-d18d-6a1e54313fa6@intel.com> In-Reply-To: <07e348a0-6a80-e176-d18d-6a1e54313fa6@intel.com> From: Baolin Wang Date: Tue, 16 Jul 2019 18:52:37 +0800 Message-ID: Subject: Re: [PATCH v3] mmc: host: sdhci-sprd: Fix the incorrect soft reset operation when runtime resuming To: Adrian Hunter Cc: Ulf Hansson , Chunyan Zhang , Orson Zhai , Vincent Guittot , linux-mmc , LKML 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 Tue, 16 Jul 2019 at 18:40, Adrian Hunter wrote: > > On 16/07/19 11:39 AM, Baolin Wang wrote: > > In sdhci_runtime_resume_host() function, we will always do software reset > > for all, which will cause Spreadtrum host controller work abnormally after > > resuming. > > > > Thus for Spreadtrum platform that do not power down the SD/eMMC card during > > runtime suspend, we should not do software reset for all. To fix this > > issue, adding a specific reset operation that add one condition to validate > > the MMC_CAP_AGGRESSIVE_PM to decide if we can do software reset for all or > > just reset command and data lines. > > > > Signed-off-by: Baolin Wang > > --- > > Changes from v2: > > - Simplify the sdhci_sprd_reset() by issuing sdhci_reset(). > > > > Changes from v1: > > - Add a specific reset operation instead of changing the core to avoid > > affecting other hardware. > > --- > > drivers/mmc/host/sdhci-sprd.c | 19 ++++++++++++++++++- > > 1 file changed, 18 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c > > index 603a5d9..bc9393c 100644 > > --- a/drivers/mmc/host/sdhci-sprd.c > > +++ b/drivers/mmc/host/sdhci-sprd.c > > @@ -373,6 +373,23 @@ static unsigned int sdhci_sprd_get_max_timeout_count(struct sdhci_host *host) > > return 1 << 31; > > } > > > > +static void sdhci_sprd_reset(struct sdhci_host *host, u8 mask) > > +{ > > + struct mmc_host *mmc = host->mmc; > > + > > + /* > > + * When try to reset controller after runtime suspend, we should not > > + * reset for all if the SD/eMMC card is not power down, just reset > > + * command and data lines instead. Otherwise will meet some strange > > + * behaviors for Spreadtrum host controller. > > + */ > > + if (host->runtime_suspended && (mask & SDHCI_RESET_ALL) && > > + !(mmc->caps & MMC_CAP_AGGRESSIVE_PM)) > > MMC_CAP_AGGRESSIVE_PM does not necessarily mean that the card will have been > runtime suspended. > > What about checking if the card power is on? i.e. Yes, you are totally correct. I'll fix this in next version. Thanks for your comments. > if (host->runtime_suspended && (mask & SDHCI_RESET_ALL) && > mmc->ios.power_mode == MMC_POWER_ON) > > > + mask = SDHCI_RESET_CMD | SDHCI_RESET_DATA; > > + > > + sdhci_reset(host, mask); > > +} > > + > > static struct sdhci_ops sdhci_sprd_ops = { > > .read_l = sdhci_sprd_readl, > > .write_l = sdhci_sprd_writel, > > @@ -381,7 +398,7 @@ static unsigned int sdhci_sprd_get_max_timeout_count(struct sdhci_host *host) > > .get_max_clock = sdhci_sprd_get_max_clock, > > .get_min_clock = sdhci_sprd_get_min_clock, > > .set_bus_width = sdhci_set_bus_width, > > - .reset = sdhci_reset, > > + .reset = sdhci_sprd_reset, > > .set_uhs_signaling = sdhci_sprd_set_uhs_signaling, > > .hw_reset = sdhci_sprd_hw_reset, > > .get_max_timeout_count = sdhci_sprd_get_max_timeout_count, > > > -- Baolin Wang Best Regards