From patchwork Mon Dec 10 16:52:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10721767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EBA915A6 for ; Mon, 10 Dec 2018 16:52:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EDD12A810 for ; Mon, 10 Dec 2018 16:52:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4347F2A82F; Mon, 10 Dec 2018 16:52:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA73D2A810 for ; Mon, 10 Dec 2018 16:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727572AbeLJQwr (ORCPT ); Mon, 10 Dec 2018 11:52:47 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:35325 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726729AbeLJQwr (ORCPT ); Mon, 10 Dec 2018 11:52:47 -0500 Received: by mail-lf1-f65.google.com with SMTP id e26so8521056lfc.2 for ; Mon, 10 Dec 2018 08:52:45 -0800 (PST) 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=hqcZCX2GWMpTtbs35jhyR+WR9qxRRzYUjJ3v61z7O8g=; b=SzZgiMwImXTYxmO6NLTH1JL6c1KYRqjgTjyNBKcECG7awagPaj9WbMYcmDhSPmjStX XTlGweHmkteY5mLcoUGMef+PR5k2wrO+KxSQJil6AN4KsLdoRgpGE1jsJw4WWzNOZWy5 /WS9RjIN/UEvcI9VhvAmE8qAfZ9y30gmanRug= 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=hqcZCX2GWMpTtbs35jhyR+WR9qxRRzYUjJ3v61z7O8g=; b=J/9UbmvWfHc2xlhRy7zFjB4E/1vZgnWA0GWD6/05xWyzOpuPwZe8+aQnnVBKiKo+pr LZcgVr1axg8/aM4uybECUpVtRJlbstpAWswCRcxiQKrxwGpTwJvo+05Nv6pHMSN6LZt0 RK4DOJJbrArSXr5c8tftkYbztDzztcpywl7acyI428ZA5kXbkXCVnTFyJSNyCnv5SGSp ydWK0WzZzNbbdz8S70BGq69/GBvPfNCPMXenFa6Y38j79lns/pPrbG3GJ4vxtirjtZJO CP6ylgIH+8TNc0FKBmq9il3RZv927k3EUs+A+gcGCmr4zHb51NdbJHd5BJ5PvHhz6fPU 0p9g== X-Gm-Message-State: AA+aEWYhPnK5/qnkt/xZkFyh5lSBKP+0bR5DkaRgiZngkj1VqKyY6v/+ nSQDcpVHTn521o6cVeFw45G+MZdihmV8sQ== X-Google-Smtp-Source: AFSGD/XuCSaqvn2tDyt/+bKKO4Zef+LXl3utQcH1+Sgb6hMW4S6pIkvKRArAigpg/59JmM19VBgt2A== X-Received: by 2002:a19:cc46:: with SMTP id c67mr7114526lfg.145.1544460764504; Mon, 10 Dec 2018 08:52:44 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id w9sm2194574lfc.66.2018.12.10.08.52.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 08:52:43 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Wolfram Sang , Adrian Hunter , Sjoerd Simons , Faiz Abbas , Jaehoon Chung , Shawn Lin Subject: [PATCH 1/5] mmc: core: Reset HPI enabled state during re-init and in case of errors Date: Mon, 10 Dec 2018 17:52:36 +0100 Message-Id: <20181210165240.23101-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181210165240.23101-1-ulf.hansson@linaro.org> References: <20181210165240.23101-1-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP During a re-initialization of the eMMC card, we may fail to re-enable HPI. In these cases, that isn't properly reflected in the card->ext_csd.hpi_en bit, as it keeps being set. This may cause following attempts to use HPI, even if's not enabled. Let's fix this! Fixes: eb0d8f135b67 ("mmc: core: support HPI send command") Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 4ff08ea930a6..1b8d38f54f65 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1785,9 +1785,11 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, if (err) { pr_warn("%s: Enabling HPI failed\n", mmc_hostname(card->host)); + card->ext_csd.hpi_en = 0; err = 0; - } else + } else { card->ext_csd.hpi_en = 1; + } } /* From patchwork Mon Dec 10 16:52:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10721769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7A8E15A6 for ; Mon, 10 Dec 2018 16:52:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A68482A816 for ; Mon, 10 Dec 2018 16:52:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A5CE2A82F; Mon, 10 Dec 2018 16:52:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29D992A816 for ; Mon, 10 Dec 2018 16:52:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727224AbeLJQws (ORCPT ); Mon, 10 Dec 2018 11:52:48 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35858 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727501AbeLJQws (ORCPT ); Mon, 10 Dec 2018 11:52:48 -0500 Received: by mail-lf1-f66.google.com with SMTP id a16so8530421lfg.3 for ; Mon, 10 Dec 2018 08:52:47 -0800 (PST) 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=hztVpdSncV6eOao2PFKFcbGFH4Z0tMgd8EvT/1T5ytY=; b=F5GpOqujUCtlG5aJbuYpiAjHJzPJKUwLVe1sxJJe1bUs6qEqc87rwDvEtmhO5hbZGm MTur0yJs6VPyFdKHA6CKB+STdSLafvhwLXrb5S81l6SKtnEr1NCwcUv7z43HVG/9dUXv I1+Pvp6vsppxu8siTV2F+XR/OEERHLlmFhTkk= 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=hztVpdSncV6eOao2PFKFcbGFH4Z0tMgd8EvT/1T5ytY=; b=LFYRF1MeSWC8VbrXVlEcvYYTjJimHTMWhHOaQUQOunMJohw1D7uV5l0FXBDDK+42/V Vb+9eUg16ga63Vab1UfiCt9fcKYH0VluRVDD6seoNBvVf0dtdZXaRZmm0fakDVlY9Dhq rx9gAKgwWjPPUcFFVRNrEpY4vQ/jUAdMV0M4OHNAbpkVjXq5G6J6zTLHssswy2zpAR9j aKu5XkkiGyelfmrL/eZ3YTEvdrm0ygShM9sedwF5/zP+pjsJvScj4GPj9k8y0iUncGgL OsVhQOPvFelJkB5x8x+YnCZV+wcWOWKif1vB8qI+stX/4Xu9wVa8Ej3by3d7iZLMPwmT Re5Q== X-Gm-Message-State: AA+aEWZtc2CnXs9l1XEPD9CeY2kwdFgDMZsBOr+mLzvFkj92NnbkoXrX mEdzBQmLK+maqK1csAGPwTm8QCZYkKusKQ== X-Google-Smtp-Source: AFSGD/WYWAxFU0zEJfJz+2tQphkiejIV99WgzX0xfkvHBpUoYFUmOXOw+id8w34juF84CG64afyiLA== X-Received: by 2002:a19:5a05:: with SMTP id o5mr7849623lfb.140.1544460766011; Mon, 10 Dec 2018 08:52:46 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id w9sm2194574lfc.66.2018.12.10.08.52.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 08:52:45 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Wolfram Sang , Adrian Hunter , Sjoerd Simons , Faiz Abbas , Jaehoon Chung , Shawn Lin , Pratibhasagar V Subject: [PATCH 2/5] mmc: core: Allow BKOPS and CACHE ctrl even if no HPI support Date: Mon, 10 Dec 2018 17:52:37 +0100 Message-Id: <20181210165240.23101-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181210165240.23101-1-ulf.hansson@linaro.org> References: <20181210165240.23101-1-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In commit 5320226a0512 ("mmc: core: Disable HPI for certain Hynix eMMC cards"), then intent was to prevent HPI from being used for some eMMC cards, which didn't properly support it. However, that went too far, as even BKOPS and CACHE ctrl became prevented. Let's restore those parts and allow BKOPS and CACHE ctrl even if HPI isn't supported. Fixes: 5320226a0512 ("mmc: core: Disable HPI for certain Hynix eMMC cards") Cc: Pratibhasagar V Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 1b8d38f54f65..cb98d30df409 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -526,8 +526,7 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) card->cid.year += 16; /* check whether the eMMC card supports BKOPS */ - if (!mmc_card_broken_hpi(card) && - ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1) { + if (ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1) { card->ext_csd.bkops = 1; card->ext_csd.man_bkops_en = (ext_csd[EXT_CSD_BKOPS_EN] & @@ -1796,8 +1795,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, * If cache size is higher than 0, this indicates * the existence of cache and it can be turned on. */ - if (!mmc_card_broken_hpi(card) && - card->ext_csd.cache_size > 0) { + if (card->ext_csd.cache_size > 0) { err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_CACHE_CTRL, 1, card->ext_csd.generic_cmd6_time); From patchwork Mon Dec 10 16:52:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10721775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E45D15A6 for ; Mon, 10 Dec 2018 16:53:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D1232A810 for ; Mon, 10 Dec 2018 16:53:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 315C52A827; Mon, 10 Dec 2018 16:53:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB3562A810 for ; Mon, 10 Dec 2018 16:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728017AbeLJQwv (ORCPT ); Mon, 10 Dec 2018 11:52:51 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35860 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726720AbeLJQwu (ORCPT ); Mon, 10 Dec 2018 11:52:50 -0500 Received: by mail-lf1-f67.google.com with SMTP id a16so8530478lfg.3 for ; Mon, 10 Dec 2018 08:52:48 -0800 (PST) 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=ev/ntoDbh5ybE5JNkNvhwN8PjP40USGqAlYJOPoCA2k=; b=g8Xnjr9ZP84dkEnjjAwFKmbVa/KsRHtwFGsAtPZVNyMhYfAjyxAiOBW6I+Mk7PZEdu hS/1GL5X9snAFZHdfuUY4aW8YGquKPihYGAxanDZ390xwfBdnzJCAMtW2FeIgkmxwtSZ XhRY2QmXLYfuv8BNw9PMC5U1TnTcM2Z2mbZEw= 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=ev/ntoDbh5ybE5JNkNvhwN8PjP40USGqAlYJOPoCA2k=; b=A8IBgv+/bY7DWOjA7PEj1acRuoS+5iMxxbt3iMKfb6Fk4RftRwA19F6ChpB+paCgPX YS9nrjn3BUzSK+TceliFEOPvCQm+UPIAGsjgHrvzVx6cSxhJd0J3onBT7FoWE9JHQell VvJTXCIhZ5inPqdjilcT0o6Ya1W4fzcpBb2EP/J5FwxpTO39gBmG2BOQX3HAW5bMvwH8 Zg0UtcL2NGsFS6u6cuEZAYv+M0XljR61otcdB6wcqARs+IRWiz1CdwBcuqZCWGGo4nq2 5iCaUsKWxXpqnFN8XCX6v9DM8TKkj3TMpJqqk2DtI5Q1NYjGmkEOoMRD8QDYiCQUaq90 GNWw== X-Gm-Message-State: AA+aEWYjvAdqzV+LBsPJ7dATl+ur17h6xUtEUhziDbSCp/hN9BHjIiGX kzSXrKapr/ITfUHRKvDqhc/MmzRBvfnTQA== X-Google-Smtp-Source: AFSGD/XrCuze5uCGufZGKatKIQ7GFvCpcrDcsCkEWixTeXx8bXcpRiustuqsbgD4e5rXMBl9t9W+bg== X-Received: by 2002:a19:982:: with SMTP id 124mr7061155lfj.138.1544460767408; Mon, 10 Dec 2018 08:52:47 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id w9sm2194574lfc.66.2018.12.10.08.52.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 08:52:46 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Wolfram Sang , Adrian Hunter , Sjoerd Simons , Faiz Abbas , Jaehoon Chung , Shawn Lin Subject: [PATCH 3/5] mmc: core: Use a minimum 1600ms timeout when enabling CACHE ctrl Date: Mon, 10 Dec 2018 17:52:38 +0100 Message-Id: <20181210165240.23101-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181210165240.23101-1-ulf.hansson@linaro.org> References: <20181210165240.23101-1-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some eMMCs from Micron have been reported to need ~800 ms timeout, while enabling the CACHE ctrl after running sudden power failure tests. The needed timeout is greater than what the card specifies as its generic CMD6 timeout, through the EXT_CSD register, hence the problem. Normally we would introduce a card quirk to extend the timeout for these specific Micron cards. However, due to the rather complicated debug process needed to find out the error, let's simply use a minimum timeout of 1600ms, the double of what has been reported, for all cards when enabling CACHE ctrl. Reported-by: Sjoerd Simons Reported-by: Andreas Dannenberg Reported-by: Faiz Abbas Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index cb98d30df409..2510cebd670f 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -30,6 +30,7 @@ #include "pwrseq.h" #define DEFAULT_CMD6_TIMEOUT_MS 500 +#define MIN_CACHE_EN_TIMEOUT_MS 1600 static const unsigned int tran_exp[] = { 10000, 100000, 1000000, 10000000, @@ -1792,13 +1793,18 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, } /* - * If cache size is higher than 0, this indicates - * the existence of cache and it can be turned on. + * If cache size is higher than 0, this indicates the existence of cache + * and it can be turned on. Note that some eMMCs from Micron has been + * reported to need ~800 ms timeout, while enabling the cache after + * sudden power failure tests. Let's extend the timeout to a minimum of + * DEFAULT_CACHE_EN_TIMEOUT_MS and do it for all cards. */ if (card->ext_csd.cache_size > 0) { + unsigned int timeout_ms = MIN_CACHE_EN_TIMEOUT_MS; + + timeout_ms = max(card->ext_csd.generic_cmd6_time, timeout_ms); err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_CACHE_CTRL, 1, - card->ext_csd.generic_cmd6_time); + EXT_CSD_CACHE_CTRL, 1, timeout_ms); if (err && err != -EBADMSG) goto free_card; From patchwork Mon Dec 10 16:52:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10721777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C424918E8 for ; Mon, 10 Dec 2018 16:53:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B279E2A810 for ; Mon, 10 Dec 2018 16:53:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6A992A827; Mon, 10 Dec 2018 16:53:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C0902A810 for ; Mon, 10 Dec 2018 16:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727529AbeLJQxJ (ORCPT ); Mon, 10 Dec 2018 11:53:09 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:34664 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728007AbeLJQwv (ORCPT ); Mon, 10 Dec 2018 11:52:51 -0500 Received: by mail-lf1-f65.google.com with SMTP id p6so8539478lfc.1 for ; Mon, 10 Dec 2018 08:52:49 -0800 (PST) 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=V22VZ/qtHeHwmBH5FUkElluUpeyt8M78z5UvAjTJvFE=; b=RBb4KMtFb+BjZ087pBJhfBP+eKrGW8MtaVTB2g4K7VolVP27gIRTldv/d8WaHKXGYo riNnZnUomVL0Bvvr8+aFlLzGcmEJdJZZ9vJeAxEY+OZnOEYXMVV2a0bX86TkiGcbdICa LRy7Xe/KOjJsUNAShA0R9gsAtMtIW0YH1epc8= 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=V22VZ/qtHeHwmBH5FUkElluUpeyt8M78z5UvAjTJvFE=; b=CH4EXN+x5y1aNT1MHtfQVpgflpRGaUmj5eOFLi0+Qn85Vr/XKgzwXysJ6r9bmgFwcV OzlDbOIpIDW3dlnOMG2C8Slcssb8aARqYUQUAvv345hVLEtC7vDLUFHGTXlxFFafQ+jl 4XSISa/h6FyRSfLxiGZaguXvX8kN9gVIqnQtvX5AOwoYrWQli37NYb8c6D5BzKMML1Jr 9my/JIeQFo/jAOKNlEau2GixlH2S3nLh7sZS6j7uJhxYg0nNGfsDL/oK8UcC3oKEnopu m26U3fo9eOLpX4xMuGjkqFDXSt7DmDmZ+Pu/JgqkVeEM2PSreBnUVEZFxar0OhvkeJR3 JSng== X-Gm-Message-State: AA+aEWbaaLPMBHia5e2q16XxtfEfzGlaLmKQf2TvILLvICAxRxDL9t5J I4TqUEbfGw/4B/ttbEBTZDnKgEem8yyiRQ== X-Google-Smtp-Source: AFSGD/XpkTO6mT8rp73JR9KURAhdj+8cHfnIIlL3fXCebhUHtTTSquL1i3Z6f6VmMUTpGIjw/kctUw== X-Received: by 2002:a19:4d8d:: with SMTP id a135mr7796126lfb.80.1544460768706; Mon, 10 Dec 2018 08:52:48 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id w9sm2194574lfc.66.2018.12.10.08.52.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 08:52:48 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Wolfram Sang , Adrian Hunter , Sjoerd Simons , Faiz Abbas , Jaehoon Chung , Shawn Lin Subject: [PATCH 4/5] mmc: core: Drop redundant check in mmc_send_hpi_cmd() Date: Mon, 10 Dec 2018 17:52:39 +0100 Message-Id: <20181210165240.23101-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181210165240.23101-1-ulf.hansson@linaro.org> References: <20181210165240.23101-1-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is no point checking if HPI is supported in mmc_send_hpi_cmd() as mmc_interrupt_hpi(), which is the only caller, already checks if HPI has been enabled. Therefore, let's drop the check and the corresponding error path. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc_ops.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 873b2aa0c155..ffc74d44ee67 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -802,12 +802,6 @@ static int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status) unsigned int opcode; int err; - if (!card->ext_csd.hpi) { - pr_warn("%s: Card didn't support HPI command\n", - mmc_hostname(card->host)); - return -EINVAL; - } - opcode = card->ext_csd.hpi_cmd; if (opcode == MMC_STOP_TRANSMISSION) cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; From patchwork Mon Dec 10 16:52:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10721773 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98A1717FE for ; Mon, 10 Dec 2018 16:53:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86C412A816 for ; Mon, 10 Dec 2018 16:53:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A6DB2A810; Mon, 10 Dec 2018 16:53:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 905872A810 for ; Mon, 10 Dec 2018 16:53:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728037AbeLJQwx (ORCPT ); Mon, 10 Dec 2018 11:52:53 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:32999 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728011AbeLJQwx (ORCPT ); Mon, 10 Dec 2018 11:52:53 -0500 Received: by mail-lf1-f66.google.com with SMTP id i26so8538682lfc.0 for ; Mon, 10 Dec 2018 08:52:51 -0800 (PST) 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=8zMKg9J/wlrwcIQwq1keZ7jgftzEkSMTzdh6lkHbG9k=; b=Elr7q6xLNtQxJqIdAmdsPtChbZ3aAQO0VuXkoLkvmKG5E4Z3koZ96JkbdPk95q6Rwf GbMIE7hImub0iAfGVg2iRX0tpgZe9hLyG9hYfHZm5YKE9453kwO4DEv0M/qs06FdY9gq d3N5D3JHRwfnNjj8ghNiCYjOBubffBmIZny2w= 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=8zMKg9J/wlrwcIQwq1keZ7jgftzEkSMTzdh6lkHbG9k=; b=D5MKF+BJTe30R3NC+EnPSvtBIy/AzF4GNJNs5W3L+m7hQ5adj+W4skSA0CDwWR0qLG 9lS6exmzMlGoKuDQ3k3bwt6BsrfIZIlV+lvQdezZaGrOwzYkgvlep9l/BvQ1w1+J5CYt lbMEPITOB3FsZCMES+i/n/AGi8Ecb0s4GTjybEezJckbT/xrIak8Z+g0JL6i4lAUm0vW k+JqXUxgbz6tFWsrD6Ef9lVMBFlJpIhkke5Q0MGhAjlQ4T/qMjGv0pwbendPi4k19qMy hShh2bi9f+VSEugozXyQ/NHQraN+9HxC44fAm1zBMHAM3J6Je0aAlHNvplSyPnAlrNpX H0dA== X-Gm-Message-State: AA+aEWa/8K+hpvZIu0a7JTd/ZR6AIerA/o7pfmVn/1vmyoT9zuVks4fy bJSQfflxpS/Gf2Ji1lyFTZTnHTVd50OdbQ== X-Google-Smtp-Source: AFSGD/XrX0gS2MJq1JH4kHoesOLBQf8hGyaQheUXdO7Jo0lCVjT7DFLM2wpVAOKtKtUElGg38pLJgg== X-Received: by 2002:a19:8d01:: with SMTP id p1mr6778209lfd.149.1544460770164; Mon, 10 Dec 2018 08:52:50 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id w9sm2194574lfc.66.2018.12.10.08.52.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Dec 2018 08:52:49 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Wolfram Sang , Adrian Hunter , Sjoerd Simons , Faiz Abbas , Jaehoon Chung , Shawn Lin Subject: [PATCH 5/5] mmc: core: Cleanup BKOPS support Date: Mon, 10 Dec 2018 17:52:40 +0100 Message-Id: <20181210165240.23101-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181210165240.23101-1-ulf.hansson@linaro.org> References: <20181210165240.23101-1-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It's been ~6 years ago since we introduced the BKOPS support for eMMC cards. The current code is a bit messy and primarily that's because it prepares to support running BKOPS in an asynchronous mode. However, that mode has never been fully implemented/enabled. Instead BKOPS is always executed in synchronously, when the card has reported an urgent BKOPS level. For these reasons, let's make the code more readable by dropping the unused parts. Let's also rename mmc_start_bkops() to mmc_run_bkops(), as to make it more descriptive. Cc: Jaehoon Chung Signed-off-by: Ulf Hansson --- drivers/mmc/core/block.c | 2 +- drivers/mmc/core/card.h | 6 +-- drivers/mmc/core/mmc.c | 6 --- drivers/mmc/core/mmc_ops.c | 87 ++++++++------------------------------ drivers/mmc/core/mmc_ops.h | 3 +- 5 files changed, 21 insertions(+), 83 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 111934838da2..48386473dcd7 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1961,7 +1961,7 @@ static void mmc_blk_urgent_bkops(struct mmc_queue *mq, struct mmc_queue_req *mqrq) { if (mmc_blk_urgent_bkops_needed(mq, mqrq)) - mmc_start_bkops(mq->card, true); + mmc_run_bkops(mq->card); } void mmc_blk_mq_complete(struct request *req) diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h index 1170feb8f969..eef301452406 100644 --- a/drivers/mmc/core/card.h +++ b/drivers/mmc/core/card.h @@ -23,15 +23,13 @@ #define MMC_STATE_BLOCKADDR (1<<2) /* card uses block-addressing */ #define MMC_CARD_SDXC (1<<3) /* card is SDXC */ #define MMC_CARD_REMOVED (1<<4) /* card has been removed */ -#define MMC_STATE_DOING_BKOPS (1<<5) /* card is doing BKOPS */ -#define MMC_STATE_SUSPENDED (1<<6) /* card is suspended */ +#define MMC_STATE_SUSPENDED (1<<5) /* card is suspended */ #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT) #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) #define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR) #define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC) #define mmc_card_removed(c) ((c) && ((c)->state & MMC_CARD_REMOVED)) -#define mmc_card_doing_bkops(c) ((c)->state & MMC_STATE_DOING_BKOPS) #define mmc_card_suspended(c) ((c)->state & MMC_STATE_SUSPENDED) #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) @@ -39,8 +37,6 @@ #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) #define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC) #define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED) -#define mmc_card_set_doing_bkops(c) ((c)->state |= MMC_STATE_DOING_BKOPS) -#define mmc_card_clr_doing_bkops(c) ((c)->state &= ~MMC_STATE_DOING_BKOPS) #define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED) #define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2510cebd670f..da892a599524 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -2014,12 +2014,6 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) if (mmc_card_suspended(host->card)) goto out; - if (mmc_card_doing_bkops(host->card)) { - err = mmc_stop_bkops(host->card); - if (err) - goto out; - } - err = mmc_flush_cache(host->card); if (err) goto out; diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index ffc74d44ee67..9054329fe903 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -891,34 +891,6 @@ int mmc_can_ext_csd(struct mmc_card *card) return (card && card->csd.mmca_vsn > CSD_SPEC_VER_3); } -/** - * mmc_stop_bkops - stop ongoing BKOPS - * @card: MMC card to check BKOPS - * - * Send HPI command to stop ongoing background operations to - * allow rapid servicing of foreground operations, e.g. read/ - * writes. Wait until the card comes out of the programming state - * to avoid errors in servicing read/write requests. - */ -int mmc_stop_bkops(struct mmc_card *card) -{ - int err = 0; - - err = mmc_interrupt_hpi(card); - - /* - * If err is EINVAL, we can't issue an HPI. - * It should complete the BKOPS. - */ - if (!err || (err == -EINVAL)) { - mmc_card_clr_doing_bkops(card); - mmc_retune_release(card->host); - err = 0; - } - - return err; -} - static int mmc_read_bkops_status(struct mmc_card *card) { int err; @@ -935,22 +907,17 @@ static int mmc_read_bkops_status(struct mmc_card *card) } /** - * mmc_start_bkops - start BKOPS for supported cards - * @card: MMC card to start BKOPS - * @from_exception: A flag to indicate if this function was - * called due to an exception raised by the card + * mmc_run_bkops - Run BKOPS for supported cards + * @card: MMC card to run BKOPS for * - * Start background operations whenever requested. - * When the urgent BKOPS bit is set in a R1 command response - * then background operations should be started immediately. + * Run background operations synchronously for cards having manual BKOPS + * enabled and in case it reports urgent BKOPS level. */ -void mmc_start_bkops(struct mmc_card *card, bool from_exception) +void mmc_run_bkops(struct mmc_card *card) { int err; - int timeout; - bool use_busy_signal; - if (!card->ext_csd.man_bkops_en || mmc_card_doing_bkops(card)) + if (!card->ext_csd.man_bkops_en) return; err = mmc_read_bkops_status(card); @@ -960,44 +927,26 @@ void mmc_start_bkops(struct mmc_card *card, bool from_exception) return; } - if (!card->ext_csd.raw_bkops_status) + if (!card->ext_csd.raw_bkops_status || + card->ext_csd.raw_bkops_status < EXT_CSD_BKOPS_LEVEL_2) return; - if (card->ext_csd.raw_bkops_status < EXT_CSD_BKOPS_LEVEL_2 && - from_exception) - return; - - if (card->ext_csd.raw_bkops_status >= EXT_CSD_BKOPS_LEVEL_2) { - timeout = MMC_OPS_TIMEOUT_MS; - use_busy_signal = true; - } else { - timeout = 0; - use_busy_signal = false; - } - mmc_retune_hold(card->host); - err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_BKOPS_START, 1, timeout, 0, - use_busy_signal, true, false); - if (err) { + /* + * For urgent BKOPS status, LEVEL_2 and higher, let's execute + * synchronously. Future wise, we may consider to start BKOPS, for less + * urgent levels by using an asynchronous background task, when idle. + */ + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_BKOPS_START, 1, MMC_OPS_TIMEOUT_MS); + if (err) pr_warn("%s: Error %d starting bkops\n", mmc_hostname(card->host), err); - mmc_retune_release(card->host); - return; - } - /* - * For urgent bkops status (LEVEL_2 and more) - * bkops executed synchronously, otherwise - * the operation is in progress - */ - if (!use_busy_signal) - mmc_card_set_doing_bkops(card); - else - mmc_retune_release(card->host); + mmc_retune_release(card->host); } -EXPORT_SYMBOL(mmc_start_bkops); +EXPORT_SYMBOL(mmc_run_bkops); /* * Flush the cache to the non-volatile storage. diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h index a1390d486381..018a5e3f66d6 100644 --- a/drivers/mmc/core/mmc_ops.h +++ b/drivers/mmc/core/mmc_ops.h @@ -40,8 +40,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, bool use_busy_signal, bool send_status, bool retry_crc_err); int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, unsigned int timeout_ms); -int mmc_stop_bkops(struct mmc_card *card); -void mmc_start_bkops(struct mmc_card *card, bool from_exception); +void mmc_run_bkops(struct mmc_card *card); int mmc_flush_cache(struct mmc_card *card); int mmc_cmdq_enable(struct mmc_card *card); int mmc_cmdq_disable(struct mmc_card *card);