Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Apr 2013 15:51:16 GMT
From:      Brooks Davis <brooks@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 228253 for review
Message-ID:  <201304301551.r3UFpGhg079021@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@228253?ac=10

Change 228253 by brooks@brooks_zenith on 2013/04/30 15:50:28

	Reduce the risk of spurious timeouts one busy systems by
	disabling interrupts when issuing write and erase commands.
	This has little or no performance impact with modern Intel flash
	that supports large block writes.

Affected files ...

.. //depot/projects/ctsrd/beribsd/src/sys/dev/cfi/cfi_core.c#12 edit

Differences ...

==== //depot/projects/ctsrd/beribsd/src/sys/dev/cfi/cfi_core.c#12 (text+ko) ====

@@ -460,6 +460,7 @@
 		uint16_t	*x16;
 		uint32_t	*x32;
 	} ptr, cpyprt;
+	register_t intr;
 	int error, i, neederase = 0;
 	uint32_t st;
 	u_int wlen;
@@ -482,6 +483,7 @@
 		}
 
 	if (neederase) {
+		intr = intr_disable();
 		binuptime(&start);
 		/* Erase the block. */
 		switch (sc->sc_cmdset) {
@@ -498,8 +500,10 @@
 			break;
 		default:
 			/* Better safe than sorry... */
+			intr_restore(intr);
 			return (ENODEV);
 		}
+		intr_restore(intr);
 		error = cfi_wait_ready(sc, sc->sc_wrofs, &start, 
 		    CFI_TIMEOUT_ERASE);
 		if (error)
@@ -517,6 +521,8 @@
 			for (i = 0; i < sc->sc_wrbufsz; i += wlen) {
 				wlen = MIN(sc->sc_maxbuf, sc->sc_wrbufsz - i);
 
+				intr = intr_disable();
+
 				binuptime(&start);
 				do {
 					cfi_write(sc, sc->sc_wrofs + i,
@@ -548,6 +554,8 @@
 				cfi_write(sc, sc->sc_wrofs + i,
 				    CFI_BCS_CONFIRM);
 
+				intr_restore(intr);
+
 				error = cfi_wait_ready(sc, sc->sc_wrofs + i,
 				    &start, CFI_TIMEOUT_BUFWRITE);
 			}
@@ -580,6 +588,13 @@
 			}
 		}
 
+		/*
+		 * Make sure the command to start a write and the
+		 * actual write happens back-to-back without any
+		 * excessive delays.
+		 */
+		intr = intr_disable();
+
 		binuptime(&start);
 		switch (sc->sc_cmdset) {
 		case CFI_VEND_INTEL_ECS:
@@ -605,6 +620,8 @@
 			    sc->sc_wrofs + i, *(ptr.x32 + i / 4));
 			break;
 		}
+		
+		intr_restore(intr);
 
 		error = cfi_wait_ready(sc, sc->sc_wrofs, &start,
 		   CFI_TIMEOUT_WRITE);



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