当前位置:网站首页>Detailed explanation of setting HiSilicon MMZ memory and OS memory
Detailed explanation of setting HiSilicon MMZ memory and OS memory
2022-08-03 16:41:00 【snail taking off】
1、前言
(1)本文是基于hi3516dv300芯片的ubootExplain with the kernel;
(2)dv300The chip is actually connected to the board2G内存,dv300The actual maximum chip only supports2G内存;
2、hi3516dv300The memory address range of the chip
(1)By consulting the data sheet《Hi3516DV300 专业型 Smart IP Camera SoC 用户指南》,dv300The memory address range of the chip is0x8000_0000-0xFFFF_FFFF,最大能支持2G内存;
(2)HiSilicon chips divide memory intommz内存和os内存,最终linuxThe memory that the system can manage is less than the actual memory size,Because part of the memory needs to be allocated asmmz;
3、Memory management of HiSilicon chips
(1)in the HiSilicon chip,将内存划分为OS内存和MMZ内存,板子上的2Gpart of memoryOS内存,一部分做MMZ内存;
(2)OS内存:就是分配给linux内核管理的内存,Allocated for use by the kernel and applications;
(3)MMZ(Media Memory Zone,multimedia memory area):Unique to HiSilicon,Because the HiSilicon chip is a chip specially used for audio and video encoding and decoding,requires a lot of memory,In order to the speed of the codec,The bottom layer of the HiSilicon driver will manage a part of the memory,Specially used for audio and video codec;
总结:Divide the actual physical memory into two parts——OS内存和MMZ内存,Two parts of memory management is independent of each other;
4、分配OS内存和MMZprinciples of memory
(1)分配的OS内存和MMZThe total size of the combined memory cannot exceed the size of the actual physical memory;
(2)OS内存和MMZThe memory addresses of the memory cannot overlap with each other,Otherwise there will be a memory stampede;
(3)The total physical memory size remains unchanged,OS内存和MMZAllocation between memory is trade-off,The share allocated between the two needs to be balanced,以达到最优性能;
5、设置MMZ内存
5.1、加载hi_osal.ko驱动
mmz_buf0_start=0xD8000000;
mmz_buf0_size=60M;
mmz_start=0xDBC00000; # mmz start addr
mmz_size=579M; # 579M, mmz size
insmod hi_osal.ko anony=1 mmz_allocator=hisi mmz=anonymous,0,$mmz_start,$mmz_size:buf0,0,$mmz_buf0_start,$mmz_buf0_size || report_error
mmz=anonymous | 第一块MMZThe name of the memory isanonymous |
$mmz_start | 起始地址是0xDBC00000 |
$mmz_size | 内存大小是579M |
buf0 | 第一块MMZThe name of the memory isbuf0 |
$mmz_buf0_start | 起始地址是0xD8000000 |
$mmz_buf0_size | 内存大小是60M |
(1)在海思提供的SDKThere will be a script to load the driver in the package,比如dv300The loading script for the chip isload3516dv300,The above is the loading of the excerpthi_osal.ko的脚本;
(2)加载hi_osal.ko时传入MMZThe start address and size of memory,The driver supports incoming multiple blocksMMZ内存地址;
5.2、查看MMZ内存:/proc/media-mem
~ # cat /proc/media-mem
+---ZONE: PHYS(0xD8000000, 0xDBBFFFFF), GFP=0, nBYTES=61440KB, NAME="buf0"
+---ZONE: PHYS(0xDBC00000, 0xFFEFFFFF), GFP=0, nBYTES=592896KB, NAME="anonymous"
|-MMB: phys(0xDBC00000, 0xDBC07FFF), kvirt=0xF0DE8000, flags=0x00000001, length=32KB, name="sys_scale_coef"
|-MMB: phys(0xDBC08000, 0xDBC27FFF), kvirt=0x00000000, flags=0x00000000, length=128KB, name="TDE_MEMPOOL_MMB"
|-MMB: phys(0xDBC28000, 0xDBC43FFF), kvirt=0xF0FE0000, flags=0x00000001, length=112KB, name="gdc_node_buf"
|-MMB: phys(0xDBC44000, 0xDBC44FFF), kvirt=0xF0C95000, flags=0x00000001, length=4KB, name="GDC int_pole_co"
|-MMB: phys(0xDBC45000, 0xDBCBFFFF), kvirt=0xF1100000, flags=0x00000001, length=492KB, name="VGS_NodeBuf"
|-MMB: phys(0xDBCC0000, 0xDBCC0FFF), kvirt=0xF0CD9000, flags=0x00000001, length=4KB, name="dis_node_buf"
|-MMB: phys(0xDBCC1000, 0xDC0C0FFF), kvirt=0x00000000, flags=0x00000000, length=4096KB, name="hifb_layer0"
|-MMB: phys(0xDC0C1000, 0xDC0D0FFF), kvirt=0xF14D0000, flags=0x00000001, length=64KB, name="HIFB COEF"
|-MMB: phys(0xDC0D1000, 0xDC105FFF), kvirt=0xF1C80000, flags=0x00000001, length=212KB, name="IVE_QUEUE"
|-MMB: phys(0xDC106000, 0xDC106FFF), kvirt=0xF0EDD000, flags=0x00000003, length=4KB, name="IVE_TEMP_NODE"
|-MMB: phys(0xDC107000, 0xDC116FFF), kvirt=0xF1CE0000, flags=0x00000001, length=64KB, name="SVP_NNIE_QUEUE"
|-MMB: phys(0xDC117000, 0xDC11AFFF), kvirt=0xF12F8000, flags=0x00000003, length=16KB, name="SVP_NNIE_MODLE_"
---MMZ_USE_INFO:
total size=654336KB(639MB),used=5228KB(5MB + 108KB),remain=649108KB(633MB + 916KB),zone_number=2,block_number=12
(1)从上面可知,MMZThere are two pieces of memory:名字是buf0,大小是61440KB;名字是anonymous,大小是592896KB;
(2)Just loading with ushi_osal.ko时指定的MMZMemory parameters match;
6、设置OS内存
6.1、设置bootargs
~ # cat /proc/cmdline
mem=1408M console=ttyS0,115200 root=/dev/mmcblk0p7 rootfstype=squashfs rootwait
(1)从bootargs中可以得知,OS内存分配了1408M,The starting address is not specified here,Analysis of the kernel source code,The memory start address is0x80000000;
(2)具体bootargsHow the memory specified in takes effect,参考博客:《linux内存管理——内存大小、Analysis and modification of the starting address》;
6.2、查看OS内存:free
~ # free
total used free shared buffers
Mem: 1419980 132636 1287344 448 23808
-/+ buffers: 108828 1311152
Swap: 0 0 0
7、Memory management figure
-----|----------------| 0x80000000 # Memory managed by OS.
1408M| |
| OS |
-----|----------------| 0xD8000000 #Memory managed by MMZ block buf0.
60M | |
| MMZ:buf0 |
-----|----------------| 0xDBC00000 # Memory managed by MMZ block anonymous.
579M | MMZ:anonymous |
| |
-----|----------------| 0xFFF00000 # End of memory managed by MMZ.
边栏推荐
猜你喜欢
随机推荐
Kubernetes 笔记 / 入门 / 生产环境 / 容器运行时
TypeScript文件的编译执行
【带你了解SDN和网络虚拟化】
leetcode SVM
蒋松廷 荣获第六季完美童模全球总决赛 全球总冠军
leetcode-268.丢失的数字
C专家编程 第3章 分析C语言的声明 3.8 理解所有分析过程的代码段
CPU个数_核心数_线程数之间的关系
数据中台“集存通用治”功能场景说明
如何选择合适的导电滑环型号
罗克韦尔AB PLC RSLogix5000中创建新项目、任务、程序和例程的具体方法和步骤
[Unity Getting Started Plan] Basic Concepts (6) - Sprite Renderer Sprite Renderer
高薪程序员&面试题精讲系列132之微服务之间如何进行通信?服务熔断是怎么回事?你熟悉Hystrix吗?
[Deep Learning] Today's bug (August 2)
MATLAB | 一种简易的随机曼陀罗图形生成函数
[Unity Getting Started Plan] Basic Concepts (8) - Tile Map TileMap 01
Windows 事件转发到 SQL 数据库
leetcode:187. 重复的DNA序列
元宇宙系列--Value creation in the metaverse
《社会企业开展应聘文职人员培训规范》团体标准在新华书店上架