linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Whitchurch <vincent.whitchurch@axis.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Mårten Lindahl" <Marten.Lindahl@axis.com>,
	"Doug Anderson" <dianders@chromium.org>,
	"Shawn Lin" <shawn.lin@rock-chips.com>,
	"Jaehoon Chung" <jh80.chung@samsung.com>,
	kernel <kernel@axis.com>, linux-mmc <linux-mmc@vger.kernel.org>
Subject: Re: [PATCH] mmc: dw_mmc: Support more time for data read timeouts
Date: Fri, 10 Sep 2021 11:28:08 +0200	[thread overview]
Message-ID: <20210910092808.GA6893@axis.com> (raw)
In-Reply-To: <CAPDyKFr7rFKhCcg56zhUDn+BSnKd-y93wJLFX20zXYFZwH2jnQ@mail.gmail.com>

On Mon, Sep 06, 2021 at 06:36:33PM +0200, Ulf Hansson wrote:
> On Fri, 27 Aug 2021 at 10:56, Mårten Lindahl <marten.lindahl@axis.com> wrote:
> > For data read transfers a data transfer over timer (dto_timer) is
> > started to make sure the data command can be completed in cases the Data
> > Transfer Over (DTO) interrupt does not come. This timer was originally
> > introduced as a quirk in commit 57e104864bc48 ("mmc: dw_mmc: add quirk
> > for broken data transfer over scheme"), but is since a while back part
> > of the running code.
> >
> > The dto timer picks the DATA_TIMEOUT value in the TMOUT register for its
> > timeout, which will give a max timeout of approximately 84 + (10 spare)
> > milliseconds on a 200MHz clock. But this register is not intended to be
> > used like that, since it is a counter for data read timeouts (DRTO) and
> > response timeouts (RTO), which will result in error interrupts in case
> > of data read and response delays.
> >
> > The TMOUT register is always set with a full value for every transfer,
> > which according to the manual (and with 200MHz clock) will give a full
> > DRTO of:
> > ((TMOUT[10:8] -1) * 0xFFFFFF + TMOUT[31:11] * 8) / 200000000 => ~587 ms
> >
> > But as the same register is used for the dto_timer, the dto_timer will
> > always have a fixed timeout.
> >
> > Instead of always setting a fixed value in TMOUT register, we can use
> > data->timeout_ns for the DRTO interrupts that actually matches what was
> > provided per requested command. Likewise we can also use timeout_ns for
> > the dto_timer, which will allow a max timeout of 587 ms, instead of the
> > fixed 94 ms. Furthermore, if a data error interrupt comes, it shouldn't
> > be necessary to wait for the dto_timer before we finish the command, but
> > instead we can handle it in the interrupt handler.
> >
> > Lets fix this. In most cases data->timeout_ns values are given, but in
> > case it is not given, the maximum (default) timeout for the dto_timer,
> > and the DRTO, is set to approximately 587 ms.
> >
> > Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
> 
> As this touches common dw_mmc code, I would appreciate some
> tests/reviews to be done before I apply this. Therefore I looped in
> some of the people who have been involved with dw_mmc lately.
>
> + Doug, Shawn and Vincent (maybe they can also help to review/test this change). 

I have the same hardware as Mårten (ARTPEC-8) so I don't think my
testing would add much.  We'd ideally need someone with a different
platform to help to test this.

As for the patch itself, it would perhaps be helpful if it were broken
down into three separate patches (not necessarily in the order listed
below) since it's doing three different things:

(1) Increasing the length of the software timeout.

This is the primary reason for the patch since the driver is clearly
using a wrong value for the software timeout for the entire transfer
which is lower than the timeouts required by eMMC chips' TAAC/NSAC and
the controller's timeout for (IIUC) one block.

We haven't seen any problems in practice (yet) though.

(As an aside, if I'm reading the eMMC specs correctly, the TAAC/NSAC
 applies to each block of a multi-block transfer.  If that's the case,
 then the entire transfer could, at least in theory, take several
 seconds.

 Is the data->timeout_ns calculated by mmc_set_data_timeout() supposed
 to be a per-block timeout or a timeout for the entire transfer?)

(2) Not waiting for DRTO on errors.

When attempting to increase the length of the software timeout as in (1)
or to remove it entirely, one realizes that the driver actually depends
on the software timeout to prevent hanging indefinitely when CRC errors
are received during tuning.  It's unclear if this is something specific
to our version of the IP or if this is an old regression in the driver
(given that the driver apparently used to work fine without a software
timeout at some point of time on some platforms.)

So increasing the software timeout length will make each failing step in
tuning take half a second which would increase boot time significantly,
so that's why I think the early exit is needed.

(3) Reducing the length of the hardware timeout.

I *think* this is also to reduce initialization time if there are some
transfers which are meant to time out (without any other errors) which
would now take longer to time out after (1), but this part of the change
could use a bit more rationale.

  reply	other threads:[~2021-09-10  9:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27  8:56 [PATCH] mmc: dw_mmc: Support more time for data read timeouts Mårten Lindahl
2021-09-06 16:36 ` Ulf Hansson
2021-09-10  9:28   ` Vincent Whitchurch [this message]
2021-09-10 20:53 ` Doug Anderson
2021-09-16 10:45   ` Marten Lindahl
2021-09-17  7:13 ` Christian Löhle

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=20210910092808.GA6893@axis.com \
    --to=vincent.whitchurch@axis.com \
    --cc=Marten.Lindahl@axis.com \
    --cc=dianders@chromium.org \
    --cc=jh80.chung@samsung.com \
    --cc=kernel@axis.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=ulf.hansson@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).