All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] bouncebuf: add feature to support buffer only available in DRAM
@ 2019-05-07 13:51 Kever Yang
  2019-05-07 14:10 ` Simon Goldschmidt
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kever Yang @ 2019-05-07 13:51 UTC (permalink / raw)
  To: u-boot

Some DMA which inside peripheral controller can only access space in
DRAM area, the target address outside DRAM is not available.
eg. Rockchip MMC contrller's internal DMA can only access DRAM area.

Add Kconfig option and driver for people who need it.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
---

 common/bouncebuf.c  | 9 +++++++++
 drivers/mmc/Kconfig | 6 ++++++
 2 files changed, 15 insertions(+)

diff --git a/common/bouncebuf.c b/common/bouncebuf.c
index a7098e2caf..7ff2f488a4 100644
--- a/common/bouncebuf.c
+++ b/common/bouncebuf.c
@@ -10,6 +10,8 @@
 #include <errno.h>
 #include <bouncebuf.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 static int addr_aligned(struct bounce_buffer *state)
 {
 	const ulong align_mask = ARCH_DMA_MINALIGN - 1;
@@ -26,6 +28,13 @@ static int addr_aligned(struct bounce_buffer *state)
 		return 0;
 	}
 
+#ifdef MMC_BUF_IN_DRAM
+	if (((ulong)state->user_buffer < CONFIG_SYS_SDRAM_BASE) ||
+	    ((ulong)state->user_buffer > gd->ram_top)) {
+		debug("Not support buffer address %p\n", state->user_buffer);
+		return 0;
+	}
+#endif
 	/* Aligned */
 	return 1;
 }
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index c23299ea96..e852ee6175 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -671,6 +671,12 @@ config FSL_ESDHC
 	  This selects support for the eSDHC (enhanced secure digital host
 	  controller) found on numerous Freescale/NXP SoCs.
 
+config MMC_BUF_IN_DRAM
+	bool "Only buffer in DRAM is available"
+	help
+	  This selects support those controller whose internal DMA can only
+	  access SDRAM spaces and other spaces are not available.
+
 endmenu
 
 config SYS_FSL_ERRATUM_ESDHC111
-- 
2.20.1

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

* [U-Boot] [PATCH] bouncebuf: add feature to support buffer only available in DRAM
  2019-05-07 13:51 [U-Boot] [PATCH] bouncebuf: add feature to support buffer only available in DRAM Kever Yang
@ 2019-05-07 14:10 ` Simon Goldschmidt
  2019-05-07 14:12 ` Christoph Müllner
  2019-05-08  5:26 ` Peng Fan
  2 siblings, 0 replies; 6+ messages in thread
From: Simon Goldschmidt @ 2019-05-07 14:10 UTC (permalink / raw)
  To: u-boot

On Tue, May 7, 2019 at 3:53 PM Kever Yang <kever.yang@rock-chips.com> wrote:
>
> Some DMA which inside peripheral controller can only access space in
> DRAM area, the target address outside DRAM is not available.
> eg. Rockchip MMC contrller's internal DMA can only access DRAM area.
>
> Add Kconfig option and driver for people who need it.
>
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> ---
>
>  common/bouncebuf.c  | 9 +++++++++
>  drivers/mmc/Kconfig | 6 ++++++
>  2 files changed, 15 insertions(+)
>
> diff --git a/common/bouncebuf.c b/common/bouncebuf.c
> index a7098e2caf..7ff2f488a4 100644
> --- a/common/bouncebuf.c
> +++ b/common/bouncebuf.c
> @@ -10,6 +10,8 @@
>  #include <errno.h>
>  #include <bouncebuf.h>
>
> +DECLARE_GLOBAL_DATA_PTR;
> +
>  static int addr_aligned(struct bounce_buffer *state)
>  {
>         const ulong align_mask = ARCH_DMA_MINALIGN - 1;
> @@ -26,6 +28,13 @@ static int addr_aligned(struct bounce_buffer *state)
>                 return 0;
>         }
>
> +#ifdef MMC_BUF_IN_DRAM

That again seems misplaced here. Why do we need MMC
things in such a central file?

Regards,
Simon

