linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mmc: sdhci-of-esdhc: Check for error num after setting mask
@ 2022-01-12  8:31 Jiasheng Jiang
  2022-01-12  9:10 ` Adrian Hunter
  2022-01-21 14:31 ` Ulf Hansson
  0 siblings, 2 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2022-01-12  8:31 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson; +Cc: linux-mmc, linux-kernel, Jiasheng Jiang

Because of the possible failure of the dma_supported(), the
dma_set_mask_and_coherent() may return error num.
Therefore, it should be better to check it and return the error if
fails.
And since the sdhci_setup_host() has already checked the return value of
the enable_dma, we need not check it in sdhci_resume_host() again.

Fixes: 5552d7ad596c ("mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
Changelog

v1 -> v2

* Change 1. Remove the change of esdhc_of_resume and refine the commit
* message.
---
 drivers/mmc/host/sdhci-of-esdhc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index a593b1fbd69e..0f3658b36513 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -524,12 +524,16 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
 
 static int esdhc_of_enable_dma(struct sdhci_host *host)
 {
+	int ret;
 	u32 value;
 	struct device *dev = mmc_dev(host->mmc);
 
 	if (of_device_is_compatible(dev->of_node, "fsl,ls1043a-esdhc") ||
-	    of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc"))
-		dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
+	    of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc")) {
+		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
+		if (ret)
+			return ret;
+	}
 
 	value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
 
-- 
2.25.1


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

* Re: [PATCH v2] mmc: sdhci-of-esdhc: Check for error num after setting mask
  2022-01-12  8:31 [PATCH v2] mmc: sdhci-of-esdhc: Check for error num after setting mask Jiasheng Jiang
@ 2022-01-12  9:10 ` Adrian Hunter
  2022-01-21 14:31 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Adrian Hunter @ 2022-01-12  9:10 UTC (permalink / raw)
  To: Jiasheng Jiang, ulf.hansson; +Cc: linux-mmc, linux-kernel

On 12/01/2022 10:31, Jiasheng Jiang wrote:
> Because of the possible failure of the dma_supported(), the
> dma_set_mask_and_coherent() may return error num.
> Therefore, it should be better to check it and return the error if
> fails.
> And since the sdhci_setup_host() has already checked the return value of
> the enable_dma, we need not check it in sdhci_resume_host() again.
> 
> Fixes: 5552d7ad596c ("mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> Changelog
> 
> v1 -> v2
> 
> * Change 1. Remove the change of esdhc_of_resume and refine the commit
> * message.
> ---
>  drivers/mmc/host/sdhci-of-esdhc.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index a593b1fbd69e..0f3658b36513 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -524,12 +524,16 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
>  
>  static int esdhc_of_enable_dma(struct sdhci_host *host)
>  {
> +	int ret;
>  	u32 value;
>  	struct device *dev = mmc_dev(host->mmc);
>  
>  	if (of_device_is_compatible(dev->of_node, "fsl,ls1043a-esdhc") ||
> -	    of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc"))
> -		dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
> +	    of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc")) {
> +		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
> +		if (ret)
> +			return ret;
> +	}
>  
>  	value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
>  
> 


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

* Re: [PATCH v2] mmc: sdhci-of-esdhc: Check for error num after setting mask
  2022-01-12  8:31 [PATCH v2] mmc: sdhci-of-esdhc: Check for error num after setting mask Jiasheng Jiang
  2022-01-12  9:10 ` Adrian Hunter
@ 2022-01-21 14:31 ` Ulf Hansson
  1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2022-01-21 14:31 UTC (permalink / raw)
  To: Jiasheng Jiang; +Cc: adrian.hunter, linux-mmc, linux-kernel

On Wed, 12 Jan 2022 at 09:32, Jiasheng Jiang <jiasheng@iscas.ac.cn> wrote:
>
> Because of the possible failure of the dma_supported(), the
> dma_set_mask_and_coherent() may return error num.
> Therefore, it should be better to check it and return the error if
> fails.
> And since the sdhci_setup_host() has already checked the return value of
> the enable_dma, we need not check it in sdhci_resume_host() again.
>
> Fixes: 5552d7ad596c ("mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

Applied for fixes and by adding a stable tag, thanks!

Kind regards
Uffe


> ---
> Changelog
>
> v1 -> v2
>
> * Change 1. Remove the change of esdhc_of_resume and refine the commit
> * message.
> ---
>  drivers/mmc/host/sdhci-of-esdhc.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index a593b1fbd69e..0f3658b36513 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -524,12 +524,16 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
>
>  static int esdhc_of_enable_dma(struct sdhci_host *host)
>  {
> +       int ret;
>         u32 value;
>         struct device *dev = mmc_dev(host->mmc);
>
>         if (of_device_is_compatible(dev->of_node, "fsl,ls1043a-esdhc") ||
> -           of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc"))
> -               dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
> +           of_device_is_compatible(dev->of_node, "fsl,ls1046a-esdhc")) {
> +               ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
> +               if (ret)
> +                       return ret;
> +       }
>
>         value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
>
> --
> 2.25.1
>

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

end of thread, other threads:[~2022-01-21 14:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12  8:31 [PATCH v2] mmc: sdhci-of-esdhc: Check for error num after setting mask Jiasheng Jiang
2022-01-12  9:10 ` Adrian Hunter
2022-01-21 14:31 ` Ulf Hansson

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).