From: kettenis Date: Sat, 7 Aug 2010 16:16:18 +0000 (+0000) Subject: Unmap registers upon detach. Avoid panics when detaching a partially attached X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=132d309047c4796130eeae8120ff0ce9b5006967;p=openbsd Unmap registers upon detach. Avoid panics when detaching a partially attached device. Found out the hard way by hotplugging an unsupported "Soft-Mac" device. ok deraadt@ --- diff --git a/sys/dev/ic/pgt.c b/sys/dev/ic/pgt.c index 67740f4eefb..99c0a35f4c2 100644 --- a/sys/dev/ic/pgt.c +++ b/sys/dev/ic/pgt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pgt.c,v 1.60 2010/08/07 03:50:01 krw Exp $ */ +/* $OpenBSD: pgt.c,v 1.61 2010/08/07 16:16:18 kettenis Exp $ */ /* * Copyright (c) 2006 Claudio Jeker @@ -603,6 +603,7 @@ pgt_attach(void *xsc) tsleep(&sc->sc_flags, 0, "pgtres", hz); if (sc->sc_flags & SC_UNINITIALIZED) { printf("%s: not responding\n", sc->sc_dev.dv_xname); + sc->sc_flags |= SC_NEEDS_FIRMWARE; return; } else { /* await all interrupts */ diff --git a/sys/dev/pci/if_pgt_pci.c b/sys/dev/pci/if_pgt_pci.c index f6ceaa59f3b..7fb29bdc460 100644 --- a/sys/dev/pci/if_pgt_pci.c +++ b/sys/dev/pci/if_pgt_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pgt_pci.c,v 1.11 2009/06/02 04:03:39 jsg Exp $ */ +/* $OpenBSD: if_pgt_pci.c,v 1.12 2010/08/07 16:16:18 kettenis Exp $ */ /* * Copyright (c) 2006 Marcus Glocker @@ -147,8 +147,13 @@ pgt_pci_detach(struct device *self, int flags) struct pgt_pci_softc *psc = (struct pgt_pci_softc *)self; struct pgt_softc *sc = &psc->sc_pgt; - pgt_detach(sc); - pci_intr_disestablish(psc->sc_pc, psc->sc_ih); + if (psc->sc_ih != NULL) { + pgt_detach(sc); + pci_intr_disestablish(psc->sc_pc, psc->sc_ih); + } + if (psc->sc_mapsize > 0) + bus_space_unmap(sc->sc_iotag, sc->sc_iohandle, + psc->sc_mapsize); return (0); }