All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/25] sdhci patches
@ 2017-03-20 17:50 Adrian Hunter
  2017-03-20 17:50 ` [PATCH 01/25] mmc: sdhci: Do not disable interrupts while waiting for clock Adrian Hunter
                   ` (27 more replies)
  0 siblings, 28 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Hi

Here are some sdhci patches that include preparation for CQE and some
general improvements.  Patches such as:

    mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
    mmc: sdhci: Do not use spin lock in set_ios paths

affect several drivers specifically, like:

    drivers/mmc/host/sdhci-brcmstb.c
    drivers/mmc/host/sdhci-esdhc-imx.c
    drivers/mmc/host/sdhci-of-arasan.c
    drivers/mmc/host/sdhci-of-at91.c
    drivers/mmc/host/sdhci-of-esdhc.c
    drivers/mmc/host/sdhci-pxav3.c
    drivers/mmc/host/sdhci-s3c.c
    drivers/mmc/host/sdhci-sirf.c
    drivers/mmc/host/sdhci-spear.c
    drivers/mmc/host/sdhci-st.c



Adrian Hunter (25):
      mmc: sdhci: Do not disable interrupts while waiting for clock
      mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power
      mmc: sdhci: Optimize delay loops
      mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
      mmc: sdhci-pci: Let devices define their own private data
      mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices
      mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
      mmc: sdhci: Remove ->select_drive_strength() callback
      mmc: sdhci: Do not use spin lock in set_ios paths
      mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning
      mmc: sdhci: Improve debug print format
      mmc: sdhci: Add response register to register dump
      mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs()
      mmc: sdhci: Improve register dump print format
      mmc: sdhci: Export sdhci_dumpregs
      mmc: sdhci: Get rid of 'extern' in header file
      mmc: sdhci: Add sdhci_cleanup_host
      mmc: sdhci: Factor out sdhci_set_default_irqs
      mmc: sdhci: Add CQE support
      mmc: sdhci-pci: Let devices define how to add the host
      mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm
      mmc: sdhci-pci: Conditionally compile pm sleep functions
      mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks
      mmc: sdhci-pci: Add runtime suspend/resume callbacks
      mmc: sdhci-pci: Move a function to avoid later forward declaration

 drivers/mmc/host/sdhci-acpi.c        |  12 +-
 drivers/mmc/host/sdhci-brcmstb.c     |   3 +
 drivers/mmc/host/sdhci-esdhc-imx.c   |   6 +
 drivers/mmc/host/sdhci-msm.c         |   8 -
 drivers/mmc/host/sdhci-of-arasan.c   |   9 +-
 drivers/mmc/host/sdhci-of-at91.c     |   5 +-
 drivers/mmc/host/sdhci-of-esdhc.c    |   3 +
 drivers/mmc/host/sdhci-pci-core.c    | 551 ++++++++++++++++++++---------------
 drivers/mmc/host/sdhci-pci-data.c    |   3 -
 drivers/mmc/host/sdhci-pci-o2micro.c |   4 +-
 drivers/mmc/host/sdhci-pci.h         |  24 +-
 drivers/mmc/host/sdhci-pltfm.c       |   3 +
 drivers/mmc/host/sdhci-pxav3.c       |  10 +-
 drivers/mmc/host/sdhci-s3c.c         |  10 +-
 drivers/mmc/host/sdhci-sirf.c        |   3 +
 drivers/mmc/host/sdhci-spear.c       |   3 +
 drivers/mmc/host/sdhci-st.c          |   6 +-
 drivers/mmc/host/sdhci.c             | 404 ++++++++++++++++---------
 drivers/mmc/host/sdhci.h             |  58 ++--
 19 files changed, 691 insertions(+), 434 deletions(-)


Regards
Adrian

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 01/25] mmc: sdhci: Do not disable interrupts while waiting for clock
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 02/25] mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power Adrian Hunter
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Disabling interrupts for even a millisecond can cause problems for some
devices. That can happen when sdhci changes clock frequency because it
waits for the clock to become stable under a spin lock.

The spin lock is not necessary here. Anything that is racing with changes
to the I/O state is already broken. The mmc core already provides
synchronization via "claiming" the host.

Although the spin lock probably should be removed from the code paths that
lead to this point, such a patch would touch too much code to be suitable
for stable trees. Consequently, for this patch, just drop the spin lock
while waiting.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org
---
 drivers/mmc/host/sdhci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6fdd7a70f229..9c1a099afbbe 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1362,7 +1362,9 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk)
 			return;
 		}
 		timeout--;
-		mdelay(1);
+		spin_unlock_irq(&host->lock);
+		usleep_range(900, 1100);
+		spin_lock_irq(&host->lock);
 	}
 
 	clk |= SDHCI_CLOCK_CARD_EN;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 02/25] mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
  2017-03-20 17:50 ` [PATCH 01/25] mmc: sdhci: Do not disable interrupts while waiting for clock Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 03/25] mmc: sdhci: Optimize delay loops Adrian Hunter
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Disabling interrupts for even a millisecond can cause problems for some
devices. That can happen when Intel host controllers wait for the present
state to propagate.

The spin lock is not necessary here. Anything that is racing with changes
to the I/O state is already broken. The mmc core already provides
synchronization via "claiming" the host.

Although the spin lock probably should be removed from the code paths that
lead to this point, such a patch would touch too much code to be suitable
for stable trees. Consequently, for this patch, just drop the spin lock
while waiting.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org # v4.9+
---
 drivers/mmc/host/sdhci-pci-core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 982b3e349426..86560d590786 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -451,6 +451,8 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 	if (mode == MMC_POWER_OFF)
 		return;
 
+	spin_unlock_irq(&host->lock);
+
 	/*
 	 * Bus power might not enable after D3 -> D0 transition due to the
 	 * present state not yet having propagated. Retry for up to 2ms.
@@ -463,6 +465,8 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 		reg |= SDHCI_POWER_ON;
 		sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
 	}
+
+	spin_lock_irq(&host->lock);
 }
 
 static const struct sdhci_ops sdhci_intel_byt_ops = {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 03/25] mmc: sdhci: Optimize delay loops
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
  2017-03-20 17:50 ` [PATCH 01/25] mmc: sdhci: Do not disable interrupts while waiting for clock Adrian Hunter
  2017-03-20 17:50 ` [PATCH 02/25] mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 04/25] mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm Adrian Hunter
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

The delay loops for reset and clock enable always take at least 1 ms
because they use mdelay(1). However they can take a lot less time e.g. less
than 50us. Use ktime and reduce the delay to 10 microseconds per loop.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9c1a099afbbe..642e1e4acdcf 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -14,6 +14,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/ktime.h>
 #include <linux/highmem.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -165,7 +166,7 @@ static void sdhci_runtime_pm_bus_off(struct sdhci_host *host)
 
 void sdhci_reset(struct sdhci_host *host, u8 mask)
 {
-	unsigned long timeout;
+	ktime_t timeout;
 
 	sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET);
 
@@ -177,18 +178,17 @@ void sdhci_reset(struct sdhci_host *host, u8 mask)
 	}
 
 	/* Wait max 100 ms */
-	timeout = 100;
+	timeout = ktime_add_ms(ktime_get(), 100);
 
 	/* hw clears the bit when it's done */
 	while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) & mask) {
-		if (timeout == 0) {
+		if (ktime_after(ktime_get(), timeout)) {
 			pr_err("%s: Reset 0x%x never completed.\n",
 				mmc_hostname(host->mmc), (int)mask);
 			sdhci_dumpregs(host);
 			return;
 		}
-		timeout--;
-		mdelay(1);
+		udelay(10);
 	}
 }
 EXPORT_SYMBOL_GPL(sdhci_reset);
@@ -1346,24 +1346,23 @@ u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock,
 
 void sdhci_enable_clk(struct sdhci_host *host, u16 clk)
 {
-	unsigned long timeout;
+	ktime_t timeout;
 
 	clk |= SDHCI_CLOCK_INT_EN;
 	sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
 
 	/* Wait max 20 ms */
-	timeout = 20;
+	timeout = ktime_add_ms(ktime_get(), 20);
 	while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
 		& SDHCI_CLOCK_INT_STABLE)) {
-		if (timeout == 0) {
+		if (ktime_after(ktime_get(), timeout)) {
 			pr_err("%s: Internal clock never stabilised.\n",
 			       mmc_hostname(host->mmc));
 			sdhci_dumpregs(host);
 			return;
 		}
-		timeout--;
 		spin_unlock_irq(&host->lock);
-		usleep_range(900, 1100);
+		udelay(10);
 		spin_lock_irq(&host->lock);
 	}
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 04/25] mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (2 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 03/25] mmc: sdhci: Optimize delay loops Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 05/25] mmc: sdhci-pci: Let devices define their own private data Adrian Hunter
                   ` (23 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Devices might save and restore tuning values so that re-tuning might not be
needed after a pm transition.  Let drivers decide by pushing the
mmc_retune_needed() logic down to them.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-acpi.c      | 12 ++++++++++--
 drivers/mmc/host/sdhci-brcmstb.c   |  3 +++
 drivers/mmc/host/sdhci-esdhc-imx.c |  6 ++++++
 drivers/mmc/host/sdhci-of-arasan.c |  3 +++
 drivers/mmc/host/sdhci-of-at91.c   |  3 +++
 drivers/mmc/host/sdhci-of-esdhc.c  |  3 +++
 drivers/mmc/host/sdhci-pci-core.c  | 22 ++++++++++++++++++----
 drivers/mmc/host/sdhci-pci.h       |  2 ++
 drivers/mmc/host/sdhci-pltfm.c     |  3 +++
 drivers/mmc/host/sdhci-pxav3.c     |  5 +++++
 drivers/mmc/host/sdhci-s3c.c       |  6 ++++++
 drivers/mmc/host/sdhci-sirf.c      |  3 +++
 drivers/mmc/host/sdhci-spear.c     |  3 +++
 drivers/mmc/host/sdhci-st.c        |  6 +++++-
 drivers/mmc/host/sdhci.c           |  4 ----
 15 files changed, 73 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index 9dcb7048e3b1..665c5f3009b4 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -524,8 +524,12 @@ static int sdhci_acpi_remove(struct platform_device *pdev)
 static int sdhci_acpi_suspend(struct device *dev)
 {
 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
+	struct sdhci_host *host = c->host;
 
-	return sdhci_suspend_host(c->host);
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
+	return sdhci_suspend_host(host);
 }
 
 static int sdhci_acpi_resume(struct device *dev)
@@ -544,8 +548,12 @@ static int sdhci_acpi_resume(struct device *dev)
 static int sdhci_acpi_runtime_suspend(struct device *dev)
 {
 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
+	struct sdhci_host *host = c->host;
+
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
 
-	return sdhci_runtime_suspend_host(c->host);
+	return sdhci_runtime_suspend_host(host);
 }
 
 static int sdhci_acpi_runtime_resume(struct device *dev)
diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c
index 159f6f64c68e..242c5dc7a81e 100644
--- a/drivers/mmc/host/sdhci-brcmstb.c
+++ b/drivers/mmc/host/sdhci-brcmstb.c
@@ -29,6 +29,9 @@ static int sdhci_brcmstb_suspend(struct device *dev)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	int res;
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	res = sdhci_suspend_host(host);
 	if (res)
 		return res;
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 7123ef96ed18..cf666a03b812 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1322,6 +1322,9 @@ static int sdhci_esdhc_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	return sdhci_suspend_host(host);
 }
 
@@ -1346,6 +1349,9 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev)
 
 	ret = sdhci_runtime_suspend_host(host);
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	if (!sdhci_sdio_irq_enabled(host)) {
 		clk_disable_unprepare(imx_data->clk_per);
 		clk_disable_unprepare(imx_data->clk_ipg);
diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index 1cfd7f900339..28feb5367c14 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -315,6 +315,9 @@ static int sdhci_arasan_suspend(struct device *dev)
 	struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
 	int ret;
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	ret = sdhci_suspend_host(host);
 	if (ret)
 		return ret;
diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
index 7fd964256faa..ce4ae21d5947 100644
--- a/drivers/mmc/host/sdhci-of-at91.c
+++ b/drivers/mmc/host/sdhci-of-at91.c
@@ -131,6 +131,9 @@ static int sdhci_at91_runtime_suspend(struct device *dev)
 
 	ret = sdhci_runtime_suspend_host(host);
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	clk_disable_unprepare(priv->gck);
 	clk_disable_unprepare(priv->hclock);
 	clk_disable_unprepare(priv->mainck);
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index d3aa67142839..ff37e7459386 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -528,6 +528,9 @@ static int esdhc_of_suspend(struct device *dev)
 
 	esdhc_proctl = sdhci_readl(host, SDHCI_HOST_CONTROL);
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	return sdhci_suspend_host(host);
 }
 
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 86560d590786..b7150e935fb6 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -1653,6 +1653,7 @@ static int sdhci_pci_suspend(struct device *dev)
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct sdhci_pci_chip *chip;
 	struct sdhci_pci_slot *slot;
+	struct sdhci_host *host;
 	mmc_pm_flag_t slot_pm_flags;
 	mmc_pm_flag_t pm_flags = 0;
 	int i, ret;
@@ -1666,14 +1667,19 @@ static int sdhci_pci_suspend(struct device *dev)
 		if (!slot)
 			continue;
 
-		ret = sdhci_suspend_host(slot->host);
+		host = slot->host;
+
+		if (chip->pm_retune && host->tuning_mode != SDHCI_TUNING_MODE_3)
+			mmc_retune_needed(host->mmc);
+
+		ret = sdhci_suspend_host(host);
 
 		if (ret)
 			goto err_pci_suspend;
 
-		slot_pm_flags = slot->host->mmc->pm_flags;
+		slot_pm_flags = host->mmc->pm_flags;
 		if (slot_pm_flags & MMC_PM_WAKE_SDIO_IRQ)
-			sdhci_enable_irq_wakeups(slot->host);
+			sdhci_enable_irq_wakeups(host);
 
 		pm_flags |= slot_pm_flags;
 	}
@@ -1737,6 +1743,7 @@ static int sdhci_pci_runtime_suspend(struct device *dev)
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct sdhci_pci_chip *chip;
 	struct sdhci_pci_slot *slot;
+	struct sdhci_host *host;
 	int i, ret;
 
 	chip = pci_get_drvdata(pdev);
@@ -1748,10 +1755,15 @@ static int sdhci_pci_runtime_suspend(struct device *dev)
 		if (!slot)
 			continue;
 
-		ret = sdhci_runtime_suspend_host(slot->host);
+		host = slot->host;
 
+		ret = sdhci_runtime_suspend_host(host);
 		if (ret)
 			goto err_pci_runtime_suspend;
+
+		if (chip->rpm_retune &&
+		    host->tuning_mode != SDHCI_TUNING_MODE_3)
+			mmc_retune_needed(host->mmc);
 	}
 
 	if (chip->fixes && chip->fixes->suspend) {
@@ -2042,6 +2054,8 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
 		chip->allow_runtime_pm = chip->fixes->allow_runtime_pm;
 	}
 	chip->num_slots = slots;
+	chip->pm_retune = true;
+	chip->rpm_retune = true;
 
 	pci_set_drvdata(pdev, chip);
 
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index 36f743464fcc..e6e916b3361e 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -97,6 +97,8 @@ struct sdhci_pci_chip {
 	unsigned int		quirks;
 	unsigned int		quirks2;
 	bool			allow_runtime_pm;
+	bool			pm_retune;
+	bool			rpm_retune;
 	const struct sdhci_pci_fixes *fixes;
 
 	int			num_slots;	/* Slots on controller */
diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index ad49bfaf5bf8..e090d8c42ddb 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -213,6 +213,9 @@ static int sdhci_pltfm_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	return sdhci_suspend_host(host);
 }
 
diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index 132670a612a0..22ed90433d29 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -527,6 +527,8 @@ static int sdhci_pxav3_suspend(struct device *dev)
 	struct sdhci_host *host = dev_get_drvdata(dev);
 
 	pm_runtime_get_sync(dev);
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
 	ret = sdhci_suspend_host(host);
 	pm_runtime_mark_last_busy(dev);
 	pm_runtime_put_autosuspend(dev);
@@ -560,6 +562,9 @@ static int sdhci_pxav3_runtime_suspend(struct device *dev)
 	if (ret)
 		return ret;
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	clk_disable_unprepare(pxa->clk_io);
 	if (!IS_ERR(pxa->clk_core))
 		clk_disable_unprepare(pxa->clk_core);
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 3e5c83d435ae..d02284da2ec6 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -743,6 +743,9 @@ static int sdhci_s3c_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	return sdhci_suspend_host(host);
 }
 
@@ -764,6 +767,9 @@ static int sdhci_s3c_runtime_suspend(struct device *dev)
 
 	ret = sdhci_runtime_suspend_host(host);
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	if (ourhost->cur_clk >= 0)
 		clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
 	clk_disable_unprepare(busclk);
diff --git a/drivers/mmc/host/sdhci-sirf.c b/drivers/mmc/host/sdhci-sirf.c
index 5d068639dd3f..c251c6c0a112 100644
--- a/drivers/mmc/host/sdhci-sirf.c
+++ b/drivers/mmc/host/sdhci-sirf.c
@@ -237,6 +237,9 @@ static int sdhci_sirf_suspend(struct device *dev)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	int ret;
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	ret = sdhci_suspend_host(host);
 	if (ret)
 		return ret;
diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
index 255a896769b8..8c0f88428556 100644
--- a/drivers/mmc/host/sdhci-spear.c
+++ b/drivers/mmc/host/sdhci-spear.c
@@ -165,6 +165,9 @@ static int sdhci_suspend(struct device *dev)
 	struct spear_sdhci *sdhci = sdhci_priv(host);
 	int ret;
 
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
+
 	ret = sdhci_suspend_host(host);
 	if (!ret)
 		clk_disable(sdhci->clk);
