Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/jdolecek-ncq]: src/sys/dev/ata add ATA FUA support



details:   https://anonhg.NetBSD.org/src/rev/a00b314e0c17
branches:  jdolecek-ncq
changeset: 822884:a00b314e0c17
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Wed Apr 19 21:42:39 2017 +0000

description:
add ATA FUA support

diffstat:

 sys/dev/ata/ata.c    |  15 +++++++++++----
 sys/dev/ata/atareg.h |   4 +++-
 sys/dev/ata/atavar.h |   3 ++-
 sys/dev/ata/wd.c     |  17 ++++++++++++++---
 4 files changed, 30 insertions(+), 9 deletions(-)

diffs (136 lines):

diff -r fed0d689d755 -r a00b314e0c17 sys/dev/ata/ata.c
--- a/sys/dev/ata/ata.c Wed Apr 19 21:02:43 2017 +0000
+++ b/sys/dev/ata/ata.c Wed Apr 19 21:42:39 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ata.c,v 1.132.8.5 2017/04/19 20:49:17 jdolecek Exp $   */
+/*     $NetBSD: ata.c,v 1.132.8.6 2017/04/19 21:42:39 jdolecek Exp $   */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.5 2017/04/19 20:49:17 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.6 2017/04/19 21:42:39 jdolecek Exp $");
 
 #include "opt_ata.h"
 
@@ -1980,8 +1980,14 @@
 atacmd_toncq(struct ata_xfer *xfer, uint8_t *cmd, uint16_t *count,
     uint16_t *features, uint8_t *device)
 {
-       if ((xfer->c_flags & C_NCQ) == 0)
+       if ((xfer->c_flags & C_NCQ) == 0) {
+               /* FUA handling for non-NCQ drives */
+               if (xfer->c_bio.flags & ATA_FUA
+                   && *cmd == WDCC_WRITEDMA_EXT)
+                       *cmd = WDCC_WRITEDMA_FUA_EXT;
+
                return;
+       }
 
        *cmd = (xfer->c_bio.flags & ATA_READ) ?
            WDCC_READ_FPDMA_QUEUED : WDCC_WRITE_FPDMA_QUEUED;
@@ -1993,5 +1999,6 @@
        *count = (xfer->c_slot << 3);
 
        /* other device flags */
-       /* XXX FUA handling */
+       if (xfer->c_bio.flags & ATA_FUA)
+               *device |= WDSD_FUA;
 }
diff -r fed0d689d755 -r a00b314e0c17 sys/dev/ata/atareg.h
--- a/sys/dev/ata/atareg.h      Wed Apr 19 21:02:43 2017 +0000
+++ b/sys/dev/ata/atareg.h      Wed Apr 19 21:42:39 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atareg.h,v 1.43 2013/10/30 15:37:49 drochner Exp $     */
+/*     $NetBSD: atareg.h,v 1.43.18.1 2017/04/19 21:42:39 jdolecek Exp $        */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -144,6 +144,7 @@
 
 #define        WDCC_READDMA_EXT        0x25    /* read 48-bit addressing with DMA */
 #define        WDCC_WRITEDMA_EXT       0x35    /* write 48-bit addressing with DMA */
+#define        WDCC_WRITEDMA_FUA_EXT   0x3d    /* write 48-bit addr with DMA & FUA */
 
 #if defined(_KERNEL) || defined(_STANDALONE)
 #include <dev/ata/ataconf.h>
@@ -248,6 +249,7 @@
 #define        WDSD_IBM                0xa0    /* forced to 512 byte sector, ecc */
 #define        WDSD_CHS                0x00    /* cylinder/head/sector addressing */
 #define        WDSD_LBA                0x40    /* logical block addressing */
+#define        WDSD_FUA                0x80    /* Forced Unit Access (FUA) */
 
 /* Commands for ATAPI devices */
 #define        ATAPI_CHECK_POWER_MODE  0xe5
diff -r fed0d689d755 -r a00b314e0c17 sys/dev/ata/atavar.h
--- a/sys/dev/ata/atavar.h      Wed Apr 19 21:02:43 2017 +0000
+++ b/sys/dev/ata/atavar.h      Wed Apr 19 21:42:39 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atavar.h,v 1.92.8.5 2017/04/19 20:49:17 jdolecek Exp $ */
+/*     $NetBSD: atavar.h,v 1.92.8.6 2017/04/19 21:42:39 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -49,6 +49,7 @@
 #define        ATA_READ        0x0020  /* transfer is a read (otherwise a write) */
 #define        ATA_CORR        0x0040  /* transfer had a corrected error */
 #define        ATA_LBA48       0x0080  /* transfer uses 48-bit LBA addressing */
+#define        ATA_FUA         0x0100  /* transfer uses FUA */
        daddr_t         blkno;  /* block addr */
        daddr_t         blkdone;/* number of blks transferred */
        daddr_t         nblks;  /* number of block currently transferring */
diff -r fed0d689d755 -r a00b314e0c17 sys/dev/ata/wd.c
--- a/sys/dev/ata/wd.c  Wed Apr 19 21:02:43 2017 +0000
+++ b/sys/dev/ata/wd.c  Wed Apr 19 21:42:39 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wd.c,v 1.428.2.8 2017/04/19 21:02:43 jdolecek Exp $ */
+/*     $NetBSD: wd.c,v 1.428.2.9 2017/04/19 21:42:39 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.8 2017/04/19 21:02:43 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.9 2017/04/19 21:42:39 jdolecek Exp $");
 
 #include "opt_ata.h"
 
@@ -809,6 +809,14 @@
                xfer->c_bio.flags |= ATA_LBA;
        if (bp->b_flags & B_READ)
                xfer->c_bio.flags |= ATA_READ;
+       if (bp->b_flags & B_MEDIA_FUA) {
+               /* If not using NCQ, the command WRITE DMA FUA EXT is LBA48 */
+               KASSERT((wd->sc_flags & WDF_LBA48) != 0);
+               if ((xfer->c_flags & C_NCQ) == 0)
+                       xfer->c_bio.flags |= ATA_LBA48;
+
+               xfer->c_bio.flags |= ATA_FUA;
+       }
 
        /* Instrumentation. */
        disk_busy(&wd->sc_dk);
@@ -982,7 +990,7 @@
 
        /*
         * The limit is actually 65536 for LBA48 and 256 for non-LBA48,
-        * but that requires to pass set the count for the ATA command
+        * but that requires to set the count for the ATA command
         * to 0, which is somewhat error prone, so better stay safe.
         */
        if (wd->sc_flags & WDF_LBA48)
@@ -1900,6 +1908,9 @@
        if (params.atap_cmd1_en & WDC_CMD1_CACHE)
                *bitsp |= DKCACHE_WRITE;
 
+       if (wd->drvp->drive_flags & (ATA_DRIVE_NCQ|ATA_DRIVE_WFUA))
+               *bitsp |= DKCACHE_FUA;
+
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index