> +       if (((ulong)state->user_buffer < CONFIG_SYS_SDRAM_BASE) ||
> +           ((ulong)state->user_buffer > gd->ram_top)) {
> +               debug("Not support buffer address %p\n", state->user_buffer);
> +               return 0;
> +       }
> +#endif
>         /* Aligned */
>         return 1;
>  }
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index c23299ea96..e852ee6175 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -671,6 +671,12 @@ config FSL_ESDHC
>           This selects support for the eSDHC (enhanced secure digital host
>           controller) found on numerous Freescale/NXP SoCs.
>
> +config MMC_BUF_IN_DRAM
> +       bool "Only buffer in DRAM is available"
> +       help
> +         This selects support those controller whose internal DMA can only
> +         access SDRAM spaces and other spaces are not available.
> +
>  endmenu
>
>  config SYS_FSL_ERRATUM_ESDHC111
> --
> 2.20.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

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

* [U-Boot] [PATCH] bouncebuf: add feature to support buffer only available in DRAM
  2019-05-07 13:51 [U-Boot] [PATCH] bouncebuf: add feature to support buffer only available in DRAM Kever Yang
  2019-05-07 14:10 ` Simon Goldschmidt
@ 2019-05-07 14:12 ` Christoph Müllner
  2019-05-08  5:26 ` Peng Fan
  2 siblings, 0 replies; 6+ messages in thread
From: Christoph Müllner @ 2019-05-07 14:12 UTC (permalink / raw)
  To: u-boot



On 07.05.19 15:51, Kever Yang wrote:
> Some DMA which inside peripheral controller can only access space in
> DRAM area, the target address outside DRAM is not available.
> eg. Rockchip MMC contrller's internal DMA can only access DRAM area.
> 
> Add Kconfig option and driver for people who need it.

Hi Kever,

I've addressed this in a different way:

https://lists.denx.de/pipermail/u-boot/2019-May/368307.html
https://lists.denx.de/pipermail/u-boot/2019-May/368305.html
https://lists.denx.de/pipermail/u-boot/2019-May/368306.html

BR
Christoph

> 
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> ---
> 
>  common/bouncebuf.c  | 9 +++++++++
>  drivers/mmc/Kconfig | 6 ++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/common/bouncebuf.c b/common/bouncebuf.c
> index a7098e2caf..7ff2f488a4 100644
> --- a/common/bouncebuf.c
> +++ b/common/bouncebuf.c
> @@ -10,6 +10,8 @@
>  #include <errno.h>
>  #include <bouncebuf.h>
>  
> +DECLARE_GLOBAL_DATA_PTR;
> +
>  static int addr_aligned(struct bounce_buffer *state)
>  {
>  	const ulong align_mask = ARCH_DMA_MINALIGN - 1;
> @@ -26,6 +28,13 @@ static int addr_aligned(struct bounce_buffer *state)
>  		return 0;
>  	}
>  
> +#ifdef MMC_BUF_IN_DRAM
> +	if (((ulong)state->user_buffer < CONFIG_SYS_SDRAM_BASE) ||
> +	    ((ulong)state->user_buffer > gd->ram_top)) {
> +		debug("Not support buffer address %p\n", state->user_buffer);
> +		return 0;
> +	}
> +#endif
>  	/* Aligned */
>  	return 1;
>  }
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index c23299ea96..e852ee6175 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -671,6 +671,12 @@ config FSL_ESDHC
>  	  This selects support for the eSDHC (enhanced secure digital host
>  	  controller) found on numerous Freescale/NXP SoCs.
>  
> +config MMC_BUF_IN_DRAM
> +	bool "Only buffer in DRAM is available"
> +	help
> +	  This selects support those controller whose internal DMA can only
> +	  access SDRAM spaces and other spaces are not available.
> +
>  endmenu
>  
>  config SYS_FSL_ERRATUM_ESDHC111
> 

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

* [U-Boot] [PATCH] bouncebuf: add feature to support buffer only available in DRAM
  2019-05-07 13:51 [U-Boot] [PATCH] bouncebuf: add feature to support buffer only available in DRAM Kever Yang
  2019-05-07 14:10 ` Simon Goldschmidt
  2019-05-07 14:12 ` Christoph Müllner
@ 2019-05-08  5:26 ` Peng Fan
  2019-05-08 10:52   ` Marek Vasut
  2 siblings, 1 reply; 6+ messages in thread
From: Peng Fan @ 2019-05-08  5:26 UTC (permalink / raw)
  To: u-boot

Hi Kever,

> Subject: [PATCH] bouncebuf: add feature to support buffer only available in
> DRAM
> 
> Some DMA which inside peripheral controller can only access space in DRAM
> area, the target address outside DRAM is not available.
> eg. Rockchip MMC contrller's internal DMA can only access DRAM area.
> 
> Add Kconfig option and driver for people who need it.
> 
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> ---
> 
>  common/bouncebuf.c  | 9 +++++++++
>  drivers/mmc/Kconfig | 6 ++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/common/bouncebuf.c b/common/bouncebuf.c index
> a7098e2caf..7ff2f488a4 100644
> --- a/common/bouncebuf.c
> +++ b/common/bouncebuf.c
> @@ -10,6 +10,8 @@
>  #include <errno.h>
>  #include <bouncebuf.h>
> 
> +DECLARE_GLOBAL_DATA_PTR;
> +
>  static int addr_aligned(struct bounce_buffer *state)  {
>  	const ulong align_mask = ARCH_DMA_MINALIGN - 1; @@ -26,6 +28,13
> @@ static int addr_aligned(struct bounce_buffer *state)
>  		return 0;
>  	}
> 
> +#ifdef MMC_BUF_IN_DRAM
> +	if (((ulong)state->user_buffer < CONFIG_SYS_SDRAM_BASE) ||
> +	    ((ulong)state->user_buffer > gd->ram_top)) {
> +		debug("Not support buffer address %p\n", state->user_buffer);
> +		return 0;
> +	}
> +#endif
>  	/* Aligned */
>  	return 1;
>  }
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index
> c23299ea96..e852ee6175 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -671,6 +671,12 @@ config FSL_ESDHC
>  	  This selects support for the eSDHC (enhanced secure digital host
>  	  controller) found on numerous Freescale/NXP SoCs.
> 
> +config MMC_BUF_IN_DRAM
> +	bool "Only buffer in DRAM is available"
> +	help
> +	  This selects support those controller whose internal DMA can only
> +	  access SDRAM spaces and other spaces are not available.
> +

I think introduce a new GEN_BB_FORCE flags might be better, no need to
introduce new kconfig entry, and it will be easier for others to use, if
there are other controllers has same limitation.

Regards,
Peng.

>  endmenu
> 
>  config SYS_FSL_ERRATUM_ESDHC111
> --
> 2.20.1

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

* [U-Boot] [PATCH] bouncebuf: add feature to support buffer only available in DRAM
  2019-05-08  5:26 ` Peng Fan
