提交 b613291f 编写于 作者: T Takashi Iwai

ALSA: hda - Retry codec-verbs at errors

The current error-recovery scheme for the codec communication errors
doesn't work always well.  Especially falling back to the
single-command mode causes the fatal problem on many systems.

In this patch, the problematic verb is re-issued again after the error
(even with polling mode) instead of the single-cmd mode.  The
single-cmd mode will be used only when specified via the command
option explicitly, mainly just for testing.
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 92c7c8a7
...@@ -174,14 +174,23 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, ...@@ -174,14 +174,23 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
unsigned int verb, unsigned int parm) unsigned int verb, unsigned int parm)
{ {
struct hda_bus *bus = codec->bus; struct hda_bus *bus = codec->bus;
unsigned int res; unsigned int cmd, res;
int repeated = 0;
res = make_codec_cmd(codec, nid, direct, verb, parm); cmd = make_codec_cmd(codec, nid, direct, verb, parm);
snd_hda_power_up(codec); snd_hda_power_up(codec);
mutex_lock(&bus->cmd_mutex); mutex_lock(&bus->cmd_mutex);
if (!bus->ops.command(bus, res)) again:
if (!bus->ops.command(bus, cmd)) {
res = bus->ops.get_response(bus); res = bus->ops.get_response(bus);
else if (res == -1 && bus->rirb_error) {
if (repeated++ < 1) {
snd_printd(KERN_WARNING "hda_codec: "
"Trying verb 0x%08x again\n", cmd);
goto again;
}
}
} else
res = (unsigned int)-1; res = (unsigned int)-1;
mutex_unlock(&bus->cmd_mutex); mutex_unlock(&bus->cmd_mutex);
snd_hda_power_down(codec); snd_hda_power_down(codec);
......
...@@ -623,6 +623,7 @@ struct hda_bus { ...@@ -623,6 +623,7 @@ struct hda_bus {
/* misc op flags */ /* misc op flags */
unsigned int needs_damn_long_delay :1; unsigned int needs_damn_long_delay :1;
unsigned int shutdown :1; /* being unloaded */ unsigned int shutdown :1; /* being unloaded */
unsigned int rirb_error:1; /* error in codec communication */
}; };
/* /*
......
...@@ -604,6 +604,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) ...@@ -604,6 +604,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
} }
if (!chip->rirb.cmds) { if (!chip->rirb.cmds) {
smp_rmb(); smp_rmb();
bus->rirb_error = 0;
return chip->rirb.res; /* the last value */ return chip->rirb.res; /* the last value */
} }
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout))
...@@ -623,8 +624,10 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) ...@@ -623,8 +624,10 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
chip->irq = -1; chip->irq = -1;
pci_disable_msi(chip->pci); pci_disable_msi(chip->pci);
chip->msi = 0; chip->msi = 0;
if (azx_acquire_irq(chip, 1) < 0) if (azx_acquire_irq(chip, 1) < 0) {
bus->rirb_error = 1;
return -1; return -1;
}
goto again; goto again;
} }
...@@ -644,14 +647,12 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus) ...@@ -644,14 +647,12 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
return -1; return -1;
} }
snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " snd_printk(KERN_ERR "hda_intel: azx_get_response timeout (ERROR): "
"switching to single_cmd mode: last cmd=0x%08x\n", "last cmd=0x%08x\n", chip->last_cmd);
chip->last_cmd); spin_lock_irq(&chip->reg_lock);
chip->rirb.rp = azx_readb(chip, RIRBWP); chip->rirb.cmds = 0; /* reset the index */
chip->rirb.cmds = 0; bus->rirb_error = 1;
/* switch to single_cmd mode */ spin_unlock_irq(&chip->reg_lock);
chip->single_cmd = 1;
azx_free_cmd_io(chip);
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册