From patchwork Wed Jan 22 14:27:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 182918 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp5149227ile; Wed, 22 Jan 2020 06:27:54 -0800 (PST) X-Received: by 2002:a19:5504:: with SMTP id n4mr1795190lfe.25.1579703274754; Wed, 22 Jan 2020 06:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579703274; cv=none; d=google.com; s=arc-20160816; b=DM7CwAfk/mGkjwEr4tleL0rIevOZvUq8oNm5H483y9AYVw6ccvAOqaO5NMev1A0ssL xrjvRvuC4G0cElCj2GUwbYaVx2iKGM+HwsgGqjDLwDb4vJn02N3RyT10Xeja//cdFwJ3 d60JAJcGT4o6VlUuqKiZkU2ZHyqA42dBZwZ/0CM/1NN7GI00kWtlSs8otrmhskSYOl1Z HlYMM88EN7q+7wu/hy/hwB3hBTVSWFknLW9sBtDx2mhzQ9L4UoRLpM/Gn9LmltvtAsbg NP55U+XxpcHxVpBDu/5WMLtdi1bVfuUq9Lnn1dIrhBaYoV+bivD4+RUtNcWg1+L5ZiWO tHzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u69ihC/ZR+aWt0/0qdjrRugRF6Lbl1PlbpQFAVv2gC4=; b=xEVMfZ8vWenD5s1yRBQxIv9STW2VvMHU4lMpA1oonDitC3JnuURQItswhW3BDG12MC LYmZ37pwIl11v5B4W1b3kLkNWixZXmaRMkLVv57irmUmwkahelH7YbrWYhb7w3gBleph CxivYBe1PM1ZK3j+94gkWrSa+lNNexkYkqpNx9WMK9rF+wp5uqHMdsHNT9IOvCinlhSP vws4zOcvUeenHTGQAmWLwhwySm0FGJD6UWYBVd7mqzL4I9iNutTE8PFZPLOffS5NcCfs zSjJKoAwan5YL4U2TzEHU4xX3uEAD0EUcX6X3FURvTTT+za1cuUXAilkKgPjKj9YRXol INjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rSQaUcuD; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r4sor12288460lfn.69.2020.01.22.06.27.54 for (Google Transport Security); Wed, 22 Jan 2020 06:27:54 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rSQaUcuD; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u69ihC/ZR+aWt0/0qdjrRugRF6Lbl1PlbpQFAVv2gC4=; b=rSQaUcuD9WYbFQDeILVt5uWXtC+pYCIbQTmp8rklMfgzJezqUvAmNBdusbpnMXhL9n EWdrbS4rvBkTSapeIsyu6TY4ZmacFWWuGPEWrpaQTwPAKX2Sqe269HU4+Jl70y+3X1hD ytum1u2/qb0DM+2gOimtRxoh77QvmIff2kDFsmq40gTjrpTP79wdEsPlgcBm7IJZ/tP/ pTUtKAygC7lkiDa7E26/4dfUeIyy5qfb9hIScBc1pTyO4yBj24yf/P1Ecre1MjRd080Q piTBfKDeS9NIHq5QsbjdBIOYJFOwdn9cZMjUNqznQZBfxOdYBh6jjTsWajrtcjUNlHm1 3SIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u69ihC/ZR+aWt0/0qdjrRugRF6Lbl1PlbpQFAVv2gC4=; b=o2oI+mSKgwv0ON3CARr0ncZIftFa+JGs2gTRM+1a412f9MrbXjeUY7krjahuGAUElm aEplP6jlSZtSUKk1qJnCM//hCvb5ihcM5ZJh6NlYWRIkmNs1sCsxAcrzCnrEmTn0G9V3 LwrhhZfSDF86dXnvgToiTHmTN35D+LLU7Oz3QA3BcSGKmjBDT7EOkTbtwsFpVeKyUE4M efmX7k5bSwSoLa9zmVyQ/Rcb89lqPjy6Qp0FWg/hjgbnBPAlHhHrAVzyGAsmfCYahBpW 6EAspH7takO7eJ7KyBY4kVIBoEgXiRR6hHeFnJKKik8G8R1Zn852Oahii7e1WXXrDk5p m0Nw== X-Gm-Message-State: APjAAAXCqFXf3qxO7bwJ/FffVIeZqzRh0H3RamDbqrNzyp7Xt5Pv6SEv ZKf/X3u6wnay3JGEZ9QK6ka3E9fHt/jolg== X-Google-Smtp-Source: APXvYqz3doFCmwXxXT6oY4So5XrFSZ4pwNSnSrhsOXkF8afaGw1nGLZtjWtykC5JK4h3PWjzgjy1Bg== X-Received: by 2002:a19:c697:: with SMTP id w145mr1978294lff.54.1579703274214; Wed, 22 Jan 2020 06:27:54 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u17sm20369548ljk.62.2020.01.22.06.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 06:27:52 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Chaotian Jing , Shawn Lin , mirq-linux@rere.qmqm.pl Subject: [PATCH 1/3] mmc: core: Specify timeouts for BKOPS and CACHE_FLUSH for eMMC Date: Wed, 22 Jan 2020 15:27:45 +0100 Message-Id: <20200122142747.5690-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200122142747.5690-1-ulf.hansson@linaro.org> References: <20200122142747.5690-1-ulf.hansson@linaro.org> 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 --- drivers/mmc/core/mmc_ops.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 09113b9ad679..1966abcbc7c0 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, @@ -941,7 +943,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) (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 Wed Jan 22 14:27:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 182919 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp5149266ile; Wed, 22 Jan 2020 06:27:56 -0800 (PST) X-Received: by 2002:a19:5013:: with SMTP id e19mr1955262lfb.8.1579703276769; Wed, 22 Jan 2020 06:27:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579703276; cv=none; d=google.com; s=arc-20160816; b=bMLVTCDB1tBEr8BrHfLZtCSxllia6IFP1x2Zr+xbPQpZGVqYTqQuKtStRiRf7vlhou /ZnyU9lBf8iqA/Z8CcEzS4a4RaDjQJT4VX3ywpoVc90L9Q96KaaYzxJ4QouDtRhV5I4u zW9NgYwqKe2nhiAi41lDTLWbqS0Y8r34MuN0H/Zs+iIwYM/b5+ro1K1vH6/MlF+pG2LY 2ITqviMD1dGo4GKTDPzjjaFzZnHuw0O534Gih0dJEENVs6u+clhMXwb+pM1Hq2oHjVL9 JOxyZoAxHv+DBN9XLVhz5aka2OE+Sq0nB4otnkXURKqHCWsPs4nhSBqSV/JH1tzEWSbM 7kdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7VzLcJjeEnS45bKw7Lmz/k90q+rRtqK0BCgzKkLywLM=; b=X5/uVFtgQ9QHufeIAMlxSt0cthGi2GBvkwCMq9QESjffHr8SG2+xr239Qq9NUzPF5a JsAvTGZn9gdLIQ1rN2dWSj2oZ6AS1qi3iVsT/OZz7YJr61KtDlIDb79RhJT628iOUlr1 eogUfwelZaihmbo5ZQ53r1QDGC+SdQS8r3FsVnmuDE0NOtx4JKMeB26NFCAAaNA/LoT7 6/12e86Mv0Bhonp3aUsATORW4AJU5VTLirKGcUrYdgyOZ6F3sNzQWuxm5+xHJKhVOFB9 aWrSOOd6FA7MgL53f9YJk/9LiEDKJ5D4U20FL7NaxDzjDVvenHWkrwzNyLRs/qqTelCn M4jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZB5T1AhW; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g15sor25280342ljk.9.2020.01.22.06.27.56 for (Google Transport Security); Wed, 22 Jan 2020 06:27:56 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZB5T1AhW; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7VzLcJjeEnS45bKw7Lmz/k90q+rRtqK0BCgzKkLywLM=; b=ZB5T1AhWhlYE9OxX4czvsDOmCie3OIq2PCb7t3+brXVJN03D6GPlKa9qMqFd99HI6X 3XnsPloGO2mJnQIgNFVxF+cucMuck6V1u5DIjxjfnb6UOn/Kj+B+R8vwi9GFxasDYD4q QibUbtru7HHBCqi1kTrxQ2MUZi6mBOVAH1ottkcYuVJKWAySJPRadOT4H+zOQIwR9PGW awqO6mW51Moye8qt5nFFVY2lVBwZwZLCUXreh55elFDSpXptkNhnLZ0Q/v0gXDchaJkZ ictvabxWEGB6IdMCAahlk3PJeGBZ8p6h08LhoW9QKh+wjJeKsRU5kW5glCEV3OmDe3lm x54A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7VzLcJjeEnS45bKw7Lmz/k90q+rRtqK0BCgzKkLywLM=; b=C8YtXs3TUvX+pcvE3hplz1IDaMi/gdWvWEQ9ATl5MAlQHqY8WNTY/yYHqzwGpx+wL5 y+qj+pzYtO8gExX5VTREXK3BLmsEpXUnGpIeHfaBosjg5jiEr+ELiWNYJgRaOJndcko5 COYu+KOm/BIGgdeu2/Iwimst35TVGOu2RKHZyVr/AkjE/1UJQJ1DmcZgrkxZlhvDAwur x9UcQC/0qWV2PcgwDCsT5WY45cQjenn9wzAwUhIi6LScunRQ77tRRnO80DgItPm1sJ8P NsqF+Ckr8GSlB3TuSHBiepMWMNzpTiQ7UZEFCSzdlYac3+z6ZQLuKaTWhIDmM/bCOkez 2n+w== X-Gm-Message-State: APjAAAXR8mY/FK7zVq/pBtvC1oPb79OcMf83y+GKqO9IhTOfbWmNQi7F xvKb7Yv9pCFcVqxHtvXd7XqSVYsb X-Google-Smtp-Source: APXvYqzlO8BGgEneuZccgn8tDP+LUmTOH9B89/9xKXCs35QSQAIAtq4lZyviJFDHB/ha87fK/REzaQ== X-Received: by 2002:a2e:9041:: with SMTP id n1mr19009718ljg.133.1579703276414; Wed, 22 Jan 2020 06:27:56 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u17sm20369548ljk.62.2020.01.22.06.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 06:27:55 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Chaotian Jing , Shawn Lin , mirq-linux@rere.qmqm.pl Subject: [PATCH 2/3] mmc: block: Use generic_cmd6_time when modifying INAND_CMD38_ARG_EXT_CSD Date: Wed, 22 Jan 2020 15:27:46 +0100 Message-Id: <20200122142747.5690-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200122142747.5690-1-ulf.hansson@linaro.org> References: <20200122142747.5690-1-ulf.hansson@linaro.org> 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 --- drivers/mmc/core/block.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 95b41c0891d0..663d87924e5e 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1107,7 +1107,7 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req) card->erase_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, card->erase_arg); @@ -1149,7 +1149,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; } @@ -1167,7 +1167,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 Wed Jan 22 14:27:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 182920 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp5149322ile; Wed, 22 Jan 2020 06:27:59 -0800 (PST) X-Received: by 2002:a2e:80d9:: with SMTP id r25mr19586132ljg.8.1579703278952; Wed, 22 Jan 2020 06:27:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579703278; cv=none; d=google.com; s=arc-20160816; b=OzH+dELvo7fsE+4KfYlgsU/jywgPCVwdCqFdNMV6F+sP37fI4ZdMO2X3zG6TZrIb6I PTLNKtmETGu35dbStkJtbaBdkV9+OVqQmpgZTNNTSptQsDygD7lWMKZ8ZnVMYC9OoZci nv6uPUvPPaL/i22FPC6atDCFgczFJj+baM50mCHS3tBcNJ2phvPePb2K8cJe3PHAgx4S ufRxViyI0BjY3xu2ZTbB1M4Af0rhwPnJxB9QrGW2hORy05SGr5O8eD56UoifX43a9xlp URxCXa6SaDT/0hnGbaLvti6YGoADhT7rYS0/3zLmp/fjcMXxheAW2cpvWEzGNsFQ/y3h D4NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iKMQyjxDBSc+wBx/1iQ6rTe3TF9m2VraA2r1zuub9Cs=; b=ck1dqi/JzHeuFEMEJn8JC8On/fQ3Z6licPZFKy2rV5mpb7DsWtxoe+3i21166P7dfn Wgul0blzN7tvigcgK7xMu/blaXwsOPhftq+ONvi+w8WY0vK8O0YfDUm/kDKklJI8MB3q MSsnzFePOpOF24Gmvqkk9OAsZTmwDPNGQaLPHvI/bN09XJfS5OZa3uKuF5ngFcR/T1Le /iQ6pVb3HygI/iRu7653+p9q8qvfgpwkVqP1f0Q3cVZ0gQhXxJNS3h0YHM/fljS+JA6e tNfHrZZp4HqTrocLpuqSASRxIda576KBkp/RdKg0PxTxNHQw+GleE8RjIjPus7YEonxD yFeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vCzxjkQf; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r8sor7725495ljk.0.2020.01.22.06.27.58 for (Google Transport Security); Wed, 22 Jan 2020 06:27:58 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vCzxjkQf; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iKMQyjxDBSc+wBx/1iQ6rTe3TF9m2VraA2r1zuub9Cs=; b=vCzxjkQf0eK5+n0Yvb5KS7tvQbyS0L/N38j8D0PSCIDPwdO86O32qKyP4tUM4P9pnZ +aOVG9nuZ/6L7VtsQZy+tmm2Lox8pRDM/dDSAC2E5Ec8ZFmWv6qRPl4qSmCNwxsSexx9 bHOT8t2IGpONPwgQA7O5HKltTsCQqwWfiXxEbxtnFyIDtMyb5jo9R2l3Or9XRxJ0tT7f PqwQwKDdfHILGdqZCKCPXB3M4OZw8/6N4eSSChyUYb5/WxKgqtiGgkJ5FXzS3b5yVXrq PvCFra1M2SvO0fXcov+J26WVwDJ0XOBd+xS941oR8CbAgixDFB1zRHh0fQw+OkTYsO9e WSyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iKMQyjxDBSc+wBx/1iQ6rTe3TF9m2VraA2r1zuub9Cs=; b=K/kJNbuEplEydd4K3o3WTxn9nQdSY9JdB49eD7q5BMR28qTcdPrx1ywSc0AMFn+bBI Wm8L3q3qy/8JQq02VHEiGKdUJ1rbUiDzgNdtcuSqmDsmP16hG3ZdeECGUUW8byfS2BD6 /OdHwRmThqORuwp3dU1xbpKu8Lwu3P2FOIsMPQmF12H9gdW1UrSSgYvdDkDGHna4Creq bGgrZdrCoHYX18HfXF45ThWoi1/uMVjcRARNWE5V+E/C9fcfPGh3x3Ptsw0yWCS52FNt 5cjhjIGDf1ORCnccsNt9UbkhAhyDE6UQft5m8SM5NxI+5cqf1kH2UdLYwDk07Bg9TrlD dTsw== X-Gm-Message-State: APjAAAVnU8hRtVHkaqXI11NMYZWGKuTS1DkO3rwfCjDCx/SdTQYICZTC Id55tMSncpyBvAk5oUBAk8tEapfY X-Google-Smtp-Source: APXvYqzJCmDh7AiySbGBM04U1xsULqeJFagf/nw765013LXaioofEr0/Si6wGBu+aBJy0uaZxItlUg== X-Received: by 2002:a05:651c:1110:: with SMTP id d16mr19627966ljo.86.1579703278423; Wed, 22 Jan 2020 06:27:58 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u17sm20369548ljk.62.2020.01.22.06.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 06:27:57 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Chaotian Jing , Shawn Lin , mirq-linux@rere.qmqm.pl Subject: [PATCH 3/3] mmc: core: Default to generic_cmd6_time as timeout in __mmc_switch() Date: Wed, 22 Jan 2020 15:27:47 +0100 Message-Id: <20200122142747.5690-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200122142747.5690-1-ulf.hansson@linaro.org> References: <20200122142747.5690-1-ulf.hansson@linaro.org> All callers of __mmc_switch() should now be specifying a valid timeout for the CMD6 command. However, to 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 corresponding code and clarify some related comments. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc_ops.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 1966abcbc7c0..da425ee2d9bf 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,14 +532,19 @@ 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 - * the host from doing hw busy detection, which is done by converting - * to a R1 response instead of a R1B. + * If the max_busy_timeout of the host is specified, make sure it's + * enough to fit the used timeout_ms. In case it's not, let's instruct + * the host to avoid HW busy detection, by converting to a R1 response + * instead of a R1B. */ - if (timeout_ms && host->max_busy_timeout && - (timeout_ms > host->max_busy_timeout)) + if (host->max_busy_timeout && (timeout_ms > host->max_busy_timeout)) use_r1b_resp = false; cmd.opcode = MMC_SWITCH; @@ -554,10 +555,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;