From patchwork Tue Feb 4 08:54:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 183062 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp5064270ile; Tue, 4 Feb 2020 00:55:18 -0800 (PST) X-Received: by 2002:a05:6512:4c6:: with SMTP id w6mr14233719lfq.157.1580806517935; Tue, 04 Feb 2020 00:55:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580806517; cv=none; d=google.com; s=arc-20160816; b=lGTkYYQo2jj/+YHutV3G0Aq9L8Zd91HKARSMrlN4eFAzwU/aif92Q8pPzMpqQM/3qI N7IaOO+nrjW2ZdQBtZNaYaWbBrkRioegByM/RwQy37Eoj09KtWPgGgcBnYKmvQ3jxsgP 1LxZhGMoHNgJ3+QOeLizdf6hUs6A20Syp11qZG5bd3FAtywgMrnSrfwcaXFgLgaHsKN0 kAPbGRlMVHtlOfDrfvQ4R4pIJJjwLdHIVDvZ46k0ZFgaswCyCTrEJro0bcsbInwj5MWL fyav876shpO9mDmSEUR4wUgeVzBNj8vmNPhC7d738c7JKEvSF6hPzpY2LON1cyK8NFTD iUjg== 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=HwDebRrklVLgKidfwiVAchc7w1c7H8+6yL91Fz1oklE=; b=q1d53pXPl4s41XTbZzOMQ7AEQcZSKg6M4yElkUv4C/D7Np9MrftxUMGiP8pnB59pSP nqow49WiSZOihynoVwTDgN3FbCpGiBDQqsNAd7QFo/6hOy6yUGantggOWB/e3ZHNdDbw OZqeLVXa3nKJ9Qy1TrogWS0r3TimnvAXja4kjQzK44+7/QNU1d9/YmeSPRNWY/Hjm8n4 7joRXuTGa9Wd08HRbIX7J/bJpACYw40hr0ODc6BcIc/EwkPG15trVYARDs6ZD2SE4wwg ZEoKo0MwhQag++rgIOdxVlEJDKuBJ2E8FXqOkZDD5O6c+RAu+dbGGsVKt5/d7zHKfcDT jwIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bAo8GMut; 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 p4sor12436760ljj.38.2020.02.04.00.55.17 for (Google Transport Security); Tue, 04 Feb 2020 00:55:17 -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=bAo8GMut; 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=HwDebRrklVLgKidfwiVAchc7w1c7H8+6yL91Fz1oklE=; b=bAo8GMut8ZjWRtKyXCSHaye3xTLNgyT6mpHK8vINZrV1rELokXMV+JtCngT6qEUsQP g4spROSGU0INQUEgvlRSPPj9I6KUwxtQ39wuooKIBZURGjFjkzeCxDIQCq3jsMFaBMZO AZh4pCU8crJNa+Yk+M/kbCuiFzZ2jTUnmySYZfNdRgE2ncVEN5+D97YSjVWhbSFI/QZf ZpLjVG2KX3J4Tpxwp7Jce01stmchbl6rLhBXd7ojON/4ht63tPj3ter9til6gIHkkn/c vW7mxZdjci2OlijwIsHRd9UEyDv9zYOO8Wg5WxpTjXpeMNF9n+zqtypPbmn7IMgO2/xJ 180Q== 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=HwDebRrklVLgKidfwiVAchc7w1c7H8+6yL91Fz1oklE=; b=sErZKCcRU2TLnTmDkGty8RMnatOrtzq/amE+t6QOh4u+MccbbtkDL0iOQRHPxwQlqu S/pAt1fkENDiGdtW0DxUopudQSuq9vrx6Waxa67A3uBnbHhVNeOSmub5q+vBsQ1mEVMK +yzly1AKX9EkLXVwcy7UwiKysAlWOh/i6Mnu3RExrPPMFzi5OqHUqRVH3DoCVcsnOWKc tynsP3zKr98D7NtvHItPj6DkWo8m2aommdHh6f0lisi8RbwJZYOhTia30P6fRQwZHtwa lZ801goCdD5gXpt5uUOaG/YaQPVyOIRBqUZS+rmeE18QCYvLQ9GyfuXwZMEHIK7jSGCQ IjZQ== X-Gm-Message-State: APjAAAUdZa2E+0TbIJo6jOE9XfYVMF1LSNXqZtOYItdLbNf0Nxzz+Edr 4NMTqdR+Ynvmo+ZABH6xZqLbbIAh X-Google-Smtp-Source: APXvYqzIqvoS373Ujxxhc+HIzb+LltY67F8iDrdbGB2IDZ7FD8K3h8fWuQDTv3CaYNLN6e/+kslrvA== X-Received: by 2002:a2e:9a01:: with SMTP id o1mr17111793lji.247.1580806517553; Tue, 04 Feb 2020 00:55:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 00:55:16 -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 07/12] mmc: core: Update CMD13 busy check for CMD6 commands Date: Tue, 4 Feb 2020 09:54:44 +0100 Message-Id: <20200204085449.32585-8-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> Through mmc_poll_for_busy() a CMD13 may be sent to get the status of the (e)MMC card. If the state of the card is R1_STATE_PRG, the card is considered as being busy, which means we continue to poll with CMD13. This seems to be sufficient, but it's also unnecessary fragile, as it means a new command/request could potentially be sent to the card when it's in an unknown state. To try to improve the situation, but also to move towards a more consistent CMD13 polling behaviour in the mmc core, let's deploy the same policy we use for regular I/O write requests. In other words, let's check that card returns to the R1_STATE_TRAN and that the R1_READY_FOR_DATA bit is set in the CMD13 response, before exiting the polling loop. Note that, potentially this changed behaviour could lead to unnecessary waiting for the timeout to expire, if the card for some reason, moves to an unexpected error state. However, as we bail out from the polling loop when R1_SWITCH_ERROR bit is set or when the CMD13 fails, this shouldn't be an issue. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index c17b13aacc6e..c14e24570b4e 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -468,7 +468,7 @@ static int mmc_busy_status(struct mmc_card *card, bool retry_crc_err, if (err) return err; - *busy = R1_CURRENT_STATE(status) == R1_STATE_PRG; + *busy = !mmc_ready_for_data(status); return 0; }