All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Simon Horman <horms@verge.net.au>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [RFC] mmc: tmio: fix tuning for stubborn cards
Date: Wed, 11 Oct 2017 10:35:37 +0200	[thread overview]
Message-ID: <20171011083537.GB22539@bigcity.dyn.berto.se> (raw)
In-Reply-To: <20171011073648.GF9661@verge.net.au>

Hi Simon,

On 2017-10-11 09:36:48 +0200, Simon Horman wrote:
> On Wed, Oct 11, 2017 at 02:08:14AM +0200, Niklas S�derlund wrote:
> > The commit 43b0b361b0170030 ("mmc: tmio: always get number of taps")
> > changed the behavior of the tuning. Before the commit the SCC was only
> > enabled for the first tuning attempt (host->init_tuning(host)), if that
> > failed the hardware where reset and tuning retried. In the second
> > attempt the SCC where never configured and tuning would succeed for some
> > stubborn cards. This patch restore this behavior which allows a troubled
> > card I have to be used.
> 
> Hi Wolfram,
> 
> Is tuning retried if the card is changed, f.e. ejected and a different card
> inserted?

I'd say tuning is retried every time a card is inserted, based on my 
tests bellow. Which would make the change in 43b0b361b0170030 correct as 
the number of taps should be reread each time but the fallback to try 
tuning without the SCC clock changed restored (if that is correct 
behavior?). The register write which breaks my stubborn card tuning is 
in renesas_sdhi_init_tuning() in drivers/mmc/host/renesas_sdhi_core.c:

    # I assume this write is just to unlock writing to 
    # SH_MOBILE_SDHI_SCC_CKSEL ?
    sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, ~CLK_CTL_SCLKEN &
                    sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));

    # This register change starts to produce the timeout for CMD19 with 
    # my stubborn card. In renesas_sdhi_hw_reset() this register is 
    # reset and tuning then works.
    sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_CKSEL,
                   SH_MOBILE_SDHI_SCC_CKSEL_DTSEL |
                   sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_CKSEL));

    # I as above assume this just locks the register write again ?
    sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN |
                        sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));

Test procedure as follows:

1. Insert stubborn card

[   29.048761] sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
[   34.168757] sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
[   34.228767] sh_mobile_sdhi ee100000.sd: Tuning procedure with SCC enabled failed, retry with SCC disabled
[   34.255636] mmc0: new ultra high speed SDR50 SDHC card at address aaaa
[   34.262440] mmcblk0: mmc0:aaaa SU04G 3.69 GiB 
[   34.274980]  mmcblk0: p1 p2

2. Eject stubborn card

[  115.858994] mmc0: card aaaa removed

3. Insert other card

[  137.195795] mmc0: new SD card at address 9749
[  137.200434] mmcblk0: mmc0:9749 SD128 120 MiB (ro)
[  137.208510]  mmcblk0: p1

4. Eject other card

[  142.499073] mmc0: card 9749 removed

5. Insert stubborn card

[  176.248760] sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
[  181.368756] sh_mobile_sdhi ee100000.sd: timeout waiting for hardware interrupt (CMD19)
[  181.428768] sh_mobile_sdhi ee100000.sd: Tuning procedure with SCC enabled failed, retry with SCC disabled
[  181.455631] mmc0: new ultra high speed SDR50 SDHC card at address aaaa
[  181.462424] mmcblk0: mmc0:aaaa SU04G 3.69 GiB 
[  181.474949]  mmcblk0: p1 p2

-- 
Regards,
Niklas S�derlund

  parent reply	other threads:[~2017-10-11  8:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11  0:08 [RFC] mmc: tmio: fix tuning for stubborn cards Niklas Söderlund
2017-10-11  7:36 ` Simon Horman
2017-10-11  7:38   ` Simon Horman
2017-10-11  7:40   ` Wolfram Sang
2017-10-11  8:35   ` Niklas Söderlund [this message]
2017-10-12 10:27     ` 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=20171011083537.GB22539@bigcity.dyn.berto.se \
    --to=niklas.soderlund@ragnatech.se \
    --cc=horms@verge.net.au \
    --cc=linux-renesas-soc@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.