]> git.baikalelectronics.ru Git - kernel.git/commit
mmc: alcor: don't write data before command has completed
authorDaniel Drake <drake@endlessm.com>
Tue, 26 Mar 2019 07:04:14 +0000 (15:04 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 28 Mar 2019 12:42:15 +0000 (13:42 +0100)
commit51f883008473fbad42018ea5c913048d24bda858
tree35a06018a5085a92d2e9849f5885f03197da1b7a
parentb85d83bae525031a6bd85f15b7d05f521f7900d2
mmc: alcor: don't write data before command has completed

The alcor driver is setting up data transfer and submitting the associated
MMC command at the same time. While this works most of the time, it
occasionally causes problems upon write.

In the working case, after setting up the data transfer and submitting
the MMC command, an interrupt comes in a moment later with CMD_END and
WRITE_BUF_RDY bits set. The data transfer then happens without problem.

However, on occasion, the interrupt that arrives at that point only
has WRITE_BUF_RDY set. The hardware notifies that it's ready to write
data, but the associated MMC command is still running. Regardless, the
driver was proceeding to write data immediately, and that would then cause
another interrupt indicating data CRC error, and the write would fail.

Additionally, the transfer setup function alcor_trigger_data_transfer()
was being called 3 times for each write operation, which was confusing
and may be contributing to this issue.

Solve this by tweaking the driver behaviour to follow the sequence observed
in the original ampe_stor vendor driver:
 1. When starting request handling, write 0 to DATA_XFER_CTRL
 2. Submit the command
 3. Wait for CMD_END interrupt and then trigger data transfer
 4. For the PIO case, trigger the next step of the data transfer only
    upon the following DATA_END interrupt, which occurs after the block has
    been written.

I confirmed that the read path still works (DMA & PIO) and also now
presents more consistency with the operations performed by ampe_stor.

Signed-off-by: Daniel Drake <drake@endlessm.com>
Fixes: ce15ea01bd45 ("mmc: add new Alcor Micro Cardreader SD/MMC driver")
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/alcor.c