]> git.baikalelectronics.ru Git - kernel.git/commit
mmc: atmel-mci: fix race between stop command and start of next command
authorTobias Schramm <t.schramm@manjaro.org>
Fri, 30 Dec 2022 19:43:15 +0000 (20:43 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:33:53 +0000 (13:33 +0100)
commit6cff59409b6d7f760fd0362f06c2dd6fba494759
treee30bff42851af5904362d2fefbe1c20daec439c3
parenta7b885dab742a7982960e349e0aa03c3e78b5d89
mmc: atmel-mci: fix race between stop command and start of next command

[ Upstream commit 4db5609132c059b1a4d8fd4151a05f113530d2ae ]

This commit fixes a race between completion of stop command and start of a
new command.
Previously the command ready interrupt was enabled before stop command
was written to the command register. This caused the command ready
interrupt to fire immediately since the CMDRDY flag is asserted constantly
while there is no command in progress.
Consequently the command state machine will immediately advance to the
next state when the tasklet function is executed again, no matter
actual completion state of the stop command.
Thus a new command can then be dispatched immediately, interrupting and
corrupting the stop command on the CMD line.
Fix that by dropping the command ready interrupt enable before calling
atmci_send_stop_cmd. atmci_send_stop_cmd does already enable the
command ready interrupt, no further writes to ATMCI_IER are necessary.

Signed-off-by: Tobias Schramm <t.schramm@manjaro.org>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Link: https://lore.kernel.org/r/20221230194315.809903-2-t.schramm@manjaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mmc/host/atmel-mci.c