Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4396734pxb; Mon, 21 Feb 2022 20:13:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxw2J4YpytKyqc++qmKhWc7Qq5cLrdu9p5s582Abu7oKTh+SUJ8+mYc1LRAijCUfNocXNgV X-Received: by 2002:a63:1554:0:b0:363:794c:9e31 with SMTP id 20-20020a631554000000b00363794c9e31mr18415414pgv.66.1645503203124; Mon, 21 Feb 2022 20:13:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645503203; cv=none; d=google.com; s=arc-20160816; b=fkZDnl6/o/6lGQzvB7iRwyirqBKhxqF4onL/Lhkq9DQNABNzaJPBnv+qiBJc0G45hA kSc9QBPGc0yWWNOBjubZd8MGsfxJcPhILBYZvSwR2IRlsa/6hPMDP28CycL0YUQnCbnq J3guhVZht+IE9SVejlWp2jXzvlD9D/YxnPgpNfL8U5pUHMNfc1GIwVg9OOC5y+Gj5nU+ H7QjCXxyAHuGf+N6lo2F4o83WjTUPV4vZ4ZMXBbDPaZSN438XNT1LWWc5e2VFy6bL3nn a6LNt4kOcrTdgQ5pFilMRF1njHkzv+lJX6/NOhpPzY62SInA7y8TFEoBemYWob/NQhLV yieA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iNLB3aAyUWROcXJ6fbjWKOmMx3sqm7dbWJJRGG0KQ5M=; b=EWc+IihJXvTmWxW2rWD19Jid5ArfnmTF0cf/R9+qSd/ElWI/MvTgZNvzCXfmovh26w GBzxCF+Ix3E51JoyHNmVMyZe/Fa7CfnYT8yMrIonFSePjDZAkKor4vP6pd6Wo4Qm3mrc bPcJeYX2+s4gk6oPcqgOIGZrcdFmaa5oYAul1XpBd1OqQhr7PCuu6VgS/G9EQQpdhVFn 9148XWiXpCd3BCWoKZQ53WbunokH0hkJy5aYIA6u1wS6OQrtReE4nuLBqrp7bSlphNWQ O/nuRNQPtvJLej9alds3y8CBDKSjKlZtFXCyORg9Wk8AipIZHzd9jeCAd8V8P+zcRVLB 0K+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1e27++8G; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s10si3897885plq.459.2022.02.21.20.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 20:13:23 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1e27++8G; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 218AD7EB1D; Mon, 21 Feb 2022 20:13:12 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347822AbiBUJKZ (ORCPT + 99 others); Mon, 21 Feb 2022 04:10:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347350AbiBUJFc (ORCPT ); Mon, 21 Feb 2022 04:05:32 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BA7125C5E; Mon, 21 Feb 2022 00:58:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2CC2AB80E72; Mon, 21 Feb 2022 08:58:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61632C340E9; Mon, 21 Feb 2022 08:58:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645433935; bh=miOqyMglvPOrw76ooaKXt1oEIjR+yKYxEFBxaK+Q+I4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1e27++8GBsCYYd38R5DDPWaBdkkBFq5/qxARsiksX/k1Az7rh7B09vgRmd+DcK7EA RcReTvpwqNNS3LKDYMAsIZhaQ1HhNnavnMMafOvhkAQhNQW1a/Ee8VVu69EOgCAkEm KsqLIl6W+TOG8pQxmjvo0Fit4YKhsFdv/lgVa4m4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Loehle , Adrian Hunter , Ulf Hansson Subject: [PATCH 5.4 35/80] mmc: block: fix read single on recovery logic Date: Mon, 21 Feb 2022 09:49:15 +0100 Message-Id: <20220221084916.722372444@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084915.554151737@linuxfoundation.org> References: <20220221084915.554151737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christian Löhle commit 54309fde1a352ad2674ebba004a79f7d20b9f037 upstream. On reads with MMC_READ_MULTIPLE_BLOCK that fail, the recovery handler will use MMC_READ_SINGLE_BLOCK for each of the blocks, up to MMC_READ_SINGLE_RETRIES times each. The logic for this is fixed to never report unsuccessful reads as success to the block layer. On command error with retries remaining, blk_update_request was called with whatever value error was set last to. In case it was last set to BLK_STS_OK (default), the read will be reported as success, even though there was no data read from the device. This could happen on a CRC mismatch for the response, a card rejecting the command (e.g. again due to a CRC mismatch). In case it was last set to BLK_STS_IOERR, the error is reported correctly, but no retries will be attempted. Fixes: 81196976ed946c ("mmc: block: Add blk-mq support") Cc: stable@vger.kernel.org Signed-off-by: Christian Loehle Reviewed-by: Adrian Hunter Link: https://lore.kernel.org/r/bc706a6ab08c4fe2834ba0c05a804672@hyperstone.com Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/core/block.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1671,31 +1671,31 @@ static void mmc_blk_read_single(struct m struct mmc_card *card = mq->card; struct mmc_host *host = card->host; blk_status_t error = BLK_STS_OK; - int retries = 0; do { u32 status; int err; + int retries = 0; - mmc_blk_rw_rq_prep(mqrq, card, 1, mq); + while (retries++ <= MMC_READ_SINGLE_RETRIES) { + mmc_blk_rw_rq_prep(mqrq, card, 1, mq); - mmc_wait_for_req(host, mrq); + mmc_wait_for_req(host, mrq); - err = mmc_send_status(card, &status); - if (err) - goto error_exit; - - if (!mmc_host_is_spi(host) && - !mmc_blk_in_tran_state(status)) { - err = mmc_blk_fix_state(card, req); + err = mmc_send_status(card, &status); if (err) goto error_exit; - } - if (mrq->cmd->error && retries++ < MMC_READ_SINGLE_RETRIES) - continue; + if (!mmc_host_is_spi(host) && + !mmc_blk_in_tran_state(status)) { + err = mmc_blk_fix_state(card, req); + if (err) + goto error_exit; + } - retries = 0; + if (!mrq->cmd->error) + break; + } if (mrq->cmd->error || mrq->data->error ||