最近在做edma,其中edma配置如下:
ret = edma_alloc_channel (EDMA_CHANNEL_ANY, callback1, NULL, 0);
gDmaCh = ret;
printk("nedma_alloc_channel sucsess,gDmaCh=%d\n",gDmaCh);
if (gDmaCh < 0) {
printk("edma_alloc_channel failed for dma_ch, error:%d\n", gDmaCh);
return gDmaCh;
}
printk("nedma_alloc_channel sucsess,gDmaCh=%d\n",gDmaCh);
/***********************EDMA Config*******************************/
edma_set_src (gDmaCh, (unsigned long)(fpga_phy_base), INCR, W16BIT);
printk("edma_set_src sucsess!\n");
edma_set_dest (gDmaCh, (unsigned long)(dmaphysdest), INCR, W16BIT);
printk("edma_set_dest sucsess!\n");
edma_set_src_index (gDmaCh, 0, 0);
printk("edma_set_src_index sucsess!\n");
edma_set_dest_index (gDmaCh, 0, 0);
printk("edma_set_dest_index sucsess!\n");
edma_set_transfer_params (gDmaCh, 8192, 1, 1, 1, ASYNC);
printk("edma_set_transfer_params sucsess!\n");
edma_read_slot (gDmaCh, ¶m_set);
printk("edma_read_slot sucsess!\n");
param_set.opt |= (1 << ITCINTEN_SHIFT);
printk("opt=%d\n",param_set.opt);
param_set.opt |= (1 << TCINTEN_SHIFT);
printk("opt=%d\n",param_set.opt);
param_set.opt |= EDMA_TCC(EDMA_CHAN_SLOT(gDmaCh));
printk("opt=%d\n",param_set.opt);
edma_write_slot (gDmaCh, ¶m_set);
printk("edma_write_slot sucsess!\n");
现在的情况是 打印的gDmaCh的值是一个负值 运行完之后如下图
[ 490.108757] nedma_alloc_channel sucsess,gDmaCh=-12
[ 490.113800] nedma_alloc_channel sucsess,gDmaCh=-12
[ 490.119183] Unable to handle kernel NULL pointer dereference at virtual address 00000008
[ 490.127671] pgd = ddc7c000
[ 490.130763] [00000008] *pgd=9c905831, *pte=00000000, *ppte=00000000
[ 490.137332] Internal error: Oops: 17 [#1] PREEMPT ARM
[ 490.142604] Modules linked in: fpgadev(O+) ipv6 evdev joydev ti_am335x_adc kfifo_buf industrialio musb_dsps musb_hdrc udc_core usbcore pm33xx gpio_keys snd_soc_evm omap_sham omap_aes_driver omap_rng ti_am335x_tsc rng_core c_can_platform c_can can_dev snd_soc_sgtl5000 ti_am335x_tscadc musb_am335x rtc_omap omap_wdt leds_gpio
[ 490.172579] CPU: 0 PID: 168 Comm: insmod Tainted: G O 4.1.18 #2
[ 490.179932] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 490.186290] task: ddf52d00 ti: dc860000 task.ti: dc860000
[ 490.191948] PC is at fpgadev_init+0x548/0x84c [fpgadev]
[ 490.197416] LR is at __schedule+0x1c4/0x4c0
[ 490.201779] pc : [<bf1cfc30>] lr : [<c063b6a0>] psr: 400e0013
[ 490.201779] sp : dc861db0 ip : dc861c98 fp : dc861de4
[ 490.213755] r10: 00000000 r9 : bf1d0a38 r8 : bf1d0a38
[ 490.219204] r7 : bf1d08f8 r6 : de800000 r5 : 00000000 r4 : bf1d0a38
[ 490.226013] r3 : 00000000 r2 : 0000fff4 r1 : 00000000 r0 : 00000026
[ 490.232825] Flags: nZcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 490.240267] Control: 10c5387d Table: 9dc7c019 DAC: 00000015
[ 490.246259] Process insmod (pid: 168, stack limit = 0xdc860210)
[ 490.252434] Stack: (0xdc861db0 to 0xdc862000)
这种问题该从何解决.望指点迷津.谢谢
Shine:
试试edma_alloc_channel 申请时指定个通道号.
user4822185:
回复 Shine:
这是我的edma_config 配置函数
static int edma_config(void)
{int ret;mmapbuf = (unsigned short *)kmalloc(SZ_4M, GFP_KERNEL);if(!mmapbuf ){printk("kmalloc mmapbuf fail\n");//goto init_fail_2;return -ENOMEM;}SetPageReserved(virt_to_page(mmapbuf));memset(mmapbuf , 0, SZ_4M);
fpga_buf = dma_alloc_coherent(NULL,MAX_DMA_TRANSFER_IN_BYTES,&dmaphysdest,0);printk("DST1:0x%x\n", dmaphysdest);//dmaphysdest 物理内存起始地址printk("fpga_buf:%p\n",fpga_buf);//fpga_buf虚拟内存起始地址if (!fpga_buf){printk(KERN_INFO "dma_alloc_coherent failed for dmaphysdest\n");return -ENOMEM;}edma_free_channel(EDMA_CHANNEL_ANY); ret = edma_alloc_channel (EDMA_CHANNEL_ANY, callback1, NULL, 0);gDmaCh = ret;printk("nedma_alloc_channel sucsess,gDmaCh=%d\n",gDmaCh);if (gDmaCh < 0) {printk("edma_alloc_channel failed for dma_ch, error:%d\n", gDmaCh);return gDmaCh;}printk("nedma_alloc_channel sucsess,gDmaCh=%d\n",gDmaCh);/***********************EDMA Config*******************************/edma_set_src (gDmaCh, (unsigned long)(fpga_phy_base), INCR, W16BIT);printk("edma_set_src sucsess!\n");edma_set_dest (gDmaCh, (unsigned long)(dmaphysdest), INCR, W16BIT);printk("edma_set_dest sucsess!\n");edma_set_src_index (gDmaCh, 0, 0);printk("edma_set_src_index sucsess!\n");edma_set_dest_index (gDmaCh, 0, 0);printk("edma_set_dest_index sucsess!\n");edma_set_transfer_params (gDmaCh, 8192, 1, 1, 1, ASYNC);printk("edma_set_transfer_params sucsess!\n");edma_read_slot (gDmaCh, ¶m_set);printk("edma_read_slot sucsess!\n");param_set.opt |= (1 << ITCINTEN_SHIFT);printk("opt=%d\n",param_set.opt);param_set.opt |= (1 << TCINTEN_SHIFT);printk("opt=%d\n",param_set.opt);param_set.opt |= EDMA_TCC(EDMA_CHAN_SLOT(gDmaCh));printk("opt=%d\n",param_set.opt);edma_write_slot (gDmaCh, ¶m_set);printk("edma_write_slot sucsess!\n");return 0;
}还是不行gDmaCh 值还没打印就 oops了fpga_buf:de800000
[299.697463] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[299.706338] pgd = ddd2c000
[299.709201] [00000000] *pgd=9dcf8831, *pte=00000000, *ppte=00000000
[299.715762] Internal error: Oops: 17 [#1] PREEMPT ARM
[299.721030] Modules linked in: fpgadev(O+) ipv6 evdev joydev ti_am335x_adc kfifo_buf industrialio musb_dsps musb_hdrc udc_core usbcore pm33xx gpio_keys snd_soc_evm omap_aes_driver omap_sham ti_am335x_tsc omap_rng rng_core c_can_platform c_can can_dev snd_soc_sgtl5000 rtc_omap ti_am335x_tscadc musb_am335x omap_wdt leds_gpio
[299.750995] CPU: 0 PID: 168 Comm: insmod Tainted: GO4.1.18 #2
[299.758346] Hardware name: Generic AM33XX (Flattened Device Tree)
[299.764699] task: ddf96d00 ti: ddf14000 task.ti: ddf14000
[299.770351] PC is at edma_free_channel+0x14/0x54 [fpgadev]
[299.776077] LR is at fpgadev_init+0x518/0x854 [fpgadev]
[299.781526] pc : [<bf1cf0b8>]lr : [<bf1cfc54>]psr: a0070013
[299.781526] sp : ddf15d98ip : ddf15db0fp : ddf15dac
[299.793498] r10: 00000000r9 : bf1d0a5cr8 : bf1d0a5c
[299.798945] r7 : bf1d091cr6 : de800000r5 : 00000000r4 : 0000ffff
[299.805750] r3 : 00000000r2 : 00000000r1 : 00000000r0 : ffffffff
[299.812559] Flags: NzCvIRQs onFIQs onMode SVC_32ISA ARMSegment user
[299.819999] Control: 10c5387dTable: 9dd2c019DAC: 00000015
[299.825989] Process insmod (pid: 168, stack limit = 0xddf14210)
[299.832160] Stack: (0xddf15d98 to 0xddf16000)
[299.836702] 5d80:00000000 bf1d0a5c
[299.845233] 5da0: ddf15de4 ddf15db0 bf1cfc54 bf1cf0b0 00000000 00000000 c02e1e3c 0f600000
[299.853766] 5dc0: c08da6a8 bf1cf73c c08da6a8 ddcfa3c0 bf1d0968 00000001 ddf15e64 ddf15de8
[299.862298] 5de0: c0009718 bf1cf748 00000001 00000000 0040003f 00080000 00000000 de36d000
[299.870831] 5e00: 00000001 bf1d0920 ddf15e44 ddf14000 de7a383c ddf57b80 c00ed758 dd801e40
[299.879363] 5e20: 00006cc1 bf1d0920 ddf15e5c ddf15e38 c00f8690 c00f77c8 00000026 bf1d0920
[299.887896] 5e40: 00000001 ddcfa300 ddcfa1c0 bf1d0968 00000001 bf1d0920 ddf15e8c ddf15e68
[299.896427] 5e60: c0637da0 c000969c ddcfa1c8 ddcfa1c0 ddf15e8c ddf15f40 00000001 ddcfa1c8
[299.904960] 5e80: ddf15f3c ddf15e90 c008f73c c0637d4c bf1d092c 00007fff c008c640 ddc00d80
[299.913492] 5ea0: c0646cac 00000000 bf1d092c bf1d0a4c e0ccb968 bf1d0ab0 00000000 ddf15f40
[299.922025] 5ec0: c00edaec c00ed404 ff000000 ffffffff 000002d2 00000000 00000000 00000000
[299.930557] 5ee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[299.939091] 5f00: 00000000 00000000 00000000 00000000 000002d2 000059fe 00000000 b6e33a06
[299.947623] 5f20: ddf14000 000c2008 e0cd49fe 00000000 ddf15fa4 ddf15f40 c008fadc c008db84
[299.956156] 5f40: e0caf000 000259fe e0ccb440 e0ccb2f7 e0cd4330 00001ab0 00001f40 00000000
[299.964688] 5f60: 00000000 00000000 00000021 00000022 0000000d 0000000b 00000007 00000000
[299.973221] 5f80: 000259fe be850f2b 00000002 00000080 c000fa84 ddf14000 00000000 ddf15fa8
[299.981753] 5fa0: c000f8e0 c008f9b0 000259fe be850f2b b6e0e008 000259fe 000c2008 be850f2b
[299.990286] 5fc0: 000259fe be850f2b 00000002 00000080 00000000 00000000 b6f9e000 00000000
[299.998820] 5fe0: be850c80 be850c70 00027c08 b6efe830 60070010 b6e0e008 e89da800 000c0300
[300.007347] Backtrace:
[300.009916] [<bf1cf0a4>] (edma_free_channel [fpgadev]) from [<bf1cfc54>] (fpgadev_init+0x518/0x854 [fpgadev])
[300.020256]r4:bf1d0a5c r3:00000000
[300.024010] [<bf1cf73c>] (fpgadev_init [fpgadev]) from [<c0009718>] (do_one_initcall+0x88/0x1e0)
user4822185:
回复 user4822185:
我先释放edma_free_channel(30) 然后再edma_alloc_channel(30)还是不行 在它这儿就oops了
还有这种oops 该怎么处理 , 望解惑 谢谢
根据 printk 情况程序 在edma_set_src 时 就oops了 但是我在查看edma_set_src函数时 没有null pointer