From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A8C32236EA; Thu, 12 Dec 2024 17:48:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734025716; cv=none; b=D4Wat+sNbuka5N5p5631dFvGOGR9CWyzV4jrg6WnCMvkK0oH6ehwdlD8q/ZA1chY44lpI2fxdLJqADH11jWgUwbR9pRMvbkxMjCabTk8QCpaXLU1YjJqkPZgN7T1T9lzTNF2N1TbKbuNTSwBVWU6LLrU38dodvvQzba2WMkT9SM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734025716; c=relaxed/simple; bh=GjzuLaoJKvSuZfNB25CnAMk9xLLkRPe6fTQZ1YxQVk4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BYU/9vXzeMsGpyY5ObU9bshgAB0PCYheijFIw7n9WjZwnXHhdm6zbWC3hJBDo/D3lohH8WZhOrugypxw1gSyQY5DkcFMg2WE7HuNSjZN78tkZzNI/gOEKJl2AQlWLqsMK6r5CKdscioxnfSHZjLeOA7xdeAV4WCv2dA6jn2ChQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SiOHnnvx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="SiOHnnvx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3F10C4CEDE; Thu, 12 Dec 2024 17:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734025716; bh=GjzuLaoJKvSuZfNB25CnAMk9xLLkRPe6fTQZ1YxQVk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SiOHnnvxSXPRrP+GWCbj7U5gmRe0Iw0YhqCQUN8KSc9HWAHTSgdzkiq65bjECZZle zRQGoeOtiyXKiza91ft2a+miCuz+uX0C+1j5OJqv2iHN3rDlKfn9I9R4qiJEvwIudi iT5EAHGWObH96SHxlgSxOGSTgnMytCRR7/7ulSfk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Anthony Pighin , Ulf Hansson , Adrian Hunter Subject: [PATCH 5.4 263/321] mmc: core: Further prevent card detect during shutdown Date: Thu, 12 Dec 2024 16:03:01 +0100 Message-ID: <20241212144240.372951836@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144229.291682835@linuxfoundation.org> References: <20241212144229.291682835@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ulf Hansson commit 87a0d90fcd31c0f36da0332428c9e1a1e0f97432 upstream. Disabling card detect from the host's ->shutdown_pre() callback turned out to not be the complete solution. More precisely, beyond the point when the mmc_bus->shutdown() has been called, to gracefully power off the card, we need to prevent card detect. Otherwise the mmc_rescan work may poll for the card with a CMD13, to see if it's still alive, which then will fail and hang as the card has already been powered off. To fix this problem, let's disable mmc_rescan prior to power off the card during shutdown. Reported-by: Anthony Pighin Fixes: 66c915d09b94 ("mmc: core: Disable card detect during shutdown") Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson Reviewed-by: Adrian Hunter Closes: https://lore.kernel.org/all/BN0PR08MB695133000AF116F04C3A9FFE83212@BN0PR08MB6951.namprd08.prod.outlook.com/ Tested-by: Anthony Pighin Message-ID: <20241125122446.18684-1-ulf.hansson@linaro.org> Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/core/bus.c | 2 ++ drivers/mmc/core/core.c | 3 +++ 2 files changed, 5 insertions(+) --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -134,6 +134,8 @@ static void mmc_bus_shutdown(struct devi if (dev->driver && drv->shutdown) drv->shutdown(card); + __mmc_stop_host(host); + if (host->bus_ops->shutdown) { ret = host->bus_ops->shutdown(host); if (ret) --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2382,6 +2382,9 @@ void mmc_start_host(struct mmc_host *hos void __mmc_stop_host(struct mmc_host *host) { + if (host->rescan_disable) + return; + if (host->slot.cd_irq >= 0) { mmc_gpio_set_cd_wake(host, false); disable_irq(host->slot.cd_irq);