ALSA: hda: warn on spurious response
[pandora-kernel.git] / sound / pci / hda / hda_intel.c
index b6e6314..175f07a 100644 (file)
@@ -418,7 +418,7 @@ struct azx {
        unsigned int probing :1; /* codec probing phase */
 
        /* for debugging */
-       unsigned int last_cmd;  /* last issued command (to sync) */
+       unsigned int last_cmd[AZX_MAX_CODECS];
 
        /* for pending irqs */
        struct work_struct irq_pending_work;
@@ -588,15 +588,17 @@ static int azx_corb_send_cmd(struct hda_bus *bus, u32 val)
        unsigned int addr = azx_command_addr(val);
        unsigned int wp;
 
+       spin_lock_irq(&chip->reg_lock);
+
        /* add command to corb */
        wp = azx_readb(chip, CORBWP);
        wp++;
        wp %= ICH6_MAX_CORB_ENTRIES;
 
-       spin_lock_irq(&chip->reg_lock);
        chip->rirb.cmds[addr]++;
        chip->corb.buf[wp] = cpu_to_le32(val);
        azx_writel(chip, CORBWP, wp);
+
        spin_unlock_irq(&chip->reg_lock);
 
        return 0;
@@ -630,7 +632,11 @@ static void azx_update_rirb(struct azx *chip)
                        chip->rirb.res[addr] = res;
                        smp_wmb();
                        chip->rirb.cmds[addr]--;
-               }
+               } else
+                       snd_printk(KERN_ERR SFX "spurious response %#x:%#x, "
+                                  "last cmd=%#08x\n",
+                                  res, res_ex,
+                                  chip->last_cmd[addr]);
        }
 }
 
@@ -666,7 +672,8 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
 
        if (chip->msi) {
                snd_printk(KERN_WARNING SFX "No response from codec, "
-                          "disabling MSI: last cmd=0x%08x\n", chip->last_cmd);
+                          "disabling MSI: last cmd=0x%08x\n",
+                          chip->last_cmd[addr]);
                free_irq(chip->irq, chip);
                chip->irq = -1;
                pci_disable_msi(chip->pci);
@@ -681,7 +688,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
        if (!chip->polling_mode) {
                snd_printk(KERN_WARNING SFX "azx_get_response timeout, "
                           "switching to polling mode: last cmd=0x%08x\n",
-                          chip->last_cmd);
+                          chip->last_cmd[addr]);
                chip->polling_mode = 1;
                goto again;
        }
@@ -705,7 +712,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
 
        snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, "
                   "switching to single_cmd mode: last cmd=0x%08x\n",
-                  chip->last_cmd);
+                  chip->last_cmd[addr]);
        chip->single_cmd = 1;
        bus->response_reset = 0;
        /* re-initialize CORB/RIRB */
@@ -792,7 +799,7 @@ static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
 {
        struct azx *chip = bus->private_data;
 
-       chip->last_cmd = val;
+       chip->last_cmd[azx_command_addr(val)] = val;
        if (chip->single_cmd)
                return azx_single_send_cmd(bus, val);
        else