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: 153297 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3772519ljp; Mon, 10 Dec 2018 08:52:44 -0800 (PST) X-Received: by 2002:a19:2c92:: with SMTP id s140mr6954124lfs.42.1544460764879; Mon, 10 Dec 2018 08:52:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544460764; cv=none; d=google.com; s=arc-20160816; b=loYKx9nkurkrC8Frg0fDNxWobnDLgAYYTQBVVW4fs8OcWYbl2G636T2vV43EY4X95e 1TdQVdmSyB10yPCP8q/XJmVKvk3/rFk1OHM75xKUu97fQnNFdXqCymB2TOPtB53rzGj/ sN/njqiQiLQVG29wDaRnJh2rQx380ArPb4aYI/FYtQDAu/Wy03maiwMMhciBOfhzwGP2 Bw7TAzVm/SxhsapxzC97Ni3zs71YNRWPsWZQq2oQ45Hwjz0d11d1tHS/0OXVyPR4LPZ5 8XG7swoRvpDBm50NYq/VvSpROM6iYnKWZ1hsa5tdVIk/mQMGM0aym+fsiWM3pWDlHa4j TSNA== 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=hqcZCX2GWMpTtbs35jhyR+WR9qxRRzYUjJ3v61z7O8g=; b=f/GH+fc0MuOQigwtOsbLuoOnzTBYkTjTnPUmwyiHDaUDdATAr6rYfOcDXKv3xqiEA/ eeIATGVSlVf99NaS16W07cwX0DLdWEZ9b3Dyat+f6Qp88YMLOZIZfev2WDRG4MkF8UU2 aR1PJ53ezGXHOhGG/TjCqGHmF/kvhHk0ftZw++Sqdy5i0oazlhtjcQq8mUXHwVlnIKHP NaJy24umK3YaHlqZuPXNf2Ogf6uy+7OI94nD7O1aTyngwqWU+qSCzSY+UjKKRHq6GOl4 +RN4pKtJ3cNbeTTpskrfGukUswebQdbRE8IIXiUfm5jtPsf9kh8L0VGhJ2q3Lxmy/76M bRpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SzZgiMwI; 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 n10sor2952536lfe.49.2018.12.10.08.52.44 for (Google Transport Security); Mon, 10 Dec 2018 08:52:44 -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=SzZgiMwI; 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=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=DnBI4JqfamzeSeA1Y1gsBK7oGEXQMN7odOZYKe6pO9CPvpTAGdtRi+cD5rdX0QT9Tl XMDUq83mHYHxr44uWB/I7S+cmx/Sm4GNKJ61Nu4s2/WFt78bq9LQ5rVK/4BjycPv2mRs BlDLTLBPp59nIuvUt3My9ao3BmMKjBHLo1ouvrlWpYY69xYhjRhqAlQ4bCdaWH0tRkJG SWep5O+PLabgJoV19idOB/9ft2YA85zeDIMiYCXiSq/M3oqGDy64QJQJrXLeTaxTZrKx m+wEzPumfGqHBG/Xwl+85ocIOSR7TGryCCjWGMEF+18hGuWmbUcKV6UP4wgWzMkykh1i 5Zaw== X-Gm-Message-State: AA+aEWZGzHspCWQ/0abb6TEz2rPqT/IMW6mb2qedmIlMTuqVIBUjJUNJ 3hbjLUoZ5y6/uYb5OXjU0JXRwLZP 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) 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 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> 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(-) -- 2.17.1 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: 153298 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3772553ljp; Mon, 10 Dec 2018 08:52:46 -0800 (PST) X-Received: by 2002:a2e:7317:: with SMTP id o23-v6mr8531197ljc.67.1544460766393; Mon, 10 Dec 2018 08:52:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544460766; cv=none; d=google.com; s=arc-20160816; b=UUhTzkI+H3oxDXKe0QAuBpHJitw1htXEpQCPpiIuBO1FejgyCVgTJqFRB0nWfCM8Wu f92cGVGmqdsLcjPjA13UDzNqdfrB3qRNo7+JBEG02AFxMunb84/HaQReof2qaoMti7dp sCm+492dtJjbryWSRnVERui7WQmCgP0bciphkp0tBPiLt2WPrR3OVvzRQOxGkfwePXtN IYT5FOpeJJuembtesBxBIVbrG3Krj8z4s5QfI1JNolJ6gVsUyIiP1fvtE1hUuGHOraJ0 3AkomfR0uPM4ykobSo/77dlgU66D+5A1efSqEtexCYjXKRgUr+QcIi0XC1WxNt5RC44A t4SQ== 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=hztVpdSncV6eOao2PFKFcbGFH4Z0tMgd8EvT/1T5ytY=; b=F8bEYJNjUmTDgyAI0As4zp4vqFe7Sty5iyRJ69UbO6MyhlNx+TJNvVrROtWvnFoCvo GFgwzkUq1N815FZb2yBoYLe/VLRoNLirZVpTNcHOSF8S07MMOreWh53gOAsJSE9UVkvO 9iJ/2B0/7gILjAHjHiz7LKBY/58ngfPfwCmutwq+Ka4CiWZMFK5RgUK8NySQhQBBms5O SYjUt2qsgEnEfBdPq3HkdeI+a2u3gPsa58BuhDZai9r2o9luGN3o16ol022MgQlOma9X CWVqZrQL1vpKWqHwpxx8KemoVTUDYMLnTsn4wKZRLXgN6m7wk7AIf5eKWANWEIUz5ayS 7LFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F5GpOquj; 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 x82sor2952830lff.40.2018.12.10.08.52.46 for (Google Transport Security); Mon, 10 Dec 2018 08:52:46 -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=F5GpOquj; 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=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=IiEflHh9Z12ip3gYB4C59TbyB3hBAho74pk4vYxoAJUQDqnzhUlNIDlkvbLyO9weDy JQFIngITcGtfks5XVBFDV58OXoE9SZxhYYKOdOvBIcb/EF/pSKu20impz9pIyguAJ+zb XSRlWSrH77YV/ovGQqyr52lWdwZyh9uX98EtxQ9YxXXolPz7Jdtv/Ks2t7+n0Nw2qydY MxOnrDPgnfeCqQfjKTNxdprDiNphWflpRwatE1oSRYLl/kRFU5V+HPzvbTaGYrYX2eeV HrF8NSbtMbkTNCIVNBKuK48faKt7oQAeN1Bw8sDPIpzT0fnYRiEO7Ff5V9YTQt/tX8+T l3VA== X-Gm-Message-State: AA+aEWadmD4OOYK6qlhonlnp8tHHgVMlWfmeOPKsKvH+rgz2l9LavqJ6 Jec9Th6KDPPDaOsqqq8vQUjmchIn 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) 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 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> 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(-) -- 2.17.1 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: 153299 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3772585ljp; Mon, 10 Dec 2018 08:52:47 -0800 (PST) X-Received: by 2002:a2e:80d3:: with SMTP id r19-v6mr7720659ljg.151.1544460767674; Mon, 10 Dec 2018 08:52:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544460767; cv=none; d=google.com; s=arc-20160816; b=E0BpFbN1kRZsJT8YYcT7U8WAUWvQen4TQpTYHqsARVd5MyeiPWTjVELyzdDDeIkoPE 2m8RwxDJsT8BfBR+MXe0ycdApl730W0z+h3KgmQQFh0vIktE9SIHcf744UNgn7bXskfh CXMgkasg2Q0I4laM/5/EvTap+4VGpFv679SqdUHehn1YZAAaq5JLsHXp8nHCh+pTEbtr xEZ1Jbsnl375HDF+NgBxGYrL2Th+0W8Q0zqwNdS4ogO9xrb2cROPIAO/TkrLeNFtsWNL /MvqFVHXilZIziZnjlE02FgWBUDaWZAlNYUVLpfZ9c0uH5hNZHyiYa2Rz/3wl5zgU+MS INWA== 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=ev/ntoDbh5ybE5JNkNvhwN8PjP40USGqAlYJOPoCA2k=; b=v+vZ61gnxkmI0G3uZX2Wlyj9NlcO4vCwh8zESUXOVLaZU7j2fvqrSFq0TbiILFGaAJ eF6u3v+oVZXi7wA89JdmSBXh2LdUw4yEG6j9tsn0QLzTjf5OGAFrBGs/02m0Gxs/ZwWy Kx5HxJBwix4MGglpcWatiDPVhVDc37UKZljt9RT7YtE1HLyCH1nP3VM/jCsmfwYwcu7m h2IH4eWyc9feNW0vZr2oin09MXugBo4e0dGBytGVRFeNvBzKhr6jAndEx1Zs3PCMmShq xMVqMf1yP0iC7s8LhjZ7TX7IxBdSZshNqJ6NH5SbIDno/I+2ebiNBWGVk3s0VMJ6x/oi BMqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g8Xnjr9Z; 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 u66sor2953459lff.39.2018.12.10.08.52.47 for (Google Transport Security); Mon, 10 Dec 2018 08:52:47 -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=g8Xnjr9Z; 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=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=VEuhD4GbsJXlWamDpb+Zf4IoaW38fLw8KYwyqR8DIFGOvd7/E/g6MP08DZwlJRIBpz /S5acOrTYV1+oy0Ft5P7vDnt1pAwAoF56mqpanfrWGwmpYRIYIvc9DhPMSkQzAnvha4s 2J2BbVb88CQkLjr9AofqkUUnhi/sMRzyEFvd4YfvNt7c2sJwyaHgKYud0UPkWB//Qwq7 zPROTxSk09gqeK9+g9XU4O0Zbb5yVtLID8OubtCfF/qZiVxLdCLQzAbQ6nzQ9vfT6ATk WZZkn6L4lfOcHslQ0ThEkpdw86Rd3eaFmil7X6dXDWy47/X9yC4bg6oW8FbBq7WhDWf8 l23A== X-Gm-Message-State: AA+aEWbVCAdIAad/8nrwKxHlSCqpX3mXnlkYfaP4UXLeqTASRPGvU3fW D3B3NEpF8YhNESACSh5Ae6ih3nH7 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) 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 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> 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(-) -- 2.17.1 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: 153300 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3772610ljp; Mon, 10 Dec 2018 08:52:49 -0800 (PST) X-Received: by 2002:a2e:5c86:: with SMTP id q128-v6mr8354027ljb.119.1544460769080; Mon, 10 Dec 2018 08:52:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544460769; cv=none; d=google.com; s=arc-20160816; b=jUe6jl6S3vbNBHZvpi/el6hdIhaYBTv7L2Cl0eMprrN0GSUI9kb3UR0ajAkWmPDwD4 yM+RxWkNtgGRdF3VRW4jxDrTlR5luBtgHvSaLTUQuK5X6+SGNbOS/yBH2815LZvouJMC MRWo6xzBh2miZ5qtq2ht3YZIQfymLBEWufPZAJrl8Sq6P354pyxhLY8HlG9P5D8cWA5C i7hfazDyH7ZFLGicdRENgbKf5hstYfXZDu7b9w0kGNDIaQsNuzYbFB80bbt4Sdwo7w/I EJNLV0y5cjDr5mt3oQkYx26374lVwmRUNsbylbdXVBO5H9FU0KynjTRy7nCOy7EMnVRz Tt7Q== 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=V22VZ/qtHeHwmBH5FUkElluUpeyt8M78z5UvAjTJvFE=; b=LFKjuWElE/mZxoKSlSt8vTIozBfB5gIS7GBHmLBVMSM/CF/AQU008VU0MAS7aQE4NC blMRUYDC+cwvC1yYBixEATvrQ/zimRcR0FhihEe509ruKf9OHb0ME/CDQH4K5vA+9EuK u5MrlBX2y/lABeCiTbmR/pxokQKjELan3x+HJ5Hjbk2kS4US268R+zA4p29lGx1KmWC6 gyWGUaVzEPun8s0PUxVL5L0ezjNJpj3VIxf+aZe+sDtLLXyjq1AAcTlXCAIKf4ZA9VqY YyL85021DHuoG34ZUJZCr2kNrGP3VgV6WxtAlcMik8TYduuyI7odoE8XyS4XnRYfoKVi 24qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RBb4KMtF; 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 z25sor3009618lfb.52.2018.12.10.08.52.49 for (Google Transport Security); Mon, 10 Dec 2018 08:52:49 -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=RBb4KMtF; 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=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=TSruCj7JE4V4J5ACmTbz2iujF5D6i2gkNx7WJIuEORX6rIu6Uj+PEB95FngDH5ZXfT zKIFdeiLQVi/rd1IbrddVjrgiHd/uGmQ6jdaTvuC3549YxMH3+X8QzyFbkrHqMbNJATq KXcdGKooIRrT4KrkUHRgIKoQxHVyclT1pWPLPzYZCPm81OjnpyUBFCzkUkTOFcytgC4A J03SsvVWXB3aEMBzknAZeIGzqrTzc5tt32wFe9Hoyv7velG4J1AnfVRSmoNeV3c9btbL j3WNWDTwNGg4zvJpaZYDV19rnZHmKCpKn0SLaSLDfdkzDrB9lTarszQeI+qTrsgzF9Ne Dl5w== X-Gm-Message-State: AA+aEWYN5FBrdxRegaAqkgLe1Zql5OVEa69RHH0LB7cpgRTlKLVXg4Wg gEeGHrdDIJE2jF5RIXX020d0Ad3Y 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) 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 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> 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(-) -- 2.17.1 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: 153301 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3772634ljp; Mon, 10 Dec 2018 08:52:50 -0800 (PST) X-Received: by 2002:a19:9653:: with SMTP id y80mr7242058lfd.66.1544460770476; Mon, 10 Dec 2018 08:52:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544460770; cv=none; d=google.com; s=arc-20160816; b=RmMhxQXzT+G6qJZSqZmLCNqCOFkLM1+ahYqMGBOnf81Zgh4vgVBEDD0D6S2uw5LqHn YVVcIMipqQi1oZLRqvT0Qi8JyMrtuT6WNLHstLBrq0MP+6+HDXF5isKZz+xa4Ukg8fkR NoY0V37OLkAXwTgaSPrw60qW+MeInIhA+AIkpxpaiby0cuoRO48FSFdfEpUVHqSx61nP ue7JONbXrGaoVLD8PrJWmsA7bq5pd4qq8qZ/FfzwKn5kVrgSBCxM6PZwDV0kArkx3LUX AhntnBOfVS7WvB7Ki//dpCiUEf0oPfDpbw1BSHD2a6TY3sx1dGLznXJFMp4254hQQcJz 1K0A== 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=8zMKg9J/wlrwcIQwq1keZ7jgftzEkSMTzdh6lkHbG9k=; b=qX722Q/60AjosdYN1FBKqvgRU8pEJWpJRPnNiK2v9ovixr5CE2KGMi8bEf27EHPzBW N5pyQSnFu4rz6alj7B1Qvd9w3jhmuQ2JiEL8Nqo/+AWZiar1X9H97wn1ciFDSPGKShwW qVBbr23KQnqMwvO/x6kprJRbcMV8dBsCPqmznRrh4a33IrQvoIB3KddrjIDXJ/xP+7QI EIn2VSz0yesQsrGxccbmWaGPWawmWC7V99tIA+89wvHNu8GZhnEuFZIPqbE0KQKf9/Hs qnuW/TjzlTLCGyQhobHsT6ruUv8TLrAkhRGrCASj40dssg3bW5gr5t1GCA3OeyRWZWav pGRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Elr7q6xL; 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 p191sor2986974lfp.55.2018.12.10.08.52.50 for (Google Transport Security); Mon, 10 Dec 2018 08:52:50 -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=Elr7q6xL; 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=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=Y0xImkv5+MFxFM3PFL/v/ovd0kxK4khnQLaJ46FVFc4YYvwiAmMXhriQQj97RXTKm+ AobOq+tc42kL+furtac+LLuakeJOvBXDTr3+ycgJMjmLrSTuS4LZE97dbqLeiQfXq+w/ dMJkysCGC/7GrQsz95qkBEdngM0XdVW002zJtx0wUHRtHZ7lLDr2Vkq3AuAsr2xJYPvv IjRPNX5HE/QQaRfvAEO8tBwO0elvzfclWOZlCoNN7jhUKpU0liK4eXnPaGxxo4C0vAf7 NYrEhevQtODSs00LWtN0O0yeGjHBQjopAB3qP6yxINFlDOpEhZEcGrhFyccKYIuHceGf 7Eag== X-Gm-Message-State: AA+aEWYUVGP8FCbUxuFMlb3msVLpCZdj7XVlC5bM0kuWyur4qmZRRZrF IVmG7/fkXqbSRjVqL+EtCfXlQZ5E 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) 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 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> 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(-) -- 2.17.1 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);