Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2839240rwb; Mon, 15 Aug 2022 12:21:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR48EIut8glS9wu/Tq3LqsPA5yhzPtHIK2ad0uRI9D9JukrYKBjYQ0VB7Tf0V/3z5QBARfdD X-Received: by 2002:a05:6402:510a:b0:43d:ab25:7d68 with SMTP id m10-20020a056402510a00b0043dab257d68mr15669712edd.102.1660591273158; Mon, 15 Aug 2022 12:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660591273; cv=none; d=google.com; s=arc-20160816; b=TivlNCfl7Ag+H4mpDrZwXI9XuvK8kpNu/nDJdrLlwYkoPUFyixHDBU1THHESsT7ChM SLShpjzNefybcXOec19z8gmmupvJ/OCiJrXBkQiCcTqv7REXwXhvauhmREbmdvF5Rutp AbWrmQklVkOZoU9JcKdYhidGuTRuTQec52sD0EKPu+Wzm10P1iJA1a0OaTbV7VxkC9O6 a8fUa3gvu+6BwYRS699qdD+cdM/PnyV4qy0rSyKdug7Khg5fil6Ok5TLYvd82SX2U5jZ SbcdeFDY9htmeO06+L/BskzdzZbEg9+t8Qa4Ua8DGzQP0PYtJ/7yTR+nakA+6suV6GUb k0Ug== 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=Jmzi6GCQgc0R0tL5w9PU6NNeaNiEbatW0OY7MsV2i3g=; b=QbCLnF/5/aGEl8NkyNf5oLamOCpcrpnfzrmd02A621pSxziH0ekhpST7syGhx+vPGh T2VUYnY1njQUqx9xDYI+xqcsKihTBFnwZ4b/s1vvpHngr6RL39rl4p0SgShnDcjFZOm2 fxYpIjuEkBdm8maX4kgJuZCdRbuUSj966vQCtgIF6WEbregbioVrl16C033rDKWrtl4M LY9Ulbnsa2N8Q1f6EB1bvoAZnK05n//10DZBj2M/hhqy0cumr6Tqnq4Dl6PHp25iDRrA ERqp04hW1gHwREZOGfoKSjHzDcx6+Bi1B0aok+UwLrztbHu5uL5nkuEd5QdZ4R/sA4Pq 9oOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n0Vz+PsI; 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 h15-20020aa7cdcf000000b0043e09d6bd11si7146420edw.353.2022.08.15.12.20.47; Mon, 15 Aug 2022 12:21:13 -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=n0Vz+PsI; 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 S1343930AbiHOTTQ (ORCPT + 99 others); Mon, 15 Aug 2022 15:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344384AbiHOTQf (ORCPT ); Mon, 15 Aug 2022 15:16:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4768E53D13; Mon, 15 Aug 2022 11:38:14 -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 88DB3B81084; Mon, 15 Aug 2022 18:38:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0E32C433D6; Mon, 15 Aug 2022 18:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588688; bh=pB7zu3RI90l0HgRwOw3iQx+aw/N8WeopjvTODowc39M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0Vz+PsIbOFGhL+qY1/Anxxyi/KUhBEPhmV5ghsq5kkCKNnL8IAjewHI3FGtWX/8W S9qY3ByMKKQ5azyYk2t9rTnRfJZzOSExdGTG0cIivqPKmOjeTvrjl4VFQQnwGzNkyj Bxqk07ollZ1QITn0SHOf0bttCavn9OJI2L4qkB1A= 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.15 483/779] mmc: block: Add single read for 4k sector cards Date: Mon, 15 Aug 2022 20:02:07 +0200 Message-Id: <20220815180357.905457608@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 a196116444a3..3222a9d0c245 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -175,7 +175,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); @@ -1285,7 +1285,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; @@ -1351,12 +1351,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 @@ -1573,7 +1573,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; @@ -1582,7 +1582,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; @@ -1673,7 +1673,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); @@ -1681,6 +1681,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; @@ -1715,13 +1716,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; @@ -1862,10 +1863,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