Skip to content

Commit d1e4f74

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci: Do not use spin lock in set_ios paths
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>
1 parent 0c62e67 commit d1e4f74

File tree

7 files changed

+1
-37
lines changed

7 files changed

+1
-37
lines changed

drivers/mmc/host/sdhci-msm.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -991,12 +991,8 @@ static void sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
991991
mmc_hostname(host->mmc), host->clock, uhs, ctrl_2);
992992
sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
993993

994-
spin_unlock_irq(&host->lock);
995-
996994
if (mmc->ios.timing == MMC_TIMING_MMC_HS400)
997995
sdhci_msm_hs400(host, &mmc->ios);
998-
999-
spin_lock_irq(&host->lock);
1000996
}
1001997

1002998
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)
10891085
goto out;
10901086
}
10911087

1092-
spin_unlock_irq(&host->lock);
1093-
10941088
sdhci_msm_hc_select_mode(host);
10951089

10961090
msm_set_clock_rate_for_bus_mode(host, clock);
1097-
1098-
spin_lock_irq(&host->lock);
10991091
out:
11001092
__sdhci_msm_set_clock(host, clock);
11011093
}

drivers/mmc/host/sdhci-of-arasan.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,7 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
194194
* through low speeds without power cycling.
195195
*/
196196
sdhci_set_clock(host, host->max_clk);
197-
spin_unlock_irq(&host->lock);
198197
phy_power_on(sdhci_arasan->phy);
199-
spin_lock_irq(&host->lock);
200198
sdhci_arasan->is_phy_on = true;
201199

202200
/*
@@ -215,18 +213,14 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
215213
}
216214

217215
if (ctrl_phy && sdhci_arasan->is_phy_on) {
218-
spin_unlock_irq(&host->lock);
219216
phy_power_off(sdhci_arasan->phy);
220-
spin_lock_irq(&host->lock);
221217
sdhci_arasan->is_phy_on = false;
222218
}
223219

224220
sdhci_set_clock(host, clock);
225221

226222
if (ctrl_phy) {
227-
spin_unlock_irq(&host->lock);
228223
phy_power_on(sdhci_arasan->phy);
229-
spin_lock_irq(&host->lock);
230224
sdhci_arasan->is_phy_on = true;
231225
}
232226
}

drivers/mmc/host/sdhci-of-at91.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode,
9898
if (!IS_ERR(host->mmc->supply.vmmc)) {
9999
struct mmc_host *mmc = host->mmc;
100100

101-
spin_unlock_irq(&host->lock);
102101
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
103-
spin_lock_irq(&host->lock);
104102
}
105103
sdhci_set_power_noreg(host, mode, vdd);
106104
}

drivers/mmc/host/sdhci-pci-core.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,6 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
484484
if (mode == MMC_POWER_OFF)
485485
return;
486486

487-
spin_unlock_irq(&host->lock);
488-
489487
/*
490488
* Bus power might not enable after D3 -> D0 transition due to the
491489
* 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,
498496
reg |= SDHCI_POWER_ON;
499497
sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
500498
}
501-
502-
spin_lock_irq(&host->lock);
503499
}
504500

505501
static const struct sdhci_ops sdhci_intel_byt_ops = {

drivers/mmc/host/sdhci-pxav3.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,8 @@ static void pxav3_set_power(struct sdhci_host *host, unsigned char mode,
323323
if (host->pwr == 0)
324324
vdd = 0;
325325

326-
if (!IS_ERR(mmc->supply.vmmc)) {
327-
spin_unlock_irq(&host->lock);
326+
if (!IS_ERR(mmc->supply.vmmc))
328327
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
329-
spin_lock_irq(&host->lock);
330-
}
331328
}
332329

333330
static const struct sdhci_ops pxav3_sdhci_ops = {

drivers/mmc/host/sdhci-s3c.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
190190
* speed possible with selected clock source and skip the division.
191191
*/
192192
if (ourhost->no_divider) {
193-
spin_unlock_irq(&ourhost->host->lock);
194193
rate = clk_round_rate(clksrc, wanted);
195-
spin_lock_irq(&ourhost->host->lock);
196194
return wanted - rate;
197195
}
198196

@@ -389,9 +387,7 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
389387
clk &= ~SDHCI_CLOCK_CARD_EN;
390388
sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
391389

392-
spin_unlock_irq(&host->lock);
393390
ret = clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
394-
spin_lock_irq(&host->lock);
395391
if (ret != 0) {
396392
dev_err(dev, "%s: failed to set clock rate %uHz\n",
397393
mmc_hostname(host->mmc), clock);

drivers/mmc/host/sdhci.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,9 +1361,7 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk)
13611361
sdhci_dumpregs(host);
13621362
return;
13631363
}
1364-
spin_unlock_irq(&host->lock);
13651364
udelay(10);
1366-
spin_lock_irq(&host->lock);
13671365
}
13681366

13691367
clk |= SDHCI_CLOCK_CARD_EN;
@@ -1392,9 +1390,7 @@ static void sdhci_set_power_reg(struct sdhci_host *host, unsigned char mode,
13921390
{
13931391
struct mmc_host *mmc = host->mmc;
13941392

1395-
spin_unlock_irq(&host->lock);
13961393
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
1397-
spin_lock_irq(&host->lock);
13981394

13991395
if (mode != MMC_POWER_OFF)
14001396
sdhci_writeb(host, SDHCI_POWER_ON, SDHCI_POWER_CONTROL);
@@ -1574,16 +1570,12 @@ EXPORT_SYMBOL_GPL(sdhci_set_uhs_signaling);
15741570
static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
15751571
{
15761572
struct sdhci_host *host = mmc_priv(mmc);
1577-
unsigned long flags;
15781573
u8 ctrl;
15791574

15801575
if (ios->power_mode == MMC_POWER_UNDEFINED)
15811576
return;
15821577

1583-
spin_lock_irqsave(&host->lock, flags);
1584-
15851578
if (host->flags & SDHCI_DEVICE_DEAD) {
1586-
spin_unlock_irqrestore(&host->lock, flags);
15871579
if (!IS_ERR(mmc->supply.vmmc) &&
15881580
ios->power_mode == MMC_POWER_OFF)
15891581
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)
17291721
sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
17301722

17311723
mmiowb();
1732-
spin_unlock_irqrestore(&host->lock, flags);
17331724
}
17341725

17351726
static int sdhci_get_cd(struct mmc_host *mmc)

0 commit comments

Comments
 (0)