Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b4f1f6c authored by Russell King's avatar Russell King Committed by Chris Ball
Browse files

mmc: sdhci: plug hole in disabling card detection interrupts



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: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Tested-by: default avatarMarkus Pargmann <mpa@pengutronix.de>
Tested-by: default avatarStephen Warren <swarren@nvidia.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarChris Ball <chris@printf.net>
parent b537f94c
Loading
Loading
Loading
Loading
+9 −8
Original line number Original line Diff line number Diff line
@@ -133,20 +133,21 @@ static void sdhci_dumpregs(struct sdhci_host *host)


static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
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) ||
	if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
	    (host->mmc->caps & MMC_CAP_NONREMOVABLE))
	    (host->mmc->caps & MMC_CAP_NONREMOVABLE))
		return;
		return;


	if (enable) {
		present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
		present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
				      SDHCI_CARD_PRESENT;
				      SDHCI_CARD_PRESENT;
	irqs = present ? SDHCI_INT_CARD_REMOVE : SDHCI_INT_CARD_INSERT;


	if (enable)
		host->ier |= present ? SDHCI_INT_CARD_REMOVE :
		host->ier |= irqs;
				       SDHCI_INT_CARD_INSERT;
	else
	} else {
		host->ier &= ~irqs;
		host->ier &= ~(SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT);
	}


	sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
	sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);