mmc: sdhci: plug hole in disabling card detection interrupts
authorRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 25 Apr 2014 11:57:02 +0000 (12:57 +0100)
committerChris Ball <chris@printf.net>
Thu, 22 May 2014 11:26:27 +0000 (07:26 -0400)
When we disable card detection interrupts, we should disable both the
insert and remove interrupts irrespective of the current state - this
avoids races between the hardware card detect changing state before
we've read that updated state and altered the interrupt mask.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Markus Pargmann <mpa@pengutronix.de>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
drivers/mmc/host/sdhci.c

index 4a98ee29d1369a555faacee6a2ea582071126dea..8cd20ef0a9cb4f69a85905934c5b2f23b5e2086a 100644 (file)
@@ -133,20 +133,21 @@ static void sdhci_dumpregs(struct sdhci_host *host)
 
 static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
 {
-       u32 present, irqs;
+       u32 present;
 
        if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
            (host->mmc->caps & MMC_CAP_NONREMOVABLE))
                return;
 
-       present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
-                             SDHCI_CARD_PRESENT;
-       irqs = present ? SDHCI_INT_CARD_REMOVE : SDHCI_INT_CARD_INSERT;
+       if (enable) {
+               present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
+                                     SDHCI_CARD_PRESENT;
 
-       if (enable)
-               host->ier |= irqs;
-       else
-               host->ier &= ~irqs;
+               host->ier |= present ? SDHCI_INT_CARD_REMOVE :
+                                      SDHCI_INT_CARD_INSERT;
+       } else {
+               host->ier &= ~(SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT);
+       }
 
        sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
        sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);