This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

am5726,dsp运行空间cma地址重新配置,有些地址可以,有些地址会导致系统崩溃的问题。

Other Parts Discussed in Thread: AM5728

最近在linux侧,通过修改设备树的方式,对dsp运行空间cma地址进行了重新配置,在dsp侧的资源映射头文件中也进行了相应的修改。在有些重分配的空间代码可以正常运行和重新加载;但是有些重分配的空间,系统启动后,第一次加载两个dsp核,代码完全可以运行。但是重新使用load-firmware.sh加载dsp代码内核会有崩溃现象。

以下是设备树配置:

/ {
compatible = "ti,am572x-beagle-x15", "ti,am5728", "ti,dra742", "ti,dra74", "ti,dra7";

aliases {
rtc0 = &mcp_rtc;
rtc1 = &tps659038_rtc;
rtc2 = &rtc;
display0 = &hdmi0;

sound0 = &hdmi;
sound1 = &sound0;
};

chosen {
stdout-path = &uart3;
};

memory@0 {
device_type = "memory";
reg = <0x0 0x80000000 0x0 0x80000000>;
};

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

ipu2_cma_pool: ipu2_cma@b8000000 {
compatible = "shared-dma-pool";
reg = <0x0 0xb8000000 0x0 0x2000000>;
reusable;
status = "okay";
};

dsp1_cma_pool: dsp1_cma@b0000000 {
compatible = "shared-dma-pool";
reg = <0x0 0xb0000000 0x0 0x4000000>;
reusable;
status = "okay";
};

ipu1_cma_pool: ipu1_cma@ba000000 {
compatible = "shared-dma-pool";
reg = <0x0 0xba000000 0x0 0x2000000>;
reusable;
status = "okay";
};

dsp2_cma_pool: dsp2_cma@b4000000 {
compatible = "shared-dma-pool";
reg = <0x0 0xb4000000 0x0 0x4000000>;
reusable;
status = "okay";
};

dsp2dsp_shm: dsp2dsp_shm@bf000000 {
reg = <0x0 0xbf000000 0x0 0x1000000>;
no-map;
status = "okay";
};
};

以下是dsp资源映射文件的配置:

#define CMA_DSP_PHYS_ADDR 0xb0000000
#define CMA_DSP_SIZE (SZ_1M * 56)
#define SR0_PHYS_ADDR 0xbf000000
#define SR0_SIZE (SZ_1M)
#define CMEM_PHYS_ADDR 0xbc000000
#define CMEM_SIZE (SZ_1M * 10)

//dsp cmd
#define DSP_MEM_TEXT 0xa0000000
#define DSP_MEM_DATA 0xa0200000
#define DSP_MEM_HEAP 0xa0400000
#define DSP_MEM_IPC_DATA 0xa0f00000
#define DSP_MEM_TEXT_SIZE (SZ_1M * 2)
#define DSP_MEM_DATA_SIZE (SZ_1M * 2)
#define DSP_MEM_HEAP_SIZE (SZ_1M * 3)
#define DSP_MEM_IPC_DATA_SIZE SZ_1M

//cmem
#define PHYS_MEM_IOBUFS CMEM_PHYS_ADDR
#define DSP_MEM_IOBUFS 0x80000000
#define DSP_MEM_IOBUFS_SIZE CMEM_SIZE

//SR0
#define PHYS_SR0 SR0_PHYS_ADDR
#define DSP_SR0 SR0_PHYS_ADDR
#define DSP_SR0_SIZE SR0_SIZE

/*
* Assign fixed RAM addresses to facilitate a fixed MMU table.
*/
/* Once you’ve created your custom resource table,
* you must update the address of PHYS_MEM_IPC_VRING
* to be the same base address as your corresponding CMA. */
#define PHYS_MEM_IPC_VRING CMA_DSP_PHYS_ADDR

#define DSP_MEM_IPC_VRING 0xc0000000
#define DSP_MEM_RPMSG_VRING0 0xc0000000
#define DSP_MEM_RPMSG_VRING1 0xc0004000
#define DSP_MEM_VRING_BUFS0 0xc0040000
#define DSP_MEM_VRING_BUFS1 0xc0080000

#define DSP_MEM_IPC_VRING_SIZE SZ_1M

/*
* Sizes of the virtqueues (expressed in number of buffers supported,
* and must be power of 2)
*/
#define DSP_RPMSG_VQ0_SIZE 256
#define DSP_RPMSG_VQ1_SIZE 256

/* flip up bits whose indices represent features we support */
#define RPMSG_DSP_C0_FEATURES 1

这里DSP的cma地址为:

DSP1:0xb0000000~0xb3ffffff

DSP2:0xb4000000~0xb7ffffff

此时重新加载dsp代码,在执行echo 40800000.dsp > /sys/bus/platform/drivers/omap-rproc/unbind时系统崩溃,以下是崩溃日志的开头。

[ 457.348466] Unable to handle kernel paging request at virtual address f226608c
[ 457.355723] pgd = cf8d7b80
[ 457.358442] [f226608c] *pgd=80000080007003, *pmd=ac1f7003, *pte=00000000
[ 457.365200] Internal error: Oops: a07 [#1] PREEMPT SMP ARM
[ 457.365206] Modules linked in: cmemk(O)
[ 457.365213] CPU: 0 PID: 249 Comm: load-firmware.s Tainted: G O 4.9.65-rt23 #3

但是我修改DSP的cma地址为:

DSP1:0xa0000000~0xa3ffffff

DSP2:0xa4000000~0xa7ffffff

代码可以正常运行和重新加载。系统不会崩溃

我想问,在linux的设备树配置dsp的运行cma地址时,是有地址上的限制吗?我在wiki里没有找到相应的说明,谢谢。