summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2011-04-04 18:05:32 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2011-04-04 18:05:32 +0000
commitd606b9cf0a1caee3b293f77b5fb38dee5032eaf3 (patch)
treec604c16d6d3a8b6bc1c66c1d616b0719a2d2303c /sys
parent6a30f7d0b34875b3f04cbe05136e7cb5dcc5a1cd (diff)
detach happens after the hardware is gone, so don't try to touch
the hardware in the detach path
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/azalia.c94
1 files changed, 13 insertions, 81 deletions
diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c
index 1759de4acc5..ae092d17eec 100644
--- a/sys/dev/pci/azalia.c
+++ b/sys/dev/pci/azalia.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: azalia.c,v 1.191 2011/03/04 22:04:21 jakemsr Exp $ */
+/* $OpenBSD: azalia.c,v 1.192 2011/04/04 18:05:31 jakemsr Exp $ */
/* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */
/*-
@@ -209,10 +209,8 @@ int azalia_init_streams(azalia_t *);
void azalia_shutdown(void *);
int azalia_halt_corb(azalia_t *);
int azalia_init_corb(azalia_t *, int);
-int azalia_delete_corb(azalia_t *);
int azalia_halt_rirb(azalia_t *);
int azalia_init_rirb(azalia_t *, int);
-int azalia_delete_rirb(azalia_t *);
int azalia_set_command(azalia_t *, nid_t, int, uint32_t, uint32_t);
int azalia_get_response(azalia_t *, uint32_t *);
void azalia_rirb_kick_unsol_events(void *);
@@ -250,7 +248,6 @@ void azalia_widget_print_audio(const widget_t *, const char *);
void azalia_widget_print_pin(const widget_t *);
int azalia_stream_init(stream_t *, azalia_t *, int, int, int);
-int azalia_stream_delete(stream_t *, azalia_t *);
int azalia_stream_reset(stream_t *);
int azalia_stream_start(stream_t *);
int azalia_stream_halt(stream_t *);
@@ -570,7 +567,6 @@ int
azalia_pci_detach(struct device *self, int flags)
{
azalia_t *az;
- uint32_t gctl;
int i;
DPRINTF(("%s\n", __func__));
@@ -580,15 +576,13 @@ azalia_pci_detach(struct device *self, int flags)
az->audiodev = NULL;
}
- /* disable unsolicited response */
- gctl = AZ_READ_4(az, GCTL);
- AZ_WRITE_4(az, GCTL, gctl & ~(HDA_GCTL_UNSOL));
-
timeout_del(&az->unsol_to);
DPRINTF(("%s: delete streams\n", __func__));
- azalia_stream_delete(&az->rstream, az);
- azalia_stream_delete(&az->pstream, az);
+ if (az->rstream.bdlist.addr != NULL)
+ azalia_free_dmamem(az, &az->rstream.bdlist);
+ if (az->pstream.bdlist.addr != NULL)
+ azalia_free_dmamem(az, &az->pstream.bdlist);
DPRINTF(("%s: delete codecs\n", __func__));
for (i = 0; i < az->ncodecs; i++) {
@@ -601,16 +595,14 @@ azalia_pci_detach(struct device *self, int flags)
}
DPRINTF(("%s: delete CORB and RIRB\n", __func__));
- azalia_delete_corb(az);
- azalia_delete_rirb(az);
-
- DPRINTF(("%s: disable interrupts\n", __func__));
- AZ_WRITE_4(az, INTCTL, 0);
-
- DPRINTF(("%s: clear interrupts\n", __func__));
- AZ_WRITE_4(az, INTSTS, HDA_INTSTS_CIS | HDA_INTSTS_GIS);
- AZ_WRITE_2(az, STATESTS, HDA_STATESTS_SDIWAKE);
- AZ_WRITE_1(az, RIRBSTS, HDA_RIRBSTS_RINTFL | HDA_RIRBSTS_RIRBOIS);
+ if (az->corb_dma.addr != NULL)
+ azalia_free_dmamem(az, &az->corb_dma);
+ if (az->rirb_dma.addr != NULL)
+ azalia_free_dmamem(az, &az->rirb_dma);
+ if (az->unsolq != NULL) {
+ free(az->unsolq, M_DEVBUF);
+ az->unsolq = NULL;
+ }
DPRINTF(("%s: delete PCI resources\n", __func__));
if (az->ih != NULL) {
@@ -1011,27 +1003,6 @@ azalia_init_corb(azalia_t *az, int resuming)
}
int
-azalia_delete_corb(azalia_t *az)
-{
- int i;
- uint8_t corbctl;
-
- if (az->corb_dma.addr == NULL)
- return 0;
- /* stop the CORB */
- corbctl = AZ_READ_1(az, CORBCTL);
- AZ_WRITE_1(az, CORBCTL, corbctl & ~HDA_CORBCTL_CORBRUN);
- for (i = 5000; i >= 0; i--) {
- DELAY(10);
- corbctl = AZ_READ_1(az, CORBCTL);
- if ((corbctl & HDA_CORBCTL_CORBRUN) == 0)
- break;
- }
- azalia_free_dmamem(az, &az->corb_dma);
- return 0;
-}
-
-int
azalia_halt_rirb(azalia_t *az)
{
int i;
@@ -1113,31 +1084,6 @@ azalia_init_rirb(azalia_t *az, int resuming)
}
int
-azalia_delete_rirb(azalia_t *az)
-{
- int i;
- uint8_t rirbctl;
-
- if (az->unsolq != NULL) {
- free(az->unsolq, M_DEVBUF);
- az->unsolq = NULL;
- }
- if (az->rirb_dma.addr == NULL)
- return 0;
- /* stop the RIRB */
- rirbctl = AZ_READ_1(az, RIRBCTL);
- AZ_WRITE_1(az, RIRBCTL, rirbctl & ~HDA_RIRBCTL_RIRBDMAEN);
- for (i = 5000; i >= 0; i--) {
- DELAY(10);
- rirbctl = AZ_READ_1(az, RIRBCTL);
- if ((rirbctl & HDA_RIRBCTL_RIRBDMAEN) == 0)
- break;
- }
- azalia_free_dmamem(az, &az->rirb_dma);
- return 0;
-}
-
-int
azalia_comresp(const codec_t *codec, nid_t nid, uint32_t control,
uint32_t param, uint32_t* result)
{
@@ -3656,20 +3602,6 @@ azalia_stream_init(stream_t *this, azalia_t *az, int regindex, int strnum,
}
int
-azalia_stream_delete(stream_t *this, azalia_t *az)
-{
- if (this->bdlist.addr == NULL)
- return 0;
-
- /* disable stream interrupts */
- STR_WRITE_1(this, CTL, STR_READ_1(this, CTL) |
- ~(HDA_SD_CTL_DEIE | HDA_SD_CTL_FEIE | HDA_SD_CTL_IOCE));
-
- azalia_free_dmamem(az, &this->bdlist);
- return 0;
-}
-
-int
azalia_stream_reset(stream_t *this)
{
int i;