Skip to content

Commit

Permalink
ALSA: hda/ca0132 - Avoid endless loop
Browse files Browse the repository at this point in the history
Introduce a timeout to dspio_clear_response_queue() so that it won't
be caught in an endless loop even if the hardware doesn't respond
properly.

Fixes: a73d511 ("ALSA: hda/ca0132: Add unsol handler for DSP and jack detection")
Cc: <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Dec 14, 2019
1 parent 377bc0c commit cb04fc3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sound/pci/hda/patch_ca0132.c
Original file line number Diff line number Diff line change
Expand Up @@ -1809,13 +1809,14 @@ struct scp_msg {

static void dspio_clear_response_queue(struct hda_codec *codec)
{
unsigned long timeout = jiffies + msecs_to_jiffies(1000);
unsigned int dummy = 0;
int status = -1;
int status;

/* clear all from the response queue */
do {
status = dspio_read(codec, &dummy);
} while (status == 0);
} while (status == 0 && time_before(jiffies, timeout));
}

static int dspio_get_response_data(struct hda_codec *codec)
Expand Down

0 comments on commit cb04fc3

Please sign in to comment.