mmc: guarantee atomic access INTMASK register for sdio_irq_thread
authorlintao <lintao@rock-chips.com>
Tue, 9 Sep 2014 09:38:40 +0000 (17:38 +0800)
committerlintao <lintao@rock-chips.com>
Tue, 9 Sep 2014 09:41:54 +0000 (17:41 +0800)
drivers/mmc/host/rk_sdmmc.c

index 4db50856b0da574de99e0e50a6131bff0d935150..586b91479e3a0d88f439702f650ab6c76de52431 100755 (executable)
@@ -701,10 +701,11 @@ err_exit:
 
 static void dw_mci_edmac_exit(struct dw_mci *host)
 {
-        dma_release_channel(host->dms->ch);
-        host->dms->ch = NULL;
-
         if (NULL != host->dms) {
+                if (NULL != host->dms->ch) {
+                        dma_release_channel(host->dms->ch);
+                        host->dms->ch = NULL;
+                }
                 kfree(host->dms);
                 host->dms = NULL;
         }
@@ -1696,6 +1697,8 @@ static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb)
        u32 int_mask;
        u32 sdio_int;
 
+        spin_lock_bh(&host->lock);
+
        /* Enable/disable Slot Specific SDIO interrupt */
        int_mask = mci_readl(host, INTMASK);
 
@@ -1719,6 +1722,8 @@ static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb)
                mci_writel(host, INTMASK,
                           (int_mask & ~sdio_int));
        }
+
+       spin_unlock_bh(&host->lock);
 }
 
 #ifdef CONFIG_MMC_DW_ROCKCHIP_SWITCH_VOLTAGE