Chinaunix首页 | 论坛 | 博客
  • 博客访问: 325013
  • 博文数量: 78
  • 博客积分: 1322
  • 博客等级: 中尉
  • 技术积分: 680
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-14 13:24
文章分类
文章存档

2012年(20)

2011年(55)

2010年(3)

分类: LINUX

2011-09-27 22:59:24

我在内核为2.6.18中使用pci_alloc_consistent()申请内存时,发现竟然不能多次申请,会出错,而代码在内核为2.4.13中又是OK的,搞得我都糊涂了,你们帮看看代码那里有问题????????

#define MAX_BUFFER_COUNT   16

static int __devinit drv_dm642_probe(struct pci_dev *pcidev,
                        const struct pci_device_id *devid)
{
  static u32 *cpu_zeroes[MAX_BUFFER_COUNT];
    static dma_addr_t zeroes[MAX_BUFFER_COUNT];    
    .....   //略
  ulLen = 20+(128+128*1024);

    printk("drv_dm642_probe() module enable irq ok\n");
    for(i = 0; i < MAX_BUFFER_COUNT; ++i)
    {
      printk("::::::::::::::::::::::pci_alloc_consistent :: start \n");  
      cpu_zeroes = pci_alloc_consistent(pcidev, ulLen, &(zeroes));
      printk("::::::::::::::::::::::::::::::::pci_alloc_consistent :: end \n");    
      if(NULL == cpu_zeroes )
      {
    printk("11::s->video_buf_info_addr[%d] pci_alloc_consistent error\n",i);
    goto fail3;
      }
      printk("i[%d] :: cpu_zeroes[0x%8x], zeroes[0x%8x]\n",
              i, (unsigned int) cpu_zeroes, (unsigned int) zeroes);
      memset(cpu_zeroes, 0, ulLen);
    }
  fail3:
    .......   //略
}

打印信息如下:

drv_dm642_probe() module enable irq ok
::::::::::::::::::::::pci_alloc_consistent :: start
::::::::::::::::::::::::::::::::pci_alloc_consistent :: end
i[0] :: cpu_zeroes[0xff103000], zeroes[0x ee00000]
::::::::::::::::::::::pci_alloc_consistent :: start
::::::::::::::::::::::::::::::::pci_alloc_consistent :: end
i[1] :: cpu_zeroes[0xff124000], zeroes[0x e100000]
::::::::::::::::::::::pci_alloc_consistent :: start
::::::::::::::::::::::::::::::::pci_alloc_consistent :: end
i[2] :: cpu_zeroes[0xff145000], zeroes[0x 540000]
::::::::::::::::::::::pci_alloc_consistent :: start
::::::::::::::::::::::::::::::::pci_alloc_consistent :: end
i[3] :: cpu_zeroes[0xff166000], zeroes[0x e140000]
::::::::::::::::::::::pci_alloc_consistent :: start
::::::::::::::::::::::::::::::::pci_alloc_consistent :: end
i[4] :: cpu_zeroes[0xff187000], zeroes[0x e680000]
::::::::::::::::::::::pci_alloc_consistent :: start
::::::::::::::::::::::::::::::::pci_alloc_consistent :: end
i[5] :: cpu_zeroes[0xff1a8000], zeroes[0x e6c0000]
::::::::::::::::::::::pci_alloc_consistent :: start
::::::::::::::::::::::::::::::::pci_alloc_consistent :: end
i[6] :: cpu_zeroes[0xff1c9000], zeroes[0x ea00000]
::::::::::::::::::::::pci_alloc_consistent :: start
kernel BUG in __dma_alloc_coherent at arch/ppc/kernel/dma-mapping.c:233!
Oops: Exception in kernel mode, sig: 5 [#1]
NIP: C0004D3C LR: C0004D08 CTR: 00000000
REGS: cea8fc70 TRAP: 0700   Not tainted (2.6.18-rc2)
MSR: 00029000 CR: 84084084 XER: 00000000
TASK = cfe67090[53] 'insmod' THREAD: cea8e000
GPR00: 00000001 CEA8FD20 CFE67090 C04CD100 0000003F 0000001F CEA60FFC 00029000
GPR08: 00000000 00000000 CFF13020 00000400 24084028 1008C868 00000000 00000000
GPR16: 00000000 00000000 00000124 00000000 D5099BDE C02D0000 C0260000 00000006
GPR24: CEE99E80 C025E40C FF2DF000 D1067750 C04CD100 CFF2E000 C04CCBC0 0000B000
NIP [C0004D3C] __dma_alloc_coherent+0x220/0x2ec
LR [C0004D08] __dma_alloc_coherent+0x1ec/0x2ec
Call Trace:
[CEA8FD20] [C0004C60] __dma_alloc_coherent+0x144/0x2ec (unreliable)
[CEA8FD60] [D10691D4] drv_dm642_probe+0xac/0x660 [dm642drv]
[CEA8FD90] [C011B3A0] pci_device_probe+0x80/0xa0
[CEA8FDB0] [C0133670] driver_probe_device+0x60/0x118
[CEA8FDD0] [C01338A8] __driver_attach+0xcc/0xf8
[CEA8FDF0] [C0132AFC] bus_for_each_dev+0x54/0x90
[CEA8FE20] [C01334D8] driver_attach+0x24/0x34
[CEA8FE30] [C0132F3C] bus_add_driver+0x84/0x144
[CEA8FE50] [C0133D90] driver_register+0x70/0xb8
[CEA8FE60] [C011B030] __pci_register_driver+0x44/0x54
[CEA8FE70] [D1069030] drv_dm642_init+0x30/0x128 [dm642drv]
[CEA8FE90] [C00345F8] sys_init_module+0xe8/0x157c
[CEA8FF40] [C0001C88] ret_from_syscall+0x0/0x3c
Instruction dump:
3d20c02d 8169c0dc 7c00f050 54003826 7c005a14 901b0000 815d0004 39200000
7d205379 38000000 41820008 38000001 <0f000000> 38000400 7d60f028 7d6b0378
Trace/breakpoint trap
阅读(7508) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

wmiss4142011-09-27 23:05:51

MAX_ORDER defaults to 11 so you even do alloc_page (which
is the underlying allocator of pci_alloc_consistent) upto 2^11 page that
is 8MB.  Downside - memory allocation is making such large allocations
unreliable; the more unreliable the larger the allocation.