Skip to content

Commit b61749a

Browse files
yuzhaogooglebroonie
authored andcommitted
sound: enable interrupt after dma buffer initialization
In snd_hdac_bus_init_chip(), we enable interrupt before snd_hdac_bus_init_cmd_io() initializing dma buffers. If irq has been acquired and irq handler uses the dma buffer, kernel may crash when interrupt comes in. Fix the problem by postponing enabling irq after dma buffer initialization. And warn once on null dma buffer pointer during the initialization. Reviewed-by: Takashi Iwai <[email protected]> Signed-off-by: Yu Zhao <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 542cede commit b61749a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sound/hda/hdac_controller.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ static void azx_clear_corbrp(struct hdac_bus *bus)
4040
*/
4141
void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus)
4242
{
43+
WARN_ON_ONCE(!bus->rb.area);
44+
4345
spin_lock_irq(&bus->reg_lock);
4446
/* CORB set up */
4547
bus->corb.addr = bus->rb.addr;
@@ -479,13 +481,15 @@ bool snd_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset)
479481
/* reset controller */
480482
azx_reset(bus, full_reset);
481483

482-
/* initialize interrupts */
484+
/* clear interrupts */
483485
azx_int_clear(bus);
484-
azx_int_enable(bus);
485486

486487
/* initialize the codec command I/O */
487488
snd_hdac_bus_init_cmd_io(bus);
488489

490+
/* enable interrupts after CORB/RIRB buffers are initialized above */
491+
azx_int_enable(bus);
492+
489493
/* program the position buffer */
490494
if (bus->use_posbuf && bus->posbuf.addr) {
491495
snd_hdac_chip_writel(bus, DPLBASE, (u32)bus->posbuf.addr);

0 commit comments

Comments
 (0)