From patchwork Tue Feb 4 08:54:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 183067 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp5064383ile; Tue, 4 Feb 2020 00:55:25 -0800 (PST) X-Received: by 2002:ac2:5f74:: with SMTP id c20mr14525818lfc.15.1580806525633; Tue, 04 Feb 2020 00:55:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580806525; cv=none; d=google.com; s=arc-20160816; b=IABSdAQuoltk31ft4V+yNbUy4GHTOIjIv8uhjeY25N66uJTEU5HP37eogs6WmD/2wZ Ek2JPWwsk8QMiJS/AUlA0v2XUwWIxcp8QroWQSHmp8T3vSq4h7t+QWAI8+yaxfpz0S4y ReD7DolMyONr7IrTnFpadnW8BIHmtQOcYDJ3SBMyHxiuWEOZnKJbJ4v2tS5uEWEXgmrq YdloM4KblYVV1hR2Q0ngUG0sf10vwNBLLZy4uDnuz/Yf1AAy1/lfdMaQgazKH/A8Jrdv D3/UJVNh5ZDEKrGTCeAg8P7k+zvIYULXGCyz0zXqwrV/xIS/XBp/NCDUV1vL+PY6fD2q 0iiA== 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=KLjqRxjOu37hotK4LZ6sgid1xsi6x3z1IsXdytiYo/0=; b=OeorspGgLlib0U4hYvNVHD/W2Inc6jKGQ4YPY++Vydeu8fXUAa8I9P6rLAbsp8wVBq Z03kAQd9EU5OOiAnAOyEsLJWZ2ZNg3drrJL+mzlNkpRCOH6ijlE7mfa3yl+4v67WtYPn akBK5znbBshnDe6QqDKhV03+iYOG7dJVt91PSWfN8ERFF2LW4kM/88MerJhMG6DpfLGE kkBeD9ImY+y61DKHxSzXI9wch1rwCuY7ooLuTYlbjDEz7kAZ29m4uOqAagWT9y7RC9Ob IjPMFyLjMaYe/TwTn0jH4wsiZAt5nnU32zXMJYByDF8tU4a9au25xLrN/jhzQt25vQVV s15A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r5GdvLAX; 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 q14sor12243566ljh.45.2020.02.04.00.55.25 for (Google Transport Security); Tue, 04 Feb 2020 00:55:25 -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=r5GdvLAX; 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=KLjqRxjOu37hotK4LZ6sgid1xsi6x3z1IsXdytiYo/0=; b=r5GdvLAXN9EdLzVKnNrEIQlTqye2BCI+enOv/sqW+eNnO41xvphgSQ+xKMnCMSRJDM /3J0K6p27Ll3Eu3aUjPPf/VMbNgmDsNx9ZNL05Yajs/wGE8i0ITNJnBLrwhrCdq55h1e 5ScBvEc3pZo1MDGiTa7LYf95U6otdEDxAe8J18l5p0OsB/zfjIsDRVXKO/4/gKHY0ukK huGNt/yAFmwIlpf0oCvd++l1p5gWVolqk8ZprpzwKsyw2ptX0AOg77tlMCKpUYQLFrB0 JgbC7wJW7tkDses99Pig4geGlbqndqEFdmbo4iZQI4j/jS/BJ9G2flz09MNX00lUJIrb af4Q== 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=KLjqRxjOu37hotK4LZ6sgid1xsi6x3z1IsXdytiYo/0=; b=cEGFxAbRiGRM8Bgy2s2jD8khp534xv6WU4XnY9qQODP9GjXskx07yaIFNRXRxZ9BKj zNdFLeeKXKFATy/d333jOr8wSqiGJwEMs33qjhZBB7bsIiW1UEBbrlY95Hcn3rO3D5TE lpOMKPBl8Ye9ybwuc5osLcD5urhycCjmbN0eL8f80cXk+YcoW7Ga1BfgTZe6VyfxX5sG q2t2Aywl27k2JTvnpAIUDVLln/pOIJD87NgksCwPayDzhscxTpsWv9DLFF9xeXc9pJAg KaZB4UGH4QFb4F5O6asZgdwFihduFwj0eoTogYIw/0hawu8J1TZ4yows6KTxbzJsRMlZ K4cA== X-Gm-Message-State: APjAAAVgVel42KZy/uCG+cghTzeGo2IAM9PjQyG98xLRjN6kaIP+fiqj cVLeID7aW0sZ2I6wT0XGY0W5TIpN X-Google-Smtp-Source: APXvYqzyE9gMGXnT5ZFghzMWHqfr+J/2GenIi3CD0MpPlBQcqyhts9H7Vi4hlfbeXiaqRqMRpIq2DQ== X-Received: by 2002:a2e:808a:: with SMTP id i10mr16669196ljg.151.1580806525240; Tue, 04 Feb 2020 00:55:25 -0800 (PST) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id n2sm11156283ljj.1.2020.02.04.00.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 00:55:24 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Wolfram Sang , Ludovic Barre , Baolin Wang , Linus Walleij , Chaotian Jing , Shawn Lin , mirq-linux@rere.qmqm.pl Subject: [PATCH 12/12] mmc: core: Re-work the error path for the eMMC sanitize command Date: Tue, 4 Feb 2020 09:54:49 +0100 Message-Id: <20200204085449.32585-13-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204085449.32585-1-ulf.hansson@linaro.org> References: <20200204085449.32585-1-ulf.hansson@linaro.org> The error path for sanitize operations that returns with a -ETIMEDOUT error code, is for some reason very tightly coupled with the internal request handling code of the mmc core. For example, mmc_wait_for_req_done() runs code at completion of requests, to check specific sanitize errors. This is inefficient, as at it affects all types of requests. To improve the behaviour, let's move the error management for sanitize requests into ioctl_do_sanitize(), as it's really there it belongs. Moving the error handling requires retuning to be held, so let's do that. While updating this code, let's also take the opportunity to clean it up a bit. Signed-off-by: Ulf Hansson --- drivers/mmc/core/block.c | 33 +++++++++++++++++++-------------- drivers/mmc/core/core.c | 17 ----------------- drivers/mmc/core/mmc_ops.c | 3 --- include/linux/mmc/core.h | 3 --- 4 files changed, 19 insertions(+), 37 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 8ac12e3fff27..db59c51052df 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -410,29 +410,34 @@ static int mmc_blk_ioctl_copy_to_user(struct mmc_ioc_cmd __user *ic_ptr, static int ioctl_do_sanitize(struct mmc_card *card) { + struct mmc_host *host = card->host; int err; if (!mmc_can_sanitize(card)) { - pr_warn("%s: %s - SANITIZE is not supported\n", - mmc_hostname(card->host), __func__); - err = -EOPNOTSUPP; - goto out; + pr_warn("%s: SANITIZE is not supported\n", mmc_hostname(host)); + return -EOPNOTSUPP; } - pr_debug("%s: %s - SANITIZE IN PROGRESS...\n", - mmc_hostname(card->host), __func__); + pr_debug("%s: SANITIZE IN PROGRESS...\n", mmc_hostname(host)); - err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_SANITIZE_START, 1, - MMC_SANITIZE_REQ_TIMEOUT); + mmc_retune_hold(host); + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_SANITIZE_START, + 1, MMC_SANITIZE_REQ_TIMEOUT); if (err) - pr_err("%s: %s - EXT_CSD_SANITIZE_START failed. err=%d\n", - mmc_hostname(card->host), __func__, err); + pr_err("%s: SANITIZE failed err=%d\n", mmc_hostname(host), err); - pr_debug("%s: %s - SANITIZE COMPLETED\n", mmc_hostname(card->host), - __func__); -out: + /* + * If the santize operation timed out, the card is probably still busy + * in the R1_STATE_PRG. Rather than continue to wait, let's try to abort + * it with a HPI command to get back into R1_STATE_TRAN. + */ + if (err == -ETIMEDOUT && !mmc_interrupt_hpi(card)) + pr_warn("%s: Sanitize aborted\n", mmc_hostname(host)); + + mmc_retune_release(host); + + pr_debug("%s: SANITIZE COMPLETED\n", mmc_hostname(host)); return err; } diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 6b38c194d74f..95db8ffbdd35 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -403,23 +403,6 @@ void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) cmd = mrq->cmd; - /* - * If host has timed out waiting for the sanitize - * to complete, card might be still in programming state - * so let's try to bring the card out of programming - * state. - */ - if (cmd->sanitize_busy && cmd->error == -ETIMEDOUT) { - if (!mmc_interrupt_hpi(host->card)) { - pr_warn("%s: %s: Interrupted sanitize\n", - mmc_hostname(host), __func__); - cmd->error = 0; - break; - } else { - pr_err("%s: %s: Failed to interrupt sanitize\n", - mmc_hostname(host), __func__); - } - } if (!cmd->error || !cmd->retries || mmc_card_removed(host->card)) break; diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index aa0cab190cd8..c08f8b723a3b 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -595,9 +595,6 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, cmd.flags |= MMC_RSP_SPI_R1 | MMC_RSP_R1; } - if (index == EXT_CSD_SANITIZE_START) - cmd.sanitize_busy = true; - err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); if (err) goto out; diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index b7ba8810a3b5..29aa50711626 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h @@ -107,9 +107,6 @@ struct mmc_command { */ unsigned int busy_timeout; /* busy detect timeout in ms */ - /* Set this flag only for blocking sanitize request */ - bool sanitize_busy; - struct mmc_data *data; /* data segment associated with cmd */ struct mmc_request *mrq; /* associated request */ };