Linux Renesas SOC kernel development
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Magnus Damm <magnus.damm@gmail.com>,
	linux-mmc <linux-mmc@vger.kernel.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH v4 2/4] mmc: tmio: Add tuning support
Date: Thu, 1 Sep 2016 16:19:07 +0200	[thread overview]
Message-ID: <20160901141907.GF14300@verge.net.au> (raw)
In-Reply-To: <CAPDyKFraiatvCcmhPLU+=M01Q9Dkd73QTQRJd_e=vBr-g4MwQw@mail.gmail.com>

On Thu, Sep 01, 2016 at 11:55:27AM +0200, Ulf Hansson wrote:
> On 1 September 2016 at 10:37, Simon Horman <horms@verge.net.au> wrote:
> > On Thu, Sep 01, 2016 at 08:46:44AM +0200, Simon Horman wrote:
> >> On Wed, Aug 31, 2016 at 09:38:40AM +0200, Ulf Hansson wrote:
> >> > On 30 August 2016 at 22:51, Simon Horman <horms@verge.net.au> wrote:
> >> > > On Mon, Aug 29, 2016 at 04:05:55PM +0200, Ulf Hansson wrote:
> >> > >> On 29 August 2016 at 14:05, Simon Horman <horms@verge.net.au> wrote:
> >> > >> > On Fri, Aug 26, 2016 at 10:01:35AM +0200, Ulf Hansson wrote:
> >> > >> >> On 25 August 2016 at 14:04, Simon Horman <horms@verge.net.au> wrote:
> >> > >> >> > On Tue, Aug 23, 2016 at 05:02:56PM +0200, Ulf Hansson wrote:
> >> > >> >
> >> > >> > ...
> >> > >
> >> > > ...
> >> > >
> >> > >> > @@ -1271,6 +1278,7 @@ int tmio_mmc_host_runtime_suspend(struct device *dev)
> >> > >> >
> >> > >> >         mmc_retune_timer_stop(host->mmc);
> >> > >> >         mmc_retune_needed(host->mmc);
> >> > >> > +       host->use_saved_taps = true;
> >> > >>
> >> > >> I don't think you should trigger a re-tune here at all. Moreover you
> >> > >> don't need to keep track of whether you have valid tap values by using
> >> > >> the ->use_saved_taps variable, the mmc core deals with this for you.
> >> > >>
> >> > >> Instead, you should restore the tap values by invoking
> >> > >> host->select_tuning() from the ->runtime_resume() callback, although
> >> > >> only when host->mmc->can_retune == 1. We should probably add a helper
> >> > >> function in the mmc core for this check, instead of accessing
> >> > >> "can_retune" directly.
> >> > >
> >> > > Thanks, I was wondering what the best way to handle this is.
> >> > >
> >> > > I tried your suggestion above but it seems that host->mmc->can_retune is
> >> > > zero when ->runtime_resume() is called because of the following call paths:
> >> > >
> >> > > a) _mmc_sd_suspend()
> >> > >      -> mmc_power_off()
> >> > >         -> mmc_set_initial_state()
> >> > >            -> mmc_retune_disable
> >> > >    and
> >> > > b) mmc_sd_runtime_resume()
> >> > >      -> mmc_power_up
> >> > >         -> mmc_set_initial_state()
> >> > >            -> mmc_retune_disable
> >> > >
> >> > >> >         tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
> >> >
> >> > This is exactly what shall happen :-)
> >> >
> >> > If the mmc core suspends the card, it means it will also re-initialize
> >> > the card when resuming it. In that way the regular tuning sequence
> >> > will take place as a part of re-initialization of the card, so you
> >> > definitely must not restore tap values in these case. That is why you
> >> > should be using the can_retune to know when to restore the values.
> >>
> >> Understood. In that case things are working as expected.
> >
> > I do have one question. It seems to me that  host->mmc->can_retune == 1 on
> > resume. If so, when would the saved tap values be used?  I feel that I am
> > missing something here.
> 
> There are different "resumes" here, so this gets a bit tricky to
> discuss around. Let me give it another try.
> 
> First, let's assume we have a card inserted, initialized and tuned.
> This also means we have a cache of tuning (tap) values in the host.
> 
> When the *host* runtime PM suspends, which isn't related to when the
> card suspends, typically the card remains powered/initialized. Then,
> when the host runtime PM resumes the tuning values can be restored in
> the host controller, as those should still be working because the card
> has remained initialized.
> 
> When the card system PM suspends, the card will be put to sleep/power
> off (can_retune == 0). Sooner or later the host also becomes runtime
> PM suspended in this sequence.
> 
> When the card system PM resumes, the card will be woken up from sleep,
> power on and the re-initializations starts. Before the
> re-initializations starts, the host will be runtime PM resumed, but
> since can_retune == 0, no tuning values will be restored (correct).
> When the re-initialization sequence completes of the card, can_retune
> == 1 as a new tuning sequence has also been completed. This also means
> refreshed cached tunings values in the host, which it can use the next
> time it will be runtime PM resumed.
> 
> Hope this made more sense now.

Thanks for your detailed explanation. I understand now.

  reply	other threads:[~2016-09-01 14:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-27  4:13 [PATCH v4 0/4] UHS-I SDR-104 support for sh_mobile_sdhi Simon Horman
2016-07-27  4:13 ` [PATCH v4 1/4] mmc: tmio: enhance illegal sequence handling Simon Horman
2016-07-27  4:13 ` [PATCH v4 2/4] mmc: tmio: Add tuning support Simon Horman
2016-08-10 13:10   ` Wolfram Sang
2016-08-22 13:39   ` Ulf Hansson
2016-08-23 13:52     ` Simon Horman
2016-08-23 15:02       ` Ulf Hansson
2016-08-25 12:04         ` Simon Horman
2016-08-26  8:01           ` Ulf Hansson
2016-08-29 12:05             ` Simon Horman
2016-08-29 14:05               ` Ulf Hansson
2016-08-30 20:51                 ` Simon Horman
2016-08-31  7:38                   ` Ulf Hansson
2016-09-01  6:46                     ` Simon Horman
2016-09-01  8:37                       ` Simon Horman
2016-09-01  9:55                         ` Ulf Hansson
2016-09-01 14:19                           ` Simon Horman [this message]
2016-07-27  4:13 ` [PATCH v4 3/4] mmc: sh_mobile_sdhi: " Simon Horman
2016-07-28  0:12   ` Simon Horman
2016-07-27  4:13 ` [PATCH v4 4/4] ARM: dts: r8a7790: lager: Enable UHS-I SDR-104 Simon Horman
2016-08-10 13:12 ` [PATCH v4 0/4] UHS-I SDR-104 support for sh_mobile_sdhi Wolfram Sang
2016-08-11  8:43   ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160901141907.GF14300@verge.net.au \
    --to=horms@verge.net.au \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox