Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Mar 2018 15:56:10 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r331123 - head/sys/dev/flash
Message-ID:  <201803181556.w2IFuA9d046016@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Sun Mar 18 15:56:10 2018
New Revision: 331123
URL: https://svnweb.freebsd.org/changeset/base/331123

Log:
  Do not overwrite the contents of BIO_WRITE buffers.  SPI inherently
  transfers data in both directions at once.  When writing to the device,
  use a dummy buffer for the incoming data, not the same buffer as the
  outgoing data.  Writes are done in FLASH_PAGE_SIZE chunks, which is only
  256 bytes, so just put the dummy buffer into the softc.

Modified:
  head/sys/dev/flash/mx25l.c

Modified: head/sys/dev/flash/mx25l.c
==============================================================================
--- head/sys/dev/flash/mx25l.c	Sun Mar 18 15:44:07 2018	(r331122)
+++ head/sys/dev/flash/mx25l.c	Sun Mar 18 15:56:10 2018	(r331123)
@@ -90,6 +90,7 @@ struct mx25l_softc 
 	struct bio_queue_head sc_bio_queue;
 	unsigned int	sc_flags;
 	unsigned int	sc_taskstate;
+	uint8_t		sc_dummybuf[FLASH_PAGE_SIZE];
 };
 
 #define	TSTATE_STOPPED	0
@@ -344,7 +345,7 @@ mx25l_write(device_t dev, off_t offset, caddr_t data, 
 		cmd.rx_cmd = rxBuf;
 		cmd.tx_data = data + bytes_writen;
 		cmd.tx_data_sz = bytes_to_write;
-		cmd.rx_data = data + bytes_writen;
+		cmd.rx_data = sc->sc_dummybuf;
 		cmd.rx_data_sz = bytes_to_write;
 
 		/*



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