From patchwork Fri Nov 3 08:47:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 161196 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp884097vqu; Fri, 3 Nov 2023 01:48:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFK6VSVlVXYnqAUU2XPlpGNPT5jeMr8YK4FFtGAt5TEB+N9Vf1/CnA79v0ECJMGCVWVNuas X-Received: by 2002:a05:6a00:138a:b0:68e:3772:4e40 with SMTP id t10-20020a056a00138a00b0068e37724e40mr21724123pfg.3.1699001310647; Fri, 03 Nov 2023 01:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699001310; cv=none; d=google.com; s=arc-20160816; b=eL4sY+i0eytM5hNnRhSsv2v5KPjnCh/mQ/TuxjqZ44TnFFz7L95DynZNkRiQGdd2Kl dL5TaKGpBmuqVPwsKiYXy3gdDgAGeSJwnerIuWFjMg0Lhr/9KIQpYS3LB1ufTgnL0oEW ETChuZCPMM+2yc9tGtOhFxeks3+SzIMos/ZrqJtmyE2cASrOKcJUe1HUbfZ/Ek5udZ0z IiLy/fxh9Jy8AQhxoeSeSO6cwH+tUICULbAaYBnKVpofRp3TLPThhEbIh0W33ss4HGGP 0l9SF7g5mzsYoSYs1I/172yPdnye1d3FjKVVeVi+2Qr+Frbp8DS/RprkPH9/rQsAoLWX JKzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5J0htK/ANZECTLyddEuMj3zEZVPZu/LSWK9MeetjuA0=; fh=aIvDo0DPc47ZdKemLI3k3NodRhLAZ2m+5rlxdvTm1gA=; b=yiR0UqZYA5JroQSZBSE2+P+joi3W7vGeMZ8NQujxaqmrRlSvbKxsHfnfwtV6om7EH9 ZOtFUNUOluJi2BX4eg205d0g0EnRbpAU1iCe/EN8Au6gVmP4ehEkk8gihQrqoNB2F/Tu PNnaSeIUQhj/MNH9DVu2uH2Ka0gGFpD7u/0BBCllgFquHZQFdvM0NxhEZ7BR8t6ba35y Kgz6FvP7/jY+00P+cw+gfjCXhndo8eiGCcVJxH/Bhw2xVtIsika0yaJwxXxTIAZYWQ3L aAFdkA+I8LHrADqqm/BKAHwHfdWLZatKWLsVA/WV7B50a2w/ad2fqDyP/A00RRmKh2zU NkXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=S2OVV7Qb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s35-20020a635263000000b005b8dd557b38si1216760pgl.14.2023.11.03.01.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 01:48:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=S2OVV7Qb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AFF1283792FD; Fri, 3 Nov 2023 01:48:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344768AbjKCIsY (ORCPT + 36 others); Fri, 3 Nov 2023 04:48:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234700AbjKCIsV (ORCPT ); Fri, 3 Nov 2023 04:48:21 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC920D49; Fri, 3 Nov 2023 01:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699001296; x=1730537296; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CPuhmUzZJc2Fl7jj6hRHKrHunHiCOvwemWTDCOmv/zs=; b=S2OVV7QbJBG4ROH5g7x7WP85fN7u/NMpnfj5NsBWMC223/6pCHHcVzCa hEp61SZNH9r3Abv/blWconm2ynk2benzTUh8tkKX1n2LOxvfXjz5Uu7QG d54u+0WBCUCAtRFthwyVWxTOm2U9qkRZSQW8PSDbAYd3nXq1P7WXF63ze 3k0+1IrEzZaTlRYK6UWbugLxW4ILMk6YbvPKFaljfV4PIfLn0bRE8GdB2 6uh74a4YFQjpclnV9Iyt/AyX2Yel8cYeg3mkPpeTb3tBfGTHTbYo7Pq/a FYSvPO/NhgY2PNvg3CM9Ag2zDYot1pFVrKjvHpmWt/826gdWwbLDLouuU Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="391774495" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="391774495" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="796556454" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="796556454" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.51.133]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:10 -0700 From: Adrian Hunter To: Ulf Hansson , =?utf-8?q?Kornel_Dul=C4=99ba?= , Radoslaw Biernacki , Gwendal Grignou , Asutosh Das Cc: Chaotian Jing , Bhavya Kapoor , Kamal Dasu , Al Cooper , Haibo Chen , Shaik Sajida Bhanu , Sai Krishna Potthuri , Victor Shih , Ben Chuang , Thierry Reding , Aniruddha Tvs Rao , Chun-Hung Wu , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 1/6] mmc: block: Do not lose cache flush during CQE error recovery Date: Fri, 3 Nov 2023 10:47:15 +0200 Message-Id: <20231103084720.6886-2-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231103084720.6886-1-adrian.hunter@intel.com> References: <20231103084720.6886-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 01:48:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781531997853323902 X-GMAIL-MSGID: 1781531997853323902 During CQE error recovery, error-free data commands get requeued if there is any data left to transfer, but non-data commands are completed even though they have not been processed. Requeue them instead. Note the only non-data command is cache flush, which would have resulted in a cache flush being lost if it was queued at the time of CQE recovery. Fixes: 1e8e55b67030 ("mmc: block: Add CQE support") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter --- drivers/mmc/core/block.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 3a8f27c3e310..4a32b756b7d8 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1482,6 +1482,8 @@ static void mmc_blk_cqe_complete_rq(struct mmc_queue *mq, struct request *req) blk_mq_requeue_request(req, true); else __blk_mq_end_request(req, BLK_STS_OK); + } else if (mq->in_recovery) { + blk_mq_requeue_request(req, true); } else { blk_mq_end_request(req, BLK_STS_OK); } From patchwork Fri Nov 3 08:47:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 161197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp884136vqu; Fri, 3 Nov 2023 01:48:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjZU8q06k/EDoK0U4G/XNQmKPs61KjxJYmbjvYDHrMxWhTQZYhwGMyRLiZQCDD+zodpxpd X-Received: by 2002:a05:6a20:8428:b0:181:16dc:d1ae with SMTP id c40-20020a056a20842800b0018116dcd1aemr12634236pzd.48.1699001317286; Fri, 03 Nov 2023 01:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699001317; cv=none; d=google.com; s=arc-20160816; b=igeEsoMe25+Wl0XdtqIGMG3nVl5w+R3wlkpZ5zydyfXyN8Y0msrA2DW7Ad+SLUBc2z jqaXAAK/+v6hyV9zJiY26XOvx+malNT5MSb14B1TN2yPlZbflJTrWfjGS8tKv8hRHiyu FQNMunpHcffwQ1OcNdQHqNsgx85dYoy79Koyvu8ZPPIaTy5NaosWe4XO/l9pvArr6c20 YceLtDNu6kW7fF9GG5M9//zNFnIpl+o3dyWnkpEeaQb2oK0vbFHBZJ9LG5xstn6xL0pA Ml2QW1uXg44FT3zQ4Nck9PQUGOHmIDq8phqzeHHmxtc6jtcJVRQYRKLF9yoJR2dxP6HF ulyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xB18ET7k5Cab0qNbVr1XjceBMbRVUdXjO5899oGyQyI=; fh=aIvDo0DPc47ZdKemLI3k3NodRhLAZ2m+5rlxdvTm1gA=; b=q1KgSySuCJxFQpCJy/B61hfD13MRUnGWg7WvtX1NZxVzVxsA3sg/TrZupMJAa60Kce qUeG/jQ/69lyxlNmSgxNmrEG7EMuFd1TRgukOvlNmrzHzePFfh12DTXohrA0IU/lOoah dYrQW1YPucFochtbEwnFRVlNTxmUVGKgKkCnoDd4W7qNpA1voua9b5teqgPZCZ4dDn19 KtGKUSxAzcASmN6Te6u8dFcZuM+XY5o6T1iRoK9NDXjJQ3+MHJi+ABOJ6A/r7bb33lGl tPiUHhtWI1CT7UQKkzb8O6wEgGzCxjZ9odq9Wtt6Zbj3Vr7oEDOPBoXSQhfLqRgZ9kCI O5JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NKXXyLYp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i4-20020a170902c94400b001b8698149fbsi1207270pla.477.2023.11.03.01.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 01:48:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NKXXyLYp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 708DD837B2CA; Fri, 3 Nov 2023 01:48:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343700AbjKCIsa (ORCPT + 36 others); Fri, 3 Nov 2023 04:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345458AbjKCIsZ (ORCPT ); Fri, 3 Nov 2023 04:48:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E457CE; Fri, 3 Nov 2023 01:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699001301; x=1730537301; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cUiL60Q4g/FFeKGo5RkMz2YZaR7uRt/yFxzYNEjO4gA=; b=NKXXyLYpweIc7hJ3SvY3EM5xJp2MFZk4bOIRRbMaVOO9jAHogMCWzVNo Edx3sTvdR9Wwfh4UEXZ1Zvz5qTFVi5ORIj3e68GcDmlQA8dpI4OKs4Qkw Xv4xOz0opBRTGYzaK4U4ud5AnFXS3GjIlI7uWpQ5uB1RL93EXs8lM4hK8 FpmDNKtJBUnhlctjZx0imqMu7Vk2JEc5E1atDFzPPYlOp9C8Yb/wWuf+u fbGJQiXs3w3otEDJ6E8tUUOgjE7IOQ7ubWWff3pQjdwKicH0p2wuqCkHT 2hDjrJfqdTcCHMOmnvPYTEGDPKaKro1NiEDQw00K3g2Qw3rgAK09sYZk6 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="391774512" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="391774512" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="796556495" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="796556495" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.51.133]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:15 -0700 From: Adrian Hunter To: Ulf Hansson , =?utf-8?q?Kornel_Dul=C4=99ba?= , Radoslaw Biernacki , Gwendal Grignou , Asutosh Das Cc: Chaotian Jing , Bhavya Kapoor , Kamal Dasu , Al Cooper , Haibo Chen , Shaik Sajida Bhanu , Sai Krishna Potthuri , Victor Shih , Ben Chuang , Thierry Reding , Aniruddha Tvs Rao , Chun-Hung Wu , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 2/6] mmc: cqhci: Increase recovery halt timeout Date: Fri, 3 Nov 2023 10:47:16 +0200 Message-Id: <20231103084720.6886-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231103084720.6886-1-adrian.hunter@intel.com> References: <20231103084720.6886-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 01:48:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781532005013289575 X-GMAIL-MSGID: 1781532005013289575 Failing to halt complicates the recovery. Additionally, unless the card or controller are stuck, which is expected to be very rare, then the halt should succeed, so it is better to wait. Set a large timeout. Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter --- drivers/mmc/host/cqhci-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c index b3d7d6d8d654..15f5a069af1f 100644 --- a/drivers/mmc/host/cqhci-core.c +++ b/drivers/mmc/host/cqhci-core.c @@ -984,10 +984,10 @@ static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout) /* * After halting we expect to be able to use the command line. We interpret the * failure to halt to mean the data lines might still be in use (and the upper - * layers will need to send a STOP command), so we set the timeout based on a - * generous command timeout. + * layers will need to send a STOP command), however failing to halt complicates + * the recovery, so set a timeout that would reasonably allow I/O to complete. */ -#define CQHCI_START_HALT_TIMEOUT 5 +#define CQHCI_START_HALT_TIMEOUT 500 static void cqhci_recovery_start(struct mmc_host *mmc) { From patchwork Fri Nov 3 08:47:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 161199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp884292vqu; Fri, 3 Nov 2023 01:49:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfZkvHNdL7gBje1D45Wp7SCSpTed0RVXs6M6MzuUNyKa/vPaPIrFIK9/Nvijji1Qpbddhp X-Received: by 2002:a05:6a20:da97:b0:181:90eb:6b24 with SMTP id iy23-20020a056a20da9700b0018190eb6b24mr5594509pzb.22.1699001348498; Fri, 03 Nov 2023 01:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699001348; cv=none; d=google.com; s=arc-20160816; b=uudigXn26YwWDW/TSa3wMT+8GCgaYGs9hn711Zn8rbWsvCU1NJt+oRrO0a4st7RABf cljqeyniXJBXCQctOQYQihbjmm72dG0qWduIJQq73CAMWOAgliPNlKX8t8JMf+q347LX lmohrf8n83GfV/8wZEQWmIjJ0FcZEM/wcKauh23mzlgkyr9Vtb6TdGrYY4Gy0sbhXCXL CfQK7ZLuDqdcKs303X1tGHXRxsRiopgGXvADK393d1wnFc0CIGa8TT5Y5iKWjIR6mCZ2 1EiZmGU8Qv7zEkN93yyzklqqUVIil9mJ/pKkklPp/O7L+VNij6t3Cg8uqaxs8yGP1Bn2 +3Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0ujTn+DR9HZ4nFmpW/WRmU1wpFxEf+lLTPzALBDZpxc=; fh=aIvDo0DPc47ZdKemLI3k3NodRhLAZ2m+5rlxdvTm1gA=; b=zX7vvsUGCBQKKSX7uh26rQxzvk6vem9ZikhbGgyGPB/i39yq0Fkk9cFla8B5D805Eu kcNAG5Vddvzj6L84o2ZyfpAkBPAbq+wtu00XguSgVNG6T5cKevoWns3gSeh511Bp8PWO n8OP2GBzmQWdtjNhsaOTgNHynQVQrWrkYdFeVOqXhs/xhaEWmIWvS9cD8Ft8gjSUCdTx ywoa7jM06SjDIA4WHjebKUV9tzvMW/O2/euGUgvQfVnd8mNPvZHGDOqLw7H+i7CAtu35 KOc8NA/F6dG9Q9BRPATaxBxOPpOZGWl/M5YKoBko+M2TjgCVW4THlmFjhcrBZ8JMpAJa jVRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fUibThXb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id x7-20020aa79187000000b006be31836ce4si1146265pfa.309.2023.11.03.01.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 01:49:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fUibThXb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D618A81B5D22; Fri, 3 Nov 2023 01:48:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346089AbjKCIsf (ORCPT + 36 others); Fri, 3 Nov 2023 04:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345458AbjKCIsc (ORCPT ); Fri, 3 Nov 2023 04:48:32 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AC4AD4C; Fri, 3 Nov 2023 01:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699001306; x=1730537306; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mP6Mo3+Nw1x4znWMjlIBYHth0os2JHcW2xe8+eVSNhY=; b=fUibThXbGmf0QqoFUB5cbQ5iuRSh+YG9qigwb0TOFsHLSOe4NuSiAAzM BFmrIDEZPOiolOW6IN9CBfIhMBTKIkRksxpVcx8HwDxNfqWRkFn2NoRst vjlv2TpgjoWbw1SI65bkIvQGD7XpXKkelXLGNgxyOx8WlWVzlkCt/A8Pe 3A/GCQkq2GJvhmnTxgLbQrh8/DPk/Cfb6DBvH4LwW4862BdZ/DVDLGXDE mBU4EHZZXQVrdAnG/istQBgazXHiBxAu1NtIw8M0EGxk91YTqqACONJAM AkGomgHyra78/arJDac2tE1eafOSx0FXAzgWLkAB+wkZpRtcyTK55HpV6 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="391774560" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="391774560" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="796556575" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="796556575" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.51.133]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:20 -0700 From: Adrian Hunter To: Ulf Hansson , =?utf-8?q?Kornel_Dul=C4=99ba?= , Radoslaw Biernacki , Gwendal Grignou , Asutosh Das Cc: Chaotian Jing , Bhavya Kapoor , Kamal Dasu , Al Cooper , Haibo Chen , Shaik Sajida Bhanu , Sai Krishna Potthuri , Victor Shih , Ben Chuang , Thierry Reding , Aniruddha Tvs Rao , Chun-Hung Wu , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 3/6] mmc: block: Be sure to wait while busy in CQE error recovery Date: Fri, 3 Nov 2023 10:47:17 +0200 Message-Id: <20231103084720.6886-4-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231103084720.6886-1-adrian.hunter@intel.com> References: <20231103084720.6886-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 01:48:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781532038041641126 X-GMAIL-MSGID: 1781532038041641126 STOP command does not guarantee to wait while busy, but subsequent command MMC_CMDQ_TASK_MGMT to discard the queue will fail if the card is busy, so be sure to wait by employing mmc_poll_for_busy(). Fixes: 72a5af554df8 ("mmc: core: Add support for handling CQE requests") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter Reviewed-by: Christian Loehle --- drivers/mmc/core/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 3d3e0ca52614..befde2bd26d3 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -553,6 +553,8 @@ int mmc_cqe_recovery(struct mmc_host *host) cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT; mmc_wait_for_cmd(host, &cmd, 0); + mmc_poll_for_busy(host->card, MMC_CQE_RECOVERY_TIMEOUT, true, MMC_BUSY_IO); + memset(&cmd, 0, sizeof(cmd)); cmd.opcode = MMC_CMDQ_TASK_MGMT; cmd.arg = 1; /* Discard entire queue */ From patchwork Fri Nov 3 08:47:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 161198 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp884188vqu; Fri, 3 Nov 2023 01:48:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMEGea9Kmk0t6zstfn6xpANaj4WwU2twVvHc8rf6gh0waU/noz6Uf4NruIs3hYM0F6JcZt X-Received: by 2002:a05:6a00:190b:b0:6c3:69b9:44db with SMTP id y11-20020a056a00190b00b006c369b944dbmr1621554pfi.22.1699001327822; Fri, 03 Nov 2023 01:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699001327; cv=none; d=google.com; s=arc-20160816; b=SywTsWMzsrfq2xNfqze1Npar0lQZF3z8jb0jU0Pw1JQ9ALRFMc3WcAgTDmud5fRpH2 E2bEG5ZGshMAgWuWdRQHfRfzOoR3iMRwB1AwJ+RV4+pSxIVZI0N6GN+gwIA6P+W+gxTa 4s/9M8DodnVkyTDAeDDGdGZs6q8B3f0TdEwW8IliDrR8y54+A33abmssU/cbkHkiNRsR O0efIdT4HWbQnM0ZcJRyBZAHKnQ68f6H0E7e3aRwoyeXOUeVs29pSO4g7Upy+f1v+ZjF ky63npfJod1Hz9heF+ZioDs5SqGK0KWZCDXiF9suEQEZ2wEB6yuERGKD6EW+PhyIUo6X ELxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BTKYkLTvs/mbKW2eEVWXGznLCcf8HQLLSg1ZPbBOAj8=; fh=aIvDo0DPc47ZdKemLI3k3NodRhLAZ2m+5rlxdvTm1gA=; b=hr16eaav12aLsEg4m7ChjCjAPVoNMDoXOaDZ9f7hQLogg5AY66l7T6KjxLF7dihX5C KmRS+QiR5rFBocW+1PVKgGcKiJR5/UKPNepQCq3iv9r2VKRFma+uxcmLliBNSpv7XfC1 cKljS61PlDs3OKhFeqdiCH/aYpqBas9V5szMgQTccLY+wMjb87GKDdUTO1MeLCDSu4Um EWZxUCzoFHDX9y5QOlMrubupwNmL6PFUcSrcu1EqxtovBC7jWmUuPYjcBQ4560dWnHbA ogA9h2UsGXvu5TLYIPybKSQe0H9DUouquCvfmrVeP5ZO/N8ruIm8OPI9ayQnszu4FVLj mm7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="XlnPH/nD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g12-20020a056a000b8c00b006be25b58596si1168091pfj.77.2023.11.03.01.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 01:48:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="XlnPH/nD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DFE2F83792F5; Fri, 3 Nov 2023 01:48:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345458AbjKCIsp (ORCPT + 36 others); Fri, 3 Nov 2023 04:48:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235601AbjKCIsl (ORCPT ); Fri, 3 Nov 2023 04:48:41 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21285D50; Fri, 3 Nov 2023 01:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699001311; x=1730537311; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OV8RDN4Bd1h5BCWBvIEygF8kScSzkr9HTkdiwgabNdQ=; b=XlnPH/nDTf/57/Y//gWwmw8gGwYDhUoO2SCsp3/zUXCNxiqhyDhCl9Qi 12OS/RnYc8sIjh3SueKOyLsEyT+EFvDZDvDCKj509QRUcz8Az/AIoB1qW FGtLhbIaMi55bXLxO7wFMvD5GOuERP5N4NeZsUIcDPYeFuQ6W6Ew2293u pUK4w5XYr1e11C2CHPpT3B+5/VFFTS1kr5pjP0YIZEv9xcs00yC+oVaq7 syLoXXYikAAET/BpiPcugQFsn9WTqVPvG9Kzk6EI6pmQjqaYUqguPWHkL ee/Q3hUL6VzeBwJCbemZY6gRT24fea2a+SnBR/e/4fnM3y8aeq+PeJ68r A==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="391774580" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="391774580" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="796556610" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="796556610" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.51.133]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:25 -0700 From: Adrian Hunter To: Ulf Hansson , =?utf-8?q?Kornel_Dul=C4=99ba?= , Radoslaw Biernacki , Gwendal Grignou , Asutosh Das Cc: Chaotian Jing , Bhavya Kapoor , Kamal Dasu , Al Cooper , Haibo Chen , Shaik Sajida Bhanu , Sai Krishna Potthuri , Victor Shih , Ben Chuang , Thierry Reding , Aniruddha Tvs Rao , Chun-Hung Wu , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 4/6] mmc: block: Retry commands in CQE error recovery Date: Fri, 3 Nov 2023 10:47:18 +0200 Message-Id: <20231103084720.6886-5-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231103084720.6886-1-adrian.hunter@intel.com> References: <20231103084720.6886-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 01:48:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781532016485793810 X-GMAIL-MSGID: 1781532016485793810 It is important that MMC_CMDQ_TASK_MGMT command to discard the queue is successful because otherwise a subsequent reset might fail to flush the cache first. Retry it and the previous STOP command. Fixes: 72a5af554df8 ("mmc: core: Add support for handling CQE requests") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter Reviewed-by: Avri Altman --- drivers/mmc/core/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index befde2bd26d3..a8c17b4cd737 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -551,7 +551,7 @@ int mmc_cqe_recovery(struct mmc_host *host) cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; cmd.flags &= ~MMC_RSP_CRC; /* Ignore CRC */ cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT; - mmc_wait_for_cmd(host, &cmd, 0); + mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); mmc_poll_for_busy(host->card, MMC_CQE_RECOVERY_TIMEOUT, true, MMC_BUSY_IO); @@ -561,10 +561,13 @@ int mmc_cqe_recovery(struct mmc_host *host) cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; cmd.flags &= ~MMC_RSP_CRC; /* Ignore CRC */ cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT; - err = mmc_wait_for_cmd(host, &cmd, 0); + err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); host->cqe_ops->cqe_recovery_finish(host); + if (err) + err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); + mmc_retune_release(host); return err; From patchwork Fri Nov 3 08:47:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 161200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp884349vqu; Fri, 3 Nov 2023 01:49:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2sxe8BqDyLF2wIi4l47hGV0qPq8Bf0RVnyxKIOkotApXLBimnvsDoa9p6VSRA6fAqBKvv X-Received: by 2002:a05:6a00:b55:b0:6be:314c:16cb with SMTP id p21-20020a056a000b5500b006be314c16cbmr24054733pfo.10.1699001359846; Fri, 03 Nov 2023 01:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699001359; cv=none; d=google.com; s=arc-20160816; b=0tYoa/JbrLXdRt/BnSG41zRqAJbOmXhKM7jCDB+mlTDZc56ETFE4ykVUiLEHEGG3Og i6eCrtPYFS4xo8IxmS15tn0yF14n43u8xgLXV7NxZweDrd7W//lYwrcr6ZretQi13M2i 4hlnDsbtliQtaM4k0OxBl6N0wJv69OCKFnaO1G6xBe9TKZkhk8rJXgIRruTnpvFBxRXE uP6HvTk5PKu8bec7mkqx9Nh601T//xDp65s0Onk/+y+gKwzylWsTtKot4Ry9vladES/2 gFWR04PazlTqSZD1hBvwa0ut0b8+0IFVgFm5APulWmbbXOFIxU4oxo/A2j23ht+H3B9y qghA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=P6ZIRjlu+/MwftTx3BPF+79pssGUXBSCsYkve2wqp3o=; fh=aIvDo0DPc47ZdKemLI3k3NodRhLAZ2m+5rlxdvTm1gA=; b=c2q/TiERHSegHAYvEVZxnyZYYOHYxI0V8pnfSZGKGYv3QwUaKM+x1A3oqpQxGhtVPO rUy3OVAtrwsos8Nt2gpP6jXwsChZ3oTVIpcSRKkEOql/ZBsgJDUov1fmG7TpA7bM+X7/ ms/5sZZCbPv2OM9gE1EcX77Zxx9dUBWgIcHyHXQCUy5hCYmS9DJBUz467ciEr+xqKWJy fsK0pvNqxo5V9gbitk+OxYt0yfj94/w5ECFyJTGpQKCx2eweYr51AK+MsqWU5vB3yuuB s3CeFLtCWDalQ3NCqdMBTTUq5lTWfalafWFEh+AZwu4uA9MlUPokTwBa8obgdtTrWHrQ mmcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BlEtAY7q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ck20-20020a056a02091400b005b99ea68841si1264115pgb.581.2023.11.03.01.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 01:49:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BlEtAY7q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7143D826BBBC; Fri, 3 Nov 2023 01:49:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235135AbjKCIsr (ORCPT + 36 others); Fri, 3 Nov 2023 04:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235812AbjKCIsn (ORCPT ); Fri, 3 Nov 2023 04:48:43 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26745D61; Fri, 3 Nov 2023 01:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699001316; x=1730537316; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YBQ2Lyin2LPrMqjjbn7C4KRka6RjCsHhKLhnLJTF9TM=; b=BlEtAY7q1rtdlgC+Q5k7lk9cmmOvLixbDgsRfZ8p4KhTolwLpgpgSPGD 4tqpYTD2rN4nEOhH34BROmvvXPj/WRxalJ8uH/0d32MevQQDLixYkJ0nl x9YO5XBzplL7Hth6MwBa98671/z7kcDIwcZFgM/6Ou4nbM/QZuELLSDX1 XWLxDyhzLNHIYcTDkW6rmU8Yv6Lty3SrsNVV29nUDobbxAqKRLrkaBNJq fqcO0aeVN/jB5reKKKS00kgUIfxyPLj6x8eLz//mTrzGfjBhss3WYB30o zF4vIYR/W9Fhb1sjpUaSWoOPK+RQG60YBdQAV2Yrn+wsT2Ntw25YjaJFZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="391774604" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="391774604" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="796556657" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="796556657" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.51.133]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:30 -0700 From: Adrian Hunter To: Ulf Hansson , =?utf-8?q?Kornel_Dul=C4=99ba?= , Radoslaw Biernacki , Gwendal Grignou , Asutosh Das Cc: Chaotian Jing , Bhavya Kapoor , Kamal Dasu , Al Cooper , Haibo Chen , Shaik Sajida Bhanu , Sai Krishna Potthuri , Victor Shih , Ben Chuang , Thierry Reding , Aniruddha Tvs Rao , Chun-Hung Wu , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 5/6] mmc: cqhci: Warn of halt or task clear failure Date: Fri, 3 Nov 2023 10:47:19 +0200 Message-Id: <20231103084720.6886-6-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231103084720.6886-1-adrian.hunter@intel.com> References: <20231103084720.6886-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 03 Nov 2023 01:49:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781532049799527157 X-GMAIL-MSGID: 1781532049799527157 A correctly operating controller should successfully halt and clear tasks. Failure may result in errors elsewhere, so promote messages from debug to warnings. Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter --- drivers/mmc/host/cqhci-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c index 15f5a069af1f..948799a0980c 100644 --- a/drivers/mmc/host/cqhci-core.c +++ b/drivers/mmc/host/cqhci-core.c @@ -942,8 +942,8 @@ static bool cqhci_clear_all_tasks(struct mmc_host *mmc, unsigned int timeout) ret = cqhci_tasks_cleared(cq_host); if (!ret) - pr_debug("%s: cqhci: Failed to clear tasks\n", - mmc_hostname(mmc)); + pr_warn("%s: cqhci: Failed to clear tasks\n", + mmc_hostname(mmc)); return ret; } @@ -976,7 +976,7 @@ static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout) ret = cqhci_halted(cq_host); if (!ret) - pr_debug("%s: cqhci: Failed to halt\n", mmc_hostname(mmc)); + pr_warn("%s: cqhci: Failed to halt\n", mmc_hostname(mmc)); return ret; } From patchwork Fri Nov 3 08:47:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 161201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp884465vqu; Fri, 3 Nov 2023 01:49:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHovCqSTODT2Z/NnB4CvvtThYzR6SBgh6kIVgUk/p/opmPxvQhHftz01N0lfkLih9lPHZEn X-Received: by 2002:a05:6358:7e42:b0:169:9788:8741 with SMTP id p2-20020a0563587e4200b0016997888741mr9689948rwm.27.1699001385903; Fri, 03 Nov 2023 01:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699001385; cv=none; d=google.com; s=arc-20160816; b=LpT2uWj/3VyEMmsINW7v+zq68k+Zfoe1VHgD42i+Ht2tRGBP6CtxHi4JyCWmVOMrED u9rfGD+Wb/Vm6eMfRXtxWvLyW45E54qiiQYJS+hdstMKbcMYD6VfXSzj7q1WApbSSe7d yccUlfNC+4OpfmcczVy3Zw+n76Ii+9tzJUeXmXnI/tVGIZt91YLYb+LiW9vazjx3LApL TFSTLbL3TJCZTOYKZCXMK0o3axD+jRCJ9lYH9Qd4w4UdBd+C5HQ5u7QH2FqAm7YdQSR+ rnnkHovhj5Gw0cylQgsDf2O/zbS12DW6jxhYBQRxTCeEHPUeyIC80PEIXCkPclnqGMEL y3QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=c20jI2zv0SoVtsSW7Cck3Ic1OgQTEoxnh2Wagk+pWZY=; fh=aIvDo0DPc47ZdKemLI3k3NodRhLAZ2m+5rlxdvTm1gA=; b=K0fhTYVhE51qsP/wAKpK+mW92BQzU1oYWgwgmnCVzfcD04EIcQiZ2yBRkj9hWdJqc9 UX1A8MQPP7kCLPMa01oSQXpasWVuAkyssK8A0OQhXClODpDrdiSPWUyFM0lvXhY6vqvQ sT8byuEe72Rposh+jW20v2qD4QvwzyJKc68JfRIB3vg2FgEcSf7kPkIwAtRUfk7/vMT9 LVc4nUiSwR8++YVzQB77sG5QS68QHE78g9pR80wTw7g+IY952f89PIN5wHyZnKyw7DvH y7WDwdHu/yuvrNVhEwT4CIyZb7qLLunNs52ZjWMElp4nY+NdqD6wnylhsjf54dMr9oXs sFMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EAYuVz3f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l12-20020a65680c000000b005b91496019esi1164574pgt.400.2023.11.03.01.49.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 01:49:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EAYuVz3f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8C3DD81B5D18; Fri, 3 Nov 2023 01:49:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235325AbjKCIs7 (ORCPT + 36 others); Fri, 3 Nov 2023 04:48:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346130AbjKCIsr (ORCPT ); Fri, 3 Nov 2023 04:48:47 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68241D4E; Fri, 3 Nov 2023 01:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699001321; x=1730537321; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QAFnkZjCEfVfLAK7KrRDYxSV98mreyDoOmktfPkz9T8=; b=EAYuVz3f2lClSgtM2RSUPVYMj9S0Of5Gbsa/B4PXfWcNw3qZ1GMNhkOp qDU2Mk0O1vFKxWUWZt/kYbAbHLeuDM47x55pn8btRglA80I0jNWoELfa0 E7/d7ergo2NekkcshsxT/xkfzLgjqjbFXhFhrL19Za7JLhGOQpGRDgMb5 JFCj6+ZuNxpji4jDXZH+Ujq6TBuPankpxMMYn8BBJ19WhvK8fhZCCTFNS ZjDlQVmMHW66H8qnTOjVWGlOaL2MZspi7IdkFXvGVJW83e0VSXuwaocuQ ErXnVK2aJLqg2nRlKT660u8hGy/3guR+jtcNqZBW9vMKL3cgpLCgPM+Ge Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="391774620" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="391774620" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="796556695" X-IronPort-AV: E=Sophos;i="6.03,273,1694761200"; d="scan'208";a="796556695" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.51.133]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2023 01:48:35 -0700 From: Adrian Hunter To: Ulf Hansson , =?utf-8?q?Kornel_Dul=C4=99ba?= , Radoslaw Biernacki , Gwendal Grignou , Asutosh Das Cc: Chaotian Jing , Bhavya Kapoor , Kamal Dasu , Al Cooper , Haibo Chen , Shaik Sajida Bhanu , Sai Krishna Potthuri , Victor Shih , Ben Chuang , Thierry Reding , Aniruddha Tvs Rao , Chun-Hung Wu , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 6/6] mmc: cqhci: Fix task clearing in CQE error recovery Date: Fri, 3 Nov 2023 10:47:20 +0200 Message-Id: <20231103084720.6886-7-adrian.hunter@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231103084720.6886-1-adrian.hunter@intel.com> References: <20231103084720.6886-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 03 Nov 2023 01:49:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781532076824615070 X-GMAIL-MSGID: 1781532076824615070 If a task completion notification (TCN) is received when there is no outstanding task, the cqhci driver issues a "spurious TCN" warning. This was observed to happen right after CQE error recovery. When an error interrupt is received the driver runs recovery logic. It halts the controller, clears all pending tasks, and then re-enables it. On some platforms, like Intel Jasper Lake, a stale task completion event was observed, regardless of the CQHCI_CLEAR_ALL_TASKS bit being set. This results in either: a) Spurious TC completion event for an empty slot. b) Corrupted data being passed up the stack, as a result of premature completion for a newly added task. Rather than add a quirk for affected controllers, ensure tasks are cleared by toggling CQHCI_ENABLE, which would happen anyway if cqhci_clear_all_tasks() timed out. This is simpler and should be safe and effective for all controllers. Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host") Cc: stable@vger.kernel.org Reported-by: Kornel Dulęba Tested-by: Kornel Dulęba Co-developed-by: Kornel Dulęba Signed-off-by: Kornel Dulęba Signed-off-by: Adrian Hunter --- drivers/mmc/host/cqhci-core.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c index 948799a0980c..41e94cd14109 100644 --- a/drivers/mmc/host/cqhci-core.c +++ b/drivers/mmc/host/cqhci-core.c @@ -1075,28 +1075,28 @@ static void cqhci_recovery_finish(struct mmc_host *mmc) ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT); - if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT)) - ok = false; - /* * The specification contradicts itself, by saying that tasks cannot be * cleared if CQHCI does not halt, but if CQHCI does not halt, it should * be disabled/re-enabled, but not to disable before clearing tasks. * Have a go anyway. */ - if (!ok) { - pr_debug("%s: cqhci: disable / re-enable\n", mmc_hostname(mmc)); - cqcfg = cqhci_readl(cq_host, CQHCI_CFG); - cqcfg &= ~CQHCI_ENABLE; - cqhci_writel(cq_host, cqcfg, CQHCI_CFG); - cqcfg |= CQHCI_ENABLE; - cqhci_writel(cq_host, cqcfg, CQHCI_CFG); - /* Be sure that there are no tasks */ - ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT); - if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT)) - ok = false; - WARN_ON(!ok); - } + if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT)) + ok = false; + + /* Disable to make sure tasks really are cleared */ + cqcfg = cqhci_readl(cq_host, CQHCI_CFG); + cqcfg &= ~CQHCI_ENABLE; + cqhci_writel(cq_host, cqcfg, CQHCI_CFG); + + cqcfg = cqhci_readl(cq_host, CQHCI_CFG); + cqcfg |= CQHCI_ENABLE; + cqhci_writel(cq_host, cqcfg, CQHCI_CFG); + + cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT); + + if (!ok) + cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT); cqhci_recover_mrqs(cq_host);