From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10F16606EEA0 for ; Wed, 4 Nov 2026 15:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=qssxaiZz; 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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=SHiodlaN/47Q9sQElac/FcGmKIxlHSOhqHHn7r3qETE=; b=qssxaiZzo2RjvU k4sGwYA4yxA15H9lUhyfxYet3AoWDLiirly+kgIiiLf2WjROzjtoFvSPN3k4FRkp6KLVMan+VcX/L g9ZDbXAc56Hrae+4NCvtC2yGQtoeaad24owIO37+ZiOYYD0BCOngUXREM54zIe3aieI0zIWLV73Oj T2e+i8mAKo1i4CvEOrHDjdMX6MUgaxVBioyhpgxFd9iGapMf/qHmPsFI3rdN2XjVV5MDTfkiDm5XO IXDgFttH9QMx21MQBahuYhL7I1C9dSWlvL8E6ik4L+Agf5tmhw5W/g6Ohwoncn+Rv6BXIJNaatslc 3C8goKT+WFhAykjnXQ9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOctZ-00000005mOh-1aRX; Wed, 04 Nov 2026 15:27:25 +0000 Received: from mout02.posteo.de ([185.67.36.66]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOctW-00000005mNL-3eNQ for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2026 15:27:24 +0000 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 1D7B8240105 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-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261104_072723_060963_7CD9BD09 X-CRM114-Status: GOOD ( 13.43 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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