[PATCH 2/2] redo

Chris Wilson chris at chris-wilson.co.uk
Tue Feb 13 16:21:28 UTC 2018


---
 sound/pci/hda/hda_codec.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index e018ecbf78a8..da1d7b15221a 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2710,21 +2710,29 @@ static unsigned int hda_sync_power_state(struct hda_codec *codec,
 					 unsigned int power_state)
 {
 	unsigned long end_time = jiffies + msecs_to_jiffies(500);
-	unsigned int state, actual_state;
+	int count;
+
+	for (count = 0; count < 500; count++) {
+		unsigned int state, actual_state;
 
-	for (;;) {
 		state = snd_hda_codec_read(codec, fg, 0,
 					   AC_VERB_GET_POWER_STATE, 0);
-		if (state & AC_PWRST_ERROR)
+		if (state & AC_PWRST_ERROR) {
+			msleep(20);
 			break;
+		}
+
 		actual_state = (state >> 4) & 0x0f;
 		if (actual_state == power_state)
 			break;
+
 		if (time_after_eq(jiffies, end_time))
 			break;
+
 		/* wait until the codec reachs to the target state */
 		msleep(1);
 	}
+
 	return state;
 }
 
-- 
2.16.1



More information about the Intel-gfx-trybot mailing list