Skip to content

Commit 63e51fd

Browse files
committed
ALSA: hda - Don't take unresponsive D3 transition too serious
When a codec is powered off, some systems don't respond properly after D3 FG transition, while the driver still expects the response and tries to fall back to different modes (polling and single-cmd). When the fallback happens, the driver stays in that mode, and falling back to the single-cmd mode means it'll loose the unsol event handling, too. The unresponsiveness at D3 isn't too serious, thus this fallback is mostly superfluous. We can gracefully ignore the error there so that the driver keeps the normal operation mode. This patch adds a new bit flag for codec read/write, set in the power transition stage, which is notified to the controller driver via a new bus->no_response_fallback flag. Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent e7ecc27 commit 63e51fd

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎sound/pci/hda/hda_codec.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
221221
again:
222222
snd_hda_power_up(codec);
223223
mutex_lock(&bus->cmd_mutex);
224+
if (flags & HDA_RW_NO_RESPONSE_FALLBACK)
225+
bus->no_response_fallback = 1;
224226
for (;;) {
225227
trace_hda_send_cmd(codec, cmd);
226228
err = bus->ops.command(bus, cmd);
@@ -233,6 +235,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
233235
*res = bus->ops.get_response(bus, codec->addr);
234236
trace_hda_get_response(codec, *res);
235237
}
238+
bus->no_response_fallback = 0;
236239
mutex_unlock(&bus->cmd_mutex);
237240
snd_hda_power_down(codec);
238241
if (!codec_in_pm(codec) && res && *res == -1 && bus->rirb_error) {
@@ -3805,11 +3808,13 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,
38053808
hda_nid_t fg = codec->afg ? codec->afg : codec->mfg;
38063809
int count;
38073810
unsigned int state;
3811+
int flags = 0;
38083812

38093813
/* this delay seems necessary to avoid click noise at power-down */
38103814
if (power_state == AC_PWRST_D3) {
38113815
/* transition time less than 10ms for power down */
38123816
msleep(codec->epss ? 10 : 100);
3817+
flags = HDA_RW_NO_RESPONSE_FALLBACK;
38133818
}
38143819

38153820
/* repeat power states setting at most 10 times*/
@@ -3818,7 +3823,7 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,
38183823
codec->patch_ops.set_power_state(codec, fg,
38193824
power_state);
38203825
else {
3821-
snd_hda_codec_read(codec, fg, 0,
3826+
snd_hda_codec_read(codec, fg, flags,
38223827
AC_VERB_SET_POWER_STATE,
38233828
power_state);
38243829
snd_hda_codec_set_power_to_all(codec, fg, power_state);

‎sound/pci/hda/hda_codec.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ struct hda_bus {
679679
unsigned int response_reset:1; /* controller was reset */
680680
unsigned int in_reset:1; /* during reset operation */
681681
unsigned int power_keep_link_on:1; /* don't power off HDA link */
682+
unsigned int no_response_fallback:1; /* don't fallback at RIRB error */
682683

683684
int primary_dig_out_type; /* primary digital out PCM type */
684685
};
@@ -930,6 +931,8 @@ enum {
930931
HDA_INPUT, HDA_OUTPUT
931932
};
932933

934+
/* snd_hda_codec_read/write optional flags */
935+
#define HDA_RW_NO_RESPONSE_FALLBACK (1 << 0)
933936

934937
/*
935938
* constructors

‎sound/pci/hda/hda_intel.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,9 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus,
942942
}
943943
}
944944

945+
if (!bus->no_response_fallback)
946+
return -1;
947+
945948
if (!chip->polling_mode && chip->poll_count < 2) {
946949
snd_printdd(SFX "%s: azx_get_response timeout, "
947950
"polling the codec once: last cmd=0x%08x\n",

0 commit comments

Comments
 (0)