diff --git a/drivers/mmc/host/sdhci-st.c b/drivers/mmc/host/sdhci-st.c
index f8b3b919b947..9498c89eeae9 100644
--- a/drivers/mmc/host/sdhci-st.c
+++ b/drivers/mmc/host/sdhci-st.c
@@ -460,8 +460,12 @@ static int sdhci_st_suspend(struct device *dev)
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct st_mmc_platform_data *pdata = sdhci_pltfm_priv(pltfm_host);
-	int ret = sdhci_suspend_host(host);
+	int ret;
+
+	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
+		mmc_retune_needed(host->mmc);
 
+	ret = sdhci_suspend_host(host);
 	if (ret)
 		goto out;
 
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 642e1e4acdcf..c3c7df480a66 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2851,8 +2851,6 @@ int sdhci_suspend_host(struct sdhci_host *host)
 	sdhci_disable_card_detection(host);
 
 	mmc_retune_timer_stop(host->mmc);
-	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
-		mmc_retune_needed(host->mmc);
 
 	if (!device_may_wakeup(mmc_dev(host->mmc))) {
 		host->ier = 0;
@@ -2913,8 +2911,6 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host)
 	unsigned long flags;
 
 	mmc_retune_timer_stop(host->mmc);
-	if (host->tuning_mode != SDHCI_TUNING_MODE_3)
-		mmc_retune_needed(host->mmc);
 
 	spin_lock_irqsave(&host->lock, flags);
 	host->ier &= SDHCI_INT_CARD_INT;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 05/25] mmc: sdhci-pci: Let devices define their own private data
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (3 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 04/25] mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 06/25] mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices Adrian Hunter
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Let devices define their own private data to facilitate device-specific
operations. The size of the private structure is specified in the
sdhci_pci_fixes structure, then sdhci_pci_probe_slot() will allocate extra
space for it, and sdhci_pci_priv() can be used to get a reference to it.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-pci-core.c | 3 ++-
 drivers/mmc/host/sdhci-pci.h      | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index b7150e935fb6..84b73cb22940 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -1830,6 +1830,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 	struct sdhci_pci_slot *slot;
 	struct sdhci_host *host;
 	int ret, bar = first_bar + slotno;
+	size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0;
 
 	if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
 		dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
@@ -1851,7 +1852,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 		return ERR_PTR(-ENODEV);
 	}
 
