From 9ac611b2a61e730cf8af9f79266895224f02ad8c Mon Sep 17 00:00:00 2001 From: Jacob Meuser Date: Tue, 20 Apr 2010 02:17:25 +0000 Subject: - an unsolicited response contains the codec address, not the codec index - we only care about unsolicited responses from the codec we're using - no need to enable unsolicited responses until we know which codec we're using fixes crash reported by jacekm@ --- sys/dev/pci/azalia.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'sys/dev/pci') diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index 29e4e8a17e0..78ead0e85f8 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.171 2010/04/04 20:07:45 kettenis Exp $ */ +/* $OpenBSD: azalia.c,v 1.172 2010/04/20 02:17:24 jakemsr Exp $ */ /* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */ /*- @@ -801,7 +801,6 @@ int azalia_init(azalia_t *az, int resuming) { int err; - uint32_t gctl; err = azalia_reset(az); if (err) @@ -833,10 +832,6 @@ azalia_init(azalia_t *az, int resuming) AZ_WRITE_4(az, INTCTL, AZ_READ_4(az, INTCTL) | HDA_INTCTL_CIE | HDA_INTCTL_GIE); - /* enable unsolicited response */ - gctl = AZ_READ_4(az, GCTL); - AZ_WRITE_4(az, GCTL, gctl | HDA_GCTL_UNSOL); - return(0); } @@ -904,6 +899,9 @@ azalia_init_codecs(azalia_t *az) } } + /* Enable unsolicited responses now that az->codecno is set. */ + AZ_WRITE_4(az, GCTL, AZ_READ_4(az, GCTL) | HDA_GCTL_UNSOL); + return(0); } @@ -1221,21 +1219,22 @@ void azalia_rirb_kick_unsol_events(void *v) { azalia_t *az = v; + int addr, tag; if (az->unsolq_kick) return; az->unsolq_kick = TRUE; while (az->unsolq_rp != az->unsolq_wp) { - int i; - int tag; - codec_t *codec; - i = RIRB_RESP_CODEC(az->unsolq[az->unsolq_rp].resp_ex); + addr = RIRB_RESP_CODEC(az->unsolq[az->unsolq_rp].resp_ex); tag = RIRB_UNSOL_TAG(az->unsolq[az->unsolq_rp].resp); - codec = &az->codecs[i]; - DPRINTF(("%s: codec#=%d tag=%d\n", __func__, i, tag)); + DPRINTF(("%s: codec address=%d tag=%d\n", __func__, addr, tag)); + az->unsolq_rp++; az->unsolq_rp %= UNSOLQ_SIZE; - azalia_unsol_event(codec, tag); + + /* We only care about events on the using codec. */ + if (az->codecs[az->codecno].address == addr) + azalia_unsol_event(&az->codecs[az->codecno], tag); } az->unsolq_kick = FALSE; } -- cgit v1.2.3