linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning()
@ 2014-12-01 16:02 Ulf Hansson
  2014-12-01 16:02 ` [PATCH 1/4] mmc: sdhci-esdhc-imx: Convert " Ulf Hansson
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Ulf Hansson @ 2014-12-01 16:02 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Chris Ball
  Cc: Seungwon Jeon, Jaehoon Chung, Shawn Guo, Sascha Hauer,
	Aisheng Dong, Stephen Boyd, Minda Chen, Barry Song

Due to commit "mmc: core: add core-level function for sending tuning commands",
the mmc core provides an API to send the tuning command and as well compare the
response pattern.

Convert those host drivers which implemented their own version for how to deal
with this, into using the new API.

Note, this patchset has currently only been compile tested. Any help in testing
on HW is higly appreciated.


Ulf Hansson (4):
  mmc: sdhci-esdhc-imx: Convert to mmc_send_tuning()
  mmc: sdhci-msm: Convert to mmc_send_tuning()
  mmc: dw_mmc: Convert to mmc_send_tuning()
  mmc: core: Make tuning block patterns static

 drivers/mmc/core/mmc.c             | 32 ------------------
 drivers/mmc/core/mmc_ops.c         | 30 +++++++++++++++++
 drivers/mmc/host/dw_mmc-exynos.c   | 49 +++------------------------
 drivers/mmc/host/dw_mmc.c          | 22 +-----------
 drivers/mmc/host/dw_mmc.h          |  8 +----
 drivers/mmc/host/sdhci-esdhc-imx.c | 68 ++------------------------------------
 drivers/mmc/host/sdhci-msm.c       | 50 ++++------------------------
 include/linux/mmc/mmc.h            |  5 ---
 8 files changed, 46 insertions(+), 218 deletions(-)

-- 
1.9.1


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

* [PATCH 1/4] mmc: sdhci-esdhc-imx: Convert to mmc_send_tuning()
  2014-12-01 16:02 [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning() Ulf Hansson
@ 2014-12-01 16:02 ` Ulf Hansson
  2014-12-05 11:11   ` Dong Aisheng
  2014-12-01 16:02 ` [PATCH 2/4] mmc: sdhci-msm: " Ulf Hansson
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Ulf Hansson @ 2014-12-01 16:02 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Chris Ball
  Cc: Seungwon Jeon, Jaehoon Chung, Shawn Guo, Sascha Hauer,
	Aisheng Dong, Stephen Boyd, Minda Chen, Barry Song

Instead of having a local function taking care of sending the tuning
command, let's use the common mmc_send_tuning() API provided by the mmc
core. In this way the request will be handled as any other request by
sdhci core.

As an effect of this change, the pm_runtime_get_sync() call at
esdhc_prepare_tuning() isn't needed any more.

This patch will also introduce another change in behavior, since before
the response pattern to the tuning command wasn't verified by
sdhci-esdhc-imx. The mmc_send_tuning() does that.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 68 ++------------------------------------
 1 file changed, 3 insertions(+), 65 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 0135f00..a33d64c 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -65,8 +65,6 @@
 /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */
 #define ESDHC_TUNING_START_TAP		0x1
 
-#define ESDHC_TUNING_BLOCK_PATTERN_LEN	64
-
 /* pinctrl state */
 #define ESDHC_PINCTRL_STATE_100MHZ	"state_100mhz"
 #define ESDHC_PINCTRL_STATE_200MHZ	"state_200mhz"
@@ -692,8 +690,6 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
 	/* FIXME: delay a bit for card to be ready for next tuning due to errors */
 	mdelay(1);
 
-	/* This is balanced by the runtime put in sdhci_tasklet_finish */
-	pm_runtime_get_sync(host->mmc->parent);
 	reg = readl(host->ioaddr + ESDHC_MIX_CTRL);
 	reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL |
 			ESDHC_MIX_CTRL_FBCLK_SEL;
@@ -704,54 +700,6 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
 			val, readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS));
 }
 
-static void esdhc_request_done(struct mmc_request *mrq)
-{
-	complete(&mrq->completion);
-}
-
-static int esdhc_send_tuning_cmd(struct sdhci_host *host, u32 opcode,
-				 struct scatterlist *sg)
-{
-	struct mmc_command cmd = {0};
-	struct mmc_request mrq = {NULL};
-	struct mmc_data data = {0};
-
-	cmd.opcode = opcode;
-	cmd.arg = 0;
-	cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
-
-	data.blksz = ESDHC_TUNING_BLOCK_PATTERN_LEN;
-	data.blocks = 1;
-	data.flags = MMC_DATA_READ;
-	data.sg = sg;
-	data.sg_len = 1;
-
-	mrq.cmd = &cmd;
-	mrq.cmd->mrq = &mrq;
-	mrq.data = &data;
-	mrq.data->mrq = &mrq;
-	mrq.cmd->data = mrq.data;
-
-	mrq.done = esdhc_request_done;
-	init_completion(&(mrq.completion));
-
-	spin_lock_irq(&host->lock);
-	host->mrq = &mrq;
-
-	sdhci_send_command(host, mrq.cmd);
-
-	spin_unlock_irq(&host->lock);
-
-	wait_for_completion(&mrq.completion);
-
-	if (cmd.error)
-		return cmd.error;
-	if (data.error)
-		return data.error;
-
-	return 0;
-}
-
 static void esdhc_post_tuning(struct sdhci_host *host)
 {
 	u32 reg;
@@ -763,21 +711,13 @@ static void esdhc_post_tuning(struct sdhci_host *host)
 
 static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
 {
-	struct scatterlist sg;
-	char *tuning_pattern;
 	int min, max, avg, ret;
 
-	tuning_pattern = kmalloc(ESDHC_TUNING_BLOCK_PATTERN_LEN, GFP_KERNEL);
-	if (!tuning_pattern)
-		return -ENOMEM;
-
-	sg_init_one(&sg, tuning_pattern, ESDHC_TUNING_BLOCK_PATTERN_LEN);
-
 	/* find the mininum delay first which can pass tuning */
 	min = ESDHC_TUNE_CTRL_MIN;
 	while (min < ESDHC_TUNE_CTRL_MAX) {
 		esdhc_prepare_tuning(host, min);
-		if (!esdhc_send_tuning_cmd(host, opcode, &sg))
+		if (!mmc_send_tuning(host->mmc->card))
 			break;
 		min += ESDHC_TUNE_CTRL_STEP;
 	}
@@ -786,7 +726,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
 	max = min + ESDHC_TUNE_CTRL_STEP;
 	while (max < ESDHC_TUNE_CTRL_MAX) {
 		esdhc_prepare_tuning(host, max);
-		if (esdhc_send_tuning_cmd(host, opcode, &sg)) {
+		if (mmc_send_tuning(host->mmc->card)) {
 			max -= ESDHC_TUNE_CTRL_STEP;
 			break;
 		}
@@ -796,11 +736,9 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
 	/* use average delay to get the best timing */
 	avg = (min + max) / 2;
 	esdhc_prepare_tuning(host, avg);
-	ret = esdhc_send_tuning_cmd(host, opcode, &sg);
+	ret = mmc_send_tuning(host->mmc->card);
 	esdhc_post_tuning(host);
 
-	kfree(tuning_pattern);
-
 	dev_dbg(mmc_dev(host->mmc), "tunning %s at 0x%x ret %d\n",
 		ret ? "failed" : "passed", avg, ret);
 
-- 
1.9.1


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

* [PATCH 2/4] mmc: sdhci-msm: Convert to mmc_send_tuning()
  2014-12-01 16:02 [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning() Ulf Hansson
  2014-12-01 16:02 ` [PATCH 1/4] mmc: sdhci-esdhc-imx: Convert " Ulf Hansson
@ 2014-12-01 16:02 ` Ulf Hansson
  2014-12-01 16:02 ` [PATCH 3/4] mmc: dw_mmc: " Ulf Hansson
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2014-12-01 16:02 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Chris Ball
  Cc: Seungwon Jeon, Jaehoon Chung, Shawn Guo, Sascha Hauer,
	Aisheng Dong, Stephen Boyd, Minda Chen, Barry Song

Instead of having a local hack taking care of sending the tuning
command and as well to verify the response pattern, let's convert to
the common mmc_send_tuning() API instead.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/sdhci-msm.c | 50 +++++++-------------------------------------
 1 file changed, 7 insertions(+), 43 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 3080438..592e0a1 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -339,9 +339,7 @@ static int msm_init_cm_dll(struct sdhci_host *host)
 static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
 {
 	int tuning_seq_cnt = 3;
-	u8 phase, *data_buf, tuned_phases[16], tuned_phase_cnt = 0;
-	const u8 *tuning_block_pattern = tuning_blk_pattern_4bit;
-	int size = sizeof(tuning_blk_pattern_4bit);
+	u8 phase, tuned_phases[16], tuned_phase_cnt = 0;
 	int rc;
 	struct mmc_host *mmc = host->mmc;
 	struct mmc_ios ios = host->mmc->ios;
@@ -355,53 +353,21 @@ static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
 	      (ios.timing == MMC_TIMING_UHS_SDR104)))
 		return 0;
 
-	if ((opcode == MMC_SEND_TUNING_BLOCK_HS200) &&
-	    (mmc->ios.bus_width == MMC_BUS_WIDTH_8)) {
-		tuning_block_pattern = tuning_blk_pattern_8bit;
-		size = sizeof(tuning_blk_pattern_8bit);
-	}
-
-	data_buf = kmalloc(size, GFP_KERNEL);
-	if (!data_buf)
-		return -ENOMEM;
-
 retry:
 	/* First of all reset the tuning block */
 	rc = msm_init_cm_dll(host);
 	if (rc)
-		goto out;
+		return rc;
 
 	phase = 0;
 	do {
-		struct mmc_command cmd = { 0 };
-		struct mmc_data data = { 0 };
-		struct mmc_request mrq = {
-			.cmd = &cmd,
-			.data = &data
-		};
-		struct scatterlist sg;
-
 		/* Set the phase in delay line hw block */
 		rc = msm_config_cm_dll_phase(host, phase);
 		if (rc)
-			goto out;
+			return rc;
 
-		cmd.opcode = opcode;
-		cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
-
-		data.blksz = size;
-		data.blocks = 1;
-		data.flags = MMC_DATA_READ;
-		data.timeout_ns = NSEC_PER_SEC;	/* 1 second */
-
-		data.sg = &sg;
-		data.sg_len = 1;
-		sg_init_one(&sg, data_buf, size);
-		memset(data_buf, 0, size);
-		mmc_wait_for_req(mmc, &mrq);
-
-		if (!cmd.error && !data.error &&
-		    !memcmp(data_buf, tuning_block_pattern, size)) {
+		rc = mmc_send_tuning(mmc->card);
+		if (!rc) {
 			/* Tuning is successful at this tuning point */
 			tuned_phases[tuned_phase_cnt++] = phase;
 			dev_dbg(mmc_dev(mmc), "%s: Found good phase = %d\n",
@@ -413,7 +379,7 @@ retry:
 		rc = msm_find_most_appropriate_phase(host, tuned_phases,
 						     tuned_phase_cnt);
 		if (rc < 0)
-			goto out;
+			return rc;
 		else
 			phase = rc;
 
@@ -423,7 +389,7 @@ retry:
 		 */
 		rc = msm_config_cm_dll_phase(host, phase);
 		if (rc)
-			goto out;
+			return rc;
 		dev_dbg(mmc_dev(mmc), "%s: Setting the tuning phase to %d\n",
 			 mmc_hostname(mmc), phase);
 	} else {
@@ -435,8 +401,6 @@ retry:
 		rc = -EIO;
 	}
 
-out:
-	kfree(data_buf);
 	return rc;
 }
 
-- 
1.9.1


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

* [PATCH 3/4] mmc: dw_mmc: Convert to mmc_send_tuning()
  2014-12-01 16:02 [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning() Ulf Hansson
  2014-12-01 16:02 ` [PATCH 1/4] mmc: sdhci-esdhc-imx: Convert " Ulf Hansson
  2014-12-01 16:02 ` [PATCH 2/4] mmc: sdhci-msm: " Ulf Hansson
@ 2014-12-01 16:02 ` Ulf Hansson
  2014-12-01 16:02 ` [PATCH 4/4] mmc: core: Make tuning block patterns static Ulf Hansson
  2014-12-04 20:50 ` [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning() Stephen Boyd
  4 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2014-12-01 16:02 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Chris Ball
  Cc: Seungwon Jeon, Jaehoon Chung, Shawn Guo, Sascha Hauer,
	Aisheng Dong, Stephen Boyd, Minda Chen, Barry Song

Instead of having a local hack taking care of sending the tuning
command and as well to verify the response pattern, let's convert to
the common mmc_send_tuning() API.

This change affects the Exynos variant, since it's the only one which
support the dw_mmc's ->execute_tuning() callback.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/dw_mmc-exynos.c | 49 ++++------------------------------------
 drivers/mmc/host/dw_mmc.c        | 22 +-----------------
 drivers/mmc/host/dw_mmc.h        |  8 +------
 3 files changed, 6 insertions(+), 73 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
index 509365c..0a23edf 100644
--- a/drivers/mmc/host/dw_mmc-exynos.c
+++ b/drivers/mmc/host/dw_mmc-exynos.c
@@ -375,64 +375,24 @@ out:
 	return loc;
 }
 
-static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode,
-					struct dw_mci_tuning_data *tuning_data)
+static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot)
 {
 	struct dw_mci *host = slot->host;
 	struct mmc_host *mmc = slot->mmc;
-	const u8 *blk_pattern = tuning_data->blk_pattern;
-	u8 *blk_test;
-	unsigned int blksz = tuning_data->blksz;
 	u8 start_smpl, smpl, candiates = 0;
 	s8 found = -1;
 	int ret = 0;
 
-	blk_test = kmalloc(blksz, GFP_KERNEL);
-	if (!blk_test)
-		return -ENOMEM;
-
 	start_smpl = dw_mci_exynos_get_clksmpl(host);
 
 	do {
-		struct mmc_request mrq = {NULL};
-		struct mmc_command cmd = {0};
-		struct mmc_command stop = {0};
-		struct mmc_data data = {0};
-		struct scatterlist sg;
-
-		cmd.opcode = opcode;
-		cmd.arg = 0;
-		cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
-
-		stop.opcode = MMC_STOP_TRANSMISSION;
-		stop.arg = 0;
-		stop.flags = MMC_RSP_R1B | MMC_CMD_AC;
-
-		data.blksz = blksz;
-		data.blocks = 1;
-		data.flags = MMC_DATA_READ;
-		data.sg = &sg;
-		data.sg_len = 1;
-
-		sg_init_one(&sg, blk_test, blksz);
-		mrq.cmd = &cmd;
-		mrq.stop = &stop;
-		mrq.data = &data;
-		host->mrq = &mrq;
-
 		mci_writel(host, TMOUT, ~0);
 		smpl = dw_mci_exynos_move_next_clksmpl(host);
 
-		mmc_wait_for_req(mmc, &mrq);
+		ret = mmc_send_tuning(mmc->card);
+		if (!ret)
+			candiates |= (1 << smpl);
 
-		if (!cmd.error && !data.error) {
-			if (!memcmp(blk_pattern, blk_test, blksz))
-				candiates |= (1 << smpl);
-		} else {
-			dev_dbg(host->dev,
-				"Tuning error: cmd.error:%d, data.error:%d\n",
-				cmd.error, data.error);
-		}
 	} while (start_smpl != smpl);
 
 	found = dw_mci_exynos_get_best_clksmpl(candiates);
@@ -441,7 +401,6 @@ static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode,
 	else
 		ret = -EIO;
 
-	kfree(blk_test);
 	return ret;
 }
 
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 67c0451..265bb28 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1299,30 +1299,10 @@ static int dw_mci_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	struct dw_mci_slot *slot = mmc_priv(mmc);
 	struct dw_mci *host = slot->host;
 	const struct dw_mci_drv_data *drv_data = host->drv_data;
-	struct dw_mci_tuning_data tuning_data;
 	int err = -ENOSYS;
 
-	if (opcode == MMC_SEND_TUNING_BLOCK_HS200) {
-		if (mmc->ios.bus_width == MMC_BUS_WIDTH_8) {
-			tuning_data.blk_pattern = tuning_blk_pattern_8bit;
-			tuning_data.blksz = sizeof(tuning_blk_pattern_8bit);
-		} else if (mmc->ios.bus_width == MMC_BUS_WIDTH_4) {
-			tuning_data.blk_pattern = tuning_blk_pattern_4bit;
-			tuning_data.blksz = sizeof(tuning_blk_pattern_4bit);
-		} else {
-			return -EINVAL;
-		}
-	} else if (opcode == MMC_SEND_TUNING_BLOCK) {
-		tuning_data.blk_pattern = tuning_blk_pattern_4bit;
-		tuning_data.blksz = sizeof(tuning_blk_pattern_4bit);
-	} else {
-		dev_err(host->dev,
-			"Undefined command(%d) for tuning\n", opcode);
-		return -EINVAL;
-	}
-
 	if (drv_data && drv_data->execute_tuning)
-		err = drv_data->execute_tuning(slot, opcode, &tuning_data);
+		err = drv_data->execute_tuning(slot);
 	return err;
 }
 
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index 0d0f7a2..c1f4557 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -248,11 +248,6 @@ struct dw_mci_slot {
 	int			sdio_id;
 };
 
-struct dw_mci_tuning_data {
-	const u8 *blk_pattern;
-	unsigned int blksz;
-};
-
 /**
  * dw_mci driver data - dw-mshc implementation specific driver data.
  * @caps: mmc subsystem specified capabilities of the controller(s).
@@ -274,7 +269,6 @@ struct dw_mci_drv_data {
 	void		(*prepare_command)(struct dw_mci *host, u32 *cmdr);
 	void		(*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
 	int		(*parse_dt)(struct dw_mci *host);
-	int		(*execute_tuning)(struct dw_mci_slot *slot, u32 opcode,
-					struct dw_mci_tuning_data *tuning_data);
+	int		(*execute_tuning)(struct dw_mci_slot *slot);
 };
 #endif /* _DW_MMC_H_ */
-- 
1.9.1


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

* [PATCH 4/4] mmc: core: Make tuning block patterns static
  2014-12-01 16:02 [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning() Ulf Hansson
                   ` (2 preceding siblings ...)
  2014-12-01 16:02 ` [PATCH 3/4] mmc: dw_mmc: " Ulf Hansson
@ 2014-12-01 16:02 ` Ulf Hansson
  2014-12-04 20:50 ` [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning() Stephen Boyd
  4 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2014-12-01 16:02 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Chris Ball
  Cc: Seungwon Jeon, Jaehoon Chung, Shawn Guo, Sascha Hauer,
	Aisheng Dong, Stephen Boyd, Minda Chen, Barry Song

Since previous patches removed the need for the tuning block patterns
to be exported, let's move them close to the mmc_send_tuning() API.

Those are now intended to be used only by the mmc core.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/mmc.c     | 32 --------------------------------
 drivers/mmc/core/mmc_ops.c | 30 ++++++++++++++++++++++++++++++
 include/linux/mmc/mmc.h    |  5 -----
 3 files changed, 30 insertions(+), 37 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 02ad792..ea96705 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1155,38 +1155,6 @@ bus_speed:
 	return err;
 }
 
-const u8 tuning_blk_pattern_4bit[MMC_TUNING_BLK_PATTERN_4BIT_SIZE] = {
-	0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc,
-	0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef,
-	0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb,
-	0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef,
-	0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c,
-	0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee,
-	0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff,
-	0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde,
-};
-EXPORT_SYMBOL(tuning_blk_pattern_4bit);
-
-const u8 tuning_blk_pattern_8bit[MMC_TUNING_BLK_PATTERN_8BIT_SIZE] = {
-	0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
-	0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc,
-	0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff,
-	0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff,
-	0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd,
-	0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb,
-	0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff,
-	0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff,
-	0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-	0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc,
-	0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff,
-	0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee,
-	0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd,
-	0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff,
-	0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff,
-	0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee,
-};
-EXPORT_SYMBOL(tuning_blk_pattern_8bit);
-
 /*
  * Execute tuning sequence to seek the proper bus operating
  * conditions for HS200 and HS400, which sends CMD21 to the device.
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 12b2a32..baa526d 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -23,6 +23,36 @@
 
 #define MMC_OPS_TIMEOUT_MS	(10 * 60 * 1000) /* 10 minute timeout */
 
+static const u8 tuning_blk_pattern_4bit[] = {
+	0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc,
+	0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef,
+	0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb,
+	0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef,
+	0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c,
+	0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee,
+	0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff,
+	0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde,
+};
+
+static const u8 tuning_blk_pattern_8bit[] = {
+	0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
+	0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc,
+	0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff,
+	0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff,
+	0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd,
+	0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb,
+	0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff,
+	0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff,
+	0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
+	0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc,
+	0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff,
+	0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee,
+	0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd,
+	0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff,
+	0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff,
+	0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee,
+};
+
 static inline int __mmc_send_status(struct mmc_card *card, u32 *status,
 				    bool ignore_crc)
 {
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 49ad7a9..fb97b5c 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -53,11 +53,6 @@
 #define MMC_SEND_TUNING_BLOCK    19   /* adtc                    R1  */
 #define MMC_SEND_TUNING_BLOCK_HS200	21	/* adtc R1  */
 
-#define MMC_TUNING_BLK_PATTERN_4BIT_SIZE	 64
-#define MMC_TUNING_BLK_PATTERN_8BIT_SIZE	128
-extern const u8 tuning_blk_pattern_4bit[MMC_TUNING_BLK_PATTERN_4BIT_SIZE];
-extern const u8 tuning_blk_pattern_8bit[MMC_TUNING_BLK_PATTERN_8BIT_SIZE];
-
   /* class 3 */
 #define MMC_WRITE_DAT_UNTIL_STOP 20   /* adtc [31:0] data addr   R1  */
 
-- 
1.9.1


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

* Re: [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning()
  2014-12-01 16:02 [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning() Ulf Hansson
                   ` (3 preceding siblings ...)
  2014-12-01 16:02 ` [PATCH 4/4] mmc: core: Make tuning block patterns static Ulf Hansson
@ 2014-12-04 20:50 ` Stephen Boyd
  2014-12-05 10:51   ` Dong Aisheng
  4 siblings, 1 reply; 9+ messages in thread
From: Stephen Boyd @ 2014-12-04 20:50 UTC (permalink / raw)
  To: Ulf Hansson, linux-mmc, Chris Ball
  Cc: Seungwon Jeon, Jaehoon Chung, Shawn Guo, Sascha Hauer,
	Aisheng Dong, Minda Chen, Barry Song

On 12/01/2014 08:02 AM, Ulf Hansson wrote:
> Due to commit "mmc: core: add core-level function for sending tuning commands",
> the mmc core provides an API to send the tuning command and as well compare the
> response pattern.
>
> Convert those host drivers which implemented their own version for how to deal
> with this, into using the new API.
>
> Note, this patchset has currently only been compile tested. Any help in testing
> on HW is higly appreciated.

I get a crash on boot with these patches. I think it's because
host->card is not assigned until after we do the tuning in
mmc_init_card(). I took these patches and applied them on top of the
patch you mentioned above. I wonder why the mmc_send_tuning() function
doesn't take the mmc_host structure instead? The card structure is only
used to get the host anyway.

[    1.199844] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[    1.199870] pgd = c0204000
[    1.207008] [00000000] *pgd=00000000
[    1.212909] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[    1.213153] Modules linked in:
[    1.221397] CPU: 0 PID: 53 Comm: kworker/u8:1 Not tainted 3.18.0-rc4-00116-g5d5e4adeefc9 #114
[    1.221500] Workqueue: kmmcd mmc_rescan
[    1.233632] task: ee368e40 ti: ee3d2000 task.ti: ee3d2000
[    1.233819] PC is at mmc_send_tuning+0x90/0x1b4
[    1.239201] LR is at sdhci_msm_execute_tuning+0x1ec/0x3c8
[    1.243536] pc : [<c059f900>]    lr : [<c05b2c04>]    psr: 60000113
[    1.243536] sp : ee3d3c90  ip : 00000000  fp : 082a7440
[    1.249099] r10: ee3cb280  r9 : 07735940  r8 : c0a03d40
[    1.260375] r7 : ee3cb000  r6 : 00000000  r5 : 00000000  r4 : 00000000
[    1.265585] r3 : 00000000  r2 : 00000000  r1 : 60000113  r0 : 00000000
[    1.272183] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
[    1.278695] Control: 10c5787d  Table: 0020406a  DAC: 00000015
[    1.285898] Process kworker/u8:1 (pid: 53, stack limit = 0xee3d2240)
[    1.291800] Stack: (0xee3d3c90 to 0xee3d4000)
[    1.298223] 3c80:                                     00000000 c09a4a00 2de1c000 c0a28300
[    1.302482] 3ca0: 00000000 c0241668 c09a25d0 00000000 00000000 00000000 00000000 00000000
[    1.310642] 3cc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.318802] 3ce0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 c06eb3e8
[    1.326962] 3d00: 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.335120] 3d20: 00000000 00000000 00000000 00000000 00000000 00000000 f00bc900 00000000
[    1.343286] 3d40: 00000000 00000000 ee3cb000 c0a03d40 07735940 ee3cb280 082a7440 c05b2c04
[    1.351443] 3d60: 00000000 c09a8100 ee3cb2a8 00000003 08f0d180 09a7ec80 0a6e49c0 0b2564c0
[    1.359603] 3d80: 0bebc200 00020007 01090302 00000000 ee3cb000 c0599c60 00000001 ee3d2000
[    1.367761] 3da0: ee3d3db4 ee3cb000 a0000113 ee3cb2a8 00000015 ee3cb000 00000001 ee3cb000
[    1.375919] 3dc0: ee3cb000 c05af5a0 ffff8b60 c059fca8 00000000 ee3cb280 00000001 000000fa
[    1.384079] 3de0: 00000006 03b90201 00000800 00000000 00000001 ee3d2000 ee3d3e0c c0241544
[    1.392238] 3e00: ee3cb280 ee3cb16c ee3cb2a8 c09ae444 60000113 00000080 00000003 c05b0e1c
[    1.400408] 3e20: ee3cb000 ee3cb16c 0bebc200 ee29dc00 00000024 c06ed9e4 00008008 c059a3a8
[    1.400415] 3e40: 00008008 c059b1a0 c05ae3e8 ee3cb000 00000000 00000000 ee29dc00 ee3cb000
[    1.400422] 3e60: 00000001 ee3cb000 00000024 c059e438 000000fa 00000001 00000001 00000001
[    1.400428] 3e80: 0000fa03 3d640fff 00000000 00000020 c0ff8080 ed83a000 45010053 454d3136
[    1.400435] 3ea0: 4706309b d1d35000 00000000 ee3cb000 00000000 ee3cb000 00061a80 c075e2ec
[    1.400442] 3ec0: 00000000 ee223900 00000000 c059f354 00061a80 40ff8080 00000000 ee3cb1a4
[    1.400449] 3ee0: c075e2e0 c059c1ec ee3cb1a4 ee2ff500 ee00e400 c09fb8f8 ee3d2000 c0235800
[    1.400455] 3f00: 00000001 ee089ed8 00000000 00000000 00000001 ee00e414 ee3d2000 ee3d2000
[    1.400462] 3f20: ee2ff518 ee2ff500 ee00e400 00000088 ee00e400 c0235b20 ee3d2000 00000000
[    1.400468] 3f40: 00000000 ee3a2840 00000000 ee2ff500 c0235ae4 00000000 00000000 00000000
[    1.400475] 3f60: 00000000 c023a30c a8a2aaaa 00000000 aaaaaaaa ee2ff500 00000000 00000000
[    1.400481] 3f80: ee3d3f80 ee3d3f80 00000000 00000000 ee3d3f90 ee3d3f90 ee3d3fac ee3a2840
[    1.400488] 3fa0: c023a240 00000000 00000000 c020f198 00000000 00000000 00000000 00000000
[    1.400494] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    1.400500] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 aa8a2aa8 80aaaaa0
[    1.400529] [<c059f900>] (mmc_send_tuning) from [<c05b2c04>] (sdhci_msm_execute_tuning+0x1ec/0x3c8)
[    1.400543] [<c05b2c04>] (sdhci_msm_execute_tuning) from [<c05af5a0>] (sdhci_execute_tuning+0x90/0x5b4)
[    1.400555] [<c05af5a0>] (sdhci_execute_tuning) from [<c059e438>] (mmc_init_card+0x8e0/0x15fc)
[    1.400567] [<c059e438>] (mmc_init_card) from [<c059f354>] (mmc_attach_mmc+0x90/0x15c)
[    1.400578] [<c059f354>] (mmc_attach_mmc) from [<c059c1ec>] (mmc_rescan+0x29c/0x2e4)
[    1.400593] [<c059c1ec>] (mmc_rescan) from [<c0235800>] (process_one_work+0x140/0x3f0)
[    1.400605] [<c0235800>] (process_one_work) from [<c0235b20>] (worker_thread+0x3c/0x4b0)
[    1.400615] [<c0235b20>] (worker_thread) from [<c023a30c>] (kthread+0xcc/0xe8)
[    1.400629] [<c023a30c>] (kthread) from [<c020f198>] (ret_from_fork+0x14/0x3c)
[    1.400637] Code: e58d305c e58d3060 e58d3064 e58d3068 (e5905000)


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


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

* Re: [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning()
  2014-12-04 20:50 ` [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning() Stephen Boyd
@ 2014-12-05 10:51   ` Dong Aisheng
  0 siblings, 0 replies; 9+ messages in thread
From: Dong Aisheng @ 2014-12-05 10:51 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Ulf Hansson, linux-mmc, Chris Ball, Seungwon Jeon, Jaehoon Chung,
	Shawn Guo, Sascha Hauer, Minda Chen, Barry Song

On Thu, Dec 04, 2014 at 12:50:02PM -0800, Stephen Boyd wrote:
> On 12/01/2014 08:02 AM, Ulf Hansson wrote:
> > Due to commit "mmc: core: add core-level function for sending tuning commands",
> > the mmc core provides an API to send the tuning command and as well compare the
> > response pattern.
> >
> > Convert those host drivers which implemented their own version for how to deal
> > with this, into using the new API.
> >
> > Note, this patchset has currently only been compile tested. Any help in testing
> > on HW is higly appreciated.
> 
> I get a crash on boot with these patches. I think it's because
> host->card is not assigned until after we do the tuning in
> mmc_init_card(). I took these patches and applied them on top of the
> patch you mentioned above. I wonder why the mmc_send_tuning() function
> doesn't take the mmc_host structure instead? The card structure is only
> used to get the host anyway.
> 

I met the same crash with it.

Regards
Dong Aisheng

> [    1.199844] Unable to handle kernel NULL pointer dereference at virtual address 00000000
> [    1.199870] pgd = c0204000
> [    1.207008] [00000000] *pgd=00000000
> [    1.212909] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
> [    1.213153] Modules linked in:
> [    1.221397] CPU: 0 PID: 53 Comm: kworker/u8:1 Not tainted 3.18.0-rc4-00116-g5d5e4adeefc9 #114
> [    1.221500] Workqueue: kmmcd mmc_rescan
> [    1.233632] task: ee368e40 ti: ee3d2000 task.ti: ee3d2000
> [    1.233819] PC is at mmc_send_tuning+0x90/0x1b4
> [    1.239201] LR is at sdhci_msm_execute_tuning+0x1ec/0x3c8
> [    1.243536] pc : [<c059f900>]    lr : [<c05b2c04>]    psr: 60000113
> [    1.243536] sp : ee3d3c90  ip : 00000000  fp : 082a7440
> [    1.249099] r10: ee3cb280  r9 : 07735940  r8 : c0a03d40
> [    1.260375] r7 : ee3cb000  r6 : 00000000  r5 : 00000000  r4 : 00000000
> [    1.265585] r3 : 00000000  r2 : 00000000  r1 : 60000113  r0 : 00000000
> [    1.272183] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
> [    1.278695] Control: 10c5787d  Table: 0020406a  DAC: 00000015
> [    1.285898] Process kworker/u8:1 (pid: 53, stack limit = 0xee3d2240)
> [    1.291800] Stack: (0xee3d3c90 to 0xee3d4000)
> [    1.298223] 3c80:                                     00000000 c09a4a00 2de1c000 c0a28300
> [    1.302482] 3ca0: 00000000 c0241668 c09a25d0 00000000 00000000 00000000 00000000 00000000
> [    1.310642] 3cc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> [    1.318802] 3ce0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 c06eb3e8
> [    1.326962] 3d00: 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> [    1.335120] 3d20: 00000000 00000000 00000000 00000000 00000000 00000000 f00bc900 00000000
> [    1.343286] 3d40: 00000000 00000000 ee3cb000 c0a03d40 07735940 ee3cb280 082a7440 c05b2c04
> [    1.351443] 3d60: 00000000 c09a8100 ee3cb2a8 00000003 08f0d180 09a7ec80 0a6e49c0 0b2564c0
> [    1.359603] 3d80: 0bebc200 00020007 01090302 00000000 ee3cb000 c0599c60 00000001 ee3d2000
> [    1.367761] 3da0: ee3d3db4 ee3cb000 a0000113 ee3cb2a8 00000015 ee3cb000 00000001 ee3cb000
> [    1.375919] 3dc0: ee3cb000 c05af5a0 ffff8b60 c059fca8 00000000 ee3cb280 00000001 000000fa
> [    1.384079] 3de0: 00000006 03b90201 00000800 00000000 00000001 ee3d2000 ee3d3e0c c0241544
> [    1.392238] 3e00: ee3cb280 ee3cb16c ee3cb2a8 c09ae444 60000113 00000080 00000003 c05b0e1c
> [    1.400408] 3e20: ee3cb000 ee3cb16c 0bebc200 ee29dc00 00000024 c06ed9e4 00008008 c059a3a8
> [    1.400415] 3e40: 00008008 c059b1a0 c05ae3e8 ee3cb000 00000000 00000000 ee29dc00 ee3cb000
> [    1.400422] 3e60: 00000001 ee3cb000 00000024 c059e438 000000fa 00000001 00000001 00000001
> [    1.400428] 3e80: 0000fa03 3d640fff 00000000 00000020 c0ff8080 ed83a000 45010053 454d3136
> [    1.400435] 3ea0: 4706309b d1d35000 00000000 ee3cb000 00000000 ee3cb000 00061a80 c075e2ec
> [    1.400442] 3ec0: 00000000 ee223900 00000000 c059f354 00061a80 40ff8080 00000000 ee3cb1a4
> [    1.400449] 3ee0: c075e2e0 c059c1ec ee3cb1a4 ee2ff500 ee00e400 c09fb8f8 ee3d2000 c0235800
> [    1.400455] 3f00: 00000001 ee089ed8 00000000 00000000 00000001 ee00e414 ee3d2000 ee3d2000
> [    1.400462] 3f20: ee2ff518 ee2ff500 ee00e400 00000088 ee00e400 c0235b20 ee3d2000 00000000
> [    1.400468] 3f40: 00000000 ee3a2840 00000000 ee2ff500 c0235ae4 00000000 00000000 00000000
> [    1.400475] 3f60: 00000000 c023a30c a8a2aaaa 00000000 aaaaaaaa ee2ff500 00000000 00000000
> [    1.400481] 3f80: ee3d3f80 ee3d3f80 00000000 00000000 ee3d3f90 ee3d3f90 ee3d3fac ee3a2840
> [    1.400488] 3fa0: c023a240 00000000 00000000 c020f198 00000000 00000000 00000000 00000000
> [    1.400494] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> [    1.400500] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 aa8a2aa8 80aaaaa0
> [    1.400529] [<c059f900>] (mmc_send_tuning) from [<c05b2c04>] (sdhci_msm_execute_tuning+0x1ec/0x3c8)
> [    1.400543] [<c05b2c04>] (sdhci_msm_execute_tuning) from [<c05af5a0>] (sdhci_execute_tuning+0x90/0x5b4)
> [    1.400555] [<c05af5a0>] (sdhci_execute_tuning) from [<c059e438>] (mmc_init_card+0x8e0/0x15fc)
> [    1.400567] [<c059e438>] (mmc_init_card) from [<c059f354>] (mmc_attach_mmc+0x90/0x15c)
> [    1.400578] [<c059f354>] (mmc_attach_mmc) from [<c059c1ec>] (mmc_rescan+0x29c/0x2e4)
> [    1.400593] [<c059c1ec>] (mmc_rescan) from [<c0235800>] (process_one_work+0x140/0x3f0)
> [    1.400605] [<c0235800>] (process_one_work) from [<c0235b20>] (worker_thread+0x3c/0x4b0)
> [    1.400615] [<c0235b20>] (worker_thread) from [<c023a30c>] (kthread+0xcc/0xe8)
> [    1.400629] [<c023a30c>] (kthread) from [<c020f198>] (ret_from_fork+0x14/0x3c)
> [    1.400637] Code: e58d305c e58d3060 e58d3064 e58d3068 (e5905000)
> 
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

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

* Re: [PATCH 1/4] mmc: sdhci-esdhc-imx: Convert to mmc_send_tuning()
  2014-12-01 16:02 ` [PATCH 1/4] mmc: sdhci-esdhc-imx: Convert " Ulf Hansson
@ 2014-12-05 11:11   ` Dong Aisheng
  2014-12-05 12:02     ` Ulf Hansson
  0 siblings, 1 reply; 9+ messages in thread
From: Dong Aisheng @ 2014-12-05 11:11 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Chris Ball, Seungwon Jeon, Jaehoon Chung, Shawn Guo,
	Sascha Hauer, Stephen Boyd, Minda Chen, Barry Song

On Mon, Dec 01, 2014 at 05:02:07PM +0100, Ulf Hansson wrote:
> Instead of having a local function taking care of sending the tuning
> command, let's use the common mmc_send_tuning() API provided by the mmc
> core. In this way the request will be handled as any other request by
> sdhci core.
> 
> As an effect of this change, the pm_runtime_get_sync() call at
> esdhc_prepare_tuning() isn't needed any more.
> 
> This patch will also introduce another change in behavior, since before
> the response pattern to the tuning command wasn't verified by
> sdhci-esdhc-imx. The mmc_send_tuning() does that.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

After applying your mmc_send_tuning() fix patch and it's usage update,
i tested it worked well on a imx6dl sabreauto board.

So you can add my tag when update the patch.
Tested-by: Dong Aisheng <b29396@freescale.com>
Acked-by: Dong Aisheng <b29396@freescale.com>

Regards
Dong Aisheng

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index a33d64c..12711ab 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -717,7 +717,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
        min = ESDHC_TUNE_CTRL_MIN;
        while (min < ESDHC_TUNE_CTRL_MAX) {
                esdhc_prepare_tuning(host, min);
-               if (!mmc_send_tuning(host->mmc->card))
+               if (!mmc_send_tuning(host->mmc))
                        break;
                min += ESDHC_TUNE_CTRL_STEP;
        }
@@ -726,7 +726,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
        max = min + ESDHC_TUNE_CTRL_STEP;
        while (max < ESDHC_TUNE_CTRL_MAX) {
                esdhc_prepare_tuning(host, max);
-               if (mmc_send_tuning(host->mmc->card)) {
+               if (mmc_send_tuning(host->mmc)) {
                        max -= ESDHC_TUNE_CTRL_STEP;
                        break;
                }
@@ -736,7 +736,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
        /* use average delay to get the best timing */
        avg = (min + max) / 2;
        esdhc_prepare_tuning(host, avg);
-       ret = mmc_send_tuning(host->mmc->card);
+       ret = mmc_send_tuning(host->mmc);
        esdhc_post_tuning(host);

        dev_dbg(mmc_dev(host->mmc), "tunning %s at 0x%x ret %d\n",

> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 68 ++------------------------------------
>  1 file changed, 3 insertions(+), 65 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 0135f00..a33d64c 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -65,8 +65,6 @@
>  /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */
>  #define ESDHC_TUNING_START_TAP		0x1
>  
> -#define ESDHC_TUNING_BLOCK_PATTERN_LEN	64
> -
>  /* pinctrl state */
>  #define ESDHC_PINCTRL_STATE_100MHZ	"state_100mhz"
>  #define ESDHC_PINCTRL_STATE_200MHZ	"state_200mhz"
> @@ -692,8 +690,6 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
>  	/* FIXME: delay a bit for card to be ready for next tuning due to errors */
>  	mdelay(1);
>  
> -	/* This is balanced by the runtime put in sdhci_tasklet_finish */
> -	pm_runtime_get_sync(host->mmc->parent);
>  	reg = readl(host->ioaddr + ESDHC_MIX_CTRL);
>  	reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL |
>  			ESDHC_MIX_CTRL_FBCLK_SEL;
> @@ -704,54 +700,6 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
>  			val, readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS));
>  }
>  
> -static void esdhc_request_done(struct mmc_request *mrq)
> -{
> -	complete(&mrq->completion);
> -}
> -
> -static int esdhc_send_tuning_cmd(struct sdhci_host *host, u32 opcode,
> -				 struct scatterlist *sg)
> -{
> -	struct mmc_command cmd = {0};
> -	struct mmc_request mrq = {NULL};
> -	struct mmc_data data = {0};
> -
> -	cmd.opcode = opcode;
> -	cmd.arg = 0;
> -	cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
> -
> -	data.blksz = ESDHC_TUNING_BLOCK_PATTERN_LEN;
> -	data.blocks = 1;
> -	data.flags = MMC_DATA_READ;
> -	data.sg = sg;
> -	data.sg_len = 1;
> -
> -	mrq.cmd = &cmd;
> -	mrq.cmd->mrq = &mrq;
> -	mrq.data = &data;
> -	mrq.data->mrq = &mrq;
> -	mrq.cmd->data = mrq.data;
> -
> -	mrq.done = esdhc_request_done;
> -	init_completion(&(mrq.completion));
> -
> -	spin_lock_irq(&host->lock);
> -	host->mrq = &mrq;
> -
> -	sdhci_send_command(host, mrq.cmd);
> -
> -	spin_unlock_irq(&host->lock);
> -
> -	wait_for_completion(&mrq.completion);
> -
> -	if (cmd.error)
> -		return cmd.error;
> -	if (data.error)
> -		return data.error;
> -
> -	return 0;
> -}
> -
>  static void esdhc_post_tuning(struct sdhci_host *host)
>  {
>  	u32 reg;
> @@ -763,21 +711,13 @@ static void esdhc_post_tuning(struct sdhci_host *host)
>  
>  static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
>  {
> -	struct scatterlist sg;
> -	char *tuning_pattern;
>  	int min, max, avg, ret;
>  
> -	tuning_pattern = kmalloc(ESDHC_TUNING_BLOCK_PATTERN_LEN, GFP_KERNEL);
> -	if (!tuning_pattern)
> -		return -ENOMEM;
> -
> -	sg_init_one(&sg, tuning_pattern, ESDHC_TUNING_BLOCK_PATTERN_LEN);
> -
>  	/* find the mininum delay first which can pass tuning */
>  	min = ESDHC_TUNE_CTRL_MIN;
>  	while (min < ESDHC_TUNE_CTRL_MAX) {
>  		esdhc_prepare_tuning(host, min);
> -		if (!esdhc_send_tuning_cmd(host, opcode, &sg))
> +		if (!mmc_send_tuning(host->mmc->card))
>  			break;
>  		min += ESDHC_TUNE_CTRL_STEP;
>  	}
> @@ -786,7 +726,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
>  	max = min + ESDHC_TUNE_CTRL_STEP;
>  	while (max < ESDHC_TUNE_CTRL_MAX) {
>  		esdhc_prepare_tuning(host, max);
> -		if (esdhc_send_tuning_cmd(host, opcode, &sg)) {
> +		if (mmc_send_tuning(host->mmc->card)) {
>  			max -= ESDHC_TUNE_CTRL_STEP;
>  			break;
>  		}
> @@ -796,11 +736,9 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
>  	/* use average delay to get the best timing */
>  	avg = (min + max) / 2;
>  	esdhc_prepare_tuning(host, avg);
> -	ret = esdhc_send_tuning_cmd(host, opcode, &sg);
> +	ret = mmc_send_tuning(host->mmc->card);
>  	esdhc_post_tuning(host);
>  
> -	kfree(tuning_pattern);
> -
>  	dev_dbg(mmc_dev(host->mmc), "tunning %s at 0x%x ret %d\n",
>  		ret ? "failed" : "passed", avg, ret);
>  
> -- 
> 1.9.1
> 

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

* Re: [PATCH 1/4] mmc: sdhci-esdhc-imx: Convert to mmc_send_tuning()
  2014-12-05 11:11   ` Dong Aisheng
@ 2014-12-05 12:02     ` Ulf Hansson
  0 siblings, 0 replies; 9+ messages in thread
From: Ulf Hansson @ 2014-12-05 12:02 UTC (permalink / raw)
  To: Dong Aisheng
  Cc: linux-mmc, Chris Ball, Seungwon Jeon, Jaehoon Chung, Shawn Guo,
	Sascha Hauer, Stephen Boyd, Minda Chen, Barry Song

On 5 December 2014 at 12:11, Dong Aisheng <b29396@freescale.com> wrote:
> On Mon, Dec 01, 2014 at 05:02:07PM +0100, Ulf Hansson wrote:
>> Instead of having a local function taking care of sending the tuning
>> command, let's use the common mmc_send_tuning() API provided by the mmc
>> core. In this way the request will be handled as any other request by
>> sdhci core.
>>
>> As an effect of this change, the pm_runtime_get_sync() call at
>> esdhc_prepare_tuning() isn't needed any more.
>>
>> This patch will also introduce another change in behavior, since before
>> the response pattern to the tuning command wasn't verified by
>> sdhci-esdhc-imx. The mmc_send_tuning() does that.
>>
>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>
> After applying your mmc_send_tuning() fix patch and it's usage update,
> i tested it worked well on a imx6dl sabreauto board.
>
> So you can add my tag when update the patch.
> Tested-by: Dong Aisheng <b29396@freescale.com>
> Acked-by: Dong Aisheng <b29396@freescale.com>

Thanks Dong for helping out! Much appreciated!

Kind regards
Uffe

>
> Regards
> Dong Aisheng
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index a33d64c..12711ab 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -717,7 +717,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
>         min = ESDHC_TUNE_CTRL_MIN;
>         while (min < ESDHC_TUNE_CTRL_MAX) {
>                 esdhc_prepare_tuning(host, min);
> -               if (!mmc_send_tuning(host->mmc->card))
> +               if (!mmc_send_tuning(host->mmc))
>                         break;
>                 min += ESDHC_TUNE_CTRL_STEP;
>         }
> @@ -726,7 +726,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
>         max = min + ESDHC_TUNE_CTRL_STEP;
>         while (max < ESDHC_TUNE_CTRL_MAX) {
>                 esdhc_prepare_tuning(host, max);
> -               if (mmc_send_tuning(host->mmc->card)) {
> +               if (mmc_send_tuning(host->mmc)) {
>                         max -= ESDHC_TUNE_CTRL_STEP;
>                         break;
>                 }
> @@ -736,7 +736,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
>         /* use average delay to get the best timing */
>         avg = (min + max) / 2;
>         esdhc_prepare_tuning(host, avg);
> -       ret = mmc_send_tuning(host->mmc->card);
> +       ret = mmc_send_tuning(host->mmc);
>         esdhc_post_tuning(host);
>
>         dev_dbg(mmc_dev(host->mmc), "tunning %s at 0x%x ret %d\n",
>
>> ---
>>  drivers/mmc/host/sdhci-esdhc-imx.c | 68 ++------------------------------------
>>  1 file changed, 3 insertions(+), 65 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
>> index 0135f00..a33d64c 100644
>> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
>> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
>> @@ -65,8 +65,6 @@
>>  /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */
>>  #define ESDHC_TUNING_START_TAP               0x1
>>
>> -#define ESDHC_TUNING_BLOCK_PATTERN_LEN       64
>> -
>>  /* pinctrl state */
>>  #define ESDHC_PINCTRL_STATE_100MHZ   "state_100mhz"
>>  #define ESDHC_PINCTRL_STATE_200MHZ   "state_200mhz"
>> @@ -692,8 +690,6 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
>>       /* FIXME: delay a bit for card to be ready for next tuning due to errors */
>>       mdelay(1);
>>
>> -     /* This is balanced by the runtime put in sdhci_tasklet_finish */
>> -     pm_runtime_get_sync(host->mmc->parent);
>>       reg = readl(host->ioaddr + ESDHC_MIX_CTRL);
>>       reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL |
>>                       ESDHC_MIX_CTRL_FBCLK_SEL;
>> @@ -704,54 +700,6 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
>>                       val, readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS));
>>  }
>>
>> -static void esdhc_request_done(struct mmc_request *mrq)
>> -{
>> -     complete(&mrq->completion);
>> -}
>> -
>> -static int esdhc_send_tuning_cmd(struct sdhci_host *host, u32 opcode,
>> -                              struct scatterlist *sg)
>> -{
>> -     struct mmc_command cmd = {0};
>> -     struct mmc_request mrq = {NULL};
>> -     struct mmc_data data = {0};
>> -
>> -     cmd.opcode = opcode;
>> -     cmd.arg = 0;
>> -     cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
>> -
>> -     data.blksz = ESDHC_TUNING_BLOCK_PATTERN_LEN;
>> -     data.blocks = 1;
>> -     data.flags = MMC_DATA_READ;
>> -     data.sg = sg;
>> -     data.sg_len = 1;
>> -
>> -     mrq.cmd = &cmd;
>> -     mrq.cmd->mrq = &mrq;
>> -     mrq.data = &data;
>> -     mrq.data->mrq = &mrq;
>> -     mrq.cmd->data = mrq.data;
>> -
>> -     mrq.done = esdhc_request_done;
>> -     init_completion(&(mrq.completion));
>> -
>> -     spin_lock_irq(&host->lock);
>> -     host->mrq = &mrq;
>> -
>> -     sdhci_send_command(host, mrq.cmd);
>> -
>> -     spin_unlock_irq(&host->lock);
>> -
>> -     wait_for_completion(&mrq.completion);
>> -
>> -     if (cmd.error)
>> -             return cmd.error;
>> -     if (data.error)
>> -             return data.error;
>> -
>> -     return 0;
>> -}
>> -
>>  static void esdhc_post_tuning(struct sdhci_host *host)
>>  {
>>       u32 reg;
>> @@ -763,21 +711,13 @@ static void esdhc_post_tuning(struct sdhci_host *host)
>>
>>  static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
>>  {
>> -     struct scatterlist sg;
>> -     char *tuning_pattern;
>>       int min, max, avg, ret;
>>
>> -     tuning_pattern = kmalloc(ESDHC_TUNING_BLOCK_PATTERN_LEN, GFP_KERNEL);
>> -     if (!tuning_pattern)
>> -             return -ENOMEM;
>> -
>> -     sg_init_one(&sg, tuning_pattern, ESDHC_TUNING_BLOCK_PATTERN_LEN);
>> -
>>       /* find the mininum delay first which can pass tuning */
>>       min = ESDHC_TUNE_CTRL_MIN;
>>       while (min < ESDHC_TUNE_CTRL_MAX) {
>>               esdhc_prepare_tuning(host, min);
>> -             if (!esdhc_send_tuning_cmd(host, opcode, &sg))
>> +             if (!mmc_send_tuning(host->mmc->card))
>>                       break;
>>               min += ESDHC_TUNE_CTRL_STEP;
>>       }
>> @@ -786,7 +726,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
>>       max = min + ESDHC_TUNE_CTRL_STEP;
>>       while (max < ESDHC_TUNE_CTRL_MAX) {
>>               esdhc_prepare_tuning(host, max);
>> -             if (esdhc_send_tuning_cmd(host, opcode, &sg)) {
>> +             if (mmc_send_tuning(host->mmc->card)) {
>>                       max -= ESDHC_TUNE_CTRL_STEP;
>>                       break;
>>               }
>> @@ -796,11 +736,9 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
>>       /* use average delay to get the best timing */
>>       avg = (min + max) / 2;
>>       esdhc_prepare_tuning(host, avg);
>> -     ret = esdhc_send_tuning_cmd(host, opcode, &sg);
>> +     ret = mmc_send_tuning(host->mmc->card);
>>       esdhc_post_tuning(host);
>>
>> -     kfree(tuning_pattern);
>> -
>>       dev_dbg(mmc_dev(host->mmc), "tunning %s at 0x%x ret %d\n",
>>               ret ? "failed" : "passed", avg, ret);
>>
>> --
>> 1.9.1
>>

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

end of thread, other threads:[~2014-12-05 12:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-01 16:02 [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning() Ulf Hansson
2014-12-01 16:02 ` [PATCH 1/4] mmc: sdhci-esdhc-imx: Convert " Ulf Hansson
2014-12-05 11:11   ` Dong Aisheng
2014-12-05 12:02     ` Ulf Hansson
2014-12-01 16:02 ` [PATCH 2/4] mmc: sdhci-msm: " Ulf Hansson
2014-12-01 16:02 ` [PATCH 3/4] mmc: dw_mmc: " Ulf Hansson
2014-12-01 16:02 ` [PATCH 4/4] mmc: core: Make tuning block patterns static Ulf Hansson
2014-12-04 20:50 ` [PATCH 0/4] mmc: Convert host drivers to mmc_send_tuning() Stephen Boyd
2014-12-05 10:51   ` Dong Aisheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).