linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing
@ 2019-08-29 10:49 Masahiro Yamada
  2019-08-29 10:49 ` [PATCH 2/3] mmc: sdhci: constify references of parameters to __sdhci_read_caps() Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Masahiro Yamada @ 2019-08-29 10:49 UTC (permalink / raw)
  To: linux-mmc, Adrian Hunter, Ulf Hansson
  Cc: Piotr Sroka, Masahiro Yamada, stable, linux-kernel

The IP datasheet says this controller is compatible with SD Host
Specification Version v4.00.

As it turned out, the ADMA of this IP does not work with 64-bit mode
when it is in the Version 3.00 compatible mode; it understands the
old 64-bit descriptor table (as defined in SDHCI v2), but the ADMA
System Address Register (SDHCI_ADMA_ADDRESS) cannot point to the
64-bit address.

I noticed this issue only after commit bd2e75633c80 ("dma-contiguous:
use fallback alloc_pages for single pages"). Prior to that commit,
dma_set_mask_and_coherent() returned the dma address that fits in
32-bit range, at least for the default arm64 configuration
(arch/arm64/configs/defconfig). Now the host->adma_addr exceeds the
32-bit limit, causing the real problem for the Socionext SoCs.
(As a side-note, I was also able to reproduce the issue for older
kernels by turning off CONFIG_DMA_CMA.)

Call sdhci_enable_v4_mode() to fix this.

I think it is better to back-port this, but only possible for v4.20+.

When this driver was merged (v4.10), the v4 mode support did not exist.
It was added by commit b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")
i.e. v4.20.

Cc: <stable@vger.kernel.org> # v4.20+
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/mmc/host/sdhci-cadence.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c
index 163d1cf4367e..44139fceac24 100644
--- a/drivers/mmc/host/sdhci-cadence.c
+++ b/drivers/mmc/host/sdhci-cadence.c
@@ -369,6 +369,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
 	host->mmc_host_ops.execute_tuning = sdhci_cdns_execute_tuning;
 	host->mmc_host_ops.hs400_enhanced_strobe =
 				sdhci_cdns_hs400_enhanced_strobe;
+	sdhci_enable_v4_mode(host);
 
 	sdhci_get_of_property(pdev);
 
-- 
2.17.1


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

* [PATCH 2/3] mmc: sdhci: constify references of parameters to __sdhci_read_caps()
  2019-08-29 10:49 [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing Masahiro Yamada
@ 2019-08-29 10:49 ` Masahiro Yamada
  2019-08-29 13:09   ` Adrian Hunter
  2019-08-29 13:34   ` Ulf Hansson
  2019-08-29 10:49 ` [PATCH 3/3] mmc: sdhci-cadence: override spec version Masahiro Yamada
  2019-08-29 11:47 ` [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing Ulf Hansson
  2 siblings, 2 replies; 12+ messages in thread
From: Masahiro Yamada @ 2019-08-29 10:49 UTC (permalink / raw)
  To: linux-mmc, Adrian Hunter, Ulf Hansson
  Cc: Piotr Sroka, Masahiro Yamada, linux-kernel

__sdhci_read_caps() does not modify *ver, *caps, or *caps1.

Probably, the caller of this function will want to constifythe
parameters passed in.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/mmc/host/sdhci.c | 3 ++-
 drivers/mmc/host/sdhci.h | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index a5dc5aae973e..08cc0792c174 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -3565,7 +3565,8 @@ static int sdhci_set_dma_mask(struct sdhci_host *host)
 	return ret;
 }
 
-void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps, u32 *caps1)
+void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
+		       const u32 *caps, const u32 *caps1)
 {
 	u16 v;
 	u64 dt_caps_mask = 0;
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 902f855efe8f..81e23784475a 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -738,8 +738,8 @@ static inline void *sdhci_priv(struct sdhci_host *host)
 }
 
 void sdhci_card_detect(struct sdhci_host *host);
-void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps,
-		       u32 *caps1);
+void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
+		       const u32 *caps, const u32 *caps1);
 int sdhci_setup_host(struct sdhci_host *host);
 void sdhci_cleanup_host(struct sdhci_host *host);
 int __sdhci_add_host(struct sdhci_host *host);
