]> git.baikalelectronics.ru Git - kernel.git/commit
mmc: jz4740: Fix race condition in IRQ mask update
authorAlex Smith <alex.smith@imgtec.com>
Wed, 28 Mar 2018 21:00:43 +0000 (18:00 -0300)
committerUlf Hansson <ulf.hansson@linaro.org>
Wed, 4 Apr 2018 07:47:27 +0000 (09:47 +0200)
commitaee239755ea889c1cd1128206ef0d71d7fe43b22
tree995807951552d0a59985c61288d8c9c5e855265f
parent265af13f7a8af0ad4d68bd938dd5bf282e712425
mmc: jz4740: Fix race condition in IRQ mask update

A spinlock is held while updating the internal copy of the IRQ mask,
but not while writing it to the actual IMASK register. After the lock
is released, an IRQ can occur before the IMASK register is written.
If handling this IRQ causes the mask to be changed, when the handler
returns back to the middle of the first mask update, a stale value
will be written to the mask register.

If this causes an IRQ to become unmasked that cannot have its status
cleared by writing a 1 to it in the IREG register, e.g. the SDIO IRQ,
then we can end up stuck with the same IRQ repeatedly being fired but
not handled. Normally the MMC IRQ handler attempts to clear any
unexpected IRQs by writing IREG, but for those that cannot be cleared
in this way then the IRQ will just repeatedly fire.

This was resulting in lockups after a while of using Wi-Fi on the
CI20 (GitHub issue #19).

Resolve by holding the spinlock until after the IMASK register has
been updated.

Cc: stable@vger.kernel.org
Link: https://github.com/MIPS/CI20_linux/issues/19
Fixes: 7f905d1b3522 ("MMC: Add support for the controller on JZ4740 SoCs.")
Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Alex Smith <alex.smith@imgtec.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/jz4740_mmc.c