-	host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pci_slot));
+	host = sdhci_alloc_host(&pdev->dev, sizeof(*slot) + priv_size);
 	if (IS_ERR(host)) {
 		dev_err(&pdev->dev, "cannot allocate host\n");
 		return ERR_CAST(host);
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index e6e916b3361e..cfe519c0c990 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -70,6 +70,7 @@ struct sdhci_pci_fixes {
 	int			(*resume) (struct sdhci_pci_chip *);
 
 	const struct sdhci_ops	*ops;
+	size_t			priv_size;
 };
 
 struct sdhci_pci_slot {
@@ -89,6 +90,7 @@ struct sdhci_pci_slot {
 				     struct mmc_card *card,
 				     unsigned int max_dtr, int host_drv,
 				     int card_drv, int *drv_type);
+	unsigned long		private[0] ____cacheline_aligned;
 };
 
 struct sdhci_pci_chip {
@@ -105,4 +107,9 @@ struct sdhci_pci_chip {
 	struct sdhci_pci_slot	*slots[MAX_SLOTS]; /* Pointers to host slots */
 };
 
+static inline void *sdhci_pci_priv(struct sdhci_pci_slot *slot)
+{
+	return (void *)slot->private;
+}
+
 #endif /* __SDHCI_PCI_H */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 06/25] mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (4 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 05/25] mmc: sdhci-pci: Let devices define their own private data Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 07/25] mmc: sdhci-pci: Use ACPI DSM to get driver strength " Adrian Hunter
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Make use  of an Intel ACPI _DSM that indicates if re-tuning is needed after
D3.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-pci-core.c | 90 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 84b73cb22940..3564327c9c7b 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -259,6 +259,77 @@ static int mfd_sdio_probe_slot(struct sdhci_pci_slot *slot)
 	.probe_slot	= pch_hc_probe_slot,
 };
 
+enum {
+	INTEL_DSM_FNS		=  0,
+	INTEL_DSM_D3_RETUNE	= 10,
+};
+
+struct intel_host {
+	u32	dsm_fns;
+	bool	d3_retune;
+};
+
+const u8 intel_dsm_uuid[] = {
+	0xA5, 0x3E, 0xC1, 0xF6, 0xCD, 0x65, 0x1F, 0x46,
+	0xAB, 0x7A, 0x29, 0xF7, 0xE8, 0xD5, 0xBD, 0x61,
+};
+
+static int __intel_dsm(struct intel_host *intel_host, struct device *dev,
+		       unsigned int fn, u32 *result)
+{
+	union acpi_object *obj;
+	int err = 0;
+
+	obj = acpi_evaluate_dsm(ACPI_HANDLE(dev), intel_dsm_uuid, 0, fn, NULL);
+	if (!obj)
+		return -EOPNOTSUPP;
+
+	if (obj->type != ACPI_TYPE_BUFFER || obj->buffer.length < 1) {
+		err = -EINVAL;
+		goto out;
+	}
+
+	if (obj->buffer.length >= 4)
+		*result = *(u32 *)obj->buffer.pointer;
+	else if (obj->buffer.length >= 2)
+		*result = *(u16 *)obj->buffer.pointer;
+	else
+		*result = *(u8 *)obj->buffer.pointer;
+out:
+	ACPI_FREE(obj);
+
+	return err;
+}
+
+static int intel_dsm(struct intel_host *intel_host, struct device *dev,
+		     unsigned int fn, u32 *result)
+{
+	if (fn > 31 || !(intel_host->dsm_fns & (1 << fn)))
+		return -EOPNOTSUPP;
+
+	return __intel_dsm(intel_host, dev, fn, result);
+}
+
+static void intel_dsm_init(struct intel_host *intel_host, struct device *dev,
+			   struct mmc_host *mmc)
+{
+	int err;
+	u32 val;
+
+	err = __intel_dsm(intel_host, dev, INTEL_DSM_FNS, &intel_host->dsm_fns);
+	if (err) {
+		pr_debug("%s: DSM not supported, error %d\n",
+			 mmc_hostname(mmc), err);
+		return;
+	}
+
+	pr_debug("%s: DSM function mask %#x\n",
+		 mmc_hostname(mmc), intel_host->dsm_fns);
+
+	err = intel_dsm(intel_host, dev, INTEL_DSM_D3_RETUNE, &val);
+	intel_host->d3_retune = err ? true : !!val;
+}
+
 static void sdhci_pci_int_hw_reset(struct sdhci_host *host)
 {
 	u8 reg;
@@ -359,8 +430,19 @@ static int bxt_get_cd(struct mmc_host *mmc)
 	return ret;
 }
 
+static void byt_read_dsm(struct sdhci_pci_slot *slot)
+{
+	struct intel_host *intel_host = sdhci_pci_priv(slot);
+	struct device *dev = &slot->chip->pdev->dev;
+	struct mmc_host *mmc = slot->host->mmc;
+
+	intel_dsm_init(intel_host, dev, mmc);
+	slot->chip->rpm_retune = intel_host->d3_retune;
+}
+
 static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
 {
+	byt_read_dsm(slot);
 	slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE |
 				 MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR |
 				 MMC_CAP_CMD_DURING_TFR |
@@ -405,6 +487,8 @@ static int ni_byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
 {
 	int err;
 
+	byt_read_dsm(slot);
+
 	err = ni_set_max_freq(slot);
 	if (err)
 		return err;
@@ -416,6 +500,7 @@ static int ni_byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
 
 static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
 {
+	byt_read_dsm(slot);
 	slot->host->mmc->caps |= MMC_CAP_POWER_OFF_CARD | MMC_CAP_NONREMOVABLE |
 				 MMC_CAP_WAIT_WHILE_BUSY;
 	return 0;
@@ -423,6 +508,7 @@ static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot)
 
 static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
 {
+	byt_read_dsm(slot);
 	slot->host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
 	slot->cd_idx = 0;
 	slot->cd_override_level = true;
@@ -488,6 +574,7 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 			  SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 |
 			  SDHCI_QUIRK2_STOP_WITH_TC,
 	.ops		= &sdhci_intel_byt_ops,
+	.priv_size	= sizeof(struct intel_host),
 };
 
 static const struct sdhci_pci_fixes sdhci_ni_byt_sdio = {
@@ -497,6 +584,7 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 	.allow_runtime_pm = true,
 	.probe_slot	= ni_byt_sdio_probe_slot,
 	.ops		= &sdhci_intel_byt_ops,
+	.priv_size	= sizeof(struct intel_host),
 };
 
 static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = {
@@ -506,6 +594,7 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 	.allow_runtime_pm = true,
 	.probe_slot	= byt_sdio_probe_slot,
 	.ops		= &sdhci_intel_byt_ops,
+	.priv_size	= sizeof(struct intel_host),
 };
 
 static const struct sdhci_pci_fixes sdhci_intel_byt_sd = {
@@ -517,6 +606,7 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 	.own_cd_for_runtime_pm = true,
 	.probe_slot	= byt_sd_probe_slot,
 	.ops		= &sdhci_intel_byt_ops,
+	.priv_size	= sizeof(struct intel_host),
 };
 
 /* Define Host controllers for Intel Merrifield platform */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 07/25] mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (5 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 06/25] mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-04-04  8:48   ` Wolfram Sang
  2017-03-20 17:50 ` [PATCH 08/25] mmc: sdhci: Remove ->select_drive_strength() callback Adrian Hunter
                   ` (20 subsequent siblings)
  27 siblings, 1 reply; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Make use  of an Intel ACPI _DSM that provides eMMC driver strength.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-pci-core.c | 77 +++++++--------------------------------
 drivers/mmc/host/sdhci-pci-data.c |  3 --
 2 files changed, 14 insertions(+), 66 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 3564327c9c7b..351920f4ec42 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -261,11 +261,13 @@ static int mfd_sdio_probe_slot(struct sdhci_pci_slot *slot)
 
 enum {
 	INTEL_DSM_FNS		=  0,
+	INTEL_DSM_DRV_STRENGTH	=  9,
 	INTEL_DSM_D3_RETUNE	= 10,
 };
 
 struct intel_host {
 	u32	dsm_fns;
+	int	drv_strength;
 	bool	d3_retune;
 };
 
@@ -326,6 +328,9 @@ static void intel_dsm_init(struct intel_host *intel_host, struct device *dev,
 	pr_debug("%s: DSM function mask %#x\n",
 		 mmc_hostname(mmc), intel_host->dsm_fns);
 
+	err = intel_dsm(intel_host, dev, INTEL_DSM_DRV_STRENGTH, &val);
+	intel_host->drv_strength = err ? 0 : val;
+
 	err = intel_dsm(intel_host, dev, INTEL_DSM_D3_RETUNE, &val);
 	intel_host->d3_retune = err ? true : !!val;
 }
@@ -345,67 +350,15 @@ static void sdhci_pci_int_hw_reset(struct sdhci_host *host)
 	usleep_range(300, 1000);
 }
 
-static int spt_select_drive_strength(struct sdhci_host *host,
-				     struct mmc_card *card,
-				     unsigned int max_dtr,
-				     int host_drv, int card_drv, int *drv_type)
+static int intel_select_drive_strength(struct mmc_card *card,
+				       unsigned int max_dtr, int host_drv,
+				       int card_drv, int *drv_type)
 {
-	int drive_strength;
-
-	if (sdhci_pci_spt_drive_strength > 0)
-		drive_strength = sdhci_pci_spt_drive_strength & 0xf;
-	else
-		drive_strength = 0; /* Default 50-ohm */
-
-	if ((mmc_driver_type_mask(drive_strength) & card_drv) == 0)
-		drive_strength = 0; /* Default 50-ohm */
-
-	return drive_strength;
-}
-
-/* Try to read the drive strength from the card */
-static void spt_read_drive_strength(struct sdhci_host *host)
-{
-	u32 val, i, t;
-	u16 m;
-
-	if (sdhci_pci_spt_drive_strength)
-		return;
-
-	sdhci_pci_spt_drive_strength = -1;
-
-	m = sdhci_readw(host, SDHCI_HOST_CONTROL2) & 0x7;
-	if (m != 3 && m != 5)
-		return;
-	val = sdhci_readl(host, SDHCI_PRESENT_STATE);
-	if (val & 0x3)
-		return;
-	sdhci_writel(host, 0x007f0023, SDHCI_INT_ENABLE);
-	sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE);
-	sdhci_writew(host, 0x10, SDHCI_TRANSFER_MODE);
-	sdhci_writeb(host, 0xe, SDHCI_TIMEOUT_CONTROL);
-	sdhci_writew(host, 512, SDHCI_BLOCK_SIZE);
-	sdhci_writew(host, 1, SDHCI_BLOCK_COUNT);
-	sdhci_writel(host, 0, SDHCI_ARGUMENT);
-	sdhci_writew(host, 0x83b, SDHCI_COMMAND);
-	for (i = 0; i < 1000; i++) {
-		val = sdhci_readl(host, SDHCI_INT_STATUS);
-		if (val & 0xffff8000)
-			return;
-		if (val & 0x20)
-			break;
-		udelay(1);
-	}
-	val = sdhci_readl(host, SDHCI_PRESENT_STATE);
-	if (!(val & 0x800))
-		return;
-	for (i = 0; i < 47; i++)
-		val = sdhci_readl(host, SDHCI_BUFFER);
-	t = val & 0xf00;
-	if (t != 0x200 && t != 0x300)
-		return;
+	struct sdhci_host *host = mmc_priv(card->host);
+	struct sdhci_pci_slot *slot = sdhci_priv(host);
+	struct intel_host *intel_host = sdhci_pci_priv(slot);
 
-	sdhci_pci_spt_drive_strength = 0x10 | ((val >> 12) & 0xf);
+	return intel_host->drv_strength;
 }
 
 static int bxt_get_cd(struct mmc_host *mmc)
@@ -451,10 +404,8 @@ static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
 	slot->hw_reset = sdhci_pci_int_hw_reset;
 	if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BSW_EMMC)
 		slot->host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */
-	if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_SPT_EMMC) {
-		spt_read_drive_strength(slot->host);
-		slot->select_drive_strength = spt_select_drive_strength;
-	}
+	slot->host->mmc_host_ops.select_drive_strength =
+						intel_select_drive_strength;
 	return 0;
 }
 
diff --git a/drivers/mmc/host/sdhci-pci-data.c b/drivers/mmc/host/sdhci-pci-data.c
index 56fddc622a54..a611217769f5 100644
--- a/drivers/mmc/host/sdhci-pci-data.c
+++ b/drivers/mmc/host/sdhci-pci-data.c
@@ -3,6 +3,3 @@
 
 struct sdhci_pci_data *(*sdhci_pci_get_data)(struct pci_dev *pdev, int slotno);
 EXPORT_SYMBOL_GPL(sdhci_pci_get_data);
-
-int sdhci_pci_spt_drive_strength;
-EXPORT_SYMBOL_GPL(sdhci_pci_spt_drive_strength);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 08/25] mmc: sdhci: Remove ->select_drive_strength() callback
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (6 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 07/25] mmc: sdhci-pci: Use ACPI DSM to get driver strength " Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 09/25] mmc: sdhci: Do not use spin lock in set_ios paths Adrian Hunter
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Drivers can use the host operation directly, so remove this now unused
callback.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-pci-core.c | 20 --------------------
 drivers/mmc/host/sdhci-pci.h      |  4 ----
 drivers/mmc/host/sdhci.c          | 14 --------------
 drivers/mmc/host/sdhci.h          |  4 ----
 4 files changed, 42 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 351920f4ec42..5c620206138e 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -36,10 +36,6 @@
 static int sdhci_pci_enable_dma(struct sdhci_host *host);
 static void sdhci_pci_set_bus_width(struct sdhci_host *host, int width);
 static void sdhci_pci_hw_reset(struct sdhci_host *host);
-static int sdhci_pci_select_drive_strength(struct sdhci_host *host,
-					   struct mmc_card *card,
-					   unsigned int max_dtr, int host_drv,
-					   int card_drv, int *drv_type);
 
 /*****************************************************************************\
  *                                                                           *
@@ -514,7 +510,6 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 	.reset			= sdhci_reset,
 	.set_uhs_signaling	= sdhci_set_uhs_signaling,
 	.hw_reset		= sdhci_pci_hw_reset,
-	.select_drive_strength	= sdhci_pci_select_drive_strength,
 };
 
 static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = {
@@ -1658,20 +1653,6 @@ static void sdhci_pci_hw_reset(struct sdhci_host *host)
 		slot->hw_reset(host);
 }
 
-static int sdhci_pci_select_drive_strength(struct sdhci_host *host,
-					   struct mmc_card *card,
-					   unsigned int max_dtr, int host_drv,
-					   int card_drv, int *drv_type)
-{
-	struct sdhci_pci_slot *slot = sdhci_priv(host);
-
-	if (!slot->select_drive_strength)
-		return 0;
-
-	return slot->select_drive_strength(host, card, max_dtr, host_drv,
-					   card_drv, drv_type);
-}
-
 static const struct sdhci_ops sdhci_pci_ops = {
 	.set_clock	= sdhci_set_clock,
 	.enable_dma	= sdhci_pci_enable_dma,
@@ -1679,7 +1660,6 @@ static int sdhci_pci_select_drive_strength(struct sdhci_host *host,
 	.reset		= sdhci_reset,
 	.set_uhs_signaling = sdhci_set_uhs_signaling,
 	.hw_reset		= sdhci_pci_hw_reset,
-	.select_drive_strength	= sdhci_pci_select_drive_strength,
 };
 
 /*****************************************************************************\
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index cfe519c0c990..da7b95016c6f 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -86,10 +86,6 @@ struct sdhci_pci_slot {
 	bool			cd_override_level;
 
 	void (*hw_reset)(struct sdhci_host *host);
-	int (*select_drive_strength)(struct sdhci_host *host,
-				     struct mmc_card *card,
-				     unsigned int max_dtr, int host_drv,
-				     int card_drv, int *drv_type);
 	unsigned long		private[0] ____cacheline_aligned;
 };
 
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c3c7df480a66..cb235cb74948 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2176,19 +2176,6 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
 }
 EXPORT_SYMBOL_GPL(sdhci_execute_tuning);
 
-static int sdhci_select_drive_strength(struct mmc_card *card,
-				       unsigned int max_dtr, int host_drv,
-				       int card_drv, int *drv_type)
-{
-	struct sdhci_host *host = mmc_priv(card->host);
-
-	if (!host->ops->select_drive_strength)
-		return 0;
-
-	return host->ops->select_drive_strength(host, card, max_dtr, host_drv,
-						card_drv, drv_type);
-}
-
 static void sdhci_enable_preset_value(struct sdhci_host *host, bool enable)
 {
 	/* Host Controller v3.00 defines preset value registers */
@@ -2302,7 +2289,6 @@ static void sdhci_card_event(struct mmc_host *mmc)
 	.start_signal_voltage_switch	= sdhci_start_signal_voltage_switch,
 	.prepare_hs400_tuning		= sdhci_prepare_hs400_tuning,
 	.execute_tuning			= sdhci_execute_tuning,
-	.select_drive_strength		= sdhci_select_drive_strength,
 	.card_event			= sdhci_card_event,
 	.card_busy	= sdhci_card_busy,
 };
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index edf3adfbc213..67772674da90 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -562,10 +562,6 @@ struct sdhci_ops {
 	void    (*adma_workaround)(struct sdhci_host *host, u32 intmask);
 	void    (*card_event)(struct sdhci_host *host);
 	void	(*voltage_switch)(struct sdhci_host *host);
-	int	(*select_drive_strength)(struct sdhci_host *host,
-					 struct mmc_card *card,
-					 unsigned int max_dtr, int host_drv,
-					 int card_drv, int *drv_type);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 09/25] mmc: sdhci: Do not use spin lock in set_ios paths
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (7 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 08/25] mmc: sdhci: Remove ->select_drive_strength() callback Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 10/25] mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning Adrian Hunter
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

The spin lock is not necessary in set_ios. Anything that is racing with
changes to the I/O state is already broken. The mmc core already provides
synchronization via "claiming" the host. So remove spin_lock and friends
from sdhci_set_ios and related callbacks.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-msm.c       | 8 --------
 drivers/mmc/host/sdhci-of-arasan.c | 6 ------
 drivers/mmc/host/sdhci-of-at91.c   | 2 --
 drivers/mmc/host/sdhci-pci-core.c  | 4 ----
 drivers/mmc/host/sdhci-pxav3.c     | 5 +----
 drivers/mmc/host/sdhci-s3c.c       | 4 ----
 drivers/mmc/host/sdhci.c           | 9 ---------
 7 files changed, 1 insertion(+), 37 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 10cdc84d5113..9d601dc0d646 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -991,12 +991,8 @@ static void sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
 		mmc_hostname(host->mmc), host->clock, uhs, ctrl_2);
 	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
 
-	spin_unlock_irq(&host->lock);
-
 	if (mmc->ios.timing == MMC_TIMING_MMC_HS400)
 		sdhci_msm_hs400(host, &mmc->ios);
-
-	spin_lock_irq(&host->lock);
 }
 
 static void sdhci_msm_voltage_switch(struct sdhci_host *host)
@@ -1089,13 +1085,9 @@ static void sdhci_msm_set_clock(struct sdhci_host *host, unsigned int clock)
 		goto out;
 	}
 
-	spin_unlock_irq(&host->lock);
-
 	sdhci_msm_hc_select_mode(host);
 
 	msm_set_clock_rate_for_bus_mode(host, clock);
-
-	spin_lock_irq(&host->lock);
 out:
 	__sdhci_msm_set_clock(host, clock);
 }
diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index 28feb5367c14..61accf0d4739 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -194,9 +194,7 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
 			 * through low speeds without power cycling.
 			 */
 			sdhci_set_clock(host, host->max_clk);
-			spin_unlock_irq(&host->lock);
 			phy_power_on(sdhci_arasan->phy);
-			spin_lock_irq(&host->lock);
 			sdhci_arasan->is_phy_on = true;
 
 			/*
@@ -215,18 +213,14 @@ static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
 	}
 
 	if (ctrl_phy && sdhci_arasan->is_phy_on) {
-		spin_unlock_irq(&host->lock);
 		phy_power_off(sdhci_arasan->phy);
-		spin_lock_irq(&host->lock);
 		sdhci_arasan->is_phy_on = false;
 	}
 
 	sdhci_set_clock(host, clock);
 
 	if (ctrl_phy) {
-		spin_unlock_irq(&host->lock);
 		phy_power_on(sdhci_arasan->phy);
-		spin_lock_irq(&host->lock);
 		sdhci_arasan->is_phy_on = true;
 	}
 }
diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
index ce4ae21d5947..814571fec0e2 100644
--- a/drivers/mmc/host/sdhci-of-at91.c
+++ b/drivers/mmc/host/sdhci-of-at91.c
@@ -96,9 +96,7 @@ static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode,
 	if (!IS_ERR(host->mmc->supply.vmmc)) {
 		struct mmc_host *mmc = host->mmc;
 
-		spin_unlock_irq(&host->lock);
 		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
-		spin_lock_irq(&host->lock);
 	}
 	sdhci_set_power_noreg(host, mode, vdd);
 }
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 5c620206138e..98ed90cbd9b4 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -484,8 +484,6 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 	if (mode == MMC_POWER_OFF)
 		return;
 
-	spin_unlock_irq(&host->lock);
-
 	/*
 	 * Bus power might not enable after D3 -> D0 transition due to the
 	 * present state not yet having propagated. Retry for up to 2ms.
@@ -498,8 +496,6 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 		reg |= SDHCI_POWER_ON;
 		sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
 	}
-
-	spin_lock_irq(&host->lock);
 }
 
 static const struct sdhci_ops sdhci_intel_byt_ops = {
diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index 22ed90433d29..f953f35c2624 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -323,11 +323,8 @@ static void pxav3_set_power(struct sdhci_host *host, unsigned char mode,
 	if (host->pwr == 0)
 		vdd = 0;
 
-	if (!IS_ERR(mmc->supply.vmmc)) {
-		spin_unlock_irq(&host->lock);
+	if (!IS_ERR(mmc->supply.vmmc))
 		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
-		spin_lock_irq(&host->lock);
-	}
 }
 
 static const struct sdhci_ops pxav3_sdhci_ops = {
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index d02284da2ec6..7c065a70f92b 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -190,9 +190,7 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
 	 * speed possible with selected clock source and skip the division.
 	 */
 	if (ourhost->no_divider) {
-		spin_unlock_irq(&ourhost->host->lock);
 		rate = clk_round_rate(clksrc, wanted);
-		spin_lock_irq(&ourhost->host->lock);
 		return wanted - rate;
 	}
 
@@ -389,9 +387,7 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
 	clk &= ~SDHCI_CLOCK_CARD_EN;
 	sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
 
-	spin_unlock_irq(&host->lock);
 	ret = clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
-	spin_lock_irq(&host->lock);
 	if (ret != 0) {
 		dev_err(dev, "%s: failed to set clock rate %uHz\n",
 			mmc_hostname(host->mmc), clock);
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index cb235cb74948..f7dfb40826c7 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1361,9 +1361,7 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk)
 			sdhci_dumpregs(host);
 			return;
 		}
-		spin_unlock_irq(&host->lock);
 		udelay(10);
-		spin_lock_irq(&host->lock);
 	}
 
 	clk |= SDHCI_CLOCK_CARD_EN;
@@ -1392,9 +1390,7 @@ static void sdhci_set_power_reg(struct sdhci_host *host, unsigned char mode,
 {
 	struct mmc_host *mmc = host->mmc;
 
-	spin_unlock_irq(&host->lock);
 	mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
-	spin_lock_irq(&host->lock);
 
 	if (mode != MMC_POWER_OFF)
 		sdhci_writeb(host, SDHCI_POWER_ON, SDHCI_POWER_CONTROL);
@@ -1574,16 +1570,12 @@ void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
 static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct sdhci_host *host = mmc_priv(mmc);
-	unsigned long flags;
 	u8 ctrl;
 
 	if (ios->power_mode == MMC_POWER_UNDEFINED)
 		return;
 
-	spin_lock_irqsave(&host->lock, flags);
-
 	if (host->flags & SDHCI_DEVICE_DEAD) {
-		spin_unlock_irqrestore(&host->lock, flags);
 		if (!IS_ERR(mmc->supply.vmmc) &&
 		    ios->power_mode == MMC_POWER_OFF)
 			mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
@@ -1729,7 +1721,6 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
 
 	mmiowb();
-	spin_unlock_irqrestore(&host->lock, flags);
 }
 
 static int sdhci_get_cd(struct mmc_host *mmc)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 10/25] mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (8 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 09/25] mmc: sdhci: Do not use spin lock in set_ios paths Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 11/25] mmc: sdhci: Improve debug print format Adrian Hunter
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Tuning execution is already synchronized with respect to other host
operations by upper layers "claiming" the host, which also takes care of
runtime pm. There can be no requests in progress. Retain the spin lock
usage only for ensuring that sending tuning commands is synchronized with
respect to the interrupt handler.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index f7dfb40826c7..fffd2efd703e 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1987,8 +1987,7 @@ static void sdhci_reset_tuning(struct sdhci_host *host)
 	sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
 }
 
-static void sdhci_abort_tuning(struct sdhci_host *host, u32 opcode,
-			       unsigned long flags)
+static void sdhci_abort_tuning(struct sdhci_host *host, u32 opcode)
 {
 	sdhci_reset_tuning(host);
 
@@ -1997,9 +1996,7 @@ static void sdhci_abort_tuning(struct sdhci_host *host, u32 opcode,
 
 	sdhci_end_tuning(host);
 
-	spin_unlock_irqrestore(&host->lock, flags);
 	mmc_abort_tuning(host->mmc, opcode);
-	spin_lock_irqsave(&host->lock, flags);
 }
 
 /*
@@ -2009,12 +2006,14 @@ static void sdhci_abort_tuning(struct sdhci_host *host, u32 opcode,
  * interrupt setup is different to other commands and there is no timeout
  * interrupt so special handling is needed.
  */
-static void sdhci_send_tuning(struct sdhci_host *host, u32 opcode,
-			      unsigned long flags)
+static void sdhci_send_tuning(struct sdhci_host *host, u32 opcode)
 {
 	struct mmc_host *mmc = host->mmc;
 	struct mmc_command cmd = {};
 	struct mmc_request mrq = {};
+	unsigned long flags;
+
+	spin_lock_irqsave(&host->lock, flags);
 
 	cmd.opcode = opcode;
 	cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
@@ -2048,17 +2047,16 @@ static void sdhci_send_tuning(struct sdhci_host *host, u32 opcode,
 
 	host->tuning_done = 0;
 
+	mmiowb();
 	spin_unlock_irqrestore(&host->lock, flags);
 
 	/* Wait for Buffer Read Ready interrupt */
 	wait_event_timeout(host->buf_ready_int, (host->tuning_done == 1),
 			   msecs_to_jiffies(50));
 
-	spin_lock_irqsave(&host->lock, flags);
 }
 
-static void __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode,
-				   unsigned long flags)
+static void __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
 {
 	int i;
 
@@ -2069,12 +2067,12 @@ static void __sdhci_execute_tuning(struct sdhci_host *host, u32 opcode,
 	for (i = 0; i < MAX_TUNING_LOOP; i++) {
 		u16 ctrl;
 
-		sdhci_send_tuning(host, opcode, flags);
+		sdhci_send_tuning(host, opcode);
 
 		if (!host->tuning_done) {
 			pr_info("%s: Tuning timeout, falling back to fixed sampling clock\n",
 				mmc_hostname(host->mmc));
-			sdhci_abort_tuning(host, opcode, flags);
+			sdhci_abort_tuning(host, opcode);
 			return;
 		}
 
@@ -2099,12 +2097,9 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
 {
 	struct sdhci_host *host = mmc_priv(mmc);
 	int err = 0;
-	unsigned long flags;
 	unsigned int tuning_count = 0;
 	bool hs400_tuning;
 
-	spin_lock_irqsave(&host->lock, flags);
-
 	hs400_tuning = host->flags & SDHCI_HS400_TUNING;
 
 	if (host->tuning_mode == SDHCI_TUNING_MODE_1)
@@ -2121,7 +2116,7 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	/* HS400 tuning is done in HS200 mode */
 	case MMC_TIMING_MMC_HS400:
 		err = -EINVAL;
-		goto out_unlock;
+		goto out;
 
 	case MMC_TIMING_MMC_HS200:
 		/*
@@ -2142,26 +2137,23 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
 		/* FALLTHROUGH */
 
 	default:
-		goto out_unlock;
+		goto out;
 	}
 
 	if (host->ops->platform_execute_tuning) {
-		spin_unlock_irqrestore(&host->lock, flags);
 		err = host->ops->platform_execute_tuning(host, opcode);
-		spin_lock_irqsave(&host->lock, flags);
-		goto out_unlock;
+		goto out;
 	}
 
 	host->mmc->retune_period = tuning_count;
 
 	sdhci_start_tuning(host);
 
-	__sdhci_execute_tuning(host, opcode, flags);
+	__sdhci_execute_tuning(host, opcode);
 
 	sdhci_end_tuning(host);
-out_unlock:
+out:
 	host->flags &= ~SDHCI_HS400_TUNING;
-	spin_unlock_irqrestore(&host->lock, flags);
 
 	return err;
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 11/25] mmc: sdhci: Improve debug print format
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (9 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 10/25] mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 12/25] mmc: sdhci: Add response register to register dump Adrian Hunter
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Ensure all debug prints start with the mmc host name.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index fffd2efd703e..56be77c2044e 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -38,7 +38,7 @@
 #define DRIVER_NAME "sdhci"
 
 #define DBG(f, x...) \
-	pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x)
+	pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
 
 #define MAX_TUNING_LOOP 40
 
@@ -715,8 +715,8 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
 	}
 
 	if (count >= 0xF) {
-		DBG("%s: Too large timeout 0x%x requested for CMD%d!\n",
-		    mmc_hostname(host->mmc), count, cmd->opcode);
+		DBG("Too large timeout 0x%x requested for CMD%d!\n",
+		    count, cmd->opcode);
 		count = 0xE;
 	}
 
@@ -2479,7 +2479,6 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
 #ifdef CONFIG_MMC_DEBUG
 static void sdhci_adma_show_error(struct sdhci_host *host)
 {
-	const char *name = mmc_hostname(host->mmc);
 	void *desc = host->adma_table;
 
 	sdhci_dumpregs(host);
@@ -2488,14 +2487,14 @@ static void sdhci_adma_show_error(struct sdhci_host *host)
 		struct sdhci_adma2_64_desc *dma_desc = desc;
 
 		if (host->flags & SDHCI_USE_64_BIT_DMA)
-			DBG("%s: %p: DMA 0x%08x%08x, LEN 0x%04x, Attr=0x%02x\n",
-			    name, desc, le32_to_cpu(dma_desc->addr_hi),
+			DBG("%p: DMA 0x%08x%08x, LEN 0x%04x, Attr=0x%02x\n",
+			    desc, le32_to_cpu(dma_desc->addr_hi),
 			    le32_to_cpu(dma_desc->addr_lo),
 			    le16_to_cpu(dma_desc->len),
 			    le16_to_cpu(dma_desc->cmd));
 		else
-			DBG("%s: %p: DMA 0x%08x, LEN 0x%04x, Attr=0x%02x\n",
-			    name, desc, le32_to_cpu(dma_desc->addr_lo),
+			DBG("%p: DMA 0x%08x, LEN 0x%04x, Attr=0x%02x\n",
+			    desc, le32_to_cpu(dma_desc->addr_lo),
 			    le16_to_cpu(dma_desc->len),
 			    le16_to_cpu(dma_desc->cmd));
 
@@ -2611,10 +2610,8 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
 				~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1)) +
 				SDHCI_DEFAULT_BOUNDARY_SIZE;
 			host->data->bytes_xfered = dmanow - dmastart;
-			DBG("%s: DMA base 0x%08x, transferred 0x%06x bytes,"
-				" next 0x%08x\n",
-				mmc_hostname(host->mmc), dmastart,
-				host->data->bytes_xfered, dmanow);
+			DBG("DMA base 0x%08x, transferred 0x%06x bytes, next 0x%08x\n",
+			    dmastart, host->data->bytes_xfered, dmanow);
 			sdhci_writel(host, dmanow, SDHCI_DMA_ADDRESS);
 		}
 
@@ -2659,8 +2656,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
 				  SDHCI_INT_BUS_POWER);
 		sdhci_writel(host, mask, SDHCI_INT_STATUS);
 
-		DBG("*** %s got interrupt: 0x%08x\n",
-			mmc_hostname(host->mmc), intmask);
+		DBG("IRQ status 0x%08x\n", intmask);
 
 		if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) {
 			u32 present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
@@ -3290,9 +3286,9 @@ int sdhci_setup_host(struct sdhci_host *host)
 	     !(host->flags & SDHCI_USE_SDMA)) &&
 	     !(host->quirks2 & SDHCI_QUIRK2_ACMD23_BROKEN)) {
 		host->flags |= SDHCI_AUTO_CMD23;
-		DBG("%s: Auto-CMD23 available\n", mmc_hostname(mmc));
+		DBG("Auto-CMD23 available\n");
 	} else {
-		DBG("%s: Auto-CMD23 unavailable\n", mmc_hostname(mmc));
+		DBG("Auto-CMD23 unavailable\n");
 	}
 
 	/*
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 12/25] mmc: sdhci: Add response register to register dump
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (10 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 11/25] mmc: sdhci: Improve debug print format Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 13/25] mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs() Adrian Hunter
                   ` (15 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Add response register to register dump.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 56be77c2044e..40f69ae51adf 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -87,6 +87,13 @@ static void sdhci_dumpregs(struct sdhci_host *host)
 	pr_err(DRIVER_NAME ": Cmd:      0x%08x | Max curr: 0x%08x\n",
 	       sdhci_readw(host, SDHCI_COMMAND),
 	       sdhci_readl(host, SDHCI_MAX_CURRENT));
+	pr_err(DRIVER_NAME ": Resp[0]:  0x%08x | Resp[1]:  0x%08x\n",
+		   sdhci_readl(host, SDHCI_RESPONSE),
+		   sdhci_readl(host, SDHCI_RESPONSE + 4));
+	pr_err(DRIVER_NAME ": Resp[2]:  0x%08x | Resp[3]:  0x%08x\n",
+		   sdhci_readl(host, SDHCI_RESPONSE + 8),
+		   sdhci_readl(host, SDHCI_RESPONSE + 12));
+
 	pr_err(DRIVER_NAME ": Host ctl2: 0x%08x\n",
 	       sdhci_readw(host, SDHCI_HOST_CONTROL2));
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 13/25] mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs()
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (11 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 12/25] mmc: sdhci: Add response register to register dump Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 14/25] mmc: sdhci: Improve register dump print format Adrian Hunter
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Use sdhci io wrappers consistently.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 40f69ae51adf..93730a3013ff 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -100,13 +100,13 @@ static void sdhci_dumpregs(struct sdhci_host *host)
 	if (host->flags & SDHCI_USE_ADMA) {
 		if (host->flags & SDHCI_USE_64_BIT_DMA)
 			pr_err(DRIVER_NAME ": ADMA Err: 0x%08x | ADMA Ptr: 0x%08x%08x\n",
-			       readl(host->ioaddr + SDHCI_ADMA_ERROR),
-			       readl(host->ioaddr + SDHCI_ADMA_ADDRESS_HI),
-			       readl(host->ioaddr + SDHCI_ADMA_ADDRESS));
+			       sdhci_readl(host, SDHCI_ADMA_ERROR),
+			       sdhci_readl(host, SDHCI_ADMA_ADDRESS_HI),
+			       sdhci_readl(host, SDHCI_ADMA_ADDRESS));
 		else
 			pr_err(DRIVER_NAME ": ADMA Err: 0x%08x | ADMA Ptr: 0x%08x\n",
-			       readl(host->ioaddr + SDHCI_ADMA_ERROR),
-			       readl(host->ioaddr + SDHCI_ADMA_ADDRESS));
+			       sdhci_readl(host, SDHCI_ADMA_ERROR),
+			       sdhci_readl(host, SDHCI_ADMA_ADDRESS));
 	}
 
 	pr_err(DRIVER_NAME ": ===========================================\n");
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 14/25] mmc: sdhci: Improve register dump print format
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (12 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 13/25] mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs() Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 15/25] mmc: sdhci: Export sdhci_dumpregs Adrian Hunter
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Ensure all prints start with the mmc host name, and the text all lines up.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 104 ++++++++++++++++++++++++-----------------------
 1 file changed, 53 insertions(+), 51 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 93730a3013ff..70022a0c886a 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -40,6 +40,9 @@
 #define DBG(f, x...) \
 	pr_debug("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
 
+#define SDHCI_DUMP(f, x...) \
+	pr_err("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x)
+
 #define MAX_TUNING_LOOP 40
 
 static unsigned int debug_quirks = 0;
@@ -51,65 +54,64 @@
 
 static void sdhci_dumpregs(struct sdhci_host *host)
 {
-	pr_err(DRIVER_NAME ": =========== REGISTER DUMP (%s)===========\n",
-	       mmc_hostname(host->mmc));
-
-	pr_err(DRIVER_NAME ": Sys addr: 0x%08x | Version:  0x%08x\n",
-	       sdhci_readl(host, SDHCI_DMA_ADDRESS),
-	       sdhci_readw(host, SDHCI_HOST_VERSION));
-	pr_err(DRIVER_NAME ": Blk size: 0x%08x | Blk cnt:  0x%08x\n",
-	       sdhci_readw(host, SDHCI_BLOCK_SIZE),
-	       sdhci_readw(host, SDHCI_BLOCK_COUNT));
-	pr_err(DRIVER_NAME ": Argument: 0x%08x | Trn mode: 0x%08x\n",
-	       sdhci_readl(host, SDHCI_ARGUMENT),
-	       sdhci_readw(host, SDHCI_TRANSFER_MODE));
-	pr_err(DRIVER_NAME ": Present:  0x%08x | Host ctl: 0x%08x\n",
-	       sdhci_readl(host, SDHCI_PRESENT_STATE),
-	       sdhci_readb(host, SDHCI_HOST_CONTROL));
-	pr_err(DRIVER_NAME ": Power:    0x%08x | Blk gap:  0x%08x\n",
-	       sdhci_readb(host, SDHCI_POWER_CONTROL),
-	       sdhci_readb(host, SDHCI_BLOCK_GAP_CONTROL));
-	pr_err(DRIVER_NAME ": Wake-up:  0x%08x | Clock:    0x%08x\n",
-	       sdhci_readb(host, SDHCI_WAKE_UP_CONTROL),
-	       sdhci_readw(host, SDHCI_CLOCK_CONTROL));
-	pr_err(DRIVER_NAME ": Timeout:  0x%08x | Int stat: 0x%08x\n",
-	       sdhci_readb(host, SDHCI_TIMEOUT_CONTROL),
-	       sdhci_readl(host, SDHCI_INT_STATUS));
-	pr_err(DRIVER_NAME ": Int enab: 0x%08x | Sig enab: 0x%08x\n",
-	       sdhci_readl(host, SDHCI_INT_ENABLE),
-	       sdhci_readl(host, SDHCI_SIGNAL_ENABLE));
-	pr_err(DRIVER_NAME ": AC12 err: 0x%08x | Slot int: 0x%08x\n",
-	       sdhci_readw(host, SDHCI_ACMD12_ERR),
-	       sdhci_readw(host, SDHCI_SLOT_INT_STATUS));
-	pr_err(DRIVER_NAME ": Caps:     0x%08x | Caps_1:   0x%08x\n",
-	       sdhci_readl(host, SDHCI_CAPABILITIES),
-	       sdhci_readl(host, SDHCI_CAPABILITIES_1));
-	pr_err(DRIVER_NAME ": Cmd:      0x%08x | Max curr: 0x%08x\n",
-	       sdhci_readw(host, SDHCI_COMMAND),
-	       sdhci_readl(host, SDHCI_MAX_CURRENT));
-	pr_err(DRIVER_NAME ": Resp[0]:  0x%08x | Resp[1]:  0x%08x\n",
+	SDHCI_DUMP("============ SDHCI REGISTER DUMP ===========\n");
+
+	SDHCI_DUMP("Sys addr:  0x%08x | Version:  0x%08x\n",
+		   sdhci_readl(host, SDHCI_DMA_ADDRESS),
+		   sdhci_readw(host, SDHCI_HOST_VERSION));
+	SDHCI_DUMP("Blk size:  0x%08x | Blk cnt:  0x%08x\n",
+		   sdhci_readw(host, SDHCI_BLOCK_SIZE),
+		   sdhci_readw(host, SDHCI_BLOCK_COUNT));
+	SDHCI_DUMP("Argument:  0x%08x | Trn mode: 0x%08x\n",
+		   sdhci_readl(host, SDHCI_ARGUMENT),
+		   sdhci_readw(host, SDHCI_TRANSFER_MODE));
+	SDHCI_DUMP("Present:   0x%08x | Host ctl: 0x%08x\n",
+		   sdhci_readl(host, SDHCI_PRESENT_STATE),
+		   sdhci_readb(host, SDHCI_HOST_CONTROL));
+	SDHCI_DUMP("Power:     0x%08x | Blk gap:  0x%08x\n",
+		   sdhci_readb(host, SDHCI_POWER_CONTROL),
+		   sdhci_readb(host, SDHCI_BLOCK_GAP_CONTROL));
+	SDHCI_DUMP("Wake-up:   0x%08x | Clock:    0x%08x\n",
+		   sdhci_readb(host, SDHCI_WAKE_UP_CONTROL),
+		   sdhci_readw(host, SDHCI_CLOCK_CONTROL));
+	SDHCI_DUMP("Timeout:   0x%08x | Int stat: 0x%08x\n",
+		   sdhci_readb(host, SDHCI_TIMEOUT_CONTROL),
+		   sdhci_readl(host, SDHCI_INT_STATUS));
+	SDHCI_DUMP("Int enab:  0x%08x | Sig enab: 0x%08x\n",
+		   sdhci_readl(host, SDHCI_INT_ENABLE),
+		   sdhci_readl(host, SDHCI_SIGNAL_ENABLE));
+	SDHCI_DUMP("AC12 err:  0x%08x | Slot int: 0x%08x\n",
+		   sdhci_readw(host, SDHCI_ACMD12_ERR),
+		   sdhci_readw(host, SDHCI_SLOT_INT_STATUS));
+	SDHCI_DUMP("Caps:      0x%08x | Caps_1:   0x%08x\n",
+		   sdhci_readl(host, SDHCI_CAPABILITIES),
+		   sdhci_readl(host, SDHCI_CAPABILITIES_1));
+	SDHCI_DUMP("Cmd:       0x%08x | Max curr: 0x%08x\n",
+		   sdhci_readw(host, SDHCI_COMMAND),
+		   sdhci_readl(host, SDHCI_MAX_CURRENT));
+	SDHCI_DUMP("Resp[0]:   0x%08x | Resp[1]:  0x%08x\n",
 		   sdhci_readl(host, SDHCI_RESPONSE),
 		   sdhci_readl(host, SDHCI_RESPONSE + 4));
-	pr_err(DRIVER_NAME ": Resp[2]:  0x%08x | Resp[3]:  0x%08x\n",
+	SDHCI_DUMP("Resp[2]:   0x%08x | Resp[3]:  0x%08x\n",
 		   sdhci_readl(host, SDHCI_RESPONSE + 8),
 		   sdhci_readl(host, SDHCI_RESPONSE + 12));
-
-	pr_err(DRIVER_NAME ": Host ctl2: 0x%08x\n",
-	       sdhci_readw(host, SDHCI_HOST_CONTROL2));
+	SDHCI_DUMP("Host ctl2: 0x%08x\n",
+		   sdhci_readw(host, SDHCI_HOST_CONTROL2));
 
 	if (host->flags & SDHCI_USE_ADMA) {
-		if (host->flags & SDHCI_USE_64_BIT_DMA)
-			pr_err(DRIVER_NAME ": ADMA Err: 0x%08x | ADMA Ptr: 0x%08x%08x\n",
-			       sdhci_readl(host, SDHCI_ADMA_ERROR),
-			       sdhci_readl(host, SDHCI_ADMA_ADDRESS_HI),
-			       sdhci_readl(host, SDHCI_ADMA_ADDRESS));
-		else
-			pr_err(DRIVER_NAME ": ADMA Err: 0x%08x | ADMA Ptr: 0x%08x\n",
-			       sdhci_readl(host, SDHCI_ADMA_ERROR),
-			       sdhci_readl(host, SDHCI_ADMA_ADDRESS));
+		if (host->flags & SDHCI_USE_64_BIT_DMA) {
+			SDHCI_DUMP("ADMA Err:  0x%08x | ADMA Ptr: 0x%08x%08x\n",
+				   sdhci_readl(host, SDHCI_ADMA_ERROR),
+				   sdhci_readl(host, SDHCI_ADMA_ADDRESS_HI),
+				   sdhci_readl(host, SDHCI_ADMA_ADDRESS));
+		} else {
+			SDHCI_DUMP("ADMA Err:  0x%08x | ADMA Ptr: 0x%08x\n",
+				   sdhci_readl(host, SDHCI_ADMA_ERROR),
+				   sdhci_readl(host, SDHCI_ADMA_ADDRESS));
+		}
 	}
 
-	pr_err(DRIVER_NAME ": ===========================================\n");
+	SDHCI_DUMP("============================================\n");
 }
 
 /*****************************************************************************\
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 15/25] mmc: sdhci: Export sdhci_dumpregs
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (13 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 14/25] mmc: sdhci: Improve register dump print format Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 16/25] mmc: sdhci: Get rid of 'extern' in header file Adrian Hunter
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Export sdhci_dumpregs so that it can be called by drivers.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 3 ++-
 drivers/mmc/host/sdhci.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 70022a0c886a..fc5cd8c21527 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -52,7 +52,7 @@
 
 static void sdhci_enable_preset_value(struct sdhci_host *host, bool enable);
 
-static void sdhci_dumpregs(struct sdhci_host *host)
+void sdhci_dumpregs(struct sdhci_host *host)
 {
 	SDHCI_DUMP("============ SDHCI REGISTER DUMP ===========\n");
 
@@ -113,6 +113,7 @@ static void sdhci_dumpregs(struct sdhci_host *host)
 
 	SDHCI_DUMP("============================================\n");
 }
+EXPORT_SYMBOL_GPL(sdhci_dumpregs);
 
 /*****************************************************************************\
  *                                                                           *
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 67772674da90..51c440eebe5c 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -698,4 +698,6 @@ void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,
 extern int sdhci_runtime_resume_host(struct sdhci_host *host);
 #endif
 
+void sdhci_dumpregs(struct sdhci_host *host);
+
 #endif /* __SDHCI_HW_H */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 16/25] mmc: sdhci: Get rid of 'extern' in header file
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (14 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 15/25] mmc: sdhci: Export sdhci_dumpregs Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 17/25] mmc: sdhci: Add sdhci_cleanup_host Adrian Hunter
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Get rid of unnecessary 'extern' in header file.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.h | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 51c440eebe5c..6fe6005b284e 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -648,24 +648,22 @@ static inline u8 sdhci_readb(struct sdhci_host *host, int reg)
 
 #endif /* CONFIG_MMC_SDHCI_IO_ACCESSORS */
 
-extern struct sdhci_host *sdhci_alloc_host(struct device *dev,
-	size_t priv_size);
-extern void sdhci_free_host(struct sdhci_host *host);
+struct sdhci_host *sdhci_alloc_host(struct device *dev, size_t priv_size);
+void sdhci_free_host(struct sdhci_host *host);
 
 static inline void *sdhci_priv(struct sdhci_host *host)
 {
 	return host->private;
 }
 
-extern void sdhci_card_detect(struct sdhci_host *host);
-extern void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps,
-			      u32 *caps1);
-extern int sdhci_setup_host(struct sdhci_host *host);
-extern int __sdhci_add_host(struct sdhci_host *host);
-extern int sdhci_add_host(struct sdhci_host *host);
-extern void sdhci_remove_host(struct sdhci_host *host, int dead);
-extern void sdhci_send_command(struct sdhci_host *host,
-				struct mmc_command *cmd);
+void sdhci_card_detect(struct sdhci_host *host);
+void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps,
+		       u32 *caps1);
+int sdhci_setup_host(struct sdhci_host *host);
+int __sdhci_add_host(struct sdhci_host *host);
+int sdhci_add_host(struct sdhci_host *host);
+void sdhci_remove_host(struct sdhci_host *host, int dead);
+void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd);
 
 static inline void sdhci_read_caps(struct sdhci_host *host)
 {
@@ -691,11 +689,11 @@ void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,
 int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode);
 
 #ifdef CONFIG_PM
