Source-Changes-HG archive

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

[src/jdolecek-ncq]: src/sys/dev/ic fix to not access active_xfer directly



details:   https://anonhg.NetBSD.org/src/rev/118c07459182
branches:  jdolecek-ncq
changeset: 822870:118c07459182
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Tue Apr 11 18:13:17 2017 +0000

description:
fix to not access active_xfer directly

diffstat:

 sys/dev/ic/ahcisata_core.c |   6 +++---
 sys/dev/ic/mvsata.c        |  42 +++++++++++++++++++++---------------------
 sys/dev/ic/siisata.c       |  10 +++++-----
 3 files changed, 29 insertions(+), 29 deletions(-)

diffs (189 lines):

diff -r 323fa13272f3 -r 118c07459182 sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c        Mon Apr 10 22:57:02 2017 +0000
+++ b/sys/dev/ic/ahcisata_core.c        Tue Apr 11 18:13:17 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_core.c,v 1.57.6.1 2017/04/10 22:57:02 jdolecek Exp $  */
+/*     $NetBSD: ahcisata_core.c,v 1.57.6.2 2017/04/11 18:13:17 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.1 2017/04/10 22:57:02 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.57.6.2 2017/04/11 18:13:17 jdolecek Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -1433,7 +1433,7 @@
 ahci_timeout(void *v)
 {
        struct ata_channel *chp = (struct ata_channel *)v;
-       struct ata_xfer *xfer = chp->ch_queue->active_xfers[0];
+       struct ata_xfer *xfer = ata_queue_hwslot_to_xfer(chp->ch_queue, 0); /* XXX slot */
 #ifdef AHCI_DEBUG
        struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
 #endif
diff -r 323fa13272f3 -r 118c07459182 sys/dev/ic/mvsata.c
--- a/sys/dev/ic/mvsata.c       Mon Apr 10 22:57:02 2017 +0000
+++ b/sys/dev/ic/mvsata.c       Tue Apr 11 18:13:17 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mvsata.c,v 1.35.6.1 2017/04/10 22:57:02 jdolecek Exp $ */
+/*     $NetBSD: mvsata.c,v 1.35.6.2 2017/04/11 18:13:17 jdolecek Exp $ */
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.35.6.1 2017/04/10 22:57:02 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.35.6.2 2017/04/11 18:13:17 jdolecek Exp $");
 
 #include "opt_mvsata.h"
 
@@ -630,7 +630,10 @@
                xfer = mvport->port_reqtbl[i].xfer;
                if (xfer == NULL)
                        continue;
-               chp->ch_queue->active_xfers[0] = xfer;
+#if 0
+               /* This doesn't seem to be needed? */
+               chp->ch_queue->active_xfers[0] = xfer; /* XXX slot */
+#endif
                xfer->c_kill_xfer(chp, xfer, KILL_RESET);
        }
 
@@ -1447,15 +1450,11 @@
        ata_bio->bcount = xfer->c_bcount;
 
        /* mark controller inactive and free xfer */
-       KASSERT(chp->ch_queue->active_xfers[0] != NULL);
        ata_deactivate_xfer(chp, xfer);
        ata_free_xfer(chp, xfer);
 
-       if (chp->ch_drive[drive].drive_flags & ATA_DRIVE_WAITDRAIN) {
+       if (ata_waitdrain_check(chp, drive)) {
                ata_bio->error = ERR_NODEV;
-               chp->ch_drive[drive].drive_flags &= ~ATA_DRIVE_WAITDRAIN;
-               wakeup(chp->ch_queue->active_xfers);
-       }
        ata_bio->flags |= ATA_ITSDONE;
        (*chp->ch_drive[drive].drv_done)(chp->ch_drive[drive].drv_softc);
        atastart(chp);
@@ -1820,11 +1819,8 @@
                MVSATA_WDC_WRITE_1(mvport, SRB_CAS, WDCTL_4BIT);
                delay(10);      /* some drives need a little delay here */
        }
-       if (chp->ch_drive[xfer->c_drive].drive_flags & ATA_DRIVE_WAITDRAIN) {
-               mvsata_wdc_cmd_kill_xfer(chp, xfer, KILL_GONE);
-               chp->ch_drive[xfer->c_drive].drive_flags &= ~ATA_DRIVE_WAITDRAIN;
-               wakeup(chp->ch_queue->active_xfers);
-       } else
+
+       if (!ata_waitdrain_xfer_check(chp, xfer))
                mvsata_wdc_cmd_done_end(chp, xfer);
 }
 
@@ -2462,8 +2458,9 @@
                return rv;
 
        KASSERT(mvport->port_reqtbl[quetag].xfer == NULL);
-       KASSERT(chp->ch_queue->active_xfers[0] != NULL);
-       mvport->port_reqtbl[quetag].xfer = chp->ch_queue->active_xfers[0];
+       KASSERT(ata_queue_hwslot_to_xfer(chp->ch_queue, 0) != NULL);
+       mvport->port_reqtbl[quetag].xfer = ata_queue_hwslot_to_xfer(
+           chp->ch_queue, 0);  /* XXX slot */
 
        /* setup EDMA Physical Region Descriptors (ePRD) Table Data */
        data_dmamap = mvport->port_reqtbl[quetag].data_dmamap;
@@ -2576,8 +2573,8 @@
 #endif
                crpb = mvport->port_crpb + erpqop;
                quetag = CRPB_CHOSTQUETAG(le16toh(crpb->id));
-               KASSERT(chp->ch_queue->active_xfers[0] != NULL);
-               xfer = chp->ch_queue->active_xfers[0];
+               xfer = ata_queue_hwslot_to_xfer(chp->ch_queue, 0); /* XXX slot */
+               KASSERT(xfer != NULL);
                KASSERT(xfer == mvport->port_reqtbl[quetag].xfer);
 #ifdef DIAGNOSTIC
                if (xfer == NULL)
@@ -2765,9 +2762,10 @@
        if (rv != 0)
                return rv;
 
-       KASSERT(chp->ch_queue->active_xfers[0] != NULL);
+       KASSERT(ata_queue_hwslot_to_xfer(chp->ch_queue, 0) != NULL);
        KASSERT(mvport->port_reqtbl[quetag].xfer == NULL);
-       mvport->port_reqtbl[quetag].xfer = chp->ch_queue->active_xfers[0];
+       mvport->port_reqtbl[quetag].xfer = ata_queue_hwslot_to_xfer(
+           chp->ch_queue, 0); /* XXX slot */
 
        /* setup EDMA Physical Region Descriptors (ePRD) Table Data */
        data_dmamap = mvport->port_reqtbl[quetag].data_dmamap;
@@ -3452,7 +3450,8 @@
        uint8_t cmd, head;
        int i;
        const int drive =
-           mvport->port_ata_channel.ch_queue->active_xfers[0]->c_drive;
+           ata_queue_hwslot_to_xfer(mvport->port_ata_channel.ch_queue, 0) /* XXX slot */
+           ->c_drive;
 
        eprd_addr = mvport->port_eprd_dmamap->dm_segs[0].ds_addr +
            mvport->port_reqtbl[quetag].eprd_offset;
@@ -3700,7 +3699,8 @@
        uint32_t ctrlflg, rw;
        uint8_t cmd, head;
        const int drive =
-           mvport->port_ata_channel.ch_queue->active_xfers[0]->c_drive;
+           ata_queue_hwslot_to_xfer(mvport->port_ata_channel.ch_queue, 0) /* XXX slot */
+           ->c_drive;
 
        eprd_addr = mvport->port_eprd_dmamap->dm_segs[0].ds_addr +
            mvport->port_reqtbl[quetag].eprd_offset;
diff -r 323fa13272f3 -r 118c07459182 sys/dev/ic/siisata.c
--- a/sys/dev/ic/siisata.c      Mon Apr 10 22:57:02 2017 +0000
+++ b/sys/dev/ic/siisata.c      Tue Apr 11 18:13:17 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.30.4.1 2017/04/10 22:57:02 jdolecek Exp $ */
+/* $NetBSD: siisata.c,v 1.30.4.2 2017/04/11 18:13:17 jdolecek Exp $ */
 
 /* from ahcisata_core.c */
 
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.30.4.1 2017/04/10 22:57:02 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.30.4.2 2017/04/11 18:13:17 jdolecek Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -480,7 +480,7 @@
 
        sc = (struct siisata_softc *)schp->ata_channel.ch_atac;
        chp = &schp->ata_channel;
-       xfer = chp->ch_queue->active_xfers[0];
+       xfer = ata_queue_hwslot_to_xfer(chp->ch_queue, 0); /* XXX slot */
        slot = SIISATA_NON_NCQ_SLOT;
 
        pis = PRREAD(sc, PRX(chp->ch_channel, PRO_PIS));
@@ -640,7 +640,7 @@
                DELAY(10);
        PRWRITE(sc, PRX(chp->ch_channel, PRO_SERROR),
            PRREAD(sc, PRX(chp->ch_channel, PRO_SERROR)));
-       if ((xfer = chp->ch_queue->active_xfers[0]) != NULL) {
+       if ((xfer = ata_queue_hwslot_to_xfer(chp->ch_queue, 0)) != NULL) { /* XXX slot */
                (*xfer->c_kill_xfer)(chp, xfer, KILL_RESET);
        }
 
@@ -1191,7 +1191,7 @@
 siisata_timeout(void *v)
 {
        struct ata_channel *chp = (struct ata_channel *)v;
-       struct ata_xfer *xfer = chp->ch_queue->active_xfers[0];
+       struct ata_xfer *xfer = ata_queue_hwslot_to_xfer(chp->ch_queue, 0); /* XXX slot */
        int slot = SIISATA_NON_NCQ_SLOT;
        int s = splbio();
        SIISATA_DEBUG_PRINT(("%s: %p\n", __func__, xfer), DEBUG_INTR);



Home | Main Index | Thread Index | Old Index