[RFC 1/4] mmc: bcm2835_sdhci: use phys2bus macro when dma address is accessed

Marek Szyprowski m.szyprowski at samsung.com
Mon Jan 20 11:37:44 CET 2020


Hi Jaehoon,

On 20.01.2020 11:20, Jaehoon Chung wrote:
> Use phys2bus macro when dma address is accessed.
> After applied it, SDMA mode can be used.
>
> When thor download is used,
> - Before : 1.8MB/s
> - After : 7.23MB/s
>
> Signed-off-by: Jaehoon Chung <jh80.chung at samsung.com>
> ---
>   drivers/mmc/bcm2835_sdhci.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c
> index 39c93db275..222ba22d66 100644
> --- a/drivers/mmc/bcm2835_sdhci.c
> +++ b/drivers/mmc/bcm2835_sdhci.c
> @@ -46,6 +46,7 @@
>   #include <asm/arch/mbox.h>
>   #include <mach/sdhci.h>
>   #include <mach/timer.h>
> +#include <phys2bus.h>
>   
>   /* 400KHz is max freq for card ID etc. Use that as min */
>   #define MIN_FREQ 400000
> @@ -86,7 +87,11 @@ static inline void bcm2835_sdhci_raw_writel(struct sdhci_host *host, u32 val,
>   			;
>   	}
>   
> -	writel(val, host->ioaddr + reg);
> +	if (reg == SDHCI_DMA_ADDRESS)
> +		writel(phys_to_bus((unsigned long)val), host->ioaddr + reg);
> +	else
> +		writel(val, host->ioaddr + reg);
> +
>   	bcm_host->last_write = timer_get_us();
>   }

It would be better to fix this directly in the place where writel with 
SDHCI_DMA_ADDRESS is called:

simply change sdhci_writel(host, host->start_addr, SDHCI_DMA_ADDRESS) to 
sdhci_writel(host, phys_to_bus(host->start_addr), SDHCI_DMA_ADDRESS);

In such case no if statement is the needed and phys_to_bus() is safe for 
non-rpi users (it is identity in such case).

# git grep SDHCI_DMA_ADDRESS

shows 2 places where writel to SDHCI_DMA_ADDRESS is being done.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland



More information about the U-Boot mailing list