-extern int sdhci_suspend_host(struct sdhci_host *host);
-extern int sdhci_resume_host(struct sdhci_host *host);
-extern void sdhci_enable_irq_wakeups(struct sdhci_host *host);
-extern int sdhci_runtime_suspend_host(struct sdhci_host *host);
-extern int sdhci_runtime_resume_host(struct sdhci_host *host);
+int sdhci_suspend_host(struct sdhci_host *host);
+int sdhci_resume_host(struct sdhci_host *host);
+void sdhci_enable_irq_wakeups(struct sdhci_host *host);
+int sdhci_runtime_suspend_host(struct sdhci_host *host);
+int sdhci_runtime_resume_host(struct sdhci_host *host);
 #endif
 
 void sdhci_dumpregs(struct sdhci_host *host);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 17/25] mmc: sdhci: Add sdhci_cleanup_host
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (15 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 16/25] mmc: sdhci: Get rid of 'extern' in header file Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 18/25] mmc: sdhci: Factor out sdhci_set_default_irqs Adrian Hunter
                   ` (10 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Add sdhci_cleanup_host() to cleanup __sdhci_add_host().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 37 ++++++++++++++++++++++++++-----------
 drivers/mmc/host/sdhci.h |  1 +
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index fc5cd8c21527..b2ef0d93cebd 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -3562,6 +3562,22 @@ int sdhci_setup_host(struct sdhci_host *host)
 }
 EXPORT_SYMBOL_GPL(sdhci_setup_host);
 
+void sdhci_cleanup_host(struct sdhci_host *host)
+{
+	struct mmc_host *mmc = host->mmc;
+
+	if (!IS_ERR(mmc->supply.vqmmc))
+		regulator_disable(mmc->supply.vqmmc);
+
+	if (host->align_buffer)
+		dma_free_coherent(mmc_dev(mmc), host->align_buffer_sz +
+				  host->adma_table_sz, host->align_buffer,
+				  host->align_addr);
+	host->adma_table = NULL;
+	host->align_buffer = NULL;
+}
+EXPORT_SYMBOL_GPL(sdhci_cleanup_host);
+
 int __sdhci_add_host(struct sdhci_host *host)
 {
 	struct mmc_host *mmc = host->mmc;
@@ -3626,16 +3642,6 @@ int __sdhci_add_host(struct sdhci_host *host)
 untasklet:
 	tasklet_kill(&host->finish_tasklet);
 
-	if (!IS_ERR(mmc->supply.vqmmc))
-		regulator_disable(mmc->supply.vqmmc);
-
-	if (host->align_buffer)
-		dma_free_coherent(mmc_dev(mmc), host->align_buffer_sz +
-				  host->adma_table_sz, host->align_buffer,
-				  host->align_addr);
-	host->adma_table = NULL;
-	host->align_buffer = NULL;
-
 	return ret;
 }
 EXPORT_SYMBOL_GPL(__sdhci_add_host);
@@ -3648,7 +3654,16 @@ int sdhci_add_host(struct sdhci_host *host)
 	if (ret)
 		return ret;
 
-	return __sdhci_add_host(host);
+	ret = __sdhci_add_host(host);
+	if (ret)
+		goto cleanup;
+
+	return 0;
+
+cleanup:
+	sdhci_cleanup_host(host);
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(sdhci_add_host);
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 6fe6005b284e..477b3f5bedfd 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -660,6 +660,7 @@ static inline void *sdhci_priv(struct sdhci_host *host)
 void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps,
 		       u32 *caps1);
 int sdhci_setup_host(struct sdhci_host *host);
+void sdhci_cleanup_host(struct sdhci_host *host);
 int __sdhci_add_host(struct sdhci_host *host);
 int sdhci_add_host(struct sdhci_host *host);
 void sdhci_remove_host(struct sdhci_host *host, int dead);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 18/25] mmc: sdhci: Factor out sdhci_set_default_irqs
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (16 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 17/25] mmc: sdhci: Add sdhci_cleanup_host Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 19/25] mmc: sdhci: Add CQE support Adrian Hunter
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Factor out sdhci_set_default_irqs().

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index b2ef0d93cebd..7f1c0126342f 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -225,15 +225,8 @@ static void sdhci_do_reset(struct sdhci_host *host, u8 mask)
 	}
 }
 
-static void sdhci_init(struct sdhci_host *host, int soft)
+static void sdhci_set_default_irqs(struct sdhci_host *host)
 {
-	struct mmc_host *mmc = host->mmc;
-
-	if (soft)
-		sdhci_do_reset(host, SDHCI_RESET_CMD|SDHCI_RESET_DATA);
-	else
-		sdhci_do_reset(host, SDHCI_RESET_ALL);
-
 	host->ier = SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
 		    SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT |
 		    SDHCI_INT_INDEX | SDHCI_INT_END_BIT | SDHCI_INT_CRC |
@@ -246,6 +239,18 @@ static void sdhci_init(struct sdhci_host *host, int soft)
 
 	sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
 	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
+}
+
+static void sdhci_init(struct sdhci_host *host, int soft)
+{
+	struct mmc_host *mmc = host->mmc;
+
+	if (soft)
+		sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
+	else
+		sdhci_do_reset(host, SDHCI_RESET_ALL);
+
+	sdhci_set_default_irqs(host);
 
 	if (soft) {
 		/* force clock reconfiguration */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 19/25] mmc: sdhci: Add CQE support
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (17 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 18/25] mmc: sdhci: Factor out sdhci_set_default_irqs Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 20/25] mmc: sdhci-pci: Let devices define how to add the host Adrian Hunter
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Add an interrupt hook and helper functions for enabling, disabling and
delivering interrupts to a CQE.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 130 +++++++++++++++++++++++++++++++++++++++++++++--
 drivers/mmc/host/sdhci.h |  19 +++++++
 2 files changed, 146 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 7f1c0126342f..a33102fc800b 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -252,6 +252,8 @@ static void sdhci_init(struct sdhci_host *host, int soft)
 
 	sdhci_set_default_irqs(host);
 
+	host->cqe_on = false;
+
 	if (soft) {
 		/* force clock reconfiguration */
 		host->clock = 0;
@@ -2666,13 +2668,19 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
 	}
 
 	do {
+		DBG("IRQ status 0x%08x\n", intmask);
+
+		if (host->ops->irq) {
+			intmask = host->ops->irq(host, intmask);
+			if (!intmask)
+				goto cont;
+		}
+
 		/* Clear selected interrupts. */
 		mask = intmask & (SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK |
 				  SDHCI_INT_BUS_POWER);
 		sdhci_writel(host, mask, SDHCI_INT_STATUS);
 
-		DBG("IRQ status 0x%08x\n", intmask);
-
 		if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) {
 			u32 present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
 				      SDHCI_CARD_PRESENT;
@@ -2732,7 +2740,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
 			unexpected |= intmask;
 			sdhci_writel(host, intmask, SDHCI_INT_STATUS);
 		}
-
+cont:
 		if (result == IRQ_NONE)
 			result = IRQ_HANDLED;
 
@@ -2961,6 +2969,119 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
 
 /*****************************************************************************\
  *                                                                           *
+ * Command Queue Engine (CQE) helpers                                        *
+ *                                                                           *
+\*****************************************************************************/
+
+void sdhci_cqe_enable(struct mmc_host *mmc)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	unsigned long flags;
+	u8 ctrl;
+
+	spin_lock_irqsave(&host->lock, flags);
+
+	ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
+	ctrl &= ~SDHCI_CTRL_DMA_MASK;
+	if (host->flags & SDHCI_USE_64_BIT_DMA)
+		ctrl |= SDHCI_CTRL_ADMA64;
+	else
+		ctrl |= SDHCI_CTRL_ADMA32;
+	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+
+	sdhci_writew(host, SDHCI_MAKE_BLKSZ(SDHCI_DEFAULT_BOUNDARY_ARG, 512),
+		     SDHCI_BLOCK_SIZE);
+
+	/* Set maximum timeout */
+	sdhci_writeb(host, 0xE, SDHCI_TIMEOUT_CONTROL);
+
+	host->ier = host->cqe_ier;
+
+	sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
+	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
+
+	host->cqe_on = true;
+
+	pr_debug("%s: sdhci: CQE on, IRQ mask %#x, IRQ status %#x\n",
+		 mmc_hostname(mmc), host->ier,
+		 sdhci_readl(host, SDHCI_INT_STATUS));
+
+	mmiowb();
+	spin_unlock_irqrestore(&host->lock, flags);
+}
+EXPORT_SYMBOL_GPL(sdhci_cqe_enable);
+
+void sdhci_cqe_disable(struct mmc_host *mmc, bool recovery)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	unsigned long flags;
+
+	spin_lock_irqsave(&host->lock, flags);
+
+	sdhci_set_default_irqs(host);
+
+	host->cqe_on = false;
+
+	if (recovery) {
+		sdhci_do_reset(host, SDHCI_RESET_CMD);
+		sdhci_do_reset(host, SDHCI_RESET_DATA);
+	}
+
+	pr_debug("%s: sdhci: CQE off, IRQ mask %#x, IRQ status %#x\n",
+		 mmc_hostname(mmc), host->ier,
+		 sdhci_readl(host, SDHCI_INT_STATUS));
+
+	mmiowb();
+	spin_unlock_irqrestore(&host->lock, flags);
+}
+EXPORT_SYMBOL_GPL(sdhci_cqe_disable);
+
+bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
+		   int *data_error)
+{
+	u32 mask;
+
+	if (!host->cqe_on)
+		return false;
+
+	if (intmask & (SDHCI_INT_INDEX | SDHCI_INT_END_BIT | SDHCI_INT_CRC))
+		*cmd_error = -EILSEQ;
+	else if (intmask & SDHCI_INT_TIMEOUT)
+		*cmd_error = -ETIMEDOUT;
+	else
+		*cmd_error = 0;
+
+	if (intmask & (SDHCI_INT_DATA_END_BIT | SDHCI_INT_DATA_CRC))
+		*data_error = -EILSEQ;
+	else if (intmask & SDHCI_INT_DATA_TIMEOUT)
+		*data_error = -ETIMEDOUT;
+	else if (intmask & SDHCI_INT_ADMA_ERROR)
+		*data_error = -EIO;
+	else
+		*data_error = 0;
+
+	/* Clear selected interrupts. */
+	mask = intmask & host->cqe_ier;
+	sdhci_writel(host, mask, SDHCI_INT_STATUS);
+
+	if (intmask & SDHCI_INT_BUS_POWER)
+		pr_err("%s: Card is consuming too much power!\n",
+		       mmc_hostname(host->mmc));
+
+	intmask &= ~(host->cqe_ier | SDHCI_INT_ERROR);
+	if (intmask) {
+		sdhci_writel(host, intmask, SDHCI_INT_STATUS);
+		pr_err("%s: CQE: Unexpected interrupt 0x%08x.\n",
+		       mmc_hostname(host->mmc), intmask);
+		sdhci_dumpregs(host);
+	}
+
+	return true;
+}
+EXPORT_SYMBOL_GPL(sdhci_cqe_irq);
+
+/*****************************************************************************\
+ *                                                                           *
  * Device allocation/registration                                            *
  *                                                                           *
 \*****************************************************************************/
@@ -2984,6 +3105,9 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
 
 	host->flags = SDHCI_SIGNALING_330;
 
+	host->cqe_ier     = SDHCI_CQE_INT_MASK;
+	host->cqe_err_ier = SDHCI_CQE_INT_ERR_MASK;
+
 	return host;
 }
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 477b3f5bedfd..35b41da0a636 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -134,6 +134,7 @@
 #define  SDHCI_INT_CARD_REMOVE	0x00000080
 #define  SDHCI_INT_CARD_INT	0x00000100
 #define  SDHCI_INT_RETUNE	0x00001000
+#define  SDHCI_INT_CQE		0x00004000
 #define  SDHCI_INT_ERROR	0x00008000
 #define  SDHCI_INT_TIMEOUT	0x00010000
 #define  SDHCI_INT_CRC		0x00020000
@@ -158,6 +159,13 @@
 		SDHCI_INT_BLK_GAP)
 #define SDHCI_INT_ALL_MASK	((unsigned int)-1)
 
+#define SDHCI_CQE_INT_ERR_MASK ( \
+	SDHCI_INT_ADMA_ERROR | SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT | \
+	SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_INDEX | \
+	SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT)
+
+#define SDHCI_CQE_INT_MASK (SDHCI_CQE_INT_ERR_MASK | SDHCI_INT_CQE)
+
 #define SDHCI_ACMD12_ERR	0x3C
 
 #define SDHCI_HOST_CONTROL2		0x3E
@@ -518,6 +526,10 @@ struct sdhci_host {
 	/* cached registers */
 	u32			ier;
 
+	bool			cqe_on;		/* CQE is operating */
+	u32			cqe_ier;	/* CQE interrupt mask */
+	u32			cqe_err_ier;	/* CQE error interrupt mask */
+
 	wait_queue_head_t	buf_ready_int;	/* Waitqueue for Buffer Read Ready interrupt */
 	unsigned int		tuning_done;	/* Condition flag set when CMD19 succeeds */
 
@@ -544,6 +556,8 @@ struct sdhci_ops {
 	void	(*set_power)(struct sdhci_host *host, unsigned char mode,
 			     unsigned short vdd);
 
+	u32		(*irq)(struct sdhci_host *host, u32 intmask);
+
 	int		(*enable_dma)(struct sdhci_host *host);
 	unsigned int	(*get_max_clock)(struct sdhci_host *host);
 	unsigned int	(*get_min_clock)(struct sdhci_host *host);
@@ -697,6 +711,11 @@ void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,
 int sdhci_runtime_resume_host(struct sdhci_host *host);
 #endif
 
+void sdhci_cqe_enable(struct mmc_host *mmc);
+void sdhci_cqe_disable(struct mmc_host *mmc, bool recovery);
+bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
+		   int *data_error);
+
 void sdhci_dumpregs(struct sdhci_host *host);
 
 #endif /* __SDHCI_HW_H */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 20/25] mmc: sdhci-pci: Let devices define how to add the host
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (18 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 19/25] mmc: sdhci: Add CQE support Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 21/25] mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm Adrian Hunter
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

SDHCI provides more flexibility than simply calling sdhci_add_host(). Make
that available by allowing devices to specify their own ->add_host()
function.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-pci-core.c | 5 ++++-
 drivers/mmc/host/sdhci-pci.h      | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 98ed90cbd9b4..b5fd82e26125 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -1949,7 +1949,10 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 		}
 	}
 
-	ret = sdhci_add_host(host);
+	if (chip->fixes && chip->fixes->add_host)
+		ret = chip->fixes->add_host(slot);
+	else
+		ret = sdhci_add_host(host);
 	if (ret)
 		goto remove;
 
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index da7b95016c6f..d53dccb0f416 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -64,6 +64,7 @@ struct sdhci_pci_fixes {
 	int			(*probe) (struct sdhci_pci_chip *);
 
 	int			(*probe_slot) (struct sdhci_pci_slot *);
+	int			(*add_host) (struct sdhci_pci_slot *);
 	void			(*remove_slot) (struct sdhci_pci_slot *, int);
 
 	int			(*suspend) (struct sdhci_pci_chip *);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 21/25] mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (19 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 20/25] mmc: sdhci-pci: Let devices define how to add the host Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 22/25] mmc: sdhci-pci: Conditionally compile pm sleep functions Adrian Hunter
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Do not use suspend/resume callbacks with runtime pm. It doesn't make sense
and isn't being used, so remove.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-pci-core.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index b5fd82e26125..7e8163affb26 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -1783,12 +1783,6 @@ static int sdhci_pci_runtime_suspend(struct device *dev)
 			mmc_retune_needed(host->mmc);
 	}
 
-	if (chip->fixes && chip->fixes->suspend) {
-		ret = chip->fixes->suspend(chip);
-		if (ret)
-			goto err_pci_runtime_suspend;
-	}
-
 	return 0;
 
 err_pci_runtime_suspend:
@@ -1808,12 +1802,6 @@ static int sdhci_pci_runtime_resume(struct device *dev)
 	if (!chip)
 		return 0;
 
-	if (chip->fixes && chip->fixes->resume) {
-		ret = chip->fixes->resume(chip);
-		if (ret)
-			return ret;
-	}
-
 	for (i = 0; i < chip->num_slots; i++) {
 		slot = chip->slots[i];
 		if (!slot)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 22/25] mmc: sdhci-pci: Conditionally compile pm sleep functions
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (20 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 21/25] mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 23/25] mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks Adrian Hunter
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

It is confusing to have some parts of suspend / resume under conditional
compilation and some parts not. Use conditional compilation everywhere.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-pci-core.c    | 10 ++++++++++
 drivers/mmc/host/sdhci-pci-o2micro.c |  2 ++
 drivers/mmc/host/sdhci-pci.h         |  2 ++
 3 files changed, 14 insertions(+)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 7e8163affb26..47a3965dff4d 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -67,6 +67,7 @@ static int ricoh_mmc_probe_slot(struct sdhci_pci_slot *slot)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
 static int ricoh_mmc_resume(struct sdhci_pci_chip *chip)
 {
 	/* Apply a delay to allow controller to settle */
@@ -75,6 +76,7 @@ static int ricoh_mmc_resume(struct sdhci_pci_chip *chip)
 	msleep(500);
 	return 0;
 }
+#endif
 
 static const struct sdhci_pci_fixes sdhci_ricoh = {
 	.probe		= ricoh_probe,
@@ -85,7 +87,9 @@ static int ricoh_mmc_resume(struct sdhci_pci_chip *chip)
 
 static const struct sdhci_pci_fixes sdhci_ricoh_mmc = {
 	.probe_slot	= ricoh_mmc_probe_slot,
+#ifdef CONFIG_PM_SLEEP
 	.resume		= ricoh_mmc_resume,
+#endif
 	.quirks		= SDHCI_QUIRK_32BIT_DMA_ADDR |
 			  SDHCI_QUIRK_CLOCK_BEFORE_RESET |
 			  SDHCI_QUIRK_NO_CARD_NO_RESET |
@@ -751,6 +755,7 @@ static void jmicron_remove_slot(struct sdhci_pci_slot *slot, int dead)
 		jmicron_enable_mmc(slot->host, 0);
 }
 
+#ifdef CONFIG_PM_SLEEP
 static int jmicron_suspend(struct sdhci_pci_chip *chip)
 {
 	int i;
@@ -782,13 +787,16 @@ static int jmicron_resume(struct sdhci_pci_chip *chip)
 
 	return 0;
 }
+#endif
 
 static const struct sdhci_pci_fixes sdhci_o2 = {
 	.probe = sdhci_pci_o2_probe,
 	.quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
 	.quirks2 = SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD,
 	.probe_slot = sdhci_pci_o2_probe_slot,
+#ifdef CONFIG_PM_SLEEP
 	.resume = sdhci_pci_o2_resume,
+#endif
 };
 
 static const struct sdhci_pci_fixes sdhci_jmicron = {
@@ -797,8 +805,10 @@ static int jmicron_resume(struct sdhci_pci_chip *chip)
 	.probe_slot	= jmicron_probe_slot,
 	.remove_slot	= jmicron_remove_slot,
 
+#ifdef CONFIG_PM_SLEEP
 	.suspend	= jmicron_suspend,
 	.resume		= jmicron_resume,
+#endif
 };
 
 /* SysKonnect CardBus2SDIO extra registers */
diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
index d48f03104b5b..0ea34e2c7cba 100644
--- a/drivers/mmc/host/sdhci-pci-o2micro.c
+++ b/drivers/mmc/host/sdhci-pci-o2micro.c
@@ -384,8 +384,10 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
 int sdhci_pci_o2_resume(struct sdhci_pci_chip *chip)
 {
 	sdhci_pci_o2_probe(chip);
 	return 0;
 }
+#endif
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index d53dccb0f416..e70a27058e0b 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -67,8 +67,10 @@ struct sdhci_pci_fixes {
 	int			(*add_host) (struct sdhci_pci_slot *);
 	void			(*remove_slot) (struct sdhci_pci_slot *, int);
 
+#ifdef CONFIG_PM_SLEEP
 	int			(*suspend) (struct sdhci_pci_chip *);
 	int			(*resume) (struct sdhci_pci_chip *);
+#endif
 
 	const struct sdhci_ops	*ops;
 	size_t			priv_size;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 23/25] mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (21 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 22/25] mmc: sdhci-pci: Conditionally compile pm sleep functions Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 24/25] mmc: sdhci-pci: Add runtime suspend/resume callbacks Adrian Hunter
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

The suspend / resume callbacks lack the flexibility to allow a device to
specify a different function entirely. Change them around so that device
functions are called directly and they in turn can call the default
implementations if needed.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-pci-core.c    | 170 ++++++++++++++++++++---------------
 drivers/mmc/host/sdhci-pci-o2micro.c |   2 +-
 drivers/mmc/host/sdhci-pci.h         |   4 +
 3 files changed, 104 insertions(+), 72 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 47a3965dff4d..5ed8369704fd 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -37,6 +37,88 @@
 static void sdhci_pci_set_bus_width(struct sdhci_host *host, int width);
 static void sdhci_pci_hw_reset(struct sdhci_host *host);
 
+#ifdef CONFIG_PM_SLEEP
+static int __sdhci_pci_suspend_host(struct sdhci_pci_chip *chip)
+{
+	int i, ret;
+
+	for (i = 0; i < chip->num_slots; i++) {
+		struct sdhci_pci_slot *slot = chip->slots[i];
+		struct sdhci_host *host;
+
+		if (!slot)
+			continue;
+
+		host = slot->host;
+
+		if (chip->pm_retune && host->tuning_mode != SDHCI_TUNING_MODE_3)
+			mmc_retune_needed(host->mmc);
+
+		ret = sdhci_suspend_host(host);
+		if (ret)
+			goto err_pci_suspend;
+
+		if (host->mmc->pm_flags & MMC_PM_WAKE_SDIO_IRQ)
+			sdhci_enable_irq_wakeups(host);
+	}
+
+	return 0;
+
+err_pci_suspend:
+	while (--i >= 0)
+		sdhci_resume_host(chip->slots[i]->host);
+	return ret;
+}
+
+static int sdhci_pci_init_wakeup(struct sdhci_pci_chip *chip)
+{
+	mmc_pm_flag_t pm_flags = 0;
+	int i;
+
+	for (i = 0; i < chip->num_slots; i++) {
+		struct sdhci_pci_slot *slot = chip->slots[i];
+
+		if (slot)
+			pm_flags |= slot->host->mmc->pm_flags;
+	}
+
+	return device_init_wakeup(&chip->pdev->dev,
+				  (pm_flags & MMC_PM_KEEP_POWER) &&
+				  (pm_flags & MMC_PM_WAKE_SDIO_IRQ));
+}
+
+static int sdhci_pci_suspend_host(struct sdhci_pci_chip *chip)
+{
+	int ret;
+
+	ret = __sdhci_pci_suspend_host(chip);
+	if (ret)
+		return ret;
+
+	sdhci_pci_init_wakeup(chip);
+
+	return 0;
+}
+
+int sdhci_pci_resume_host(struct sdhci_pci_chip *chip)
+{
+	struct sdhci_pci_slot *slot;
+	int i, ret;
+
+	for (i = 0; i < chip->num_slots; i++) {
+		slot = chip->slots[i];
+		if (!slot)
+			continue;
+
+		ret = sdhci_resume_host(slot->host);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+#endif
+
 /*****************************************************************************\
  *                                                                           *
  * Hardware specific quirk handling                                          *
@@ -74,7 +156,7 @@ static int ricoh_mmc_resume(struct sdhci_pci_chip *chip)
 	/* Otherwise it becomes confused if card state changed
 		during suspend */
 	msleep(500);
-	return 0;
+	return sdhci_pci_resume_host(chip);
 }
 #endif
 
@@ -758,7 +840,11 @@ static void jmicron_remove_slot(struct sdhci_pci_slot *slot, int dead)
 #ifdef CONFIG_PM_SLEEP
 static int jmicron_suspend(struct sdhci_pci_chip *chip)
 {
-	int i;
+	int i, ret;
+
+	ret = __sdhci_pci_suspend_host(chip);
+	if (ret)
+		return ret;
 
 	if (chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB38X_MMC ||
 	    chip->pdev->device == PCI_DEVICE_ID_JMICRON_JMB388_ESD) {
@@ -766,6 +852,8 @@ static int jmicron_suspend(struct sdhci_pci_chip *chip)
 			jmicron_enable_mmc(chip->slots[i]->host, 0);
 	}
 
+	sdhci_pci_init_wakeup(chip);
+
 	return 0;
 }
 
@@ -785,7 +873,7 @@ static int jmicron_resume(struct sdhci_pci_chip *chip)
 		return ret;
 	}
 
-	return 0;
+	return sdhci_pci_resume_host(chip);
 }
 #endif
 
@@ -1678,89 +1766,29 @@ static void sdhci_pci_hw_reset(struct sdhci_host *host)
 static int sdhci_pci_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
-	struct sdhci_pci_chip *chip;
-	struct sdhci_pci_slot *slot;
-	struct sdhci_host *host;
-	mmc_pm_flag_t slot_pm_flags;
-	mmc_pm_flag_t pm_flags = 0;
-	int i, ret;
+	struct sdhci_pci_chip *chip = pci_get_drvdata(pdev);
 
-	chip = pci_get_drvdata(pdev);
 	if (!chip)
 		return 0;
 
-	for (i = 0; i < chip->num_slots; i++) {
-		slot = chip->slots[i];
-		if (!slot)
-			continue;
-
-		host = slot->host;
-
-		if (chip->pm_retune && host->tuning_mode != SDHCI_TUNING_MODE_3)
-			mmc_retune_needed(host->mmc);
-
-		ret = sdhci_suspend_host(host);
-
-		if (ret)
-			goto err_pci_suspend;
-
-		slot_pm_flags = host->mmc->pm_flags;
-		if (slot_pm_flags & MMC_PM_WAKE_SDIO_IRQ)
-			sdhci_enable_irq_wakeups(host);
+	if (chip->fixes && chip->fixes->suspend)
+		return chip->fixes->suspend(chip);
 
-		pm_flags |= slot_pm_flags;
-	}
-
-	if (chip->fixes && chip->fixes->suspend) {
-		ret = chip->fixes->suspend(chip);
-		if (ret)
-			goto err_pci_suspend;
-	}
-
-	if (pm_flags & MMC_PM_KEEP_POWER) {
-		if (pm_flags & MMC_PM_WAKE_SDIO_IRQ)
-			device_init_wakeup(dev, true);
-		else
-			device_init_wakeup(dev, false);
-	} else
-		device_init_wakeup(dev, false);
-
-	return 0;
-
-err_pci_suspend:
-	while (--i >= 0)
-		sdhci_resume_host(chip->slots[i]->host);
-	return ret;
+	return sdhci_pci_suspend_host(chip);
 }
 
 static int sdhci_pci_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
-	struct sdhci_pci_chip *chip;
-	struct sdhci_pci_slot *slot;
-	int i, ret;
+	struct sdhci_pci_chip *chip = pci_get_drvdata(pdev);
 
-	chip = pci_get_drvdata(pdev);
 	if (!chip)
 		return 0;
 
-	if (chip->fixes && chip->fixes->resume) {
-		ret = chip->fixes->resume(chip);
-		if (ret)
-			return ret;
-	}
-
-	for (i = 0; i < chip->num_slots; i++) {
-		slot = chip->slots[i];
-		if (!slot)
-			continue;
-
-		ret = sdhci_resume_host(slot->host);
-		if (ret)
-			return ret;
-	}
+	if (chip->fixes && chip->fixes->resume)
+		return chip->fixes->resume(chip);
 
-	return 0;
+	return sdhci_pci_resume_host(chip);
 }
 #endif
 
diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
index 0ea34e2c7cba..14273ca00641 100644
--- a/drivers/mmc/host/sdhci-pci-o2micro.c
+++ b/drivers/mmc/host/sdhci-pci-o2micro.c
@@ -388,6 +388,6 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
 int sdhci_pci_o2_resume(struct sdhci_pci_chip *chip)
 {
 	sdhci_pci_o2_probe(chip);
-	return 0;
+	return sdhci_pci_resume_host(chip);
 }
 #endif
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index e70a27058e0b..ec8f91c403d6 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -111,4 +111,8 @@ static inline void *sdhci_pci_priv(struct sdhci_pci_slot *slot)
 	return (void *)slot->private;
 }
 
+#ifdef CONFIG_PM_SLEEP
+int sdhci_pci_resume_host(struct sdhci_pci_chip *chip);
+#endif
+
 #endif /* __SDHCI_PCI_H */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 24/25] mmc: sdhci-pci: Add runtime suspend/resume callbacks
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (22 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 23/25] mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-20 17:50 ` [PATCH 25/25] mmc: sdhci-pci: Move a function to avoid later forward declaration Adrian Hunter
                   ` (3 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Add runtime suspend/resume callbacks to match suspend/resume callbacks.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-pci-core.c | 98 +++++++++++++++++++++++----------------
 drivers/mmc/host/sdhci-pci.h      |  4 ++
 2 files changed, 62 insertions(+), 40 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 5ed8369704fd..d9a38c53e2ba 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -119,6 +119,56 @@ int sdhci_pci_resume_host(struct sdhci_pci_chip *chip)
 }
 #endif
 
+#ifdef CONFIG_PM
+static int sdhci_pci_runtime_suspend_host(struct sdhci_pci_chip *chip)
+{
+	struct sdhci_pci_slot *slot;
+	struct sdhci_host *host;
+	int i, ret;
+
+	for (i = 0; i < chip->num_slots; i++) {
+		slot = chip->slots[i];
+		if (!slot)
+			continue;
+
+		host = slot->host;
+
+		ret = sdhci_runtime_suspend_host(host);
+		if (ret)
+			goto err_pci_runtime_suspend;
+
+		if (chip->rpm_retune &&
+		    host->tuning_mode != SDHCI_TUNING_MODE_3)
+			mmc_retune_needed(host->mmc);
+	}
+
+	return 0;
+
+err_pci_runtime_suspend:
+	while (--i >= 0)
+		sdhci_runtime_resume_host(chip->slots[i]->host);
+	return ret;
+}
+
+static int sdhci_pci_runtime_resume_host(struct sdhci_pci_chip *chip)
+{
+	struct sdhci_pci_slot *slot;
+	int i, ret;
+
+	for (i = 0; i < chip->num_slots; i++) {
+		slot = chip->slots[i];
+		if (!slot)
+			continue;
+
+		ret = sdhci_runtime_resume_host(slot->host);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+#endif
+
 /*****************************************************************************\
  *                                                                           *
  * Hardware specific quirk handling                                          *
@@ -1796,61 +1846,29 @@ static int sdhci_pci_resume(struct device *dev)
 static int sdhci_pci_runtime_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
-	struct sdhci_pci_chip *chip;
-	struct sdhci_pci_slot *slot;
-	struct sdhci_host *host;
-	int i, ret;
+	struct sdhci_pci_chip *chip = pci_get_drvdata(pdev);
 
-	chip = pci_get_drvdata(pdev);
 	if (!chip)
 		return 0;
 
-	for (i = 0; i < chip->num_slots; i++) {
-		slot = chip->slots[i];
-		if (!slot)
-			continue;
-
-		host = slot->host;
-
-		ret = sdhci_runtime_suspend_host(host);
-		if (ret)
-			goto err_pci_runtime_suspend;
-
-		if (chip->rpm_retune &&
-		    host->tuning_mode != SDHCI_TUNING_MODE_3)
-			mmc_retune_needed(host->mmc);
-	}
-
-	return 0;
+	if (chip->fixes && chip->fixes->runtime_suspend)
+		return chip->fixes->runtime_suspend(chip);
 
-err_pci_runtime_suspend:
-	while (--i >= 0)
-		sdhci_runtime_resume_host(chip->slots[i]->host);
-	return ret;
+	return sdhci_pci_runtime_suspend_host(chip);
 }
 
 static int sdhci_pci_runtime_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
-	struct sdhci_pci_chip *chip;
-	struct sdhci_pci_slot *slot;
-	int i, ret;
+	struct sdhci_pci_chip *chip = pci_get_drvdata(pdev);
 
-	chip = pci_get_drvdata(pdev);
 	if (!chip)
 		return 0;
 
-	for (i = 0; i < chip->num_slots; i++) {
-		slot = chip->slots[i];
-		if (!slot)
-			continue;
+	if (chip->fixes && chip->fixes->runtime_resume)
+		return chip->fixes->runtime_resume(chip);
 
-		ret = sdhci_runtime_resume_host(slot->host);
-		if (ret)
-			return ret;
-	}
-
-	return 0;
+	return sdhci_pci_runtime_resume_host(chip);
 }
 #endif
 
diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
index ec8f91c403d6..37766d20a600 100644
--- a/drivers/mmc/host/sdhci-pci.h
+++ b/drivers/mmc/host/sdhci-pci.h
@@ -71,6 +71,10 @@ struct sdhci_pci_fixes {
 	int			(*suspend) (struct sdhci_pci_chip *);
 	int			(*resume) (struct sdhci_pci_chip *);
 #endif
+#ifdef CONFIG_PM
+	int			(*runtime_suspend) (struct sdhci_pci_chip *);
+	int			(*runtime_resume) (struct sdhci_pci_chip *);
+#endif
 
 	const struct sdhci_ops	*ops;
 	size_t			priv_size;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 25/25] mmc: sdhci-pci: Move a function to avoid later forward declaration
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (23 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 24/25] mmc: sdhci-pci: Add runtime suspend/resume callbacks Adrian Hunter
@ 2017-03-20 17:50 ` Adrian Hunter
  2017-03-21 10:01 ` [PATCH 00/25] sdhci patches Ulf Hansson
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-03-20 17:50 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

Move a function to avoid having to forward declare it in a subsequent
patch.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci-pci-core.c | 76 +++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 38 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index d9a38c53e2ba..6c0440ef54be 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -515,6 +515,44 @@ static int bxt_get_cd(struct mmc_host *mmc)
 	return ret;
 }
 
+#define SDHCI_INTEL_PWR_TIMEOUT_CNT	20
+#define SDHCI_INTEL_PWR_TIMEOUT_UDELAY	100
+
+static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
+				  unsigned short vdd)
+{
+	int cntr;
+	u8 reg;
+
+	sdhci_set_power(host, mode, vdd);
+
+	if (mode == MMC_POWER_OFF)
+		return;
+
+	/*
+	 * Bus power might not enable after D3 -> D0 transition due to the
+	 * present state not yet having propagated. Retry for up to 2ms.
+	 */
+	for (cntr = 0; cntr < SDHCI_INTEL_PWR_TIMEOUT_CNT; cntr++) {
+		reg = sdhci_readb(host, SDHCI_POWER_CONTROL);
+		if (reg & SDHCI_POWER_ON)
+			break;
+		udelay(SDHCI_INTEL_PWR_TIMEOUT_UDELAY);
+		reg |= SDHCI_POWER_ON;
+		sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
+	}
+}
+
+static const struct sdhci_ops sdhci_intel_byt_ops = {
+	.set_clock		= sdhci_set_clock,
+	.set_power		= sdhci_intel_set_power,
+	.enable_dma		= sdhci_pci_enable_dma,
+	.set_bus_width		= sdhci_pci_set_bus_width,
+	.reset			= sdhci_reset,
+	.set_uhs_signaling	= sdhci_set_uhs_signaling,
+	.hw_reset		= sdhci_pci_hw_reset,
+};
+
 static void byt_read_dsm(struct sdhci_pci_slot *slot)
 {
 	struct intel_host *intel_host = sdhci_pci_priv(slot);
@@ -606,44 +644,6 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
 	return 0;
 }
 
-#define SDHCI_INTEL_PWR_TIMEOUT_CNT	20
-#define SDHCI_INTEL_PWR_TIMEOUT_UDELAY	100
-
-static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
-				  unsigned short vdd)
-{
-	int cntr;
-	u8 reg;
-
-	sdhci_set_power(host, mode, vdd);
-
-	if (mode == MMC_POWER_OFF)
-		return;
-
-	/*
-	 * Bus power might not enable after D3 -> D0 transition due to the
-	 * present state not yet having propagated. Retry for up to 2ms.
-	 */
-	for (cntr = 0; cntr < SDHCI_INTEL_PWR_TIMEOUT_CNT; cntr++) {
-		reg = sdhci_readb(host, SDHCI_POWER_CONTROL);
-		if (reg & SDHCI_POWER_ON)
-			break;
-		udelay(SDHCI_INTEL_PWR_TIMEOUT_UDELAY);
-		reg |= SDHCI_POWER_ON;
-		sdhci_writeb(host, reg, SDHCI_POWER_CONTROL);
-	}
-}
-
-static const struct sdhci_ops sdhci_intel_byt_ops = {
-	.set_clock		= sdhci_set_clock,
-	.set_power		= sdhci_intel_set_power,
-	.enable_dma		= sdhci_pci_enable_dma,
-	.set_bus_width		= sdhci_pci_set_bus_width,
-	.reset			= sdhci_reset,
-	.set_uhs_signaling	= sdhci_set_uhs_signaling,
-	.hw_reset		= sdhci_pci_hw_reset,
-};
-
 static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = {
 	.allow_runtime_pm = true,
 	.probe_slot	= byt_emmc_probe_slot,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/25] sdhci patches
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (24 preceding siblings ...)
  2017-03-20 17:50 ` [PATCH 25/25] mmc: sdhci-pci: Move a function to avoid later forward declaration Adrian Hunter