@ 2019-05-08 10:52   ` Marek Vasut
  2019-05-08 10:59     ` Christoph Müllner
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2019-05-08 10:52 UTC (permalink / raw)
  To: u-boot

On 5/8/19 7:26 AM, Peng Fan wrote:
> Hi Kever,
> 
>> Subject: [PATCH] bouncebuf: add feature to support buffer only available in
>> DRAM
>>
>> Some DMA which inside peripheral controller can only access space in DRAM
>> area, the target address outside DRAM is not available.
>> eg. Rockchip MMC contrller's internal DMA can only access DRAM area.
>>
>> Add Kconfig option and driver for people who need it.
>>
>> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
>> ---
>>
>>  common/bouncebuf.c  | 9 +++++++++
>>  drivers/mmc/Kconfig | 6 ++++++
>>  2 files changed, 15 insertions(+)
>>
>> diff --git a/common/bouncebuf.c b/common/bouncebuf.c index
>> a7098e2caf..7ff2f488a4 100644
>> --- a/common/bouncebuf.c
>> +++ b/common/bouncebuf.c
>> @@ -10,6 +10,8 @@
>>  #include <errno.h>
>>  #include <bouncebuf.h>
>>
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>>  static int addr_aligned(struct bounce_buffer *state)  {
>>  	const ulong align_mask = ARCH_DMA_MINALIGN - 1; @@ -26,6 +28,13
>> @@ static int addr_aligned(struct bounce_buffer *state)
>>  		return 0;
>>  	}
>>
>> +#ifdef MMC_BUF_IN_DRAM
>> +	if (((ulong)state->user_buffer < CONFIG_SYS_SDRAM_BASE) ||
>> +	    ((ulong)state->user_buffer > gd->ram_top)) {
>> +		debug("Not support buffer address %p\n", state->user_buffer);
>> +		return 0;
>> +	}
>> +#endif
>>  	/* Aligned */
>>  	return 1;
>>  }
>> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index
>> c23299ea96..e852ee6175 100644
>> --- a/drivers/mmc/Kconfig
>> +++ b/drivers/mmc/Kconfig
>> @@ -671,6 +671,12 @@ config FSL_ESDHC
>>  	  This selects support for the eSDHC (enhanced secure digital host
>>  	  controller) found on numerous Freescale/NXP SoCs.
>>
>> +config MMC_BUF_IN_DRAM
>> +	bool "Only buffer in DRAM is available"
>> +	help
>> +	  This selects support those controller whose internal DMA can only
>> +	  access SDRAM spaces and other spaces are not available.
>> +
> 
> I think introduce a new GEN_BB_FORCE flags might be better, no need to
> introduce new kconfig entry, and it will be easier for others to use, if
> there are other controllers has same limitation.

