From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385292; b=zAQTqB3df5xX5xg1xzGsWbBDhqMq59Knxm0BOVTBgKhIAH9fdBiOf9+ieMvvetWCw/2s dA4tjX9jQIFnV7F3jP7Tf7hEAMowiPbU8KtwfFMwK+Cx7YBE6lA4jOWuYcKk1IKZKxSjP nEs8fnsYs9siURwx6xP59kit2LxBkYg81+wrYfM6Cj5xTI+qROk3N5HSDXG5R7XhAF+dG CD+k5CTFAD+/iGeISNuEUk5Kc4mbfkG40z81VR4C2cJGip5jrV+vMKgNgRCBsQQnpC1VB LI5/EPzJIkEu3W4XkLlzStWQnuZDPnQoq/YTEHoMrGDD/cmhLlCB7ugG+q1/jjHhprA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385292; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=D6fGMEHkULvJvJa1FbGTHdC9apnZNtXdEvO46ECaaLc=; b=kLLcsyugqto8yYoimK5/65HBr+yG5IOg5CwUOvaM/gyJPLS/eb0LS5t3kCHYhbgcxiaA Ll1zBf+xhNRzfzuLVlQCtNtWglyNWb4hOeWeJU2D/5WiqGAmZW4LBarYnFIdoW2Zj36cp nm9AqA77pB4ixedhURxfNpTfTkxYl4Z4ooN3n2p0tujFEnOCx2ZVjwK3BbNigSkSiElaL Bfoyq3QKd/r3FbXj8Yc4jfTqaFeMtw+4El6UqwxAsnaDFATNIX4yvG0n4BYza+NOxfNcP 4OoFuyRIUUFBb/zN1SNapM3pI4D3vQOwCnDxRtur+2LLqRNvd2ewqBso7uIpm5cI/Ag== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=f7RFfrq2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86DCF606A322; Fri, 4 Dec 2026 11:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=f7RFfrq2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 879BE1F0092C; Fri, 4 Dec 2026 11:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385292; bh=D6fGMEHkULvJvJa1FbGTHdC9apnZNtXdEvO46ECaaLc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f7RFfrq2ih9Qoaq6ejLFrX5dw/WmmsMM5BEsjazAuFw4qnlh5LClsylKGPkO+81l5 A+Vc6iQB9RNonv6rtOuWNJCxEvB87luT2N04L/iiwmXIijGo/VqsxzU8CS9rEeZmtC psMhFjELzZLGjHQljJmnk05fXfseH0ynQNbQGiFc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Igor Velkov , Neil Armstrong , Ulf Hansson Subject: [PATCH 6.6 0494/1167] mmc: meson-gx: honour the busy timeout for R1b commands Date: Fri, 4 Dec 2026 18:58:41 +0900 Message-ID: <20261204100714.930175592@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Igor Velkov commit 7e3cc541aa5855bc36e6cbffa82efc2795955a10 upstream. For a command without data the driver programs a fixed 1024 ms into the CMD_CFG timeout field, and for R1b the controller waits for the card to release busy within that time. The core sends erase and cache flush as R1b with busy timeouts of up to 60 s and 30 s, and the controller gives up after one second: mmc_erase: erase error -110, status 0x0 mmc1: cache flush error -110 Program the timeout from cmd->busy_timeout, kept between 1024 ms, the fixed value until now, and 32768 ms, the most the field holds, and rounded up to a power of two. The clamp comes first: MMC_IOC_CMD passes cmd_timeout_ms from user space straight into busy_timeout, and roundup_pow_of_two() of a value above 2^31 does not fit in unsigned int. sdhci takes its command timeout from cmd->busy_timeout in the same way. Fixes: 51c5d8447bd7 ("MMC: meson: initial support for GX platforms") Cc: stable@vger.kernel.org Signed-off-by: Igor Velkov Reviewed-by: Neil Armstrong Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/meson-gx-mmc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -214,6 +214,20 @@ static unsigned int meson_mmc_get_timeou return min(timeout, 32768U); /* max. 2^15 ms */ } +/* For R1b the controller waits for busy to be released within this timeout. */ +static unsigned int meson_mmc_get_cmd_timeout_msecs(struct mmc_command *cmd) +{ + unsigned int timeout = cmd->busy_timeout; + + if (!timeout) + return SD_EMMC_CMD_TIMEOUT; + + timeout = clamp_t(unsigned int, timeout, SD_EMMC_CMD_TIMEOUT, + SD_EMMC_CMD_TIMEOUT_MAX); + + return roundup_pow_of_two(timeout); +} + static struct mmc_command *meson_mmc_get_next_command(struct mmc_command *cmd) { if (cmd->opcode == MMC_SET_BLOCK_COUNT && !cmd->error) @@ -840,7 +854,7 @@ static void meson_mmc_start_cmd(struct m cmd_data = host->bounce_dma_addr & CMD_DATA_MASK; } else { cmd_cfg |= FIELD_PREP(CMD_CFG_TIMEOUT_MASK, - ilog2(SD_EMMC_CMD_TIMEOUT)); + ilog2(meson_mmc_get_cmd_timeout_msecs(cmd))); } /* Last descriptor */