From patchwork Thu May 19 18:45:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12855918 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 392CBC433EF for ; Thu, 19 May 2022 18:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241410AbiESSpt (ORCPT ); Thu, 19 May 2022 14:45:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233931AbiESSps (ORCPT ); Thu, 19 May 2022 14:45:48 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA5A8E03; Thu, 19 May 2022 11:45:45 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id u15so5838164pfi.3; Thu, 19 May 2022 11:45:45 -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=tqc9CjYXSuy6AdiCkGL4DWkq+ghQRYbszthnl1/c6ug=; b=DLosP//U/yqmP4buDsONCNH/Ob1xACs5t9tAIStn+sl0+Vi/cQtkNdAw+x3WcmXQ+2 yPhSI9nOBaHVCutLBYmoQ/irIakkaWj8hA8+MINvPLi5cv0PvCcyMqLyHiMjxmrVyZmy d0QkWDkvXFb/iR22eStlHemj/L4Aka2U0cawm5mQbighGlwLrRvdfOqVt4ombvVowyIq 8zTocD9IXxqfEqb3HyrP7e7Me8pd3u7ISA0TFmayH1NWrGol0qSqKEk54CdbRWhaV/5i kja38E9QmGuwpSTKFMm/cKRzeP7h/8USyS4BZjVeT9Tr0TbLdriqjJ9/z1/1BrSmXhH5 4wRQ== 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=tqc9CjYXSuy6AdiCkGL4DWkq+ghQRYbszthnl1/c6ug=; b=QhaC9/exJezP1OArtkO9ara+xngOa/PMq7Zie1Z8Wmu60mgf4OsZ5k32cjOq9Dze9n ConruTyQMZOXmWPEzaLj8IM+zu7RhAn1oQRj07j27KdlpHWKwP6jtEu3cZxWwvItKNFa rGgd98oI85ZQDx/Q5Eovl21I8FRo0mwQTza2P8QdewjBWUfE5HAqeh7KrYvHbNZAVaLR fCKR62tDEBbKAbSJYrtoFlzvpotAHyWzSh5WOna2YwRs2b8tO8QxVpBTOkTolHb9GSmI HjO3zpRabwk3SpFGNgE3VYePWjaGVTOlQK8WA3WBMnXu4d4tVnmLd45sKMHh49iCY/5V dojw== X-Gm-Message-State: AOAM531aRLFaD73av5Q/Vnn0Z/liVmTUV5/jzD4WPzlJ2eqAajhNncDq 9gmcJDyZ1EvEV4pkdJzNvthCN+TaRAY= X-Google-Smtp-Source: ABdhPJynkSnH8pHBmbNKiNxYCNpc7fxmj6jYs7F2C5z8LeHEfuohaVMAWE27vylvVZpTfsJz6XpUTw== X-Received: by 2002:a63:2057:0:b0:3f5:fd47:754f with SMTP id r23-20020a632057000000b003f5fd47754fmr5088566pgm.440.1652985944926; Thu, 19 May 2022 11:45:44 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 5-20020aa79245000000b0050dc76281c2sm2965pfp.156.2022.05.19.11.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 11:45:44 -0700 (PDT) From: Florian Fainelli To: stable@vger.kernel.org Cc: Ulf Hansson , Jaehoon Chung , 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 4.19 v2 1/4] mmc: core: Cleanup BKOPS support Date: Thu, 19 May 2022 11:45:33 -0700 Message-Id: <20220519184536.370540-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220519184536.370540-1-f.fainelli@gmail.com> References: <20220519184536.370540-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 0c204979c691f05666ecfb74501e7adfdde8fbf9 upstream It's been ~6 years ago since we introduced the BKOPS support for eMMC cards. The current code is a bit messy and primarily that's because it prepares to support running BKOPS in an asynchronous mode. However, that mode has never been fully implemented/enabled. Instead BKOPS is always executed in synchronously, when the card has reported an urgent BKOPS level. For these reasons, let's make the code more readable by dropping the unused parts. Let's also rename mmc_start_bkops() to mmc_run_bkops(), as to make it more descriptive. Cc: Jaehoon Chung Signed-off-by: Ulf Hansson Signed-off-by: Florian Fainelli --- drivers/mmc/core/block.c | 2 +- drivers/mmc/core/card.h | 6 +-- drivers/mmc/core/mmc.c | 6 --- drivers/mmc/core/mmc_ops.c | 87 ++++++++------------------------------ drivers/mmc/core/mmc_ops.h | 3 +- 5 files changed, 21 insertions(+), 83 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 630f3bcba56d..d8bcf1e0b337 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1944,7 +1944,7 @@ static void mmc_blk_urgent_bkops(struct mmc_queue *mq, struct mmc_queue_req *mqrq) { if (mmc_blk_urgent_bkops_needed(mq, mqrq)) - mmc_start_bkops(mq->card, true); + mmc_run_bkops(mq->card); } void mmc_blk_mq_complete(struct request *req) diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h index 1170feb8f969..eef301452406 100644 --- a/drivers/mmc/core/card.h +++ b/drivers/mmc/core/card.h @@ -23,15 +23,13 @@ #define MMC_STATE_BLOCKADDR (1<<2) /* card uses block-addressing */ #define MMC_CARD_SDXC (1<<3) /* card is SDXC */ #define MMC_CARD_REMOVED (1<<4) /* card has been removed */ -#define MMC_STATE_DOING_BKOPS (1<<5) /* card is doing BKOPS */ -#define MMC_STATE_SUSPENDED (1<<6) /* card is suspended */ +#define MMC_STATE_SUSPENDED (1<<5) /* card is suspended */ #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT) #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) #define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR) #define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC) #define mmc_card_removed(c) ((c) && ((c)->state & MMC_CARD_REMOVED)) -#define mmc_card_doing_bkops(c) ((c)->state & MMC_STATE_DOING_BKOPS) #define mmc_card_suspended(c) ((c)->state & MMC_STATE_SUSPENDED) #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) @@ -39,8 +37,6 @@ #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) #define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC) #define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED) -#define mmc_card_set_doing_bkops(c) ((c)->state |= MMC_STATE_DOING_BKOPS) -#define mmc_card_clr_doing_bkops(c) ((c)->state &= ~MMC_STATE_DOING_BKOPS) #define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED) #define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index d9202f2726d1..745a4b07faff 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -2026,12 +2026,6 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) if (mmc_card_suspended(host->card)) goto out; - if (mmc_card_doing_bkops(host->card)) { - err = mmc_stop_bkops(host->card); - if (err) - goto out; - } - err = mmc_flush_cache(host->card); if (err) goto out; diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 334678707deb..6d759fc6165d 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -899,34 +899,6 @@ int mmc_can_ext_csd(struct mmc_card *card) return (card && card->csd.mmca_vsn > CSD_SPEC_VER_3); } -/** - * mmc_stop_bkops - stop ongoing BKOPS - * @card: MMC card to check BKOPS - * - * Send HPI command to stop ongoing background operations to - * allow rapid servicing of foreground operations, e.g. read/ - * writes. Wait until the card comes out of the programming state - * to avoid errors in servicing read/write requests. - */ -int mmc_stop_bkops(struct mmc_card *card) -{ - int err = 0; - - err = mmc_interrupt_hpi(card); - - /* - * If err is EINVAL, we can't issue an HPI. - * It should complete the BKOPS. - */ - if (!err || (err == -EINVAL)) { - mmc_card_clr_doing_bkops(card); - mmc_retune_release(card->host); - err = 0; - } - - return err; -} - static int mmc_read_bkops_status(struct mmc_card *card) { int err; @@ -943,22 +915,17 @@ static int mmc_read_bkops_status(struct mmc_card *card) } /** - * mmc_start_bkops - start BKOPS for supported cards - * @card: MMC card to start BKOPS - * @from_exception: A flag to indicate if this function was - * called due to an exception raised by the card + * mmc_run_bkops - Run BKOPS for supported cards + * @card: MMC card to run BKOPS for * - * Start background operations whenever requested. - * When the urgent BKOPS bit is set in a R1 command response - * then background operations should be started immediately. + * Run background operations synchronously for cards having manual BKOPS + * enabled and in case it reports urgent BKOPS level. */ -void mmc_start_bkops(struct mmc_card *card, bool from_exception) +void mmc_run_bkops(struct mmc_card *card) { int err; - int timeout; - bool use_busy_signal; - if (!card->ext_csd.man_bkops_en || mmc_card_doing_bkops(card)) + if (!card->ext_csd.man_bkops_en) return; err = mmc_read_bkops_status(card); @@ -968,44 +935,26 @@ void mmc_start_bkops(struct mmc_card *card, bool from_exception) return; } - if (!card->ext_csd.raw_bkops_status) + if (!card->ext_csd.raw_bkops_status || + card->ext_csd.raw_bkops_status < EXT_CSD_BKOPS_LEVEL_2) return; - if (card->ext_csd.raw_bkops_status < EXT_CSD_BKOPS_LEVEL_2 && - from_exception) - return; - - if (card->ext_csd.raw_bkops_status >= EXT_CSD_BKOPS_LEVEL_2) { - timeout = MMC_OPS_TIMEOUT_MS; - use_busy_signal = true; - } else { - timeout = 0; - use_busy_signal = false; - } - mmc_retune_hold(card->host); - err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_BKOPS_START, 1, timeout, 0, - use_busy_signal, true, false); - if (err) { + /* + * For urgent BKOPS status, LEVEL_2 and higher, let's execute + * synchronously. Future wise, we may consider to start BKOPS, for less + * 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); + if (err) pr_warn("%s: Error %d starting bkops\n", mmc_hostname(card->host), err); - mmc_retune_release(card->host); - return; - } - /* - * For urgent bkops status (LEVEL_2 and more) - * bkops executed synchronously, otherwise - * the operation is in progress - */ - if (!use_busy_signal) - mmc_card_set_doing_bkops(card); - else - mmc_retune_release(card->host); + mmc_retune_release(card->host); } -EXPORT_SYMBOL(mmc_start_bkops); +EXPORT_SYMBOL(mmc_run_bkops); /* * Flush the cache to the non-volatile storage. diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h index a1390d486381..018a5e3f66d6 100644 --- a/drivers/mmc/core/mmc_ops.h +++ b/drivers/mmc/core/mmc_ops.h @@ -40,8 +40,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, bool use_busy_signal, bool send_status, bool retry_crc_err); int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, unsigned int timeout_ms); -int mmc_stop_bkops(struct mmc_card *card); -void mmc_start_bkops(struct mmc_card *card, bool from_exception); +void mmc_run_bkops(struct mmc_card *card); int mmc_flush_cache(struct mmc_card *card); int mmc_cmdq_enable(struct mmc_card *card); int mmc_cmdq_disable(struct mmc_card *card); From patchwork Thu May 19 18:45:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12855921 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 95948C43219 for ; Thu, 19 May 2022 18:46:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244062AbiESSpy (ORCPT ); Thu, 19 May 2022 14:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243300AbiESSpu (ORCPT ); Thu, 19 May 2022 14:45:50 -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 200E2109E; Thu, 19 May 2022 11:45:47 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id 137so5831613pgb.5; Thu, 19 May 2022 11:45:47 -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=5SU+w9hgi+POXdxltfAITobv8QuuLB+odkG94GhTEgs=; b=HCPGXLIowEc4TfgLek+X1SwnRfZRLrsaNkVMgzWo3/y686rkolUMxTgvCnVXNzWJqz pXCIpNKvu51NII8Py9T5e+JZPGhlHoZ2QM5xGzFgsML2ELFnPvQrhrMPHzpN5OKYkzhH jFnQmoIgbCo9hwUpTXeyU+PLfVR6VPKujV3sD9V25PVW5Lr1AlSdGJwhDgFGpdjUFJfR O/UEKSPjNkyjnK3mwuDHBlWQgYT+Aw/s2eu56nS3JoibZvQobz7VCOHQaxfNd0o5CWua 2xzEx9Kym2ErT7tZcWyZdnHkNz6lFf07t8YTshfoRYJD8SY+6bOkJvMamPhiBwo52Szn Am4g== 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=5SU+w9hgi+POXdxltfAITobv8QuuLB+odkG94GhTEgs=; b=QZ3TiqXac96hGkPkX7mAL/Sg/tEmA13rUvgO4w5BHtOgv6tlBZ140uvdGRn3UXhl8p nI2RUm4Q+txagLQvuIb9mBrwF8GQvGobBKcFAUEE/6/dzdUwUfREGzKPs4CcgHhDCVkG QntpZAt5WexRUSse2l2DK/5GMFGPcLufp/9ZIuGtTIXylEKgdk9za11SAnikdlW7s2Iv ajFIMZf/iejdPeGUiFwhIY3hvZNKMSkPqW4OnehXcuPD0xp+QYmJExZwaknk4zBzQKko mbuaUJYgjZECfyymYm02gyrdr2uGfpzKkWvNs37xebTHBEmcre+E+vIGXrA3jChe5gBC P1/A== X-Gm-Message-State: AOAM5302pDBqKuc6k0Y3mOQRGwqWBaHK9D/BtqWa6sFsgcfYaqS95Eyo UaXYK22gz0LwadHxaKOa7O3XYgxJVuk= X-Google-Smtp-Source: ABdhPJzTj/U5wGU2C/aGMOITBrjbWQSEEa8cjr65o044OgIUCMFwmEH2e/Gxe0Q9tsZLtevJro52xA== X-Received: by 2002:a05:6a00:1c76:b0:510:8b76:93b5 with SMTP id s54-20020a056a001c7600b005108b7693b5mr6171900pfw.44.1652985946249; Thu, 19 May 2022 11:45:46 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 5-20020aa79245000000b0050dc76281c2sm2965pfp.156.2022.05.19.11.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 11:45:45 -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 4.19 v2 2/4] mmc: core: Specify timeouts for BKOPS and CACHE_FLUSH for eMMC Date: Thu, 19 May 2022 11:45:34 -0700 Message-Id: <20220519184536.370540-3-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220519184536.370540-1-f.fainelli@gmail.com> References: <20220519184536.370540-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 6d759fc6165d..2b0bfead730a 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -23,7 +23,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, @@ -947,7 +949,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); @@ -965,7 +967,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 Thu May 19 18:45:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12855922 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 74EAFC4332F for ; Thu, 19 May 2022 18:46:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244057AbiESSpw (ORCPT ); Thu, 19 May 2022 14:45:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243296AbiESSpu (ORCPT ); Thu, 19 May 2022 14:45:50 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6358A2192; Thu, 19 May 2022 11:45:48 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id z7-20020a17090abd8700b001df78c7c209so9539374pjr.1; Thu, 19 May 2022 11:45:48 -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=iVjd1/EvWaUwXfqtYGQYzVVFnQ1gXdjk50qNj+0oQ6A=; b=pqBrRfWnGfmlO7DN6JqKh6vWUqA1p8Xg14czQ4dwzHHNyGUrXQBcWIZCjzP6N2dgA5 RsJoYKTa7oaXBxLIwRpOaIGx7ypL8rN7YKKsbfjtgcxUptUgoXFziGBRiejkn6F/ggPr C+w6UjHt7rizNRBYj6Mv1jcxtn3tOALNk1rBkXoC6DKIUROhIU2ieszoK60zgjjSDqlr 45dQFSGSItVHODh+GdukwFeq6g7KoxVqaj8w1lqcPCTyDu0AoMZVL0PAc4EIcLE2tG+D Gsr/Kqg9UeERMn/lZJ2mn6JsdlF2Ok8UHvMnYT24+feCdcpJQQjnPOzbFPAMDqHNfMe/ qDjg== 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=iVjd1/EvWaUwXfqtYGQYzVVFnQ1gXdjk50qNj+0oQ6A=; b=t97Jurx4UDzbuWZhHYreevfbXYEz9BUuLAfXXBnv7VjbYaXNLDY/uW7VlpT02Uu/lf hnp9jJbejgCb8o5jT5Hxa6WRer4lS6KupOxtd17VMvRdEjvLByyFchQJJLzX0n7fPpL3 N5VYLh2t2XZ0fIFWvNQrROF1k1/LV8CJx5cKcVj8/qlcKK1sgAKHafrs7Xs9DY4oT49U skwDfAuVgxd+M4I0UwiUqTO37F4outsP2XxGuGVf9C2tjkTEdh2y0zFj2j9YOkdpmFCJ 0yt2l+XCoqfrXsbP6DQMxjWgVTgLKVKxI0Z8lJdnWdVwujSWBwvRiMi9LGyjgmiMb7bv rYuw== X-Gm-Message-State: AOAM5300ucLWrKh5/65TOH1FhEDkyWTUweYIi1d0fOIoGOZ7Z6Dtu2Nf X60hOeMTunDwZVi8YkL4HDftHusMHk8= X-Google-Smtp-Source: ABdhPJwzk08FWAy+yUBTXj2QGpGnjLjx6Tc5fUvqRWFQZQUJnv2ncHp88mtToOd0+hdEuDm1PLAk4w== X-Received: by 2002:a17:90a:9b0d:b0:1dc:e81d:6c18 with SMTP id f13-20020a17090a9b0d00b001dce81d6c18mr6629643pjp.72.1652985947575; Thu, 19 May 2022 11:45:47 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 5-20020aa79245000000b0050dc76281c2sm2965pfp.156.2022.05.19.11.45.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 11:45:47 -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 4.19 v2 3/4] mmc: block: Use generic_cmd6_time when modifying INAND_CMD38_ARG_EXT_CSD Date: Thu, 19 May 2022 11:45:35 -0700 Message-Id: <20220519184536.370540-4-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220519184536.370540-1-f.fainelli@gmail.com> References: <20220519184536.370540-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: Florian Fainelli --- drivers/mmc/core/block.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index d8bcf1e0b337..c6e83f6021c1 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1133,7 +1133,7 @@ static void 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) err = mmc_erase(card, from, nr, arg); @@ -1175,7 +1175,7 @@ static void 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; } @@ -1193,7 +1193,7 @@ static void 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 Thu May 19 18:45:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12855920 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 A5351C43217 for ; Thu, 19 May 2022 18:45:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244054AbiESSpw (ORCPT ); Thu, 19 May 2022 14:45:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243348AbiESSpu (ORCPT ); Thu, 19 May 2022 14:45:50 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA6B72BCE; Thu, 19 May 2022 11:45:49 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id a38so2954124pgl.9; Thu, 19 May 2022 11:45:49 -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=ZzqOqhSTkWyW6a60hc2pV5v/t4bQqt425oCJrlN7gc0=; b=qsypusjSlrTckBPP5ArDLAECrZ8fySUH4miXGfSSc1QlMcM/cxx5aubfqQGjVVmVkW 4vK2X6kHRFe78UZntaE9zvoQG9NSwIpXrPyjnvTWvVaNBIMTGa4aSc4Aje7a16SW2ZBn U7bzRAV5yIgW8af417CkMh8BCqa793GsEBbgNTctMPuSGWNc8T6r4fuBlcfkav2ZRIWJ XBZ2xAvvFrMJguTA+7qYo1VyBQeVWWIy1j7oyyGr5Yy4UndiW42xykJw+eA4BtaQwhlo Xxf+Nl6XMXP9Mj+iVekEeRk9csU3HM3vSKVhbQFm6TXHMh5RYfLP7FPSLKppRA2qKYH8 h1wA== 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=ZzqOqhSTkWyW6a60hc2pV5v/t4bQqt425oCJrlN7gc0=; b=Zq89Otm4t8V+g85UXdcZwp5PRC84rfnH+bZQolBwV37Zxcqt8wVcqA4+VEl7LHbp2x DDEg47zCdRkLSsRXv1azSPs1GpLvs8Z7lVAg9MR5uBUvdfBcg/193lp+v1O8LkIbc3ci tLT7b3hMUTUzPueUzQxpULFwyRunzSYebwl0JcVdnEQiuvJA+1C3WvXmnFIqgCIuIpOf KqjwwnQXT1hDWwSe+s5sZYTjB/3Q9tM9JicojbJrwgFzLyWihS3QoU3+Ar1sEVfTfROa a27n7Cr7lCwGLgZyqC2tXBv5iNlA3CwSaqfKSYevLzHjV8KRErbKxvEJq/Cl3lLvJtG1 /zSQ== X-Gm-Message-State: AOAM5336D5kUHhLyc+FzpJ6eDFnHbjfg+CQN6ri0sQF7zN4yoK5rv2vw 7NZjAIt07gNXrrj5y12d0/L6r/APUtM= X-Google-Smtp-Source: ABdhPJxRdCTc0olvpIJOOzMkLS6FI1DrpkkBY8Bh9LqDwibV6e8SzxsEAVa/ebrSGs4MaYcULA91hQ== X-Received: by 2002:a05:6a00:4086:b0:518:3207:f9df with SMTP id bw6-20020a056a00408600b005183207f9dfmr5999716pfb.9.1652985948802; Thu, 19 May 2022 11:45:48 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id 5-20020aa79245000000b0050dc76281c2sm2965pfp.156.2022.05.19.11.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 11:45:48 -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 4.19 v2 4/4] mmc: core: Default to generic_cmd6_time as timeout in __mmc_switch() Date: Thu, 19 May 2022 11:45:36 -0700 Message-Id: <20220519184536.370540-5-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220519184536.370540-1-f.fainelli@gmail.com> References: <20220519184536.370540-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 2b0bfead730a..c2187fc6dcba 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -458,10 +458,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 @@ -534,6 +530,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 @@ -542,7 +544,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; @@ -554,10 +556,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;