Skip to contentSkip to conversation

bouncebuf: add feature to support buffer only available in DRAM

PATCH New Kever Yang 5 participants 6 messages May 7, 2019 – May 8, 2019 MMC, SD and SDIO

lore
Share & tools
lore

Kever Yang

author
#0 lore raw

PATCH 1/1 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.

---

 common/bouncebuf.c  | 9 +++++++++
 drivers/mmc/Kconfig | 6 ++++++
 2 files changed, 15 insertions(+)
common/bouncebuf.c +9 -0
index a7098e2caf..7ff2f488a4 100644
@@ -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;
 }
drivers/mmc/Kconfig +6 -0
index c23299ea96..e852ee6175 100644
@@ -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
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 bouncebuf: add feature to support buffer only available in DRAM

Quoted 28 lines · Kever Yang

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.

---

 common/bouncebuf.c  | 9 +++++++++
 drivers/mmc/Kconfig | 6 ++++++
 2 files changed, 15 insertions(+)
common/bouncebuf.c +2 -0
index a7098e2caf..7ff2f488a4 100644
@@ -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;

common/bouncebuf.c static int addr_aligned(struct bounce_buffer *state) · line 31

Quoted 4 lines
common/bouncebuf.c +1 -0
@@ -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

Quoted 33 lines
common/bouncebuf.c +6 -0
+       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;
 }
drivers/mmc/Kconfig +6 -1
index c23299ea96..e852ee6175 100644
@@ -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

#2 lore raw

PATCH 1/1 bouncebuf: add feature to support buffer only available in DRAM

In reply to Kever Yang
Quoted 5 lines · Kever Yang

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

Quoted 53 lines

---

 common/bouncebuf.c  | 9 +++++++++
 drivers/mmc/Kconfig | 6 ++++++
 2 files changed, 15 insertions(+)
common/bouncebuf.c +9 -0
index a7098e2caf..7ff2f488a4 100644
@@ -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;
 }
drivers/mmc/Kconfig +6 -0
index c23299ea96..e852ee6175 100644
@@ -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
#3 lore raw

PATCH 1/1 bouncebuf: add feature to support buffer only available in DRAM

In reply to Kever Yang

Hi Kever,

Quoted 47 lines

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.

---

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

a7098e2caf..7ff2f488a4 100644

common/bouncebuf.c +2 -0
@@ -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)
common/bouncebuf.c +7 -0
 		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;
 }
drivers/mmc/Kconfig index renamed from drivers/mmc/Kconfig +0 -0

c23299ea96..e852ee6175 100644

drivers/mmc/Kconfig config FSL_ESDHC · line 679

Quoted 9 lines
drivers/mmc/Kconfig +6 -0
@@ -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.

Quoted 5 lines
drivers/mmc/Kconfig +0 -1
 endmenu
 
 config SYS_FSL_ERRATUM_ESDHC111
--

2.20.1

#4 lore raw

PATCH 1/1 bouncebuf: add feature to support buffer only available in DRAM

Quoted 52 lines · Peng Fan

Hi Kever,

Quoted 50 lines

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.

---

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

a7098e2caf..7ff2f488a4 100644

common/bouncebuf.c +2 -0
@@ -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)
common/bouncebuf.c +7 -0
 		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;
 }
drivers/mmc/Kconfig index renamed from drivers/mmc/Kconfig +0 -0

c23299ea96..e852ee6175 100644

drivers/mmc/Kconfig +0 -0
@@ -671,6 +671,12 @@ config FSL_ESDHC
 	  This selects support for the eSDHC (enhanced secure digital host
 	  controller) found on numerous Freescale/NXP SoCs.
 
Quoted 10 lines

drivers/mmc/Kconfig config FSL_ESDHC · line 679

Quoted 6 lines
drivers/mmc/Kconfig +6 -0
+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 ?

Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

PATCH 1/1 bouncebuf: add feature to support buffer only available in DRAM

Quoted 64 lines · Marek Vasut
Quoted 52 lines · Peng Fan

Hi Kever,

Quoted 50 lines

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.

---

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

a7098e2caf..7ff2f488a4 100644

common/bouncebuf.c +2 -0
@@ -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)
common/bouncebuf.c +7 -0
 		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;
 }
drivers/mmc/Kconfig index renamed from drivers/mmc/Kconfig +0 -0

c23299ea96..e852ee6175 100644

drivers/mmc/Kconfig +0 -0
@@ -671,6 +671,12 @@ config FSL_ESDHC
 	  This selects support for the eSDHC (enhanced secure digital host
 	  controller) found on numerous Freescale/NXP SoCs.
 
Quoted 10 lines

drivers/mmc/Kconfig config FSL_ESDHC · line 679

Quoted 6 lines
drivers/mmc/Kconfig +6 -0
+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.

Quoted 2 lines

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.