From patchwork Tue May 17 18:09:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 574775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 869E5C433EF for ; Tue, 17 May 2022 18:09:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351916AbiEQSJb (ORCPT ); Tue, 17 May 2022 14:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351893AbiEQSJS (ORCPT ); Tue, 17 May 2022 14:09:18 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D256F50B0E; Tue, 17 May 2022 11:09:16 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id l14so7216891pjk.2; Tue, 17 May 2022 11:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NitEEt9lv1RnCtUE5yy6vc9OX+05AmwrbwfqCcJlYBk=; b=ddOkwGZtVLkZdLmz8EEVVJzO0uzs3q6uSMLh1vbMAC4Urd7qA5pF3i4eEpPv13EVkD SZA+g4ti400dVFWQZ/ucVPllkDgaVgpcINgA5L6ym5twcm3/KSWwC5sLYUind52LLEd2 1yOyoOvwaTnzc5qGym812TsKBuBg7mMVlDIHXkzzGpoSjERzcNwcZYtvLox0gxBrg7na Fh0/+NLKmrY7DaeGrTOsxRODeqTf5AZwAKb4WoFMhPGIE+bZODajYQR7XOJdkZG+PaO+ 8ZVFNCNDlwQQglkgu7B8RBnVNHu/tXGGrMB/yPznZGXpiuGOqN5fzmcUCO8Meg7hHsWO FBFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NitEEt9lv1RnCtUE5yy6vc9OX+05AmwrbwfqCcJlYBk=; b=75iByfTpxL57gqJNk3Gke/uUNT4/0qKpgV2wNM1JFWPhoD4KEoUn3N/HLD1zaAtgFt AvgnvxXu08mJdunspcKoiGb6rf9dZKTixElnAEO0LMszk/KnBa/cC502T8jdSR0ZbG1W N0BF++AVSlIAzt8kYvgFKgwMMdeUHu3L1xWPw7x6mXl8yezGmlNzXu3NAuAaOk+pYSpH 0OUs7rO9GQOsu7QlgiNsVGQ7SOGBYSvHV4o6Y2pnvgK+IlDbRZ2OJrhoTEPmjU7zTDQF Qh/buurU9YRsmtGKGo1RsG02MjAh8ETLO3sMquIEzgATav9UtkDad8wfsIbkl9sa8xyd rWpw== X-Gm-Message-State: AOAM530AZYW2hBrNZdyrUZeQJ/C0Mj/yenVOTzVGarF2/0vkuGTHh3GK dQkWzY4B4cRLPkfenjMgffQLCOvgHZc= X-Google-Smtp-Source: ABdhPJxMRn66HsCjJwUG2dqVSdWDnit4HAxDSUO5nQ/2ICFqyl+Gysm4q0ec6mOzd+391d8LHyMsaw== X-Received: by 2002:a17:90b:120c:b0:1df:3fb3:3565 with SMTP id gl12-20020a17090b120c00b001df3fb33565mr14526958pjb.106.1652810955809; Tue, 17 May 2022 11:09:15 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id i5-20020a056a00224500b0050dc7628160sm46854pfu.58.2022.05.17.11.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 11:09:15 -0700 (PDT) From: Florian Fainelli To: stable@vger.kernel.org Cc: Ulf Hansson , Florian Fainelli , Adrian Hunter , Greg Kroah-Hartman , Avri Altman , Bean Huo , Nishad Kamdar , =?utf-8?q?Christian_L=C3=B6hle?= , linux-mmc@vger.kernel.org (open list:MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND...), linux-kernel@vger.kernel.org (open list), alcooperx@gmail.com, kdasu.kdev@gmail.com Subject: [PATCH stable 5.4 1/3] mmc: core: Specify timeouts for BKOPS and CACHE_FLUSH for eMMC Date: Tue, 17 May 2022 11:09:09 -0700 Message-Id: <20220517180911.246016-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220517180911.246016-1-f.fainelli@gmail.com> References: <20220517180911.246016-1-f.fainelli@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Ulf Hansson commit 24ed3bd01d6a844fd5e8a75f48d0a3d10ed71bf9 upstream The timeout values used while waiting for a CMD6 for BKOPS or a CACHE_FLUSH to complete, are not defined by the eMMC spec. However, a timeout of 10 minutes as is currently being used, is just silly for both of these cases. Instead, let's specify more reasonable timeouts, 120s for BKOPS and 30s for CACHE_FLUSH. Signed-off-by: Ulf Hansson Link: https://lore.kernel.org/r/20200122142747.5690-2-ulf.hansson@linaro.org Signed-off-by: Florian Fainelli --- drivers/mmc/core/mmc_ops.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 09311c2bd858..d8f419183144 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -19,7 +19,9 @@ #include "host.h" #include "mmc_ops.h" -#define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ +#define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10min*/ +#define MMC_BKOPS_TIMEOUT_MS (120 * 1000) /* 120s */ +#define MMC_CACHE_FLUSH_TIMEOUT_MS (30 * 1000) /* 30s */ static const u8 tuning_blk_pattern_4bit[] = { 0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc, @@ -943,7 +945,7 @@ void mmc_run_bkops(struct mmc_card *card) * urgent levels by using an asynchronous background task, when idle. */ err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_BKOPS_START, 1, MMC_OPS_TIMEOUT_MS); + EXT_CSD_BKOPS_START, 1, MMC_BKOPS_TIMEOUT_MS); if (err) pr_warn("%s: Error %d starting bkops\n", mmc_hostname(card->host), err); @@ -961,7 +963,8 @@ int mmc_flush_cache(struct mmc_card *card) if (mmc_cache_enabled(card->host)) { err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_FLUSH_CACHE, 1, 0); + EXT_CSD_FLUSH_CACHE, 1, + MMC_CACHE_FLUSH_TIMEOUT_MS); if (err) pr_err("%s: cache flush error %d\n", mmc_hostname(card->host), err); From patchwork Tue May 17 18:09:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 574776 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24F07C4332F for ; Tue, 17 May 2022 18:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351959AbiEQSJc (ORCPT ); Tue, 17 May 2022 14:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351910AbiEQSJa (ORCPT ); Tue, 17 May 2022 14:09:30 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC36F5FB8; Tue, 17 May 2022 11:09:19 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id c22so865046pgu.2; Tue, 17 May 2022 11:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zGBHNRVAReTR8yDYLvhJzA/B3avPsiigOsOP3ZNzQYw=; b=polGNZfBWi5g/eJVDnC60LyaRdJx9thJ5mqQE3iXHQMfcNAQImQ846+Lt7Wz6e6i0h wIftuHyM2SYU7q8X7x25s6UV3R1VgQkweIhF7l2lfzehTrQlaSsIboUkm/L4S1/MJoTm q/SOnSlZ/9KnGgv2gKYf0bd2rlnq0rVqAmhoiwDyuT+VWo5+2CpPdB0oPaXEFxJKYBKX oKJgeveiMEhFr5RRLC4sCQ4aEVW6YWrBAfJ3ZX6lYlGNxzMj/ILeuLyEhQ4McVIbCohK NNLauje8VSBuhCOMBojAI022Sv/jIuT0VhC2HtJcIUZOIpWPOeyoyoyl62qqOmbAX1Db kvtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zGBHNRVAReTR8yDYLvhJzA/B3avPsiigOsOP3ZNzQYw=; b=5EOqd6pMCXS7/J66tCFH4vtWfK4+SbRkzJuVD7xwiqlIMsrmfGp0RKMNZCo0uRWhzE jVyg17Q3fsji4fEuIsL9yGMioxXouGH4wdf2XMgiHMeIE/udCzVYKaoN9FJGb7hSe1zu O7u6W4kW55EqUyIAkWrfIh0eheKoYSI6UGnEDsXDV7NfggcA0TtE8oNrR/ei+xwuxpB7 PesGHIDeK5Q5rt4y8cM2MLW3avqUi1lN3tuRjZjawWWfjjSlwtnht/ckAHGR3N8hYpsP VG4wnBOPF05w61YLXJk93oDjAhQRMPfzW1YGNfg2ko8J5jYHofGU9Lq5mmk2KJCGf6Ml 1JIA== X-Gm-Message-State: AOAM530sJUMtGs3G56IErjqF1YjIaXEbKGeI9TKV0CTns8bBhqm5jf6T NNaymvOHB28tkxK8do62iwD4y2b6ZO0= X-Google-Smtp-Source: ABdhPJyI2gEUFdqQjQg0dM1F0fryaEE05aE2j0+UkSByd5iYL6bx26rgrjaDRqPhTyS/GRtMR1+D5w== X-Received: by 2002:a63:125e:0:b0:3f2:5b13:5aac with SMTP id 30-20020a63125e000000b003f25b135aacmr11837658pgs.401.1652810958893; Tue, 17 May 2022 11:09:18 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id i5-20020a056a00224500b0050dc7628160sm46854pfu.58.2022.05.17.11.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 11:09:18 -0700 (PDT) From: Florian Fainelli To: stable@vger.kernel.org Cc: Ulf Hansson , Florian Fainelli , Adrian Hunter , Greg Kroah-Hartman , Avri Altman , Bean Huo , Nishad Kamdar , =?utf-8?q?Christian_L=C3=B6hle?= , linux-mmc@vger.kernel.org (open list:MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND...), linux-kernel@vger.kernel.org (open list), alcooperx@gmail.com, kdasu.kdev@gmail.com Subject: [PATCH stable 5.4 3/3] mmc: core: Default to generic_cmd6_time as timeout in __mmc_switch() Date: Tue, 17 May 2022 11:09:11 -0700 Message-Id: <20220517180911.246016-4-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220517180911.246016-1-f.fainelli@gmail.com> References: <20220517180911.246016-1-f.fainelli@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Ulf Hansson commit 533a6cfe08f96a7b5c65e06d20916d552c11b256 upstream All callers of __mmc_switch() should now be specifying a valid timeout for the CMD6 command. However, just to be sure, let's print a warning and default to use the generic_cmd6_time in case the provided timeout_ms argument is zero. In this context, let's also simplify some of the corresponding code and clarify some related comments. Signed-off-by: Ulf Hansson Link: https://lore.kernel.org/r/20200122142747.5690-4-ulf.hansson@linaro.org Signed-off-by: Florian Fainelli --- drivers/mmc/core/mmc_ops.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index d8f419183144..d495ba2f368c 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -460,10 +460,6 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, bool expired = false; bool busy = false; - /* We have an unspecified cmd timeout, use the fallback value. */ - if (!timeout_ms) - timeout_ms = MMC_OPS_TIMEOUT_MS; - /* * In cases when not allowed to poll by using CMD13 or because we aren't * capable of polling by using ->card_busy(), then rely on waiting the @@ -536,6 +532,12 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, mmc_retune_hold(host); + if (!timeout_ms) { + pr_warn("%s: unspecified timeout for CMD6 - use generic\n", + mmc_hostname(host)); + timeout_ms = card->ext_csd.generic_cmd6_time; + } + /* * If the cmd timeout and the max_busy_timeout of the host are both * specified, let's validate them. A failure means we need to prevent @@ -544,7 +546,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, * which also means they are on their own when it comes to deal with the * busy timeout. */ - if (!(host->caps & MMC_CAP_NEED_RSP_BUSY) && timeout_ms && + if (!(host->caps & MMC_CAP_NEED_RSP_BUSY) && host->max_busy_timeout && (timeout_ms > host->max_busy_timeout)) use_r1b_resp = false; @@ -556,10 +558,6 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, cmd.flags = MMC_CMD_AC; if (use_r1b_resp) { cmd.flags |= MMC_RSP_SPI_R1B | MMC_RSP_R1B; - /* - * A busy_timeout of zero means the host can decide to use - * whatever value it finds suitable. - */ cmd.busy_timeout = timeout_ms; } else { cmd.flags |= MMC_RSP_SPI_R1 | MMC_RSP_R1;