@ 2017-03-21 10:01 ` Ulf Hansson
  2017-03-21 11:00 ` Lee Jones
  2017-03-22  8:47 ` Ludovic Desroches
  27 siblings, 0 replies; 36+ messages in thread
From: Ulf Hansson @ 2017-03-21 10:01 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen, Dong Aisheng,
	Shawn Lin, Douglas Anderson, Zach Brown, Ludovic Desroches,
	Jisheng Zhang, Yangbo Lu, Jaehoon Chung, Weijun Yang, Barry Song,
	Peter Griffin, Lee Jones, Jon Hunter, Harjani Ritesh

On 20 March 2017 at 18:50, Adrian Hunter <adrian.hunter@intel.com> wrote:
> Hi
>
> Here are some sdhci patches that include preparation for CQE and some
> general improvements.  Patches such as:
>
>     mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
>     mmc: sdhci: Do not use spin lock in set_ios paths
>
> affect several drivers specifically, like:
>
>     drivers/mmc/host/sdhci-brcmstb.c
>     drivers/mmc/host/sdhci-esdhc-imx.c
>     drivers/mmc/host/sdhci-of-arasan.c
>     drivers/mmc/host/sdhci-of-at91.c
>     drivers/mmc/host/sdhci-of-esdhc.c
>     drivers/mmc/host/sdhci-pxav3.c
>     drivers/mmc/host/sdhci-s3c.c
>     drivers/mmc/host/sdhci-sirf.c
>     drivers/mmc/host/sdhci-spear.c
>     drivers/mmc/host/sdhci-st.c
>
>
>
> Adrian Hunter (25):
>       mmc: sdhci: Do not disable interrupts while waiting for clock
>       mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power
>       mmc: sdhci: Optimize delay loops
>       mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
>       mmc: sdhci-pci: Let devices define their own private data
>       mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices
>       mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
>       mmc: sdhci: Remove ->select_drive_strength() callback
>       mmc: sdhci: Do not use spin lock in set_ios paths
>       mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning
>       mmc: sdhci: Improve debug print format
>       mmc: sdhci: Add response register to register dump
>       mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs()
>       mmc: sdhci: Improve register dump print format
>       mmc: sdhci: Export sdhci_dumpregs
>       mmc: sdhci: Get rid of 'extern' in header file
>       mmc: sdhci: Add sdhci_cleanup_host
>       mmc: sdhci: Factor out sdhci_set_default_irqs
>       mmc: sdhci: Add CQE support
>       mmc: sdhci-pci: Let devices define how to add the host
>       mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm
>       mmc: sdhci-pci: Conditionally compile pm sleep functions
>       mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks
>       mmc: sdhci-pci: Add runtime suspend/resume callbacks
>       mmc: sdhci-pci: Move a function to avoid later forward declaration
>
>  drivers/mmc/host/sdhci-acpi.c        |  12 +-
>  drivers/mmc/host/sdhci-brcmstb.c     |   3 +
>  drivers/mmc/host/sdhci-esdhc-imx.c   |   6 +
>  drivers/mmc/host/sdhci-msm.c         |   8 -
>  drivers/mmc/host/sdhci-of-arasan.c   |   9 +-
>  drivers/mmc/host/sdhci-of-at91.c     |   5 +-
>  drivers/mmc/host/sdhci-of-esdhc.c    |   3 +
>  drivers/mmc/host/sdhci-pci-core.c    | 551 ++++++++++++++++++++---------------
>  drivers/mmc/host/sdhci-pci-data.c    |   3 -
>  drivers/mmc/host/sdhci-pci-o2micro.c |   4 +-
>  drivers/mmc/host/sdhci-pci.h         |  24 +-
>  drivers/mmc/host/sdhci-pltfm.c       |   3 +
>  drivers/mmc/host/sdhci-pxav3.c       |  10 +-
>  drivers/mmc/host/sdhci-s3c.c         |  10 +-
>  drivers/mmc/host/sdhci-sirf.c        |   3 +
>  drivers/mmc/host/sdhci-spear.c       |   3 +
>  drivers/mmc/host/sdhci-st.c          |   6 +-
>  drivers/mmc/host/sdhci.c             | 404 ++++++++++++++++---------
>  drivers/mmc/host/sdhci.h             |  58 ++--
>  19 files changed, 691 insertions(+), 434 deletions(-)
>

Adrian, I have reviewed this and it looks great to me!

I have applied patch 1 and 2 for fixes, while the rest of the series
is applied for next.

Thanks and kind regards
Uffe

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/25] sdhci patches
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (25 preceding siblings ...)
  2017-03-21 10:01 ` [PATCH 00/25] sdhci patches Ulf Hansson
