diff mbox series

[RFC,V2,1/2] mmc: Update sdhci tune function to return errors

Message ID 20250206210835.2980500-1-erick.shepherd@ni.com (mailing list archive)
State New
Headers show
Series [RFC,V2,1/2] mmc: Update sdhci tune function to return errors | expand

Commit Message

Erick Shepherd Feb. 6, 2025, 9:08 p.m. UTC
Updates the sdhci_execute_tuning function to return the error code
that was returned by the __sdhci_execute_tuning function.
Previously this code was only stored in host->tuning_err and not
actually returned.

Signed-off-by: Erick Shepherd <erick.shepherd@ni.com>
---
 drivers/mmc/host/sdhci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ricardo B. Marlière Feb. 6, 2025, 10:34 p.m. UTC | #1
On Thu Feb 6, 2025 at 6:08 PM -03, Erick Shepherd wrote:
> Updates the sdhci_execute_tuning function to return the error code
> that was returned by the __sdhci_execute_tuning function.
> Previously this code was only stored in host->tuning_err and not
> actually returned.
>
> Signed-off-by: Erick Shepherd <erick.shepherd@ni.com>
> ---
>  drivers/mmc/host/sdhci.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index f4a7733a8ad2..b35b8917fa1e 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2967,7 +2967,8 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
>  
>  	sdhci_start_tuning(host);
>  
> -	host->tuning_err = __sdhci_execute_tuning(host, opcode);
> +	err = __sdhci_execute_tuning(host, opcode);
> +	host->tuning_err = err;

Reviewed-by: Ricardo B. Marlière <ricardo@marliere.net>

>  
>  	sdhci_end_tuning(host);
>  out:
Adrian Hunter Feb. 15, 2025, 1:05 a.m. UTC | #2
On 6/02/25 23:08, Erick Shepherd wrote:
> Updates the sdhci_execute_tuning function to return the error code
> that was returned by the __sdhci_execute_tuning function.
> Previously this code was only stored in host->tuning_err and not
> actually returned.
> 
> Signed-off-by: Erick Shepherd <erick.shepherd@ni.com>
> ---
>  drivers/mmc/host/sdhci.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index f4a7733a8ad2..b35b8917fa1e 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2967,7 +2967,8 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
>  
>  	sdhci_start_tuning(host);
>  
> -	host->tuning_err = __sdhci_execute_tuning(host, opcode);
> +	err = __sdhci_execute_tuning(host, opcode);
> +	host->tuning_err = err;

SDHCI uses fixed sampling clock if tuning fails.

It is up to drivers to decide what to do with tuning_err.  A driver
can provide the tuning mmc host op, call sdhci_execute_tuning()
and return tuning_err it that is preferred.

>  
>  	sdhci_end_tuning(host);
>  out:
Erick Shepherd Feb. 18, 2025, 6:41 p.m. UTC | #3
I see, in my case intel_execute_tuning() in sdhci-pci-core.c is what
is calling into sdhci_execute_tuning() so I should check the value of
tuning_err there and possibly return it? The issue I'm trying to solve
is only for DDR50 cards that do not support tuning so I could
conditionally return tuning_err if the timing mode is DDR50. Maybe
something like this?

---
 drivers/mmc/host/sdhci-pci-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 1f0bd723f011..9aedb476bd5d 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -725,6 +725,9 @@ static int intel_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	if (err)
 		return err;
 
+	if (host->tuning_err && mmc->ios.timing == MMC_TIMING_UHS_DDR50)
+		return host->tuning_err;
+
 	/*
 	 * Tuning can leave the IP in an active state (Buffer Read Enable bit
 	 * set) which prevents the entry to low power states (i.e. S0i3). Data
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index f4a7733a8ad2..b35b8917fa1e 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2967,7 +2967,8 @@  int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
 
 	sdhci_start_tuning(host);
 
-	host->tuning_err = __sdhci_execute_tuning(host, opcode);
+	err = __sdhci_execute_tuning(host, opcode);
+	host->tuning_err = err;
 
 	sdhci_end_tuning(host);
 out: