Skip to contentSkip to conversation

Support SDMA mode on RPI4 target - 32bit

PATCH New Jaehoon Chung 4 participants 10 messages Jan 22, 2020 – Feb 1, 2020 1 message not in the archive MMC, SD and SDIO

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20200122231514epcas1p2bcfc0cf1370b66b25418983d62fb66fe@epcas1p2.samsung.com

#1 lore raw

cover Support SDMA mode on RPI4 target - 32bit

RPI4's SDHCI controller is supported SDMA mode. (Checked on kernel side) But It doesn't use on u-boot side. Then it's too slow about read/write performance. This patchset is supported SDMA mode on RPI4 target(32bit).
- I didn't test on RPI4 64bit.

Read/write time about 8MB file
Before
- Read : 1.472 seconds
- Write : 4.690 seconds
After
- Read : 0.359 seconds
- Write : 0.574 seconds

This patch is based on my RFC's patches.

Jaehoon Chung (3):
mmc: sdhci: use phys2bus macro when dma address is accessed
mmc: sdhci: not return error when SDMA is not supported
configs: rpi_4_32b_defconfig: enable SDHCI_SDMA config

 configs/rpi_4_32b_defconfig |  1 +
 drivers/mmc/sdhci.c         | 16 +++++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)
Signature · 1 line
2.25.0
#2 lore raw

PATCH 1/3 mmc: sdhci: use phys2bus macro when dma address is accessed

Use phys2bus macro when dma address is accessed. Some targets need to use pyhs2bus macro. (e.g, RPI4) After applied it, SDMA mode can be used.

---
 drivers/mmc/sdhci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/sdhci.c +4 -2
index 01fa5a9d4d..93c9049c5d 100644
@@ -15,6 +15,7 @@
 #include <mmc.h>
 #include <sdhci.h>
 #include <dm.h>
+#include <phys2bus.h>
 
 #if defined(CONFIG_FIXED_SDHCI_ALIGNED_BUFFER)
 void *aligned_buffer = (void *)CONFIG_FIXED_SDHCI_ALIGNED_BUFFER;
@@ -164,7 +165,8 @@ static void sdhci_prepare_dma(struct sdhci_host *host, struct mmc_data *data,
 		if (data->flags != MMC_DATA_READ)
 			memcpy(aligned_buffer, data->src, trans_bytes);
 #endif
-		sdhci_writel(host, host->start_addr, SDHCI_DMA_ADDRESS);
+		sdhci_writel(host, phys_to_bus((ulong)host->start_addr),
+				SDHCI_DMA_ADDRESS);
 
 	} else if (host->flags & (USE_ADMA | USE_ADMA64)) {
 		sdhci_prepare_adma_table(host, data);
@@ -220,7 +222,7 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data)
 				start_addr &=
 				~(SDHCI_DEFAULT_BOUNDARY_SIZE - 1);
 				start_addr += SDHCI_DEFAULT_BOUNDARY_SIZE;
-				sdhci_writel(host, start_addr,
+				sdhci_writel(host, phys_to_bus((ulong)start_addr),
 					     SDHCI_DMA_ADDRESS);
 			}
 		}
Signature · 1 line
2.25.0
#3 lore raw

PATCH 2/3 mmc: sdhci: not return error when SDMA is not supported

In reply to Jaehoon Chung

If Host controller doesn't support SDMA, it doesn't need to return error. Because it can be worked with PIO mode.

---
 drivers/mmc/sdhci.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mmc/sdhci.c +5 -5
index 93c9049c5d..bd8157d053 100644
@@ -729,13 +729,13 @@ int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host,
 	debug("%s, caps: 0x%x\n", __func__, caps);
 
 #ifdef CONFIG_MMC_SDHCI_SDMA
