]> git.baikalelectronics.ru Git - kernel.git/commit
mmc: block: Check for errors after write on SPI
authorChristian Löhle <CLoehle@hyperstone.com>
Thu, 24 Mar 2022 14:18:41 +0000 (14:18 +0000)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 4 Apr 2022 10:17:46 +0000 (12:17 +0200)
commit66d03b8cf4b2877d6e19796bc5495af6d1768c09
treeb897de2e04aaf6afb86f74c20420a8f679113340
parent4f670ba06154d2b411d26b4bc54a6aff66c40fff
mmc: block: Check for errors after write on SPI

Introduce a SEND_STATUS check for writes through SPI to not mark
an unsuccessful write as successful.

Since SPI SD/MMC does not have states, after a write, the card will
just hold the line LOW until it is ready again. The driver marks the
write therefore as completed as soon as it reads something other than
all zeroes.
The driver does not distinguish from a card no longer signalling busy
and it being disconnected (and the line being pulled-up by the host).
This lead to writes being marked as successful when disconnecting
a busy card.
Now the card is ensured to be still connected by an additional CMD13,
just like non-SPI is ensured to go back to TRAN state.

While at it and since we already poll for the post-write status anyway,
we might as well check for SPIs error bits (any of them).

The disconnecting card problem is reproducable for me after continuous
write activity and randomly disconnecting, around every 20-50 tries
on SPI DS for some card.

Fixes: ca52c8aec19a5 ("MMC/SD card driver learns SPI")
Cc: stable@vger.kernel.org
Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/76f6f5d2b35543bab3dfe438f268609c@hyperstone.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/block.c