All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian Löhle" <CLoehle@hyperstone.com>
To: "adrian.hunter@intel.com" <adrian.hunter@intel.com>,
	Avri Altman <Avri.Altman@wdc.com>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "ulf.hansson@linaro.org" <ulf.hansson@linaro.org>
Subject: [PATCH] mmc: block: workaround long ioctl busy timeout
Date: Mon, 16 Jan 2023 14:38:53 +0000	[thread overview]
Message-ID: <68590206e8b044a2a71457cbbeda0794@hyperstone.com> (raw)

The ioctl interface allowed to set cmd_timeout_ms when polling for
busy on R1B commands. This was often limited by the max hw timeout
so work around it like for the sanitize command.

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
---
 drivers/mmc/core/block.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 20da7ed43e6d..ba3bc9014179 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -472,6 +472,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
 	struct scatterlist sg;
 	int err;
 	unsigned int target_part;
+	unsigned int busy_timeout = MMC_BLK_TIMEOUT_MS;
+	int poll_prog = false;
 
 	if (!card || !md || !idata)
 		return -EINVAL;
@@ -493,6 +495,12 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
 	cmd.opcode = idata->ic.opcode;
 	cmd.arg = idata->ic.arg;
 	cmd.flags = idata->ic.flags;
+	/* R1B flag might be removed here to work around hw, so save it */
+	poll_prog = (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B);
+	busy_timeout = idata->ic.cmd_timeout_ms ? :
+		MMC_BLK_TIMEOUT_MS;
+	if (poll_prog)
+		mmc_prepare_busy_cmd(card->host, &cmd, busy_timeout);
 
 	if (idata->buf_bytes) {
 		data.sg = &sg;
@@ -596,7 +604,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
 	if (idata->ic.postsleep_min_us)
 		usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);
 
-	if (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B) {
+	if (poll_prog) {
 		/*
 		 * Ensure RPMB/R1B command has completed by polling CMD13 "Send Status". Here we
 		 * allow to override the default timeout value if a custom timeout is specified.
-- 
2.37.3


Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


             reply	other threads:[~2023-01-16 14:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 14:38 Christian Löhle [this message]
2023-01-16 14:51 ` [PATCH] mmc: block: workaround long ioctl busy timeout Avri Altman
2023-01-16 15:03   ` Christian Löhle
2023-02-13 10:34 ` Christian Löhle
2023-02-13 19:25   ` kernel test robot
2023-02-14  1:51   ` kernel test robot
2023-02-13 13:38 ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68590206e8b044a2a71457cbbeda0794@hyperstone.com \
    --to=cloehle@hyperstone.com \
    --cc=Avri.Altman@wdc.com \
    --cc=adrian.hunter@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.