-	if (!(caps & SDHCI_CAN_DO_SDMA)) {
-		printf("%s: Your controller doesn't support SDMA!!\n",
+	if ((caps & SDHCI_CAN_DO_SDMA)) {
+		host->flags |= USE_SDMA;
+	} else {
+		caps &= ~SDHCI_CAN_DO_SDMA;
+		debug("%s: Your controller doesn't support SDMA!!\n",
 		       __func__);
-		return -EINVAL;
 	}
-
-	host->flags |= USE_SDMA;
 #endif
 #if CONFIG_IS_ENABLED(MMC_SDHCI_ADMA)
 	if (!(caps & SDHCI_CAN_DO_ADMA2)) {
Signature · 1 line
2.25.0
#4 lore raw

PATCH 3/3 configs: rpi_4_32b_defconfig: enable SDHCI_SDMA config

In reply to Jaehoon Chung

Enable SDHCI_SDMA configuration.

---
 configs/rpi_4_32b_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/rpi_4_32b_defconfig +1 -0
index 00f80f71ad..8fbadc0bc8 100644
@@ -23,6 +23,7 @@ CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_DM_KEYBOARD=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_BCM2835=y
 CONFIG_PINCTRL=y
 # CONFIG_PINCTRL_GENERIC is not set
Signature · 1 line
2.25.0
#5 lore raw

cover Support SDMA mode on RPI4 target - 32bit

In reply to Jaehoon Chung
Quoted 8 lines

Subject: [PATCH 0/3] Support SDMA mode on RPI4 target - 32bit

RPI4's SDHCI controller is supported SDMA mode. (Checked on kernel side) But It doesn't use on u-boot side. Then it's too slow about read/write performance.
This patchset is supported SDMA mode on RPI4 target(32bit).
- I didn't test on RPI4 64bit.

Quoted 7 lines

Read/write time about 8MB file
Before
- Read : 1.472 seconds
- Write : 4.690 seconds
After
- Read : 0.359 seconds
- Write : 0.574 seconds

For patch 2/3, I prefer to use printf, not debug. Other than that, For the whole patchset,

Quoted 14 lines

This patch is based on my RFC's patches.

Jaehoon Chung (3):
mmc: sdhci: use phys2bus macro when dma address is accessed
mmc: sdhci: not return error when SDMA is not supported
configs: rpi_4_32b_defconfig: enable SDHCI_SDMA config

 configs/rpi_4_32b_defconfig |  1 +
 drivers/mmc/sdhci.c         | 16 +++++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

--
2.25.0

#6 lore raw

cover Support SDMA mode on RPI4 target - 32bit

Quoted 16 lines · Peng Fan
Quoted 8 lines

Subject: [PATCH 0/3] Support SDMA mode on RPI4 target - 32bit

RPI4's SDHCI controller is supported SDMA mode. (Checked on kernel side) But It doesn't use on u-boot side. Then it's too slow about read/write performance.
This patchset is supported SDMA mode on RPI4 target(32bit).
- I didn't test on RPI4 64bit.

Quoted 7 lines

Read/write time about 8MB file
Before
- Read : 1.472 seconds
- Write : 4.690 seconds
After
- Read : 0.359 seconds
- Write : 0.574 seconds

Quoted 2 lines

For patch 2/3, I prefer to use printf, not debug. Other than that, For the whole patchset,

Well, i know what you want. but when use printf, it will be displayed ugly log relevant to mmcnr at 73e0000. mmcnr at 73e0000 is used for WiFi on RPI4 target. So i changed from printf to debug.
- Because RPI4 is using dt that passed by firmware.

U-Boot 2019.10-00002-g4746c115cc-dirty (Jan 28 2020 - 13:57:03 +0900)

DRAM: 3.9 GiB
RPI 4 Model B (0xc03111)
MMC: sdhci_setup_cfg: Your controller doesn't support SDMA!!
emmc2 at 7e340000: 0, mmcnr at 7e300000: 1

But if you're ok about above, i will resend the patches with your reviewed-tag.

And I will send patch about Host controller information.
mmcinfo is displayed many informations. but it doesn't know which mode is using. e.g) SDMA, ADMA, PIO, DMA mode, etc.
Those have dependent with Host controller.
If it's showed with any command, it's helpful to use. how about?

Best Regards,
Jaehoon Chung

Quoted 18 lines
Quoted 14 lines

This patch is based on my RFC's patches.

Jaehoon Chung (3):
mmc: sdhci: use phys2bus macro when dma address is accessed
mmc: sdhci: not return error when SDMA is not supported
configs: rpi_4_32b_defconfig: enable SDHCI_SDMA config

 configs/rpi_4_32b_defconfig |  1 +
 drivers/mmc/sdhci.c         | 16 +++++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

--
2.25.0

#7 lore raw

cover Support SDMA mode on RPI4 target - 32bit

In reply to Jaehoon Chung
Quoted 4 lines · Jaehoon Chung

RPI4's SDHCI controller is supported SDMA mode. (Checked on kernel side) But It doesn't use on u-boot side. Then it's too slow about read/write performance. This patchset is supported SDMA mode on RPI4 target(32bit).
- I didn't test on RPI4 64bit.

I tested it on RPi4 64bit:

configs/rpi_4_defconfig +1 -0
index 17ecad3aa5..6f5a2dd6e8 100644
@@ -26,6 +26,7 @@ CONFIG_DFU_MMC=y
 CONFIG_DM_KEYBOARD=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_BCM2835=y
 CONFIG_DM_ETH=y
 CONFIG_BCMGENET=y

Changed the debug to a printf and gave it a try:
U-Boot 2020.04-rc1-00010-ga963cbc9e0-dirty (Jan 30 2020 - 12:18:02 +0100)

DRAM: 1.9 GiB
RPI 4 Model B (0xb03111)
MMC: sdhci_setup_cfg: Your controller doesn't support SDMA!!
emmc2 at 7e340000: 0, mmcnr at 7e300000: 1

That's at least surprising. Any idea why it should be supported on 32 bit but not on 64 bit?
Or did you add DTS properties to enable SDMA?

Regards,
Matthias

Quoted 20 lines

Read/write time about 8MB file
Before
- Read : 1.472 seconds
- Write : 4.690 seconds
After
- Read : 0.359 seconds
- Write : 0.574 seconds

This patch is based on my RFC's patches.

Jaehoon Chung (3):
mmc: sdhci: use phys2bus macro when dma address is accessed
mmc: sdhci: not return error when SDMA is not supported
configs: rpi_4_32b_defconfig: enable SDHCI_SDMA config

 configs/rpi_4_32b_defconfig |  1 +
 drivers/mmc/sdhci.c         | 16 +++++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)
#8 lore raw

cover Support SDMA mode on RPI4 target - 32bit

Quoted 25 lines · Matthias Brugger
Quoted 4 lines · Jaehoon Chung

RPI4's SDHCI controller is supported SDMA mode. (Checked on kernel side) But It doesn't use on u-boot side. Then it's too slow about read/write performance. This patchset is supported SDMA mode on RPI4 target(32bit).
- I didn't test on RPI4 64bit.

I tested it on RPi4 64bit:

configs/rpi_4_defconfig +1 -0
index 17ecad3aa5..6f5a2dd6e8 100644
@@ -26,6 +26,7 @@ CONFIG_DFU_MMC=y
 CONFIG_DM_KEYBOARD=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_BCM2835=y
 CONFIG_DM_ETH=y
 CONFIG_BCMGENET=y

Changed the debug to a printf and gave it a try:
U-Boot 2020.04-rc1-00010-ga963cbc9e0-dirty (Jan 30 2020 - 12:18:02 +0100)

Quoted 8 lines

DRAM: 1.9 GiB
RPI 4 Model B (0xb03111)
MMC: sdhci_setup_cfg: Your controller doesn't support SDMA!!
emmc2 at 7e340000: 0, mmcnr at 7e300000: 1

That's at least surprising. Any idea why it should be supported on 32 bit but not on 64 bit?
Or did you add DTS properties to enable SDMA?

Ok, never mind. I realized that this is the other controller used for Wifi, sorry for the noise!

Regards,
Matthias

Quoted 24 lines

Regards,
Matthias

Quoted 20 lines

Read/write time about 8MB file
Before
- Read : 1.472 seconds
- Write : 4.690 seconds
After
- Read : 0.359 seconds
- Write : 0.574 seconds

This patch is based on my RFC's patches.

Jaehoon Chung (3):
mmc: sdhci: use phys2bus macro when dma address is accessed
mmc: sdhci: not return error when SDMA is not supported
configs: rpi_4_32b_defconfig: enable SDHCI_SDMA config

 configs/rpi_4_32b_defconfig |  1 +
 drivers/mmc/sdhci.c         | 16 +++++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)
#9 lore raw

cover Support SDMA mode on RPI4 target - 32bit

Quoted 33 lines · Matthias Brugger
Quoted 30 lines · Matthias Brugger
Quoted 4 lines · Jaehoon Chung

RPI4's SDHCI controller is supported SDMA mode. (Checked on kernel side) But It doesn't use on u-boot side. Then it's too slow about read/write performance. This patchset is supported SDMA mode on RPI4 target(32bit).
- I didn't test on RPI4 64bit.

I tested it on RPi4 64bit:

configs/rpi_4_defconfig +1 -0
index 17ecad3aa5..6f5a2dd6e8 100644
@@ -26,6 +26,7 @@ CONFIG_DFU_MMC=y
 CONFIG_DM_KEYBOARD=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_BCM2835=y
 CONFIG_DM_ETH=y
 CONFIG_BCMGENET=y

Changed the debug to a printf and gave it a try:
U-Boot 2020.04-rc1-00010-ga963cbc9e0-dirty (Jan 30 2020 - 12:18:02 +0100)

DRAM: 1.9 GiB
RPI 4 Model B (0xb03111)
MMC: sdhci_setup_cfg: Your controller doesn't support SDMA!!
emmc2 at 7e340000: 0, mmcnr at 7e300000: 1

Quoted 6 lines
Quoted 3 lines

That's at least surprising. Any idea why it should be supported on 32 bit but not on 64 bit?
Or did you add DTS properties to enable SDMA?

Ok, never mind. I realized that this is the other controller used for Wifi, sorry for the noise!

Yes, It's used for WiFi. So it's displayed unnecessary log.
It's possible to confuse whether SDMA is not supported or not.
So i changed from printf to debug.
Instead, i will also send patch about displaying host controller information. like the below..(I'm making patches.)

U-Boot> mmcinfo
Device: emmc2 at 7e340000
Manufacturer ID: 3
OEM: 5344
Name: SC16G
Bus Speed: 50000000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
**Host Controller Information**
Host Controller: SDHCI
Mode : PIO
SDHCI version : 2
Host max clock : 100000000

Then it doesn't need to display "sdhci_setup_cfg: Your controller doesn't support SDMA!!". How about?

And my next step is the enabling UHS speed mode.(if it's possible.) But i don't have enough RPI4 information.
- SD card's vmmc regulator information, etc...

Anyway, Peng and you want to keep "printf" instead of "debug". I will resend patch.

Best Regards,
Jaehoon Chung

Quoted 30 lines

Regards,
Matthias

Quoted 24 lines

Regards,
Matthias

Quoted 20 lines

Read/write time about 8MB file
Before
- Read : 1.472 seconds
- Write : 4.690 seconds
After
- Read : 0.359 seconds
- Write : 0.574 seconds

This patch is based on my RFC's patches.

Jaehoon Chung (3):
mmc: sdhci: use phys2bus macro when dma address is accessed
mmc: sdhci: not return error when SDMA is not supported
configs: rpi_4_32b_defconfig: enable SDHCI_SDMA config

 configs/rpi_4_32b_defconfig |  1 +
 drivers/mmc/sdhci.c         | 16 +++++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)
#10 lore raw

cover Support SDMA mode on RPI4 target - 32bit

Quoted 41 lines · Jaehoon Chung
Quoted 33 lines · Matthias Brugger
Quoted 30 lines · Matthias Brugger
Quoted 4 lines · Jaehoon Chung

RPI4's SDHCI controller is supported SDMA mode. (Checked on kernel side) But It doesn't use on u-boot side. Then it's too slow about read/write performance. This patchset is supported SDMA mode on RPI4 target(32bit).
- I didn't test on RPI4 64bit.

I tested it on RPi4 64bit:

configs/rpi_4_defconfig +1 -0
index 17ecad3aa5..6f5a2dd6e8 100644
@@ -26,6 +26,7 @@ CONFIG_DFU_MMC=y
 CONFIG_DM_KEYBOARD=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_BCM2835=y
 CONFIG_DM_ETH=y
 CONFIG_BCMGENET=y

Changed the debug to a printf and gave it a try:
U-Boot 2020.04-rc1-00010-ga963cbc9e0-dirty (Jan 30 2020 - 12:18:02 +0100)

DRAM: 1.9 GiB
RPI 4 Model B (0xb03111)
MMC: sdhci_setup_cfg: Your controller doesn't support SDMA!!
emmc2 at 7e340000: 0, mmcnr at 7e300000: 1

Quoted 6 lines
Quoted 3 lines

That's at least surprising. Any idea why it should be supported on 32 bit but not on 64 bit?
Or did you add DTS properties to enable SDMA?

Ok, never mind. I realized that this is the other controller used for Wifi, sorry for the noise!

Quoted 3 lines

Yes, It's used for WiFi. So it's displayed unnecessary log. It's possible to confuse whether SDMA is not supported or not. So i changed from printf to debug.

Hm I'm not sure which is the best way to go.
Actually in the RPi4 we have two sdhci controllers with two different compatibles. So one support SDMA (brcm,bcm2711-emmc2) while the other (brcm,bcm2815-sdhci) does not. So I see two possible ways to fix this.

First, add a sdhci-caps-mask to the bcm2835-sdhci device tree node to disable the SDMA flag.

A second posibility would be to add a flag to disable (S)DMA caps in sdhci_setup_cfg().

On the other hand the kernel only prints in the debug mode that the SDMA controller is not present. Peng what's the background that you want to keep it a printf?

Regards,
Matthias

Quoted 65 lines

Instead, i will also send patch about displaying host controller information. like the below..(I'm making patches.)

U-Boot> mmcinfo
Device: emmc2 at 7e340000
Manufacturer ID: 3
OEM: 5344
Name: SC16G
Bus Speed: 50000000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
**Host Controller Information**
Host Controller: SDHCI
Mode : PIO
SDHCI version : 2
Host max clock : 100000000

Then it doesn't need to display "sdhci_setup_cfg: Your controller doesn't support SDMA!!". How about?

And my next step is the enabling UHS speed mode.(if it's possible.) But i don't have enough RPI4 information.
- SD card's vmmc regulator information, etc...

Anyway, Peng and you want to keep "printf" instead of "debug". I will resend patch.

Best Regards,
Jaehoon Chung

Quoted 30 lines

Regards,
Matthias

Quoted 24 lines

Regards,
Matthias

Quoted 20 lines

Read/write time about 8MB file
Before
- Read : 1.472 seconds
- Write : 4.690 seconds
After
- Read : 0.359 seconds
- Write : 0.574 seconds

This patch is based on my RFC's patches.

Jaehoon Chung (3):
mmc: sdhci: use phys2bus macro when dma address is accessed
mmc: sdhci: not return error when SDMA is not supported
configs: rpi_4_32b_defconfig: enable SDHCI_SDMA config

 configs/rpi_4_32b_defconfig |  1 +
 drivers/mmc/sdhci.c         | 16 +++++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)