Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Apr 2019 20:50:55 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r346498 - stable/12/sys/arm/freescale/imx
Message-ID:  <201904212050.x3LKotwf074370@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sun Apr 21 20:50:55 2019
New Revision: 346498
URL: https://svnweb.freebsd.org/changeset/base/346498

Log:
  MFC r345000:
  
  Mark the imx_spi device busy while transfers are in progress, so that the
  module can't be unloaded while interrupts are pending.

Modified:
  stable/12/sys/arm/freescale/imx/imx_spi.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/arm/freescale/imx/imx_spi.c
==============================================================================
--- stable/12/sys/arm/freescale/imx/imx_spi.c	Sun Apr 21 20:46:49 2019	(r346497)
+++ stable/12/sys/arm/freescale/imx/imx_spi.c	Sun Apr 21 20:50:55 2019	(r346498)
@@ -424,6 +424,7 @@ spi_transfer(device_t dev, device_t child, struct spi_
 	}
 
 	mtx_lock(&sc->mtx);
+	device_busy(sc->dev);
 
 	if (sc->debug >= 1) {
 		device_printf(sc->dev,
@@ -448,6 +449,7 @@ spi_transfer(device_t dev, device_t child, struct spi_
 	spi_set_chipsel(sc, cs, false);
 	WR4(sc, ECSPI_CTLREG, 0);
 
+	device_unbusy(sc->dev);
 	mtx_unlock(&sc->mtx);
 
 	return (err);
@@ -468,11 +470,11 @@ static int
 spi_detach(device_t dev)
 {
 	struct spi_softc *sc = device_get_softc(dev);
-	int idx;
+	int error, idx;
 
-	mtx_lock(&sc->mtx);
+	if ((error = bus_generic_detach(sc->dev)) != 0)
+		return (error);
 
-	bus_generic_detach(sc->dev);
 	if (sc->spibus != NULL)
 		device_delete_child(dev, sc->spibus);
 
@@ -488,7 +490,6 @@ spi_detach(device_t dev)
 	if (sc->memres != NULL)
 		bus_release_resource(sc->dev, SYS_RES_MEMORY, 0, sc->memres);
 
-	mtx_unlock(&sc->mtx);
 	mtx_destroy(&sc->mtx);
 
 	return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904212050.x3LKotwf074370>