Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4147900ybi; Mon, 15 Jul 2019 04:38:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqvoddQRFFaBT6mtI1xpqCxY7noQPDMS/mcEzgAsdEOwXIv3zdyyWbo/rhUqIWYHYrE66k X-Received: by 2002:a63:dd4e:: with SMTP id g14mr16048641pgj.227.1563190701148; Mon, 15 Jul 2019 04:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563190701; cv=none; d=google.com; s=arc-20160816; b=Ygi3I4Rj7kXNrsRE8WaXvnei/VO8DBD6pDvBLFQhr2Vsi9x+qJVgo+jpF0sE4l3c8V s9UAwysl2jchdyFkuCcdHDkRDJy9EwpIdCRVQsYKhJVGWV0un3IJOoHTYBV3Tbc9ODtA yTfqimXr98fbWtIYFjv1+cBbK66wyTx1rAP45FkT3sxzMN2QcGJStcej/W89DWMDQ4lc jKlklQNXwD4PXBZlMMCmYW0dUKthezX+jVG702vqvSL09LZCgmiWDTQcVUSrAL8i9xZ0 2ofM6xEsZOAuhcMsSgbCaXIm5Y5ds5Vlp1nZFxuEDdivWdAwuCGpBQzIOHfg/nkJwL5O xqMg== 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=ct0CYM5F6k+ekATcWAW/eEo6/LLNd8N182gpSaiugOE=; b=dlgMNCWaTiAWjKyc+psKA3WD+tUksbYlwsrCmpVYwAvkvsKqc8F+X339EMIVckOl0l eY8HOi5v6bc6e78/EHheXgFyavd63rMNBLwo6GLPZDHcMbIIQE9BLHbSAdWI0EdDZDvW rfy0t+FCnRAl/VLVQFEucwHhOOZW/iAeG7qwrNcCTDEybLNfHOb+KRf4YMYhsfqAHUpf 3IN7MoaEFGvrlY2ceE4CyNFlBRLC2th2vI/n5C4WjQj1LNlCBzfQj4483x/99ubbCD3N 2/jrEK2S4YxdthWgfgv5uWo2JHQSJa3h3fq58Cz/B3Jwyy6wl6iQPf7hrf7QDeGHdk/D gk0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oRSmgHfr; 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 u12si6301426pfh.6.2019.07.15.04.38.03; Mon, 15 Jul 2019 04:38:21 -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=oRSmgHfr; 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 S1729866AbfGOLho (ORCPT + 99 others); Mon, 15 Jul 2019 07:37:44 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:46716 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729533AbfGOLho (ORCPT ); Mon, 15 Jul 2019 07:37:44 -0400 Received: by mail-oi1-f193.google.com with SMTP id 65so12343261oid.13 for ; Mon, 15 Jul 2019 04:37:43 -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=ct0CYM5F6k+ekATcWAW/eEo6/LLNd8N182gpSaiugOE=; b=oRSmgHfr0GQ0spP4Y5ldmoreGZRCYUpp5NxP8IQ8y61j/hvR29O/W9rOPUgUzTWbxW d468fMZkc1gUW8ng6BA7PVaq0a+rc7fr1vQYNha/xokOlxv+jSDWWzrGF6WuugfrZ2jh LNbBFElT0FT5450kLNH72xOy18sjSqqqJ9qwKkx0/+f7HQ1Y7WH1C4DS4GfhraHnkAnO QHs81P7kl2najUF3jA61IhfC1tP/HN1DX8mWOKQAiuaY+5lA4cnOiuxhmrvd7+huN89Y V2SwrGdey1gMBNTiLTWwHvGJmBmxF19ZqDUwanJtd0Hj02BUUSdpUoq3EWpl9Dp/1ALv n0Iw== 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=ct0CYM5F6k+ekATcWAW/eEo6/LLNd8N182gpSaiugOE=; b=CcOdm4bQH/frnzFMgmNCvT0Ls4uvrJzHj+LoxmdSKlDPuJmkvUxHqeNpweclRD4u8X B5yW1uefpN2J1NA9UsnERKg6MDZM4f5eagn3R2zJNkfikmYOp5hNaQoHaZyo8beC1uZW i5W01zQZZDGMJo9R0zb+oZ2CW5IXNYneA5FXEjchUvjJtjezgzzY0hDcLy0S/cEBXO3i vpy5nU6sBsqsZisOSUGg1950Jow37z/hc5ZDE1LU1dYna7WOBLdLubTEet/5u2/ND6BQ vzoQNuveEGoajJrsHvLNrYuoe2cZsvgXR45VHiPlkclEJdagxArOAJl3SWOfXIuzL/QT 6nGA== X-Gm-Message-State: APjAAAVt6mfWKiS2roCSaJiskb5qWeuUvisFUAjFBA02BMXpEiP6qo/P IMhtl+QNcZTVCHkufAjzSpNQLwYVSx/xiO48vzIS9Q== X-Received: by 2002:aca:6183:: with SMTP id v125mr11830474oib.6.1563190663088; Mon, 15 Jul 2019 04:37:43 -0700 (PDT) MIME-Version: 1.0 References: <4c5812f54e5094fa54a85bdc86687a523df254b3.1563184923.git.baolin.wang@linaro.org> In-Reply-To: From: Baolin Wang Date: Mon, 15 Jul 2019 19:37:31 +0800 Message-ID: Subject: Re: [PATCH] mmc: host: sdhci: Fix the incorrect soft reset operation when runtime resuming To: Adrian Hunter Cc: Ulf Hansson , Chunyan Zhang , Orson Zhai , Linus Walleij , 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 Hi Adrian, On Mon, 15 Jul 2019 at 19:20, Adrian Hunter wrote: > > On 15/07/19 1:58 PM, Baolin Wang wrote: > > In sdhci_runtime_resume_host() function, we will always do software reset > > for all, but according to the specification, we should issue reset command > > and reinitialize the SD/eMMC card. > > Where does it say that? I checked the SD host controller simplified specification Ver4.20, and in Page 75, Software Reset For All bit, it says "if this bit is set to1, the host driver should issue reset command and reinitialize the SD card". (I did not check other versions). > > > However, we only do reinitialize the > > SD/eMMC card when the SD/eMMC card are power down during runtime suspend. > > > > Thus for those platforms that do not power down the SD/eMMC card during > > runtime suspend, we should not do software reset for all. > > To fix this > > issue, we can 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 > > --- > > drivers/mmc/host/sdhci.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > > index 9715834..470c5e0 100644 > > --- a/drivers/mmc/host/sdhci.c > > +++ b/drivers/mmc/host/sdhci.c > > @@ -3333,7 +3333,7 @@ int sdhci_runtime_resume_host(struct sdhci_host *host) > > host->ops->enable_dma(host); > > } > > > > - sdhci_init(host, 0); > > + sdhci_init(host, !(mmc->caps & MMC_CAP_AGGRESSIVE_PM)); > > We have done a full reset for a long time, so it would be surprising to need > to change it. > > What problem is it causing? If we did not power down the SD card during runtime suspend, and we reset for all when runtime resume, our SD host controller can not work well, will meet some strange behavior, like: [ 6.525397] mmc0: Got data interrupt 0x00000002 even though no data operation was in progress. [ 6.534189] mmc0: sdhci: ============ SDHCI REGISTER DUMP =========== [ 6.540797] mmc0: sdhci: Sys addr: 0x00000008 | Version: 0x00000004 [ 6.547413] mmc0: sdhci: Blk size: 0x00000200 | Blk cnt: 0x00000000 [ 6.554029] mmc0: sdhci: Argument: 0x03200101 | Trn mode: 0x00000033 [ 6.560645] mmc0: sdhci: Present: 0x01f000f0 | Host ctl: 0x00000030 [ 6.567262] mmc0: sdhci: Power: 0x00000000 | Blk gap: 0x00000000 [ 6.573877] mmc0: sdhci: Wake-up: 0x00000000 | Clock: 0x00000007 [ 6.580493] mmc0: sdhci: Timeout: 0x0000000e | Int stat: 0x00000000 [ 6.587109] mmc0: sdhci: Int enab: 0x037f000b | Sig enab: 0x037f000b [ 6.593726] mmc0: sdhci: ACmd stat: 0x00000000 | Slot int: 0x00000000 [ 6.600342] mmc0: sdhci: Caps: 0x1c6d0080 | Caps_1: 0x08000007 [ 6.606959] mmc0: sdhci: Cmd: 0x0000061b | Max curr: 0x00ffffff [ 6.613574] mmc0: sdhci: Resp[0]: 0x00001201 | Resp[1]: 0x00000000 [ 6.620190] mmc0: sdhci: Resp[2]: 0x00000000 | Resp[3]: 0x00000000 [ 6.626806] mmc0: sdhci: Host ctl2: 0x00003807 [ 6.631364] mmc0: sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x00000000df062000 [ 6.638697] mmc0: sdhci: ============================================ [ 6.645379] mmc0: cache flush error -84 Got data interrupt but no data commands are processing now. With this patch, then our SD host controller can work well. Did I miss anything else? Thanks. -- Baolin Wang Best Regards