All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips
@ 2018-06-28  8:45 Laurentiu Tudor
  2018-07-02 14:37 ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Laurentiu Tudor @ 2018-06-28  8:45 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson, linux-mmc, linux-kernel
  Cc: yangbo.lu, Laurentiu Tudor

SDHCI controller in ls1043a and ls1046a generate 40-bit wide addresses
when doing DMA. Make sure that the corresponding dma mask is correctly
configured.

Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
---
 drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 4ffa6b173a21..8332f56e6c0d 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -22,6 +22,7 @@
 #include <linux/sys_soc.h>
 #include <linux/clk.h>
 #include <linux/ktime.h>
+#include <linux/dma-mapping.h>
 #include <linux/mmc/host.h>
 #include "sdhci-pltfm.h"
 #include "sdhci-esdhc.h"
@@ -427,6 +428,11 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
 static int esdhc_of_enable_dma(struct sdhci_host *host)
 {
 	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));
 
 	value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
 	value |= ESDHC_DMA_SNOOP;
-- 
2.17.1


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

* Re: [PATCH] mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips
  2018-06-28  8:45 [PATCH] mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips Laurentiu Tudor
@ 2018-07-02 14:37 ` Ulf Hansson
  2018-07-03 11:15   ` Laurentiu Tudor
  0 siblings, 1 reply; 6+ messages in thread
From: Ulf Hansson @ 2018-07-02 14:37 UTC (permalink / raw)
  To: Laurentiu Tudor
  Cc: Adrian Hunter, linux-mmc, Linux Kernel Mailing List, Yangbo Lu

On 28 June 2018 at 10:45, Laurentiu Tudor <laurentiu.tudor@nxp.com> wrote:
> SDHCI controller in ls1043a and ls1046a generate 40-bit wide addresses
> when doing DMA. Make sure that the corresponding dma mask is correctly
> configured.
>
> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>

Thanks, applied for next!

Kind regards
Uffe

> ---
>  drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index 4ffa6b173a21..8332f56e6c0d 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -22,6 +22,7 @@
>  #include <linux/sys_soc.h>
>  #include <linux/clk.h>
>  #include <linux/ktime.h>
> +#include <linux/dma-mapping.h>
>  #include <linux/mmc/host.h>
>  #include "sdhci-pltfm.h"
>  #include "sdhci-esdhc.h"
> @@ -427,6 +428,11 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
>  static int esdhc_of_enable_dma(struct sdhci_host *host)
>  {
>         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));
>
>         value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
>         value |= ESDHC_DMA_SNOOP;
> --
> 2.17.1
>

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

* Re: [PATCH] mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips
  2018-07-02 14:37 ` Ulf Hansson
@ 2018-07-03 11:15   ` Laurentiu Tudor
  2018-07-04 10:55     ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Laurentiu Tudor @ 2018-07-03 11:15 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: Adrian Hunter, linux-mmc, Linux Kernel Mailing List, Y.b. Lu

Hi Uffe,

On 02.07.2018 17:37, Ulf Hansson wrote:
> On 28 June 2018 at 10:45, Laurentiu Tudor <laurentiu.tudor@nxp.com> wrote:
>> SDHCI controller in ls1043a and ls1046a generate 40-bit wide addresses
>> when doing DMA. Make sure that the corresponding dma mask is correctly
>> configured.
>>
>> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> 
> Thanks, applied for next!

Thanks for picking this up!
I just realized that maybe I should have provided some context around 
this patch. I'm working on enabling smmu on these chips and encountered 
the following problem: the smmu input address size is 48 bits so the dma 
mappings for sdhci end up 48-bit wide. However, on these chips sdhci 
only use 40-bits of that address size when doing dma.
So you end up with a 48-bit address translation in smmu but the device 
generates transactions with clipped 40-bit addresses, thus smmu context 
faults are triggered. Setting up the correct dma mask fixes this situation.