@ 2017-03-21 11:00 ` Lee Jones
  2017-03-21 11:54   ` Adrian Hunter
  2017-03-22  8:47 ` Ludovic Desroches
  27 siblings, 1 reply; 36+ messages in thread
From: Lee Jones @ 2017-03-21 11:00 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Ulf Hansson, linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen,
	Dong Aisheng, Shawn Lin, Douglas Anderson, Zach Brown,
	Ludovic Desroches, Jisheng Zhang, Yangbo Lu, Jaehoon Chung,
	Weijun Yang, Barry Song, Peter Griffin, Jon Hunter,
	Harjani Ritesh

On Mon, 20 Mar 2017, Adrian Hunter wrote:

> Hi
> 
> Here are some sdhci patches that include preparation for CQE and some
> general improvements.  Patches such as:
> 
>     mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
>     mmc: sdhci: Do not use spin lock in set_ios paths
> 
> affect several drivers specifically, like:
> 
>     drivers/mmc/host/sdhci-brcmstb.c
>     drivers/mmc/host/sdhci-esdhc-imx.c
>     drivers/mmc/host/sdhci-of-arasan.c
>     drivers/mmc/host/sdhci-of-at91.c
>     drivers/mmc/host/sdhci-of-esdhc.c
>     drivers/mmc/host/sdhci-pxav3.c
>     drivers/mmc/host/sdhci-s3c.c
>     drivers/mmc/host/sdhci-sirf.c
>     drivers/mmc/host/sdhci-spear.c
>     drivers/mmc/host/sdhci-st.c
> 
> 
> 
> Adrian Hunter (25):
>       mmc: sdhci: Do not disable interrupts while waiting for clock
>       mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power
>       mmc: sdhci: Optimize delay loops
>       mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
>       mmc: sdhci-pci: Let devices define their own private data
>       mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices
>       mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
>       mmc: sdhci: Remove ->select_drive_strength() callback
>       mmc: sdhci: Do not use spin lock in set_ios paths
>       mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning
>       mmc: sdhci: Improve debug print format
>       mmc: sdhci: Add response register to register dump
>       mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs()
>       mmc: sdhci: Improve register dump print format
>       mmc: sdhci: Export sdhci_dumpregs
>       mmc: sdhci: Get rid of 'extern' in header file
>       mmc: sdhci: Add sdhci_cleanup_host
>       mmc: sdhci: Factor out sdhci_set_default_irqs
>       mmc: sdhci: Add CQE support
>       mmc: sdhci-pci: Let devices define how to add the host
>       mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm
>       mmc: sdhci-pci: Conditionally compile pm sleep functions
>       mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks
>       mmc: sdhci-pci: Add runtime suspend/resume callbacks
>       mmc: sdhci-pci: Move a function to avoid later forward declaration

Why have you sent this set to so many people?

Mores the point, why have you sent it to me?

>  drivers/mmc/host/sdhci-acpi.c        |  12 +-
>  drivers/mmc/host/sdhci-brcmstb.c     |   3 +
>  drivers/mmc/host/sdhci-esdhc-imx.c   |   6 +
>  drivers/mmc/host/sdhci-msm.c         |   8 -
>  drivers/mmc/host/sdhci-of-arasan.c   |   9 +-
>  drivers/mmc/host/sdhci-of-at91.c     |   5 +-
>  drivers/mmc/host/sdhci-of-esdhc.c    |   3 +
>  drivers/mmc/host/sdhci-pci-core.c    | 551 ++++++++++++++++++++---------------
>  drivers/mmc/host/sdhci-pci-data.c    |   3 -
>  drivers/mmc/host/sdhci-pci-o2micro.c |   4 +-
>  drivers/mmc/host/sdhci-pci.h         |  24 +-
>  drivers/mmc/host/sdhci-pltfm.c       |   3 +
>  drivers/mmc/host/sdhci-pxav3.c       |  10 +-
>  drivers/mmc/host/sdhci-s3c.c         |  10 +-
>  drivers/mmc/host/sdhci-sirf.c        |   3 +
>  drivers/mmc/host/sdhci-spear.c       |   3 +
>  drivers/mmc/host/sdhci-st.c          |   6 +-
>  drivers/mmc/host/sdhci.c             | 404 ++++++++++++++++---------
>  drivers/mmc/host/sdhci.h             |  58 ++--
>  19 files changed, 691 insertions(+), 434 deletions(-)
> 
> 
> Regards
> Adrian

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/25] sdhci patches
  2017-03-21 11:00 ` Lee Jones
