Author: jhibbits
Date: Fri Apr 19 02:28:04 2019
New Revision: 346363
URL: https://svnweb.freebsd.org/changeset/base/346363

Log:
  powerpc/powernv: Make erasing before writes optional
  
  If the OPAL flash driver supports writing without erase, it adds a
  'no-erase' property to the flash device node.  Honor that property and don't
  bother erasing if it exists.

Modified:
  head/sys/powerpc/powernv/opal_flash.c

Modified: head/sys/powerpc/powernv/opal_flash.c
==============================================================================
--- head/sys/powerpc/powernv/opal_flash.c       Fri Apr 19 00:32:13 2019        
(r346362)
+++ head/sys/powerpc/powernv/opal_flash.c       Fri Apr 19 02:28:04 2019        
(r346363)
@@ -69,6 +69,7 @@ struct opalflash_softc {
        struct proc             *sc_p;
        struct bio_queue_head    sc_bio_queue;
        int                      sc_opal_id;
+       bool                     sc_erase; /* Erase is needed before write. */
 };
 
 #define        OPALFLASH_LOCK(sc)              mtx_lock(&(sc)->sc_mtx)
@@ -242,10 +243,12 @@ opalflash_write(struct opalflash_softc *sc, off_t off,
            count % sc->sc_disk->d_stripesize != 0)
                return (EIO);
 
-       /* Erase the full block first, then write in page chunks. */
-       rv = opalflash_erase(sc, off, count);
-       if (rv != 0)
-               return (rv);
+       if (sc->sc_erase) {
+           /* Erase the full block first, then write in page chunks. */
+           rv = opalflash_erase(sc, off, count);
+           if (rv != 0)
+                   return (rv);
+       }
 
        token = opal_alloc_async_token();
 
@@ -354,6 +357,9 @@ opalflash_attach(device_t dev)
                device_printf(dev, "Cannot determine flash block size.\n");
                return (ENXIO);
        }
+
+       if (!OF_hasprop(node, "no-erase"))
+               sc->sc_erase = true;
 
        OPALFLASH_LOCK_INIT(sc);
 


_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to