Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Sep 2010 14:24:21 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r212661 - head/sys/dev/aac
Message-ID:  <201009151424.o8FEOLZE039185@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: attilio
Date: Wed Sep 15 14:24:21 2010
New Revision: 212661
URL: http://svn.freebsd.org/changeset/base/212661

Log:
  Fix bogus busying mechanism from cdevsw callbacks:
  - D_TRACKCLOSE may be used there as d_close() are expected to match up
    d_open() calls
  - Replace the hand-crafted counter and flag with the
    device_busy()/device_unbusy() proper usage.
  
  Sponsored by:	Sandvine Incorporated
  Reported by:	Mark Johnston <mjohnston at sandvine dot com>
  Tested by:	Mark Johnston
  Reviewed by:	emaste
  
  MFC after:	10 days

Modified:
  head/sys/dev/aac/aac.c
  head/sys/dev/aac/aacvar.h

Modified: head/sys/dev/aac/aac.c
==============================================================================
--- head/sys/dev/aac/aac.c	Wed Sep 15 14:23:55 2010	(r212660)
+++ head/sys/dev/aac/aac.c	Wed Sep 15 14:24:21 2010	(r212661)
@@ -212,7 +212,7 @@ static struct aac_mntinforesp *
 
 static struct cdevsw aac_cdevsw = {
 	.d_version =	D_VERSION,
-	.d_flags =	D_NEEDGIANT,
+	.d_flags =	D_NEEDGIANT | D_TRACKCLOSE,
 	.d_open =	aac_open,
 	.d_close =	aac_close,
 	.d_ioctl =	aac_ioctl,
@@ -660,9 +660,6 @@ aac_detach(device_t dev)
 	sc = device_get_softc(dev);
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	if (sc->aac_state & AAC_STATE_OPEN)
-		return(EBUSY);
-
 	callout_drain(&sc->aac_daemontime);
 
 	/* Remove the child containers */
@@ -2804,8 +2801,7 @@ aac_open(struct cdev *dev, int flags, in
 
 	sc = dev->si_drv1;
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
-	sc->aac_open_cnt++;
-	sc->aac_state |= AAC_STATE_OPEN;
+	device_busy(sc->aac_dev);
 
 	return 0;
 }
@@ -2817,10 +2813,7 @@ aac_close(struct cdev *dev, int flags, i
 
 	sc = dev->si_drv1;
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
-	sc->aac_open_cnt--;
-	/* Mark this unit as no longer open  */
-	if (sc->aac_open_cnt == 0)
-		sc->aac_state &= ~AAC_STATE_OPEN;
+	device_unbusy(sc->aac_dev);
 
 	return 0;
 }

Modified: head/sys/dev/aac/aacvar.h
==============================================================================
--- head/sys/dev/aac/aacvar.h	Wed Sep 15 14:23:55 2010	(r212660)
+++ head/sys/dev/aac/aacvar.h	Wed Sep 15 14:24:21 2010	(r212661)
@@ -319,10 +319,9 @@ struct aac_softc
 	/* controller features, limits and status */
 	int			aac_state;
 #define AAC_STATE_SUSPEND	(1<<0)
-#define	AAC_STATE_OPEN		(1<<1)
+#define	AAC_STATE_UNUSED0	(1<<1)
 #define AAC_STATE_INTERRUPTS_ON	(1<<2)
 #define AAC_STATE_AIF_SLEEPER	(1<<3)
-	int			aac_open_cnt;
 	struct FsaRevision		aac_revision;
 
 	/* controller hardware interface */



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