@ 2017-03-21 11:54   ` Adrian Hunter
  2017-03-21 15:14     ` Lee Jones
  0 siblings, 1 reply; 36+ messages in thread
From: Adrian Hunter @ 2017-03-21 11:54 UTC (permalink / raw)
  To: Lee Jones
  Cc: Ulf Hansson, linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen,
	Dong Aisheng, Shawn Lin, Douglas Anderson, Zach Brown,
	Ludovic Desroches, Jisheng Zhang, Yangbo Lu, Jaehoon Chung,
	Weijun Yang, Barry Song, Peter Griffin, Jon Hunter,
	Harjani Ritesh

On 21/03/17 13:00, Lee Jones wrote:
> On Mon, 20 Mar 2017, Adrian Hunter wrote:
> 
>> Hi
>>
>> Here are some sdhci patches that include preparation for CQE and some
>> general improvements.  Patches such as:
>>
>>     mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
>>     mmc: sdhci: Do not use spin lock in set_ios paths
>>
>> affect several drivers specifically, like:
>>
>>     drivers/mmc/host/sdhci-brcmstb.c
>>     drivers/mmc/host/sdhci-esdhc-imx.c
>>     drivers/mmc/host/sdhci-of-arasan.c
>>     drivers/mmc/host/sdhci-of-at91.c
>>     drivers/mmc/host/sdhci-of-esdhc.c
>>     drivers/mmc/host/sdhci-pxav3.c
>>     drivers/mmc/host/sdhci-s3c.c
>>     drivers/mmc/host/sdhci-sirf.c
>>     drivers/mmc/host/sdhci-spear.c
>>     drivers/mmc/host/sdhci-st.c
>>
>>
>>
>> Adrian Hunter (25):
>>       mmc: sdhci: Do not disable interrupts while waiting for clock
>>       mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power
>>       mmc: sdhci: Optimize delay loops
>>       mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
>>       mmc: sdhci-pci: Let devices define their own private data
>>       mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices
>>       mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
>>       mmc: sdhci: Remove ->select_drive_strength() callback
>>       mmc: sdhci: Do not use spin lock in set_ios paths
>>       mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning
>>       mmc: sdhci: Improve debug print format
>>       mmc: sdhci: Add response register to register dump
>>       mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs()
>>       mmc: sdhci: Improve register dump print format
>>       mmc: sdhci: Export sdhci_dumpregs
>>       mmc: sdhci: Get rid of 'extern' in header file
>>       mmc: sdhci: Add sdhci_cleanup_host
>>       mmc: sdhci: Factor out sdhci_set_default_irqs
>>       mmc: sdhci: Add CQE support
>>       mmc: sdhci-pci: Let devices define how to add the host
>>       mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm
>>       mmc: sdhci-pci: Conditionally compile pm sleep functions
>>       mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks
>>       mmc: sdhci-pci: Add runtime suspend/resume callbacks
>>       mmc: sdhci-pci: Move a function to avoid later forward declaration
> 
> Why have you sent this set to so many people?

Because they might have an interest in testing the drivers that they have
contributed to.

> 
> Mores the point, why have you sent it to me?

Because you contributed to:

	drivers/mmc/host/sdhci-st.c

and might have an interest in testing it.

> 
>>  drivers/mmc/host/sdhci-acpi.c        |  12 +-
>>  drivers/mmc/host/sdhci-brcmstb.c     |   3 +
>>  drivers/mmc/host/sdhci-esdhc-imx.c   |   6 +
>>  drivers/mmc/host/sdhci-msm.c         |   8 -
>>  drivers/mmc/host/sdhci-of-arasan.c   |   9 +-
>>  drivers/mmc/host/sdhci-of-at91.c     |   5 +-
>>  drivers/mmc/host/sdhci-of-esdhc.c    |   3 +
>>  drivers/mmc/host/sdhci-pci-core.c    | 551 ++++++++++++++++++++---------------
>>  drivers/mmc/host/sdhci-pci-data.c    |   3 -
>>  drivers/mmc/host/sdhci-pci-o2micro.c |   4 +-
>>  drivers/mmc/host/sdhci-pci.h         |  24 +-
>>  drivers/mmc/host/sdhci-pltfm.c       |   3 +
>>  drivers/mmc/host/sdhci-pxav3.c       |  10 +-
>>  drivers/mmc/host/sdhci-s3c.c         |  10 +-
>>  drivers/mmc/host/sdhci-sirf.c        |   3 +
>>  drivers/mmc/host/sdhci-spear.c       |   3 +
>>  drivers/mmc/host/sdhci-st.c          |   6 +-
>>  drivers/mmc/host/sdhci.c             | 404 ++++++++++++++++---------
>>  drivers/mmc/host/sdhci.h             |  58 ++--
>>  19 files changed, 691 insertions(+), 434 deletions(-)
>>
>>
>> Regards
>> Adrian
> 


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/25] sdhci patches
  2017-03-21 11:54   ` Adrian Hunter
@ 2017-03-21 15:14     ` Lee Jones
  2017-03-21 15:17       ` Lee Jones
  0 siblings, 1 reply; 36+ messages in thread
From: Lee Jones @ 2017-03-21 15:14 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Ulf Hansson, linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen,
	Dong Aisheng, Shawn Lin, Douglas Anderson, Zach Brown,
	Ludovic Desroches, Jisheng Zhang, Yangbo Lu, Jaehoon Chung,
	Weijun Yang, Barry Song, Peter Griffin, Jon Hunter,
	Harjani Ritesh

On Tue, 21 Mar 2017, Adrian Hunter wrote:

> On 21/03/17 13:00, Lee Jones wrote:
> > On Mon, 20 Mar 2017, Adrian Hunter wrote:
> >> Adrian Hunter (25):
> >>       mmc: sdhci: Do not disable interrupts while waiting for clock
> >>       mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power
> >>       mmc: sdhci: Optimize delay loops
> >>       mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
> >>       mmc: sdhci-pci: Let devices define their own private data
> >>       mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices
> >>       mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
> >>       mmc: sdhci: Remove ->select_drive_strength() callback
> >>       mmc: sdhci: Do not use spin lock in set_ios paths
> >>       mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning
> >>       mmc: sdhci: Improve debug print format
> >>       mmc: sdhci: Add response register to register dump
> >>       mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs()
> >>       mmc: sdhci: Improve register dump print format
> >>       mmc: sdhci: Export sdhci_dumpregs
> >>       mmc: sdhci: Get rid of 'extern' in header file
> >>       mmc: sdhci: Add sdhci_cleanup_host
> >>       mmc: sdhci: Factor out sdhci_set_default_irqs
> >>       mmc: sdhci: Add CQE support
> >>       mmc: sdhci-pci: Let devices define how to add the host
> >>       mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm
> >>       mmc: sdhci-pci: Conditionally compile pm sleep functions
> >>       mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks
> >>       mmc: sdhci-pci: Add runtime suspend/resume callbacks
> >>       mmc: sdhci-pci: Move a function to avoid later forward declaration
> > 
> > Why have you sent this set to so many people?
> 
> Because they might have an interest in testing the drivers that they have
> contributed to.
> 
> > 
> > Mores the point, why have you sent it to me?
> 
> Because you contributed to:
> 
> 	drivers/mmc/host/sdhci-st.c
> 
> and might have an interest in testing it.

Please don't send patches to every email address get_maintainer.pl
spits out.  If everyone did that contributors, especially the ones
who work across many subsystems, would be completely swamped in mail.

Instead exercise common sense and only include the Maintainers and
*maybe* super heavy, regular contributors or authors if you are that
way inclined.

Personally I only send to the Maintainers of the file.  If anyone else
has a keen interest they will normally set up filters on the MLs to
catch patches submitted. 

> >>  drivers/mmc/host/sdhci-acpi.c        |  12 +-
> >>  drivers/mmc/host/sdhci-brcmstb.c     |   3 +
> >>  drivers/mmc/host/sdhci-esdhc-imx.c   |   6 +
> >>  drivers/mmc/host/sdhci-msm.c         |   8 -
> >>  drivers/mmc/host/sdhci-of-arasan.c   |   9 +-
> >>  drivers/mmc/host/sdhci-of-at91.c     |   5 +-
> >>  drivers/mmc/host/sdhci-of-esdhc.c    |   3 +
> >>  drivers/mmc/host/sdhci-pci-core.c    | 551 ++++++++++++++++++++---------------
> >>  drivers/mmc/host/sdhci-pci-data.c    |   3 -
> >>  drivers/mmc/host/sdhci-pci-o2micro.c |   4 +-
> >>  drivers/mmc/host/sdhci-pci.h         |  24 +-
> >>  drivers/mmc/host/sdhci-pltfm.c       |   3 +
> >>  drivers/mmc/host/sdhci-pxav3.c       |  10 +-
> >>  drivers/mmc/host/sdhci-s3c.c         |  10 +-
> >>  drivers/mmc/host/sdhci-sirf.c        |   3 +
> >>  drivers/mmc/host/sdhci-spear.c       |   3 +
> >>  drivers/mmc/host/sdhci-st.c          |   6 +-
> >>  drivers/mmc/host/sdhci.c             | 404 ++++++++++++++++---------
> >>  drivers/mmc/host/sdhci.h             |  58 ++--
> >>  19 files changed, 691 insertions(+), 434 deletions(-)
> >>
> >>
> >> Regards
> >> Adrian
> > 
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/25] sdhci patches
  2017-03-21 15:14     ` Lee Jones
