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;