-- 
2.17.1


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

* [PATCH 3/3] mmc: sdhci-cadence: override spec version
  2019-08-29 10:49 [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing Masahiro Yamada
  2019-08-29 10:49 ` [PATCH 2/3] mmc: sdhci: constify references of parameters to __sdhci_read_caps() Masahiro Yamada
@ 2019-08-29 10:49 ` Masahiro Yamada
  2019-08-29 13:14   ` Adrian Hunter
  2019-08-29 13:34   ` Ulf Hansson
  2019-08-29 11:47 ` [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing Ulf Hansson
  2 siblings, 2 replies; 12+ messages in thread
From: Masahiro Yamada @ 2019-08-29 10:49 UTC (permalink / raw)
  To: linux-mmc, Adrian Hunter, Ulf Hansson
  Cc: Piotr Sroka, Masahiro Yamada, linux-kernel

The datasheet of the IP (sd4hc) says it is compiatible with SDHCI v4,
but the spec version field in the version register is read as 2
(i.e. SDHCI_SPEC_300) based on the RTL provided by Cadence.

Socionext did not fix it up when it integrated the IP into the SoCs.
So, it is working as SDHCI v3.

It is not a real problem because there is no difference in the program
flow in sdhci.c between SDHCI_SPEC_300/400, but set the real version
just in case.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/mmc/host/sdhci-cadence.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c
index 44139fceac24..9837214685b6 100644
--- a/drivers/mmc/host/sdhci-cadence.c
+++ b/drivers/mmc/host/sdhci-cadence.c
@@ -341,6 +341,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
 	unsigned int nr_phy_params;
 	int ret;
 	struct device *dev = &pdev->dev;
+	static const u16 version = SDHCI_SPEC_400 << SDHCI_SPEC_VER_SHIFT;
 
 	clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(clk))
@@ -370,6 +371,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
 	host->mmc_host_ops.hs400_enhanced_strobe =
 				sdhci_cdns_hs400_enhanced_strobe;
 	sdhci_enable_v4_mode(host);
+	__sdhci_read_caps(host, &version, NULL, NULL);
 
 	sdhci_get_of_property(pdev);
 
-- 
2.17.1


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

* Re: [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing
  2019-08-29 10:49 [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing Masahiro Yamada
  2019-08-29 10:49 ` [PATCH 2/3] mmc: sdhci: constify references of parameters to __sdhci_read_caps() Masahiro Yamada
  2019-08-29 10:49 ` [PATCH 3/3] mmc: sdhci-cadence: override spec version Masahiro Yamada
@ 2019-08-29 11:47 ` Ulf Hansson
  2019-08-29 12:05   ` Masahiro Yamada
  2 siblings, 1 reply; 12+ messages in thread
From: Ulf Hansson @ 2019-08-29 11:47 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-mmc, Adrian Hunter, Piotr Sroka, # 4.0+, Linux Kernel Mailing List

On Thu, 29 Aug 2019 at 12:49, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> The IP datasheet says this controller is compatible with SD Host
> Specification Version v4.00.
>
> As it turned out, the ADMA of this IP does not work with 64-bit mode
> when it is in the Version 3.00 compatible mode; it understands the
> old 64-bit descriptor table (as defined in SDHCI v2), but the ADMA
> System Address Register (SDHCI_ADMA_ADDRESS) cannot point to the
> 64-bit address.
>
> I noticed this issue only after commit bd2e75633c80 ("dma-contiguous:
> use fallback alloc_pages for single pages"). Prior to that commit,
> dma_set_mask_and_coherent() returned the dma address that fits in
> 32-bit range, at least for the default arm64 configuration
> (arch/arm64/configs/defconfig). Now the host->adma_addr exceeds the
> 32-bit limit, causing the real problem for the Socionext SoCs.
> (As a side-note, I was also able to reproduce the issue for older
> kernels by turning off CONFIG_DMA_CMA.)
>
> Call sdhci_enable_v4_mode() to fix this.
>
> I think it is better to back-port this, but only possible for v4.20+.
>
> When this driver was merged (v4.10), the v4 mode support did not exist.
> It was added by commit b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")
> i.e. v4.20.
>
> Cc: <stable@vger.kernel.org> # v4.20+
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Applied for fixes, by adding below tag, thanks!

Fixes: b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")

Kind regards
Uffe

> ---
>
>  drivers/mmc/host/sdhci-cadence.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c
> index 163d1cf4367e..44139fceac24 100644
> --- a/drivers/mmc/host/sdhci-cadence.c
> +++ b/drivers/mmc/host/sdhci-cadence.c
> @@ -369,6 +369,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
>         host->mmc_host_ops.execute_tuning = sdhci_cdns_execute_tuning;
>         host->mmc_host_ops.hs400_enhanced_strobe =
>                                 sdhci_cdns_hs400_enhanced_strobe;
> +       sdhci_enable_v4_mode(host);
>
>         sdhci_get_of_property(pdev);
>
> --
> 2.17.1
>

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

* Re: [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing
  2019-08-29 11:47 ` [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing Ulf Hansson
@ 2019-08-29 12:05   ` Masahiro Yamada
  2019-08-29 13:27     ` Ulf Hansson
  0 siblings, 1 reply; 12+ messages in thread
From: Masahiro Yamada @ 2019-08-29 12:05 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Adrian Hunter, Piotr Sroka, # 4.0+, Linux Kernel Mailing List

On Thu, Aug 29, 2019 at 8:48 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Thu, 29 Aug 2019 at 12:49, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
> >
> > The IP datasheet says this controller is compatible with SD Host
> > Specification Version v4.00.
> >
> > As it turned out, the ADMA of this IP does not work with 64-bit mode
> > when it is in the Version 3.00 compatible mode; it understands the
> > old 64-bit descriptor table (as defined in SDHCI v2), but the ADMA
> > System Address Register (SDHCI_ADMA_ADDRESS) cannot point to the
> > 64-bit address.
> >
> > I noticed this issue only after commit bd2e75633c80 ("dma-contiguous:
> > use fallback alloc_pages for single pages"). Prior to that commit,
> > dma_set_mask_and_coherent() returned the dma address that fits in
> > 32-bit range, at least for the default arm64 configuration
> > (arch/arm64/configs/defconfig). Now the host->adma_addr exceeds the
> > 32-bit limit, causing the real problem for the Socionext SoCs.
> > (As a side-note, I was also able to reproduce the issue for older
> > kernels by turning off CONFIG_DMA_CMA.)
> >
> > Call sdhci_enable_v4_mode() to fix this.
> >
> > I think it is better to back-port this, but only possible for v4.20+.
> >
> > When this driver was merged (v4.10), the v4 mode support did not exist.
> > It was added by commit b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")
> > i.e. v4.20.
> >
> > Cc: <stable@vger.kernel.org> # v4.20+
> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>
> Applied for fixes, by adding below tag, thanks!
>
> Fixes: b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")

This is not a bug commit.





-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 2/3] mmc: sdhci: constify references of parameters to __sdhci_read_caps()
  2019-08-29 10:49 ` [PATCH 2/3] mmc: sdhci: constify references of parameters to __sdhci_read_caps() Masahiro Yamada
@ 2019-08-29 13:09   ` Adrian Hunter
  2019-08-29 13:34   ` Ulf Hansson
  1 sibling, 0 replies; 12+ messages in thread
From: Adrian Hunter @ 2019-08-29 13:09 UTC (permalink / raw)
  To: Masahiro Yamada, linux-mmc, Ulf Hansson; +Cc: Piotr Sroka, linux-kernel

On 29/08/19 1:49 PM, Masahiro Yamada wrote:
> __sdhci_read_caps() does not modify *ver, *caps, or *caps1.
> 
> Probably, the caller of this function will want to constifythe
> parameters passed in.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

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

> ---
> 
>  drivers/mmc/host/sdhci.c | 3 ++-
>  drivers/mmc/host/sdhci.h | 4 ++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index a5dc5aae973e..08cc0792c174 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -3565,7 +3565,8 @@ static int sdhci_set_dma_mask(struct sdhci_host *host)
>  	return ret;
>  }
>  
> -void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps, u32 *caps1)
> +void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
> +		       const u32 *caps, const u32 *caps1)
>  {
>  	u16 v;
>  	u64 dt_caps_mask = 0;
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index 902f855efe8f..81e23784475a 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -738,8 +738,8 @@ static inline void *sdhci_priv(struct sdhci_host *host)
>  }
>  
>  void sdhci_card_detect(struct sdhci_host *host);
> -void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps,
> -		       u32 *caps1);
> +void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
> +		       const u32 *caps, const u32 *caps1);
>  int sdhci_setup_host(struct sdhci_host *host);
>  void sdhci_cleanup_host(struct sdhci_host *host);
>  int __sdhci_add_host(struct sdhci_host *host);
> 


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

* Re: [PATCH 3/3] mmc: sdhci-cadence: override spec version
  2019-08-29 10:49 ` [PATCH 3/3] mmc: sdhci-cadence: override spec version Masahiro Yamada
@ 2019-08-29 13:14   ` Adrian Hunter
  2019-08-29 13:34   ` Ulf Hansson
  1 sibling, 0 replies; 12+ messages in thread
From: Adrian Hunter @ 2019-08-29 13:14 UTC (permalink / raw)
  To: Masahiro Yamada, linux-mmc, Ulf Hansson; +Cc: Piotr Sroka, linux-kernel

On 29/08/19 1:49 PM, Masahiro Yamada wrote:
> The datasheet of the IP (sd4hc) says it is compiatible with SDHCI v4,
> but the spec version field in the version register is read as 2
> (i.e. SDHCI_SPEC_300) based on the RTL provided by Cadence.
> 
> Socionext did not fix it up when it integrated the IP into the SoCs.
> So, it is working as SDHCI v3.
> 
> It is not a real problem because there is no difference in the program
> flow in sdhci.c between SDHCI_SPEC_300/400, but set the real version
> just in case.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

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

> ---
> 
>  drivers/mmc/host/sdhci-cadence.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c
> index 44139fceac24..9837214685b6 100644
> --- a/drivers/mmc/host/sdhci-cadence.c
> +++ b/drivers/mmc/host/sdhci-cadence.c
> @@ -341,6 +341,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
>  	unsigned int nr_phy_params;
>  	int ret;
>  	struct device *dev = &pdev->dev;
> +	static const u16 version = SDHCI_SPEC_400 << SDHCI_SPEC_VER_SHIFT;
>  
>  	clk = devm_clk_get(dev, NULL);
>  	if (IS_ERR(clk))
> @@ -370,6 +371,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
>  	host->mmc_host_ops.hs400_enhanced_strobe =
>  				sdhci_cdns_hs400_enhanced_strobe;
>  	sdhci_enable_v4_mode(host);
> +	__sdhci_read_caps(host, &version, NULL, NULL);
>  
>  	sdhci_get_of_property(pdev);
>  
> 


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

* Re: [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing
  2019-08-29 12:05   ` Masahiro Yamada
@ 2019-08-29 13:27     ` Ulf Hansson
  2019-08-29 14:04       ` Masahiro Yamada
  0 siblings, 1 reply; 12+ messages in thread
From: Ulf Hansson @ 2019-08-29 13:27 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-mmc, Adrian Hunter, Piotr Sroka, # 4.0+, Linux Kernel Mailing List

On Thu, 29 Aug 2019 at 14:05, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> On Thu, Aug 29, 2019 at 8:48 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >
> > On Thu, 29 Aug 2019 at 12:49, Masahiro Yamada
> > <yamada.masahiro@socionext.com> wrote:
> > >
> > > The IP datasheet says this controller is compatible with SD Host
> > > Specification Version v4.00.
> > >
> > > As it turned out, the ADMA of this IP does not work with 64-bit mode
> > > when it is in the Version 3.00 compatible mode; it understands the
> > > old 64-bit descriptor table (as defined in SDHCI v2), but the ADMA
> > > System Address Register (SDHCI_ADMA_ADDRESS) cannot point to the
> > > 64-bit address.
> > >
> > > I noticed this issue only after commit bd2e75633c80 ("dma-contiguous:
> > > use fallback alloc_pages for single pages"). Prior to that commit,
> > > dma_set_mask_and_coherent() returned the dma address that fits in
> > > 32-bit range, at least for the default arm64 configuration
> > > (arch/arm64/configs/defconfig). Now the host->adma_addr exceeds the
> > > 32-bit limit, causing the real problem for the Socionext SoCs.
> > > (As a side-note, I was also able to reproduce the issue for older
> > > kernels by turning off CONFIG_DMA_CMA.)
> > >
> > > Call sdhci_enable_v4_mode() to fix this.
> > >
> > > I think it is better to back-port this, but only possible for v4.20+.
> > >
> > > When this driver was merged (v4.10), the v4 mode support did not exist.
> > > It was added by commit b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")
> > > i.e. v4.20.
> > >
> > > Cc: <stable@vger.kernel.org> # v4.20+
> > > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> >
> > Applied for fixes, by adding below tag, thanks!
> >
> > Fixes: b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")
>
> This is not a bug commit.

Right, but it can't be applied before this commit, hence why I added
it. Not sure that it matters, but I can remove the tag if you
insists!?

Kind regards
Uffe

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

* Re: [PATCH 2/3] mmc: sdhci: constify references of parameters to __sdhci_read_caps()
  2019-08-29 10:49 ` [PATCH 2/3] mmc: sdhci: constify references of parameters to __sdhci_read_caps() Masahiro Yamada
  2019-08-29 13:09   ` Adrian Hunter
@ 2019-08-29 13:34   ` Ulf Hansson
  1 sibling, 0 replies; 12+ messages in thread
From: Ulf Hansson @ 2019-08-29 13:34 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-mmc, Adrian Hunter, Piotr Sroka, Linux Kernel Mailing List

On Thu, 29 Aug 2019 at 12:49, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> __sdhci_read_caps() does not modify *ver, *caps, or *caps1.
>
> Probably, the caller of this function will want to constifythe
> parameters passed in.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>
>  drivers/mmc/host/sdhci.c | 3 ++-
>  drivers/mmc/host/sdhci.h | 4 ++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index a5dc5aae973e..08cc0792c174 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -3565,7 +3565,8 @@ static int sdhci_set_dma_mask(struct sdhci_host *host)
>         return ret;
>  }
>
> -void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps, u32 *caps1)
> +void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
> +                      const u32 *caps, const u32 *caps1)
>  {
>         u16 v;
>         u64 dt_caps_mask = 0;
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index 902f855efe8f..81e23784475a 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -738,8 +738,8 @@ static inline void *sdhci_priv(struct sdhci_host *host)
>  }
>
>  void sdhci_card_detect(struct sdhci_host *host);
> -void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps,
> -                      u32 *caps1);
> +void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
> +                      const u32 *caps, const u32 *caps1);
>  int sdhci_setup_host(struct sdhci_host *host);
>  void sdhci_cleanup_host(struct sdhci_host *host);
>  int __sdhci_add_host(struct sdhci_host *host);
> --
> 2.17.1
>

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

