mmc: dw_mmc: Add locking to the CTO timer
authorDouglas Anderson <dianders@chromium.org>
Thu, 12 Oct 2017 20:11:16 +0000 (13:11 -0700)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 30 Oct 2017 11:14:52 +0000 (12:14 +0100)
commit8892b705f58e105b0b4ce3402afa1d1b803fb207
tree2c39f76c735ce2e6bb9d1d24357bd1dc89396cca
parent4c2357f57dd5a3ecb4ce09f6a6cb394a1a8873b2
mmc: dw_mmc: Add locking to the CTO timer

This attempts to instill a bit of paranoia to the code dealing with
the CTO timer.  It's believed that this will make the CTO timer more
robust in the case that we're having very long interrupt latencies.

Note that I originally thought that perhaps this patch was being
overly paranoid and wasn't really needed, but then while I was running
mmc_test on an rk3399 board I saw one instance of the message:
  dwmmc_rockchip fe320000.dwmmc: Unexpected interrupt latency

I had debug prints in the CTO timer code and I found that it was
running CMD 13 at the time.

...so even though this patch seems like it might be overly paranoid,
maybe it really isn't?

Presumably the bad interrupt latency experienced was due to the fact
that I had serial console enabled as serial console is typically where
I place blame when I see absurdly large interrupt latencies.  In this
particular case there was an (unrelated) printout to the serial
console just before I saw the "Unexpected interrupt latency" printout.

...and actually, I managed to even reproduce the problems by running
"iw mlan0 scan > /dev/null" while mmc_test was running.  That not only
does a bunch of PCIe traffic but it also (on my system) outputs some
SELinux log spam.

Fixes: 03de19212ea3 ("mmc: dw_mmc: introduce timer for broken command transfer over scheme")
Tested-by: Emil Renner Berthing <kernel@esmil.dk>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/dw_mmc.c