From owner-svn-src-all@freebsd.org Wed Nov 25 18:09:02 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 69261470A24; Wed, 25 Nov 2020 18:09:02 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ch8661g9Yz3pXW; Wed, 25 Nov 2020 18:09:02 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2770F152E5; Wed, 25 Nov 2020 18:09:02 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0API91pv034547; Wed, 25 Nov 2020 18:09:01 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0API91Aq034546; Wed, 25 Nov 2020 18:09:01 GMT (envelope-from ian@FreeBSD.org) Message-Id: <202011251809.0API91Aq034546@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Wed, 25 Nov 2020 18:09:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368026 - head/sys/arm/freescale/imx X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/arm/freescale/imx X-SVN-Commit-Revision: 368026 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2020 18:09:02 -0000 Author: ian Date: Wed Nov 25 18:09:01 2020 New Revision: 368026 URL: https://svnweb.freebsd.org/changeset/base/368026 Log: 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. Modified: head/sys/arm/freescale/imx/imx6_sdma.c Modified: head/sys/arm/freescale/imx/imx6_sdma.c ============================================================================== --- head/sys/arm/freescale/imx/imx6_sdma.c Wed Nov 25 17:15:24 2020 (r368025) +++ head/sys/arm/freescale/imx/imx6_sdma.c Wed Nov 25 18:09:01 2020 (r368026) @@ -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);