A couple small fixes for the imx6_sdma driver...

Attach after interrupt controllers, since the attach function tries to
set up an interrupt handler.

Check for the availability of the required firmware early in the attach
code (before allocating resources).  If the firmware is not available, set
a static var to remember that, so that if the device is re-probed on later
passes it won't repeatedly try to attach and then complain again about
missing firmware.
This commit is contained in:
Ian Lepore 2020-11-25 18:09:01 +00:00
parent bca0e1d2ac
commit 4b7ae525a8

View File

@ -75,6 +75,12 @@ static struct resource_spec sdma_spec[] = {
{ -1, 0 } { -1, 0 }
}; };
/*
* This will get set to true if we can't load firmware while attaching, to
* prevent multiple attempts to re-attach the device on each bus pass.
*/
static bool firmware_unavailable;
static void static void
sdma_intr(void *arg) sdma_intr(void *arg)
{ {
@ -117,7 +123,7 @@ static int
sdma_probe(device_t dev) sdma_probe(device_t dev)
{ {
if (!ofw_bus_status_okay(dev)) if (!ofw_bus_status_okay(dev) || firmware_unavailable)
return (ENXIO); return (ENXIO);
if (!ofw_bus_is_compatible(dev, "fsl,imx6q-sdma")) if (!ofw_bus_is_compatible(dev, "fsl,imx6q-sdma"))
@ -468,6 +474,11 @@ sdma_attach(device_t dev)
sc = device_get_softc(dev); sc = device_get_softc(dev);
sc->dev = dev; sc->dev = dev;
if (load_firmware(sc) == -1) {
firmware_unavailable = true;
return (ENXIO);
}
if (bus_alloc_resources(dev, sdma_spec, sc->res)) { if (bus_alloc_resources(dev, sdma_spec, sc->res)) {
device_printf(dev, "could not allocate resources\n"); device_printf(dev, "could not allocate resources\n");
return (ENXIO); return (ENXIO);
@ -487,9 +498,6 @@ sdma_attach(device_t dev)
return (ENXIO); return (ENXIO);
} }
if (load_firmware(sc) == -1)
return (ENXIO);
if (boot_firmware(sc) == -1) if (boot_firmware(sc) == -1)
return (ENXIO); return (ENXIO);
@ -511,5 +519,6 @@ static driver_t sdma_driver = {
static devclass_t sdma_devclass; static devclass_t sdma_devclass;
/* We want to attach after all interrupt controllers, before anything else. */
EARLY_DRIVER_MODULE(sdma, simplebus, sdma_driver, sdma_devclass, 0, 0, EARLY_DRIVER_MODULE(sdma, simplebus, sdma_driver, sdma_devclass, 0, 0,
BUS_PASS_RESOURCE); BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST);