ALSA: hda: fix: lock reg_lock before calling snd_hdac_bus_update_rirb
authorBard Liao <yung-chuan.liao@linux.intel.com>
Wed, 29 May 2019 20:59:00 +0000 (04:59 +0800)
committerTakashi Iwai <tiwai@suse.de>
Thu, 30 May 2019 09:00:21 +0000 (11:00 +0200)
The patch is to fix commit 5e13cf6cd64c
(ALSA: hda: add polling mode in snd_hdac_bus_get_response)
spin_lock_irq should be called before snd_hdac_bus_update_rirb.

Fixes: 5e13cf6cd64c ("ALSA: hda: add polling mode in snd_hdac_bus_get_response")
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/hda/hdac_controller.c

index a16ac31bda835474bc9654d3cc02acb0a57ee291..d6a91429c058cddcd13e6939941f281508f50f2e 100644 (file)
@@ -239,9 +239,9 @@ int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr,
        timeout = jiffies + msecs_to_jiffies(1000);
 
        for (loopcounter = 0;; loopcounter++) {
+               spin_lock_irq(&bus->reg_lock);
                if (bus->polling_mode)
                        snd_hdac_bus_update_rirb(bus);
-               spin_lock_irq(&bus->reg_lock);
                if (!bus->rirb.cmds[addr]) {
                        if (res)
                                *res = bus->rirb.res[addr]; /* the last value */