[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.
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(-)

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.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- drivers/mmc/sdhci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 01fa5a9d4d..93c9049c5d 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -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); } }

If Host controller doesn't support SDMA, it doesn't need to return error. Because it can be worked with PIO mode.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- drivers/mmc/sdhci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 93c9049c5d..bd8157d053 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -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)) {

Enable SDHCI_SDMA configuration.
Signed-off-by: Jaehoon Chung jh80.chung@samsung.com --- configs/rpi_4_32b_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig index 00f80f71ad..8fbadc0bc8 100644 --- a/configs/rpi_4_32b_defconfig +++ b/configs/rpi_4_32b_defconfig @@ -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

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.
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,
Reviewed-by: Peng Fan peng.fan@nxp.com
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

On 1/27/20 9:53 PM, Peng Fan wrote:
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.
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,
Well, i know what you want. but when use printf, it will be displayed ugly log relevant to mmcnr@73e0000. mmcnr@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@7e340000: 0, mmcnr@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
Reviewed-by: Peng Fan peng.fan@nxp.com
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

On 23/01/2020 00:15, Jaehoon Chung wrote:
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: diff --git a/configs/rpi_4_defconfig b/configs/rpi_4_defconfig index 17ecad3aa5..6f5a2dd6e8 100644 --- a/configs/rpi_4_defconfig +++ b/configs/rpi_4_defconfig @@ -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@7e340000: 0, mmcnr@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
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(-)

On 30/01/2020 12:24, Matthias Brugger wrote:
On 23/01/2020 00:15, Jaehoon Chung wrote:
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: diff --git a/configs/rpi_4_defconfig b/configs/rpi_4_defconfig index 17ecad3aa5..6f5a2dd6e8 100644 --- a/configs/rpi_4_defconfig +++ b/configs/rpi_4_defconfig @@ -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@7e340000: 0, mmcnr@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
Regards, Matthias
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(-)

On 1/30/20 8:27 PM, Matthias Brugger wrote:
On 30/01/2020 12:24, Matthias Brugger wrote:
On 23/01/2020 00:15, Jaehoon Chung wrote:
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: diff --git a/configs/rpi_4_defconfig b/configs/rpi_4_defconfig index 17ecad3aa5..6f5a2dd6e8 100644 --- a/configs/rpi_4_defconfig +++ b/configs/rpi_4_defconfig @@ -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@7e340000: 0, mmcnr@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!
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@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
Regards, Matthias
Regards, Matthias
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(-)

On 30/01/2020 23:14, Jaehoon Chung wrote:
On 1/30/20 8:27 PM, Matthias Brugger wrote:
On 30/01/2020 12:24, Matthias Brugger wrote:
On 23/01/2020 00:15, Jaehoon Chung wrote:
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: diff --git a/configs/rpi_4_defconfig b/configs/rpi_4_defconfig index 17ecad3aa5..6f5a2dd6e8 100644 --- a/configs/rpi_4_defconfig +++ b/configs/rpi_4_defconfig @@ -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@7e340000: 0, mmcnr@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!
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
Instead, i will also send patch about displaying host controller information. like the below..(I'm making patches.)
U-Boot> mmcinfo Device: emmc2@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
Regards, Matthias
Regards, Matthias
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(-)
participants (4)
-
Jaehoon Chung
-
Matthias Brugger
-
Matthias Brugger
-
Peng Fan