* Re: [PATCH 3/3] mmc: sdhci-cadence: override spec version
  2019-08-29 10:49 ` [PATCH 3/3] mmc: sdhci-cadence: override spec version Masahiro Yamada
  2019-08-29 13:14   ` Adrian Hunter
@ 2019-08-29 13:34   ` Ulf Hansson
  1 sibling, 0 replies; 12+ messages in thread
From: Ulf Hansson @ 2019-08-29 13:34 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-mmc, Adrian Hunter, Piotr Sroka, Linux Kernel Mailing List

On Thu, 29 Aug 2019 at 12:49, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> The datasheet of the IP (sd4hc) says it is compiatible with SDHCI v4,
> but the spec version field in the version register is read as 2
> (i.e. SDHCI_SPEC_300) based on the RTL provided by Cadence.
>
> Socionext did not fix it up when it integrated the IP into the SoCs.
> So, it is working as SDHCI v3.
>
> It is not a real problem because there is no difference in the program
> flow in sdhci.c between SDHCI_SPEC_300/400, but set the real version
> just in case.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>
>  drivers/mmc/host/sdhci-cadence.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cadence.c
> index 44139fceac24..9837214685b6 100644
> --- a/drivers/mmc/host/sdhci-cadence.c
> +++ b/drivers/mmc/host/sdhci-cadence.c
> @@ -341,6 +341,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
>         unsigned int nr_phy_params;
>         int ret;
>         struct device *dev = &pdev->dev;
> +       static const u16 version = SDHCI_SPEC_400 << SDHCI_SPEC_VER_SHIFT;
>
>         clk = devm_clk_get(dev, NULL);
>         if (IS_ERR(clk))
> @@ -370,6 +371,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
>         host->mmc_host_ops.hs400_enhanced_strobe =
>                                 sdhci_cdns_hs400_enhanced_strobe;
>         sdhci_enable_v4_mode(host);
> +       __sdhci_read_caps(host, &version, NULL, NULL);
>
>         sdhci_get_of_property(pdev);
>
> --
> 2.17.1
>

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

* Re: [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing
  2019-08-29 13:27     ` Ulf Hansson