Is the bounce buffer really the right place to put per-driver DMA
restrictions ?

-- 
Best regards,
Marek Vasut

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

* [U-Boot] [PATCH] bouncebuf: add feature to support buffer only available in DRAM
  2019-05-08 10:52   ` Marek Vasut
@ 2019-05-08 10:59     ` Christoph Müllner
  0 siblings, 0 replies; 6+ messages in thread
From: Christoph Müllner @ 2019-05-08 10:59 UTC (permalink / raw)
  To: u-boot



On 08.05.19 12:52, Marek Vasut wrote:
> On 5/8/19 7:26 AM, Peng Fan wrote:
>> Hi Kever,
>>
>>> Subject: [PATCH] bouncebuf: add feature to support buffer only available in
>>> DRAM
>>>
>>> Some DMA which inside peripheral controller can only access space in DRAM
>>> area, the target address outside DRAM is not available.
>>> eg. Rockchip MMC contrller's internal DMA can only access DRAM area.
>>>
>>> Add Kconfig option and driver for people who need it.
>>>
>>> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
>>> ---
>>>
>>>  common/bouncebuf.c  | 9 +++++++++
>>>  drivers/mmc/Kconfig | 6 ++++++
>>>  2 files changed, 15 insertions(+)
>>>
>>> diff --git a/common/bouncebuf.c b/common/bouncebuf.c index
>>> a7098e2caf..7ff2f488a4 100644
>>> --- a/common/bouncebuf.c
>>> +++ b/common/bouncebuf.c
>>> @@ -10,6 +10,8 @@
>>>  #include <errno.h>
>>>  #include <bouncebuf.h>
>>>
>>> +DECLARE_GLOBAL_DATA_PTR;
>>> +
>>>  static int addr_aligned(struct bounce_buffer *state)  {
>>>  	const ulong align_mask = ARCH_DMA_MINALIGN - 1; @@ -26,6 +28,13
>>> @@ static int addr_aligned(struct bounce_buffer *state)
>>>  		return 0;
>>>  	}
>>>
>>> +#ifdef MMC_BUF_IN_DRAM
>>> +	if (((ulong)state->user_buffer < CONFIG_SYS_SDRAM_BASE) ||
>>> +	    ((ulong)state->user_buffer > gd->ram_top)) {
>>> +		debug("Not support buffer address %p\n", state->user_buffer);
>>> +		return 0;
>>> +	}
>>> +#endif
>>>  	/* Aligned */
>>>  	return 1;
>>>  }
>>> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index
>>> c23299ea96..e852ee6175 100644
>>> --- a/drivers/mmc/Kconfig
>>> +++ b/drivers/mmc/Kconfig
>>> @@ -671,6 +671,12 @@ config FSL_ESDHC
>>>  	  This selects support for the eSDHC (enhanced secure digital host
>>>  	  controller) found on numerous Freescale/NXP SoCs.
>>>
>>> +config MMC_BUF_IN_DRAM
>>> +	bool "Only buffer in DRAM is available"
>>> +	help
>>> +	  This selects support those controller whose internal DMA can only
>>> +	  access SDRAM spaces and other spaces are not available.
>>> +
>>
>> I think introduce a new GEN_BB_FORCE flags might be better, no need to
>> introduce new kconfig entry, and it will be easier for others to use, if
>> there are other controllers has same limitation.
> 
> Is the bounce buffer really the right place to put per-driver DMA
> restrictions ?

Also note that this patch addresses the exact same problem,
that my bouncebuffer mach_is_dmaable() series tackles.

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

end of thread, other threads:[~2019-05-08 10:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-07 13:51 [U-Boot] [PATCH] bouncebuf: add feature to support buffer only available in DRAM Kever Yang
2019-05-07 14:10 ` Simon Goldschmidt
2019-05-07 14:12 ` Christoph Müllner
2019-05-08  5:26 ` Peng Fan
2019-05-08 10:52   ` Marek Vasut
2019-05-08 10:59     ` Christoph Müllner

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.