@ 2017-03-21 15:17       ` Lee Jones
  0 siblings, 0 replies; 36+ messages in thread
From: Lee Jones @ 2017-03-21 15:17 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Ulf Hansson, linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen,
	Dong Aisheng, Shawn Lin, Douglas Anderson, Zach Brown,
	Ludovic Desroches, Jisheng Zhang, Yangbo Lu, Jaehoon Chung,
	Weijun Yang, Barry Song, Peter Griffin, Jon Hunter,
	Harjani Ritesh

On Tue, 21 Mar 2017, Lee Jones wrote:

> On Tue, 21 Mar 2017, Adrian Hunter wrote:
> 
> > On 21/03/17 13:00, Lee Jones wrote:
> > > On Mon, 20 Mar 2017, Adrian Hunter wrote:
> > >> Adrian Hunter (25):
> > >>       mmc: sdhci: Do not disable interrupts while waiting for clock
> > >>       mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power
> > >>       mmc: sdhci: Optimize delay loops
> > >>       mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
> > >>       mmc: sdhci-pci: Let devices define their own private data
> > >>       mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices
> > >>       mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
> > >>       mmc: sdhci: Remove ->select_drive_strength() callback
> > >>       mmc: sdhci: Do not use spin lock in set_ios paths
> > >>       mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning
> > >>       mmc: sdhci: Improve debug print format
> > >>       mmc: sdhci: Add response register to register dump
> > >>       mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs()
> > >>       mmc: sdhci: Improve register dump print format
> > >>       mmc: sdhci: Export sdhci_dumpregs
> > >>       mmc: sdhci: Get rid of 'extern' in header file
> > >>       mmc: sdhci: Add sdhci_cleanup_host
> > >>       mmc: sdhci: Factor out sdhci_set_default_irqs
> > >>       mmc: sdhci: Add CQE support
> > >>       mmc: sdhci-pci: Let devices define how to add the host
> > >>       mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm
> > >>       mmc: sdhci-pci: Conditionally compile pm sleep functions
> > >>       mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks
> > >>       mmc: sdhci-pci: Add runtime suspend/resume callbacks
> > >>       mmc: sdhci-pci: Move a function to avoid later forward declaration
> > > 
> > > Why have you sent this set to so many people?
> > 
> > Because they might have an interest in testing the drivers that they have
> > contributed to.
> > 
> > > 
> > > Mores the point, why have you sent it to me?
> > 
> > Because you contributed to:
> > 
> > 	drivers/mmc/host/sdhci-st.c
> > 
> > and might have an interest in testing it.
> 
> Please don't send patches to every email address get_maintainer.pl
> spits out.  If everyone did that contributors, especially the ones
> who work across many subsystems, would be completely swamped in mail.
> 
> Instead exercise common sense and only include the Maintainers and
> *maybe* super heavy, regular contributors or authors if you are that
> way inclined.
> 
> Personally I only send to the Maintainers of the file.  If anyone else
> has a keen interest they will normally set up filters on the MLs to
> catch patches submitted. 

I've just seen that you *are* the Maintainer of SDHCI, so I guess this
it *slightly* different for you.  In this case I would have only Cc'ed
your Co- and Sub- Maintainers and any heavy contributors/authors.

The long as the short of it is, little people like me shouldn't really
be in receipt of this change.

> > >>  drivers/mmc/host/sdhci-acpi.c        |  12 +-
> > >>  drivers/mmc/host/sdhci-brcmstb.c     |   3 +
> > >>  drivers/mmc/host/sdhci-esdhc-imx.c   |   6 +
> > >>  drivers/mmc/host/sdhci-msm.c         |   8 -
> > >>  drivers/mmc/host/sdhci-of-arasan.c   |   9 +-
> > >>  drivers/mmc/host/sdhci-of-at91.c     |   5 +-
> > >>  drivers/mmc/host/sdhci-of-esdhc.c    |   3 +
> > >>  drivers/mmc/host/sdhci-pci-core.c    | 551 ++++++++++++++++++++---------------
> > >>  drivers/mmc/host/sdhci-pci-data.c    |   3 -
> > >>  drivers/mmc/host/sdhci-pci-o2micro.c |   4 +-
> > >>  drivers/mmc/host/sdhci-pci.h         |  24 +-
> > >>  drivers/mmc/host/sdhci-pltfm.c       |   3 +
> > >>  drivers/mmc/host/sdhci-pxav3.c       |  10 +-
> > >>  drivers/mmc/host/sdhci-s3c.c         |  10 +-
> > >>  drivers/mmc/host/sdhci-sirf.c        |   3 +
> > >>  drivers/mmc/host/sdhci-spear.c       |   3 +
> > >>  drivers/mmc/host/sdhci-st.c          |   6 +-
> > >>  drivers/mmc/host/sdhci.c             | 404 ++++++++++++++++---------
> > >>  drivers/mmc/host/sdhci.h             |  58 ++--
> > >>  19 files changed, 691 insertions(+), 434 deletions(-)
> > >>
> > >>
> > >> Regards
> > >> Adrian
> > > 
> > 
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/25] sdhci patches
  2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
                   ` (26 preceding siblings ...)
  2017-03-21 11:00 ` Lee Jones
@ 2017-03-22  8:47 ` Ludovic Desroches
  27 siblings, 0 replies; 36+ messages in thread
From: Ludovic Desroches @ 2017-03-22  8:47 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Ulf Hansson, linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen,
	Dong Aisheng, Shawn Lin, Douglas Anderson, Zach Brown,
	Ludovic Desroches, Jisheng Zhang, Yangbo Lu, Jaehoon Chung,
	Weijun Yang, Barry Song, Peter Griffin, Lee Jones, Jon Hunter,
	Harjani Ritesh

On Mon, Mar 20, 2017 at 07:50:28PM +0200, Adrian Hunter wrote:
> Hi
> 
> Here are some sdhci patches that include preparation for CQE and some
> general improvements.  Patches such as:
> 
>     mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
>     mmc: sdhci: Do not use spin lock in set_ios paths
> 
> affect several drivers specifically, like:
> 
>     drivers/mmc/host/sdhci-brcmstb.c
>     drivers/mmc/host/sdhci-esdhc-imx.c
>     drivers/mmc/host/sdhci-of-arasan.c
>     drivers/mmc/host/sdhci-of-at91.c
>     drivers/mmc/host/sdhci-of-esdhc.c
>     drivers/mmc/host/sdhci-pxav3.c
>     drivers/mmc/host/sdhci-s3c.c
>     drivers/mmc/host/sdhci-sirf.c
>     drivers/mmc/host/sdhci-spear.c
>     drivers/mmc/host/sdhci-st.c
> 
> 
> 
> Adrian Hunter (25):
>       mmc: sdhci: Do not disable interrupts while waiting for clock
>       mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power
>       mmc: sdhci: Optimize delay loops
>       mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
>       mmc: sdhci-pci: Let devices define their own private data
>       mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices
>       mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
>       mmc: sdhci: Remove ->select_drive_strength() callback
>       mmc: sdhci: Do not use spin lock in set_ios paths
>       mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning
>       mmc: sdhci: Improve debug print format
>       mmc: sdhci: Add response register to register dump
>       mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs()
>       mmc: sdhci: Improve register dump print format
>       mmc: sdhci: Export sdhci_dumpregs
>       mmc: sdhci: Get rid of 'extern' in header file
>       mmc: sdhci: Add sdhci_cleanup_host
>       mmc: sdhci: Factor out sdhci_set_default_irqs
>       mmc: sdhci: Add CQE support
>       mmc: sdhci-pci: Let devices define how to add the host
>       mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm
>       mmc: sdhci-pci: Conditionally compile pm sleep functions
>       mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks
>       mmc: sdhci-pci: Add runtime suspend/resume callbacks
>       mmc: sdhci-pci: Move a function to avoid later forward declaration
> 
>  drivers/mmc/host/sdhci-acpi.c        |  12 +-
>  drivers/mmc/host/sdhci-brcmstb.c     |   3 +
>  drivers/mmc/host/sdhci-esdhc-imx.c   |   6 +
>  drivers/mmc/host/sdhci-msm.c         |   8 -
>  drivers/mmc/host/sdhci-of-arasan.c   |   9 +-
>  drivers/mmc/host/sdhci-of-at91.c     |   5 +-
>  drivers/mmc/host/sdhci-of-esdhc.c    |   3 +
>  drivers/mmc/host/sdhci-pci-core.c    | 551 ++++++++++++++++++++---------------
>  drivers/mmc/host/sdhci-pci-data.c    |   3 -
>  drivers/mmc/host/sdhci-pci-o2micro.c |   4 +-
>  drivers/mmc/host/sdhci-pci.h         |  24 +-
>  drivers/mmc/host/sdhci-pltfm.c       |   3 +
>  drivers/mmc/host/sdhci-pxav3.c       |  10 +-
>  drivers/mmc/host/sdhci-s3c.c         |  10 +-
>  drivers/mmc/host/sdhci-sirf.c        |   3 +
>  drivers/mmc/host/sdhci-spear.c       |   3 +
>  drivers/mmc/host/sdhci-st.c          |   6 +-
>  drivers/mmc/host/sdhci.c             | 404 ++++++++++++++++---------
>  drivers/mmc/host/sdhci.h             |  58 ++--
>  19 files changed, 691 insertions(+), 434 deletions(-)
> 

Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>

> 
> Regards
> Adrian
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 07/25] mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
  2017-03-20 17:50 ` [PATCH 07/25] mmc: sdhci-pci: Use ACPI DSM to get driver strength " Adrian Hunter
@ 2017-04-04  8:48   ` Wolfram Sang
  2017-04-19  8:50     ` Adrian Hunter
  0 siblings, 1 reply; 36+ messages in thread
From: Wolfram Sang @ 2017-04-04  8:48 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Ulf Hansson, linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen,
	Dong Aisheng, Shawn Lin, Douglas Anderson, Zach Brown,
	Ludovic Desroches, Jisheng Zhang, Yangbo Lu, Jaehoon Chung,
	Weijun Yang, Barry Song, Peter Griffin, Lee Jones, Jon Hunter,
	Harjani Ritesh

[-- Attachment #1: Type: text/plain, Size: 849 bytes --]

Hi Adrian,

On Mon, Mar 20, 2017 at 07:50:35PM +0200, Adrian Hunter wrote:
> Make use  of an Intel ACPI _DSM that provides eMMC driver strength.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

This is an interesting patch for me because it seems I have to deal with
drive-strength soon, as well, for the SDHI driver. You basically fall
back here to simply read the drive strength value from ACPI, right? So,
do you think it makes sense then to have a similar encoded value from DT
(maybe "mmc-fixed-driver-type-<n>" with n=0..4)? This is a largely
reduced encoding of what you proposed in 2015 [1] but may be more
pragmatic for soldered on-board devices working on their max speeds with
fixed voltages and frequencies? Or did I get something wrong?

Thanks,

   Wolfram

[1] https://lkml.org/lkml/2015/2/16/273



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 07/25] mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
  2017-04-04  8:48   ` Wolfram Sang
@ 2017-04-19  8:50     ` Adrian Hunter
  2017-04-19 12:24       ` Wolfram Sang
  0 siblings, 1 reply; 36+ messages in thread
From: Adrian Hunter @ 2017-04-19  8:50 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen,
	Dong Aisheng, Shawn Lin, Douglas Anderson, Zach Brown,
	Ludovic Desroches, Jisheng Zhang, Yangbo Lu, Jaehoon Chung,
	Weijun Yang, Barry Song, Peter Griffin, Lee Jones, Jon Hunter,
	Harjani Ritesh

On 04/04/17 11:48, Wolfram Sang wrote:
> Hi Adrian,
> 
> On Mon, Mar 20, 2017 at 07:50:35PM +0200, Adrian Hunter wrote:
>> Make use  of an Intel ACPI _DSM that provides eMMC driver strength.
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> 
> This is an interesting patch for me because it seems I have to deal with
> drive-strength soon, as well, for the SDHI driver. You basically fall
> back here to simply read the drive strength value from ACPI, right?

Yes, it is a single value.  I did not design the _DSM, it was a preexisting
method.

>                                                                     So,
> do you think it makes sense then to have a similar encoded value from DT
> (maybe "mmc-fixed-driver-type-<n>" with n=0..4)?

The _DSM, being a device-specific method does not have to support different
devices with different requirements whereas DT does.

>                                                  This is a largely
> reduced encoding of what you proposed in 2015 [1] but may be more
> pragmatic for soldered on-board devices working on their max speeds with
> fixed voltages and frequencies? Or did I get something wrong?

What I proposed was being forced on me by the requirement to provide a
solution that could meet any conceivable need.  That gets over-complicated.

But as you say, in practice people are probably only interested in providing
one value for the max speed / frequency.

> 
> Thanks,
> 
>    Wolfram
> 
> [1] https://lkml.org/lkml/2015/2/16/273
> 
> 


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 07/25] mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
  2017-04-19  8:50     ` Adrian Hunter
@ 2017-04-19 12:24       ` Wolfram Sang
  2017-04-19 12:58         ` Adrian Hunter
  0 siblings, 1 reply; 36+ messages in thread
From: Wolfram Sang @ 2017-04-19 12:24 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Ulf Hansson, linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen,
	Dong Aisheng, Shawn Lin, Douglas Anderson, Zach Brown,
	Ludovic Desroches, Jisheng Zhang, Yangbo Lu, Jaehoon Chung,
	Weijun Yang, Barry Song, Peter Griffin, Lee Jones, Jon Hunter,
	Harjani Ritesh

[-- Attachment #1: Type: text/plain, Size: 1056 bytes --]


> > do you think it makes sense then to have a similar encoded value from DT
> > (maybe "mmc-fixed-driver-type-<n>" with n=0..4)?
> 
> The _DSM, being a device-specific method does not have to support different
> devices with different requirements whereas DT does.

So, it is more like a vendor specific property (e.g. "renesas,
mmc-driver-type")? Sorry, I don't know much about ACPI.

> >                                                  This is a largely
> > reduced encoding of what you proposed in 2015 [1] but may be more
> > pragmatic for soldered on-board devices working on their max speeds with
> > fixed voltages and frequencies? Or did I get something wrong?
> 
> What I proposed was being forced on me by the requirement to provide a
> solution that could meet any conceivable need.  That gets over-complicated.

Yeah, that became pretty clear.

> But as you say, in practice people are probably only interested in providing
> one value for the max speed / frequency.

OK. Thanks for your answers! Much appreciated.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 07/25] mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices
  2017-04-19 12:24       ` Wolfram Sang
@ 2017-04-19 12:58         ` Adrian Hunter
  0 siblings, 0 replies; 36+ messages in thread
From: Adrian Hunter @ 2017-04-19 12:58 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ulf Hansson, linux-mmc, Al Cooper, Jaedon Shin, Haibo Chen,
	Dong Aisheng, Shawn Lin, Douglas Anderson, Zach Brown,
	Ludovic Desroches, Jisheng Zhang, Yangbo Lu, Jaehoon Chung,
	Weijun Yang, Barry Song, Peter Griffin, Lee Jones, Jon Hunter,
	Harjani Ritesh

On 19/04/17 15:24, Wolfram Sang wrote:
> 
>>> do you think it makes sense then to have a similar encoded value from DT
>>> (maybe "mmc-fixed-driver-type-<n>" with n=0..4)?
>>
>> The _DSM, being a device-specific method does not have to support different
>> devices with different requirements whereas DT does.
> 
> So, it is more like a vendor specific property (e.g. "renesas,
> mmc-driver-type")? Sorry, I don't know much about ACPI.

Yes, it is effectively vendor-specific in this case.


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2017-04-19 13:04 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-20 17:50 [PATCH 00/25] sdhci patches Adrian Hunter
2017-03-20 17:50 ` [PATCH 01/25] mmc: sdhci: Do not disable interrupts while waiting for clock Adrian Hunter
2017-03-20 17:50 ` [PATCH 02/25] mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power Adrian Hunter
2017-03-20 17:50 ` [PATCH 03/25] mmc: sdhci: Optimize delay loops Adrian Hunter
2017-03-20 17:50 ` [PATCH 04/25] mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm Adrian Hunter
2017-03-20 17:50 ` [PATCH 05/25] mmc: sdhci-pci: Let devices define their own private data Adrian Hunter
2017-03-20 17:50 ` [PATCH 06/25] mmc: sdhci-pci: Don't re-tune with runtime pm for some Intel devices Adrian Hunter
2017-03-20 17:50 ` [PATCH 07/25] mmc: sdhci-pci: Use ACPI DSM to get driver strength " Adrian Hunter
2017-04-04  8:48   ` Wolfram Sang
2017-04-19  8:50     ` Adrian Hunter
2017-04-19 12:24       ` Wolfram Sang
2017-04-19 12:58         ` Adrian Hunter
2017-03-20 17:50 ` [PATCH 08/25] mmc: sdhci: Remove ->select_drive_strength() callback Adrian Hunter
2017-03-20 17:50 ` [PATCH 09/25] mmc: sdhci: Do not use spin lock in set_ios paths Adrian Hunter
2017-03-20 17:50 ` [PATCH 10/25] mmc: sdhci: Reduce spin lock usage in sdhci_execute_tuning Adrian Hunter
2017-03-20 17:50 ` [PATCH 11/25] mmc: sdhci: Improve debug print format Adrian Hunter
2017-03-20 17:50 ` [PATCH 12/25] mmc: sdhci: Add response register to register dump Adrian Hunter
2017-03-20 17:50 ` [PATCH 13/25] mmc: sdhci: Use sdhci_readl() not readl() in sdhci_dumpregs() Adrian Hunter
2017-03-20 17:50 ` [PATCH 14/25] mmc: sdhci: Improve register dump print format Adrian Hunter
2017-03-20 17:50 ` [PATCH 15/25] mmc: sdhci: Export sdhci_dumpregs Adrian Hunter
2017-03-20 17:50 ` [PATCH 16/25] mmc: sdhci: Get rid of 'extern' in header file Adrian Hunter
2017-03-20 17:50 ` [PATCH 17/25] mmc: sdhci: Add sdhci_cleanup_host Adrian Hunter
2017-03-20 17:50 ` [PATCH 18/25] mmc: sdhci: Factor out sdhci_set_default_irqs Adrian Hunter
2017-03-20 17:50 ` [PATCH 19/25] mmc: sdhci: Add CQE support Adrian Hunter
2017-03-20 17:50 ` [PATCH 20/25] mmc: sdhci-pci: Let devices define how to add the host Adrian Hunter
2017-03-20 17:50 ` [PATCH 21/25] mmc: sdhci-pci: Do not use suspend/resume callbacks with runtime pm Adrian Hunter
2017-03-20 17:50 ` [PATCH 22/25] mmc: sdhci-pci: Conditionally compile pm sleep functions Adrian Hunter
2017-03-20 17:50 ` [PATCH 23/25] mmc: sdhci-pci: Let suspend/resume callbacks replace default callbacks Adrian Hunter
2017-03-20 17:50 ` [PATCH 24/25] mmc: sdhci-pci: Add runtime suspend/resume callbacks Adrian Hunter
2017-03-20 17:50 ` [PATCH 25/25] mmc: sdhci-pci: Move a function to avoid later forward declaration Adrian Hunter
2017-03-21 10:01 ` [PATCH 00/25] sdhci patches Ulf Hansson
2017-03-21 11:00 ` Lee Jones
2017-03-21 11:54   ` Adrian Hunter
2017-03-21 15:14     ` Lee Jones
2017-03-21 15:17       ` Lee Jones
2017-03-22  8:47 ` Ludovic Desroches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.