Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: sdhci: Do not lock spinlock around mmc_gpio_get_ro()

sdhci_check_ro() can call mmc_gpio_get_ro() while holding the sdhci
host->lock spinlock. That would be a problem if the GPIO access done by
mmc_gpio_get_ro() needed to sleep.

However, host->lock is not needed anyway. The mmc core ensures that host
operations do not race with each other, and asynchronous callbacks like the
interrupt handler, software timeouts, completion work etc, cannot affect
sdhci_check_ro().

So remove the locking.

Fixes: 6d5cd068ee59 ("mmc: sdhci: use WP GPIO in sdhci_check_ro()")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240614080051.4005-3-adrian.hunter@intel.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Adrian Hunter and committed by
Ulf Hansson
ab069ce1 fbd64f90

-5
-5
drivers/mmc/host/sdhci.c
··· 2516 2516 static int sdhci_check_ro(struct sdhci_host *host) 2517 2517 { 2518 2518 bool allow_invert = false; 2519 - unsigned long flags; 2520 2519 int is_readonly; 2521 - 2522 - spin_lock_irqsave(&host->lock, flags); 2523 2520 2524 2521 if (host->flags & SDHCI_DEVICE_DEAD) { 2525 2522 is_readonly = 0; ··· 2531 2534 & SDHCI_WRITE_PROTECT); 2532 2535 allow_invert = true; 2533 2536 } 2534 - 2535 - spin_unlock_irqrestore(&host->lock, flags); 2536 2537 2537 2538 if (is_readonly >= 0 && 2538 2539 allow_invert &&