Skip to contentSkip to conversation

Add retry tuning sequence

PATCH Superseded Judith Mendez 3 participants 11 messages Aug 15, 2024 – Aug 21, 2024

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Judith Mendez

author maintainer
#0 lore raw

cover Add retry tuning sequence

Due to failures to find failing region issues seen on some boards, add retry tuning sequence to make the tuning algorithm more robust. The tuning algorithm will re-execute up to 10 times if there is no failing or passing itapdly.

Due to the same issue above, add debug prints to make debugging these corner-cases easier.

Judith Mendez (2):
mmc: sdhci_am654: Add retry tuning
mmc: sdhci_am654: Add tuning debug prints

 drivers/mmc/host/sdhci_am654.c | 35 +++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)
Signature · 1 line
2.46.0
author maintainer
#1 lore raw

PATCH 1/2 mmc: sdhci_am654: Add retry tuning

Add retry tuning up to 10 times if we fail to find a failing region or no passing itapdly. This is necessary since some eMMC's have been observed to never find a failing itapdly on the first couple of tuning iterations, but eventually do. It been observed that the tuning algorithm does not need to loop more than 10 times before finding a failing itapdly.

---
 drivers/mmc/host/sdhci_am654.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci_am654.c +23 -7
index 64e10f7c9faa3..c3d485bd4d553 100644
@@ -86,6 +86,7 @@
 
 #define CLOCK_TOO_SLOW_HZ	50000000
 #define SDHCI_AM654_AUTOSUSPEND_DELAY	-1
+#define RETRY_TUNING_MAX	10
 
 /* Command Queue Host Controller Interface Base address */
 #define SDHCI_AM654_CQE_BASE_ADDR 0x200
@@ -151,6 +152,7 @@ struct sdhci_am654_data {
 	u32 flags;
 	u32 quirks;
 	bool dll_enable;
+	u32 tuning_loop;
 
 #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
 };
@@ -453,12 +455,14 @@ static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
 	int prev_fail_end = -1;
 	u8 i;
 
-	if (!num_fails)
-		return ITAPDLY_LAST_INDEX >> 1;
+	if (!num_fails) {
+		/* Retry tuning */
+		return -1;
+	}
 
 	if (fail_window->length == ITAPDLY_LENGTH) {
-		dev_err(dev, "No passing ITAPDLY, return 0\n");
-		return 0;
+		/* Retry tuning */
+		return -1;
 	}
 
 	first_fail_start = fail_window->start;
@@ -504,6 +508,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 	u8 curr_pass, itap;
 	u8 fail_index = 0;
 	u8 prev_pass = 1;
+	int ret;
 
 	memset(fail_window, 0, sizeof(fail_window));
 
@@ -532,10 +537,20 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 	if (fail_window[fail_index].length != 0)
 		fail_index++;
 
-	itap = sdhci_am654_calculate_itap(host, fail_window, fail_index,
-					  sdhci_am654->dll_enable);
+	ret = sdhci_am654_calculate_itap(host, fail_window, fail_index,
+					 sdhci_am654->dll_enable);
 
-	sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
+	if (ret >= 0) {
+		itap = ret;
+		sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
+	} else {
+		if (sdhci_am654->tuning_loop < RETRY_TUNING_MAX) {
+			sdhci_am654->tuning_loop++;
+			sdhci_am654_platform_execute_tuning(host, opcode);
+		} else {
+			return -1;
+		}
+	}
 
 	/* Save ITAPDLY */
 	sdhci_am654->itap_del_sel[timing] = itap;
@@ -908,6 +923,7 @@ static int sdhci_am654_probe(struct platform_device *pdev)
 		goto err_pltfm_free;
 	}
 
+	sdhci_am654->tuning_loop = 0;
 	host->mmc_host_ops.execute_tuning = sdhci_am654_execute_tuning;
 
 	pm_runtime_get_noresume(dev);
Signature · 1 line
2.46.0
author maintainer
#2 lore raw

Re: [PATCH 1/2] mmc: sdhci_am654: Add retry tuning

Hi all,

Quoted 7 lines · Judith Mendez

Add retry tuning up to 10 times if we fail to find a failing region or no passing itapdly. This is necessary since some eMMC's have been observed to never find a failing itapdly on the first couple of tuning iterations, but eventually do. It been observed that the tuning algorithm does not need to loop more than 10 times before finding a failing itapdly.

Will fix-up this commit message as well, there has only been one case like this so far.

~ Judith

maintainer
#3 lore raw

Re: [PATCH 1/2] mmc: sdhci_am654: Add retry tuning

In reply to Judith Mendez
Quoted 67 lines · Judith Mendez

Add retry tuning up to 10 times if we fail to find a failing region or no passing itapdly. This is necessary since some eMMC's have been observed to never find a failing itapdly on the first couple of tuning iterations, but eventually do. It been observed that the tuning algorithm does not need to loop more than 10 times before finding a failing itapdly.

---
 drivers/mmc/host/sdhci_am654.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci_am654.c +10 -6
index 64e10f7c9faa3..c3d485bd4d553 100644
@@ -86,6 +86,7 @@
 
 #define CLOCK_TOO_SLOW_HZ	50000000
 #define SDHCI_AM654_AUTOSUSPEND_DELAY	-1
+#define RETRY_TUNING_MAX	10
 
 /* Command Queue Host Controller Interface Base address */
 #define SDHCI_AM654_CQE_BASE_ADDR 0x200
@@ -151,6 +152,7 @@ struct sdhci_am654_data {
 	u32 flags;
 	u32 quirks;
 	bool dll_enable;
+	u32 tuning_loop;
 
 #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
 };
@@ -453,12 +455,14 @@ static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
 	int prev_fail_end = -1;
 	u8 i;
 
-	if (!num_fails)
-		return ITAPDLY_LAST_INDEX >> 1;
+	if (!num_fails) {
+		/* Retry tuning */
+		return -1;
+	}
 
 	if (fail_window->length == ITAPDLY_LENGTH) {
-		dev_err(dev, "No passing ITAPDLY, return 0\n");
-		return 0;
+		/* Retry tuning */
+		return -1;
 	}
 
 	first_fail_start = fail_window->start;
@@ -504,6 +508,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 	u8 curr_pass, itap;
 	u8 fail_index = 0;
 	u8 prev_pass = 1;
+	int ret;
 
 	memset(fail_window, 0, sizeof(fail_window));
 
@@ -532,10 +537,20 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 	if (fail_window[fail_index].length != 0)
 		fail_index++;
 
-	itap = sdhci_am654_calculate_itap(host, fail_window, fail_index,
-					  sdhci_am654->dll_enable);
+	ret = sdhci_am654_calculate_itap(host, fail_window, fail_index,

drivers/mmc/host/sdhci_am654.c static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host, · line 549

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +8 -1
+					 sdhci_am654->dll_enable);
 
-	sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
+	if (ret >= 0) {
+		itap = ret;
+		sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
+	} else {
+		if (sdhci_am654->tuning_loop < RETRY_TUNING_MAX) {
+			sdhci_am654->tuning_loop++;
+			sdhci_am654_platform_execute_tuning(host, opcode);

The kernel uses very small stack size, so recursive function calls should not be used. It would be better to put the loop in a separate function, or add a retry: label and goto retry.

drivers/mmc/host/sdhci_am654.c static int sdhci_am654_probe(struct platform_device *pdev) · line 926

Quoted 12 lines
drivers/mmc/host/sdhci_am654.c +5 -0
+		} else {
+			return -1;
+		}
+	}
 
 	/* Save ITAPDLY */
 	sdhci_am654->itap_del_sel[timing] = itap;
@@ -908,6 +923,7 @@ static int sdhci_am654_probe(struct platform_device *pdev)
 		goto err_pltfm_free;
 	}
 
+	sdhci_am654->tuning_loop = 0;

So this is 10 retries ever, since sdhci_am654->tuning_loop is never set back to 0. Is that the intention?

Quoted 3 lines
drivers/mmc/host/sdhci_am654.c +0 -0
 	host->mmc_host_ops.execute_tuning = sdhci_am654_execute_tuning;
 
 	pm_runtime_get_noresume(dev);
author maintainer
#4 lore raw

Re: [PATCH 1/2] mmc: sdhci_am654: Add retry tuning

Hi Adrian,

Quoted 70 lines · Adrian Hunter
Quoted 69 lines · Judith Mendez

Add retry tuning up to 10 times if we fail to find a failing region or no passing itapdly. This is necessary since some eMMC's have been observed to never find a failing itapdly on the first couple of tuning iterations, but eventually do. It been observed that the tuning algorithm does not need to loop more than 10 times before finding a failing itapdly.

---
  drivers/mmc/host/sdhci_am654.c | 30 +++++++++++++++++++++++-------
  1 file changed, 23 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci_am654.c +11 -6
index 64e10f7c9faa3..c3d485bd4d553 100644
@@ -86,6 +86,7 @@
 
  #define CLOCK_TOO_SLOW_HZ	50000000
  #define SDHCI_AM654_AUTOSUSPEND_DELAY	-1
+#define RETRY_TUNING_MAX	10
 
  /* Command Queue Host Controller Interface Base address */
  #define SDHCI_AM654_CQE_BASE_ADDR 0x200
@@ -151,6 +152,7 @@ struct sdhci_am654_data {
  	u32 flags;
  	u32 quirks;
  	bool dll_enable;
+	u32 tuning_loop;
 
  #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
  };
@@ -453,12 +455,14 @@ static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
  	int prev_fail_end = -1;
  	u8 i;
 
-	if (!num_fails)
-		return ITAPDLY_LAST_INDEX >> 1;
+	if (!num_fails) {
+		/* Retry tuning */
+		return -1;
+	}
 
  	if (fail_window->length == ITAPDLY_LENGTH) {
-		dev_err(dev, "No passing ITAPDLY, return 0\n");
-		return 0;
+		/* Retry tuning */
+		return -1;
  	}
 
  	first_fail_start = fail_window->start;
@@ -504,6 +508,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
  	u8 curr_pass, itap;
  	u8 fail_index = 0;
  	u8 prev_pass = 1;
+	int ret;
 
  	memset(fail_window, 0, sizeof(fail_window));
 
@@ -532,10 +537,20 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
  	if (fail_window[fail_index].length != 0)
  		fail_index++;
 
-	itap = sdhci_am654_calculate_itap(host, fail_window, fail_index,
-					  sdhci_am654->dll_enable);
+	ret = sdhci_am654_calculate_itap(host, fail_window, fail_index,
+					 sdhci_am654->dll_enable);
 
Quoted 12 lines

drivers/mmc/host/sdhci_am654.c static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host, · line 549

Quoted 8 lines
drivers/mmc/host/sdhci_am654.c +7 -1
-	sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
+	if (ret >= 0) {
+		itap = ret;
+		sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
+	} else {
+		if (sdhci_am654->tuning_loop < RETRY_TUNING_MAX) {
+			sdhci_am654->tuning_loop++;
+			sdhci_am654_platform_execute_tuning(host, opcode);

The kernel uses very small stack size, so recursive function calls should not be used. It would be better to put the loop in a separate function, or add a retry: label and goto retry.

Ok, can change to this method, I was not sure of recursive function call but had opted for that since the code was to be simpler.

Quoted 12 lines
Quoted 12 lines
drivers/mmc/host/sdhci_am654.c +4 -0
+		} else {
+			return -1;
+		}
+	}
 
  	/* Save ITAPDLY */
  	sdhci_am654->itap_del_sel[timing] = itap;
@@ -908,6 +923,7 @@ static int sdhci_am654_probe(struct platform_device *pdev)
  		goto err_pltfm_free;
  	}
 
