Source-Changes-HG archive

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

[src/jdolecek-ncqfixes]: src/sys/dev/ic only call ata_deactivate_xfer() once ...



details:   https://anonhg.NetBSD.org/src/rev/2de0b1811e93
branches:  jdolecek-ncqfixes
changeset: 850574:2de0b1811e93
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sat Sep 01 10:13:41 2018 +0000

description:
only call ata_deactivate_xfer() once completely done with the active
xfer in controller code (i.e. after bus_dmamap_sync() et.al.), so that
the command slot is safe to be reused immediatelly after deactivate

diffstat:

 sys/dev/ic/ahcisata_core.c |  29 +++++++++++++++--------------
 sys/dev/ic/siisata.c       |  22 +++++++++++-----------
 2 files changed, 26 insertions(+), 25 deletions(-)

diffs (163 lines):

diff -r 420bcd43b7d4 -r 2de0b1811e93 sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c        Sat Sep 01 09:48:32 2018 +0000
+++ b/sys/dev/ic/ahcisata_core.c        Sat Sep 01 10:13:41 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_core.c,v 1.62.2.1 2018/08/31 19:08:03 jdolecek Exp $  */
+/*     $NetBSD: ahcisata_core.c,v 1.62.2.2 2018/09/01 10:13:41 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.62.2.1 2018/08/31 19:08:03 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.62.2.2 2018/09/01 10:13:41 jdolecek Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -1206,9 +1206,6 @@
        if (ata_waitdrain_xfer_check(chp, xfer))
                return 0;
 
-       KASSERT((achp->ahcic_cmds_active & (1U << xfer->c_slot)) != 0);
-       achp->ahcic_cmds_active &= ~(1U << xfer->c_slot);
-
        if (xfer->c_flags & C_TIMEOU) {
                ata_c->flags |= AT_TIMEOU;
        }
@@ -1225,6 +1222,8 @@
 
        ahci_cmd_done(chp, xfer);
 
+       KASSERT((achp->ahcic_cmds_active & (1U << xfer->c_slot)) != 0);
+       achp->ahcic_cmds_active &= ~(1U << xfer->c_slot);
        ata_deactivate_xfer(chp, xfer);
 
        return 0;
@@ -1453,10 +1452,6 @@
        if (ata_waitdrain_xfer_check(chp, xfer))
                return 0;
 
-       KASSERT((achp->ahcic_cmds_active & (1U << xfer->c_slot)) != 0);
-       achp->ahcic_cmds_active &= ~(1U << xfer->c_slot);
-       ata_deactivate_xfer(chp, xfer);
-
        if (xfer->c_flags & C_TIMEOU) {
                ata_bio->error = TIMEOUT;
        }
@@ -1497,6 +1492,11 @@
                            le32toh(achp->ahcic_cmdh[xfer->c_slot].cmdh_prdbc);
        }
        AHCIDEBUG_PRINT((" now %ld\n", ata_bio->bcount), DEBUG_XFERS);
+
+       KASSERT((achp->ahcic_cmds_active & (1U << xfer->c_slot)) != 0);
+       achp->ahcic_cmds_active &= ~(1U << xfer->c_slot);
+       ata_deactivate_xfer(chp, xfer);
+
        (*chp->ch_drive[drive].drv_done)(chp->ch_drive[drive].drv_softc, xfer);
        if ((AHCI_TFD_ST(tfd) & WDCS_ERR) == 0)
                atastart(chp);
@@ -1997,10 +1997,6 @@
        if (ata_waitdrain_xfer_check(chp, xfer))
                return 0;
 
-       KASSERT((achp->ahcic_cmds_active & (1U << xfer->c_slot)) != 0);
-       achp->ahcic_cmds_active &= ~(1U << xfer->c_slot);
-       ata_deactivate_xfer(chp, xfer);
-
        if (xfer->c_flags & C_TIMEOU) {
                sc_xfer->error = XS_TIMEOUT;
        }
@@ -2030,7 +2026,12 @@
                        sc_xfer->error = XS_BUSY;
                        sc_xfer->status = SCSI_CHECK;
                }
-       } 
+       }
+
+       KASSERT((achp->ahcic_cmds_active & (1U << xfer->c_slot)) != 0);
+       achp->ahcic_cmds_active &= ~(1U << xfer->c_slot);
+       ata_deactivate_xfer(chp, xfer);
+
        ata_free_xfer(chp, xfer);
        scsipi_done(sc_xfer);
        if ((AHCI_TFD_ST(tfd) & WDCS_ERR) == 0)
diff -r 420bcd43b7d4 -r 2de0b1811e93 sys/dev/ic/siisata.c
--- a/sys/dev/ic/siisata.c      Sat Sep 01 09:48:32 2018 +0000
+++ b/sys/dev/ic/siisata.c      Sat Sep 01 10:13:41 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.35.6.1 2018/08/31 19:08:03 jdolecek Exp $ */
+/* $NetBSD: siisata.c,v 1.35.6.2 2018/09/01 10:13:41 jdolecek Exp $ */
 
 /* from ahcisata_core.c */
 
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.35.6.1 2018/08/31 19:08:03 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.35.6.2 2018/09/01 10:13:41 jdolecek Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -1154,8 +1154,6 @@
        if (ata_waitdrain_xfer_check(chp, xfer))
                return 0;
 
-       siisata_deactivate_prb(schp, xfer->c_slot);
-
        if (xfer->c_flags & C_TIMEOU)
                ata_c->flags |= AT_TIMEOU;
 
@@ -1168,6 +1166,7 @@
 
        siisata_cmd_done(chp, xfer, tfd);
 
+       siisata_deactivate_prb(schp, xfer->c_slot);
        ata_deactivate_xfer(chp, xfer);
 
        return 0;
@@ -1382,9 +1381,6 @@
        if (ata_waitdrain_xfer_check(chp, xfer))
                return 0;
 
-       siisata_deactivate_prb(schp, xfer->c_slot);
-       ata_deactivate_xfer(chp, xfer);
-
        if (xfer->c_flags & C_TIMEOU) {
                ata_bio->error = TIMEOUT;
        }
@@ -1414,6 +1410,10 @@
                        ata_bio->bcount = 0;
        }
        SIISATA_DEBUG_PRINT((" now %ld\n", ata_bio->bcount), DEBUG_XFERS);
+
+       siisata_deactivate_prb(schp, xfer->c_slot);
+       ata_deactivate_xfer(chp, xfer);
+
        (*chp->ch_drive[drive].drv_done)(chp->ch_drive[drive].drv_softc, xfer);
        if ((ATACH_ST(tfd) & WDCS_ERR) == 0)
                atastart(chp);
@@ -1949,10 +1949,6 @@
        if (ata_waitdrain_xfer_check(chp, xfer))
                return 0;
 
-       /* this command is not active any more */
-       siisata_deactivate_prb(schp, xfer->c_slot);
-       ata_deactivate_xfer(chp, xfer);
-
        if (xfer->c_flags & C_TIMEOU) {
                sc_xfer->error = XS_TIMEOUT;
        }
@@ -1980,6 +1976,10 @@
                        sc_xfer->status = SCSI_CHECK;
                }
        }
+
+       siisata_deactivate_prb(schp, xfer->c_slot);
+       ata_deactivate_xfer(chp, xfer);
+
        ata_free_xfer(chp, xfer);
        scsipi_done(sc_xfer);
        if ((ATACH_ST(tfd) & WDCS_ERR) == 0)



Home | Main Index | Thread Index | Old Index