- Allocate the interrupt resource as RF_SHAREABLE allowing uart(4) to work

with shared IRQs in case the bus code, MD interrupt code, etc. permits.
  Together with sys/sparc64/sparc64/intr_machdep.c rev. 1.21 this fixes
  an endless loop in uart_intr() when using the second NS16550 on the ISA
  bus of sparc64 machines.
- Destroy the hardware mutex on detach and in case attaching fails.

Approved by:	marcel
This commit is contained in:
Marius Strobl 2005-03-02 11:30:14 +00:00
parent 559bf8bc95
commit 2682e7b661

View File

@ -321,14 +321,16 @@ uart_bus_attach(device_t dev)
*/
sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype, &sc->sc_rrid,
0, ~0, sc->sc_class->uc_range, RF_ACTIVE);
if (sc->sc_rres == NULL)
if (sc->sc_rres == NULL) {
mtx_destroy(&sc->sc_hwmtx);
return (ENXIO);
}
sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
sc->sc_irid = 0;
sc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sc_irid,
RF_ACTIVE);
RF_ACTIVE | RF_SHAREABLE);
if (sc->sc_ires != NULL) {
error = BUS_SETUP_INTR(device_get_parent(dev), dev,
sc->sc_ires, INTR_TYPE_TTY | INTR_FAST, uart_intr,
@ -438,6 +440,8 @@ uart_bus_attach(device_t dev)
}
bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres);
mtx_destroy(&sc->sc_hwmtx);
return (error);
}
@ -467,6 +471,8 @@ uart_bus_detach(device_t dev)
}
bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres);
mtx_destroy(&sc->sc_hwmtx);
if (sc->sc_class->size > sizeof(*sc)) {
device_set_softc(dev, NULL);
free(sc, M_UART);