当前位置: 技术问答>linux和unix
request_irq 與free_irq問題
来源: 互联网 发布时间:2016-10-10
本文导语: 我的alsa driver裡,在open function裡request_irq 在close function裡free_irq 當執行aplay 播放一段聲音,irq callback function開始中斷 然後停了,程序沒有正常結束,那個部份可能我還沒處理好,我用ctrl+c結束 [snd_nxc2600_trigger] : Leave l I...
我的alsa driver裡,在open function裡request_irq
在close function裡free_irq
當執行aplay 播放一段聲音,irq callback function開始中斷
然後停了,程序沒有正常結束,那個部份可能我還沒處理好,我用ctrl+c結束
[snd_nxc2600_trigger] : Leave
l Interrupt...
[snd_nxc2600_playback_trigger] : Leave
[snd_nxc2600_close] : Enter
Trying to free free IRQ4
[snd_nxc2600_close] : Leave
然後看cat /proc/interrupts
CPU0
4: 1 wb audio
5: 0 w90x900-lcd
7: 337 w90x900-uart
12: 17293 w90x900 Timer Tick
15: 395 ehci_hcd:usb1
16: 21 w90x900-MAC
17: 169 w90x900-MAC
19: 0 W90X900_DMAC
20: 1 W90X900_SD
Err: 0
4號中斷沒被free,為什麼呢,再執行一次aplay
./aplay ringback.wav
[snd_nxc2600_playback_open] : Enter
wb_audio_init : Request IRQ error
Trying to free free IRQ4
aplay: main:546: audio open error: Operation not permitted
就不能播了,我把全部ac97的moduel都remove再cat /proc/interrupts
Unable to handle kernel paging request at virtual address bf03d880
pgd = c03e0000
[bf03d880] *pgd=00e6a011, *pte=00000000, *ppte=00000000
Internal error: Oops: 7 [#1]
Modules linked in:
CPU: 0
PC is at strnlen+0x20/0x34
LR is at vsnprintf+0x300/0x5b4
pc : [] lr : [] Not tainted
sp : c0f01e48 ip : c0f01e58 fp : c0f01e54
r10: ffffffff r9 : c0fd3fff r8 : 00000000
r7 : c0f01ec8 r6 : c0fd3022 r5 : c0868d20 r4 : bf03d880
r3 : c0229624 r2 : bf03d880 r1 : fffffffe r0 : bf03d880
Flags: NzCv IRQs off FIQs on Mode SVC_32 Segment user
Control: 5317F Table: 003E0000 DAC: 00000015
Process cat (pid: 838, stack limit = 0xc0f001a0)
Stack: (0xc0f01e48 to 0xc0f02000)
1e40: c0f01ea4 c0f01e58 c012b510 c012a3ac 0000000a 0000000a
1e60: ffffffff 00000000 00000056 00000fe0 c0fd3020 c0218ddb c005f224 c0868d20
1e80: c0868d20 80000013 00000000 00000004 00000000 00000010 c0f01ec0 c0f01ea8
1ea0: c0095328 c012b220 c0dde530 c0f01ec8 c0e17920 c0f01f04 c0f01ed0 c002151c
1ec0: c00952f4 c0218dd8 bf03d880 00000015 bec69c08 30555043 c0f00000 00000000
1ee0: c0f01f04 c0f01f18 00000000 c0868d20 bec69c08 00001000 c0f01f54 c0f01f08
1f00: c0095968 c0021458 c0f01f78 c0304c60 c0868d40 00000000 00000004 00000000
1f20: 00000003 00000000 c0f01f7c c0304c60 bec69c08 c0f01f78 00001000 c001ff68
1f40: c0f00000 00000000 c0f01f74 c0f01f58 c0071854 c0095744 00000000 00000000
1f60: c0304c60 00000003 c0f01fa4 c0f01f78 c0071d28 c00717b4 00000000 00000000
1f80: 00000005 00000000 ffffffff 00001000 bec69c08 00000003 00000000 c0f01fa8
1fa0: c001fdc0 c0071cf4 00001000 bec69c08 00000003 bec69c08 00001000 00000001
1fc0: 00001000 bec69c08 00000003 00000003 00000000 bec69c08 00000001 00000003
1fe0: 00000002 bec69be0 0000a42c 0005e024 60000010 00000003 2043494d 204d4350
Backtrace:
[] (strnlen+0x0/0x34) from [] (vsnprintf+0x300/0x5b4)
[] (vsnprintf+0x0/0x5b4) from [] (seq_printf+0x48/0x7c)
[] (seq_printf+0x0/0x7c) from [] (show_interrupts+0xd4/0x16c)
r3 = 00000015 r2 = BF03D880 r1 = C0218DD8
r4 = C0E17920
[] (show_interrupts+0x0/0x16c) from [] (seq_read+0x234/0x378)
r8 = 00001000 r7 = BEC69C08 r6 = C0868D20 r5 = 00000000
r4 = C0F01F18
[] (seq_read+0x0/0x378) from [] (vfs_read+0xb0/0x17c)
[] (vfs_read+0x0/0x17c) from [] (sys_read+0x44/0x70)
r7 = 00000003 r6 = C0304C60 r5 = 00000000 r4 = 00000000
[] (sys_read+0x0/0x70) from [] (ret_fast_syscall+0x0/0x2c)
r6 = 00000003 r5 = BEC69C08 r4 = 00001000
Code: ea000000 e2800001 e2511001 3a000002 (e5d03000)
note: cat[838] exited with preempt_count 1
Segmentation fault
再全部insert module一次 cat /proc/interrupts
CPU0
4: 1 wb audio
5: 0 w90x900-lcd
7: 461 w90x900-uart
12: 39498 w90x900 Timer Tick
15: 427 ehci_hcd:usb1
16: 34 w90x900-MAC
17: 394 w90x900-MAC
19: 0 W90X900_DMAC
20: 1 W90X900_SD
Err: 0
又正常了
./aplay ringback.wav
[snd_nxc2600_playback_open] : Enter
wb_audio_init : Request IRQ error
Trying to free free IRQ4
aplay: main:546: audio open error: Operation not permitted
還是不行,為什麼free_irq不行呢?每次執行ap一次不就會request_irq一次
那是代表只能被單一ap獨佔嗎
在close function裡free_irq
當執行aplay 播放一段聲音,irq callback function開始中斷
然後停了,程序沒有正常結束,那個部份可能我還沒處理好,我用ctrl+c結束
[snd_nxc2600_trigger] : Leave
l Interrupt...
[snd_nxc2600_playback_trigger] : Leave
[snd_nxc2600_close] : Enter
Trying to free free IRQ4
[snd_nxc2600_close] : Leave
然後看cat /proc/interrupts
CPU0
4: 1 wb audio
5: 0 w90x900-lcd
7: 337 w90x900-uart
12: 17293 w90x900 Timer Tick
15: 395 ehci_hcd:usb1
16: 21 w90x900-MAC
17: 169 w90x900-MAC
19: 0 W90X900_DMAC
20: 1 W90X900_SD
Err: 0
4號中斷沒被free,為什麼呢,再執行一次aplay
./aplay ringback.wav
[snd_nxc2600_playback_open] : Enter
wb_audio_init : Request IRQ error
Trying to free free IRQ4
aplay: main:546: audio open error: Operation not permitted
就不能播了,我把全部ac97的moduel都remove再cat /proc/interrupts
Unable to handle kernel paging request at virtual address bf03d880
pgd = c03e0000
[bf03d880] *pgd=00e6a011, *pte=00000000, *ppte=00000000
Internal error: Oops: 7 [#1]
Modules linked in:
CPU: 0
PC is at strnlen+0x20/0x34
LR is at vsnprintf+0x300/0x5b4
pc : [] lr : [] Not tainted
sp : c0f01e48 ip : c0f01e58 fp : c0f01e54
r10: ffffffff r9 : c0fd3fff r8 : 00000000
r7 : c0f01ec8 r6 : c0fd3022 r5 : c0868d20 r4 : bf03d880
r3 : c0229624 r2 : bf03d880 r1 : fffffffe r0 : bf03d880
Flags: NzCv IRQs off FIQs on Mode SVC_32 Segment user
Control: 5317F Table: 003E0000 DAC: 00000015
Process cat (pid: 838, stack limit = 0xc0f001a0)
Stack: (0xc0f01e48 to 0xc0f02000)
1e40: c0f01ea4 c0f01e58 c012b510 c012a3ac 0000000a 0000000a
1e60: ffffffff 00000000 00000056 00000fe0 c0fd3020 c0218ddb c005f224 c0868d20
1e80: c0868d20 80000013 00000000 00000004 00000000 00000010 c0f01ec0 c0f01ea8
1ea0: c0095328 c012b220 c0dde530 c0f01ec8 c0e17920 c0f01f04 c0f01ed0 c002151c
1ec0: c00952f4 c0218dd8 bf03d880 00000015 bec69c08 30555043 c0f00000 00000000
1ee0: c0f01f04 c0f01f18 00000000 c0868d20 bec69c08 00001000 c0f01f54 c0f01f08
1f00: c0095968 c0021458 c0f01f78 c0304c60 c0868d40 00000000 00000004 00000000
1f20: 00000003 00000000 c0f01f7c c0304c60 bec69c08 c0f01f78 00001000 c001ff68
1f40: c0f00000 00000000 c0f01f74 c0f01f58 c0071854 c0095744 00000000 00000000
1f60: c0304c60 00000003 c0f01fa4 c0f01f78 c0071d28 c00717b4 00000000 00000000
1f80: 00000005 00000000 ffffffff 00001000 bec69c08 00000003 00000000 c0f01fa8
1fa0: c001fdc0 c0071cf4 00001000 bec69c08 00000003 bec69c08 00001000 00000001
1fc0: 00001000 bec69c08 00000003 00000003 00000000 bec69c08 00000001 00000003
1fe0: 00000002 bec69be0 0000a42c 0005e024 60000010 00000003 2043494d 204d4350
Backtrace:
[] (strnlen+0x0/0x34) from [] (vsnprintf+0x300/0x5b4)
[] (vsnprintf+0x0/0x5b4) from [] (seq_printf+0x48/0x7c)
[] (seq_printf+0x0/0x7c) from [] (show_interrupts+0xd4/0x16c)
r3 = 00000015 r2 = BF03D880 r1 = C0218DD8
r4 = C0E17920
[] (show_interrupts+0x0/0x16c) from [] (seq_read+0x234/0x378)
r8 = 00001000 r7 = BEC69C08 r6 = C0868D20 r5 = 00000000
r4 = C0F01F18
[] (seq_read+0x0/0x378) from [] (vfs_read+0xb0/0x17c)
[] (vfs_read+0x0/0x17c) from [] (sys_read+0x44/0x70)
r7 = 00000003 r6 = C0304C60 r5 = 00000000 r4 = 00000000
[] (sys_read+0x0/0x70) from [] (ret_fast_syscall+0x0/0x2c)
r6 = 00000003 r5 = BEC69C08 r4 = 00001000
Code: ea000000 e2800001 e2511001 3a000002 (e5d03000)
note: cat[838] exited with preempt_count 1
Segmentation fault
再全部insert module一次 cat /proc/interrupts
CPU0
4: 1 wb audio
5: 0 w90x900-lcd
7: 461 w90x900-uart
12: 39498 w90x900 Timer Tick
15: 427 ehci_hcd:usb1
16: 34 w90x900-MAC
17: 394 w90x900-MAC
19: 0 W90X900_DMAC
20: 1 W90X900_SD
Err: 0
又正常了
./aplay ringback.wav
[snd_nxc2600_playback_open] : Enter
wb_audio_init : Request IRQ error
Trying to free free IRQ4
aplay: main:546: audio open error: Operation not permitted
還是不行,為什麼free_irq不行呢?每次執行ap一次不就會request_irq一次
那是代表只能被單一ap獨佔嗎
static int snd_nxc2600_playback_open(struct snd_pcm_substream *substream)
{
int err; ENTER();
struct snd_nxc2600 *nxc2600 = substream->pcm->private_data;
// if(nxc2600->playback.channel == NULL)
// return -EBUSY;
nxc2600->playback.substream = substream;
substream->private_data = &nxc2600->playback;
substream->runtime->hw = snd_nxc2600_hw;
//========================================
if((err = request_irq(IRQ_ACTL, wb_dsp_irq, SA_INTERRUPT, "wb audio", nxc2600))) {
printk("Request IRQ error=%dn",err); snd_card_free(nxc2600_card);
return -1; }
//========================================= memset(&play_half_buf, 0, sizeof(play_half_buf));
memset(&record_half_buf, 0, sizeof(record_half_buf));
LEAVE();
return (snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates) private_data;
spin_lock_irq(&stream->dma_lock); //nxc2600_dma_stop(stream);
Disable_Int(AU_PLAY_INT_NUM);
free_irq(IRQ_ACTL, NULL);
spin_unlock_irq(&stream->dma_lock);
stream->substream = NULL;
LEAVE(); return 0;
}
|
然後看cat /proc/interrupts
CPU0
4: 1 wb audio
5: 0 w90x900-lcd
7: 337 w90x900-uart
12: 17293 w90x900 Timer Tick
15: 395 ehci_hcd:usb1
16: 21 w90x900-MAC
17: 169 w90x900-MAC
19: 0 W90X900_DMAC
20: 1 W90X900_SD
Err: 0
4號中斷沒被free,為什麼呢,再執行一次aplay
free_irq没有操作成功.
CPU0
4: 1 wb audio
5: 0 w90x900-lcd
7: 337 w90x900-uart
12: 17293 w90x900 Timer Tick
15: 395 ehci_hcd:usb1
16: 21 w90x900-MAC
17: 169 w90x900-MAC
19: 0 W90X900_DMAC
20: 1 W90X900_SD
Err: 0
4號中斷沒被free,為什麼呢,再執行一次aplay
free_irq没有操作成功.
|
这个中断只是处理与硬件的交互,与有几个应用没有关系。与应用相关的是你的驱动是否
支持多次 open,只要处理好每次读写的数据不会互相重叠(包括硬件上),并能正确的
反映到硬件上去。一般驱动会有一个缓存的动作,将多次读写数据进行排队,避免冲突。
还有注册时,pci 上的中断一般采用共享中断方式注册。
呵呵,最后顺便提一句:还请兄弟支持一下我升星星吧...
支持多次 open,只要处理好每次读写的数据不会互相重叠(包括硬件上),并能正确的
反映到硬件上去。一般驱动会有一个缓存的动作,将多次读写数据进行排队,避免冲突。
if (request_irq(pci->irq, irq_handler, IRQF_SHARED,
card->shortname, chip)) {
snd_printk(KERN_ERR "unable to grab IRQ %dn", pci->irq);
snd_als300_free(chip);
return -EBUSY;
}
chip->irq = pci->irq;
还有注册时,pci 上的中断一般采用共享中断方式注册。
呵呵,最后顺便提一句:还请兄弟支持一下我升星星吧...