Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2902706pxb; Tue, 24 Aug 2021 10:13:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx5+SZq6QxSyXKWQosRt5gODWXP6mybQPjo3f/t66R8+37JJm+n73lMb5/qMuM7Uaa9gl+ X-Received: by 2002:a92:d3c1:: with SMTP id c1mr27622356ilh.194.1629825222846; Tue, 24 Aug 2021 10:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629825222; cv=none; d=google.com; s=arc-20160816; b=tKsVRPNbD1iIXELmD1mApfGDA+7ZU1oOo229ppI/5KyYvyOWxa81QMPmnnfTTgGjmq Xdro/UQ6TyftyiQ8bjBPG3FwOaA9ZM1AZaKEFY8p239JqG0NdNT7jQavoofK78S6OkRL eGa9QH90pbO98QljjZxRbPnvrzWgUDIVmbaH+1HmgIwSh4h30p91wGSiVpQhkU/fQdte dZUpv4dGyHBGKZFDqboz6t78nr//7ARF3/n+4i3IXzU4OX4qDjCDt85AmWswscoxtbzp 9qpcNSoQnn7jsw/JTyqZnzOUEu3ZJn/sapK2rgYygNaiVwZgK6/KMEaDFCtM9qmeKOSc bz6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jSU5Ofzs2anurYcpNdmViwPHHyHefVywpyPRPrj6YXo=; b=jSAv+jbjJTLYel9KP6rp3qYemolpmAkjrpookl8krCh7tSIu/MPlL0PVWys4nYy0dW BKZuIxGxyZxnVDhq63u3hv2X5753ZonAZxB26u0XeYBx6RYdyX0TWMUXUHRsjgFHCdXM EMmoUWOGAO9pIdrIXlFF04sHqzxzGxY6PxnqkFRXfavxRxCcbiQHBBKliKUI36RGzh+a nfGTHuJccpsHr2aSpD1HVp7Aaf2sLJsaV9UUCEaLMdPGAWtaMLUwL3MLVU0cGBiZouzg b5437EhSG2i/gzdAvMOQ4zBhx68L1+F53yvt/KKrBtifigOSfn4opHmolbHbjhCOqJ1l JPlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="c6/zMwfH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e11si17383978iot.82.2021.08.24.10.13.30; Tue, 24 Aug 2021 10:13:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="c6/zMwfH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239863AbhHXRMW (ORCPT + 99 others); Tue, 24 Aug 2021 13:12:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:52376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239874AbhHXRJl (ORCPT ); Tue, 24 Aug 2021 13:09:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6BD2E6147F; Tue, 24 Aug 2021 17:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824424; bh=rFWVkTbFx0XTXndnBQgZe6MHT/XWE9zLb9BHU1Gz09o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c6/zMwfHx6Ak7XRvXUaVMe+48UMdtvJeX01qWFXrn2wEAiHct4nrluUBvJ8wPYxNB uJVMnhoKWgSuKX88P/LrR8Okp0veRvdJv9a0uLLnGXbRkZMX8hvhYTxgxV6UfD1jTX Gg4SubjyTv+tKoQUucWXM4BK6CxpwExHM0Kt2y5RLKiHsekaBOWmsz0Mq7YE7Mr0bZ Z8oqhZvMpdCGDhOLvj9ucK1dqRXkfUYbWxp1QRuRlOUPEmD4WP0mYCljqXryatW7aU oKqkLndmew1q6FlTkTqwx+mdg+o7/K3b8gqQ9X6saJmi34T2WxKcPAimpD7KPkX/MI DOu1ATaBhVvTA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christophe Kerello , Yann Gautier , Ulf Hansson , Sasha Levin Subject: [PATCH 5.10 74/98] mmc: mmci: stm32: Check when the voltage switch procedure should be done Date: Tue, 24 Aug 2021 12:58:44 -0400 Message-Id: <20210824165908.709932-75-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165908.709932-1-sashal@kernel.org> References: <20210824165908.709932-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.61-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.61-rc1 X-KernelTest-Deadline: 2021-08-26T16:58+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Kerello [ Upstream commit d8e193f13b07e6c0ffaa1a999386f1989f2b4c5e ] If the card has not been power cycled, it may still be using 1.8V signaling. This situation is detected in mmc_sd_init_card function and should be handled in mmci stm32 variant. The host->pwr_reg variable is also correctly protected with spin locks. Fixes: 94b94a93e355 ("mmc: mmci_sdmmc: Implement signal voltage callbacks") Signed-off-by: Christophe Kerello Signed-off-by: Yann Gautier Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210701143353.13188-1-yann.gautier@foss.st.com Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/mmci_stm32_sdmmc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/mmci_stm32_sdmmc.c b/drivers/mmc/host/mmci_stm32_sdmmc.c index 51db30acf4dc..fdaa11f92fe6 100644 --- a/drivers/mmc/host/mmci_stm32_sdmmc.c +++ b/drivers/mmc/host/mmci_stm32_sdmmc.c @@ -479,8 +479,9 @@ static int sdmmc_post_sig_volt_switch(struct mmci_host *host, u32 status; int ret = 0; - if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180) { - spin_lock_irqsave(&host->lock, flags); + spin_lock_irqsave(&host->lock, flags); + if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180 && + host->pwr_reg & MCI_STM32_VSWITCHEN) { mmci_write_pwrreg(host, host->pwr_reg | MCI_STM32_VSWITCH); spin_unlock_irqrestore(&host->lock, flags); @@ -492,9 +493,11 @@ static int sdmmc_post_sig_volt_switch(struct mmci_host *host, writel_relaxed(MCI_STM32_VSWENDC | MCI_STM32_CKSTOPC, host->base + MMCICLEAR); + spin_lock_irqsave(&host->lock, flags); mmci_write_pwrreg(host, host->pwr_reg & ~(MCI_STM32_VSWITCHEN | MCI_STM32_VSWITCH)); } + spin_unlock_irqrestore(&host->lock, flags); return ret; } -- 2.30.2