dannylsl 发表于 2011-8-7 16:13:45

OK6410 想释放GPIO-KEYS 占有的中断号

Linux 2.6.36.2
Ubuntu 10.04
我想编写GPIO-KEYS的中断驱动程序,由于板子上的系统已经使用了相关中断号
所以只有释放周才能使用
使用 free_irq(IRQ_EINT(0),NULL) 来释放中断
但是cat /proc/kmsg 有如下提示<4>------------[ cut here ]------------
<4>WARNING: at kernel/irq/manage.c:899 __free_irq+0x9c/0x1ac()
<4>Trying to free already-free IRQ 101
<4>Modules linked in: button2(+)
<4>[<c0037a8c>] (unwind_backtrace+0x0/0xfc) from [<c04ac5f8>] (dump_stack+0x18/0x1c)
<4>[<c04ac5f8>] (dump_stack+0x18/0x1c) from [<c004c54c>] (warn_slowpath_common+0x54/0x6c)
<4>[<c004c54c>] (warn_slowpath_common+0x54/0x6c) from [<c004c608>] (warn_slowpath_fmt+0x38/0x40)
<4>[<c004c608>] (warn_slowpath_fmt+0x38/0x40) from [<c0082dbc>] (__free_irq+0x9c/0x1ac)
<4>[<c0082dbc>] (__free_irq+0x9c/0x1ac) from [<c0082f10>] (free_irq+0x44/0x64)
<4>[<c0082f10>] (free_irq+0x44/0x64) from [<bf006054>] (button2_init+0x34/0x58 )
<4>[<bf006054>] (button2_init+0x34/0x58 ) from [<c0031378>] (do_one_initcall+0x38/0x1ac)
<4>[<c0031378>] (do_one_initcall+0x38/0x1ac) from [<c007e894>] (sys_init_module+0xb8/0x1cc)
<4>[<c007e894>] (sys_init_module+0xb8/0x1cc) from [<c0031a20>] (ret_fast_syscall+0x0/0x30)
<4>---[ end trace 69130b5f71451ee3 ]---
<4>------------[ cut here ]------------
<4>WARNING: at kernel/irq/manage.c:899 __free_irq+0x9c/0x1ac()
<4>Trying to free already-free IRQ 102
<4>Modules linked in: button2(+)
<4>[<c0037a8c>] (unwind_backtrace+0x0/0xfc) from [<c04ac5f8>] (dump_stack+0x18/0x1c)
<4>[<c04ac5f8>] (dump_stack+0x18/0x1c) from [<c004c54c>] (warn_slowpath_common+0x54/0x6c)
<4>[<c004c54c>] (warn_slowpath_common+0x54/0x6c) from [<c004c608>] (warn_slowpath_fmt+0x38/0x40)
<4>[<c004c608>] (warn_slowpath_fmt+0x38/0x40) from [<c0082dbc>] (__free_irq+0x9c/0x1ac)
<4>[<c0082dbc>] (__free_irq+0x9c/0x1ac) from [<c0082f10>] (free_irq+0x44/0x64)
<4>[<c0082f10>] (free_irq+0x44/0x64) from [<bf006054>] (button2_init+0x34/0x58 )
<4>[<bf006054>] (button2_init+0x34/0x58 ) from [<c0031378>] (do_one_initcall+0x38/0x1ac)
<4>[<c0031378>] (do_one_initcall+0x38/0x1ac) from [<c007e894>] (sys_init_module+0xb8/0x1cc)
<4>[<c007e894>] (sys_init_module+0xb8/0x1cc) from [<c0031a20>] (ret_fast_syscall+0x0/0x30)
<4>---[ end trace 69130b5f71451ee4 ]---
<4>------------[ cut here ]------------
<4>WARNING: at kernel/irq/manage.c:899 __free_irq+0x9c/0x1ac()
<4>Trying to free already-free IRQ 103
<4>Modules linked in: button2(+)
<4>[<c0037a8c>] (unwind_backtrace+0x0/0xfc) from [<c04ac5f8>] (dump_stack+0x18/0x1c)
<4>[<c04ac5f8>] (dump_stack+0x18/0x1c) from [<c004c54c>] (warn_slowpath_common+0x54/0x6c)
<4>[<c004c54c>] (warn_slowpath_common+0x54/0x6c) from [<c004c608>] (warn_slowpath_fmt+0x38/0x40)
<4>[<c004c608>] (warn_slowpath_fmt+0x38/0x40) from [<c0082dbc>] (__free_irq+0x9c/0x1ac)
<4>[<c0082dbc>] (__free_irq+0x9c/0x1ac) from [<c0082f10>] (free_irq+0x44/0x64)
<4>[<c0082f10>] (free_irq+0x44/0x64) from [<bf006054>] (button2_init+0x34/0x58 )
<4>[<bf006054>] (button2_init+0x34/0x58 ) from [<c0031378>] (do_one_initcall+0x38/0x1ac)
<4>[<c0031378>] (do_one_initcall+0x38/0x1ac) from [<c007e894>] (sys_init_module+0xb8/0x1cc)
<4>[<c007e894>] (sys_init_module+0xb8/0x1cc) from [<c0031a20>] (ret_fast_syscall+0x0/0x30)
<4>---[ end trace 69130b5f71451ee5 ]---
<4>------------[ cut here ]------------
<4>WARNING: at kernel/irq/manage.c:899 __free_irq+0x9c/0x1ac()
<4>Trying to free already-free IRQ 104
<4>Modules linked in: button2(+)
<4>[<c0037a8c>] (unwind_backtrace+0x0/0xfc) from [<c04ac5f8>] (dump_stack+0x18/0x1c)
<4>[<c04ac5f8>] (dump_stack+0x18/0x1c) from [<c004c54c>] (warn_slowpath_common+0x54/0x6c)
<4>[<c004c54c>] (warn_slowpath_common+0x54/0x6c) from [<c004c608>] (warn_slowpath_fmt+0x38/0x40)
<4>[<c004c608>] (warn_slowpath_fmt+0x38/0x40) from [<c0082dbc>] (__free_irq+0x9c/0x1ac)
<4>[<c0082dbc>] (__free_irq+0x9c/0x1ac) from [<c0082f10>] (free_irq+0x44/0x64)
<4>[<c0082f10>] (free_irq+0x44/0x64) from [<bf006054>] (button2_init+0x34/0x58 )
<4>[<bf006054>] (button2_init+0x34/0x58 ) from [<c0031378>] (do_one_initcall+0x38/0x1ac)
<4>[<c0031378>] (do_one_initcall+0x38/0x1ac) from [<c007e894>] (sys_init_module+0xb8/0x1cc)
<4>[<c007e894>] (sys_init_module+0xb8/0x1cc) from [<c0031a20>] (ret_fast_syscall+0x0/0x30)
<4>---[ end trace 69130b5f71451ee6 ]---
<4>------------[ cut here ]------------
<4>WARNING: at kernel/irq/manage.c:899 __free_irq+0x9c/0x1ac()
<4>Trying to free already-free IRQ 105
<4>Modules linked in: button2(+)
<4>[<c0037a8c>] (unwind_backtrace+0x0/0xfc) from [<c04ac5f8>] (dump_stack+0x18/0x1c)
<4>[<c04ac5f8>] (dump_stack+0x18/0x1c) from [<c004c54c>] (warn_slowpath_common+0x54/0x6c)
<4>[<c004c54c>] (warn_slowpath_common+0x54/0x6c) from [<c004c608>] (warn_slowpath_fmt+0x38/0x40)
<4>[<c004c608>] (warn_slowpath_fmt+0x38/0x40) from [<c0082dbc>] (__free_irq+0x9c/0x1ac)
<4>[<c0082dbc>] (__free_irq+0x9c/0x1ac) from [<c0082f10>] (free_irq+0x44/0x64)
<4>[<c0082f10>] (free_irq+0x44/0x64) from [<bf006054>] (button2_init+0x34/0x58 )
<4>[<bf006054>] (button2_init+0x34/0x58 ) from [<c0031378>] (do_one_initcall+0x38/0x1ac)
<4>[<c0031378>] (do_one_initcall+0x38/0x1ac) from [<c007e894>] (sys_init_module+0xb8/0x1cc)
<4>[<c007e894>] (sys_init_module+0xb8/0x1cc) from [<c0031a20>] (ret_fast_syscall+0x0/0x30)
<4>---[ end trace 69130b5f71451ee7 ]---
<4>------------[ cut here ]------------
<4>WARNING: at kernel/irq/manage.c:899 __free_irq+0x9c/0x1ac()
<4>Trying to free already-free IRQ 106
<4>Modules linked in: button2(+)
<4>[<c0037a8c>] (unwind_backtrace+0x0/0xfc) from [<c04ac5f8>] (dump_stack+0x18/0x1c)
<4>[<c04ac5f8>] (dump_stack+0x18/0x1c) from [<c004c54c>] (warn_slowpath_common+0x54/0x6c)
<4>[<c004c54c>] (warn_slowpath_common+0x54/0x6c) from [<c004c608>] (warn_slowpath_fmt+0x38/0x40)
<4>[<c004c608>] (warn_slowpath_fmt+0x38/0x40) from [<c0082dbc>] (__free_irq+0x9c/0x1ac)
<4>[<c0082dbc>] (__free_irq+0x9c/0x1ac) from [<c0082f10>] (free_irq+0x44/0x64)
<4>[<c0082f10>] (free_irq+0x44/0x64) from [<bf006054>] (button2_init+0x34/0x58 )
<4>[<bf006054>] (button2_init+0x34/0x58 ) from [<c0031378>] (do_one_initcall+0x38/0x1ac)
<4>[<c0031378>] (do_one_initcall+0x38/0x1ac) from [<c007e894>] (sys_init_module+0xb8/0x1cc)
<4>[<c007e894>] (sys_init_module+0xb8/0x1cc) from [<c0031a20>] (ret_fast_syscall+0x0/0x30)
<4>---[ end trace 69130b5f71451ee8 ]---
查看 cat/proc/interrupts 原来的中断BUTTON依旧在,请教解决方法,或者求教系统自带的GPIO-KEYS的驱动的调用方法
顺便告诉一下 GPIO-KEYS驱动的示例程序和驱动程序的位置,懒得找的话说个文件名也行....

