Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8828464ybi; Tue, 23 Jul 2019 16:11:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwORMzfVKgjv1fuo3pkiu8ezLVqDhPN1Kf7rO8V/4FuG6C2PgHG1QFmwTguE9EIV7HOybaT X-Received: by 2002:a63:101b:: with SMTP id f27mr75635704pgl.291.1563923461033; Tue, 23 Jul 2019 16:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563923461; cv=none; d=google.com; s=arc-20160816; b=eBAKvz0pml0mWwu5Glsdat4ZecmfLiotIEGeXIebqcuHpw1Z/4kGsUq7+dyPwQFD/N 3iVb/vps28GpL2xx91rrSGrc9yiqRlwSe/26plNHwivrluvNTpP9Ty27x1SyYkrcVf1W a0VNCTzVEoUhlPhueYo6rvIgTNXtrwb2TBDbxgY5ilH5ajken9sYheAPfzvk+P/SIbEF kHXZrTSXnCAePHzgXcF26UhWxVeajbc7gUIsdwJ8/n63zL7iPSbk0WykzJnvKncOTX0R xgqM7xACyIwM1I6SzaleQ92ak5/outJDd1cfmt5u022DaeinFtx+OkEsD1zuvplWLkil jvSw== 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=hDYKhmxn2J0UWXf4pkGZBo1Wis9vp9LCh83FPTIg9xw=; b=C91Kf9Vc1V4jtaUUx1h9wdQukCKZCAO6ADV+bouApPcQ/RwjE2E71ClBEBI3//CVJV pd0E8wBo3SXKltLCgLq4ZatGVS9apI1Zj2TK5dhM7jayc8BMGsKoeXKIZoypT8clGNr0 s6HACjMSsjH+IZKWKQviIfmGR7Os8U3kK3fciT0Q+ow+EGW4CjnrVCbGg9SFznt6UiLI 22x8CtNihEI5ANw9KhqlaR9qFh3HdK1u0/9ahvaW4H71RuVlqwp57FxSB4nockvQi5l6 NmNuMGlvOIW0qXSsNCCIXpD9SzlwKco0qAOeobJWzeCH1vq/2fs+x+GV22OH4K1C2WcZ qKpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gm1n02Yy; 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 h99si11721308pje.83.2019.07.23.16.10.45; Tue, 23 Jul 2019 16:11:00 -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=Gm1n02Yy; 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 S1730697AbfGWMjK (ORCPT + 99 others); Tue, 23 Jul 2019 08:39:10 -0400 Received: from mail-vs1-f67.google.com ([209.85.217.67]:33766 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726720AbfGWMjK (ORCPT ); Tue, 23 Jul 2019 08:39:10 -0400 Received: by mail-vs1-f67.google.com with SMTP id m8so28746377vsj.0 for ; Tue, 23 Jul 2019 05:39:09 -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=hDYKhmxn2J0UWXf4pkGZBo1Wis9vp9LCh83FPTIg9xw=; b=Gm1n02YyhumxOu44VutgphyUY0n/RR1S8owJG9yQ0GmeHh7N9cJSFQ631OOBk1Qc7c gI5UOhSj6Qn99wHnZjWwGAJ7+v5vBzFa+7b738mylE8LVLvIp6j6DvUdB7qfwXHoX3/x IK/A1eQGXq02wD0hFBumhKtp+dRsnlIqkHxAONzI3tXzWG7rR658NMbUO0Y8dcnxBmG6 LWCNr1CiSNjBwA5Pgg302OWmh+0P9rEMDsuJ3vwtmCTa8D6+ljOm4xQ6W69gmCcysvXM 4/CjFoobaIgpg03OcQVPzJkymyoZHaiFmXGSHUCM3O+R/G5qqxGg7kjMeoeAznl3JItE BnFA== 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=hDYKhmxn2J0UWXf4pkGZBo1Wis9vp9LCh83FPTIg9xw=; b=c5omqicn4Rj5Wk9ekVtLPUiNX/+yr7Yvs/miPbA9LKo5VJO6mAGpXIjjilV0j8VGWe 0ivVywNssZCOopxC9rgxQ4CNTNrlda4d1+ASl6jLxUv95P3ec+3sJ/hu/yqeWAqr/jbl q0MJTGKStJX7TY3dd6+6/v36BU/128V279gnskRBL3OnpBQqv5lsVRsbPWStjJxh+oNL TzEQaga1VBp7a24L3gw/bZiIvV8OOaOfgyI6IfvtFbiZgY8mpLOBTA0Gzipl/by4K8hi lPXTBEt+tACYkKsE+Mjf3gZeeTReKxkvt41zJQddorVG8y3iZBdUJ7xN36lkDTiWzm5O oPvA== X-Gm-Message-State: APjAAAVxZ1wNKyP1ZCd0fhpecDwDM7ZuhLZCndTALgHipYnVNzowc/Ef MISTyE4NjOL/L1ZAjPfXXXdn7bdIMnhV3l70aFymKA== X-Received: by 2002:a67:e454:: with SMTP id n20mr48233154vsm.34.1563885549183; Tue, 23 Jul 2019 05:39:09 -0700 (PDT) MIME-Version: 1.0 References: <89c3ef495c367d58ca3abe99a1f82c48f8c08705.1563274904.git.baolin.wang@linaro.org> In-Reply-To: From: Ulf Hansson Date: Tue, 23 Jul 2019 14:38:32 +0200 Message-ID: Subject: Re: [PATCH v4] mmc: host: sdhci-sprd: Fix the incorrect soft reset operation when runtime resuming To: Baolin Wang Cc: Adrian Hunter , Chunyan Zhang , Orson Zhai , Vincent Guittot , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List 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, 23 Jul 2019 at 05:05, Baolin Wang wrote: > > Hi Ulf, > > On Mon, 22 Jul 2019 at 19:54, Ulf Hansson wrote: > > > > On Wed, 17 Jul 2019 at 04:29, 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. > > > > What does "software reset for all" means? > > The SD host controller specification defines 3 types software reset: > software reset for data line, software reset for command line and > software reset for all. > Software reset for all means this reset affects the entire Host > controller except for the card detection circuit. Thanks for clarifying, please update the changelog accordingly. > > > > > > > > > Thus for Spreadtrum platform that will not power down the SD/eMMC card during > > > runtime suspend, we should not do software reset for all. > > > > Normally, sdhci hosts that enters runtime suspend doesn't power off > > the card (there are some exceptions like PCI variants). > > Yes, same as our controller. > > > > > So, what's so special here and how does the reset come into play? I > > don't see sdhci doing a reset in sdhci_runtime_suspend|resume_host() > > and nor doesn the callback from the sdhci-sprd.c variant doing it. > > In sdhci_runtime_resume_host(), it will issue sdhci_init(host, 0) to > issue software reset for all. Aha, I didn't read the code carefully enough. Apologize for the noise. > > > > > > To fix this > > > issue, adding a specific reset operation that adds one condition to validate > > > the power mode to decide if we can do software reset for all or just reset > > > command and data lines. > > > > > > Signed-off-by: Baolin Wang > > > --- > > > Changess from v3: > > > - Use ios.power_mode to validate if the card is power down or not. > > > > > > 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..94f9726 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->ios.power_mode == MMC_POWER_ON) > > > + mask = SDHCI_RESET_CMD | SDHCI_RESET_DATA; > > > > Can sdhci_sprd_reset() be called when the host is runtime suspended? > > When host tries to runtime resume in sdhci_runtime_resume_host(), it > will call reset operation to do software reset. Right, I see that now, thanks for clarifying. However, there are still some weird things going on in sdhci_runtime_resume_host(). Like why is host->ops->enable_dma() called first, directly from sdhci_runtime_resume_host(), then again in sdhci_do_reset(), after host->ops->reset() has been called. Looks like the first call to ->enable_dma() doesn't make sense? > > > That sounds like a bug to me, no? > > Since our controller will meet some strange behaviors if we do > software reset for all in sdhci_runtime_resume_host(), and try to > avoid changing the core logic of sdhci_runtime_resume_host() used by > other hardware controllers, thus I introduced a specific reset ops and > added some condition to make sure we just do software reset command > and data lines from runtime suspend state. I understand, but perhaps it would become more clear if sdhci_runtime_resume_host() is re-factored a bit. Maybe the caller can give it some new parameter to let it decide if a SDHCI_RESET_ALL shall be done or not. > > > > > > + > > > + 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, > > > -- > > > 1.7.9.5 > > > Kind regards Uffe