Source-Changes-HG archive

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

[src/jdolecek-ncq]: src/sys/dev do not use PRD Byte Count for queued commands...



details:   https://anonhg.NetBSD.org/src/rev/ae77097bd68a
branches:  jdolecek-ncq
changeset: 352658:ae77097bd68a
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Apr 24 15:15:02 2017 +0000

description:
do not use PRD Byte Count for queued commands to determine number of bytes
actually transferred; it should not be used and is not guaranteed to be
valid according to AHCI spec, underflow is always invalid for queued cmds

this fixes my ls problem under QEMU

diffstat:

 sys/dev/ata/TODO.ncq       |   5 -----
 sys/dev/ic/ahcisata_core.c |  14 ++++++++++----
 2 files changed, 10 insertions(+), 9 deletions(-)

diffs (56 lines):

diff -r 5a7974c83b36 -r ae77097bd68a sys/dev/ata/TODO.ncq
--- a/sys/dev/ata/TODO.ncq      Mon Apr 24 14:07:29 2017 +0000
+++ b/sys/dev/ata/TODO.ncq      Mon Apr 24 15:15:02 2017 +0000
@@ -1,11 +1,6 @@
 Bugs
 ----
 
-under QEMU, the mounted AHCI drive doesn't show directories for ls,
-but cd, mkdir, stat and creating files wroks just fine - what do?
-- https://lists.freebsd.org/pipermail/freebsd-current/2011-September/027294.html
-- somewhat critical since we use QEMU for babylon builds
-
 mvsata, siisata - fix all 'XXX slot' 
 
 test wd* at umass?, confirm the ata_channel kludge works
diff -r 5a7974c83b36 -r ae77097bd68a sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c        Mon Apr 24 14:07:29 2017 +0000
+++ b/sys/dev/ic/ahcisata_core.c        Mon Apr 24 15:15:02 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_core.c,v 1.57.6.9 2017/04/24 10:21:15 jdolecek Exp $  */
+/*     $NetBSD: ahcisata_core.c,v 1.57.6.10 2017/04/24 15:15:02 jdolecek Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.57.6.9 2017/04/24 10:21:15 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.57.6.10 2017/04/24 15:15:02 jdolecek Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -1331,14 +1331,20 @@
        AHCIDEBUG_PRINT(("ahci_bio_complete bcount %ld",
            ata_bio->bcount), DEBUG_XFERS);
        /* 
-        * if it was a write, complete data buffer may have been transfered
+        * If it was a write, complete data buffer may have been transfered
         * before error detection; in this case don't use cmdh_prdbc
         * as it won't reflect what was written to media. Assume nothing
         * was transfered and leave bcount as-is.
+        * For queued commands, PRD Byte Count should not be used, and is
+        * not required to be valid; in that case underflow is always illegal.
         */
-       if ((ata_bio->flags & ATA_READ) || ata_bio->error == NOERROR)
+       if ((xfer->c_flags & C_NCQ) != 0) {
+               ata_bio->bcount = 0;
+       } else {
+           if ((ata_bio->flags & ATA_READ) || ata_bio->error == NOERROR)
                ata_bio->bcount -=
                    le32toh(achp->ahcic_cmdh[xfer->c_slot].cmdh_prdbc);
+       }
        AHCIDEBUG_PRINT((" now %ld\n", ata_bio->bcount), DEBUG_XFERS);
        (*chp->ch_drive[drive].drv_done)(chp->ch_drive[drive].drv_softc, xfer);
        atastart(chp);



Home | Main Index | Thread Index | Old Index