---
Best Regards, Laurentiu

> 
>> ---
>>   drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
>> index 4ffa6b173a21..8332f56e6c0d 100644
>> --- a/drivers/mmc/host/sdhci-of-esdhc.c
>> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
>> @@ -22,6 +22,7 @@
>>   #include <linux/sys_soc.h>
>>   #include <linux/clk.h>
>>   #include <linux/ktime.h>
>> +#include <linux/dma-mapping.h>
>>   #include <linux/mmc/host.h>
>>   #include "sdhci-pltfm.h"
>>   #include "sdhci-esdhc.h"
>> @@ -427,6 +428,11 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
>>   static int esdhc_of_enable_dma(struct sdhci_host *host)
>>   {
>>          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));
>>
>>          value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
>>          value |= ESDHC_DMA_SNOOP;
>> --
>> 2.17.1
>>

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

* Re: [PATCH] mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips
  2018-07-03 11:15   ` Laurentiu Tudor
@ 2018-07-04 10:55     ` Ulf Hansson
  2018-07-04 11:34       ` [PATCH v2] " Laurentiu Tudor
  0 siblings, 1 reply; 6+ messages in thread
From: Ulf Hansson @ 2018-07-04 10:55 UTC (permalink / raw)
  To: Laurentiu Tudor
  Cc: Adrian Hunter, linux-mmc, Linux Kernel Mailing List, Y.b. Lu

On 3 July 2018 at 13:15, Laurentiu Tudor <laurentiu.tudor@nxp.com> wrote:
> Hi Uffe,
>
> On 02.07.2018 17:37, Ulf Hansson wrote:
>> On 28 June 2018 at 10:45, Laurentiu Tudor <laurentiu.tudor@nxp.com> wrote:
>>> SDHCI controller in ls1043a and ls1046a generate 40-bit wide addresses
>>> when doing DMA. Make sure that the corresponding dma mask is correctly
>>> configured.
>>>
>>> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
>>
>> Thanks, applied for next!
>
> Thanks for picking this up!
> I just realized that maybe I should have provided some context around
> this patch. I'm working on enabling smmu on these chips and encountered
> the following problem: the smmu input address size is 48 bits so the dma
> mappings for sdhci end up 48-bit wide. However, on these chips sdhci
> only use 40-bits of that address size when doing dma.
> So you end up with a 48-bit address translation in smmu but the device
> generates transactions with clipped 40-bit addresses, thus smmu context
> faults are triggered. Setting up the correct dma mask fixes this situation.

That's perfect data for the changelog. Care to send a v2, then I
re-place the one I have just applied!

Kind regards
Uffe

>
> ---
> Best Regards, Laurentiu
>
>>
>>> ---
>>>   drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++++
>>>   1 file changed, 6 insertions(+)
>>>
>>> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
>>> index 4ffa6b173a21..8332f56e6c0d 100644
>>> --- a/drivers/mmc/host/sdhci-of-esdhc.c
>>> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
>>> @@ -22,6 +22,7 @@
>>>   #include <linux/sys_soc.h>
>>>   #include <linux/clk.h>
>>>   #include <linux/ktime.h>
>>> +#include <linux/dma-mapping.h>
>>>   #include <linux/mmc/host.h>
>>>   #include "sdhci-pltfm.h"
>>>   #include "sdhci-esdhc.h"
>>> @@ -427,6 +428,11 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
>>>   static int esdhc_of_enable_dma(struct sdhci_host *host)
>>>   {
>>>          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));
>>>
>>>          value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
>>>          value |= ESDHC_DMA_SNOOP;
>>> --
>>> 2.17.1
>>>

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

* [PATCH v2] mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips
  2018-07-04 10:55     ` Ulf Hansson
