PERFORCE change 228253 for review

Brooks Davis brooks at FreeBSD.org
Tue Apr 30 15:51:17 UTC 2013


http://p4web.freebsd.org/@@228253?ac=10

Change 228253 by brooks at 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);


More information about the p4-projects mailing list