Module Name: src
Committed By: jdolecek
Date: Mon Apr 24 22:20:23 UTC 2017
Modified Files:
src/sys/dev/ata [jdolecek-ncq]: TODO.ncq ata.c atareg.h atavar.h wd.c
Log Message:
set NCQ priority field to 'high' for BPRIO_TIMECRITICAL transfers if drive
supports it
To generate a diff of this commit:
cvs rdiff -u -r1.1.2.10 -r1.1.2.11 src/sys/dev/ata/TODO.ncq
cvs rdiff -u -r1.132.8.7 -r1.132.8.8 src/sys/dev/ata/ata.c
cvs rdiff -u -r1.43.18.1 -r1.43.18.2 src/sys/dev/ata/atareg.h
cvs rdiff -u -r1.92.8.7 -r1.92.8.8 src/sys/dev/ata/atavar.h
cvs rdiff -u -r1.428.2.13 -r1.428.2.14 src/sys/dev/ata/wd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ata/TODO.ncq
diff -u src/sys/dev/ata/TODO.ncq:1.1.2.10 src/sys/dev/ata/TODO.ncq:1.1.2.11
--- src/sys/dev/ata/TODO.ncq:1.1.2.10 Mon Apr 24 15:15:02 2017
+++ src/sys/dev/ata/TODO.ncq Mon Apr 24 22:20:23 2017
@@ -8,14 +8,6 @@ test wd* at umass?, confirm the ata_chan
is ata_exec_xfer() + POLL safe wrt. more outstanding I/Os? why is it waiting
until xfer is head of queue? also layer violation with the ata_xfer_free() call
-NCQ PRIO/ICC handling
----------------------
-fix handling of ATA 'devices' value to be full 16-bit value, to prepare for
-the ICC/AUXILIARY support
-
-set PRIO/ICC for NCQ transfers for BPRIO_TIMECRITICAL/BPRIO_TIMELIMITED
-NCQ ICC - investigate and set/get the behaviour with timeouts (WDNC, RDNC)
-
Other random notes (maybe do outside the NCQ branch):
-----------------------------------------------------
add support for the NCQ TRIM if supported by device?
Index: src/sys/dev/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.132.8.7 src/sys/dev/ata/ata.c:1.132.8.8
--- src/sys/dev/ata/ata.c:1.132.8.7 Sun Apr 23 01:30:30 2017
+++ src/sys/dev/ata/ata.c Mon Apr 24 22:20:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ata.c,v 1.132.8.7 2017/04/23 01:30:30 jakllsch Exp $ */
+/* $NetBSD: ata.c,v 1.132.8.8 2017/04/24 22:20:23 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.7 2017/04/23 01:30:30 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.8 2017/04/24 22:20:23 jdolecek Exp $");
#include "opt_ata.h"
@@ -1421,10 +1421,12 @@ ata_print_modes(struct ata_channel *chp)
)
aprint_verbose(" (using DMA)");
- if (drvp->drive_flags & ATA_DRIVE_NCQ)
- aprint_verbose(", NCQ (%d tags)",
- chp->ch_queue->queue_openings);
- else if (drvp->drive_flags & ATA_DRIVE_WFUA)
+ if (drvp->drive_flags & ATA_DRIVE_NCQ) {
+ aprint_verbose(", NCQ (%d tags)%s",
+ chp->ch_queue->queue_openings,
+ (drvp->drive_flags & ATA_DRIVE_NCQ_PRIO)
+ ? " w/PRIO" : "");
+ } else if (drvp->drive_flags & ATA_DRIVE_WFUA)
aprint_verbose(", WRITE DMA FUA EXT");
#endif /* NATA_DMA || NATA_PIOBM */
@@ -1748,6 +1750,11 @@ ata_probe_caps(struct ata_drive_datas *d
(params.atap_queuedepth & WDC_QUEUE_DEPTH_MASK) + 1;
aprint_verbose("%s NCQ (%d tags)", sep, drvp->drv_openings);
sep = ",";
+
+ if (params.atap_sata_caps & SATA_NCQ_PRIO) {
+ drvp->drive_flags |= ATA_DRIVE_NCQ_PRIO;
+ aprint_verbose(" w/PRIO");
+ }
}
if (drvp->drv_openings < chp->ch_queue->queue_openings)
ata_queue_downsize(chp->ch_queue, drvp->drv_openings);
@@ -1999,6 +2006,9 @@ atacmd_toncq(struct ata_xfer *xfer, uint
/* NCQ tag */
*count = (xfer->c_slot << 3);
+ if (xfer->c_bio.flags & ATA_PRIO_HIGH)
+ *count |= WDSC_PRIO_HIGH;
+
/* other device flags */
if (xfer->c_bio.flags & ATA_FUA)
*device |= WDSD_FUA;
Index: src/sys/dev/ata/atareg.h
diff -u src/sys/dev/ata/atareg.h:1.43.18.1 src/sys/dev/ata/atareg.h:1.43.18.2
--- src/sys/dev/ata/atareg.h:1.43.18.1 Wed Apr 19 21:42:39 2017
+++ src/sys/dev/ata/atareg.h Mon Apr 24 22:20:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: atareg.h,v 1.43.18.1 2017/04/19 21:42:39 jdolecek Exp $ */
+/* $NetBSD: atareg.h,v 1.43.18.2 2017/04/24 22:20:23 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -245,6 +245,11 @@ atacmd_tostatq(int cmd32)
#define WDSMART_CYL 0xc24f
+/* parameters uploaded to count register for NCQ */
+#define WDSC_PRIO_HIGH __BIT(15)
+#define WDSC_PRIO_ISOCHRONOUS __BIT(14)
+#define WDSC_PRIO_NORMAL 0x0000
+
/* parameters uploaded to device/heads register */
#define WDSD_IBM 0xa0 /* forced to 512 byte sector, ecc */
#define WDSD_CHS 0x00 /* cylinder/head/sector addressing */
@@ -377,9 +382,11 @@ struct ataparams {
#define SATA_SIGNAL_GEN1 0x02
#define SATA_SIGNAL_GEN2 0x04
#define SATA_SIGNAL_GEN3 0x08
-#define SATA_NATIVE_CMDQ 0x0100
-#define SATA_HOST_PWR_MGMT 0x0200
-#define SATA_PHY_EVNT_CNT 0x0400
+#define SATA_NATIVE_CMDQ 0x0100 /* supp. NCQ feature set */
+#define SATA_HOST_PWR_MGMT 0x0200 /* supp. host-init. pwr mngmt reqs */
+#define SATA_PHY_EVNT_CNT 0x0400 /* supp. SATA Phy Event Counters log */
+#define SATA_UNLOAD_W_NCQ 0x0800 /* supp. unload w/ NCQ commands act */
+#define SATA_NCQ_PRIO 0x1000 /* supp. NCQ priority information */
uint16_t atap_sata_reserved; /* 77: */
uint16_t atap_sata_features_supp; /* 78: */
#define SATA_NONZERO_OFFSETS 0x02
Index: src/sys/dev/ata/atavar.h
diff -u src/sys/dev/ata/atavar.h:1.92.8.7 src/sys/dev/ata/atavar.h:1.92.8.8
--- src/sys/dev/ata/atavar.h:1.92.8.7 Thu Apr 20 20:14:42 2017
+++ src/sys/dev/ata/atavar.h Mon Apr 24 22:20:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: atavar.h,v 1.92.8.7 2017/04/20 20:14:42 jdolecek Exp $ */
+/* $NetBSD: atavar.h,v 1.92.8.8 2017/04/24 22:20:23 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -50,6 +50,7 @@ struct ata_bio {
#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 */
+#define ATA_PRIO_HIGH 0x0200 /* transfer has high priority */
daddr_t blkno; /* block addr */
daddr_t blkdone;/* number of blks transferred */
daddr_t nblks; /* number of block currently transferring */
@@ -232,7 +233,8 @@ struct ata_drive_datas {
#define ATA_DRIVE_NOSTREAM 0x0040 /* no stream methods on this drive */
#define ATA_DRIVE_ATAPIDSCW 0x0080 /* needs to wait for DSC in phase_complete */
#define ATA_DRIVE_WFUA 0x0100 /* drive supports WRITE DMA FUA EXT */
-#define ATA_DRIVE_NCQ 0x0200 /* drive supports NCQ */
+#define ATA_DRIVE_NCQ 0x0200 /* drive supports NCQ feature set */
+#define ATA_DRIVE_NCQ_PRIO 0x0400 /* drive supports NCQ PRIO field */
uint8_t drive_type;
#define ATA_DRIVET_NONE 0
Index: src/sys/dev/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.428.2.13 src/sys/dev/ata/wd.c:1.428.2.14
--- src/sys/dev/ata/wd.c:1.428.2.13 Mon Apr 24 14:07:29 2017
+++ src/sys/dev/ata/wd.c Mon Apr 24 22:20:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: wd.c,v 1.428.2.13 2017/04/24 14:07:29 jdolecek Exp $ */
+/* $NetBSD: wd.c,v 1.428.2.14 2017/04/24 22:20:23 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.13 2017/04/24 14:07:29 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.428.2.14 2017/04/24 22:20:23 jdolecek Exp $");
#include "opt_ata.h"
@@ -689,6 +689,10 @@ wdstart1(struct wd_softc *wd, struct buf
if (wd->drvp->drive_flags & ATA_DRIVE_NCQ) {
xfer->c_bio.flags |= ATA_LBA48;
xfer->c_flags |= C_NCQ;
+
+ if ((wd->drvp->drive_flags & ATA_DRIVE_NCQ_PRIO) &&
+ BIO_GETPRIO(bp) == BPRIO_TIMECRITICAL)
+ xfer->c_bio.flags |= ATA_PRIO_HIGH;
}
if (wd->sc_flags & WDF_LBA)