@ 2019-08-29 14:04       ` Masahiro Yamada
  2019-08-29 14:33         ` Ulf Hansson
  0 siblings, 1 reply; 12+ messages in thread
From: Masahiro Yamada @ 2019-08-29 14:04 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: linux-mmc, Adrian Hunter, Piotr Sroka, # 4.0+, Linux Kernel Mailing List

Hi Ulf,

On Thu, Aug 29, 2019 at 10:27 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Thu, 29 Aug 2019 at 14:05, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
> >
> > On Thu, Aug 29, 2019 at 8:48 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > >
> > > On Thu, 29 Aug 2019 at 12:49, Masahiro Yamada
> > > <yamada.masahiro@socionext.com> wrote:
> > > >
> > > > The IP datasheet says this controller is compatible with SD Host
> > > > Specification Version v4.00.
> > > >
> > > > As it turned out, the ADMA of this IP does not work with 64-bit mode
> > > > when it is in the Version 3.00 compatible mode; it understands the
> > > > old 64-bit descriptor table (as defined in SDHCI v2), but the ADMA
> > > > System Address Register (SDHCI_ADMA_ADDRESS) cannot point to the
> > > > 64-bit address.
> > > >
> > > > I noticed this issue only after commit bd2e75633c80 ("dma-contiguous:
> > > > use fallback alloc_pages for single pages"). Prior to that commit,
> > > > dma_set_mask_and_coherent() returned the dma address that fits in
> > > > 32-bit range, at least for the default arm64 configuration
> > > > (arch/arm64/configs/defconfig). Now the host->adma_addr exceeds the
> > > > 32-bit limit, causing the real problem for the Socionext SoCs.
> > > > (As a side-note, I was also able to reproduce the issue for older
> > > > kernels by turning off CONFIG_DMA_CMA.)
> > > >
> > > > Call sdhci_enable_v4_mode() to fix this.
> > > >
> > > > I think it is better to back-port this, but only possible for v4.20+.
> > > >
> > > > When this driver was merged (v4.10), the v4 mode support did not exist.
> > > > It was added by commit b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")
> > > > i.e. v4.20.
> > > >
> > > > Cc: <stable@vger.kernel.org> # v4.20+
> > > > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> > >
> > > Applied for fixes, by adding below tag, thanks!
> > >
> > > Fixes: b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")
> >
> > This is not a bug commit.
>
> Right, but it can't be applied before this commit, hence why I added
> it. Not sure that it matters, but I can remove the tag if you
> insists!?

I hesitate to add Fixes to the commit that
did nothing wrong.


I added "Cc: <stable@vger.kernel.org> # v4.20+"
so this is enough for the stable kernel maintainers.




-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing
  2019-08-29 14:04       ` Masahiro Yamada
@ 2019-08-29 14:33         ` Ulf Hansson
  0 siblings, 0 replies; 12+ messages in thread
From: Ulf Hansson @ 2019-08-29 14:33 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-mmc, Adrian Hunter, Piotr Sroka, # 4.0+, Linux Kernel Mailing List

On Thu, 29 Aug 2019 at 16:04, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> Hi Ulf,
>
> On Thu, Aug 29, 2019 at 10:27 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >
> > On Thu, 29 Aug 2019 at 14:05, Masahiro Yamada
> > <yamada.masahiro@socionext.com> wrote:
> > >
> > > On Thu, Aug 29, 2019 at 8:48 PM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > >
> > > > On Thu, 29 Aug 2019 at 12:49, Masahiro Yamada
> > > > <yamada.masahiro@socionext.com> wrote:
> > > > >
> > > > > The IP datasheet says this controller is compatible with SD Host
> > > > > Specification Version v4.00.
> > > > >
> > > > > As it turned out, the ADMA of this IP does not work with 64-bit mode
> > > > > when it is in the Version 3.00 compatible mode; it understands the
> > > > > old 64-bit descriptor table (as defined in SDHCI v2), but the ADMA
> > > > > System Address Register (SDHCI_ADMA_ADDRESS) cannot point to the
> > > > > 64-bit address.
> > > > >
> > > > > I noticed this issue only after commit bd2e75633c80 ("dma-contiguous:
> > > > > use fallback alloc_pages for single pages"). Prior to that commit,
> > > > > dma_set_mask_and_coherent() returned the dma address that fits in
> > > > > 32-bit range, at least for the default arm64 configuration
> > > > > (arch/arm64/configs/defconfig). Now the host->adma_addr exceeds the
> > > > > 32-bit limit, causing the real problem for the Socionext SoCs.
> > > > > (As a side-note, I was also able to reproduce the issue for older
> > > > > kernels by turning off CONFIG_DMA_CMA.)
> > > > >
> > > > > Call sdhci_enable_v4_mode() to fix this.
> > > > >
> > > > > I think it is better to back-port this, but only possible for v4.20+.
> > > > >
> > > > > When this driver was merged (v4.10), the v4 mode support did not exist.
> > > > > It was added by commit b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")
> > > > > i.e. v4.20.
> > > > >
> > > > > Cc: <stable@vger.kernel.org> # v4.20+
> > > > > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> > > >
> > > > Applied for fixes, by adding below tag, thanks!
> > > >
> > > > Fixes: b3f80b434f72 ("mmc: sdhci: Add sd host v4 mode")
> > >
> > > This is not a bug commit.
> >
> > Right, but it can't be applied before this commit, hence why I added
> > it. Not sure that it matters, but I can remove the tag if you
> > insists!?
>
> I hesitate to add Fixes to the commit that
> did nothing wrong.
>
>
> I added "Cc: <stable@vger.kernel.org> # v4.20+"
> so this is enough for the stable kernel maintainers.

Yes, I drop the fixes tag. But as I said, I don't think it's a big deal.

Kind regards
Uffe

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

end of thread, other threads:[~2019-08-29 14:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-29 10:49 [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing Masahiro Yamada
2019-08-29 10:49 ` [PATCH 2/3] mmc: sdhci: constify references of parameters to __sdhci_read_caps() Masahiro Yamada
2019-08-29 13:09   ` Adrian Hunter
2019-08-29 13:34   ` Ulf Hansson
2019-08-29 10:49 ` [PATCH 3/3] mmc: sdhci-cadence: override spec version Masahiro Yamada
2019-08-29 13:14   ` Adrian Hunter
2019-08-29 13:34   ` Ulf Hansson
2019-08-29 11:47 ` [PATCH 1/3] mmc: sdhci-cadence: enable v4_mode to fix ADMA 64-bit addressing Ulf Hansson
2019-08-29 12:05   ` Masahiro Yamada
2019-08-29 13:27     ` Ulf Hansson
2019-08-29 14:04       ` Masahiro Yamada
2019-08-29 14:33         ` 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).