From 4b7ae525a8e9a428ddba663d9d589e9a6abed45a Mon Sep 17 00:00:00 2001 From: Ian Lepore Date: Wed, 25 Nov 2020 18:09:01 +0000 Subject: [PATCH] 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. --- sys/arm/freescale/imx/imx6_sdma.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sys/arm/freescale/imx/imx6_sdma.c b/sys/arm/freescale/imx/imx6_sdma.c index 3bae225a75d5..ca817208ae73 100644 --- a/sys/arm/freescale/imx/imx6_sdma.c +++ b/sys/arm/freescale/imx/imx6_sdma.c @@ -75,6 +75,12 @@ static struct resource_spec sdma_spec[] = { { -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 sdma_intr(void *arg) { @@ -117,7 +123,7 @@ static int sdma_probe(device_t dev) { - if (!ofw_bus_status_okay(dev)) + if (!ofw_bus_status_okay(dev) || firmware_unavailable) return (ENXIO); if (!ofw_bus_is_compatible(dev, "fsl,imx6q-sdma")) @@ -468,6 +474,11 @@ sdma_attach(device_t dev) sc = device_get_softc(dev); sc->dev = dev; + if (load_firmware(sc) == -1) { + firmware_unavailable = true; + return (ENXIO); + } + if (bus_alloc_resources(dev, sdma_spec, sc->res)) { device_printf(dev, "could not allocate resources\n"); return (ENXIO); @@ -487,9 +498,6 @@ sdma_attach(device_t dev) return (ENXIO); } - if (load_firmware(sc) == -1) - return (ENXIO); - if (boot_firmware(sc) == -1) return (ENXIO); @@ -511,5 +519,6 @@ static driver_t sdma_driver = { 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, - BUS_PASS_RESOURCE); + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LAST);