diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2008-04-08 20:41:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-08 21:25:53 -0400 |
commit | 4b47c971dc947cadecc20dc7681037e96ece520e (patch) | |
tree | 14afde1ea46a6b573ad1602e2ae440cb3f09ff1e /sound/pci/es1968.c | |
parent | 41e3355de052693c7a0cad74b845148d262edadf (diff) |
es1968: fix sleep-while-holding-lock bug
snd_es1968_ac97_read() calls snd_es1968_ac97_wait() first outside a locked
area, and later, while holding a lock.
snd_es1968_ac97_wait() has a polling loop with a cond_resched() inside it..
which sleeps, so the second call is invalid.
This patch adds a version of the wait function that just pure polls. While
this is not very elegant in principle, it's very likely the easiest thing to
do here, we already checked if the chip was ready (while yielding) just
before, so it is very unlikely to take a long time here.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Jaroslav Kysela <perex@suse.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'sound/pci/es1968.c')
-rw-r--r-- | sound/pci/es1968.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 25ccfce45759..7d911a18c082 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c | |||
@@ -617,6 +617,18 @@ static int snd_es1968_ac97_wait(struct es1968 *chip) | |||
617 | return 1; /* timeout */ | 617 | return 1; /* timeout */ |
618 | } | 618 | } |
619 | 619 | ||
620 | static int snd_es1968_ac97_wait_poll(struct es1968 *chip) | ||
621 | { | ||
622 | int timeout = 100000; | ||
623 | |||
624 | while (timeout-- > 0) { | ||
625 | if (!(inb(chip->io_port + ESM_AC97_INDEX) & 1)) | ||
626 | return 0; | ||
627 | } | ||
628 | snd_printd("es1968: ac97 timeout\n"); | ||
629 | return 1; /* timeout */ | ||
630 | } | ||
631 | |||
620 | static void snd_es1968_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) | 632 | static void snd_es1968_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) |
621 | { | 633 | { |
622 | struct es1968 *chip = ac97->private_data; | 634 | struct es1968 *chip = ac97->private_data; |
@@ -645,7 +657,7 @@ static unsigned short snd_es1968_ac97_read(struct snd_ac97 *ac97, unsigned short | |||
645 | outb(reg | 0x80, chip->io_port + ESM_AC97_INDEX); | 657 | outb(reg | 0x80, chip->io_port + ESM_AC97_INDEX); |
646 | /*msleep(1);*/ | 658 | /*msleep(1);*/ |
647 | 659 | ||
648 | if (! snd_es1968_ac97_wait(chip)) { | 660 | if (!snd_es1968_ac97_wait_poll(chip)) { |
649 | data = inw(chip->io_port + ESM_AC97_DATA); | 661 | data = inw(chip->io_port + ESM_AC97_DATA); |
650 | /*msleep(1);*/ | 662 | /*msleep(1);*/ |
651 | } | 663 | } |