CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sun Oct 21 19:16:48 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq Log Message: testing done (including PMP on siisata(4) and ATAPI cd(4) on ahcisata/siisata) To generate a diff of this commit: cvs rdiff -u -r1.4.2.16 -r1.4.2.17 src/sys/dev/ata/TODO.ncq 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.4.2.16 src/sys/dev/ata/TODO.ncq:1.4.2.17 --- src/sys/dev/ata/TODO.ncq:1.4.2.16 Wed Oct 17 18:03:26 2018 +++ src/sys/dev/ata/TODO.ncq Sun Oct 21 19:16:48 2018 @@ -1,7 +1,3 @@ -jdolecek-ncqfixes to finish: -- re-check READ LOG EXT handling under native -- recheck native working for ahcisata(4), siisata(4), mvsata(4) + PMP - Bugs test wd* at umass?, confirm the ata_channel kludge works @@ -29,7 +25,7 @@ add support for the NCQ TRIM if supporte implement DIOCGCACHE/DIOCCACHESYNC for ld@ataraid? just passthrough, like ccd -MSI/MSI-X support for AHCI and mvsata(4) +MSI/MSI-X support for ahcisata(4), siisata(4) and mvsata(4) mvsata - move pci-specific code to the pci attach code
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Oct 20 21:08:23 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: satapmp_subr.c Log Message: hold lock during drive reset (new locking protocol) erase xfer before each reuse for read/write port commands To generate a diff of this commit: cvs rdiff -u -r1.14.2.1 -r1.14.2.2 src/sys/dev/ata/satapmp_subr.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/satapmp_subr.c diff -u src/sys/dev/ata/satapmp_subr.c:1.14.2.1 src/sys/dev/ata/satapmp_subr.c:1.14.2.2 --- src/sys/dev/ata/satapmp_subr.c:1.14.2.1 Sat Sep 22 09:22:59 2018 +++ src/sys/dev/ata/satapmp_subr.c Sat Oct 20 21:08:23 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: satapmp_subr.c,v 1.14.2.1 2018/09/22 09:22:59 jdolecek Exp $ */ +/* $NetBSD: satapmp_subr.c,v 1.14.2.2 2018/10/20 21:08:23 jdolecek Exp $ */ /* * Copyright (c) 2012 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.14.2.1 2018/09/22 09:22:59 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: satapmp_subr.c,v 1.14.2.2 2018/10/20 21:08:23 jdolecek Exp $"); #include #include @@ -62,6 +62,7 @@ satapmp_read_8(struct ata_channel *chp, KASSERT(drvp->drive == PMP_PORT_CTL); ata_channel_lock_owned(chp); + memset(xfer, 0, sizeof(*xfer)); xfer->c_ata_c.r_command = PMPC_READ_PORT; xfer->c_ata_c.r_features = reg; xfer->c_ata_c.r_device = port; @@ -133,6 +134,7 @@ satapmp_write_8(struct ata_channel *chp, KASSERT(drvp->drive == PMP_PORT_CTL); ata_channel_lock_owned(chp); + memset(xfer, 0, sizeof(*xfer)); xfer->c_ata_c.r_command = PMPC_WRITE_PORT; xfer->c_ata_c.r_features = reg; xfer->c_ata_c.r_device = port; @@ -261,10 +263,10 @@ satapmp_rescan(struct ata_channel *chp, device_xname(chp->atabus), i); continue; } - ata_channel_unlock(chp); + + ata_channel_lock_owned(chp); chp->ch_atac->atac_bustype_ata->ata_reset_drive( >ch_drive[i], AT_WAIT, ); - ata_channel_lock(chp); sata_interpret_sig(chp, i, sig); }
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Wed Oct 17 18:03:27 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq Log Message: rechecked bad block handling under Parallels and it really doesn't set any error bits in any of the registers (neither IS nor SERR) for out-of-range block read nor write, while it works just fine under VMware, so not our bug To generate a diff of this commit: cvs rdiff -u -r1.4.2.15 -r1.4.2.16 src/sys/dev/ata/TODO.ncq 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.4.2.15 src/sys/dev/ata/TODO.ncq:1.4.2.16 --- src/sys/dev/ata/TODO.ncq:1.4.2.15 Mon Oct 15 21:18:53 2018 +++ src/sys/dev/ata/TODO.ncq Wed Oct 17 18:03:26 2018 @@ -1,6 +1,6 @@ -jdolecek-ncqfixes goals: -- re-check READ LOG EXT handling under native and Parallels to make sure - the NOERROR under Parallels is their bug and not ours +jdolecek-ncqfixes to finish: +- re-check READ LOG EXT handling under native +- recheck native working for ahcisata(4), siisata(4), mvsata(4) + PMP Bugs
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sun Oct 14 16:13:51 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: ata.c Log Message: add comment to kthread_create() call to explain why atabus_thread is actually running under KERNEL_LOCK() To generate a diff of this commit: cvs rdiff -u -r1.141.6.16 -r1.141.6.17 src/sys/dev/ata/ata.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/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.16 src/sys/dev/ata/ata.c:1.141.6.17 --- src/sys/dev/ata/ata.c:1.141.6.16 Thu Oct 11 20:57:51 2018 +++ src/sys/dev/ata/ata.c Sun Oct 14 16:13:51 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.16 2018/10/11 20:57:51 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.17 2018/10/14 16:13:51 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.16 2018/10/11 20:57:51 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.17 2018/10/14 16:13:51 jdolecek Exp $"); #include "opt_ata.h" @@ -593,6 +593,7 @@ atabus_attach(device_t parent, device_t mutex_exit(_qlock); config_pending_incr(sc->sc_dev); + /* XXX MPSAFE - no KTHREAD_MPSAFE, so protected by KERNEL_LOCK() */ if ((error = kthread_create(PRI_NONE, 0, NULL, atabus_thread, sc, >ch_thread, "%s", device_xname(self))) != 0) aprint_error_dev(self,
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Oct 6 21:19:55 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: ata.c ata_subr.c atavar.h wd.c Log Message: actually, just make dump use the same queue skip as recovery, and remove the no longer necessary ata_queue_reset() call from wd(4) also for PR kern/47041 To generate a diff of this commit: cvs rdiff -u -r1.141.6.14 -r1.141.6.15 src/sys/dev/ata/ata.c cvs rdiff -u -r1.6.2.6 -r1.6.2.7 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.99.2.9 -r1.99.2.10 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.441.2.11 -r1.441.2.12 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/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.14 src/sys/dev/ata/ata.c:1.141.6.15 --- src/sys/dev/ata/ata.c:1.141.6.14 Sat Oct 6 20:27:36 2018 +++ src/sys/dev/ata/ata.c Sat Oct 6 21:19:55 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.14 2018/10/06 20:27:36 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.15 2018/10/06 21:19:55 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.14 2018/10/06 20:27:36 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.15 2018/10/06 21:19:55 jdolecek Exp $"); #include "opt_ata.h" @@ -961,7 +961,7 @@ ata_read_log_ext_ncq(struct ata_drive_da * and to make this a little faster. Realistically, it * should not matter. */ - xfer->c_flags |= C_RECOVERY; + xfer->c_flags |= C_SKIP_QUEUE; xfer->c_ata_c.r_command = WDCC_READ_LOG_EXT; xfer->c_ata_c.r_lba = page = WDCC_LOG_PAGE_NCQ; xfer->c_ata_c.r_st_bmask = WDCS_DRDY; @@ -1087,7 +1087,7 @@ ata_exec_xfer(struct ata_channel *chp, s * Standard commands are added to the end of command list, but * recovery commands must be run immediatelly. */ - if ((xfer->c_flags & C_RECOVERY) == 0) + if ((xfer->c_flags & C_SKIP_QUEUE) == 0) SIMPLEQ_INSERT_TAIL(>ch_queue->queue_xfer, xfer, c_xferchain); else @@ -1137,7 +1137,7 @@ atastart(struct ata_channel *chp) struct atac_softc *atac = chp->ch_atac; struct ata_queue *chq = chp->ch_queue; struct ata_xfer *xfer, *axfer; - bool recovery; + bool skipq; #ifdef ATA_DEBUG int spl1, spl2; @@ -1174,18 +1174,18 @@ again: goto out; } - recovery = ISSET(xfer->c_flags, C_RECOVERY); + skipq = ISSET(xfer->c_flags, C_SKIP_QUEUE); /* is the queue frozen? */ - if (__predict_false(!recovery && chq->queue_freeze > 0)) { + if (__predict_false(!skipq && chq->queue_freeze > 0)) { if (chq->queue_flags & QF_IDLE_WAIT) { chq->queue_flags &= ~QF_IDLE_WAIT; cv_signal(>ch_queue->queue_idle); } ATADEBUG_PRINT(("%s(chp=%p): channel %d drive %d " - "queue frozen: %d (recovery: %d)\n", + "queue frozen: %d\n", __func__, chp, chp->ch_channel, xfer->c_drive, - chq->queue_freeze, recovery), + chq->queue_freeze), DEBUG_XFERS); goto out; } @@ -1201,7 +1201,7 @@ again: * Need only check first xfer. * XXX FIS-based switching - revisit */ - if (!recovery && (axfer = TAILQ_FIRST(>ch_queue->active_xfers))) { + if (!skipq && (axfer = TAILQ_FIRST(>ch_queue->active_xfers))) { if (!ISSET(xfer->c_flags, C_NCQ) || !ISSET(axfer->c_flags, C_NCQ) || xfer->c_drive != axfer->c_drive) @@ -1211,17 +1211,17 @@ again: struct ata_drive_datas * const drvp = >ch_drive[xfer->c_drive]; /* - * Are we on limit of active xfers ? - * For recovery, we must leave one slot available at all times. + * Are we on limit of active xfers ? If the queue has more + * than 1 openings, we keep one slot reserved for recovery or dump. */ KASSERT(chq->queue_active <= chq->queue_openings); - const uint8_t chq_openings = (!recovery && chq->queue_openings > 1) + const uint8_t chq_openings = (!skipq && chq->queue_openings > 1) ? (chq->queue_openings - 1) : chq->queue_openings; const uint8_t drv_openings = ISSET(xfer->c_flags, C_NCQ) ? drvp->drv_openings : ATA_MAX_OPENINGS; if (chq->queue_active >= MIN(chq_openings, drv_openings)) { - if (recovery) { - panic("%s: channel %d busy, recovery not possible", + if (skipq) { + panic("%s: channel %d busy, xfer not possible", __func__, chp->ch_channel); } @@ -1272,8 +1272,8 @@ again: break; } - /* Queue more commands if possible, but not during recovery */ - if (!recovery && chq->queue_active < chq->queue_openings) + /* Queue more commands if possible, but not during recovery or dump */ + if (!skipq && chq->queue_active < chq->queue_openings) goto again; out: @@ -1321,17 +1321,9 @@ ata_activate_xfer_locked(struct ata_chan struct ata_queue * const chq = chp->ch_queue; KASSERT(mutex_owned(>ch_lock)); - - /* - * When openings is just 1, can't reserve anything for - * recovery. KASSERT() here is to catch code which naively - * relies on
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Oct 6 20:27:28 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq Log Message: move the entry for error recovery on thread up, it will be done on ncqfixes branch To generate a diff of this commit: cvs rdiff -u -r1.4.2.11 -r1.4.2.12 src/sys/dev/ata/TODO.ncq 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.4.2.11 src/sys/dev/ata/TODO.ncq:1.4.2.12 --- src/sys/dev/ata/TODO.ncq:1.4.2.11 Thu Oct 4 19:42:01 2018 +++ src/sys/dev/ata/TODO.ncq Sat Oct 6 20:27:28 2018 @@ -2,6 +2,8 @@ jdolecek-ncqfixes goals: - re-check READ LOG EXT handling under native and Parallels to make sure the NOERROR under Parallels is their bug and not ours - run recovery via atathread, move to new function and share ahci/siisata/mvsata +- maybe do device error handling in not-interrupt-context (maybe this should be + done on a mpata branch?) - remove controller-specific slot bitmaps (ic/siisata.c, ic/ahcisata_core.c) Bugs @@ -18,9 +20,6 @@ implement support for PM FIS-based switc for hw which supports it, adjust error handling in controller drivers to handle xfers for several different drives -maybe do device error handling in not-interrupt-context (maybe this should be -done on a mpata branch?) - dump to unopened disk fails (e.g. dump do wd1b when wd1a not mounted), due to the open path executing ata_get_params(), which eventually tsleeps() while waiting for the command to finish; specifically, if WDF_LOADED is not
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Oct 6 20:27:36 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: ata.c atavar.h wd.c Log Message: remove AT_RST_EMERG, do the queue reset explicitly in wd(4) this should explicitly fix PR kern/47041 with sync during heavy disk activity, even thought it was actually already implicitly fixed by calling ata_thread_run() for drive reset in previous commit already, since the function already called ata_queue_reset() drop now unused ch_reset_flags and drive_reset_flags To generate a diff of this commit: cvs rdiff -u -r1.141.6.13 -r1.141.6.14 src/sys/dev/ata/ata.c cvs rdiff -u -r1.99.2.8 -r1.99.2.9 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.441.2.10 -r1.441.2.11 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/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.13 src/sys/dev/ata/ata.c:1.141.6.14 --- src/sys/dev/ata/ata.c:1.141.6.13 Sat Oct 6 20:13:12 2018 +++ src/sys/dev/ata/ata.c Sat Oct 6 20:27:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.13 2018/10/06 20:13:12 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.14 2018/10/06 20:27:36 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.13 2018/10/06 20:13:12 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.14 2018/10/06 20:27:36 jdolecek Exp $"); #include "opt_ata.h" @@ -480,20 +480,17 @@ atabus_thread(void *arg) } if (chp->ch_flags & ATACH_TH_RESET) { /* this will unfreeze the channel */ - ata_thread_run(chp, AT_WAIT | chp->ch_reset_flags, + ata_thread_run(chp, AT_WAIT, ATACH_TH_RESET, ATACH_NODRIVE); } else if (chp->ch_flags & ATACH_TH_DRIVE_RESET) { for (i = 0; i < chp->ch_ndrives; i++) { struct ata_drive_datas *drvp; -int drv_reset_flags; drvp = >ch_drive[i]; -drv_reset_flags = drvp->drive_reset_flags; if (drvp->drive_flags & ATA_DRIVE_TH_RESET) { ata_thread_run(chp, - AT_WAIT | drv_reset_flags, - ATACH_TH_DRIVE_RESET, i); + AT_WAIT, ATACH_TH_DRIVE_RESET, i); } } chp->ch_flags &= ~ATACH_TH_DRIVE_RESET; @@ -1527,9 +1524,6 @@ ata_kill_active(struct ata_channel *chp, TAILQ_FOREACH_SAFE(xfer, >active_xfers, c_activechain, xfernext) { xfer->ops->c_kill_xfer(xfer->c_chp, xfer, reason); } - - if (flags & AT_RST_EMERG) - ata_queue_reset(chq); } /* @@ -1651,7 +1645,6 @@ ata_thread_run(struct ata_channel *chp, /* No need to schedule another reset */ return; } - chp->ch_reset_flags = flags & AT_RST_EMERG; break; case ATACH_TH_DRIVE_RESET: KASSERT(drive <= chp->ch_ndrives); @@ -1662,7 +1655,6 @@ ata_thread_run(struct ata_channel *chp, return; } drvp->drive_flags |= ATA_DRIVE_TH_RESET; - drvp->drive_reset_flags = flags; break; default: panic("%s: unknown type: %x", __func__, type); @@ -1726,11 +1718,6 @@ ata_thread_run(struct ata_channel *chp, /* Signal the thread in case there is an xfer to run */ cv_signal(>ch_thr_idle); - - if (flags & AT_RST_EMERG) { - /* make sure that we can use polled commands */ - ata_queue_reset(chp->ch_queue); - } } int Index: src/sys/dev/ata/atavar.h diff -u src/sys/dev/ata/atavar.h:1.99.2.8 src/sys/dev/ata/atavar.h:1.99.2.9 --- src/sys/dev/ata/atavar.h:1.99.2.8 Wed Oct 3 19:20:48 2018 +++ src/sys/dev/ata/atavar.h Sat Oct 6 20:27:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.99.2.8 2018/10/03 19:20:48 jdolecek Exp $ */ +/* $NetBSD: atavar.h,v 1.99.2.9 2018/10/06 20:27:36 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -275,7 +275,6 @@ struct ata_drive_datas { #define ATA_DRIVE_NCQ 0x0200 /* drive supports NCQ feature set */ #define ATA_DRIVE_NCQ_PRIO 0x0400 /* drive supports NCQ PRIO field */ #define ATA_DRIVE_TH_RESET 0x0800 /* drive waits for thread drive reset */ - int drive_reset_flags; /* flags for drive reset via thread */ uint8_t drive_type; #define ATA_DRIVET_NONE 0 @@ -365,9 +364,6 @@ struct ata_bustype { int (*ata_bio)(struct ata_drive_datas *, struct ata_xfer *); void (*ata_reset_drive)(struct ata_drive_datas *, int, uint32_t *); void (*ata_reset_channel)(struct ata_channel *, int); -/* extra flags for ata_reset_*(), in addition to AT_* */ -#define AT_RST_EMERG 0x1 /* emergency - e.g. for a dump */ - int (*ata_exec_command)(struct ata_drive_datas *, struct ata_xfer *); @@ -421,9 +417,6 @@ struct ata_channel { #define ATACH_NODRIVE 0xff /* no drive selected for reset */ - /* for the reset callback */ - int ch_reset_flags; - /* for the timeout callout */ struct callout c_timo_callout; /* timeout callout handle */ Index: src/sys/dev/ata/wd.c diff -u src/sys/dev/ata/wd.c:1.441.2.10 src/sys/dev/ata/wd.c:1.441.2.11 ---
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Oct 6 20:13:12 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: ata.c Log Message: remove extra newline To generate a diff of this commit: cvs rdiff -u -r1.141.6.12 -r1.141.6.13 src/sys/dev/ata/ata.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/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.12 src/sys/dev/ata/ata.c:1.141.6.13 --- src/sys/dev/ata/ata.c:1.141.6.12 Sat Oct 6 20:12:37 2018 +++ src/sys/dev/ata/ata.c Sat Oct 6 20:13:12 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.12 2018/10/06 20:12:37 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.13 2018/10/06 20:13:12 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.12 2018/10/06 20:12:37 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.13 2018/10/06 20:13:12 jdolecek Exp $"); #include "opt_ata.h" @@ -1676,7 +1676,6 @@ ata_thread_run(struct ata_channel *chp, ata_channel_freeze_locked(chp); chp->ch_flags |= type; - cv_signal(>ch_thr_idle); return; }
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Oct 6 20:12:37 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: ata.c Log Message: fix ata_thread_run() for drive reset to set and check correct drive_flags To generate a diff of this commit: cvs rdiff -u -r1.141.6.11 -r1.141.6.12 src/sys/dev/ata/ata.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/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.11 src/sys/dev/ata/ata.c:1.141.6.12 --- src/sys/dev/ata/ata.c:1.141.6.11 Wed Oct 3 19:20:48 2018 +++ src/sys/dev/ata/ata.c Sat Oct 6 20:12:37 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.11 2018/10/03 19:20:48 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.12 2018/10/06 20:12:37 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.11 2018/10/03 19:20:48 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.12 2018/10/06 20:12:37 jdolecek Exp $"); #include "opt_ata.h" @@ -490,7 +490,7 @@ atabus_thread(void *arg) drvp = >ch_drive[i]; drv_reset_flags = drvp->drive_reset_flags; -if (drvp->drive_flags & ATACH_TH_DRIVE_RESET) { +if (drvp->drive_flags & ATA_DRIVE_TH_RESET) { ata_thread_run(chp, AT_WAIT | drv_reset_flags, ATACH_TH_DRIVE_RESET, i); @@ -1645,26 +1645,23 @@ ata_thread_run(struct ata_channel *chp, ATADEBUG_PRINT(("%s flags 0x%x ch_flags 0x%x\n", __func__, flags, chp->ch_flags), DEBUG_FUNCS | DEBUG_XFERS); if ((flags & (AT_POLL | AT_WAIT)) == 0) { - if (chp->ch_flags & type) { - /* No need to schedule a reset more than one time. */ - return; - } - - /* - * Block execution of other commands while reset is scheduled - * to a thread. - */ - ata_channel_freeze_locked(chp); - chp->ch_flags |= type; - - switch (type) { case ATACH_TH_RESET: + if (chp->ch_flags & ATACH_TH_RESET) { +/* No need to schedule another reset */ +return; + } chp->ch_reset_flags = flags & AT_RST_EMERG; break; case ATACH_TH_DRIVE_RESET: + KASSERT(drive <= chp->ch_ndrives); drvp = >ch_drive[drive]; - drvp->drive_flags |= ATACH_TH_DRIVE_RESET; + + if (drvp->drive_flags & ATA_DRIVE_TH_RESET) { +/* No need to schedule another reset */ +return; + } + drvp->drive_flags |= ATA_DRIVE_TH_RESET; drvp->drive_reset_flags = flags; break; default: @@ -1672,6 +1669,14 @@ ata_thread_run(struct ata_channel *chp, /* NOTREACHED */ } + /* + * Block execution of other commands while reset is scheduled + * to a thread. + */ + ata_channel_freeze_locked(chp); + chp->ch_flags |= type; + + cv_signal(>ch_thr_idle); return; }
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Oct 6 19:25:43 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: wd.c Log Message: fix dump to also hold channel lock for the drive reset To generate a diff of this commit: cvs rdiff -u -r1.441.2.9 -r1.441.2.10 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/wd.c diff -u src/sys/dev/ata/wd.c:1.441.2.9 src/sys/dev/ata/wd.c:1.441.2.10 --- src/sys/dev/ata/wd.c:1.441.2.9 Thu Oct 4 19:42:01 2018 +++ src/sys/dev/ata/wd.c Sat Oct 6 19:25:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.441.2.9 2018/10/04 19:42:01 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.441.2.10 2018/10/06 19:25:43 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441.2.9 2018/10/04 19:42:01 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441.2.10 2018/10/06 19:25:43 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -1492,8 +1492,11 @@ wd_dumpblocks(device_t dev, void *va, da /* Recalibrate, if first dump transfer. */ if (wddumprecalibrated == 0) { wddumprecalibrated = 1; - (*wd->atabus->ata_reset_drive)(wd->drvp, - AT_POLL | AT_RST_EMERG, NULL); + ata_channel_lock(wd->drvp->chnl_softc); + /* This will directly execute the reset due to AT_POLL */ + ata_thread_run(wd->drvp->chnl_softc, AT_POLL | AT_RST_EMERG, + ATACH_TH_DRIVE_RESET, wd->drvp->drive); + ata_channel_unlock(wd->drvp->chnl_softc); wd->drvp->state = RESET; }
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Thu Oct 4 19:42:01 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq wd.c Log Message: relax the NOERROR + C_CHAOS, just rerun the xfer instead of panic, to handle another variant of bad/missing AHCI error recovery, this time under Parallels To generate a diff of this commit: cvs rdiff -u -r1.4.2.10 -r1.4.2.11 src/sys/dev/ata/TODO.ncq cvs rdiff -u -r1.441.2.8 -r1.441.2.9 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.4.2.10 src/sys/dev/ata/TODO.ncq:1.4.2.11 --- src/sys/dev/ata/TODO.ncq:1.4.2.10 Wed Oct 3 19:20:48 2018 +++ src/sys/dev/ata/TODO.ncq Thu Oct 4 19:42:01 2018 @@ -1,6 +1,7 @@ jdolecek-ncqfixes goals: -- fix ahci(4) error handling under paralles - invalid bio via WD_CHAOS_MONKEY - ends up being handled as NOERROR, triggering KASSERT() in wd(4) +- re-check READ LOG EXT handling under native and Parallels to make sure + the NOERROR under Parallels is their bug and not ours +- run recovery via atathread, move to new function and share ahci/siisata/mvsata - remove controller-specific slot bitmaps (ic/siisata.c, ic/ahcisata_core.c) Bugs Index: src/sys/dev/ata/wd.c diff -u src/sys/dev/ata/wd.c:1.441.2.8 src/sys/dev/ata/wd.c:1.441.2.9 --- src/sys/dev/ata/wd.c:1.441.2.8 Thu Oct 4 17:53:23 2018 +++ src/sys/dev/ata/wd.c Thu Oct 4 19:42:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.441.2.8 2018/10/04 17:53:23 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.441.2.9 2018/10/04 19:42:01 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441.2.8 2018/10/04 17:53:23 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441.2.9 2018/10/04 19:42:01 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -914,13 +914,23 @@ out: bp->b_error = EIO; break; case NOERROR: +#ifdef WD_CHAOS_MONKEY + /* + * For example Parallels AHCI emulation doesn't actually + * return error for the invalid I/O, so just re-run + * the request and do not panic. + */ + if (__predict_false(xfer->c_flags & C_CHAOS)) { + xfer->c_bio.error = REQUEUE; + errmsg = "chaos noerror"; + goto retry2; + } +#endif + noerror: if ((xfer->c_bio.flags & ATA_CORR) || xfer->c_retries > 0) device_printf(dksc->sc_dev, "soft error (corrected) xfer %"PRIxPTR"\n", (intptr_t)xfer & PAGE_MASK); -#ifdef WD_CHAOS_MONKEY - KASSERT((xfer->c_flags & C_CHAOS) == 0); -#endif break; case ERR_NODEV: bp->b_error = EIO;
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Thu Oct 4 17:53:23 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: wd.c Log Message: don't add +1 to retry on error To generate a diff of this commit: cvs rdiff -u -r1.441.2.7 -r1.441.2.8 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/wd.c diff -u src/sys/dev/ata/wd.c:1.441.2.7 src/sys/dev/ata/wd.c:1.441.2.8 --- src/sys/dev/ata/wd.c:1.441.2.7 Wed Oct 3 19:20:48 2018 +++ src/sys/dev/ata/wd.c Thu Oct 4 17:53:23 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.441.2.7 2018/10/03 19:20:48 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.441.2.8 2018/10/04 17:53:23 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441.2.7 2018/10/03 19:20:48 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441.2.8 2018/10/04 17:53:23 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -853,7 +853,7 @@ retry2: if (xfer->c_retries < WDIORETRIES) printf(", xfer %"PRIxPTR", retry %d", (intptr_t)xfer & PAGE_MASK, - xfer->c_retries + 1); + xfer->c_retries); printf("\n"); if (do_perror) wdperror(wd, xfer);
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Sep 24 19:48:02 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq ata.c Log Message: replace KASSERT() for READ LOG EXT returning without error indication with just log to avoid triggering panic under QEMU - it doesn't implement the command for AHCI emulation To generate a diff of this commit: cvs rdiff -u -r1.4.2.8 -r1.4.2.9 src/sys/dev/ata/TODO.ncq cvs rdiff -u -r1.141.6.9 -r1.141.6.10 src/sys/dev/ata/ata.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.4.2.8 src/sys/dev/ata/TODO.ncq:1.4.2.9 --- src/sys/dev/ata/TODO.ncq:1.4.2.8 Sat Sep 22 17:52:24 2018 +++ src/sys/dev/ata/TODO.ncq Mon Sep 24 19:48:02 2018 @@ -1,9 +1,9 @@ jdolecek-ncqfixes goals: -- re-fix QEMU ahci(4) bug workaround (no READ LOG EXT support) - now it - triggers KASSERT() - fix ahci(4) error handling under paralles - invalid bio via WD_CHAOS_MONKEY ends up being handled as NOERROR, triggering KASSERT() in wd(4) - remove controller-specific slot bitmaps (ic/siisata.c, ic/ahcisata_core.c) +- revert rev 1.431 of wd.c (AT_POOL removal) - ensure still works + for the reset-via-thread case Bugs Index: src/sys/dev/ata/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.9 src/sys/dev/ata/ata.c:1.141.6.10 --- src/sys/dev/ata/ata.c:1.141.6.9 Sat Sep 22 16:14:25 2018 +++ src/sys/dev/ata/ata.c Mon Sep 24 19:48:02 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.9 2018/09/22 16:14:25 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.10 2018/09/24 19:48:02 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.9 2018/09/22 16:14:25 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.10 2018/09/24 19:48:02 jdolecek Exp $"); #include "opt_ata.h" @@ -972,7 +972,7 @@ ata_read_log_ext_ncq(struct ata_drive_da for (int i = 0; i < sizeof(drvp->recovery_blk); i++) cksum += tb[i]; if (cksum != 0) { - aprint_error_dev(drvp->drv_softc, + device_printf(drvp->drv_softc, "invalid checksum %x for READ LOG EXT page %x\n", cksum, page); rv = EINVAL; @@ -989,10 +989,20 @@ ata_read_log_ext_ncq(struct ata_drive_da *status = tb[2]; *err = tb[3]; - KASSERTMSG((*status & WDCS_ERR), - "%s: non-error command slot %d reported by READ LOG EXT page %x: " - "err %x status %x\n", - device_xname(drvp->drv_softc), *slot, page, *err, *status); + if ((*status & WDCS_ERR) == 0) { + /* + * We expect error here. Normal physical drives always + * do, it's part of ATA standard. However, QEMU AHCI emulation + * misehandles READ LOG EXT in a way that the command itself + * returns without error, but no data is transferred. + */ + device_printf(drvp->drv_softc, + "READ LOG EXT page %x failed to report error: " + "slot %d err %x status %x\n", + page, *slot, *err, *status); + rv = EOPNOTSUPP; + goto out; + } rv = 0; @@ -1460,7 +1470,7 @@ ata_timo_xfer_check(struct ata_xfer *xfe xfer->c_flags &= ~C_FREE; ata_channel_unlock(chp); - aprint_normal_dev(drvp->drv_softc, + device_printf(drvp->drv_softc, "xfer %p freed while invoking timeout\n", xfer); ata_free_xfer(chp, xfer); @@ -1470,7 +1480,7 @@ ata_timo_xfer_check(struct ata_xfer *xfe /* Race vs. callout_stop() in ata_deactivate_xfer() */ ata_channel_unlock(chp); - aprint_normal_dev(drvp->drv_softc, + device_printf(drvp->drv_softc, "xfer %p deactivated while invoking timeout\n", xfer); return true; }
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Sep 22 17:52:24 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq Log Message: one more To generate a diff of this commit: cvs rdiff -u -r1.4.2.7 -r1.4.2.8 src/sys/dev/ata/TODO.ncq 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.4.2.7 src/sys/dev/ata/TODO.ncq:1.4.2.8 --- src/sys/dev/ata/TODO.ncq:1.4.2.7 Sat Sep 22 17:50:09 2018 +++ src/sys/dev/ata/TODO.ncq Sat Sep 22 17:52:24 2018 @@ -3,6 +3,7 @@ jdolecek-ncqfixes goals: triggers KASSERT() - fix ahci(4) error handling under paralles - invalid bio via WD_CHAOS_MONKEY ends up being handled as NOERROR, triggering KASSERT() in wd(4) +- remove controller-specific slot bitmaps (ic/siisata.c, ic/ahcisata_core.c) Bugs
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Sep 22 17:50:09 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq ata_subr.c atavar.h wd.c wdvar.h Log Message: remove explicit ata_channel_start() calls, it's no longer necessary now that ata_xfer's are allocated via pool and not really limited; replace by just a callout to restart the processing for rare cases where system runs out of memory To generate a diff of this commit: cvs rdiff -u -r1.4.2.6 -r1.4.2.7 src/sys/dev/ata/TODO.ncq cvs rdiff -u -r1.6.2.5 -r1.6.2.6 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.99.2.6 -r1.99.2.7 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.441.2.5 -r1.441.2.6 src/sys/dev/ata/wd.c cvs rdiff -u -r1.46.6.3 -r1.46.6.4 src/sys/dev/ata/wdvar.h 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.4.2.6 src/sys/dev/ata/TODO.ncq:1.4.2.7 --- src/sys/dev/ata/TODO.ncq:1.4.2.6 Sat Sep 22 16:14:25 2018 +++ src/sys/dev/ata/TODO.ncq Sat Sep 22 17:50:09 2018 @@ -1,6 +1,4 @@ jdolecek-ncqfixes goals: -- add to wd(4) a callout to restart buf queue processing when ata_get_xfer() - call fails and remove ata_channel_start() - re-fix QEMU ahci(4) bug workaround (no READ LOG EXT support) - now it triggers KASSERT() - fix ahci(4) error handling under paralles - invalid bio via WD_CHAOS_MONKEY Index: src/sys/dev/ata/ata_subr.c diff -u src/sys/dev/ata/ata_subr.c:1.6.2.5 src/sys/dev/ata/ata_subr.c:1.6.2.6 --- src/sys/dev/ata/ata_subr.c:1.6.2.5 Sat Sep 22 09:22:59 2018 +++ src/sys/dev/ata/ata_subr.c Sat Sep 22 17:50:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.6.2.5 2018/09/22 09:22:59 jdolecek Exp $ */ +/* $NetBSD: ata_subr.c,v 1.6.2.6 2018/09/22 17:50:09 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.6.2.5 2018/09/22 09:22:59 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.6.2.6 2018/09/22 17:50:09 jdolecek Exp $"); #include "opt_ata.h" @@ -257,54 +257,6 @@ ata_timeout(void *v) splx(s); } -/* - * Must be called without any locks, i.e. with both drive and channel locks - * released. - */ -void -ata_channel_start(struct ata_channel *chp, int drive, bool start_self) -{ - int i, s; - struct ata_drive_datas *drvp; - - s = splbio(); - - KASSERT(chp->ch_ndrives > 0); - -#define ATA_DRIVE_START(chp, drive) \ - do { \ - KASSERT(drive < chp->ch_ndrives); \ - drvp = >ch_drive[drive]; \ -\ - if (drvp->drive_type != ATA_DRIVET_ATA && \ - drvp->drive_type != ATA_DRIVET_ATAPI && \ - drvp->drive_type != ATA_DRIVET_OLD) \ - continue;\ -\ - if (drvp->drv_start != NULL) \ - (*drvp->drv_start)(drvp->drv_softc); \ - } while (0) - - /* - * Process drives in round robin fashion starting with next one after - * the one which finished transfer. Thus no single drive would - * completely starve other drives on same channel. - * This loop processes all but the current drive, so won't do anything - * if there is only one drive in channel. - */ - for (i = (drive + 1) % chp->ch_ndrives; i != drive; - i = (i + 1) % chp->ch_ndrives) { - ATA_DRIVE_START(chp, i); - } - - /* Now try to kick off xfers on the current drive */ - if (start_self) - ATA_DRIVE_START(chp, drive); - - splx(s); -#undef ATA_DRIVE_START -} - void ata_channel_lock(struct ata_channel *chp) { Index: src/sys/dev/ata/atavar.h diff -u src/sys/dev/ata/atavar.h:1.99.2.6 src/sys/dev/ata/atavar.h:1.99.2.7 --- src/sys/dev/ata/atavar.h:1.99.2.6 Sat Sep 22 16:14:25 2018 +++ src/sys/dev/ata/atavar.h Sat Sep 22 17:50:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.99.2.6 2018/09/22 16:14:25 jdolecek Exp $ */ +/* $NetBSD: atavar.h,v 1.99.2.7 2018/09/22 17:50:09 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -327,7 +327,6 @@ struct ata_drive_datas { /* Callbacks into the drive's driver. */ void (*drv_done)(device_t, struct ata_xfer *); /* xfer is done */ - void (*drv_start)(device_t); /* start queue */ device_t drv_softc; /* ATA drives softc, if any */ struct ata_channel *chnl_softc; /* channel softc */ @@ -547,7 +546,6 @@ void ata_kill_active(struct ata_channel void ata_reset_channel(struct ata_channel *, int); void ata_channel_freeze(struct ata_channel *); void ata_channel_thaw(struct ata_channel *); -void ata_channel_start(struct ata_channel *, int, bool); void ata_channel_lock(struct ata_channel *); void ata_channel_unlock(struct ata_channel *); void ata_channel_lock_owned(struct ata_channel *); Index: src/sys/dev/ata/wd.c diff -u src/sys/dev/ata/wd.c:1.441.2.5 src/sys/dev/ata/wd.c:1.441.2.6 --- src/sys/dev/ata/wd.c:1.441.2.5 Sat Sep 22 16:14:25 2018 +++ src/sys/dev/ata/wd.c Sat Sep 22 17:50:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.441.2.5 2018/09/22
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Sep 22 16:14:25 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq ata.c atavar.h wd.c wdvar.h Log Message: fix use-after-free in wd(4) dump, detected by switch to the pool change code in wd_dumpblocks() to use it's own non-pool ata_xfer, which skips the deallocation step and thus keeps the contents when the I/O is finished To generate a diff of this commit: cvs rdiff -u -r1.4.2.5 -r1.4.2.6 src/sys/dev/ata/TODO.ncq cvs rdiff -u -r1.141.6.8 -r1.141.6.9 src/sys/dev/ata/ata.c cvs rdiff -u -r1.99.2.5 -r1.99.2.6 src/sys/dev/ata/atavar.h cvs rdiff -u -r1.441.2.4 -r1.441.2.5 src/sys/dev/ata/wd.c cvs rdiff -u -r1.46.6.2 -r1.46.6.3 src/sys/dev/ata/wdvar.h 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.4.2.5 src/sys/dev/ata/TODO.ncq:1.4.2.6 --- src/sys/dev/ata/TODO.ncq:1.4.2.5 Sat Sep 22 09:26:48 2018 +++ src/sys/dev/ata/TODO.ncq Sat Sep 22 16:14:25 2018 @@ -1,8 +1,6 @@ jdolecek-ncqfixes goals: - add to wd(4) a callout to restart buf queue processing when ata_get_xfer() call fails and remove ata_channel_start() -- change wd(4) dump code to use preallocated or on-stack ata_xfer to not rely - on pool having memory - re-fix QEMU ahci(4) bug workaround (no READ LOG EXT support) - now it triggers KASSERT() - fix ahci(4) error handling under paralles - invalid bio via WD_CHAOS_MONKEY Index: src/sys/dev/ata/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.8 src/sys/dev/ata/ata.c:1.141.6.9 --- src/sys/dev/ata/ata.c:1.141.6.8 Sat Sep 22 12:20:31 2018 +++ src/sys/dev/ata/ata.c Sat Sep 22 16:14:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.8 2018/09/22 12:20:31 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.9 2018/09/22 16:14:25 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.8 2018/09/22 12:20:31 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.9 2018/09/22 16:14:25 jdolecek Exp $"); #include "opt_ata.h" @@ -1350,7 +1350,7 @@ ata_free_xfer(struct ata_channel *chp, s ata_channel_lock(chp); - if (xfer->c_flags & (C_WAITACT|C_WAITTIMO)) { + if (__predict_false(xfer->c_flags & (C_WAITACT|C_WAITTIMO))) { /* Someone is waiting for this xfer, so we can't free now */ xfer->c_flags |= C_FREE; cv_broadcast(>c_active); @@ -1360,7 +1360,7 @@ ata_free_xfer(struct ata_channel *chp, s /* XXX move PIOBM and free_gw to deactivate? */ #if NATA_PIOBM /* XXX wdc dependent code */ - if (xfer->c_flags & C_PIOBM) { + if (__predict_false(xfer->c_flags & C_PIOBM)) { struct wdc_softc *wdc = CHAN_TO_WDC(chp); /* finish the busmastering PIO */ @@ -1375,7 +1375,8 @@ ata_free_xfer(struct ata_channel *chp, s ata_channel_unlock(chp); - pool_put(_xfer_pool, xfer); + if (__predict_true(!ISSET(xfer->c_flags, C_PRIVATE_ALLOC))) + pool_put(_xfer_pool, xfer); } void Index: src/sys/dev/ata/atavar.h diff -u src/sys/dev/ata/atavar.h:1.99.2.5 src/sys/dev/ata/atavar.h:1.99.2.6 --- src/sys/dev/ata/atavar.h:1.99.2.5 Sat Sep 22 09:22:59 2018 +++ src/sys/dev/ata/atavar.h Sat Sep 22 16:14:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.99.2.5 2018/09/22 09:22:59 jdolecek Exp $ */ +/* $NetBSD: atavar.h,v 1.99.2.6 2018/09/22 16:14:25 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. @@ -198,6 +198,7 @@ struct ata_xfer_ops { #define C_WAITTIMO 0x0400 /* race vs. timeout */ #define C_CHAOS 0x0800 /* forced error xfer */ #define C_RECOVERED 0x1000 /* error recovered, no need for reset */ +#define C_PRIVATE_ALLOC 0x2000 /* private alloc, skip pool_put() */ /* reasons for c_kill_xfer() */ #define KILL_GONE 1 /* device is gone while xfer was active */ Index: src/sys/dev/ata/wd.c diff -u src/sys/dev/ata/wd.c:1.441.2.4 src/sys/dev/ata/wd.c:1.441.2.5 --- src/sys/dev/ata/wd.c:1.441.2.4 Sat Sep 22 09:22:59 2018 +++ src/sys/dev/ata/wd.c Sat Sep 22 16:14:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.441.2.4 2018/09/22 09:22:59 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.441.2.5 2018/09/22 16:14:25 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441.2.4 2018/09/22 09:22:59 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441.2.5 2018/09/22 16:14:25 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -1458,7 +1458,7 @@ wd_dumpblocks(device_t dev, void *va, da struct wd_softc *wd = device_private(dev); struct dk_softc *dksc = >sc_dksc; struct disk_geom *dg = >sc_dkdev.dk_geom; - struct ata_xfer *xfer; + struct ata_xfer *xfer = >dump_xfer; int err; /* Recalibrate, if first dump transfer. */ @@ -1469,11 +1469,8 @@ wd_dumpblocks(device_t dev, void *va, da
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Sep 22 12:20:32 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: ata.c Log Message: revert atabus_alloc_drives() to use KM_NOSLEEP again - it's called with ch_lock held hence cannot actually sleep, fixing is out of scope of the branch To generate a diff of this commit: cvs rdiff -u -r1.141.6.7 -r1.141.6.8 src/sys/dev/ata/ata.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/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.7 src/sys/dev/ata/ata.c:1.141.6.8 --- src/sys/dev/ata/ata.c:1.141.6.7 Sat Sep 22 09:26:48 2018 +++ src/sys/dev/ata/ata.c Sat Sep 22 12:20:31 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.7 2018/09/22 09:26:48 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.8 2018/09/22 12:20:31 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.7 2018/09/22 09:26:48 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.8 2018/09/22 12:20:31 jdolecek Exp $"); #include "opt_ata.h" @@ -719,7 +719,7 @@ atabus_alloc_drives(struct ata_channel * atabus_free_drives(chp); if (chp->ch_drive == NULL) { chp->ch_drive = kmem_zalloc( - sizeof(struct ata_drive_datas) * ndrives, KM_SLEEP); + sizeof(struct ata_drive_datas) * ndrives, KM_NOSLEEP); } if (chp->ch_drive == NULL) { aprint_error_dev(chp->ch_atac->atac_dev,
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Sep 22 09:26:49 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq ata.c Log Message: use KM_SLEEP in atabus_alloc_drives() to avoid spurious failures; this is not called from interrupt context To generate a diff of this commit: cvs rdiff -u -r1.4.2.4 -r1.4.2.5 src/sys/dev/ata/TODO.ncq cvs rdiff -u -r1.141.6.6 -r1.141.6.7 src/sys/dev/ata/ata.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.4.2.4 src/sys/dev/ata/TODO.ncq:1.4.2.5 --- src/sys/dev/ata/TODO.ncq:1.4.2.4 Sat Sep 22 09:22:59 2018 +++ src/sys/dev/ata/TODO.ncq Sat Sep 22 09:26:48 2018 @@ -7,7 +7,6 @@ jdolecek-ncqfixes goals: triggers KASSERT() - fix ahci(4) error handling under paralles - invalid bio via WD_CHAOS_MONKEY ends up being handled as NOERROR, triggering KASSERT() in wd(4) -- weed out remaining KM_NOSLEEP Bugs Index: src/sys/dev/ata/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.6 src/sys/dev/ata/ata.c:1.141.6.7 --- src/sys/dev/ata/ata.c:1.141.6.6 Sat Sep 22 09:22:59 2018 +++ src/sys/dev/ata/ata.c Sat Sep 22 09:26:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.6 2018/09/22 09:22:59 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.7 2018/09/22 09:26:48 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.6 2018/09/22 09:22:59 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.7 2018/09/22 09:26:48 jdolecek Exp $"); #include "opt_ata.h" @@ -719,7 +719,7 @@ atabus_alloc_drives(struct ata_channel * atabus_free_drives(chp); if (chp->ch_drive == NULL) { chp->ch_drive = kmem_zalloc( - sizeof(struct ata_drive_datas) * ndrives, KM_NOSLEEP); + sizeof(struct ata_drive_datas) * ndrives, KM_SLEEP); } if (chp->ch_drive == NULL) { aprint_error_dev(chp->ch_atac->atac_dev,
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Sep 17 20:54:41 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq ata.c ata_raid.c ata_raid_adaptec.c ata_raid_intel.c ata_raid_jmicron.c ata_raid_nvidia.c ata_raid_promise.c ata_raid_via.c ata_subr.c ata_wdc.c ld_ataraid.c wd.c Log Message: convert from malloc()/free() to kmem_zalloc()/kmem_free() To generate a diff of this commit: cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/dev/ata/TODO.ncq cvs rdiff -u -r1.141.6.4 -r1.141.6.5 src/sys/dev/ata/ata.c cvs rdiff -u -r1.40 -r1.40.4.1 src/sys/dev/ata/ata_raid.c cvs rdiff -u -r1.10 -r1.10.6.1 src/sys/dev/ata/ata_raid_adaptec.c cvs rdiff -u -r1.8 -r1.8.6.1 src/sys/dev/ata/ata_raid_intel.c \ src/sys/dev/ata/ata_raid_via.c cvs rdiff -u -r1.6 -r1.6.6.1 src/sys/dev/ata/ata_raid_jmicron.c cvs rdiff -u -r1.3 -r1.3.6.1 src/sys/dev/ata/ata_raid_nvidia.c cvs rdiff -u -r1.12 -r1.12.6.1 src/sys/dev/ata/ata_raid_promise.c cvs rdiff -u -r1.6.2.3 -r1.6.2.4 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.110.4.2 -r1.110.4.3 src/sys/dev/ata/ata_wdc.c cvs rdiff -u -r1.45 -r1.45.4.1 src/sys/dev/ata/ld_ataraid.c cvs rdiff -u -r1.441.2.2 -r1.441.2.3 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.4.2.2 src/sys/dev/ata/TODO.ncq:1.4.2.3 --- src/sys/dev/ata/TODO.ncq:1.4.2.2 Fri Aug 31 19:23:54 2018 +++ src/sys/dev/ata/TODO.ncq Mon Sep 17 20:54:41 2018 @@ -1,6 +1,7 @@ jdolecek-ncqfixes goals: - make ata_xfer dynamically allocated using a pool - - fixes: queue is allocated regardless if there are any drives, fix? + - will fix: queue is allocated regardless if there are any drives, fix? + - malloc() -> kmem_zalloc() in ata_queue_alloc() once this is done - remove limit of queued ata_xfers, allow any number of pending xfers; this should fix kern/52614 AKA wdc-attached ATAPI cd(4) - remove the wd(4) flush condition, just allocate a dynamic ata_xfer Index: src/sys/dev/ata/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.4 src/sys/dev/ata/ata.c:1.141.6.5 --- src/sys/dev/ata/ata.c:1.141.6.4 Mon Sep 17 19:00:43 2018 +++ src/sys/dev/ata/ata.c Mon Sep 17 20:54:41 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.4 2018/09/17 19:00:43 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.5 2018/09/17 20:54:41 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,14 +25,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.4 2018/09/17 19:00:43 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.5 2018/09/17 20:54:41 jdolecek Exp $"); #include "opt_ata.h" #include #include #include -#include #include #include #include @@ -292,7 +291,7 @@ atabusconfig(struct atabus_softc *atabus cv_broadcast(_qcv); mutex_exit(_qlock); - free(atabus_initq, M_DEVBUF); + kmem_free(atabus_initq, sizeof(*atabus_initq)); ata_delref(chp); @@ -418,7 +417,7 @@ atabusconfig_thread(void *arg) cv_broadcast(_qcv); mutex_exit(_qlock); - free(atabus_initq, M_DEVBUF); + kmem_free(atabus_initq, sizeof(*atabus_initq)); ata_delref(chp); @@ -569,7 +568,7 @@ atabus_attach(device_t parent, device_t RUN_ONCE(_init_ctrl, atabus_init); - initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK); + initq = kmem_zalloc(sizeof(*initq), KM_SLEEP); initq->atabus_sc = sc; mutex_enter(_qlock); TAILQ_INSERT_TAIL(_initq_head, initq, atabus_initq); @@ -716,9 +715,8 @@ atabus_alloc_drives(struct ata_channel * if (chp->ch_ndrives != ndrives) atabus_free_drives(chp); if (chp->ch_drive == NULL) { - chp->ch_drive = malloc( - sizeof(struct ata_drive_datas) * ndrives, - M_DEVBUF, M_NOWAIT | M_ZERO); + chp->ch_drive = kmem_zalloc( + sizeof(struct ata_drive_datas) * ndrives, KM_NOSLEEP); } if (chp->ch_drive == NULL) { aprint_error_dev(chp->ch_atac->atac_dev, @@ -761,8 +759,9 @@ atabus_free_drives(struct ata_channel *c if (chp->ch_drive == NULL) return; + kmem_free(chp->ch_drive, + sizeof(struct ata_drive_datas) * chp->ch_ndrives); chp->ch_ndrives = 0; - free(chp->ch_drive, M_DEVBUF); chp->ch_drive = NULL; } @@ -2218,7 +2217,7 @@ atabus_rescan(device_t self, const char } } - initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK); + initq = kmem_zalloc(sizeof(*initq), KM_SLEEP); initq->atabus_sc = sc; mutex_enter(_qlock); TAILQ_INSERT_TAIL(_initq_head, initq, atabus_initq); Index: src/sys/dev/ata/ata_raid.c diff -u src/sys/dev/ata/ata_raid.c:1.40 src/sys/dev/ata/ata_raid.c:1.40.4.1 --- src/sys/dev/ata/ata_raid.c:1.40 Fri Jun 22 09:06:04 2018 +++ src/sys/dev/ata/ata_raid.c Mon Sep 17 20:54:41 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_raid.c,v 1.40 2018/06/22 09:06:04 pgoyette Exp $ */ +/* $NetBSD: ata_raid.c,v 1.40.4.1 2018/09/17 20:54:41 jdolecek Exp $ */ /* * Copyright (c) 2003 Wasabi
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Mon Sep 17 19:00:43 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: ata.c ata_subr.c atavar.h Log Message: switch from TAILQ to SIMPLEQ for ata_xfer pending queue to save space, don't need doubly linked queue To generate a diff of this commit: cvs rdiff -u -r1.141.6.3 -r1.141.6.4 src/sys/dev/ata/ata.c cvs rdiff -u -r1.6.2.2 -r1.6.2.3 src/sys/dev/ata/ata_subr.c cvs rdiff -u -r1.99.2.2 -r1.99.2.3 src/sys/dev/ata/atavar.h 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/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.3 src/sys/dev/ata/ata.c:1.141.6.4 --- src/sys/dev/ata/ata.c:1.141.6.3 Mon Sep 17 18:36:13 2018 +++ src/sys/dev/ata/ata.c Mon Sep 17 19:00:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.3 2018/09/17 18:36:13 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.4 2018/09/17 19:00:43 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.3 2018/09/17 18:36:13 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.4 2018/09/17 19:00:43 jdolecek Exp $"); #include "opt_ata.h" @@ -1062,10 +1062,10 @@ ata_exec_xfer(struct ata_channel *chp, s * recovery commands must be run immediatelly. */ if ((xfer->c_flags & C_RECOVERY) == 0) - TAILQ_INSERT_TAIL(>ch_queue->queue_xfer, xfer, + SIMPLEQ_INSERT_TAIL(>ch_queue->queue_xfer, xfer, c_xferchain); else - TAILQ_INSERT_HEAD(>ch_queue->queue_xfer, xfer, + SIMPLEQ_INSERT_HEAD(>ch_queue->queue_xfer, xfer, c_xferchain); /* @@ -1073,7 +1073,7 @@ ata_exec_xfer(struct ata_channel *chp, s */ if ((xfer->c_flags & (C_POLL | C_WAIT)) == (C_POLL | C_WAIT)) { while (chp->ch_queue->queue_active > 0 || - TAILQ_FIRST(>ch_queue->queue_xfer) != xfer) { + SIMPLEQ_FIRST(>ch_queue->queue_xfer) != xfer) { xfer->c_flags |= C_WAITACT; cv_wait(>ch_queue->c_active, >ch_lock); xfer->c_flags &= ~C_WAITACT; @@ -1137,7 +1137,7 @@ again: } /* is there a xfer ? */ - if ((xfer = TAILQ_FIRST(>ch_queue->queue_xfer)) == NULL) { + if ((xfer = SIMPLEQ_FIRST(>ch_queue->queue_xfer)) == NULL) { ATADEBUG_PRINT(("%s(chp=%p): channel %d queue_xfer is empty\n", __func__, chp, chp->ch_channel), DEBUG_XFERS); goto out; @@ -1207,6 +1207,8 @@ again: else CLR(chp->ch_flags, ATACH_NCQ); + SIMPLEQ_REMOVE_HEAD(>queue_xfer, c_xferchain); + ata_activate_xfer_locked(chp, xfer); if (atac->atac_cap & ATAC_CAP_NOIRQ) @@ -1275,7 +1277,6 @@ ata_activate_xfer_locked(struct ata_chan KASSERT(chq->queue_active < chq->queue_openings); KASSERT((chq->active_xfers_used & __BIT(xfer->c_slot)) == 0); - TAILQ_REMOVE(>queue_xfer, xfer, c_xferchain); if ((xfer->c_flags & C_RECOVERY) == 0) TAILQ_INSERT_TAIL(>active_xfers, xfer, c_activechain); else { @@ -1419,18 +1420,18 @@ ata_kill_pending(struct ata_drive_datas { struct ata_channel * const chp = drvp->chnl_softc; struct ata_queue * const chq = chp->ch_queue; - struct ata_xfer *xfer, *xfernext; + struct ata_xfer *xfer; ata_channel_lock(chp); /* Kill all pending transfers */ - TAILQ_FOREACH_SAFE(xfer, >queue_xfer, c_xferchain, xfernext) { + while ((xfer = SIMPLEQ_FIRST(>queue_xfer))) { KASSERT(xfer->c_chp == chp); if (xfer->c_drive != drvp->drive) continue; - TAILQ_REMOVE(>ch_queue->queue_xfer, xfer, c_xferchain); + SIMPLEQ_REMOVE_HEAD(>ch_queue->queue_xfer, c_xferchain); /* * Keep the lock, so that we get deadlock (and 'locking against Index: src/sys/dev/ata/ata_subr.c diff -u src/sys/dev/ata/ata_subr.c:1.6.2.2 src/sys/dev/ata/ata_subr.c:1.6.2.3 --- src/sys/dev/ata/ata_subr.c:1.6.2.2 Mon Sep 17 18:36:13 2018 +++ src/sys/dev/ata/ata_subr.c Mon Sep 17 19:00:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.6.2.2 2018/09/17 18:36:13 jdolecek Exp $ */ +/* $NetBSD: ata_subr.c,v 1.6.2.3 2018/09/17 19:00:43 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.6.2.2 2018/09/17 18:36:13 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.6.2.3 2018/09/17 19:00:43 jdolecek Exp $"); #include "opt_ata.h" @@ -70,7 +70,7 @@ void ata_queue_reset(struct ata_queue *chq) { /* make sure that we can use polled commands */ - TAILQ_INIT(>queue_xfer); + SIMPLEQ_INIT(>queue_xfer); TAILQ_INIT(>active_xfers); chq->queue_freeze = 0; chq->queue_active = 0; Index: src/sys/dev/ata/atavar.h diff -u src/sys/dev/ata/atavar.h:1.99.2.2 src/sys/dev/ata/atavar.h:1.99.2.3 --- src/sys/dev/ata/atavar.h:1.99.2.2 Mon Sep 17 18:36:13 2018 +++ src/sys/dev/ata/atavar.h Mon Sep 17 19:00:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: atavar.h,v 1.99.2.2 2018/09/17 18:36:13 jdolecek Exp $ */ +/* $NetBSD: atavar.h,v 1.99.2.3 2018/09/17 19:00:43
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Sat Sep 1 09:48:32 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: ata.c wd.c Log Message: stop assuming c_slot is immutable, use the xfer pointer rather than c_slot in printfs() To generate a diff of this commit: cvs rdiff -u -r1.141.6.1 -r1.141.6.2 src/sys/dev/ata/ata.c cvs rdiff -u -r1.441.2.1 -r1.441.2.2 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/ata.c diff -u src/sys/dev/ata/ata.c:1.141.6.1 src/sys/dev/ata/ata.c:1.141.6.2 --- src/sys/dev/ata/ata.c:1.141.6.1 Fri Aug 31 19:08:03 2018 +++ src/sys/dev/ata/ata.c Sat Sep 1 09:48:32 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.141.6.1 2018/08/31 19:08:03 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.141.6.2 2018/09/01 09:48:32 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.1 2018/08/31 19:08:03 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.2 2018/09/01 09:48:32 jdolecek Exp $"); #include "opt_ata.h" @@ -1370,8 +1370,7 @@ ata_timo_xfer_check(struct ata_xfer *xfe ata_channel_unlock(chp); aprint_normal_dev(drvp->drv_softc, - "xfer %d freed while invoking timeout\n", - xfer->c_slot); + "xfer %p freed while invoking timeout\n", xfer); ata_free_xfer(chp, xfer); return true; @@ -1381,8 +1380,7 @@ ata_timo_xfer_check(struct ata_xfer *xfe ata_channel_unlock(chp); aprint_normal_dev(drvp->drv_softc, - "xfer %d deactivated while invoking timeout\n", - xfer->c_slot); + "xfer %p deactivated while invoking timeout\n", xfer); return true; } Index: src/sys/dev/ata/wd.c diff -u src/sys/dev/ata/wd.c:1.441.2.1 src/sys/dev/ata/wd.c:1.441.2.2 --- src/sys/dev/ata/wd.c:1.441.2.1 Fri Aug 31 19:08:03 2018 +++ src/sys/dev/ata/wd.c Sat Sep 1 09:48:32 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wd.c,v 1.441.2.1 2018/08/31 19:08:03 jdolecek Exp $ */ +/* $NetBSD: wd.c,v 1.441.2.2 2018/09/01 09:48:32 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -54,7 +54,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441.2.1 2018/08/31 19:08:03 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.441.2.2 2018/09/01 09:48:32 jdolecek Exp $"); #include "opt_ata.h" #include "opt_wd.h" @@ -660,8 +660,8 @@ wdstart1(struct wd_softc *wd, struct buf */ if (BUF_ISREAD(bp) && xfer->c_retries == 0 && wd->drv_chaos_freq > 0 && (++wd->drv_chaos_cnt % wd->drv_chaos_freq) == 0) { - aprint_normal_dev(dksc->sc_dev, "%s: chaos xfer %d\n", - __func__, xfer->c_slot); + aprint_normal_dev(dksc->sc_dev, "%s: chaos xfer %p\n", + __func__, xfer); xfer->c_bio.blkno = 777 + wd->sc_capacity; xfer->c_flags |= C_CHAOS; } @@ -852,7 +852,7 @@ retry2: diskerr(bp, "wd", errmsg, LOG_PRINTF, xfer->c_bio.blkdone, dksc->sc_dkdev.dk_label); if (xfer->c_retries < WDIORETRIES) - printf(", slot %d, retry %d", xfer->c_slot, + printf(", xfer %p, retry %d", xfer, xfer->c_retries + 1); printf("\n"); if (do_perror) @@ -916,7 +916,7 @@ out: case NOERROR: noerror: if ((xfer->c_bio.flags & ATA_CORR) || xfer->c_retries > 0) aprint_error_dev(dksc->sc_dev, - "soft error (corrected) slot %d\n", xfer->c_slot); + "soft error (corrected) xfer %p\n", xfer); #ifdef WD_CHAOS_MONKEY KASSERT((xfer->c_flags & C_CHAOS) == 0); #endif
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Fri Aug 31 19:23:54 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq Log Message: fix comment - dynamically allocated yes, per-drive not To generate a diff of this commit: cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/sys/dev/ata/TODO.ncq 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.4.2.1 src/sys/dev/ata/TODO.ncq:1.4.2.2 --- src/sys/dev/ata/TODO.ncq:1.4.2.1 Fri Aug 31 19:15:04 2018 +++ src/sys/dev/ata/TODO.ncq Fri Aug 31 19:23:54 2018 @@ -1,5 +1,5 @@ jdolecek-ncqfixes goals: -- make ata_xfer dynamically allocated per-drive using a pool +- make ata_xfer dynamically allocated using a pool - fixes: queue is allocated regardless if there are any drives, fix? - remove limit of queued ata_xfers, allow any number of pending xfers; this should fix kern/52614 AKA wdc-attached ATAPI cd(4)
CVS commit: [jdolecek-ncqfixes] src/sys/dev/ata
Module Name:src Committed By: jdolecek Date: Fri Aug 31 19:15:04 UTC 2018 Modified Files: src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq Log Message: list goals for the jdolecek-ncqfixes branch To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.4.2.1 src/sys/dev/ata/TODO.ncq 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.4 src/sys/dev/ata/TODO.ncq:1.4.2.1 --- src/sys/dev/ata/TODO.ncq:1.4 Fri Aug 31 18:44:04 2018 +++ src/sys/dev/ata/TODO.ncq Fri Aug 31 19:15:04 2018 @@ -1,3 +1,16 @@ +jdolecek-ncqfixes goals: +- make ata_xfer dynamically allocated per-drive using a pool + - fixes: queue is allocated regardless if there are any drives, fix? +- remove limit of queued ata_xfers, allow any number of pending xfers; + this should fix kern/52614 AKA wdc-attached ATAPI cd(4) +- remove the wd(4) flush condition, just allocate a dynamic ata_xfer +- change wd(4) dump code to use on-stack ata_xfer to not rely on pool having + memory +- re-fix QEMU ahci(4) bug workaround (no READ LOG EXT support) - now it + triggers KASSERT() +- fix ahci(4) error handling under paralles - invalid bio via WD_CHAOS_MONKEY + ends up being handled as NOERROR, triggering KASSERT() in wd(4) + Bugs test wd* at umass?, confirm the ata_channel kludge works @@ -15,8 +28,6 @@ xfers for several different drives maybe do device error handling in not-interrupt-context (maybe this should be done on a mpata branch?) -queue is allocated regardless if there are any drives, fix? - dump to unopened disk fails (e.g. dump do wd1b when wd1a not mounted), due to the open path executing ata_get_params(), which eventually tsleeps() while waiting for the command to finish; specifically, if WDF_LOADED is not