Module Name: src
Committed By: jdolecek
Date: Mon Oct 15 21:18:53 UTC 2018
Modified Files:
src/sys/dev/ata [jdolecek-ncqfixes]: TODO.ncq ata.c ata_recovery.c
ata_wdc.c atavar.h
src/sys/dev/ic [jdolecek-ncqfixes]: ahcisata_core.c mvsata.c siisata.c
src/sys/dev/usb [jdolecek-ncqfixes]: umass_isdata.c
Log Message:
change the SATA/NCQ recovery to run in the atabus thread
To generate a diff of this commit:
cvs rdiff -u -r1.4.2.14 -r1.4.2.15 src/sys/dev/ata/TODO.ncq
cvs rdiff -u -r1.141.6.17 -r1.141.6.18 src/sys/dev/ata/ata.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/dev/ata/ata_recovery.c
cvs rdiff -u -r1.110.4.3 -r1.110.4.4 src/sys/dev/ata/ata_wdc.c
cvs rdiff -u -r1.99.2.11 -r1.99.2.12 src/sys/dev/ata/atavar.h
cvs rdiff -u -r1.62.2.9 -r1.62.2.10 src/sys/dev/ic/ahcisata_core.c
cvs rdiff -u -r1.41.2.10 -r1.41.2.11 src/sys/dev/ic/mvsata.c
cvs rdiff -u -r1.35.6.9 -r1.35.6.10 src/sys/dev/ic/siisata.c
cvs rdiff -u -r1.36.6.1 -r1.36.6.2 src/sys/dev/usb/umass_isdata.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.14 src/sys/dev/ata/TODO.ncq:1.4.2.15
--- src/sys/dev/ata/TODO.ncq:1.4.2.14 Sun Oct 14 14:50:54 2018
+++ src/sys/dev/ata/TODO.ncq Mon Oct 15 21:18:53 2018
@@ -1,9 +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
-- 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?)
Bugs
----
Index: src/sys/dev/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.141.6.17 src/sys/dev/ata/ata.c:1.141.6.18
--- src/sys/dev/ata/ata.c:1.141.6.17 Sun Oct 14 16:13:51 2018
+++ src/sys/dev/ata/ata.c Mon Oct 15 21:18:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ata.c,v 1.141.6.17 2018/10/14 16:13:51 jdolecek Exp $ */
+/* $NetBSD: ata.c,v 1.141.6.18 2018/10/15 21:18:53 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.141.6.17 2018/10/14 16:13:51 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.141.6.18 2018/10/15 21:18:53 jdolecek Exp $");
#include "opt_ata.h"
@@ -129,7 +129,6 @@ static bool atabus_suspend(device_t, con
static void atabusconfig_thread(void *);
static void ata_channel_idle(struct ata_channel *);
-static void ata_channel_thaw_locked(struct ata_channel *);
static void ata_activate_xfer_locked(struct ata_channel *, struct ata_xfer *);
static void ata_channel_freeze_locked(struct ata_channel *);
static void ata_thread_wake_locked(struct ata_channel *);
@@ -463,7 +462,7 @@ atabus_thread(void *arg)
ata_channel_lock(chp);
for (;;) {
if ((chp->ch_flags & (ATACH_TH_RESET | ATACH_TH_DRIVE_RESET
- | ATACH_SHUTDOWN)) == 0 &&
+ | ATACH_TH_RECOVERY | ATACH_SHUTDOWN)) == 0 &&
(chq->queue_active == 0 || chq->queue_freeze == 0)) {
chp->ch_flags &= ~ATACH_TH_RUN;
cv_wait(&chp->ch_thr_idle, &chp->ch_lock);
@@ -483,6 +482,7 @@ atabus_thread(void *arg)
ata_thread_run(chp, AT_WAIT,
ATACH_TH_RESET, ATACH_NODRIVE);
} else if (chp->ch_flags & ATACH_TH_DRIVE_RESET) {
+ /* this will unfreeze the channel */
for (i = 0; i < chp->ch_ndrives; i++) {
struct ata_drive_datas *drvp;
@@ -494,6 +494,16 @@ atabus_thread(void *arg)
}
}
chp->ch_flags &= ~ATACH_TH_DRIVE_RESET;
+ } else if (chp->ch_flags & ATACH_TH_RECOVERY) {
+ /*
+ * This will unfreeze the channel; drops locks during
+ * run, so must wrap in splbio()/splx() to avoid
+ * spurious interrupts. XXX MPSAFE
+ */
+ int s = splbio();
+ ata_thread_run(chp, AT_WAIT, ATACH_TH_RECOVERY,
+ chp->recovery_tfd);
+ splx(s);
} else if (chq->queue_active > 0 && chq->queue_freeze == 1) {
/*
* Caller has bumped queue_freeze, decrease it. This
@@ -522,10 +532,12 @@ atabus_thread(void *arg)
} else if (chq->queue_freeze > 1)
panic("%s: queue_freeze", __func__);
- /* Try to run down the queue once after each event is handled */
- ata_channel_unlock(chp);
- atastart(chp);
- ata_channel_lock(chp);
+ /* Try to run down the queue once channel is unfrozen */
+ if (chq->queue_freeze == 0) {
+ ata_channel_unlock(chp);
+ atastart(chp);
+ ata_channel_lock(chp);
+ }
}
chp->ch_thread = NULL;
cv_signal(&chp->ch_thr_idle);
@@ -1499,7 +1511,7 @@ ata_channel_freeze(struct ata_channel *c
ata_channel_unlock(chp);
}
-static void
+void
ata_channel_thaw_locked(struct ata_channel *chp)
{
KASSERT(mutex_owned(&chp->ch_lock));
@@ -1511,21 +1523,13 @@ ata_channel_thaw_locked(struct ata_chann
chp->ch_queue->queue_freeze), DEBUG_FUNCS | DEBUG_XFERS);
}
-void
-ata_channel_thaw(struct ata_channel *chp)
-{
- ata_channel_lock(chp);
- ata_channel_thaw_locked(chp);
- ata_channel_unlock(chp);
-}
-
/*
* ata_thread_run:
*
- * Reset and ATA channel. Channel lock must be held.
+ * Reset and ATA channel. Channel lock must be held. arg is type-specific.
*/
void
-ata_thread_run(struct ata_channel *chp, int flags, int type, int drive)
+ata_thread_run(struct ata_channel *chp, int flags, int type, int arg)
{
struct atac_softc *atac = chp->ch_atac;
bool threset = false;
@@ -1548,6 +1552,9 @@ ata_thread_run(struct ata_channel *chp,
}
break;
case ATACH_TH_DRIVE_RESET:
+ {
+ int drive = arg;
+
KASSERT(drive <= chp->ch_ndrives);
drvp = &chp->ch_drive[drive];
@@ -1557,6 +1564,15 @@ ata_thread_run(struct ata_channel *chp,
}
drvp->drive_flags |= ATA_DRIVE_TH_RESET;
break;
+ }
+ case ATACH_TH_RECOVERY:
+ {
+ uint32_t tfd = (uint32_t)arg;
+
+ KASSERT((chp->ch_flags & ATACH_RECOVERING) == 0);
+ chp->recovery_tfd = tfd;
+ break;
+ }
default:
panic("%s: unknown type: %x", __func__, type);
/* NOTREACHED */
@@ -1591,16 +1607,33 @@ ata_thread_run(struct ata_channel *chp,
(*atac->atac_bustype_ata->ata_reset_channel)(chp, flags);
KASSERT(chp->ch_ndrives == 0 || chp->ch_drive != NULL);
- for (drive = 0; drive < chp->ch_ndrives; drive++)
+ for (int drive = 0; drive < chp->ch_ndrives; drive++)
chp->ch_drive[drive].state = 0;
break;
case ATACH_TH_DRIVE_RESET:
+ {
+ int drive = arg;
+
KASSERT(drive <= chp->ch_ndrives);
drvp = &chp->ch_drive[drive];
(*atac->atac_bustype_ata->ata_reset_drive)(drvp, flags, NULL);
drvp->state = 0;
break;
+ }
+
+ case ATACH_TH_RECOVERY:
+ {
+ uint32_t tfd = (uint32_t)arg;
+
+ KASSERT((chp->ch_flags & ATACH_RECOVERING) == 0);
+ KASSERT(atac->atac_bustype_ata->ata_recovery != NULL);
+
+ SET(chp->ch_flags, ATACH_RECOVERING);
+ (*atac->atac_bustype_ata->ata_recovery)(chp, flags, tfd);
+ CLR(chp->ch_flags, ATACH_RECOVERING);
+ break;
+ }
default:
panic("%s: unknown type: %x", __func__, type);
Index: src/sys/dev/ata/ata_recovery.c
diff -u src/sys/dev/ata/ata_recovery.c:1.1.2.1 src/sys/dev/ata/ata_recovery.c:1.1.2.2
--- src/sys/dev/ata/ata_recovery.c:1.1.2.1 Thu Oct 11 20:57:51 2018
+++ src/sys/dev/ata/ata_recovery.c Mon Oct 15 21:18:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_recovery.c,v 1.1.2.1 2018/10/11 20:57:51 jdolecek Exp $ */
+/* $NetBSD: ata_recovery.c,v 1.1.2.2 2018/10/15 21:18:53 jdolecek Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_recovery.c,v 1.1.2.1 2018/10/11 20:57:51 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_recovery.c,v 1.1.2.2 2018/10/15 21:18:53 jdolecek Exp $");
#include "opt_ata.h"
@@ -67,9 +67,9 @@ int
ata_read_log_ext_ncq(struct ata_drive_datas *drvp, uint8_t flags,
uint8_t *slot, uint8_t *status, uint8_t *err)
{
- struct ata_xfer *xfer = &drvp->recovery_xfer;
int rv;
struct ata_channel *chp = drvp->chnl_softc;
+ struct ata_xfer *xfer = &chp->recovery_xfer;
struct atac_softc *atac = chp->ch_atac;
uint8_t *tb, cksum, page;
@@ -82,8 +82,8 @@ ata_read_log_ext_ncq(struct ata_drive_da
memset(xfer, 0, sizeof(*xfer));
- tb = drvp->recovery_blk;
- memset(tb, 0, sizeof(drvp->recovery_blk));
+ tb = chp->recovery_blk;
+ memset(tb, 0, sizeof(chp->recovery_blk));
/*
* We could use READ LOG DMA EXT if drive supports it (i.e.
@@ -101,7 +101,7 @@ ata_read_log_ext_ncq(struct ata_drive_da
xfer->c_ata_c.flags = AT_READ | AT_LBA | AT_LBA48 | flags;
xfer->c_ata_c.timeout = 1000; /* 1s */
xfer->c_ata_c.data = tb;
- xfer->c_ata_c.bcount = sizeof(drvp->recovery_blk);
+ xfer->c_ata_c.bcount = sizeof(chp->recovery_blk);
if ((*atac->atac_bustype_ata->ata_exec_command)(drvp,
xfer) != ATACMD_COMPLETE) {
@@ -114,7 +114,7 @@ ata_read_log_ext_ncq(struct ata_drive_da
}
cksum = 0;
- for (int i = 0; i < sizeof(drvp->recovery_blk); i++)
+ for (int i = 0; i < sizeof(chp->recovery_blk); i++)
cksum += tb[i];
if (cksum != 0) {
device_printf(drvp->drv_softc,
@@ -167,13 +167,16 @@ ata_recovery_resume(struct ata_channel *
struct ata_xfer *xfer;
const uint8_t ch_openings = ata_queue_openings(chp);
- ata_channel_lock(chp);
+ ata_channel_lock_owned(chp);
+
ata_queue_hold(chp);
- ata_channel_unlock(chp);
KASSERT(drive < chp->ch_ndrives);
drvp = &chp->ch_drive[drive];
+ /* Drop the lock for the READ LOG EXT request */
+ ata_channel_unlock(chp);
+
/*
* When running NCQ commands, READ LOG EXT is necessary to clear the
* error condition and unblock the device.
@@ -243,5 +246,5 @@ ata_recovery_resume(struct ata_channel *
out:
/* Nothing more to do */
- return;
+ ata_channel_lock(chp);
}
Index: src/sys/dev/ata/ata_wdc.c
diff -u src/sys/dev/ata/ata_wdc.c:1.110.4.3 src/sys/dev/ata/ata_wdc.c:1.110.4.4
--- src/sys/dev/ata/ata_wdc.c:1.110.4.3 Mon Sep 17 20:54:41 2018
+++ src/sys/dev/ata/ata_wdc.c Mon Oct 15 21:18:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_wdc.c,v 1.110.4.3 2018/09/17 20:54:41 jdolecek Exp $ */
+/* $NetBSD: ata_wdc.c,v 1.110.4.4 2018/10/15 21:18:53 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer.
@@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.110.4.3 2018/09/17 20:54:41 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.110.4.4 2018/10/15 21:18:53 jdolecek Exp $");
#include "opt_ata.h"
#include "opt_wdc.h"
@@ -128,6 +128,7 @@ const struct ata_bustype wdc_ata_bustype
wdc_ata_addref,
wdc_ata_delref,
ata_kill_pending,
+ NULL,
};
static const struct ata_xfer_ops wdc_bio_xfer_ops = {
Index: src/sys/dev/ata/atavar.h
diff -u src/sys/dev/ata/atavar.h:1.99.2.11 src/sys/dev/ata/atavar.h:1.99.2.12
--- src/sys/dev/ata/atavar.h:1.99.2.11 Thu Oct 11 20:57:51 2018
+++ src/sys/dev/ata/atavar.h Mon Oct 15 21:18:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: atavar.h,v 1.99.2.11 2018/10/11 20:57:51 jdolecek Exp $ */
+/* $NetBSD: atavar.h,v 1.99.2.12 2018/10/15 21:18:53 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -337,10 +337,6 @@ struct ata_drive_datas {
struct disklabel *lp; /* pointer to drive's label info */
uint8_t multi; /* # of blocks to transfer in multi-mode */
daddr_t badsect[127]; /* 126 plus trailing -1 marker */
-
- /* Recovery buffer */
- struct ata_xfer recovery_xfer;
- uint8_t recovery_blk[ATA_BSIZE];
};
/* User config flags that force (or disable) the use of a mode */
@@ -377,6 +373,7 @@ struct ata_bustype {
int (*ata_addref)(struct ata_drive_datas *);
void (*ata_delref)(struct ata_drive_datas *);
void (*ata_killpending)(struct ata_drive_datas *);
+ void (*ata_recovery)(struct ata_channel *, int, uint32_t);
};
/* bustype_type */ /* XXX XXX XXX */
@@ -414,8 +411,9 @@ struct ata_channel {
#define ATACH_TH_RESCAN 0x400 /* rescan requested */
#define ATACH_NCQ 0x800 /* channel executing NCQ commands */
#define ATACH_DMA_BEFORE_CMD 0x1000 /* start DMA first */
-#define ATACH_TH_DRIVE_RESET 0x2000 /* thread asked for drive(s) reset */
+#define ATACH_TH_DRIVE_RESET 0x2000 /* asked thread to drive(s) reset */
#define ATACH_RECOVERING 0x4000 /* channel is recovering */
+#define ATACH_TH_RECOVERY 0x8000 /* asked thread to run recovery */
#define ATACH_NODRIVE 0xff /* no drive selected for reset */
@@ -444,6 +442,11 @@ struct ata_channel {
/* Number of sata PMP ports, if any */
int ch_satapmp_nports;
+
+ /* Recovery buffer */
+ struct ata_xfer recovery_xfer;
+ uint8_t recovery_blk[ATA_BSIZE];
+ uint32_t recovery_tfd; /* status/err encoded ATACH_ERR_ST() */
};
/*
@@ -546,7 +549,7 @@ void ata_kill_pending(struct ata_drive_d
void ata_kill_active(struct ata_channel *, int, int);
void ata_thread_run(struct ata_channel *, int, int, int);
void ata_channel_freeze(struct ata_channel *);
-void ata_channel_thaw(struct ata_channel *);
+void ata_channel_thaw_locked(struct ata_channel *);
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/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.62.2.9 src/sys/dev/ic/ahcisata_core.c:1.62.2.10
--- src/sys/dev/ic/ahcisata_core.c:1.62.2.9 Thu Oct 11 20:57:51 2018
+++ src/sys/dev/ic/ahcisata_core.c Mon Oct 15 21:18:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ahcisata_core.c,v 1.62.2.9 2018/10/11 20:57:51 jdolecek Exp $ */
+/* $NetBSD: ahcisata_core.c,v 1.62.2.10 2018/10/15 21:18:53 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.9 2018/10/11 20:57:51 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.62.2.10 2018/10/15 21:18:53 jdolecek Exp $");
#include <sys/types.h>
#include <sys/malloc.h>
@@ -82,7 +82,7 @@ static void ahci_bio_kill_xfer(struct at
static void ahci_channel_stop(struct ahci_softc *, struct ata_channel *, int);
static void ahci_channel_start(struct ahci_softc *, struct ata_channel *,
int, int);
-void ahci_channel_recover(struct ahci_softc *, struct ata_channel *, int);
+static void ahci_channel_recover(struct ata_channel *, int, uint32_t);
static int ahci_dma_setup(struct ata_channel *, int, void *, size_t, int);
#if NATAPIBUS > 0
@@ -121,7 +121,8 @@ const struct ata_bustype ahci_ata_bustyp
ata_get_params,
ahci_ata_addref,
ahci_ata_delref,
- ahci_killpending
+ ahci_killpending,
+ ahci_channel_recover,
};
static void ahci_intr_port(struct ahci_softc *, struct ahci_channel *);
@@ -673,8 +674,10 @@ ahci_intr_port(struct ahci_softc *sc, st
}
if (__predict_false(recover)) {
- ata_channel_thaw(chp);
- ahci_channel_recover(sc, chp, tfd);
+ ata_channel_lock(chp);
+ ata_channel_thaw_locked(chp);
+ ata_thread_run(chp, 0, ATACH_TH_RECOVERY, tfd);
+ ata_channel_unlock(chp);
}
}
@@ -1565,16 +1568,14 @@ ahci_channel_start(struct ahci_softc *sc
}
/* Recover channel after command failure */
-void
-ahci_channel_recover(struct ahci_softc *sc, struct ata_channel *chp, int tfd)
+static void
+ahci_channel_recover(struct ata_channel *chp, int flags, uint32_t tfd)
{
+ struct ahci_softc *sc = (struct ahci_softc *)chp->ch_atac;
int drive = ATACH_NODRIVE;
bool reset = false;
- ata_channel_lock(chp);
- KASSERT(!ISSET(chp->ch_flags, ATACH_RECOVERING));
- SET(chp->ch_flags, ATACH_RECOVERING);
- ata_channel_unlock(chp);
+ ata_channel_lock_owned(chp);
/*
* Read FBS to get the drive which caused the error, if PM is in use.
@@ -1624,26 +1625,20 @@ ahci_channel_recover(struct ahci_softc *
* to unblock device processing if COMRESET was not done.
*/
if (reset || (AHCI_TFD_ST(tfd) & (WDCS_BSY|WDCS_DRQ)) != 0) {
- ata_channel_lock(chp);
- ahci_reset_channel(chp, AT_POLL);
- ata_channel_unlock(chp);
+ ahci_reset_channel(chp, flags);
goto out;
}
KASSERT(drive != ATACH_NODRIVE && drive >= 0);
- ahci_channel_stop(sc, chp, AT_POLL);
- ahci_channel_start(sc, chp, AT_POLL,
+ ahci_channel_stop(sc, chp, flags);
+ ahci_channel_start(sc, chp, flags,
(sc->sc_ahci_cap & AHCI_CAP_CLO) ? 1 : 0);
- ata_recovery_resume(chp, drive, tfd, AT_POLL);
+ ata_recovery_resume(chp, drive, tfd, flags);
out:
/* Drive unblocked, back to normal operation */
- ata_channel_lock(chp);
- CLR(chp->ch_flags, ATACH_RECOVERING);
- ata_channel_unlock(chp);
-
- atastart(chp);
+ return;
}
static int
Index: src/sys/dev/ic/mvsata.c
diff -u src/sys/dev/ic/mvsata.c:1.41.2.10 src/sys/dev/ic/mvsata.c:1.41.2.11
--- src/sys/dev/ic/mvsata.c:1.41.2.10 Sun Oct 14 14:50:55 2018
+++ src/sys/dev/ic/mvsata.c Mon Oct 15 21:18:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: mvsata.c,v 1.41.2.10 2018/10/14 14:50:55 jdolecek Exp $ */
+/* $NetBSD: mvsata.c,v 1.41.2.11 2018/10/15 21:18:53 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.41.2.10 2018/10/14 14:50:55 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.41.2.11 2018/10/15 21:18:53 jdolecek Exp $");
#include "opt_mvsata.h"
@@ -167,11 +167,11 @@ static void mvsata_bdma_start(struct mvs
#endif
static int mvsata_nondma_handle(struct mvsata_port *);
-static void mvsata_channel_recover(struct mvsata_port *);
static int mvsata_port_init(struct mvsata_hc *, int);
static int mvsata_wdc_reg_init(struct mvsata_port *, struct wdc_regs *);
#ifndef MVSATA_WITHOUTDMA
+static void mvsata_channel_recover(struct ata_channel *, int, uint32_t);
static void *mvsata_edma_resource_prepare(struct mvsata_port *, bus_dma_tag_t,
bus_dmamap_t *, size_t, int);
static void mvsata_edma_resource_purge(struct mvsata_port *, bus_dma_tag_t,
@@ -218,7 +218,8 @@ static const struct ata_bustype mvsata_a
ata_get_params,
mvsata_addref,
mvsata_delref,
- mvsata_killpending
+ mvsata_killpending,
+ mvsata_channel_recover,
};
#if NATAPIBUS > 0
@@ -533,28 +534,29 @@ mvsata_error(struct mvsata_port *mvport)
mvport->port_hc->hc, mvport->port);
}
if (cause & EDMA_IE_EDEVERR) {
+ struct ata_channel *chp = &mvport->port_ata_channel;
+
aprint_error("%s:%d:%d: device error, recovering\n",
device_xname(MVSATA_DEV2(mvport)),
mvport->port_hc->hc, mvport->port);
- if (!ISSET(mvport->port_ata_channel.ch_flags,
- ATACH_RECOVERING))
- mvsata_channel_recover(mvport);
+ ata_channel_lock(chp);
+ ata_thread_run(chp, 0, ATACH_TH_RECOVERY,
+ ATACH_ERR_ST(0, WDCS_ERR));
+ ata_channel_unlock(chp);
}
return 1;
}
+#ifndef MVSATA_WITHOUTDMA
static void
-mvsata_channel_recover(struct mvsata_port *mvport)
+mvsata_channel_recover(struct ata_channel *chp, int flags, uint32_t tfd)
{
- struct ata_channel *chp = &mvport->port_ata_channel;
- int drive, tfd = ATACH_ERR_ST(0, WDCS_ERR);
+ struct mvsata_port * const mvport = (struct mvsata_port *)chp;
+ int drive;
- ata_channel_lock(chp);
- KASSERT(!ISSET(chp->ch_flags, ATACH_RECOVERING));
- SET(chp->ch_flags, ATACH_RECOVERING);
- ata_channel_unlock(chp);
+ ata_channel_lock_owned(chp);
if (chp->ch_ndrives > PMP_PORT_CTL) {
/* Get PM port number for the device in error. This device
@@ -574,12 +576,9 @@ mvsata_channel_recover(struct mvsata_por
ata_recovery_resume(chp, drive, tfd, AT_POLL);
/* Drive unblocked, back to normal operation */
- ata_channel_lock(chp);
- CLR(chp->ch_flags, ATACH_RECOVERING);
- ata_channel_unlock(chp);
-
- atastart(chp);
+ return;
}
+#endif /* !MVSATA_WITHOUTDMA */
/*
* ATA callback entry points
Index: src/sys/dev/ic/siisata.c
diff -u src/sys/dev/ic/siisata.c:1.35.6.9 src/sys/dev/ic/siisata.c:1.35.6.10
--- src/sys/dev/ic/siisata.c:1.35.6.9 Thu Oct 11 20:57:51 2018
+++ src/sys/dev/ic/siisata.c Mon Oct 15 21:18:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.35.6.9 2018/10/11 20:57:51 jdolecek Exp $ */
+/* $NetBSD: siisata.c,v 1.35.6.10 2018/10/15 21:18:53 jdolecek Exp $ */
/* from ahcisata_core.c */
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.35.6.9 2018/10/11 20:57:51 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.35.6.10 2018/10/15 21:18:53 jdolecek Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -167,7 +167,7 @@ static void siisata_device_reset(struct
static void siisata_activate_prb(struct siisata_channel *, int);
static void siisata_deactivate_prb(struct siisata_channel *, int);
static int siisata_dma_setup(struct ata_channel *, int, void *, size_t, int);
-void siisata_channel_recover(struct ata_channel *, uint32_t);
+static void siisata_channel_recover(struct ata_channel *, int, uint32_t);
#if NATAPIBUS > 0
void siisata_atapibus_attach(struct atabus_softc *);
@@ -192,7 +192,8 @@ const struct ata_bustype siisata_ata_bus
ata_get_params,
siisata_ata_addref,
siisata_ata_delref,
- siisata_killpending
+ siisata_killpending,
+ siisata_channel_recover,
};
#if NATAPIBUS > 0
@@ -586,24 +587,23 @@ process:
}
if (__predict_false(recover)) {
- ata_channel_thaw(chp);
- siisata_channel_recover(chp, tfd);
+ ata_channel_lock(chp);
+ ata_channel_thaw_locked(chp);
+ ata_thread_run(chp, 0, ATACH_TH_RECOVERY, tfd);
+ ata_channel_unlock(chp);
}
}
/* Recover channel after transfer aborted */
void
-siisata_channel_recover(struct ata_channel *chp, uint32_t tfd)
+siisata_channel_recover(struct ata_channel *chp, int flags, uint32_t tfd)
{
struct siisata_channel *schp = (struct siisata_channel *)chp;
struct siisata_softc *sc =
(struct siisata_softc *)schp->ata_channel.ch_atac;
int drive;
- ata_channel_lock(chp);
- KASSERT(!ISSET(chp->ch_flags, ATACH_RECOVERING));
- SET(chp->ch_flags, ATACH_RECOVERING);
- ata_channel_unlock(chp);
+ ata_channel_lock_owned(chp);
if (chp->ch_ndrives > PMP_PORT_CTL) {
/* Get PM port number for the device in error */
@@ -620,24 +620,18 @@ siisata_channel_recover(struct ata_chann
* was not done.
*/
if ((ATACH_ST(tfd) & (WDCS_BSY|WDCS_DRQ)) != 0) {
- ata_channel_lock(chp);
siisata_device_reset(chp);
- ata_channel_unlock(chp);
goto out;
}
KASSERT(drive >= 0);
siisata_reinit_port(chp, drive);
- ata_recovery_resume(chp, drive, tfd, AT_POLL);
+ ata_recovery_resume(chp, drive, tfd, flags);
out:
/* Drive unblocked, back to normal operation */
- ata_channel_lock(chp);
- CLR(chp->ch_flags, ATACH_RECOVERING);
- ata_channel_unlock(chp);
-
- atastart(chp);
+ return;
}
void
Index: src/sys/dev/usb/umass_isdata.c
diff -u src/sys/dev/usb/umass_isdata.c:1.36.6.1 src/sys/dev/usb/umass_isdata.c:1.36.6.2
--- src/sys/dev/usb/umass_isdata.c:1.36.6.1 Sat Sep 22 09:23:00 2018
+++ src/sys/dev/usb/umass_isdata.c Mon Oct 15 21:18:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: umass_isdata.c,v 1.36.6.1 2018/09/22 09:23:00 jdolecek Exp $ */
+/* $NetBSD: umass_isdata.c,v 1.36.6.2 2018/10/15 21:18:53 jdolecek Exp $ */
/*
* TODO:
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.36.6.1 2018/09/22 09:23:00 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.36.6.2 2018/10/15 21:18:53 jdolecek Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -134,6 +134,7 @@ const struct ata_bustype uisdata_bustype
uisdata_addref,
uisdata_delref,
uisdata_kill_pending,
+ NULL,
};
struct ata_cmd {