From patchwork Tue Apr 14 16:14:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 185416 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp1601859ilf; Tue, 14 Apr 2020 09:14:42 -0700 (PDT) X-Received: by 2002:ac2:5e65:: with SMTP id a5mr323204lfr.189.1586880882321; Tue, 14 Apr 2020 09:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586880882; cv=none; d=google.com; s=arc-20160816; b=lk2HCMdqI6soPdWoezOQjBFks2+TYePhevfBdKmXpJl2WtkPD1aqSwpAsyklxkI48z fhlCg5zw2fTK3vLvp8IXXvFWeeXt/eLl+nVoUaYh+DHlWNt0ZegvIruKbumjT50uP85g DcU/Ypdwu9UtcWoxxtj7C2pHYGhsnWfJTxhnFU/zh9+2c4KEqsAqUOjOIBnW1pSHCj+K usDfxCpiXvANYRVTlSjTpY157G/KzU02dmx4Zq7gCYOnGeAdL+mJS9izFP2vOTy11q2i N2svzaR2/54pWZGJlUGtztI3efSTDC+ykuUDcOr/FQ47af/brUkgSKoJG/pf47wohSSq 3Khg== 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=NAYTGOzmF1yJPLoKf5SgLIcN0uv0T4GhbNXd2UBLOr8=; b=xi9DlWQK8WJyT82q80EDPhqBGP/p8AbslI116iwzvW+5xaz1eeKtDb+1N+iK71fdU9 7xqd/ndgfFIt9scTKoUR7n+fNRbSp0Pb4Oq0A8b7lxNnkvGj+F7axt6ANDhC0N8tUFYN kpW3Dwg9qiuV3v1XmpeoufVq+KjMhyReHY1nkDOrycofSgkb/QxhBlplHnh4MdZrVCI2 A8cFiidGpoo0XjgKDCq4sEBwvQum/lS1S1D9FHE83oaaT3fKCeebOrruMG8Vej76/CWF 3j4Jdy7Ushk4u5tVVAdTx/UuZemfArGVi+UHx4AqDiishCHzVpFzjVIFlKggwHlHz8fb kM3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gfl+HsJW; 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 t206sor4068437lff.8.2020.04.14.09.14.42 for (Google Transport Security); Tue, 14 Apr 2020 09:14:42 -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=Gfl+HsJW; 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=NAYTGOzmF1yJPLoKf5SgLIcN0uv0T4GhbNXd2UBLOr8=; b=Gfl+HsJWMnWxD/gVNOZTbUdrOLFGtdIuGd3A8G7HoKyhcEA2BIiVTchOnmhPA2whJS bUecBLlWxzcifZpDbNPwUR8K2vocMXWcsRWSNRZ5z4iPoq8DPJpFIbPcaoBFW5Pg2gum awSIam4Mk5yBSkR9AlMJxjOtvO3CUdx6CE+KURe7wvfGbaP6ILwTO+aBLLP5+Njk/HBQ d5L0x5hq/mwv96kzvHWeBvRISzLaCyk8rKXCwGo0qx/un7Std0fkZcHA6wtDYA0pX0ty vDz+5uByI/OkDCWwo/1sltsZG8dLoi4o7LQjDIVGHyRQWcRs2UebcdC/maA4HmpuMxBE fS5A== 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=NAYTGOzmF1yJPLoKf5SgLIcN0uv0T4GhbNXd2UBLOr8=; b=a//92ssNsdXzUqUaVXFNLPCEOA1FtKwZFYmmkwWK6Gdrys1AjmTwPJt1nqrO9pNA3I YMhbSxZERTos6mE7ru6IEqNmbjKh48g7qBbruojbVCI9pDZ8k652kx4eH8/lnzR6kCiB NjrXHAyA0xcGSkoUBBEUs9QJrzrXK/aXSHDTUOyraju5kZHTh9w/L8jPyBJHDiRWM5qh OYwceXdrcBfpOucwzmPf5INqo7r0AwzTr0kdv0hGzqQHkox1UOeAq7VKehEY7kS0YdVy OeDZ0JnzmywPDGb5gqLuiloKhPLLLzazeW/KsK0FyKBmQ8qxPGrtsZ/+J0JxVv+uuBl7 0l7g== X-Gm-Message-State: AGi0PuYdQD9XM/lR0f/JTaaETMEoFHcIj4cQINSg5ZcVaCSkMaqcwiNB eyZ/lRZdH6pgen3bHVPavt7cIjuj X-Google-Smtp-Source: APiQypKUcnnytIGM2wn/odlVBvvnKz1gy03LB0EZt3MMj6rUtiVm4dzoyP886GmhOPzQBrhDOmbqtw== X-Received: by 2002:a05:6512:1046:: with SMTP id c6mr335101lfb.115.1586880881907; Tue, 14 Apr 2020 09:14:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 09:14:40 -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 14/19] mmc: sdricoh_cs: Respect the cmd->busy_timeout from the mmc core Date: Tue, 14 Apr 2020 18:14:08 +0200 Message-Id: <20200414161413.3036-15-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 1s polling timeout for all commands 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) that uses a R1B response, may require longer timeouts than 1s. 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. Note that, even if the sdricoh_cs driver may currently not support HW busy detection on DAT0, some comments in the code refer to that the HW may support it. Therefore, it seems better to be proactive in this case. Cc: Sascha Sommer Signed-off-by: Ulf Hansson --- drivers/mmc/host/sdricoh_cs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c index d7a191f14337..dfd395ff7c3e 100644 --- a/drivers/mmc/host/sdricoh_cs.c +++ b/drivers/mmc/host/sdricoh_cs.c @@ -156,7 +156,7 @@ static int sdricoh_query_status(struct sdricoh_host *host, unsigned int wanted) static int sdricoh_mmc_cmd(struct sdricoh_host *host, struct mmc_command *cmd) { - unsigned int status; + unsigned int status, timeout_us; int ret; unsigned char opcode = cmd->opcode; @@ -178,9 +178,12 @@ static int sdricoh_mmc_cmd(struct sdricoh_host *host, struct mmc_command *cmd) if (!opcode) return 0; + timeout_us = cmd->busy_timeout ? cmd->busy_timeout * 1000 : + SDRICOH_CMD_TIMEOUT_US; + ret = readl_poll_timeout(host->iobase + R21C_STATUS, status, sdricoh_status_ok(host, status, STATUS_CMD_FINISHED), - 32, SDRICOH_CMD_TIMEOUT_US); + 32, timeout_us); /* * Don't check for timeout status in the loop, as it's not always reset