From 79b783c7219cbee39081a03b549d8e8fefadbf55 Mon Sep 17 00:00:00 2001 From: Ariff Abdullah Date: Thu, 14 Jun 2007 11:11:06 +0000 Subject: [PATCH] Don't push too hard waiting/looping for codec detection interrupt. Let the interrupt do the job waking us up. --- sys/dev/sound/pci/atiixp.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sys/dev/sound/pci/atiixp.c b/sys/dev/sound/pci/atiixp.c index 1b325ef8b44d..58d99ae4d5f7 100644 --- a/sys/dev/sound/pci/atiixp.c +++ b/sys/dev/sound/pci/atiixp.c @@ -899,6 +899,7 @@ atiixp_intr(void *p) enable = atiixp_rd(sc, ATI_REG_IER); enable &= ~detected_codecs; atiixp_wr(sc, ATI_REG_IER, enable); + wakeup(sc); } /* acknowledge */ @@ -1005,18 +1006,20 @@ atiixp_chip_post_init(void *arg) polling = sc->polling; sc->polling = 0; - /* wait for the interrupts to happen */ - timeout = 100; - do { - msleep(sc, sc->lock, PWAIT, "ixpslp", 1); - if (sc->codec_not_ready_bits) - break; - } while (--timeout); + timeout = 10; + if (sc->codec_not_ready_bits == 0) { + /* wait for the interrupts to happen */ + do { + msleep(sc, sc->lock, PWAIT, "ixpslp", max(hz / 10, 1)); + if (sc->codec_not_ready_bits != 0) + break; + } while (--timeout); + } sc->polling = polling; atiixp_disable_interrupts(sc); - if (timeout == 0) { + if (sc->codec_not_ready_bits == 0 && timeout == 0) { device_printf(sc->dev, "WARNING: timeout during codec detection; " "codecs might be present but haven't interrupted\n");