From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 68A4E516148; Wed, 30 Sep 2026 17:18:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790788737; cv=none; b=jIPGk5BmNwgvlObDR/7YL/7sFp/m2AMFMSkbDQZBttC0T0c8Dfz6mstsQXpdaqz+AWVjDevctsn2J0Q+juMOVk8Dap7XLcDVDsZRUUK2wu4OxIdTFk8MsR2gJwLUjuBfBZ5N4AQ/n54DGR3J0wIS4YsJDV2GLDIUSyAgujS1uV8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790788737; c=relaxed/simple; bh=cqpY+E4WHvcClENL5WmjfS/CfiUNU2SF13jfsJjcjB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bC152zDm7f5FkffEtJNnuIivOihWYZqFP6wfZ0MfW64Nlvczl+uendqf6T8FrkOdAqAHILNXN7O07iObz1aTGrKJBLJdaWoToKxToUxChAcujypCq9TXF153Q2i26QWZ5bs9XPSVdJVEA+5WfYmf3rWHQKAHRTzH1wiUknIadns= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ttnIDWrI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ttnIDWrI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3C661F000FF; Wed, 30 Sep 2026 17:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790788736; bh=itNrRBuPG1SKHnYtuwmQouN8+NMNnBlY39mzgZ1OEHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ttnIDWrI3I1Y6l7N7F7jvxM5eK0OFHTnhksR/8bJRTC8uqC+sN6dXJe2iuUwY93oL KptlGTclMXg1ufiFm9Wm5Du+iWeZOlEiAHENBRatRm9QXnbsA/ihZ5RRbOJTJSj8hS BWMeSiPLmZ0Se+kv6GFHKokEt9MsLoC+J8xFH6lU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xu Rao , Ulf Hansson Subject: [PATCH 6.12 230/877] mmc: spi: reset bytes_xfered before retrying CRC failures Date: Wed, 30 Sep 2026 17:19:01 +0200 Message-ID: <20260930152419.691398559@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152414.738996857@linuxfoundation.org> References: <20260930152414.738996857@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xu Rao commit 8b0cc8707f65e0f51912e764e1b309b2559db1ec upstream. mmc_spi_data_do() updates data->bytes_xfered after each block has been transferred successfully. If a later block in the same data request fails with a CRC error, data->bytes_xfered may therefore contain the number of bytes completed before the failing block. mmc_spi_request() has a private recovery path for such CRC failures. It sends STOP_TRANSMISSION, clears data->error and jumps back to crc_recover to issue the same command and data request again. However, it does not clear data->bytes_xfered before the retry. If the retry succeeds, the request is completed with the bytes from the failed attempt still included in data->bytes_xfered. For a multi-block request this can make the completed request report more bytes than were transferred by the successful retry, and can even exceed the request size when most blocks completed before the CRC error. This is most likely to be observed on MMC-over-SPI systems where long multi-block transfers occasionally hit a data CRC error but the mmc_spi-internal retry succeeds. The data itself is retried, but the completion accounting is not. Clear data->bytes_xfered together with data->error before repeating the request so the final completion reports only the bytes transferred by the successful attempt. Fixes: 061c6c847eeb ("mmc_spi: Recover from CRC errors for r/w operation over SPI.") Cc: stable@vger.kernel.org Signed-off-by: Xu Rao Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/mmc_spi.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c @@ -952,6 +952,7 @@ crc_recover: status = mmc_spi_command_send(host, mrq, &stop, 0); crc_retry--; mrq->data->error = 0; + mrq->data->bytes_xfered = 0; goto crc_recover; }