Skip to content

Commit a04f001

Browse files
Alex Smithstorulf
authored andcommitted
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 torvalds#19). Resolve by holding the spinlock until after the IMASK register has been updated. Cc: [email protected] Link: MIPS#19 Fixes: 61bfbdb ("MMC: Add support for the controller on JZ4740 SoCs.") Tested-by: Mathieu Malaterre <[email protected]> Signed-off-by: Alex Smith <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 17dec0a commit a04f001

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/mmc/host/jz4740_mmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ static void jz4740_mmc_set_irq_enabled(struct jz4740_mmc_host *host,
362362
host->irq_mask &= ~irq;
363363
else
364364
host->irq_mask |= irq;
365-
spin_unlock_irqrestore(&host->lock, flags);
366365

367366
writew(host->irq_mask, host->base + JZ_REG_MMC_IMASK);
367+
spin_unlock_irqrestore(&host->lock, flags);
368368
}
369369

370370
static void jz4740_mmc_clock_enable(struct jz4740_mmc_host *host,

0 commit comments

Comments
 (0)