From patchwork Tue Apr 14 16:14:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 185420 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp1601979ilf; Tue, 14 Apr 2020 09:14:49 -0700 (PDT) X-Received: by 2002:a19:d84:: with SMTP id 126mr347266lfn.35.1586880889391; Tue, 14 Apr 2020 09:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586880889; cv=none; d=google.com; s=arc-20160816; b=M9f//zRDliESlK3u+QijjUMs5kVQrkz1oDoGBc+nGPaMwGtHBzOu5FBAo3H1+19Cy+ WwaIWtevaTgWywhd9PLK7/X37mENZRe2ZnBORps8x53oOOiX/6eawQ1Y3BcWl3q5rYkL N5tPOuB4f1zyqUDGyzv00zjgztglcIEEGu8c1A+B7wFu5vwP/Wa/0gZW8VlnukAIkdl4 KgufPkxnfihp/WrZ7ft8cq11pruZhMAe20cJGka10XnJG0Q1ClfoLWKTjeWFpERUjXh9 DbxAs/lmSJ++UDRGjTAZHpwsNIAe5RDi+lIv4A4zMjQ7kSDDpjCiVbVG5FS6ok1INUD+ O+lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=zv/IOLWsE6pD23wlMRMWXhfDzTXImiUoTlOV8wP43+4=; b=VmJBVwUQOjxTq2cNmCWoup4RJ01B1e83zczUxeSgZr0Mp57iNUoiB2qeJcqXX28hR5 B7ukUePEehZ+p+VJkMegEB84WQeDv5pe/g/0shxlID8nQnN85TT4pgH5IWv5UYy0sxOG 2+Lz0mvmYwxVbQZnvdT+fM60cE9GvjtANuXdhBj5VZ6rtOTU4Tucd9H6jHLD1pHjKbmL XqLVgAJkVsVCqEuuEOr4UkqmqQaDTWfX8/59v9D5C/FPBYbdERdnZ70N+gV+qL/ptKbY awQA6Lb4VQokrPyp38gR6GbIh1v0jS/kKsV/vQrganCO4BTv+7gMGPOCIVWzyDn0jom8 KqSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UHJb2dW0; 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 z20sor8064100lji.27.2020.04.14.09.14.49 for (Google Transport Security); Tue, 14 Apr 2020 09:14:49 -0700 (PDT) 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=UHJb2dW0; 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 :mime-version:content-transfer-encoding; bh=zv/IOLWsE6pD23wlMRMWXhfDzTXImiUoTlOV8wP43+4=; b=UHJb2dW0l0J4LUncRFQvg4oVtCEMMEfdDnMzVHl4Wb88nTNDhPXS4ozS1vm9XGcZKt IfvNexRyTE2Spm1kKol/wWU5pDiYw4m2kvaJwON0+Cn+sYc9eZr4ZXmAwEI4s7BQT5Xs n6R34d2p7c4RmwmKSkxWQPtAhfZYxDm4JcKywmEP53UH7c4snGkwu5yip74qUrGOgCaC ymVnyf1IjMOoOQ/3XLz1JxXM7EYgZp6TGmNPcOFkWCEGOQdOwTEynckvodv06Llu7uyL 3ShoitgMKzNxKKUb9Wn1670P/aBKI/3rPTLthFCyPv5fY7yLYrjkMvbCPBH94Pyh0fdS nPPg== 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:mime-version:content-transfer-encoding; bh=zv/IOLWsE6pD23wlMRMWXhfDzTXImiUoTlOV8wP43+4=; b=opRSD2Y/MJs7Y7PdY3BGXT3691Jkn/ZjmbHrtkJU1mC7oBtKm/7D9zX5nv/77J/KV7 6izAGiQuVAX+q0zjnkdMaV1WOVy2QaSUmHBhUqeh0WUYMJvzIVTl1tCA88cYmNrf2ztn b0k9bwiuG5mJRGEf1BNkMqXgnVzWfaFdVgGlcvsckgwaxdHIYCwma8gXmeq06rm+pfNa ysUXi143w77vHt9ZcZhC+OSk/wBV8A7g7zcbAGL8lkr5esrr1OreYEvM43eJPHTn2zht A/yOSZ0mCRWYlFZeZO32Pm9G6c/meGFJWv5n4ySGzEd48nzxGzeNSTwgO6nFWOszjzoP p6IQ== X-Gm-Message-State: AGi0PuZGYkCFRR+AnmfVnGUpordOo2cgwyBXg2PlKsjsi9bYCPYlXT04 psXKE2zWORM6a+lHh8lzm0T0MwFt X-Google-Smtp-Source: APiQypLsgjIE3PF75iBeDOhwcxLS1kxYncfn8xlwnEfL4bMgnXmWOTMFNs0FTXbcxwkDIQPy+TzD7g== X-Received: by 2002:a2e:9813:: with SMTP id a19mr510612ljj.215.1586880889001; Tue, 14 Apr 2020 09:14:49 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-131.NA.cust.bahnhof.se. [98.128.181.131]) by smtp.gmail.com with ESMTPSA id a26sm9330669ljn.22.2020.04.14.09.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 09:14:48 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Linus Walleij , Rui Miguel Silva , Johan Hovold , Alex Elder , Greg Kroah-Hartman , =?utf-8?q?Jonathan_Neusch=C3=A4fer?= , Bruce Chang , Harald Welte , Alex Dubov , Sascha Sommer , Manivannan Sadhasivam , mirq-linux@rere.qmqm.pl, Jesper Nilsson , Lars Persson , Paul Cercueil , Ludovic Desroches , Nicolas Ferre Subject: [PATCH 18/19] mmc: mmc_spi: Respect the cmd->busy_timeout from the mmc core Date: Tue, 14 Apr 2020 18:14:12 +0200 Message-Id: <20200414161413.3036-19-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414161413.3036-1-ulf.hansson@linaro.org> References: <20200414161413.3036-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Using a fixed 3s polling timeout for all commands with R1B responses is a bit problematic. For some commands it means waiting longer than needed for the polling to be aborted, which may not a big issue, but still. For other commands, like for an erase (CMD38), may require longer timeouts than 3s. In these cases, we may end up treating the command as it failed, while it just needed some more time to complete successfully. Fix the problem by respecting the cmd->busy_timeout, which is provided by the mmc core. Cc: Jonathan Neuschäfer Cc: Linus Walleij Signed-off-by: Ulf Hansson --- drivers/mmc/host/mmc_spi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 5768fe9f8f6f..39bb1e30c2d7 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c @@ -242,6 +242,7 @@ static char *maptype(struct mmc_command *cmd) static int mmc_spi_response_get(struct mmc_spi_host *host, struct mmc_command *cmd, int cs_on) { + unsigned long timeout_ms; u8 *cp = host->data->status; u8 *end = cp + host->t.len; int value = 0; @@ -340,9 +341,11 @@ static int mmc_spi_response_get(struct mmc_spi_host *host, /* maybe we read all the busy tokens already */ while (cp < end && *cp == 0) cp++; - if (cp == end) - mmc_spi_wait_unbusy(host, - msecs_to_jiffies(MMC_SPI_R1B_TIMEOUT_MS)); + if (cp == end) { + timeout_ms = cmd->busy_timeout ? cmd->busy_timeout : + MMC_SPI_R1B_TIMEOUT_MS; + mmc_spi_wait_unbusy(host, msecs_to_jiffies(timeout_ms)); + } break; /* SPI R2 == R1 + second status byte; SEND_STATUS