From patchwork Mon May 8 22:09:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 98850 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1539133qge; Mon, 8 May 2017 15:09:08 -0700 (PDT) X-Received: by 10.28.154.86 with SMTP id c83mr6060676wme.94.1494281348808; Mon, 08 May 2017 15:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494281348; cv=none; d=google.com; s=arc-20160816; b=Z4/yh8yyTnpvsKOSXYI9tWmqX37siPMhwuT5lZUfA5YqkiuIb42OujeSC+rv3ZKzyU r0jcFANVil1ICbnyrRlRnfzcon/JxQgaKjnKXxGltxvHFwcG5VnNHmJK/jr9seG7+zXw AqyviNI4M56NresKk8I5Uk4AzCk18dBcQ4JzuFXBhJ5lqg+07sjE77CVymGnVOOYrFVd Wjp6R1VxQzKX2cK7ZubLjVnaBxER8UAcFKFPlVwdSoHHaY7TqfBpVz+TVuRuoIlbsbJf ox1lTyOo8mkluVJnHpU+2NLBDe9aL3ZXhYm95OgC48wdWjVCFq9X9q3U8oHTBs6EIevi WPtA== 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:arc-authentication-results; bh=RqxjaRP6bAlLrU+Of5N/8exF2RISG6jrLnvNa5KjH/k=; b=yWkYQky0mjk9voYuRmAQMt27kHFsQUlQ5nOzOm3bkzOJjXHKzsUwdg7S4lKmExgYYd 4KFl9opU4Q0bY/TREf/X/AzZski7yQpha27pMI73/i1yKG47S1Gsf8uNWij04KzKRm6j UFTepelfIxbqEhjHKezb/9hvxQey8YzLvBG+GZqlylp9+wWZ4941I6N/5wB0w+JzFueB 97IYcK0ZROwK4Y/J1Q3E2RHUrSad5E1IEzb6r2qgMFFYR199UMzDa4UfgCjOZ929d6Af xvt3hhDzYQWN3eZCMcmpPbEvdCdat8Yu8R8I4rTko04OdsXiJHBB/SwNERC3RUJKhd03 HVtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c09::230 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-wm0-x230.google.com (mail-wm0-x230.google.com. [2a00:1450:400c:c09::230]) by mx.google.com with ESMTPS id 46si16788402wrx.82.2017.05.08.15.09.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 May 2017 15:09:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c09::230 as permitted sender) client-ip=2a00:1450:400c:c09::230; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c09::230 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x230.google.com with SMTP id u65so100519940wmu.1 for ; Mon, 08 May 2017 15:09:08 -0700 (PDT) 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=RqxjaRP6bAlLrU+Of5N/8exF2RISG6jrLnvNa5KjH/k=; b=e4K8EolHr6j046Fnb6m3qHZjCNnunFw86DYAbT9NG57yZUfILHdJhzy1jraiSFSJPT Fzx+X4Hxqu/e1aPt/otyBMorXVCxlqiLKHYOdyjLO9Q/31pz1k12HI3qswqOPgP429Yi 1Ne362vW/QEmhh1MjzQDHr5MdTOpy8bLNnaOA= 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=RqxjaRP6bAlLrU+Of5N/8exF2RISG6jrLnvNa5KjH/k=; b=BLx9bTs++uvOmIAKe6A4l0syhhpm1Tigb2JkmIFjmETbKiMgy4fuRqazsBFn1OL/4f JS4kK2xHT7cTAOFHnNZIEQHZ75o/dCn+1THRpeXDy9DooM6tblaMpr2evJWZMOnOLfIz WxthtqqB49nuVA8Kcha3PT2jqCZxy+SSXK9hILjMcyXN9pTBWeEp8Fd1ZYz3QB+4yZxy Ru06JoP4Ilx9u6MdfeWVtx8m4B1+XQHP/MiRO+fsSmiH0oEA9C2whsU/jYXSJXP9sAIm O6vtXjaMVAI9dCLraKUQx9rTAHOXQxmOIqYEYxIdg5QYpIx2NSQualvrSPdvCJ8aji7n G/Sw== X-Gm-Message-State: AN3rC/7vlFA7KQCFtBBJdxtK60qKAkxMgyIGNA5soTd3FpmnMqs2yH+G EeQm3zieeFD255Q6ZUk= X-Received: by 10.25.89.197 with SMTP id n188mr23179061lfb.163.1494281348455; Mon, 08 May 2017 15:09:08 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id 1sm1741011ljn.59.2017.05.08.15.09.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 May 2017 15:09:07 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Heiner Kallweit , Marek Szyprowski , Javier Martinez Canillas , Douglas Anderson , Markus Reichl , Anand Moon Subject: [PATCH 1/2] mmc: pwrseq: Add reset callback to the struct mmc_pwrseq_ops Date: Tue, 9 May 2017 00:09:02 +0200 Message-Id: <1494281343-18963-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494281343-18963-1-git-send-email-ulf.hansson@linaro.org> References: <1494281343-18963-1-git-send-email-ulf.hansson@linaro.org> The ->reset() callback is needed to implement a better support for eMMC HW reset. The following changes will take advantage of the new callback. Suggested-by: Heiner Kallweit Signed-off-by: Ulf Hansson --- drivers/mmc/core/pwrseq.c | 8 ++++++++ drivers/mmc/core/pwrseq.h | 3 +++ 2 files changed, 11 insertions(+) -- 2.7.4 diff --git a/drivers/mmc/core/pwrseq.c b/drivers/mmc/core/pwrseq.c index 9386c47..e3ad30f 100644 --- a/drivers/mmc/core/pwrseq.c +++ b/drivers/mmc/core/pwrseq.c @@ -76,6 +76,14 @@ void mmc_pwrseq_power_off(struct mmc_host *host) pwrseq->ops->power_off(host); } +void mmc_pwrseq_reset(struct mmc_host *host) +{ + struct mmc_pwrseq *pwrseq = host->pwrseq; + + if (pwrseq && pwrseq->ops->reset) + pwrseq->ops->reset(host); +} + void mmc_pwrseq_free(struct mmc_host *host) { struct mmc_pwrseq *pwrseq = host->pwrseq; diff --git a/drivers/mmc/core/pwrseq.h b/drivers/mmc/core/pwrseq.h index 39c911a..819386f 100644 --- a/drivers/mmc/core/pwrseq.h +++ b/drivers/mmc/core/pwrseq.h @@ -18,6 +18,7 @@ struct mmc_pwrseq_ops { void (*pre_power_on)(struct mmc_host *host); void (*post_power_on)(struct mmc_host *host); void (*power_off)(struct mmc_host *host); + void (*reset)(struct mmc_host *host); }; struct mmc_pwrseq { @@ -36,6 +37,7 @@ int mmc_pwrseq_alloc(struct mmc_host *host); void mmc_pwrseq_pre_power_on(struct mmc_host *host); void mmc_pwrseq_post_power_on(struct mmc_host *host); void mmc_pwrseq_power_off(struct mmc_host *host); +void mmc_pwrseq_reset(struct mmc_host *host); void mmc_pwrseq_free(struct mmc_host *host); #else @@ -49,6 +51,7 @@ static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; } static inline void mmc_pwrseq_pre_power_on(struct mmc_host *host) {} static inline void mmc_pwrseq_post_power_on(struct mmc_host *host) {} static inline void mmc_pwrseq_power_off(struct mmc_host *host) {} +static inline void mmc_pwrseq_reset(struct mmc_host *host) {} static inline void mmc_pwrseq_free(struct mmc_host *host) {} #endif From patchwork Mon May 8 22:09:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 98851 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1539143qge; Mon, 8 May 2017 15:09:10 -0700 (PDT) X-Received: by 10.223.139.25 with SMTP id n25mr41195274wra.17.1494281350214; Mon, 08 May 2017 15:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494281350; cv=none; d=google.com; s=arc-20160816; b=nIU+bf2ffDRd/n8MBw4Lx9celty6fYFeqQaXjYOtQkw1wxooOP0d+Iry3p5NNva5Ju Lpf0J30+lQ5sllpe9y26iZk0jFmLarUVha9UqsJMSHSh3hO/M/KFBlVjVQ/sSEu7NJvz u5zPO7X1LlmQcJVJt8eGgvbMQgpOS0/HlXi5IhvEntxr7AZyXuemBwRbm4En6SQ8VGTo p+qYNDyyI9WDjclB53qahoovpqP6tWAciaxwxMB8bsbNDN/1KzHg/qQGmznJFJzV0C8/ hBloAhIa7K7g8Rn1x8OAVyWExjCEmc1xoB3hVBdR9XD7Tpx3XB+6UO5ZhoEN0vVCEAQi Og3Q== 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:arc-authentication-results; bh=T+kgzfPoPtqIgnd8UEGlO6JJi3jp4x5kqp8A98vpLwQ=; b=tTXYfGtPHwwfX60dUWTf7AJFQ3QjsWhSChxk/2v5nSQ2UyMPOtxd4+TmSoEjcaIXez FSqrsHTzKbgL+TPnnA1nGSQLXWl3C+x/ZmRAgK7+11xQBNEcP2qYOrpHAV+d0Ufq9iQ/ NmxfCwe7DNw3SPBadHOusM++dMpA0zGfuk34+hR+IdXSS/z9MGqS4lDTZfRM1WYCjd9X IQQgF1PO6eEHYX66vwBGsr9ZZ0tKvYd2GNWDoswLXaSjZkH4tQ74CkUuUfXUrEvfoy1x ySUKUpKCKDpJ1qwDWcAuyLVcqRfOghRy1vSD2pd9PObS7fp/wl1ExfwwvREMP/1HI2wE 0LHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c09::22f 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-wm0-x22f.google.com (mail-wm0-x22f.google.com. [2a00:1450:400c:c09::22f]) by mx.google.com with ESMTPS id l12si14027462wrb.103.2017.05.08.15.09.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 May 2017 15:09:10 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c09::22f as permitted sender) client-ip=2a00:1450:400c:c09::22f; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c09::22f as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wm0-x22f.google.com with SMTP id m123so80162294wma.0 for ; Mon, 08 May 2017 15:09:10 -0700 (PDT) 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=T+kgzfPoPtqIgnd8UEGlO6JJi3jp4x5kqp8A98vpLwQ=; b=W8q+NDJs9/j6o1xIe0mX5kghVSejFC04Endtf8EfU5wfsb8w+QV4pxww+SzEyIG66e 69ssxSfM4auFvRenLji8o/CeWTMUy56BDGslfN/0mPbeR7mSrYb6XWH9cgD7skF9VziV /04e/GWcrbFmVUfrpp5ec6ayNkZudX1DjuCMA= 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=T+kgzfPoPtqIgnd8UEGlO6JJi3jp4x5kqp8A98vpLwQ=; b=Y9YS2A59uWAMvLnSQ/9y6S6vHtVVvXwDS2TIVp42hEGejVL4gnj9qWUfNhq7sjBFzJ e5B7oI7yIYXd6yiVo8txzysLoiyBnYEw/phwp7qhVaJybABoJ0USjGKDftZXcAalDtNZ scwa7PRd7ToyH0p6Ub9zcW3k1hO5vDpT4k4I6iiqZjBNAMjNDX9A9XP/bI8sH5e9V1DZ JVE0WrzFOD2yU0CjVWYeSRR3BgZ3p1JzsQDtpsBzVns38keWJGPgWYN0U9zrbgT4brWn w5vyxbb6qANjydNYPjcxX8LONI84EuYXtipHJKSl7thvZ0IK/U6XKA0G1P+9S+0kfAE8 fRqQ== X-Gm-Message-State: AODbwcBCYx7RGR2P5/Q8FFdZWK80oM0mQE35zsUesErd/WRc5tBwS1cg rndOHhLVKE86EAIH4aHfqT6Z X-Received: by 10.25.29.145 with SMTP id d139mr5002877lfd.126.1494281349815; Mon, 08 May 2017 15:09:09 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id 1sm1741011ljn.59.2017.05.08.15.09.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 May 2017 15:09:09 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Heiner Kallweit , Marek Szyprowski , Javier Martinez Canillas , Douglas Anderson , Markus Reichl , Anand Moon Subject: [PATCH 2/2] mmc: core: Don't do eMMC HW reset when resuming the eMMC card Date: Tue, 9 May 2017 00:09:03 +0200 Message-Id: <1494281343-18963-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494281343-18963-1-git-send-email-ulf.hansson@linaro.org> References: <1494281343-18963-1-git-send-email-ulf.hansson@linaro.org> In case if a pwrseq-emmc has been bound to the host, a call to mmc_power_up() triggers an eMMC HW reset via the pwrseq_emmc's ->post_power_on() callback. This isn't really what we want, as mmc_power_up() is called each time when resuming the card. As a matter of fact, the current approach may also violate the eMMC spec, as the involved delays managed in pwrseq_emmc assumes both VCC and VCCQ has been turned on, which isn't the case for VCCQ, unless the regulator is always on. Fix this behaviour by aligning to the same procedure used when the mmc host implements the ->hw_reset() callback and has the MMC_CAP_HW_RESET flag set. In this way the eMMC HW reset is issued at card detection scan, to cope with bogus bootloaders and in the error recovery path via the mmc specific bus_ops->reset() callback. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 2 ++ drivers/mmc/core/mmc.c | 2 ++ drivers/mmc/core/pwrseq_emmc.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 82c45dd..ad8caf4 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2597,6 +2597,8 @@ EXPORT_SYMBOL(mmc_set_blockcount); static void mmc_hw_reset_for_init(struct mmc_host *host) { + mmc_pwrseq_reset(host); + if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset) return; host->ops->hw_reset(host); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2c87ded..e3b6bea 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -27,6 +27,7 @@ #include "mmc_ops.h" #include "quirks.h" #include "sd_ops.h" +#include "pwrseq.h" #define DEFAULT_CMD6_TIMEOUT_MS 500 @@ -2127,6 +2128,7 @@ static int mmc_reset(struct mmc_host *host) } else { /* Do a brute force power cycle */ mmc_power_cycle(host, card->ocr); + mmc_pwrseq_reset(host); } return mmc_init_card(host, card->ocr, card); } diff --git a/drivers/mmc/core/pwrseq_emmc.c b/drivers/mmc/core/pwrseq_emmc.c index adc9c0c..efb8a79 100644 --- a/drivers/mmc/core/pwrseq_emmc.c +++ b/drivers/mmc/core/pwrseq_emmc.c @@ -56,7 +56,7 @@ static int mmc_pwrseq_emmc_reset_nb(struct notifier_block *this, } static const struct mmc_pwrseq_ops mmc_pwrseq_emmc_ops = { - .post_power_on = mmc_pwrseq_emmc_reset, + .reset = mmc_pwrseq_emmc_reset, }; static int mmc_pwrseq_emmc_probe(struct platform_device *pdev)