Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit b61749a8 authored by Yu Zhao's avatar Yu Zhao Committed by Mark Brown
Browse files

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: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarYu Zhao <yuzhao@google.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 542cedec
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ static void azx_clear_corbrp(struct hdac_bus *bus)
 */
void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus)
{
	WARN_ON_ONCE(!bus->rb.area);

	spin_lock_irq(&bus->reg_lock);
	/* CORB set up */
	bus->corb.addr = bus->rb.addr;
@@ -479,13 +481,15 @@ bool snd_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset)
	/* reset controller */
	azx_reset(bus, full_reset);

	/* initialize interrupts */
	/* clear interrupts */
	azx_int_clear(bus);
	azx_int_enable(bus);

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

	/* enable interrupts after CORB/RIRB buffers are initialized above */
	azx_int_enable(bus);

	/* program the position buffer */
	if (bus->use_posbuf && bus->posbuf.addr) {
		snd_hdac_chip_writel(bus, DPLBASE, (u32)bus->posbuf.addr);