Quoted 4 lines

drivers/mmc/host/sdhci_am654.c static int sdhci_am654_probe(struct platform_device *pdev) · line 926

Quoted 1 line
drivers/mmc/host/sdhci_am654.c +1 -0
+	sdhci_am654->tuning_loop = 0;

So this is 10 retries ever, since sdhci_am654->tuning_loop is never set back to 0. Is that the intention?

Yes, maximum of 10 re-tries. So far we have only seen issues during boot.

~ Judith

Quoted 5 lines
Quoted 4 lines
drivers/mmc/host/sdhci_am654.c +0 -0
  	host->mmc_host_ops.execute_tuning = sdhci_am654_execute_tuning;
 
  	pm_runtime_get_noresume(dev);
author maintainer
#5 lore raw

PATCH 2/2 mmc: sdhci_am654: Add tuning debug prints

In reply to Judith Mendez

Add debug prints to tuning algorithm for debugging.

---
 drivers/mmc/host/sdhci_am654.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci_am654.c +5 -0
index c3d485bd4d553..a909f8de0eabe 100644
@@ -457,11 +457,13 @@ static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
 
 	if (!num_fails) {
 		/* Retry tuning */
+		dev_err(dev, "No failing region found, retry tuning\n");
 		return -1;
 	}
 
 	if (fail_window->length == ITAPDLY_LENGTH) {
 		/* Retry tuning */
+		dev_err(dev, "No passing ITAPDLY, retry tuning\n");
 		return -1;
 	}
 
@@ -505,6 +507,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
 	unsigned char timing = host->mmc->ios.timing;
 	struct window fail_window[ITAPDLY_LENGTH];
+	struct device *dev = mmc_dev(host->mmc);
 	u8 curr_pass, itap;
 	u8 fail_index = 0;
 	u8 prev_pass = 1;
@@ -542,12 +545,14 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 
 	if (ret >= 0) {
 		itap = ret;
+		dev_dbg(dev, "Final ITAPDLY=%d\n", itap);
 		sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
 	} else {
 		if (sdhci_am654->tuning_loop < RETRY_TUNING_MAX) {
 			sdhci_am654->tuning_loop++;
 			sdhci_am654_platform_execute_tuning(host, opcode);
 		} else {
+			dev_err(dev, "Failed to find ITAPDLY, fail tuning\n");
 			return -1;
 		}
 	}
Signature · 1 line
2.46.0
#6 lore raw

Re: [PATCH 2/2] mmc: sdhci_am654: Add tuning debug prints

Quoted 13 lines · Judith Mendez

Add debug prints to tuning algorithm for debugging.

---
 drivers/mmc/host/sdhci_am654.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci_am654.c +0 -0
index c3d485bd4d553..a909f8de0eabe 100644

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window · line 460

Quoted 4 lines
drivers/mmc/host/sdhci_am654.c +1 -0
@@ -457,11 +457,13 @@ static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
 
        if (!num_fails) {
                /* Retry tuning */
+               dev_err(dev, "No failing region found, retry tuning\n");

A dev_err seems to be too heavy, but I am not sure at what frequency this could occur?

Why isn't a dev_dbg sufficient?

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window · line 466

Quoted 6 lines
drivers/mmc/host/sdhci_am654.c +1 -0
                return -1;
        }
 
        if (fail_window->length == ITAPDLY_LENGTH) {
                /* Retry tuning */
+               dev_err(dev, "No passing ITAPDLY, retry tuning\n");

Ditto.

Quoted 13 lines
drivers/mmc/host/sdhci_am654.c +1 -0
                return -1;
        }
 
@@ -505,6 +507,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
        struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
        unsigned char timing = host->mmc->ios.timing;
        struct window fail_window[ITAPDLY_LENGTH];
+       struct device *dev = mmc_dev(host->mmc);
        u8 curr_pass, itap;
        u8 fail_index = 0;
        u8 prev_pass = 1;
