summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2002-08-10 06:37:32 +0000
committerimp <imp@FreeBSD.org>2002-08-10 06:37:32 +0000
commite2c33f00df09e37c682b64837ebac6f07e9fb612 (patch)
tree2d5a2045a85000544fb186a4bbbe1d60884dadc5
parentd52ece8b2a62a5b33c9b24097f23dbce00f1e526 (diff)
downloadFreeBSD-src-e2c33f00df09e37c682b64837ebac6f07e9fb612.zip
FreeBSD-src-e2c33f00df09e37c682b64837ebac6f07e9fb612.tar.gz
When we allocate our bus address via the kludge that we have in the
code to do it when the bios doesn't do it for us, flag it. Then, when we dealloc, do an equal kludge to get rid of the address. This should address the can't get IRQ and panic bug in a more graceful way. # really should write a dealloc routine and just call it instead, since # this might not fix things in the kldunload case.
-rw-r--r--sys/dev/pccbb/pccbb.c32
-rw-r--r--sys/dev/pccbb/pccbbvar.h7
2 files changed, 23 insertions, 16 deletions
diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c
index d5d2b6f..5cb6cd8 100644
--- a/sys/dev/pccbb/pccbb.c
+++ b/sys/dev/pccbb/pccbb.c
@@ -609,15 +609,14 @@ pccbb_attach(device_t brdev)
cv_destroy(&sc->cv);
return (ENOMEM);
}
+ sc->flags |= PCCBB_KLUDGE_ALLOC;
pci_write_config(brdev, CBBR_SOCKBASE,
rman_get_start(sc->base_res), 4);
DEVPRINTF((brdev, "PCI Memory allocated: %08lx\n",
rman_get_start(sc->base_res)));
} else {
device_printf(brdev, "Could not map register memory\n");
- mtx_destroy(&sc->mtx);
- cv_destroy(&sc->cv);
- return (ENOMEM);
+ goto err;
}
}
@@ -650,22 +649,14 @@ pccbb_attach(device_t brdev)
RF_SHAREABLE | RF_ACTIVE);
if (sc->irq_res == NULL) {
printf("pccbb: Unable to map IRQ...\n");
- bus_release_resource(brdev, SYS_RES_MEMORY, CBBR_SOCKBASE,
- sc->base_res);
- mtx_destroy(&sc->mtx);
- cv_destroy(&sc->cv);
+ goto err;
return (ENOMEM);
}
if (bus_setup_intr(brdev, sc->irq_res, INTR_TYPE_AV, pccbb_intr, sc,
&sc->intrhand)) {
device_printf(brdev, "couldn't establish interrupt");
- bus_release_resource(brdev, SYS_RES_IRQ, 0, sc->irq_res);
- bus_release_resource(brdev, SYS_RES_MEMORY, CBBR_SOCKBASE,
- sc->base_res);
- mtx_destroy(&sc->mtx);
- cv_destroy(&sc->cv);
- return (ENOMEM);
+ goto err;
}
/* reset 16-bit pcmcia bus */
@@ -688,6 +679,21 @@ pccbb_attach(device_t brdev)
}
return (0);
+err:
+ if (sc->irq_res)
+ bus_release_resource(brdev, SYS_RES_IRQ, 0, sc->irq_res);
+ if (sc->base_res) {
+ if (sc->flags & PCCBB_KLUDGE_ALLOC)
+ bus_generic_release_resource(device_get_parent(brdev),
+ brdev, SYS_RES_MEMORY, CBBR_SOCKBASE,
+ sc->base_res);
+ else
+ bus_release_resource(brdev, SYS_RES_MEMORY,
+ CBBR_SOCKBASE, sc->base_res);
+ }
+ mtx_destroy(&sc->mtx);
+ cv_destroy(&sc->cv);
+ return (ENOMEM);
}
static int
diff --git a/sys/dev/pccbb/pccbbvar.h b/sys/dev/pccbb/pccbbvar.h
index a7ca49d..c8de2dd 100644
--- a/sys/dev/pccbb/pccbbvar.h
+++ b/sys/dev/pccbb/pccbbvar.h
@@ -65,9 +65,10 @@ struct pccbb_softc {
struct mtx mtx;
struct cv cv;
u_int32_t flags;
-#define PCCBB_16BIT_CARD 0x02000000
-#define PCCBB_KTHREAD_RUNNING 0x04000000
-#define PCCBB_KTHREAD_DONE 0x08000000
+#define PCCBB_KLUDGE_ALLOC 0x10000000
+#define PCCBB_16BIT_CARD 0x20000000
+#define PCCBB_KTHREAD_RUNNING 0x40000000
+#define PCCBB_KTHREAD_DONE 0x80000000
int chipset; /* chipset id */
#define CB_UNKNOWN 0 /* NOT Cardbus-PCI bridge */
#define CB_TI113X 1 /* TI PCI1130/1131 */
OpenPOWER on IntegriCloud