您尚未登录。

楼主 # 2021-07-18 20:51:11

xboot
会员
注册时间: 2019-10-15
已发帖子: 692
积分: 434

给F1C100S编写DMA驱动,并测试NDMA及DDMA的带宽

F1C100S芯片支持4个NDMA以及4个DDMA。

NDMA支持的端口有

#define F1C100S_NDMA_PORT_IR		(0)
#define F1C100S_NDMA_PORT_OWA		(1)
#define F1C100S_NDMA_PORT_SPI0		(4)
#define F1C100S_NDMA_PORT_SPI1		(5)
#define F1C100S_NDMA_PORT_UART0		(8)
#define F1C100S_NDMA_PORT_UART1		(9)
#define F1C100S_NDMA_PORT_UART2		(10)
#define F1C100S_NDMA_PORT_AUDIO		(12)
#define F1C100S_NDMA_PORT_TP		(13)
#define F1C100S_NDMA_PORT_DAUDIO	(14)
#define F1C100S_NDMA_PORT_SRAM		(16)
#define F1C100S_NDMA_PORT_SDRAM		(17)
#define F1C100S_NDMA_PORT_USB		(20)
#define F1C100S_NDMA_PORT_USB_EP1	(21)
#define F1C100S_NDMA_PORT_USB_EP2	(22)
#define F1C100S_NDMA_PORT_USB_EP3	(23)

DDMA支持的端口有

#define F1C100S_DDMA_PORT_SRAM		(0)
#define F1C100S_DDMA_PORT_SDRAM		(1)
#define F1C100S_DDMA_PORT_LCD		(2)
#define F1C100S_DDMA_PORT_USB		(4)
#define F1C100S_DDMA_PORT_AHB		(9)

这个8个通道编码如下:

#define F1C100S_NDMA_CHANNEL0		(0)
#define F1C100S_NDMA_CHANNEL1		(1)
#define F1C100S_NDMA_CHANNEL2		(2)
#define F1C100S_NDMA_CHANNEL3		(3)
#define F1C100S_DDMA_CHANNEL0		(4)
#define F1C100S_DDMA_CHANNEL1		(5)
#define F1C100S_DDMA_CHANNEL2		(6)
#define F1C100S_DDMA_CHANNEL3		(7)

这两种DMA都拥有MEM TO MEM能力,现在直接用白盒测试工具测试下带宽
测试工具默认使用0通道,也就是NDMA的通道,键入命令,wboxtest dma

xboot: /# wboxtest dma      
[dma]-[benchmark]
 Bandwidth: 6.043MB/s
[dma]-[dmacpy-16bit]
 [wboxtest/dma/dmacpy-16bit.c:91] { pdat->complete }                [OKAY]
 [wboxtest/dma/dmacpy-16bit.c:92] { M[pdat->src == pdat->dst] }     [OKAY]
[dma]-[dmacpy-32bit]
 [wboxtest/dma/dmacpy-32bit.c:91] { pdat->complete }                [OKAY]
 [wboxtest/dma/dmacpy-32bit.c:92] { M[pdat->src == pdat->dst] }     [OKAY]
[dma]-[dmacpy-64bit]
 [wboxtest/dma/dmacpy-64bit.c:91] { pdat->complete }                [OKAY]
 [wboxtest/dma/dmacpy-64bit.c:92] { M[pdat->src == pdat->dst] }     [OKAY]
[dma]-[dmacpy-8bit]
 [wboxtest/dma/dmacpy-8bit.c:91] { pdat->complete }                 [OKAY]
 [wboxtest/dma/dmacpy-8bit.c:92] { M[pdat->src == pdat->dst] }      [OKAY]

修改测试工具的DMA通道到4通道,也就是DDMA的0通道,结果如下:

xboot: /# wboxtest dma
[dma]-[benchmark]
 Bandwidth: 6.938MB/s
[dma]-[dmacpy-16bit]
 [wboxtest/dma/dmacpy-16bit.c:91] { pdat->complete }                [OKAY]
 [wboxtest/dma/dmacpy-16bit.c:92] { M[pdat->src == pdat->dst] }     [OKAY]
[dma]-[dmacpy-32bit]
 [wboxtest/dma/dmacpy-32bit.c:91] { pdat->complete }                [OKAY]
 [wboxtest/dma/dmacpy-32bit.c:92] { M[pdat->src == pdat->dst] }     [OKAY]
[dma]-[dmacpy-64bit]
 [wboxtest/dma/dmacpy-64bit.c:91] { pdat->complete }                [OKAY]
 [wboxtest/dma/dmacpy-64bit.c:92] { M[pdat->src == pdat->dst] }     [OKAY]
[dma]-[dmacpy-8bit]
 [wboxtest/dma/dmacpy-8bit.c:91] { pdat->complete }                 [OKAY]
 [wboxtest/dma/dmacpy-8bit.c:92] { M[pdat->src == pdat->dst] }      [OKAY]

DDMA的带宽要比NDMA稍快一些,但差别不是特别大。

DMA驱动程序路径
https://gitee.com/xboot/xboot/blob/master/src/arch/arm32/mach-trimui/driver/dma-f1c200s.c

编写DMA驱动时,发现dma忙等待信号不是特别可靠,会出现dma还没传输完,就认为空闲了,算一个坑把。这里驱动添加额外的限定条件了,判断了中断的状态,只要中断开着,就认为是忙信号。

static int dma_f1c200s_busying(struct dmachip_t * chip, int offset)
{
	struct dma_f1c200s_pdata_t * pdat = (struct dma_f1c200s_pdata_t *)chip->priv;

	if(offset < chip->ndma)
	{
		if(offset < 4)
		{
			if((read32(pdat->virt + NDMA_CH_CFG(offset)) & (0x3 << 30)) || (read32(pdat->virt + DMA_INT_CTL) & (0x3 << (offset << 1))))
				return 1;
		}
		else
		{
			if((read32(pdat->virt + DDMA_CH_CFG(offset)) & (0x3 << 30)) || (read32(pdat->virt + DMA_INT_CTL) & (0x30000 << ((offset - 4) << 1))))
				return 1;
		}
	}
	return 0;
}

离线

楼主 #2 2021-07-19 15:35:40

xboot
会员
注册时间: 2019-10-15
已发帖子: 692
积分: 434

Re: 给F1C100S编写DMA驱动,并测试NDMA及DDMA的带宽

DDMA的通道4就是USB传输

#define F1C100S_DDMA_PORT_USB		(4)

离线

楼主 #4 2021-07-19 16:36:46

xboot
会员
注册时间: 2019-10-15
已发帖子: 692
积分: 434

Re: 给F1C100S编写DMA驱动,并测试NDMA及DDMA的带宽

你这跳转APP是什么意思,引导linux,还是什么其他的二进制程序,注意cache,中断,mmu,定时器的状态吧,如果引导linux,这些都是需要关闭的。有个machine_cleanup接口,这个就是干这种事的

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn