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 put recovery command on head of active xf...



details:   https://anonhg.NetBSD.org/src/rev/22c494f64cf5
branches:  jdolecek-ncq
changeset: 823031:22c494f64cf5
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Mon Sep 25 22:43:46 2017 +0000

description:
put recovery command on head of active xfers queue, so that drivers using
ata_queue_get_active_xfer() like mvsata(4) will find it and not random other
NCQ xfer

never return NCQ xfer from ata_queue_get_active_xfer(), if the first xfer
is NCQ simply return NULL

adjust ata_timo_xfer_check() to not check the expiring flag in C_WAITTIMO
branch, if we get there we ought to get the timeout handler aborted

diffstat:

 sys/dev/ata/ata.c |  43 ++++++++++++++++++++++++++++++-------------
 1 files changed, 30 insertions(+), 13 deletions(-)

diffs (87 lines):

diff -r ddea8daa3cf1 -r 22c494f64cf5 sys/dev/ata/ata.c
--- a/sys/dev/ata/ata.c Sat Sep 23 14:53:26 2017 +0000
+++ b/sys/dev/ata/ata.c Mon Sep 25 22:43:46 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ata.c,v 1.132.8.36 2017/09/23 14:53:26 jdolecek Exp $  */
+/*     $NetBSD: ata.c,v 1.132.8.37 2017/09/25 22:43:46 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.36 2017/09/23 14:53:26 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.37 2017/09/25 22:43:46 jdolecek Exp $");
 
 #include "opt_ata.h"
 
@@ -208,7 +208,8 @@
 
        KASSERTMSG(hwslot < chq->queue_openings, "hwslot %d > openings %d",
            hwslot, chq->queue_openings);
-       KASSERT((chq->active_xfers_used & __BIT(hwslot)) != 0);
+       KASSERTMSG((chq->active_xfers_used & __BIT(hwslot)) != 0,
+           "hwslot %d not active", hwslot);
 
        /* Usually the first entry will be the one */
        TAILQ_FOREACH(xfer, &chq->active_xfers, c_activechain) {
@@ -228,8 +229,17 @@
 static struct ata_xfer *
 ata_queue_get_active_xfer_locked(struct ata_channel *chp)
 {
+       struct ata_xfer *xfer;
+
        KASSERT(mutex_owned(&chp->ch_lock));
-       return TAILQ_FIRST(&chp->ch_queue->active_xfers);
+       xfer = TAILQ_FIRST(&chp->ch_queue->active_xfers);
+
+       if (xfer && ISSET(xfer->c_flags, C_NCQ)) {
+               /* Spurious call, never return NCQ xfer from this interface */
+               xfer = NULL;
+       }
+
+       return xfer;
 }
 
 /*
@@ -1543,7 +1553,16 @@
        KASSERT((chq->active_xfers_used & __BIT(xfer->c_slot)) == 0);
 
        TAILQ_REMOVE(&chq->queue_xfer, xfer, c_xferchain);
-       TAILQ_INSERT_TAIL(&chq->active_xfers, xfer, c_activechain);
+       if ((xfer->c_flags & C_RECOVERY) == 0)
+               TAILQ_INSERT_TAIL(&chq->active_xfers, xfer, c_activechain);
+       else {
+               /*
+                * Must go to head, so that ata_queue_get_active_xfer()
+                * returns the recovery command, and not some other
+                * random active transfer.
+                */
+               TAILQ_INSERT_HEAD(&chq->active_xfers, xfer, c_activechain);
+       }
        chq->active_xfers_used |= __BIT(xfer->c_slot);
        chq->queue_active++;
 }
@@ -1632,15 +1651,13 @@
                        return true;
                }
 
-               /* Handle race vs. callout_stop() in ata_deactivate_xfer() */
-               if (!callout_expired(&xfer->c_timo_callout)) {
-                       ata_channel_unlock(chp);
+               /* Race vs. callout_stop() in ata_deactivate_xfer() */
+               ata_channel_unlock(chp);
 
-                       aprint_normal_dev(drvp->drv_softc,
-                           "xfer %d deactivated while invoking timeout\n",
-                           xfer->c_slot); 
-                       return true;
-               }
+               aprint_normal_dev(drvp->drv_softc,
+                   "xfer %d deactivated while invoking timeout\n",
+                   xfer->c_slot); 
+               return true;
        }
 
        ata_channel_unlock(chp);



Home | Main Index | Thread Index | Old Index