ALSA: emu10k1: simplify interrupt handler, part 1
PATCH 1/4 ALSA: emu10k1: simplify interrupt handler, part 1
IPR_CHANNELNUMBERMASK cannot be non-zero when IPR_CHANNELLOOP is unset, so join marking them as handled.
This logically reverts part of commit f453e20d8a0 ("ALSA update 0.9.3a"), which made the inverse change with no explanation.
--- sound/pci/emu10k1/irq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/pci/emu10k1/irq.c +1 -2
@@ -79,9 +79,8 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id) val >>=1 ; pvoice++; } - status &= ~IPR_CHANNELLOOP ; + status &= ~(IPR_CHANNELLOOP |IPR_CHANNELNUMBERMASK ); } - status &= ~IPR_CHANNELNUMBERMASK ;if (status & (IPR_ADCBUFFULL |IPR_ADCBUFHALFFULL )) {if (emu->capture_interrupt) emu->capture_interrupt (emu, status);
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 2/4 ALSA: emu10k1: simplify interrupt handler, part 2
Remove weird INTE_* clearing code. The bits were a subset of the actually handled interrupts, which kind of contradicted the stated purpose. I suppose it would make sense to complete the set and negate it, but interrupts being enabled out of the blue is neither something that happens a lot, nor should it result in just one error message, IMO.
--- sound/pci/emu10k1/irq.c | 18 ------------------ 1 file changed, 18 deletions(-)
sound/pci/emu10k1/irq.c +0 -18
@@ -146,26 +146,8 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id) }if (status) { -unsigned int bits;dev_err (emu->card->dev,"unhandled interrupt: 0x%08x\n" , status); -//make sure any interrupts we don't handle are disabled: - bits =INTE_FXDSPENABLE | -INTE_PCIERRORENABLE | -INTE_VOLINCRENABLE | -INTE_VOLDECRENABLE | -INTE_MUTEENABLE | -INTE_MICBUFENABLE | -INTE_ADCBUFENABLE | -INTE_EFXBUFENABLE | -INTE_GPSPDIFENABLE | -INTE_CDSPDIFENABLE | -INTE_INTERVALTIMERENB | -INTE_MIDITXENABLE | -INTE_MIDIRXENABLE ; -if (emu->audigy) - bits |=INTE_A_MIDITXENABLE2 |INTE_A_MIDIRXENABLE2 ; -snd_emu10k1_intr_disable (emu, bits); }outl (orig_status, emu->port +IPR );/* ack all */ }
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 3/4 ALSA: emu10k1: simplify interrupt handler, part 3
In reply to Oswald BuddenhagenHandle the "timeout" (actually the retry counter) such that it's more obvious and causes less cost in the normal case.
--- sound/pci/emu10k1/irq.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
sound/pci/emu10k1/irq.c +6 -5
@@ -22,15 +22,18 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id)int handled =0 ;int timeout =0 ; -while (((status =inl (emu->port +IPR )) !=0 ) && (timeout <1000 )) { - timeout++; - orig_status = status; +while ((status =inl (emu->port +IPR )) !=0 ) { handled =1 ;if ((status &0xffffffff ) ==0xffffffff ) {dev_info (emu->card->dev,"Suspected sound card removal\n" );break ; } +if (++timeout ==1000 ) { +dev_info (emu->card->dev,"emu10k1 irq routine failure\n" ); +break ; + } + orig_status = status;if (status &IPR_PCIERROR ) {dev_err (emu->card->dev,"interrupt: PCI error\n" );snd_emu10k1_intr_disable (emu,INTE_PCIERRORENABLE );
@@ -151,8 +154,6 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id) }outl (orig_status, emu->port +IPR );/* ack all */ } -if (timeout ==1000 ) -dev_info (emu->card->dev,"emu10k1 irq routine failure\n" );return IRQ_RETVAL (handled); }
Signature · 1 line
2.40.0.152.g15d061e6df
PATCH 4/4 ALSA: emu10k1: fix handling of half-loop interrupts
In reply to Oswald BuddenhagenWe'd try to iterate the voices twice without resetting the pointer. This went unnoticed, because the code isn't actually in use.
Amends commit 27ae958cf6 ("emu10k1 driver - add multichannel device hw:x,3 [2-8/8]").
--- sound/pci/emu10k1/irq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/pci/emu10k1/irq.c +3 -1
@@ -47,12 +47,13 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id) status &= ~(IPR_VOLINCR |IPR_VOLDECR |IPR_MUTE ); }if (status &IPR_CHANNELLOOP ) { +struct snd_emu10k1_voice *pvoice;int voice;int voice_max = status &IPR_CHANNELNUMBERMASK ;u32 val; -struct snd_emu10k1_voice *pvoice = emu->voices; val =snd_emu10k1_ptr_read (emu,CLIPL ,0 ); + pvoice = emu->voices;for (voice =0 ; voice <= voice_max; voice++) {if (voice ==0x20 ) val =snd_emu10k1_ptr_read (emu,CLIPH ,0 );
@@ -68,6 +69,7 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id) pvoice++; } val =snd_emu10k1_ptr_read (emu,HLIPL ,0 ); + pvoice = emu->voices;for (voice =0 ; voice <= voice_max; voice++) {if (voice ==0x20 ) val =snd_emu10k1_ptr_read (emu,HLIPH ,0 );
Signature · 1 line
2.40.0.152.g15d061e6df
Takashi Iwai
AppliedQuoted 7 lines · Oswald Buddenhagen
IPR_CHANNELNUMBERMASKcannot be non-zero whenIPR_CHANNELLOOPis unset, so join marking them as handled.
This logically reverts part of commitf453e20d8a0("ALSA update 0.9.3a"), which made the inverse change with no explanation.Signed-off-by Oswald Buddenhagen <[email protected]>
Applied all four patches now. Thanks.
Takashi