Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp545968ybi; Tue, 16 Jul 2019 01:29:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3KdteSI82lIwjeM2U8+BFqhCyOdWcC9VIo97Swn674DHgKHj2QbjO8ep0sAMVl0hkIlth X-Received: by 2002:a17:902:8490:: with SMTP id c16mr34406194plo.1.1563265799171; Tue, 16 Jul 2019 01:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563265799; cv=none; d=google.com; s=arc-20160816; b=VQttTTVp0niJ/3d48BHuuBqp0lRuidBdvv0/xaL+DA/H4GXDRbELi7RceYYMoC6wA3 w01WNrOGXGGqaI5TTN5m1Ra/6OKEIDS2DzI10tI4FHK5vCQvXiH0Y3+vQaNdUpS0n5Vm wiP3p4r9nJJGs+dCI+YJH9BCrwqNhuVSirsdV/aiglYPAwoNOTEz8IBOi/SEXei1KLBA 1ayge0/kxG3YI+2nwXsSsufcGn5Fd5WSuJCWZH4AWMKcqKdhOgQt+2h5qx0xDMjwfwKn 5xBQONg7z/MbjovWgHxfKVvkaMU9IJrw5csyN/4vv5bN0AH2k729fvrz5MPHj7vIxjhY YeZg== 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=dAReaf3rIK7cjdNG/p1sH0aoz/zivoXItfETtanUzFI=; b=I1vl56dFEDsWgM4abyINJk+K65A+73nfn+hIswOa5V7GmAgdS/u/Tdl3TBEomv9wtx JTGrNosyQDCE79PThc3HFaIDEVxU/QHr7/dRHcBogt9yqrmzXDrYjSe+3nS1Jkfl8/D+ eajZ+9jR45YA/JnYynvJKHpONF30ZqLYjPbBfdrzlrGjflKLd625mA/+sK7AhUqiKsTP lx6JrWKjzv0mREUCXCiNuYXw6+1ozxVMW7hgvFKrLwHbmnRnFu5thaE4IU4zvyALdU7R vQ0g+p5Ov7NaNrYZczMUMTo5SYmL/iE3mU9a1q8W3O61wXSTsN1Lu2IIeye3yHdkX8Tj HzDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GylbGvQj; 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 h69si19548443pge.543.2019.07.16.01.29.42; Tue, 16 Jul 2019 01:29:59 -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=GylbGvQj; 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 S1730984AbfGPI3F (ORCPT + 99 others); Tue, 16 Jul 2019 04:29:05 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:39919 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727796AbfGPI3F (ORCPT ); Tue, 16 Jul 2019 04:29:05 -0400 Received: by mail-ot1-f65.google.com with SMTP id r21so14097477otq.6 for ; Tue, 16 Jul 2019 01:29:04 -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=dAReaf3rIK7cjdNG/p1sH0aoz/zivoXItfETtanUzFI=; b=GylbGvQjevcMby7m1jmxXgt1he2d3TdFGOKlC06/ZL0yKsesMNofyKRjxUxvWLUZrH qoPnchqDL4UcXwmvCgWl0MFjV7GpoDwC4zhscGHO+rdLBaWWgGkTkOzO5I2jtBqxk+lu O9OFwwOPRUV1NmfFUF4GpPLHOmIbrFHiVrCpRtzMBz9oI1NY1o+OPOOACxr1sVGwwYIS jJNsQh/9iledp8Q9bKjwBsyYR5fY62KqMp/1C450DFk/E1zDnpm47uYafb5S/f5ig2dz yuSKAIIVlXcg4aZeuwrRn6JZoRYFX+LtibHW3LRdID+XlyTnVXhgVkwlHkV883zyWJHA SoLg== 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=dAReaf3rIK7cjdNG/p1sH0aoz/zivoXItfETtanUzFI=; b=WKg/UxuaCLKwtQsdLFL13F1DicdD71S+grz8nf3vS+XTd04LdDB/PIeHlfcjuaehtb 559Rqro/4XO90mmcKfWnQhoKdLZ0WUgNeOBGROD33HmobAYK8wG9xrGB1lYROjEjsfFl woff+fT6LeZpv9isPzYLJY/h89DMPmp2e6g4b4A9RtW3hpSAD8rBdWOltucGm+/MMnUa lmMWnXqNgMXhCaO8Hiyy5gizi38cE2Jd2AirddSrKeNFT7qTbJMCwYujTkyZRPjF0SVB BxUVYNzCVK4olYOfESfA6e58RjtGHuG/AAEnSO08itWbycQpeLv/qjIHpkLuEv+7FOV0 5Dgw== X-Gm-Message-State: APjAAAVMpBAB8c0bq8RfC7MtqjHN2AXMM3D46IoNfRT1YW+9rWtYrOF9 xhr8m6dJGcJ5bIUvo+pQh2V+rZDrDw64vMnGLuXVTA== X-Received: by 2002:a9d:7a8b:: with SMTP id l11mr15513286otn.247.1563265744191; Tue, 16 Jul 2019 01:29:04 -0700 (PDT) MIME-Version: 1.0 References: <987d226b-5906-f403-d641-3c54430f1c9b@intel.com> In-Reply-To: <987d226b-5906-f403-d641-3c54430f1c9b@intel.com> From: Baolin Wang Date: Tue, 16 Jul 2019 16:28:52 +0800 Message-ID: Subject: Re: [PATCH v2] 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 16:24, Adrian Hunter wrote: > > On 16/07/19 10:31 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 v1: > > - Add a specific reset operation instead of changing the core to avoid > > affecting other hardware. > > --- > > drivers/mmc/host/sdhci-sprd.c | 38 +++++++++++++++++++++++++++++++++++++- > > 1 file changed, 37 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c > > index 603a5d9..174b566 100644 > > --- a/drivers/mmc/host/sdhci-sprd.c > > +++ b/drivers/mmc/host/sdhci-sprd.c > > @@ -373,6 +373,42 @@ 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; > > + ktime_t timeout; > > + > > + /* > > + * 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)) > > + mask = SDHCI_RESET_CMD | SDHCI_RESET_DATA; > > + > > Here you could just call sdhci_reset(host, mask) instead of below. Ah, right. Thanks for your comment. > > > + sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET); > > + > > + /* Wait max 100 ms */ > > + timeout = ktime_add_ms(ktime_get(), 100); > > + > > + /* hw clears the bit when it's done */ > > + while (1) { > > + bool timedout = ktime_after(ktime_get(), timeout); > > + > > + if (!(sdhci_readb(host, SDHCI_SOFTWARE_RESET) & mask)) > > + break; > > + if (timedout) { > > + pr_err("%s: Reset 0x%x never completed.\n", > > + mmc_hostname(host->mmc), (int)mask); > > + sdhci_dumpregs(host); > > + return; > > + } > > + udelay(10); > > + } > > +} > > + > > static struct sdhci_ops sdhci_sprd_ops = { > > .read_l = sdhci_sprd_readl, > > .write_l = sdhci_sprd_writel, > > @@ -381,7 +417,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