免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4654 | 回复: 11
打印 上一主题 下一主题

自己编写的驱动出现这种情况???? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-09-30 14:31 |只看该作者 |倒序浏览
加载驱动时,可以加载成功!但是一触发中断之后超级终端打印:

scheduling while atomic: swapper/0x00000100/0
bad: scheduling from the idle thread!
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 17 [#1]
Modules linked in: stk_gpio stk_rtc8025 nfs lockd sunrpc mmc_block himci mmc_core sd_mmc_sdio hi3511_usb_1_1 nls_iso8859_1 nls_cp437 hifb fb hi3511_jpege hi3511_h264d hi3511_h264e hi3511_chnl hi3511_ao hi3511_ai hi3511_sio hi3511_md hi3511_vdec hi3511_group hi3511_venc hi3511_vpp hi3511_dsu hi3511_vou hi3511_viu hi3511_sys hi3511_base tde stkwm8510 stkmediactl stksaa7113 stkflashenv hidmac gpioi2c hiether mmz
CPU: 0
PC is at dequeue_task+0xc/0x78
LR is at deactivate_task+0x24/0x30
pc : [<c003346c>]    lr : [<c00337b8>]    Tainted: P     
sp : c02a9dc8  ip : c02a9de0  fp : c02a9ddc
r10: c02fb8d8  r9 : c02a8000  r8 : c02aac40
r7 : c02abe88  r6 : c02aad6c  r5 : 00000000  r4 : c02aac40
r3 : ffffffff  r2 : 40000093  r1 : 00000000  r0 : c02aac40
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  Segment kernel
Control: 5317F  Table: E1B78000  DAC: 00000017
Process swapper (pid: 0, stack limit = 0xc02a8194)
Stack: (0xc02a9dc8 to 0xc02aa000)
9dc0:                   c02aac40 00000000 c02a9df0 c02a9de0 c00337b8 c0033470
9de0: 00000000 c02a9e38 c02a9df4 c0260978 c00337a4 c02aac74 0a0bcb26 00754540
9e00: 0098965c c02aad68 c0037cc8 c02a9e38 ffffc3af 00000015 c02a9e3c c02abe88
9e20: c02a9eac c02abe88 c02fb8d8 c02a9e74 c02a9e3c c0261594 c0260550 c02fbe58
9e40: c02fbe58 ffffc3af 4b87ad6e c00411b4 c02aac40 c02fb8d8 00000002 bf1d8350
9e60: c02a8000 00000000 c02a9e84 c02a9e78 c0261634 c0261530 c02a9e94 c02a9e88
9e80: c00411f8 c0261620 c02a9ea8 c02a9e98 bf1d8444 c00411d8 00000100 c02a9ee0
9ea0: c02a9eac c0040958 bf1d8360 c02a9eac c02a9eac 00000000 00000001 c02fb670
9ec0: 00000001 c02fd124 0000000a c02a8000 c02fb640 c02a9f0c c02a9ee4 c003c858
9ee0: c0040864 c02a8000 fe140000 00000010 c02abc1c c02a9f50 41069265 c02f56e4
9f00: c02a9f1c c02a9f10 c003ca08 c003c7f8 c02a9f4c c02a9f20 c0021e10 c003c9d4
9f20: c0037cc8 00000a00 ffffffff fe140000 00000010 c031453c e001d114 e001d0e4
9f40: c02a9fa4 c02a9f50 c00209c4 c0021cf4 00000000 0005317f 0005217f 60000013
9f60: c0022640 c02a8000 c02f5d6c c031453c e001d114 41069265 e001d0e4 c02a9fa4
9f80: c02a9f98 c02a9f98 c002bab0 c002269c 60000013 ffffffff c02a9fc0 c02a9fa8
9fa0: c00226e8 c0022650 00053175 c02f529c c02fde54 c02a9fd0 c02a9fc4 c0020024
9fc0: c00226b4 c02a9ff4 c02a9fd4 c00087e4 c0020010 c00082e4 c02f5e48 00053175
9fe0: c02f5ddc c02abbb8 00000000 c02a9ff8 e0008094 c0008698 00000000 00000000
Backtrace:
[<c0033460>] (dequeue_task+0x0/0x7 from [<c00337b8>] (deactivate_task+0x24/0x30)
r5 = 00000000  r4 = C02AAC40
[<c0033794>] (deactivate_task+0x0/0x30) from [<c0260978>] (schedule+0x438/0x61
r4 = 00000000
[<c0260540>] (schedule+0x0/0x61 from [<c0261594>] (schedule_timeout+0x74/0xc
[<c0261520>] (schedule_timeout+0x0/0xc from [<c0261634>] (schedule_timeout_uninterruptible+0x24/0x2
r7 = 00000000  r6 = C02A8000  r5 = BF1D8350  r4 = 00000002
[<c0261610>] (schedule_timeout_uninterruptible+0x0/0x2 from [<c00411f8>] (msleep+0x30/0x40)
[<c00411c8>] (msleep+0x0/0x40) from [<bf1d8444>] (send_signal_handle+0xf4/0x14c [stk_gpio])
[<bf1d8350>] (send_signal_handle+0x0/0x14c [stk_gpio]) from [<c0040958>] (run_timer_softirq+0x104/0x1f4)
r4 = 00000100
[<c0040854>] (run_timer_softirq+0x0/0x1f4) from [<c003c858>] (__do_softirq+0x70/0xf0)
[<c003c7e8>] (__do_softirq+0x0/0xf0) from [<c003ca08>] (irq_exit+0x44/0x4c)
[<c003c9c4>] (irq_exit+0x0/0x4c) from [<c0021e10>] (asm_do_IRQ+0x12c/0x140)
[<c0021ce4>] (asm_do_IRQ+0x0/0x140) from [<c00209c4>] (__irq_svc+0x24/0x80)
[<c0022640>] (default_idle+0x0/0x64) from [<c00226e8>] (cpu_idle+0x44/0x60)
[<c00226a4>] (cpu_idle+0x0/0x60) from [<c0020024>] (__init_end+0x24/0x2c)
r6 = C02FDE54  r5 = C02F529C  r4 = 00053175
[<c0020000>] (__init_end+0x0/0x2c) from [<c00087e4>] (start_kernel+0x15c/0x1c4)
[<c0008688>] (start_kernel+0x0/0x1c4) from [<e0008094>] (0xe0008094)
Code: e89da800 e1a0c00d e92dd830 e24cb004 (e5913000)
<0>Kernel panic - not syncing: Aiee, killing interrupt handler!

论坛徽章:
0
2 [报告]
发表于 2010-09-30 14:35 |只看该作者
附上主要源代码:
---------------------------------------------------------------------------------------------------------------------
  1. static struct miscdevice stk_gpio_dev =
  2. {
  3.         MISC_DYNAMIC_MINOR,
  4.         "stk_gpio",
  5.         &stk_gpio_fops,
  6. };

  7. //-----------------------Zhuqing added it here.......-------------------------//

  8. void send_signal_handle(void)
  9. {
  10.         int flag_judge;
  11.        
  12.         flag_judge = flag & (0x0f);
  13.         switch (flag_judge)
  14.         {
  15.                 case 0x01:
  16.                 {
  17.                         flag &= (0xfe);
  18.                         printk("--- lock on\n");
  19.                         gpio_write_bit(GPIO_5_PORT,IPC3_ALARMEN_BIT,1);
  20.                         gpio_write_bit(GPIO_7_PORT,IPC3_WALARMOUT_2_BIT,1);
  21.                         msleep(200);
  22.                         gpio_write_bit(GPIO_7_PORT,IPC3_WALARMOUT_2_BIT,0);
  23.                         printk("--- clear alarm on\n");
  24.                         break;
  25.                        
  26.                 }

  27.                 case 0x02:
  28.                 {
  29.                         flag &= (0xfd);
  30.                         printk("--- lock off \n");
  31.                         gpio_write_bit(GPIO_5_PORT,IPC3_ALARMEN_BIT,1);
  32.                         gpio_write_bit(GPIO_7_PORT,IPC3_WALARMOUT_1_BIT,1);
  33.                         msleep(200);
  34.                         gpio_write_bit(GPIO_7_PORT,IPC3_WALARMOUT_1_BIT,0);
  35.                         printk("--- clear alarm on\n");
  36.                         break;
  37.                 }

  38.                 case 0x04:
  39.                 {
  40.                         flag &= (0xfc);
  41.                         printk("--- SOS on \n");
  42.                         gpio_write_bit(GPIO_7_PORT,IPC3_WALARMOUT_0_BIT,1);
  43.                         msleep(200);
  44.                         gpio_write_bit(GPIO_7_PORT,IPC3_WALARMOUT_0_BIT,0);
  45.                         printk("--- clear alarm on\n");
  46.                         break;
  47.                 }

  48.                 default:break;
  49.         }

  50.         mod_timer(&stk_gpio_timer, jiffies + HZ/10);
  51. }
  52. static irqreturn_t interrupt_handle(int irq, char *dev_id)
  53. {
  54.        
  55.         //Disable the interrupt, because these interrupt can not be interruptted again before them being handled//
  56.         //gpio_IE_set_bit(GPIO_5_PORT,IPC3_WALARMIN_0_BIT,INTERRUPT_DISABLE);
  57.         //gpio_IE_set_bit(GPIO_5_PORT,IPC3_WALARMIN_1_BIT,INTERRUPT_DISABLE);
  58.         //gpio_IE_set_bit(GPIO_5_PORT,IPC3_WALARMIN_2_BIT,INTERRUPT_DISABLE);
  59.         //gpio_IE_set_bit(GPIO_5_PORT,IPC3_WALARMIN_3_BIT,INTERRUPT_DISABLE);
  60.         //----------------------------The End----------------------------//
  61.        
  62.         //gpio_write_bit(GPIO_7_PORT,IPC3_WALARMOUT_2_BIT,1);
  63.         wa0 = gpio_read_bit(GPIO_5_PORT ,IPC3_WALARMIN_0_BIT);
  64.           wa2 = gpio_read_bit(GPIO_5_PORT ,IPC3_WALARMIN_2_BIT);
  65.           wa1 = gpio_read_bit(GPIO_5_PORT ,IPC3_WALARMIN_1_BIT);
  66.         wa3 = gpio_read_bit(GPIO_5_PORT ,IPC3_WALARMIN_3_BIT);
  67.         temp = (wa3 << 3) |(wa2 << 2) | (wa1 << 1) |(wa0 << 0);
  68.        
  69.        
  70.         switch (temp)
  71.         {
  72.                 case IPC3_LOCKON_STATUS:
  73.                 {
  74.                         flag |= (0x01);
  75.                         break;
  76.                        
  77.                 }

  78.                 case IPC3_LOCKOFF_STATUS:
  79.                 {
  80.                         flag |= (0x02);
  81.                         break;
  82.                 }

  83.                 case IPC3_SOS_STATUS:
  84.                 {
  85.                         flag |= (0x04);
  86.                         break;
  87.                 }

  88.                 default:break;
  89.         }
  90.         //clear the interrupt
  91.         writel(0xff, (HI_SYS_GPIO+(GPIO_5_PORT) * GPIO_SPACE_SIZE + GPIO_IC));
  92.         //Open the interrupt again
  93.         //gpio_IE_set_bit(GPIO_5_PORT,IPC3_WALARMIN_0_BIT,INTERRUPT_ENABLE);
  94.         //gpio_IE_set_bit(GPIO_5_PORT,IPC3_WALARMIN_1_BIT,INTERRUPT_ENABLE);
  95.         //gpio_IE_set_bit(GPIO_5_PORT,IPC3_WALARMIN_2_BIT,INTERRUPT_ENABLE);
  96.         //gpio_IE_set_bit(GPIO_5_PORT,IPC3_WALARMIN_3_BIT,INTERRUPT_ENABLE);
  97.         //----------------------------The End----------------------------//
  98.         return IRQ_RETVAL(1);
  99. }
复制代码
  1. static int gpio_interrupt_init(void)
  2. {
  3.        
  4.         gpio_interrupt_reg_init();
  5.         int err = 0;
  6.         err = request_irq(GPIO_IRQ, &interrupt_handle, SA_SHIRQ, "stk_gpio", &stk_gpio_dev);
  7.         printk("the request_irq return numble is %d\n",err);
  8.         if (err != 0)
  9.         {
  10.                 printk("gpio_interrupt_init() fail!\n");
  11.                 goto gpio_interrupt_init_fail;
  12.         }
  13.        
  14.         return 0;
  15.         gpio_interrupt_init_fail:        misc_deregister(&stk_gpio_dev);
  16.                                 free_irq(GPIO_IRQ, &stk_gpio_dev);
  17.                                                                 return 0;
  18.                
  19. }

  20. //----------------------------------The End--------------------------------//
  21. static int __init  stk_gpio_init(void)
  22. {
  23.             int ret;
  24.             unsigned int tmp;
  25.             ret = misc_register(&stk_gpio_dev);
  26.             if (ret)
  27.             {
  28.                 printk(GPIO_DEVICE_NAME " can't register major number\n");
  29.                 return ret;
  30.             }   

  31.     //        gpio_remap();
  32.             gpio_init();

  33.                 stk_gpio_timer_init();
  34.                 add_timer(&stk_gpio_timer);

  35.                 gpio_interrupt_init();//Zhuqing added it here.......

  36.                 printk("stk gpio control Driver v1.0\n");
  37.             return 0;
  38. }


  39. static void __exit stk_gpio_exit(void)
  40. {
  41.        
  42.         //del_timer_sync(&stk_gpio_timer);
  43.         misc_deregister(&stk_gpio_dev);
  44.     //gpio_unmap();
  45.    
  46.    
  47.         //disable_irq(GPIO_IRQ); //Zhuqing added it here......
  48.         free_irq(GPIO_IRQ, &stk_gpio_dev);//Zhuqing added it here......
  49.    
  50. }
复制代码
谢谢了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

论坛徽章:
0
3 [报告]
发表于 2010-09-30 20:41 |只看该作者
还好,自己搞定了!!!!!!!!!!!!!!!!
{:3_186:}

论坛徽章:
1
射手座
日期:2013-11-07 09:19:48
4 [报告]
发表于 2010-10-12 15:06 |只看该作者
回复 3# zhuqing_739
LZ可否告知是如何解决的,我现在用mini2440,自己写了一个按键驱动,但是只要触发中断也会出现你所描述的问题。
请教LZ是如何解决的?

论坛徽章:
0
5 [报告]
发表于 2010-10-13 17:44 |只看该作者
中断里面 schedule 了当然会出现问题,去掉 msleep就可以了

论坛徽章:
0
6 [报告]
发表于 2010-10-17 14:11 |只看该作者
哈哈,在中断中sleep了,肯定会出问题的

论坛徽章:
0
7 [报告]
发表于 2010-10-18 21:27 |只看该作者
用了NULL指针

论坛徽章:
0
8 [报告]
发表于 2010-10-19 22:03 |只看该作者
回复 6# ashengsheng


    我没有在中断服务子程序中使用sleep啊????????

论坛徽章:
0
9 [报告]
发表于 2010-10-19 22:04 |只看该作者
回复 5# star316


    我没有在中断服务子程序中使用sleep啊????????我没有在中断服务子程序中使用sleep啊????????

论坛徽章:
0
10 [报告]
发表于 2010-10-20 09:12 |只看该作者
scheduling while atomic: swapper/0x00000100/0
bad: scheduling from the idle thread!


这句话非常的明显
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP