From patchwork Tue Apr 14 16:14:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 185409 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp1601635ilf; Tue, 14 Apr 2020 09:14:29 -0700 (PDT) X-Received: by 2002:a19:cb41:: with SMTP id b62mr349788lfg.21.1586880869637; Tue, 14 Apr 2020 09:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586880869; cv=none; d=google.com; s=arc-20160816; b=zwHAd7Jc0xT+IR5MKsyP1WNxRvgRDiTw+iG6AswZuRsukY7Suk5qKTsDfC/Toog/+9 Pyzbn7qtAm0tLcq4bgWW8bk2AzHiaP2UEvEkEWwnrg7BdF0zvncrcEwLXkL1amuOODqk eFRRrF1vP5fguo68uZ8hjs0DBtTeZXCEFO0dIrRbt2ZwAeWYTbndkSnGQp/BeY9Y8yDl xd9m2r9DN1nD7+J5JQgoxdnOPCAR3pm+HlDxcN/vY2mAOZn9t8JfLCV2at43cc5VgzZV 9wMXAzPlSFlQCuoS2wOkOYl1VmL73Tc4kWmqwzPQezEe1RP1ykWxvduhKpDGGaPhHH5W G0ng== 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=Drk5vikO+eMqgoiRlkCCu1nIyTRzBQ4eNzUPfgIrlk0=; b=dmMUWXwKpZbwmzLHbekFUfjmJLG8n7oMfZHL7l9vZWkKQwnlZzK3NBoTwaTxQkKSnZ jWy4Ij+okV2v7eNe9gEgN5QLkp82FCe6rCeAwQbU5p6SCLkq0dBFgbTW4Zfh1glVfI4i pTWIUZ+0iwa8tZlykGm3foL5MZpDcV04oXxyQAQfxqpC8kj9DE9py6Tqr9FHbGfVl6xg MM1Z9zU9JR7N99Io2BaJVKZcs0mjtoIjw8sYGSRNhcBvJMaK9FW6Azow9t+Khq+SF3iY yFNfxg5HRuon41Rr/KGIuy3wIvrfoENhwhI5KD/DvfbHvyXk1jGax1893JDxujIVQTI/ Q77g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f8tt1y6f; 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 n196sor4171019lfa.4.2020.04.14.09.14.29 for (Google Transport Security); Tue, 14 Apr 2020 09:14:29 -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=f8tt1y6f; 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=Drk5vikO+eMqgoiRlkCCu1nIyTRzBQ4eNzUPfgIrlk0=; b=f8tt1y6fsUG4FuFOTOxcmCUl1y8XY4OykCcWGg3sdeQ3pDiqvmiZ7kVd2xkOinMQX/ Lr5HBkGlDH2aWz/Biy5r5L/ia7J1Hr1kPq7pZswKNjxGgVYq5JV7KgijmMcbQqt7Xr9J WKx52zGAU2O3ULVisvpbNXtcsPHWX76fGbfOgKw1tOvsqQbvM32ZPAZs/7ir4cqv9bfx OILu4jihPtYoWNQxbW7GhW2Poh53TEXuvzqGvV+7NfTJK6o4MlkbamvHA/KtCwhz5exH Bf7eE7DrkKIxqD/fk2qUAdye4LYKJsvQsR5mlGn/ZPnX129uX/GURaKVEKYNePDO5mxF 8X3Q== 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=Drk5vikO+eMqgoiRlkCCu1nIyTRzBQ4eNzUPfgIrlk0=; b=dBF4H60OTLlV5JI73lQxvhvWr+ABlvmcjGWH+FBZkUJgB/hNsoxcuMMCep9bZapgsk 7ZP9+zFJMPFjsVO2XoSm1W5CWO+1EYwxJ+Hu+3Eea/E9OQ2Td0YEtatAtHRb0gxbkYGC xdcY50TRt4t6B/YXkNDS7BglUZKCEUNjEjVz56rHRlLIkMuw/2iPfndwyXJR8dCzpypK FwH1gFD4KkgmdCiXa7K7s5X+7Mf0Za8IJ9FLeqGdEwArAyQeLMiqfSAr2Xwr1CAgnCmO Dpg0GejE22ZMg2dmwO5htXRO4dtwCI3D0nv/+Fxd3ngrE0IRNVQz+cMaVtJa7UCvTN1l gT3Q== X-Gm-Message-State: AGi0PuYNLJ6qmepxG2tnZwslX82sPX/ILXA9vhCIz6AQAw4qOw8rQY7z yxLFYArc6qBL2xVAeP/G8w1AKqpg X-Google-Smtp-Source: APiQypJgAn6RWPcdZxUy7YdttREG6dpFC9F1so2iARfkwl8BaVEyPKJpOcK0U7i9LQV4UmYygU+KxQ== X-Received: by 2002:ac2:46ea:: with SMTP id q10mr370834lfo.128.1586880869221; Tue, 14 Apr 2020 09:14:29 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 09:14:28 -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 07/19] mmc: owl-mmc: Respect the cmd->busy_timeout from the mmc core Date: Tue, 14 Apr 2020 18:14:01 +0200 Message-Id: <20200414161413.3036-8-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 For commands that doesn't involve to prepare a data transfer, owl-mmc is using a fixed 30s response timeout. This is a bit problematic. For some commands it means waiting longer than needed for the completion to expire, which may not a big issue, but still. For other commands, like for an erase (CMD38) that uses a R1B response, may require longer timeouts than 30s. 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: Manivannan Sadhasivam Signed-off-by: Ulf Hansson --- drivers/mmc/host/owl-mmc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/mmc/host/owl-mmc.c b/drivers/mmc/host/owl-mmc.c index 01ffe51f413d..5e20c099fe03 100644 --- a/drivers/mmc/host/owl-mmc.c +++ b/drivers/mmc/host/owl-mmc.c @@ -92,6 +92,8 @@ #define OWL_SD_STATE_RC16ER BIT(1) #define OWL_SD_STATE_CRC7ER BIT(0) +#define OWL_CMD_TIMEOUT_MS 30000 + struct owl_mmc_host { struct device *dev; struct reset_control *reset; @@ -172,6 +174,7 @@ static void owl_mmc_send_cmd(struct owl_mmc_host *owl_host, struct mmc_command *cmd, struct mmc_data *data) { + unsigned long timeout; u32 mode, state, resp[2]; u32 cmd_rsp_mask = 0; @@ -239,7 +242,10 @@ static void owl_mmc_send_cmd(struct owl_mmc_host *owl_host, if (data) return; - if (!wait_for_completion_timeout(&owl_host->sdc_complete, 30 * HZ)) { + timeout = msecs_to_jiffies(cmd->busy_timeout ? cmd->busy_timeout : + OWL_CMD_TIMEOUT_MS); + + if (!wait_for_completion_timeout(&owl_host->sdc_complete, timeout)) { dev_err(owl_host->dev, "CMD interrupt timeout\n"); cmd->error = -ETIMEDOUT; return;