From 183498934bdc4eedcb346ef8fdb32415e2f30d27 Mon Sep 17 00:00:00 2001 From: Hidetoshi Shimokawa Date: Mon, 4 Aug 2003 05:43:02 +0000 Subject: [PATCH] - Don't mess with TX queue in fwohci_stop() if we failed to attach the device. Tested by: wilko - Detect memory mapping failure of registers by checking OHCI version. Tested by: KONDOU, Kazuhiro --- sys/dev/firewire/fwohci.c | 8 +++++++- sys/dev/firewire/fwohci_pci.c | 13 +++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c index f3ca25679a1c..b007f7646a77 100644 --- a/sys/dev/firewire/fwohci.c +++ b/sys/dev/firewire/fwohci.c @@ -584,6 +584,11 @@ fwohci_init(struct fwohci_softc *sc, device_t dev) device_printf(dev, "OHCI version %x.%x (ROM=%d)\n", (reg>>16) & 0xff, reg & 0xff, (reg>>24) & 1); + if (((reg>>16) & 0xff) < 1) { + device_printf(dev, "invalid OHCI version\n"); + return (ENXIO); + } + /* Available Isochrounous DMA channel probe */ OWRITE(sc, OHCI_IT_MASK, 0xffffffff); OWRITE(sc, OHCI_IR_MASK, 0xffffffff); @@ -1690,7 +1695,8 @@ fwohci_stop(struct fwohci_softc *sc, device_t dev) | OHCI_INT_DMA_ARRQ | OHCI_INT_DMA_ARRS | OHCI_INT_PHY_BUS_R); - fw_drain_txq(&sc->fc); + if (sc->fc.arq !=0 && sc->fc.arq->maxq > 0) + fw_drain_txq(&sc->fc); /* XXX Link down? Bus reset? */ return 0; diff --git a/sys/dev/firewire/fwohci_pci.c b/sys/dev/firewire/fwohci_pci.c index 0ac6b0040374..513343ae97ee 100644 --- a/sys/dev/firewire/fwohci_pci.c +++ b/sys/dev/firewire/fwohci_pci.c @@ -346,8 +346,14 @@ fwohci_pci_detach(device_t self) s = splfw(); - fwohci_stop(sc, self); + if (sc->bsr) + fwohci_stop(sc, self); + bus_generic_detach(self); + if (sc->fc.bdev) { + device_delete_child(self, sc->fc.bdev); + sc->fc.bdev = NULL; + } /* disable interrupts that might have been switched on */ if (sc->bst && sc->bsh) @@ -366,11 +372,6 @@ fwohci_pci_detach(device_t self) sc->ih = NULL; } - if (sc->fc.bdev) { - device_delete_child(self, sc->fc.bdev); - sc->fc.bdev = NULL; - } - if (sc->irq_res) { bus_release_resource(self, SYS_RES_IRQ, 0, sc->irq_res); sc->irq_res = NULL;