xiaoling 发表于 2011-8-7 21:00:03

nomaze 发表于 2012-6-27 16:11:58

我也是这个问题啊。。。在考虑用disable_irq和enable_irq来解决,不知道可不可以

nomaze 发表于 2012-6-27 21:55:19

这个问题有人能回答吗?飞凌的工作人员呢

nomaze 发表于 2012-6-28 01:31:54

经过不懈的努力,总算是被我找出解决方法了,这里无法注册中断的原因,当然是中断线已被占用,而去查看free_irq的代码(在kernel/irq/manage.c中),可以发现,出现这个Trying to free already-free IRQ 101 告警的原因是存在该中断号对应的中断描述符desc ,而相印的中断服务程序却不存在。说明有驱动程序占用了该中断号。 因而,我们要去掉这个驱动程序,方法:make menuconfig->Device Drivers->input device support->Key Boards->GPIO Buttons 去掉前面的*,即不选该项即可。
重新编译内核,ok

飞凌-develop 发表于 2012-6-28 08:42:47

楼上朋友的方法是配置Linux内核时去掉中断,也可以采用中断共享的方式来使用相同的中断源。

飞凌-develop 发表于 2012-6-28 08:47:24

楼上朋友的方法是配置Linux内核时去掉设备占用的中断,也可以采用中断共享的方式来使用相同的中断源,比如ADC驱动和触摸屏驱动都使用了相同的ADC中断号,楼主可以参考一下这两个设备的驱动程序。

nomaze 发表于 2012-6-28 16:10:38

回复 7# 飞凌-develop


    我试过共享的方式,没有成功,一直返回-EBUSY,不知道应该是怎么样一个形式来注册中断号,我采用的是request_irq,然后flags是IRQF_SHARED,第五个参数也设置了,教我一下

caoshunxin 发表于 2012-8-22 15:18:23

Hang_hang 发表于 2012-11-19 14:22:48

页: [1]
查看完整版本: OK6410 想释放GPIO-KEYS 占有的中断号