@@ -542,12 +545,14 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 

drivers/mmc/host/sdhci_am654.c static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host, · line 555

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +2 -0
        if (ret >= 0) {
                itap = ret;
+               dev_dbg(dev, "Final ITAPDLY=%d\n", itap);
                sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
        } else {
                if (sdhci_am654->tuning_loop < RETRY_TUNING_MAX) {
                        sdhci_am654->tuning_loop++;
                        sdhci_am654_platform_execute_tuning(host, opcode);
                } else {
+                       dev_err(dev, "Failed to find ITAPDLY, fail tuning\n");

The commit message only talks about debug messages, but this is an error message. Perhaps update the commit message a bit?

Quoted 6 lines
drivers/mmc/host/sdhci_am654.c +0 -1
                        return -1;
                }
        }
--

2.46.0

Kind regards
Uffe

author maintainer
#7 lore raw

Re: [PATCH 2/2] mmc: sdhci_am654: Add tuning debug prints

Hi Ulf Hansson,

Quoted 15 lines · Ulf Hansson
Quoted 14 lines · Judith Mendez

Add debug prints to tuning algorithm for debugging.

---
  drivers/mmc/host/sdhci_am654.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci_am654.c +0 -0
index c3d485bd4d553..a909f8de0eabe 100644
@@ -457,11 +457,13 @@ static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
 
Quoted 6 lines

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window · line 460

Quoted 3 lines
drivers/mmc/host/sdhci_am654.c +1 -0
         if (!num_fails) {
                 /* Retry tuning */
+               dev_err(dev, "No failing region found, retry tuning\n");

A dev_err seems to be too heavy, but I am not sure at what frequency this could occur?

Having no failing region is what we call a corner case, it rarely happens. The one case where it did happen, it took a good amount of time to discover there were no failing regions found. The tuning
algorithm had to be looped 3 times before finding a failing itapdly.

Quoted 2 lines

Why isn't a dev_dbg sufficient?

I thought about using dev_dbg, but based on some feedback after coming upon this issue on a board bring up case, we think it would help enormously if we make it as obvious as possible when no failing region is found.

The one case where this came up, the dev_err print would only print 3 times... Now this is only one case and we are not aware of any more cases like this, also we cannot replicate on TI EVM's.

Quoted 9 lines

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window · line 466

Quoted 7 lines
drivers/mmc/host/sdhci_am654.c +1 -0
                 return -1;
         }
 
         if (fail_window->length == ITAPDLY_LENGTH) {
                 /* Retry tuning */
+               dev_err(dev, "No passing ITAPDLY, retry tuning\n");

Ditto.

Same idea as above..

But with this print, the maximum amount of prints that could be printed is 20, is this too many prints in your opinion?

Quoted 14 lines
Quoted 14 lines
drivers/mmc/host/sdhci_am654.c +1 -0
                 return -1;
         }
 
@@ -505,6 +507,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
         struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
         unsigned char timing = host->mmc->ios.timing;
         struct window fail_window[ITAPDLY_LENGTH];
+       struct device *dev = mmc_dev(host->mmc);
         u8 curr_pass, itap;
         u8 fail_index = 0;
         u8 prev_pass = 1;
@@ -542,12 +545,14 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 
Quoted 13 lines

drivers/mmc/host/sdhci_am654.c static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host, · line 555

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +2 -0
         if (ret >= 0) {
                 itap = ret;
+               dev_dbg(dev, "Final ITAPDLY=%d\n", itap);
                 sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
         } else {
                 if (sdhci_am654->tuning_loop < RETRY_TUNING_MAX) {
                         sdhci_am654->tuning_loop++;
                         sdhci_am654_platform_execute_tuning(host, opcode);
                 } else {
+                       dev_err(dev, "Failed to find ITAPDLY, fail tuning\n");

The commit message only talks about debug messages, but this is an error message. Perhaps update the commit message a bit?

Sure will do, after we conclude the discussion above and in v2.

Thanks so much for reviewing.

~ Judith

Quoted 10 lines
Quoted 7 lines
drivers/mmc/host/sdhci_am654.c +0 -1
                         return -1;
                 }
         }
