From patchwork Tue May 17 18:32:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12852871 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 E3730C4332F for ; Tue, 17 May 2022 18:32:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352188AbiEQScf (ORCPT ); Tue, 17 May 2022 14:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236152AbiEQSc3 (ORCPT ); Tue, 17 May 2022 14:32:29 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0772517C9; Tue, 17 May 2022 11:32:22 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d17so18133785plg.0; Tue, 17 May 2022 11:32:22 -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=gl/4AJ7Cg2JSrI1J5T3voQUF9eM/BVXgo43onu7DnJA=; b=LXZPescd/0efMq7QxYUQswhy7KmAm7WXHyyuFnoBI0lupbX0iESYI7IQbrtEzw32iS vIZcfrafU49YDPEHFszrtKdQcgEGHTdzGBEkB8th3jHrhWMi6R670PvKvvePCxMa+/dW r0Q2I/WCRj2dhzRsyztJ3LgatscRVbJ4WNzZehs/CpCleaLoBdCiTJH3G42MLZKSlWkk JST9Ook+jMIFDR2wkjH/u5bYjiyAI2AKxs7k2HLbEwDUaCEQW692COjXBysd2Yq3lxgP HWCBZV+7vVOpkTqjp4Vmp+iwFRwrKHtDFW/Qtxcd5bhO31bz0Koz2W2BRx5cbrOj4kOj +qOg== 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=gl/4AJ7Cg2JSrI1J5T3voQUF9eM/BVXgo43onu7DnJA=; b=GsdUwLwd+EGeCf+GSSRGL3Y4MjqGuvmdASErbnwX1fcT5rk79hmeBW7rQnhTHQMCty tykDFIiFCOAdgy6uFdGmcst5iySJgiMKNIz9PL00Q6TuujLOls7FsAPd5N9Ng/bBldyE 3wIyT0EiOYRaa+C1uTa9OjKQEHlc0YBXfv9unKTFhowIwEZRlmx66ulwEuXOcT6tksBg NnJ98A/IIBWrVtTMu+7of0VMXKPLhu1LdqPoeQdYBuD6I1qvYfD8w4ihvGQgJrRx1Roq UliSXb5rItfJeACTRDOmk5cAznV2x8N1TCUqwTRXH2iLl3Aj1XQhMS+Zook7F7+6Hml9 +aAA== X-Gm-Message-State: AOAM532EncCKjT/pMo71GQBpd9fSle2B5Nkz+UbC/YAc5rSVQSi3gJU6 pBqW66tsmUXF7+7ODFgzaFtJWBBxYKI= X-Google-Smtp-Source: ABdhPJytTFfVTyULaEC/jxTxxlyYjnNEqcirSiBZWV1z2SxVYBLNltoBCeSBkMtYYK1plvS5tHkaTg== X-Received: by 2002:a17:903:244f:b0:15e:bb9a:3aa9 with SMTP id l15-20020a170903244f00b0015ebb9a3aa9mr23432797pls.78.1652812342038; Tue, 17 May 2022 11:32:22 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id d26-20020a634f1a000000b003c619f3d086sm8950355pgb.2.2022.05.17.11.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 11:32:21 -0700 (PDT) From: Florian Fainelli To: stable@vger.kernel.org Cc: Ulf Hansson , Kamal Dasu , 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 Subject: [PATCH stable 4.9 1/3] mmc: core: Specify timeouts for BKOPS and CACHE_FLUSH for eMMC Date: Tue, 17 May 2022 11:32:05 -0700 Message-Id: <20220517183207.258065-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220517183207.258065-1-f.fainelli@gmail.com> References: <20220517183207.258065-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: Kamal Dasu [kamal: Drop mmc_run_bkops hunk, non-existent] Signed-off-by: Florian Fainelli --- drivers/mmc/core/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index f0fa6a799f7c..dfe55e9d729f 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -61,6 +61,8 @@ /* The max erase timeout, used when host->max_busy_timeout isn't specified */ #define MMC_ERASE_TIMEOUT_MS (60 * 1000) /* 60 s */ +#define MMC_CACHE_FLUSH_TIMEOUT_MS (30 * 1000) /* 30s */ + static const unsigned freqs[] = { 400000, 300000, 200000, 100000 }; /* @@ -2936,7 +2938,8 @@ int mmc_flush_cache(struct mmc_card *card) (card->ext_csd.cache_size > 0) && (card->ext_csd.cache_ctrl & 1)) { 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:32:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12852870 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 E4C7BC433EF for ; Tue, 17 May 2022 18:32:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352228AbiEQSce (ORCPT ); Tue, 17 May 2022 14:32:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352159AbiEQSc3 (ORCPT ); Tue, 17 May 2022 14:32:29 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DA603D1D4; Tue, 17 May 2022 11:32:24 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id i17so18077114pla.10; Tue, 17 May 2022 11:32:24 -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=Oac74zs7UeOjKQRdpb+Td3T589EU3K7hbAq7QVHJ8PM=; b=mbYKyuopYnBMN0wBO01acMUKoUrcyNW3nt8q++Bf7DBwrpIhdw6LAqIHosfMBWQrkm ZBdQBdYvFAasCMQxvZAPcGh156vfQYcfmwrw5IAhjUcekYZLgYqeyZi/nGLeW+c9QV0P 4EBKwkk3kfiXXhJIj5Fu16jIFkMUYMhlNw7oR8XHukXOWHERrcp3Ol64r3h2GEpTXxpT oqc28+YsjkftRCHWBb7XnpMrRT/Ab6AyFsBJwrgM6ELCFws4aBRBFbjGqqXANFL5l4Hj xYJBPp5/sQHo2ZN7LI2NE9D+vagfZztsHTdDowk3zNLhgyArKr/J+irLmYZUTXSl+Ksr t4oA== 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=Oac74zs7UeOjKQRdpb+Td3T589EU3K7hbAq7QVHJ8PM=; b=EZqNOAh/hVkFgdGnnod/gN5W0CfToT5M17LI0ji1kAZmF1Wr9rr/HNbCTiJQpg9Q6E SVAQcuUSvh8mep4S15MEq6dq4feAynUdE9+wRL6UQBfEgzzpKqTZD0L0zjXhyzjh4PGx gJnP9Q6GPMVuwDxwiNYqEpVLa+fZCAnwJG2Fbs3Vxv8lR3WtdSfNvzO6kuxTQpnf29gj AzAFy2oobzXUOf/+BYguWEQUWAuDGvDY7aMTl2lkvueRWuTQxD+f1yc9dszFq5TQPF74 S7NRhaARv8OcFJ9MKPR7sN24JyKiH0sZJd1tqrQrEmoIfZg6bUIcjzquaAT5UCHV6VM+ IUOw== X-Gm-Message-State: AOAM531pAIFRogndYwdtsjZC5XF4z92hyUzZmwo9ZFoqoV4NoLCQ6/f1 FMuqDqiFAzRWY/biWuLvF/zSHpJ/5Ds= X-Google-Smtp-Source: ABdhPJx2Zze5zEix5qgl1h8ATK7J5FIyAyyumQCrYGBGA2GNLBWNpKicrUIWz5ZBVhB1TLGMhwYgiw== X-Received: by 2002:a17:902:d48d:b0:15e:c236:4fd3 with SMTP id c13-20020a170902d48d00b0015ec2364fd3mr23479962plg.113.1652812343400; Tue, 17 May 2022 11:32:23 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id d26-20020a634f1a000000b003c619f3d086sm8950355pgb.2.2022.05.17.11.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 11:32:22 -0700 (PDT) From: Florian Fainelli To: stable@vger.kernel.org Cc: Ulf Hansson , Kamal Dasu , 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 Subject: [PATCH stable 4.9 2/3] mmc: block: Use generic_cmd6_time when modifying INAND_CMD38_ARG_EXT_CSD Date: Tue, 17 May 2022 11:32:06 -0700 Message-Id: <20220517183207.258065-3-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220517183207.258065-1-f.fainelli@gmail.com> References: <20220517183207.258065-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 ad91619aa9d78ab1c6d4a969c3db68bc331ae76c upstream The INAND_CMD38_ARG_EXT_CSD is a vendor specific EXT_CSD register, which is used to prepare an erase/trim operation. However, it doesn't make sense to use a timeout of 10 minutes while updating the register, which becomes the case when the timeout_ms argument for mmc_switch() is set to zero. Instead, let's use the generic_cmd6_time, as that seems like a reasonable timeout to use for these cases. Signed-off-by: Ulf Hansson Link: https://lore.kernel.org/r/20200122142747.5690-3-ulf.hansson@linaro.org Signed-off-by: Kamal Dasu Signed-off-by: Florian Fainelli --- drivers/mmc/card/block.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 709a872ed484..7b8c72a07900 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -1192,7 +1192,7 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) arg == MMC_TRIM_ARG ? INAND_CMD38_ARG_TRIM : INAND_CMD38_ARG_ERASE, - 0); + card->ext_csd.generic_cmd6_time); if (err) goto out; } @@ -1235,7 +1235,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, arg == MMC_SECURE_TRIM1_ARG ? INAND_CMD38_ARG_SECTRIM1 : INAND_CMD38_ARG_SECERASE, - 0); + card->ext_csd.generic_cmd6_time); if (err) goto out_retry; } @@ -1251,7 +1251,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, INAND_CMD38_ARG_EXT_CSD, INAND_CMD38_ARG_SECTRIM2, - 0); + card->ext_csd.generic_cmd6_time); if (err) goto out_retry; } From patchwork Tue May 17 18:32:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12852872 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 77228C43219 for ; Tue, 17 May 2022 18:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352233AbiEQSci (ORCPT ); Tue, 17 May 2022 14:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352259AbiEQSc3 (ORCPT ); Tue, 17 May 2022 14:32:29 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DFFC517D9; Tue, 17 May 2022 11:32:25 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id c2so369715plh.2; Tue, 17 May 2022 11:32:25 -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=MRi64/PwuNw25RzXmUxNDrjHI6TIqkB2bzuLr80n4x0=; b=YlKqY7mSqg1Y4uGarG6CW5TziiwkWrwLN4qJFbQwbCrJZZmvKpqPSM1E8Jqcr0NUnJ KMkmxPgIPD4S3BHOMnEYXLVc79NKZx6wHmSkWwgcDzOs1ON4xxwEirNBEOcm7z2+/Qld 11Fn/4Uh5IzAkch0AZU5UOkQzKIyN1ALy5DZkpf7Oa4pLUEv6GPbRVsePHuDDEvN9q5b NRY63nhagddXTXX5QTnGINp/Cy38hFcvhVVA97gMlNMzy0S0285WQ4abbNASWkOWtxNo eVgwNyKQhWWas2ZJtjHszBPn++Jy+ZAcSShXU8o3hnqc9Mmb5fxsX0YL+dQGE3S7wkcR k82g== 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=MRi64/PwuNw25RzXmUxNDrjHI6TIqkB2bzuLr80n4x0=; b=xZht1+iGkoKOQWyhuteMVEkrfxIQdxCx8U8W+4ldUDnpiurldNiPxuSGvStW5pSHlY tTMfDDjSK0X85/U5LIGVNR01Fak7uw+VaWSt9n53jmnv3VY8J/b8HSDffW+9UOxKg/Bq y2pSDZ4dC2RQim4lokah3oGwH0kbYXc1JK95L4OSgLnFPJl0LTC99vtl+md7AkTpeojW /9QxyQ6nXz4sogElBHAbrEUClB7ZO+yj6nqfv1c6aXLEKK+Nwau/mA09XPA0iuTySCut Woov7XFLN1ULzoZ6bHQ7lGEWMAeRFZVAyRfVF+9kLrAi+l8yOe/AObmitMGmeyDsRNwo uQgw== X-Gm-Message-State: AOAM533TlPszUqUt7Z3zlqYpHjJBAIqYO1OQhgL4nR+T9wRgwTRsXuuW R4DKULP+7LdLqkD1CwCY28j5lVsoRXc= X-Google-Smtp-Source: ABdhPJxZfECC+6xgBYrxA3YgS6Q2OHNJnbGxs8+1BRVQu/DPC4W/MT3yN+QdFoywWSEOEuHtcLZB9g== X-Received: by 2002:a17:902:d2c6:b0:161:6e0e:c5e1 with SMTP id n6-20020a170902d2c600b001616e0ec5e1mr12520168plc.139.1652812344793; Tue, 17 May 2022 11:32:24 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id d26-20020a634f1a000000b003c619f3d086sm8950355pgb.2.2022.05.17.11.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 11:32:24 -0700 (PDT) From: Florian Fainelli To: stable@vger.kernel.org Cc: Ulf Hansson , Kamal Dasu , 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 Subject: [PATCH stable 4.9 3/3] mmc: core: Default to generic_cmd6_time as timeout in __mmc_switch() Date: Tue, 17 May 2022 11:32:07 -0700 Message-Id: <20220517183207.258065-4-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220517183207.258065-1-f.fainelli@gmail.com> References: <20220517183207.258065-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: Kamal Dasu [kamal: Drop non-existent hunks in 4.9's __mmc_switch] Signed-off-by: Florian Fainelli --- drivers/mmc/core/mmc_ops.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index ad6e9798e949..3d8907fc2a52 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -22,8 +22,6 @@ #include "host.h" #include "mmc_ops.h" -#define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ - static const u8 tuning_blk_pattern_4bit[] = { 0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc, 0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef, @@ -530,8 +528,11 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, ignore_crc = false; /* We have an unspecified cmd timeout, use the fallback value. */ - if (!timeout_ms) - timeout_ms = MMC_OPS_TIMEOUT_MS; + if (!timeout_ms) { + pr_warn("%s: unspecified timeout for CMD6 - use generic\n", + mmc_hostname(host)); + timeout_ms = card->ext_csd.generic_cmd6_time; + } /* Must check status to be sure of no errors. */ timeout = jiffies + msecs_to_jiffies(timeout_ms) + 1;