mmc: sdhci: Do not use spin lock in set_ios paths
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 20 Mar 2017 17:50:37 +0000 (19:50 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 24 Apr 2017 19:41:29 +0000 (21:41 +0200)
The spin lock is not necessary in set_ios. Anything that is racing with
changes to the I/O state is already broken. The mmc core already provides
synchronization via "claiming" the host. So remove spin_lock and friends
from sdhci_set_ios and related callbacks.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
drivers/mmc/host/sdhci-msm.c
drivers/mmc/host/sdhci-of-arasan.c
drivers/mmc/host/sdhci-of-at91.c
drivers/mmc/host/sdhci-pci-core.c
drivers/mmc/host/sdhci-pxav3.c
drivers/mmc/host/sdhci-s3c.c
drivers/mmc/host/sdhci.c

index 10cdc84d51136694d8e95413b754d5f6d26ace48..9d601dc0d64605e312b984fc98b556077a1167ba 100644 (file)
@@ -991,12 +991,8 @@ static void sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
                mmc_hostname(host->mmc), host->clock, uhs, ctrl_2);
        sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
 
-       spin_unlock_irq(&host->lock);
-
        if (mmc->ios.timing == MMC_TIMING_MMC_HS400)
                sdhci_msm_hs400(host, &mmc->ios);
-
-       spin_lock_irq(&host->lock);
 }
 
 static void sdhci_msm_voltage_switch(struct sdhci_host *host)
@@ -1089,13 +1085,9 @@ static void sdhci_msm_set_clock(struct sdhci_host *host, unsigned int clock)
                goto out;
        }
 
-       spin_unlock_irq(&host->lock);
-
        sdhci_msm_hc_select_mode(host);
 
        msm_set_clock_rate_for_bus_mode(host, clock);
-
-       spin_lock_irq(&host->lock);
 out:
        __sdhci_msm_set_clock(host, clock);
 }
index 28feb5367c1459392803eae932df154cabe86d22..61accf0d4739215be4a46e6a43d4a869435fc92b 100644 (file)
@@ -194,9 +194,7 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
                         * through low speeds without power cycling.
                         */
                        sdhci_set_clock(host, host->max_clk);
-                       spin_unlock_irq(&host->lock);
                        phy_power_on(sdhci_arasan->phy);
-                       spin_lock_irq(&host->lock);
                        sdhci_arasan->is_phy_on = true;
 
                        /*
@@ -215,18 +213,14 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
        }
 
        if (ctrl_phy && sdhci_arasan->is_phy_on) {
-               spin_unlock_irq(&host->lock);
                phy_power_off(sdhci_arasan->phy);
-               spin_lock_irq(&host->lock);
                sdhci_arasan->is_phy_on = false;
        }
 
        sdhci_set_clock(host, clock);
 
        if (ctrl_phy) {
-               spin_unlock_irq(&host->lock);
                phy_power_on(sdhci_arasan->phy);
-               spin_lock_irq(&host->lock);
                sdhci_arasan->is_phy_on = true;
        }
 }
index 3f08b7ebec438b5635b8fdb2626be8bd6435224d..7611fd679f1ad83d7dee4052aebb6e9f6d3168cf 100644 (file)
@@ -98,9 +98,7 @@ static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode,
        if (!IS_ERR(host->mmc->supply.vmmc)) {
                struct mmc_host *mmc = host->mmc;
 
-               spin_unlock_irq(&host->lock);
                mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
-               spin_lock_irq(&host->lock);
        }
        sdhci_set_power_noreg(host, mode, vdd);
 }
index 5c620206138edc576b95f31d2a3008c4928129e0..98ed90cbd9b4b0ec65c1766dcc6106a24ba5ed37 100644 (file)
@@ -484,8 +484,6 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
        if (mode == MMC_POWER_OFF)
                return;
 
-       spin_unlock_irq(&host->lock);
-
        /*
         * Bus power might not enable after D3 -> D0 transition due to the
         * present state not yet having propagated. Retry for up to 2ms.
@@ -498,8 +496,6 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
                reg |= SDHCI_POWER_ON;
                sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
        }
-
-       spin_lock_irq(&host->lock);
 }
 
 static const struct sdhci_ops sdhci_intel_byt_ops = {
index 22ed90433d291cf5e258ce8de4fee40e706fc211..f953f35c26247ff60584070c23a5f04473cffc6f 100644 (file)
@@ -323,11 +323,8 @@ static void pxav3_set_power(struct sdhci_host *host, unsigned char mode,
        if (host->pwr == 0)
                vdd = 0;
 
-       if (!IS_ERR(mmc->supply.vmmc)) {
-               spin_unlock_irq(&host->lock);
+       if (!IS_ERR(mmc->supply.vmmc))
                mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
-               spin_lock_irq(&host->lock);
-       }
 }
 
 static const struct sdhci_ops pxav3_sdhci_ops = {
index d02284da2ec612e6671630e2fdacedcefcd45d8a..7c065a70f92bc7cc81418439aad311ece8ba1036 100644 (file)
@@ -190,9 +190,7 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
         * speed possible with selected clock source and skip the division.
         */
        if (ourhost->no_divider) {
-               spin_unlock_irq(&ourhost->host->lock);
                rate = clk_round_rate(clksrc, wanted);
-               spin_lock_irq(&ourhost->host->lock);
                return wanted - rate;
        }
 
@@ -389,9 +387,7 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
        clk &= ~SDHCI_CLOCK_CARD_EN;
        sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
 
-       spin_unlock_irq(&host->lock);
        ret = clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
-       spin_lock_irq(&host->lock);
        if (ret != 0) {
                dev_err(dev, "%s: failed to set clock rate %uHz\n",
                        mmc_hostname(host->mmc), clock);
index e055bd3f5fe8101545a0799a3c4bcd6f2cd79b77..5c2b35dd1c456347131bd51df3175df6e66ca233 100644 (file)
@@ -1361,9 +1361,7 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk)
                        sdhci_dumpregs(host);
                        return;
                }
-               spin_unlock_irq(&host->lock);
                udelay(10);
-               spin_lock_irq(&host->lock);
        }
 
        clk |= SDHCI_CLOCK_CARD_EN;
@@ -1392,9 +1390,7 @@ static void sdhci_set_power_reg(struct sdhci_host *host, unsigned char mode,
 {
        struct mmc_host *mmc = host->mmc;
 
-       spin_unlock_irq(&host->lock);
        mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
-       spin_lock_irq(&host->lock);
 
        if (mode != MMC_POWER_OFF)
                sdhci_writeb(host, SDHCI_POWER_ON, SDHCI_POWER_CONTROL);
@@ -1574,16 +1570,12 @@ EXPORT_SYMBOL_GPL(sdhci_set_uhs_signaling);
 static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
        struct sdhci_host *host = mmc_priv(mmc);
-       unsigned long flags;
        u8 ctrl;
 
        if (ios->power_mode == MMC_POWER_UNDEFINED)
                return;
 
-       spin_lock_irqsave(&host->lock, flags);
-
        if (host->flags & SDHCI_DEVICE_DEAD) {
-               spin_unlock_irqrestore(&host->lock, flags);
                if (!IS_ERR(mmc->supply.vmmc) &&
                    ios->power_mode == MMC_POWER_OFF)
                        mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
@@ -1729,7 +1721,6 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
                sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
 
        mmiowb();
-       spin_unlock_irqrestore(&host->lock, flags);
 }
 
 static int sdhci_get_cd(struct mmc_host *mmc)