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;
 
                /*
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to