{"id":816909,"url":"http://patchwork.ozlabs.org/api/patches/816909/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1506004213-22620-24-git-send-email-jjhiblot@ti.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1506004213-22620-24-git-send-email-jjhiblot@ti.com>","list_archive_url":null,"date":"2017-09-21T14:30:10","name":"[U-Boot,v2,23/26] mmc: Retry some MMC cmds on failure","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"6ed0fae15cd6f5e0a178fe9a1d47f939324f15f7","submitter":{"id":70508,"url":"http://patchwork.ozlabs.org/api/people/70508/?format=json","name":"Jean-Jacques Hiblot","email":"jjhiblot@ti.com"},"delegate":{"id":12423,"url":"http://patchwork.ozlabs.org/api/users/12423/?format=json","username":"Jaehoon","first_name":"Jaehoon","last_name":"Chung","email":"jh80.chung@samsung.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1506004213-22620-24-git-send-email-jjhiblot@ti.com/mbox/","series":[{"id":4400,"url":"http://patchwork.ozlabs.org/api/series/4400/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=4400","date":"2017-09-21T14:29:47","name":"mmc: Add support for HS200 and UHS modes","version":2,"mbox":"http://patchwork.ozlabs.org/series/4400/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816909/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816909/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ti.com header.i=@ti.com header.b=\"v1PCcgHX\";\n\tdkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xyfTC73KZz9sNc\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 22 Sep 2017 00:42:07 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid BCD6AC2200A; Thu, 21 Sep 2017 14:34:44 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id A7755C21E3B;\n\tThu, 21 Sep 2017 14:32:08 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid E0354C21E78; Thu, 21 Sep 2017 14:31:18 +0000 (UTC)","from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80])\n\tby lists.denx.de (Postfix) with ESMTPS id 98BF7C22012\n\tfor <u-boot@lists.denx.de>; Thu, 21 Sep 2017 14:31:12 +0000 (UTC)","from dlelxv90.itg.ti.com ([172.17.2.17])\n\tby lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8LEVAbx002971; \n\tThu, 21 Sep 2017 09:31:10 -0500","from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29])\n\tby dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEVAUb020674; \n\tThu, 21 Sep 2017 09:31:10 -0500","from DFLE109.ent.ti.com (10.64.6.30) by DFLE108.ent.ti.com\n\t(10.64.6.29) with Microsoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34;\n\tThu, 21 Sep 2017 09:31:10 -0500","from dlep33.itg.ti.com (157.170.170.75) by DFLE109.ent.ti.com\n\t(10.64.6.30) with Microsoft SMTP Server (version=TLS1_0,\n\tcipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend\n\tTransport; Thu, 21 Sep 2017 09:31:10 -0500","from localhost (ileax41-snat.itg.ti.com [10.172.224.153])\n\tby dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8LEV8c6012050;\n\tThu, 21 Sep 2017 09:31:09 -0500"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tT_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com;\n\ts=ti-com-17Q1; t=1506004270;\n\tbh=aDxGCQF+JQ6H5+zNl3D4EQ+pWu9BLualohyPFFbj11o=;\n\th=From:To:CC:Subject:Date:In-Reply-To:References;\n\tb=v1PCcgHX5FXH53OgEIKdi85u761emw+FuVwNDdCHKeDMShav0cklkilHHvtn8BHNn\n\tmPHZqLlpC9Rb07hyXJB2NHBJOJlK4zb32rNmAKZuZmyyWkzhI/y4QUatE0WLdmTdg+\n\txsvZRSZKrfcIQMxg2e+PgvaMc6a0QAijmemE6v/o=","From":"Jean-Jacques Hiblot <jjhiblot@ti.com>","To":"<jh80.chung@samsung.com>, <trini@konsulko.com>, <kishon@ti.com>,\n\t<sjg@chromium.org>","Date":"Thu, 21 Sep 2017 16:30:10 +0200","Message-ID":"<1506004213-22620-24-git-send-email-jjhiblot@ti.com>","X-Mailer":"git-send-email 1.9.1","In-Reply-To":"<1506004213-22620-1-git-send-email-jjhiblot@ti.com>","References":"<1506004213-22620-1-git-send-email-jjhiblot@ti.com>","MIME-Version":"1.0","X-EXCLAIMER-MD-CONFIG":"e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180","Cc":"u-boot@lists.denx.de","Subject":"[U-Boot] [PATCH v2 23/26] mmc: Retry some MMC cmds on failure","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"From: Kishon Vijay Abraham I <kishon@ti.com>\n\nWith certain SD cards like Kingston 8GB/16GB UHS card, it is seen that\nMMC_CMD_ALL_SEND_CID cmd fails on first attempt, but succeeds\nsubsequently. Therefore, retry MMC_CMD_ALL_SEND_CID cmd a few time\nas done in Linux kernel.\nSimilarly, it is seen that MMC_CMD_SET_BLOCKLEN may fail on first\nattempt, therefore retry this cmd a few times as done in kernel.\n\nTo make it clear that those are optionnal workarounds, a new Kconfig\noption 'MMC_QUIRKS' is added (enabled by default).\n\nSigned-off-by: Vignesh R <vigneshr@ti.com>\nSigned-off-by: Kishon Vijay Abraham I <kishon@ti.com>\nSigned-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>\n---\n drivers/mmc/Kconfig |  9 +++++++++\n drivers/mmc/mmc.c   | 41 +++++++++++++++++++++++++++++++++++++++--\n include/mmc.h       |  4 ++++\n 3 files changed, 52 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig\nindex 3d577e0..78e58d4 100644\n--- a/drivers/mmc/Kconfig\n+++ b/drivers/mmc/Kconfig\n@@ -33,6 +33,15 @@ config SPL_DM_MMC\n \n if MMC\n \n+config MMC_QUIRKS\n+\tbool \"Enable quirks\"\n+\tdefault y\n+\thelp\n+\t  Some cards and hosts may sometimes behave unexpectedly (quirks).\n+\t  This option enable workarounds to handle those quirks. Some of them\n+\t  are enabled by default, other may require additionnal flags or are\n+\t  enabled by the host driver.\n+\n config MMC_VERBOSE\n \tbool \"Output more information about the MMC\"\n \tdefault y\ndiff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c\nindex c5eaeaf..6d1bf94 100644\n--- a/drivers/mmc/mmc.c\n+++ b/drivers/mmc/mmc.c\n@@ -279,6 +279,7 @@ int mmc_send_status(struct mmc *mmc, int timeout)\n int mmc_set_blocklen(struct mmc *mmc, int len)\n {\n \tstruct mmc_cmd cmd;\n+\tint err;\n \n \tif (mmc->ddr_mode)\n \t\treturn 0;\n@@ -287,7 +288,24 @@ int mmc_set_blocklen(struct mmc *mmc, int len)\n \tcmd.resp_type = MMC_RSP_R1;\n \tcmd.cmdarg = len;\n \n-\treturn mmc_send_cmd(mmc, &cmd, NULL);\n+\terr = mmc_send_cmd(mmc, &cmd, NULL);\n+\n+#ifdef CONFIG_MMC_QUIRKS\n+\tif (err && (mmc->quirks & MMC_QUIRK_RETRY_SET_BLOCKLEN)) {\n+\t\tint retries = 4;\n+\t\t/*\n+\t\t * It has been seen that SET_BLOCKLEN may fail on the first\n+\t\t * attempt, let's try a few more time\n+\t\t */\n+\t\tdo {\n+\t\t\terr = mmc_send_cmd(mmc, &cmd, NULL);\n+\t\t\tif (!err)\n+\t\t\t\tbreak;\n+\t\t} while (retries--);\n+\t}\n+#endif\n+\n+\treturn err;\n }\n \n static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,\n@@ -1881,7 +1899,6 @@ static int mmc_startup(struct mmc *mmc)\n \t\tcmd.resp_type = MMC_RSP_R1;\n \t\tcmd.cmdarg = 1;\n \t\terr = mmc_send_cmd(mmc, &cmd, NULL);\n-\n \t\tif (err)\n \t\t\treturn err;\n \t}\n@@ -1895,6 +1912,21 @@ static int mmc_startup(struct mmc *mmc)\n \n \terr = mmc_send_cmd(mmc, &cmd, NULL);\n \n+#ifdef CONFIG_MMC_QUIRKS\n+\tif (err && (mmc->quirks & MMC_QUIRK_RETRY_SEND_CID)) {\n+\t\tint retries = 4;\n+\t\t/*\n+\t\t * It has been seen that SEND_CID may fail on the first\n+\t\t * attempt, let's try a few more time\n+\t\t */\n+\t\tdo {\n+\t\t\terr = mmc_send_cmd(mmc, &cmd, NULL);\n+\t\t\tif (!err)\n+\t\t\t\tbreak;\n+\t\t} while (retries--);\n+\t}\n+#endif\n+\n \tif (err)\n \t\treturn err;\n \n@@ -2239,6 +2271,11 @@ int mmc_start_init(struct mmc *mmc)\n \tif (err)\n \t\treturn err;\n \n+#ifdef CONFIG_MMC_QUIRKS\n+\tmmc->quirks = MMC_QUIRK_RETRY_SET_BLOCKLEN |\n+\t\t      MMC_QUIRK_RETRY_SEND_CID;\n+#endif\n+\n \terr = mmc_power_cycle(mmc);\n \tif (err) {\n \t\t/*\ndiff --git a/include/mmc.h b/include/mmc.h\nindex a8901bf..a9ebc88 100644\n--- a/include/mmc.h\n+++ b/include/mmc.h\n@@ -306,6 +306,9 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx)\n #define ENHNCD_SUPPORT\t\t(0x2)\n #define PART_ENH_ATTRIB\t\t(0x1f)\n \n+#define MMC_QUIRK_RETRY_SEND_CID\tBIT(0)\n+#define MMC_QUIRK_RETRY_SET_BLOCKLEN\tBIT(1)\n+\n enum mmc_voltage {\n \tMMC_SIGNAL_VOLTAGE_000 = 0,\n \tMMC_SIGNAL_VOLTAGE_120,\n@@ -591,6 +594,7 @@ struct mmc {\n \t\t\t\t  * operating mode due to limitations when\n \t\t\t\t  * accessing the boot partitions\n \t\t\t\t  */\n+\tu32 quirks;\n };\n \n struct mmc_hwpart_conf {\n","prefixes":["U-Boot","v2","23/26"]}