--

2.46.0

Kind regards
Uffe

#8 lore raw

Re: [PATCH 2/2] mmc: sdhci_am654: Add tuning debug prints

Quoted 34 lines · Judith Mendez

Hi Ulf Hansson,

Quoted 15 lines · Ulf Hansson
Quoted 14 lines · Judith Mendez

Add debug prints to tuning algorithm for debugging.

---
  drivers/mmc/host/sdhci_am654.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci_am654.c +0 -0
index c3d485bd4d553..a909f8de0eabe 100644
@@ -457,11 +457,13 @@ static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
 
Quoted 6 lines

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window · line 460

Quoted 3 lines
drivers/mmc/host/sdhci_am654.c +1 -0
         if (!num_fails) {
                 /* Retry tuning */
+               dev_err(dev, "No failing region found, retry tuning\n");

A dev_err seems to be too heavy, but I am not sure at what frequency this could occur?

Having no failing region is what we call a corner case, it rarely happens. The one case where it did happen, it took a good amount of time to discover there were no failing regions found. The tuning algorithm had to be looped 3 times before finding a failing itapdly.

Quoted 2 lines

Why isn't a dev_dbg sufficient?

Quoted 8 lines

I thought about using dev_dbg, but based on some feedback after coming upon this issue on a board bring up case, we think it would help enormously if we make it as obvious as possible when no failing region is found.

The one case where this came up, the dev_err print would only print 3 times... Now this is only one case and we are not aware of any more cases like this, also we cannot replicate on TI EVM's.

What happens if/when we fail here? Do we fail to detect the card or do we end up running it in some degraded mode?

If the latter a dev_warn, the former a dev_err(). Does that make sense?

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/mmc/host/sdhci_am654.c +1 -0
                 return -1;
         }
 
         if (fail_window->length == ITAPDLY_LENGTH) {
                 /* Retry tuning */
+               dev_err(dev, "No passing ITAPDLY, retry tuning\n");
Quoted 6 lines
Quoted 1 line

Ditto.

Same idea as above..

But with this print, the maximum amount of prints that could be printed is 20, is this too many prints in your opinion?

This sounds like dev_dbg to me. We are not really failing, as we are making a re-try and will most likely succeed then, right?

Quoted 30 lines
Quoted 16 lines
Quoted 16 lines
drivers/mmc/host/sdhci_am654.c +1 -0
                 return -1;
         }
 
@@ -505,6 +507,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
         struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
         unsigned char timing = host->mmc->ios.timing;
         struct window fail_window[ITAPDLY_LENGTH];
+       struct device *dev = mmc_dev(host->mmc);
         u8 curr_pass, itap;
         u8 fail_index = 0;
         u8 prev_pass = 1;
@@ -542,12 +545,14 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 
Quoted 13 lines

