Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 May 2019 12:51:13 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r348159 - head/sys/dev/mrsas
Message-ID:  <201905231251.x4NCpDeT084740@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Thu May 23 12:51:13 2019
New Revision: 348159
URL: https://svnweb.freebsd.org/changeset/base/348159

Log:
  add mrsas_shutdown method
  
  It should be safer to flush controller and disk caches on the shutdown.
  And to gracefully shut down the controller as well.
  It seems that the Linux driver has been doing that for a long time.
  
  Discussed with:	scottl
  Reviewed by:	imp, Sumit Saxena <sumit.saxena@broadcom.com>
  		(both earlier version)
  MFC after:	3 weeks
  Sponsored by:	Panzura
  Differential Revision: https://reviews.freebsd.org/D19817

Modified:
  head/sys/dev/mrsas/mrsas.c

Modified: head/sys/dev/mrsas/mrsas.c
==============================================================================
--- head/sys/dev/mrsas/mrsas.c	Thu May 23 12:35:40 2019	(r348158)
+++ head/sys/dev/mrsas/mrsas.c	Thu May 23 12:51:13 2019	(r348159)
@@ -1182,6 +1182,39 @@ mrsas_detach(device_t dev)
 	return (0);
 }
 
+static int
+mrsas_shutdown(device_t dev)
+{
+	struct mrsas_softc *sc;
+	int i;
+
+	sc = device_get_softc(dev);
+	sc->remove_in_progress = 1;
+	if (panicstr == NULL) {
+		if (sc->ocr_thread_active)
+			wakeup(&sc->ocr_chan);
+		i = 0;
+		while (sc->reset_in_progress && i < 15) {
+			i++;
+			if ((i % MRSAS_RESET_NOTICE_INTERVAL) == 0) {
+				mrsas_dprint(sc, MRSAS_INFO,
+				    "[%2d]waiting for OCR to be finished "
+				    "from %s\n", i, __func__);
+			}
+			pause("mr_shutdown", hz);
+		}
+		if (sc->reset_in_progress) {
+			mrsas_dprint(sc, MRSAS_INFO,
+			    "gave up waiting for OCR to be finished\n");
+		}
+	}
+
+	mrsas_flush_cache(sc);
+	mrsas_shutdown_ctlr(sc, MR_DCMD_CTRL_SHUTDOWN);
+	mrsas_disable_intr(sc);
+	return (0);
+}
+
 /*
  * mrsas_free_mem:		Frees allocated memory
  * input:				Adapter instance soft state
@@ -5028,6 +5061,7 @@ static device_method_t mrsas_methods[] = {
 	DEVMETHOD(device_probe, mrsas_probe),
 	DEVMETHOD(device_attach, mrsas_attach),
 	DEVMETHOD(device_detach, mrsas_detach),
+	DEVMETHOD(device_shutdown, mrsas_shutdown),
 	DEVMETHOD(device_suspend, mrsas_suspend),
 	DEVMETHOD(device_resume, mrsas_resume),
 	DEVMETHOD(bus_print_child, bus_generic_print_child),



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