@ 2018-07-04 11:34       ` Laurentiu Tudor
  2018-07-05 13:09         ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Laurentiu Tudor @ 2018-07-04 11:34 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson, linux-mmc, linux-kernel
  Cc: yangbo.lu, Laurentiu Tudor

SDHCI controller in ls1043a and ls1046a generate 40-bit wide addresses
when doing DMA. Make sure that the corresponding dma mask is correctly
configured.

Context: when enabling smmu on these chips the following problem is
encountered: the smmu input address size is 48 bits so the dma mappings
for sdhci end up 48-bit wide. However, on these chips sdhci only use
40-bits of that address size when doing dma.
So you end up with a 48-bit address translation in smmu but the device
generates transactions with clipped 40-bit addresses, thus smmu context
faults are triggered. Setting up the correct dma mask fixes this
situation.

Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
---
Changes in v2:
 - updated commit log with some context

 drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 4ffa6b173a21..8332f56e6c0d 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -22,6 +22,7 @@
 #include <linux/sys_soc.h>
 #include <linux/clk.h>
 #include <linux/ktime.h>
+#include <linux/dma-mapping.h>
 #include <linux/mmc/host.h>
 #include "sdhci-pltfm.h"
 #include "sdhci-esdhc.h"
@@ -427,6 +428,11 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
 static int esdhc_of_enable_dma(struct sdhci_host *host)
 {
 	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));
 
 	value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
 	value |= ESDHC_DMA_SNOOP;
-- 
2.17.1


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

* Re: [PATCH v2] mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips
  2018-07-04 11:34       ` [PATCH v2] " Laurentiu Tudor
@ 2018-07-05 13:09         ` Ulf Hansson
  0 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2018-07-05 13:09 UTC (permalink / raw)
  To: Laurentiu Tudor
  Cc: Adrian Hunter, linux-mmc, Linux Kernel Mailing List, Yangbo Lu

On 4 July 2018 at 13:34, Laurentiu Tudor <laurentiu.tudor@nxp.com> wrote:
> SDHCI controller in ls1043a and ls1046a generate 40-bit wide addresses
> when doing DMA. Make sure that the corresponding dma mask is correctly
> configured.
>
> Context: when enabling smmu on these chips the following problem is
> encountered: the smmu input address size is 48 bits so the dma mappings
> for sdhci end up 48-bit wide. However, on these chips sdhci only use
> 40-bits of that address size when doing dma.
> So you end up with a 48-bit address translation in smmu but the device
> generates transactions with clipped 40-bit addresses, thus smmu context
> faults are triggered. Setting up the correct dma mask fixes this
> situation.
>
> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>

Thanks, re-placed v1 with v2 on my next branch.

Kind regards
Uffe

> ---
> Changes in v2:
>  - updated commit log with some context
>
>  drivers/mmc/host/sdhci-of-esdhc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
> index 4ffa6b173a21..8332f56e6c0d 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -22,6 +22,7 @@
>  #include <linux/sys_soc.h>
>  #include <linux/clk.h>
>  #include <linux/ktime.h>
> +#include <linux/dma-mapping.h>
>  #include <linux/mmc/host.h>
>  #include "sdhci-pltfm.h"
>  #include "sdhci-esdhc.h"
> @@ -427,6 +428,11 @@ static void esdhc_of_adma_workaround(struct sdhci_host *host, u32 intmask)
>  static int esdhc_of_enable_dma(struct sdhci_host *host)
>  {
>         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));
>
>         value = sdhci_readl(host, ESDHC_DMA_SYSCTL);
>         value |= ESDHC_DMA_SNOOP;
> --
> 2.17.1
>

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

end of thread, other threads:[~2018-07-05 13:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-28  8:45 [PATCH] mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips Laurentiu Tudor
2018-07-02 14:37 ` Ulf Hansson
2018-07-03 11:15   ` Laurentiu Tudor
2018-07-04 10:55     ` Ulf Hansson
2018-07-04 11:34       ` [PATCH v2] " Laurentiu Tudor
2018-07-05 13:09         ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.