summaryrefslogtreecommitdiff
path: root/sys/dev/pci/arc.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2007-10-30 12:32:47 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2007-10-30 12:32:47 +0000
commitfdc9f4819fcc92272d5c5d75a26f9bb51a6617ff (patch)
tree754915f225832776f1a3c442018b8c77eaf3f518 /sys/dev/pci/arc.c
parent05355484b51c09a4ab6148f5bce0973a7d232424 (diff)
if we cant query the firmware or allocate ccbs then clean up the pci
mappings. without this a problem board can cause a panic when the interrupt handler touches unallocated memory.
Diffstat (limited to 'sys/dev/pci/arc.c')
-rw-r--r--sys/dev/pci/arc.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/sys/dev/pci/arc.c b/sys/dev/pci/arc.c
index 5a18e3d970a..8fa438b9440 100644
--- a/sys/dev/pci/arc.c
+++ b/sys/dev/pci/arc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */
+/* $OpenBSD: arc.c,v 1.69 2007/10/30 12:32:46 dlg Exp $ */
/*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
@@ -469,6 +469,7 @@ void arc_scsi_cmd_done(struct arc_softc *, struct arc_ccb *,
/* real stuff for dealing with the hardware */
int arc_map_pci_resources(struct arc_softc *,
struct pci_attach_args *);
+void arc_unmap_pci_resources(struct arc_softc *);
int arc_query_firmware(struct arc_softc *);
@@ -525,12 +526,12 @@ arc_attach(struct device *parent, struct device *self, void *aux)
if (arc_query_firmware(sc) != 0) {
/* error message printed by arc_query_firmware */
- return;
+ goto unmap_pci;
}
if (arc_alloc_ccbs(sc) != 0) {
/* error message printed by arc_alloc_ccbs */
- return;
+ goto unmap_pci;
}
sc->sc_shutdownhook = shutdownhook_establish(arc_shutdown, sc);
@@ -571,6 +572,8 @@ arc_attach(struct device *parent, struct device *self, void *aux)
#endif
return;
+unmap_pci:
+ arc_unmap_pci_resources(sc);
}
int
@@ -906,6 +909,14 @@ unmap:
return (1);
}
+void
+arc_unmap_pci_resources(struct arc_softc *sc)
+{
+ pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
+ bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios);
+ sc->sc_ios = 0;
+}
+
int
arc_query_firmware(struct arc_softc *sc)
{