{"id":804531,"url":"http://patchwork.ozlabs.org/api/1.2/patches/804531/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1503414919-30820-7-git-send-email-bmeng.cn@gmail.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/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":"<1503414919-30820-7-git-send-email-bmeng.cn@gmail.com>","list_archive_url":null,"date":"2017-08-22T15:15:11","name":"[U-Boot,06/14] nvme: Respect timeout when en/disabling the controller","commit_ref":"04d2a3840110e495a119e6226b5c38936b48988a","pull_url":null,"state":"accepted","archived":false,"hash":"da4829bc968f0c478546dd86987c33137f9f2743","submitter":{"id":64981,"url":"http://patchwork.ozlabs.org/api/1.2/people/64981/?format=json","name":"Bin Meng","email":"bmeng.cn@gmail.com"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/1.2/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1503414919-30820-7-git-send-email-bmeng.cn@gmail.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/804531/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/804531/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\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"vfQ9LcRX\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xcDjP1t1Rz9sNd\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 23 Aug 2017 01:18:49 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 03495C21F01; Tue, 22 Aug 2017 15:13:18 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 22D0DC21F21;\n\tTue, 22 Aug 2017 15:11:44 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid DF1D3C21F06; Tue, 22 Aug 2017 15:11:10 +0000 (UTC)","from mail-it0-f65.google.com (mail-it0-f65.google.com\n\t[209.85.214.65])\n\tby lists.denx.de (Postfix) with ESMTPS id 0104CC21E99\n\tfor <u-boot@lists.denx.de>; Tue, 22 Aug 2017 15:11:07 +0000 (UTC)","by mail-it0-f65.google.com with SMTP id w204so3940331ita.5\n\tfor <u-boot@lists.denx.de>; Tue, 22 Aug 2017 08:11:06 -0700 (PDT)","from ala-d2121-lx1.wrs.com (unknown-156-139.windriver.com.\n\t[147.11.156.139]) by smtp.gmail.com with ESMTPSA id\n\ta189sm5182572itd.5.2017.08.22.08.11.04\n\t(version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tTue, 22 Aug 2017 08:11:05 -0700 (PDT)"],"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=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:subject:date:message-id:in-reply-to:references;\n\tbh=ERfb/Gpo50NRxncT4yARaOnU/p1US9KsiO48JDMumLI=;\n\tb=vfQ9LcRXhx/cTv67zPPWgU90PW5HbWS8s7DXk+/A2jAmqss99QZ8SbWZSLxR3zHafA\n\tLT/woKOlykgjCypFIjt2kFz6UGkxxnPAL0wod3F2BJsuybKAfK/qD1CMwjKhucmAYW1+\n\toj9NJfOOE/Lke/klz2klHAzj5ioFI0MTdnyc4eK+I3atfa7tKFXTwK5UqNwheYyep53L\n\tEtLpP+pdu2HHqbrPGby9kz40dqzjhGkkPrgOyIMVuiEDKSxc9jvJF7MSxWR4+q/34ol0\n\tZXCu2a6/JI+++bNET1O7dincH6B9dn5KRc1BrqdNVd2kt7cKF15UdW8oU5mzohp6gqUA\n\tM4cA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=ERfb/Gpo50NRxncT4yARaOnU/p1US9KsiO48JDMumLI=;\n\tb=ATd3Ws67rPPJvxToHP7cq6z9vHYDu4ouF4ngFaByucvSRM9hovt8ICbUNaCnwfen0C\n\tEqiPwtiFZne5+HO7Pew5Xo1iLomd4Jm+FnliyKlRLcANMJj9+y2+7IV1CRxK6G3a+fcS\n\tepxf0+VmP5TsVtnpXpA7uZfZkA+gBsfQIvgMfPJMuPyKZnrzhz/f8eB96iGuaIXU7J1L\n\tLB5VQXQHrTTEnSVuKg1xPGMg0srhgNhoapRwXVIuVLaqeXqqCf/6e6aVM8RLHgQkgHOV\n\tWxGbV/VxHnWAwpOC+I0wwrKfZ2FCIZnhdEpeaMX2KGka7H1u8WZ/VqYFnAm+SA2Juxha\n\ttUbQ==","X-Gm-Message-State":"AHYfb5giaOd/RzeH4x8C3LlhU1bOFh5a+waSDPDwQXnTvlm2Ig/WxsfQ\n\tGBkK8jhkA7nhbL8K","X-Received":"by 10.36.208.132 with SMTP id m126mr180763itg.41.1503414665971; \n\tTue, 22 Aug 2017 08:11:05 -0700 (PDT)","From":"Bin Meng <bmeng.cn@gmail.com>","To":"Tom Rini <trini@konsulko.com>, U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Tue, 22 Aug 2017 08:15:11 -0700","Message-Id":"<1503414919-30820-7-git-send-email-bmeng.cn@gmail.com>","X-Mailer":"git-send-email 1.7.9.5","In-Reply-To":"<1503414919-30820-1-git-send-email-bmeng.cn@gmail.com>","References":"<1503414919-30820-1-git-send-email-bmeng.cn@gmail.com>","Subject":"[U-Boot] [PATCH 06/14] nvme: Respect timeout when en/disabling the\n\tcontroller","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>","MIME-Version":"1.0","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":"So far the driver unconditionally delays 10ms when en/disabling the\ncontroller and still return 0 if 10ms times out. In fact, spec defines\na timeout value in the CAP register that is the worst case time that\nhost software shall wait for the controller to become ready.\n\nSigned-off-by: Bin Meng <bmeng.cn@gmail.com>\n---\n\n drivers/nvme/nvme.c | 14 +++++++++++---\n 1 file changed, 11 insertions(+), 3 deletions(-)","diff":"diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c\nindex d92273e..8867977 100644\n--- a/drivers/nvme/nvme.c\n+++ b/drivers/nvme/nvme.c\n@@ -47,11 +47,19 @@ struct nvme_queue {\n static int nvme_wait_ready(struct nvme_dev *dev, bool enabled)\n {\n \tu32 bit = enabled ? NVME_CSTS_RDY : 0;\n+\tint timeout;\n+\tulong start;\n \n-\twhile ((readl(&dev->bar->csts) & NVME_CSTS_RDY) != bit)\n-\t\tudelay(10000);\n+\t/* Timeout field in the CAP register is in 500 millisecond units */\n+\ttimeout = NVME_CAP_TIMEOUT(dev->cap) * 500;\n \n-\treturn 0;\n+\tstart = get_timer(0);\n+\twhile (get_timer(start) < timeout) {\n+\t\tif ((readl(&dev->bar->csts) & NVME_CSTS_RDY) == bit)\n+\t\t\treturn 0;\n+\t}\n+\n+\treturn -ETIME;\n }\n \n static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,\n","prefixes":["U-Boot","06/14"]}