From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.67.36.66 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793806043; b=cHaJOzNeo3tbq35SCNKPRCFBsTQzzcaqz40Qkd7H9hoP/tBPRg3OIl/LH/cuQsXDjnA8 y9z6U/+U/+dnWJG0465aTQ7+l9BNT1t4KeILeEvAsKsp0BOUmGF0+r+pLthmp9rPeIYdt JpO6hf2QxcvX0DhjBr4h1D78cuK0K22Eu9SqKCVQQg3isa3Jpy10sWwYIscdeWgvG9ynC lO6je8e0qnAz3GHz9DrOywNCOtQ22bxzv8Puh29XQh+ds1A+ngug3sOKNHbSFIae2qz3s vGBF3LMW5wxBfujCn2S3/YQpGISjVpbrjiyvcLFp8uEgWxAq58309BUtmAKgbyZUkPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793806043; h=DMARC-Filter:Received:DKIM-Signature:Received:From:To:Cc:Subject: Date:Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=SHiodlaN/47Q9sQElac/FcGmKIxlHSOhqHHn7r3qETE=; b=vDnwwYAKVyHJhHZDETrS81u04+gIMHiL+isc0xG/zBjUqm2sxLW5Y4SxIG71KSvRbs10 BT9EEzXa4X7sdZWbcY+FT7GOXePHW1EIfDnHzCSSWjjwmTPyrfjUJ0sQZiCmuOhKuhdP0 VMkEDC+fhsbiRJCNeHtenqNWNDrtpMOxDnKYRaxzn1tQNrgAvbU0WRp1iISmyYS9uklR4 +YbMPgrIfNbUJvJgfDdFe9An4+1B8eKvRuZpQ0+RevlF8KgvgCbMuLr3ODlUC0x4QZ2c7 yjSpOoL3JQgQWL/iVOmZY2xCG/WV/FxuFY42p7oTsd6exa+4ERmlpwr/UF4+i1540Kg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=posteo.net; spf=pass smtp.mailfrom=posteo.net; dkim=pass header.d=posteo.net header.i=@posteo.net header.a=rsa-sha256 header.s=1984.8680eb header.b="I9KYYC/e"; arc=none smtp.remote-ip=185.67.36.66 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) (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 869D6606A334 for ; Wed, 4 Nov 2026 15:27:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 869D6606A334 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=posteo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=posteo.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=posteo.net header.i=@posteo.net header.a=rsa-sha256 header.s=1984.8680eb header.b=I9KYYC/e Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2EC5824010D for ; Wed, 4 Nov 2026 16:27:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.net; s=1984.8680eb; t=1793806039; bh=SHiodlaN/47Q9sQElac/FcGmKIxlHSOhqHHn7r3qETE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=I9KYYC/e+KLAWDoaHEhgolVvi1RNgS3YAtdQC1WfLWpWwGGVnGU0c2hYOiR/F3zUh c6wNGyd1wRwKpM0m9UKXbwbk77qsbe6Y3oeWs4fhQu3r7PkWn1Zt5TvljjXmKT9B3L E5mMDG6V41ORNoxGI+1NelvQ2ciXpdj4QyU7T/V2Xr1am7iMQl2TjfYNzcXHotOe+v m3Zi8U7TMlGuSKJvr7G8PATKXSWubrPD0HT9dkgORmbY++ozHnYhpHh++TAOF0Zv4W SrI/w9jp2u6VV8FUxirkB9wr146WqFAohsjQkPPc+uDhnO/iL3mh16IFb6rzU59hNT sKeTXVvEIn+ng== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4jKTnw7557z9rxV; Wed, 4 Nov 2026 16:27:16 +0100 (CET) From: Mateusz Nowicki To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Mateusz Nowicki , Russell King , Linus Walleij , Yann Gautier , Christophe Kerello , Maxime Coquelin , Alexandre Torgue , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 1/5] mmc: mmci: do not count a data CRC error as a complete transfer Date: Wed, 04 Nov 2026 15:27:18 +0000 Message-ID: <20261104152657.14909-2-mateusz.nowicki@posteo.net> In-Reply-To: <20261104152657.14909-1-mateusz.nowicki@posteo.net> References: <20261104152657.14909-1-mateusz.nowicki@posteo.net> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit With datacnt_useless (STM32 variants) success is 0 on a data error and a CRC error subtracts one from it. bytes_xfered becomes 0xfffffe00 and mmc_blk completes the whole request as successful, although the controller stopped at the failing block. Reads return stale data and writes are lost without any error. Tested on the STM32MP257F-DK eMMC in HS200 with a forced bad tuning: without this change 5 of 14 reads returned zeros, with it all 10 reads were correct. Fixes: b79220b3e0af ("mmc: mmci: add variant property to not read datacnt") Cc: stable@vger.kernel.org Signed-off-by: Mateusz Nowicki --- drivers/mmc/host/mmci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 416bdb184ed4..10eb0439fc52 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1422,8 +1422,9 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ, status 0x%08x at 0x%08x\n", status_err, success); if (status_err & MCI_DATACRCFAIL) { - /* Last block was not successful */ - success -= 1; + /* Last block was not successful, nothing counted when DATACNT is useless */ + if (success) + success -= 1; data->error = -EILSEQ; } else if (status_err & MCI_DATATIMEOUT) { data->error = -ETIMEDOUT; -- 2.56.0