Skip to content

Commit

Permalink
ALSA: hda - Loop interrupt handling until really cleared
Browse files Browse the repository at this point in the history
Currently the interrupt handler of HD-audio driver assumes that no irq
update is needed while processing the irq.  But in reality, it has
been confirmed that the HW irq is issued even during the irq
handling.  Since we clear the irq status at the beginning, process the
interrupt, then exits from the handler, the lately issued interrupt is
left untouched without being properly processed.

This patch changes the interrupt handler code to loop over the
check-and-process.  The handler tries repeatedly as long as the IRQ
status are turned on, and either stream or CORB/RIRB is handled.

For checking the stream handling, snd_hdac_bus_handle_stream_irq()
returns a value indicating the stream indices bits.  Other than that,
the change is only in the irq handler itself.

Reported-by: Libin Yang <libin.yang@linux.intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Feb 26, 2016
1 parent f883982 commit 473f414
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion include/sound/hdaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void snd_hdac_bus_enter_link_reset(struct hdac_bus *bus);
void snd_hdac_bus_exit_link_reset(struct hdac_bus *bus);

void snd_hdac_bus_update_rirb(struct hdac_bus *bus);
void snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
int snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
void (*ack)(struct hdac_bus *,
struct hdac_stream *));

Expand Down
7 changes: 6 additions & 1 deletion sound/hda/hdac_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,25 +426,30 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip);
* @bus: HD-audio core bus
* @status: INTSTS register value
* @ask: callback to be called for woken streams
*
* Returns the bits of handled streams, or zero if no stream is handled.
*/
void snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
int snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
void (*ack)(struct hdac_bus *,
struct hdac_stream *))
{
struct hdac_stream *azx_dev;
u8 sd_status;
int handled = 0;

list_for_each_entry(azx_dev, &bus->stream_list, list) {
if (status & azx_dev->sd_int_sta_mask) {
sd_status = snd_hdac_stream_readb(azx_dev, SD_STS);
snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK);
handled |= 1 << azx_dev->index;
if (!azx_dev->substream || !azx_dev->running ||
!(sd_status & SD_INT_COMPLETE))
continue;
if (ack)
ack(bus, azx_dev);
}
}
return handled;
}
EXPORT_SYMBOL_GPL(snd_hdac_bus_handle_stream_irq);

Expand Down
47 changes: 26 additions & 21 deletions sound/pci/hda/hda_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,8 @@ irqreturn_t azx_interrupt(int irq, void *dev_id)
struct azx *chip = dev_id;
struct hdac_bus *bus = azx_bus(chip);
u32 status;
bool active, handled = false;
int repeat = 0; /* count for avoiding endless loop */

#ifdef CONFIG_PM
if (azx_has_pm_runtime(chip))
Expand All @@ -939,33 +941,36 @@ irqreturn_t azx_interrupt(int irq, void *dev_id)

spin_lock(&bus->reg_lock);

if (chip->disabled) {
spin_unlock(&bus->reg_lock);
return IRQ_NONE;
}

status = azx_readl(chip, INTSTS);
if (status == 0 || status == 0xffffffff) {
spin_unlock(&bus->reg_lock);
return IRQ_NONE;
}
if (chip->disabled)
goto unlock;

snd_hdac_bus_handle_stream_irq(bus, status, stream_update);
do {
status = azx_readl(chip, INTSTS);
if (status == 0 || status == 0xffffffff)
break;

/* clear rirb int */
status = azx_readb(chip, RIRBSTS);
if (status & RIRB_INT_MASK) {
if (status & RIRB_INT_RESPONSE) {
if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
udelay(80);
snd_hdac_bus_update_rirb(bus);
handled = true;
active = false;
if (snd_hdac_bus_handle_stream_irq(bus, status, stream_update))
active = true;

/* clear rirb int */
status = azx_readb(chip, RIRBSTS);
if (status & RIRB_INT_MASK) {
active = true;
if (status & RIRB_INT_RESPONSE) {
if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
udelay(80);
snd_hdac_bus_update_rirb(bus);
}
azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
}
azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
}
} while (active && ++repeat < 10);

unlock:
spin_unlock(&bus->reg_lock);

return IRQ_HANDLED;
return IRQ_RETVAL(handled);
}
EXPORT_SYMBOL_GPL(azx_interrupt);

Expand Down

0 comments on commit 473f414

Please sign in to comment.