mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-19 14:54:24 +00:00
- 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:
parent
559bf8bc95
commit
2682e7b661
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=143025
|
@ -321,14 +321,16 @@ uart_bus_attach(device_t dev)
|
||||||
*/
|
*/
|
||||||
sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype, &sc->sc_rrid,
|
sc->sc_rres = bus_alloc_resource(dev, sc->sc_rtype, &sc->sc_rrid,
|
||||||
0, ~0, sc->sc_class->uc_range, RF_ACTIVE);
|
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);
|
return (ENXIO);
|
||||||
|
}
|
||||||
sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
|
sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
|
||||||
sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
|
sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
|
||||||
|
|
||||||
sc->sc_irid = 0;
|
sc->sc_irid = 0;
|
||||||
sc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sc_irid,
|
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) {
|
if (sc->sc_ires != NULL) {
|
||||||
error = BUS_SETUP_INTR(device_get_parent(dev), dev,
|
error = BUS_SETUP_INTR(device_get_parent(dev), dev,
|
||||||
sc->sc_ires, INTR_TYPE_TTY | INTR_FAST, uart_intr,
|
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);
|
bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres);
|
||||||
|
|
||||||
|
mtx_destroy(&sc->sc_hwmtx);
|
||||||
|
|
||||||
return (error);
|
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);
|
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)) {
|
if (sc->sc_class->size > sizeof(*sc)) {
|
||||||
device_set_softc(dev, NULL);
|
device_set_softc(dev, NULL);
|
||||||
free(sc, M_UART);
|
free(sc, M_UART);
|
||||||
|
|
Loading…
Reference in a new issue