drivers/mmc/host/sdhci_am654.c static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host, · line 555

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +2 -0
         if (ret >= 0) {
                 itap = ret;
+               dev_dbg(dev, "Final ITAPDLY=%d\n", itap);
                 sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
         } else {
                 if (sdhci_am654->tuning_loop < RETRY_TUNING_MAX) {
                         sdhci_am654->tuning_loop++;
                         sdhci_am654_platform_execute_tuning(host, opcode);
                 } else {
+                       dev_err(dev, "Failed to find ITAPDLY, fail tuning\n");

The commit message only talks about debug messages, but this is an error message. Perhaps update the commit message a bit?

Quoted 4 lines

Sure will do, after we conclude the discussion above and in v2.

Thanks so much for reviewing.

Kind regards
Uffe

author maintainer
#9 lore raw

Re: [PATCH 2/2] mmc: sdhci_am654: Add tuning debug prints

Hi Ulf Hansson,

Quoted 40 lines · Ulf Hansson
Quoted 39 lines · Judith Mendez

Hi Ulf Hansson,

Quoted 15 lines · Ulf Hansson
Quoted 14 lines · Judith Mendez

Add debug prints to tuning algorithm for debugging.

---
   drivers/mmc/host/sdhci_am654.c | 5 +++++
   1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci_am654.c +0 -0
index c3d485bd4d553..a909f8de0eabe 100644
@@ -457,11 +457,13 @@ static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
 
Quoted 6 lines

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window · line 460

Quoted 3 lines
drivers/mmc/host/sdhci_am654.c +1 -0
          if (!num_fails) {
                  /* Retry tuning */
+               dev_err(dev, "No failing region found, retry tuning\n");

A dev_err seems to be too heavy, but I am not sure at what frequency this could occur?

Having no failing region is what we call a corner case, it rarely happens. The one case where it did happen, it took a good amount of time to discover there were no failing regions found. The tuning algorithm had to be looped 3 times before finding a failing itapdly.

Quoted 2 lines

Why isn't a dev_dbg sufficient?

I thought about using dev_dbg, but based on some feedback after coming upon this issue on a board bring up case, we think it would help enormously if we make it as obvious as possible when no failing region is found.

Quoted 8 lines
Quoted 3 lines

The one case where this came up, the dev_err print would only print 3 times... Now this is only one case and we are not aware of any more cases like this, also we cannot replicate on TI EVM's.

What happens if/when we fail here? Do we fail to detect the card or do we end up running it in some degraded mode?

If the latter a dev_warn, the former a dev_err(). Does that make sense?

What was happening was, we enumerated to HS200, but then cqe error was triggered and this re-triggers the tuning algo repeatedly until the failing region was found.

After thinking about this some more, I think I will switch to dev_dbg, if we fail to find failing region and we re-run the tuning algorithm, don't want to confuse people by printing error logs if we are re-running the tuning algo anyways. Thanks so much for your feedback!

~ Judith

Quoted 57 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
drivers/mmc/host/sdhci_am654.c +1 -0
                  return -1;
          }
 
          if (fail_window->length == ITAPDLY_LENGTH) {
                  /* Retry tuning */
+               dev_err(dev, "No passing ITAPDLY, retry tuning\n");
Quoted 6 lines
Quoted 1 line

Ditto.

Same idea as above..

But with this print, the maximum amount of prints that could be printed is 20, is this too many prints in your opinion?

This sounds like dev_dbg to me. We are not really failing, as we are making a re-try and will most likely succeed then, right?

Quoted 30 lines
Quoted 16 lines
Quoted 16 lines
drivers/mmc/host/sdhci_am654.c +1 -0
                  return -1;
          }
 
@@ -505,6 +507,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
          struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
          unsigned char timing = host->mmc->ios.timing;
          struct window fail_window[ITAPDLY_LENGTH];
+       struct device *dev = mmc_dev(host->mmc);
          u8 curr_pass, itap;
          u8 fail_index = 0;
          u8 prev_pass = 1;
@@ -542,12 +545,14 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 
Quoted 13 lines

drivers/mmc/host/sdhci_am654.c static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host, · line 555

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +2 -0
          if (ret >= 0) {
                  itap = ret;
+               dev_dbg(dev, "Final ITAPDLY=%d\n", itap);
                  sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
          } else {
                  if (sdhci_am654->tuning_loop < RETRY_TUNING_MAX) {
                          sdhci_am654->tuning_loop++;
                          sdhci_am654_platform_execute_tuning(host, opcode);
                  } else {
+                       dev_err(dev, "Failed to find ITAPDLY, fail tuning\n");

The commit message only talks about debug messages, but this is an error message. Perhaps update the commit message a bit?

Quoted 4 lines

Sure will do, after we conclude the discussion above and in v2.

Thanks so much for reviewing.

Kind regards
Uffe

author maintainer
#10 lore raw

Re: [PATCH 2/2] mmc: sdhci_am654: Add tuning debug prints

In reply to Ulf Hansson
Quoted 60 lines · Ulf Hansson
Quoted 34 lines · Judith Mendez

Hi Ulf Hansson,

Quoted 15 lines · Ulf Hansson
Quoted 14 lines · Judith Mendez

Add debug prints to tuning algorithm for debugging.

---
   drivers/mmc/host/sdhci_am654.c | 5 +++++
   1 file changed, 5 insertions(+)
drivers/mmc/host/sdhci_am654.c +0 -0
index c3d485bd4d553..a909f8de0eabe 100644
@@ -457,11 +457,13 @@ static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window
 
Quoted 6 lines

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window · line 460

Quoted 3 lines
drivers/mmc/host/sdhci_am654.c +1 -0
          if (!num_fails) {
                  /* Retry tuning */
+               dev_err(dev, "No failing region found, retry tuning\n");

A dev_err seems to be too heavy, but I am not sure at what frequency this could occur?

Having no failing region is what we call a corner case, it rarely happens. The one case where it did happen, it took a good amount of time to discover there were no failing regions found. The tuning algorithm had to be looped 3 times before finding a failing itapdly.

Quoted 2 lines

Why isn't a dev_dbg sufficient?

Quoted 8 lines

I thought about using dev_dbg, but based on some feedback after coming upon this issue on a board bring up case, we think it would help enormously if we make it as obvious as possible when no failing region is found.

The one case where this came up, the dev_err print would only print 3 times... Now this is only one case and we are not aware of any more cases like this, also we cannot replicate on TI EVM's.

What happens if/when we fail here? Do we fail to detect the card or do we end up running it in some degraded mode?

If the latter a dev_warn, the former a dev_err(). Does that make sense?

Quoted 11 lines
Quoted 10 lines

drivers/mmc/host/sdhci_am654.c static u32 sdhci_am654_calculate_itap(struct sdhci_host *host, struct window · line 466

Quoted 8 lines
drivers/mmc/host/sdhci_am654.c +1 -0
                  return -1;
          }
 
          if (fail_window->length == ITAPDLY_LENGTH) {
                  /* Retry tuning */
+               dev_err(dev, "No passing ITAPDLY, retry tuning\n");

Ditto.

Quoted 7 lines
Quoted 4 lines

Same idea as above..

But with this print, the maximum amount of prints that could be printed is 20, is this too many prints in your opinion?

This sounds like dev_dbg to me. We are not really failing, as we are making a re-try and will most likely succeed then, right?

Yes absolutely right, will fix for v2, thanks.

~ Judith

Quoted 38 lines
Quoted 31 lines
Quoted 17 lines
Quoted 17 lines
drivers/mmc/host/sdhci_am654.c +1 -0
                  return -1;
          }
 
@@ -505,6 +507,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
          struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
          unsigned char timing = host->mmc->ios.timing;
          struct window fail_window[ITAPDLY_LENGTH];
+       struct device *dev = mmc_dev(host->mmc);
          u8 curr_pass, itap;
          u8 fail_index = 0;
          u8 prev_pass = 1;
@@ -542,12 +545,14 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
 
Quoted 13 lines

drivers/mmc/host/sdhci_am654.c static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host, · line 555

Quoted 10 lines
drivers/mmc/host/sdhci_am654.c +2 -0
          if (ret >= 0) {
                  itap = ret;
+               dev_dbg(dev, "Final ITAPDLY=%d\n", itap);
                  sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]);
          } else {
                  if (sdhci_am654->tuning_loop < RETRY_TUNING_MAX) {
                          sdhci_am654->tuning_loop++;
                          sdhci_am654_platform_execute_tuning(host, opcode);
                  } else {
+                       dev_err(dev, "Failed to find ITAPDLY, fail tuning\n");

The commit message only talks about debug messages, but this is an error message. Perhaps update the commit message a bit?

Quoted 4 lines

Sure will do, after we conclude the discussion above and in v2.

Thanks so much for reviewing.

Kind regards
Uffe