Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3259650rwb; Mon, 15 Aug 2022 22:33:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR6hW9Mpz+k67WJ8blFpbTAV16uD9wekQR72lFTOMj5o9Q7XCEwitnX0Uv6+icx7FvdaLGrg X-Received: by 2002:a17:90a:bb15:b0:1f2:2a7d:7e05 with SMTP id u21-20020a17090abb1500b001f22a7d7e05mr22343659pjr.70.1660628013409; Mon, 15 Aug 2022 22:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660628013; cv=none; d=google.com; s=arc-20160816; b=UwTPX64OURaaubpgwCbMF85rNY6XXJEnft5SgKi3Ci7oBMK0z5TSOyE0fsABiqnp+o rho9bFHkHE2luYXk/xxaeNRf4ZtlTXLatv1edky2w7p6cyMJyZIvCJLqC0ilaEu/zP7g oLArfXYwBSXdMrVI0OIxJzVM4oLc7VTJb0Bmwtg6kH4LxzDdOA84tmsjJHGRaAnwjnvU IXFY/ZlhKCnWdicjgPfkZotQUsErCsqlKVfvkVUhSF2xyKIpQwC0QUCYZ+xoqPaWYyuw oNv3jJoB0h7WwwjIG2sdYIHwLAX7rIWVtB1u2BeSYoIi1rkVSDMBNUzpWYUzMX+zSl5r 0f6w== 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=PKEKJfx0ESzbffcUrx9g2NzvzMHmc66f7YzKww06fic=; b=oEvJqrLvRqKZux0+bRvW4f06ytGFuQecUeohlXo9LgE+QCCfwW1e5S4cJXcXps8Kf5 6xY1I0gk5VxuyABOuIEIg6cS1cyMHowxY9gBeGt02eElnC6KjCpPa0M/zt6wparU7t7v 0n/k3rga376uy5ob+GN0k3h/VUuW5UlSCzNMmjM27JeO0+Kl611kQdwXV1T+c2OnILsP MwFvrxneI/Hq3bSiJ7Au5LbXXcMtFbZM3YJxOWLldEm0ajmmEUuEv+oItW28iCUwdooV 17MefOZshYUt7dziSGjTd637cuAyaNPMKRPAY8R92jW/L7xtH1+4y01aA/71xMDVZJgk qOEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jx7yfPAv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h69-20020a636c48000000b004206ecd8fabsi12763050pgc.781.2022.08.15.22.33.21; Mon, 15 Aug 2022 22:33:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jx7yfPAv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232270AbiHPEou (ORCPT + 99 others); Tue, 16 Aug 2022 00:44:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232455AbiHPElS (ORCPT ); Tue, 16 Aug 2022 00:41:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 320EFF09; Mon, 15 Aug 2022 13:32:35 -0700 (PDT) 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 CFB60B80EAD; Mon, 15 Aug 2022 20:32:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14C01C433C1; Mon, 15 Aug 2022 20:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595552; bh=DTZOeO8M/ZmFwWmxR/DJ1PylJAvfOZbnpLA1thsjjts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jx7yfPAvpran5bN7MorblRKZjnI93IODkGZXMvastjXpCMuX0b69JmYnYkE5MJC9Z 88LWn4r+KFuZDkgviIGVqXESPHy16o+wFxHOlzYFXjJhhVt2zW4pt9vOqXXkM8SPlN u5w253RUA0XYhsRyZgkI3djeVCeoPCIOym+ucSgU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Loehle , Adrian Hunter , Avri Altman , Ulf Hansson , Sasha Levin Subject: [PATCH 5.19 0801/1157] mmc: block: Add single read for 4k sector cards Date: Mon, 15 Aug 2022 20:02:37 +0200 Message-Id: <20220815180511.527573677@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Loehle [ Upstream commit b3fa3e6dccc465969721b8bd2824213bd235efeb ] Cards with 4k native sector size may only be read 4k-aligned, accommodate for this in the single read recovery and use it. Fixes: 81196976ed946 (mmc: block: Add blk-mq support) Signed-off-by: Christian Loehle Acked-by: Adrian Hunter Reviewed-by: Avri Altman Link: https://lore.kernel.org/r/cf4f316274c5474586d0d99b17db4a4c@hyperstone.com Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/core/block.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index f4a1281658db..912a398a9a76 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -176,7 +176,7 @@ static inline int mmc_blk_part_switch(struct mmc_card *card, unsigned int part_type); static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, struct mmc_card *card, - int disable_multi, + int recovery_mode, struct mmc_queue *mq); static void mmc_blk_hsq_req_done(struct mmc_request *mrq); @@ -1302,7 +1302,7 @@ static void mmc_blk_eval_resp_error(struct mmc_blk_request *brq) } static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, - int disable_multi, bool *do_rel_wr_p, + int recovery_mode, bool *do_rel_wr_p, bool *do_data_tag_p) { struct mmc_blk_data *md = mq->blkdata; @@ -1368,12 +1368,12 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, brq->data.blocks--; /* - * After a read error, we redo the request one sector + * After a read error, we redo the request one (native) sector * at a time in order to accurately determine which * sectors can be read successfully. */ - if (disable_multi) - brq->data.blocks = 1; + if (recovery_mode) + brq->data.blocks = queue_physical_block_size(mq->queue) >> 9; /* * Some controllers have HW issues while operating @@ -1590,7 +1590,7 @@ static int mmc_blk_cqe_issue_rw_rq(struct mmc_queue *mq, struct request *req) static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, struct mmc_card *card, - int disable_multi, + int recovery_mode, struct mmc_queue *mq) { u32 readcmd, writecmd; @@ -1599,7 +1599,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, struct mmc_blk_data *md = mq->blkdata; bool do_rel_wr, do_data_tag; - mmc_blk_data_prep(mq, mqrq, disable_multi, &do_rel_wr, &do_data_tag); + mmc_blk_data_prep(mq, mqrq, recovery_mode, &do_rel_wr, &do_data_tag); brq->mrq.cmd = &brq->cmd; @@ -1690,7 +1690,7 @@ static int mmc_blk_fix_state(struct mmc_card *card, struct request *req) #define MMC_READ_SINGLE_RETRIES 2 -/* Single sector read during recovery */ +/* Single (native) sector read during recovery */ static void mmc_blk_read_single(struct mmc_queue *mq, struct request *req) { struct mmc_queue_req *mqrq = req_to_mmc_queue_req(req); @@ -1698,6 +1698,7 @@ static void mmc_blk_read_single(struct mmc_queue *mq, struct request *req) struct mmc_card *card = mq->card; struct mmc_host *host = card->host; blk_status_t error = BLK_STS_OK; + size_t bytes_per_read = queue_physical_block_size(mq->queue); do { u32 status; @@ -1732,13 +1733,13 @@ static void mmc_blk_read_single(struct mmc_queue *mq, struct request *req) else error = BLK_STS_OK; - } while (blk_update_request(req, error, 512)); + } while (blk_update_request(req, error, bytes_per_read)); return; error_exit: mrq->data->bytes_xfered = 0; - blk_update_request(req, BLK_STS_IOERR, 512); + blk_update_request(req, BLK_STS_IOERR, bytes_per_read); /* Let it try the remaining request again */ if (mqrq->retries > MMC_MAX_RETRIES - 1) mqrq->retries = MMC_MAX_RETRIES - 1; @@ -1879,10 +1880,9 @@ static void mmc_blk_mq_rw_recovery(struct mmc_queue *mq, struct request *req) return; } - /* FIXME: Missing single sector read for large sector size */ - if (!mmc_large_sector(card) && rq_data_dir(req) == READ && - brq->data.blocks > 1) { - /* Read one sector at a time */ + if (rq_data_dir(req) == READ && brq->data.blocks > + queue_physical_block_size(mq->queue) >> 9) { + /* Read one (native) sector at a time */ mmc_blk_read_single(mq, req); return; } -- 2.35.1