Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/jdolecek-ncq]: src/sys/dev change ata_queue_hwslot_to_xfer() and ata_que...
details: https://anonhg.NetBSD.org/src/rev/c43f92c7c79f
branches: jdolecek-ncq
changeset: 352684:c43f92c7c79f
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Wed Jun 21 19:38:42 2017 +0000
description:
change ata_queue_hwslot_to_xfer() and ata_queue_get_active_xfer() to take
ata_channel instead of ata_queue as parameter, and lock the channel while
traversing the queue
diffstat:
sys/dev/ata/ata.c | 36 ++++++++++++++++++++++++++----------
sys/dev/ata/atavar.h | 6 +++---
sys/dev/ic/ahcisata_core.c | 10 ++++------
sys/dev/ic/mvsata.c | 10 +++++-----
sys/dev/ic/siisata.c | 8 ++++----
sys/dev/ic/wdc.c | 12 ++++++------
sys/dev/usb/umass_isdata.c | 6 +++---
7 files changed, 51 insertions(+), 37 deletions(-)
diffs (296 lines):
diff -r 23159c4c7d0c -r c43f92c7c79f sys/dev/ata/ata.c
--- a/sys/dev/ata/ata.c Wed Jun 21 19:21:25 2017 +0000
+++ b/sys/dev/ata/ata.c Wed Jun 21 19:38:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata.c,v 1.132.8.12 2017/06/20 20:58:22 jdolecek Exp $ */
+/* $NetBSD: ata.c,v 1.132.8.13 2017/06/21 19:38:43 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.12 2017/06/20 20:58:22 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.13 2017/06/21 19:38:43 jdolecek Exp $");
#include "opt_ata.h"
@@ -196,9 +196,12 @@
}
struct ata_xfer *
-ata_queue_hwslot_to_xfer(struct ata_queue *chq, int hwslot)
+ata_queue_hwslot_to_xfer(struct ata_channel *chp, int hwslot)
{
- struct ata_xfer *xfer;
+ struct ata_queue *chq = chp->ch_queue;
+ struct ata_xfer *xfer = NULL;
+
+ mutex_enter(&chp->ch_lock);
KASSERT(hwslot < chq->queue_openings);
KASSERT((chq->active_xfers_used & __BIT(hwslot)) != 0);
@@ -206,11 +209,16 @@
/* Usually the first entry will be the one */
TAILQ_FOREACH(xfer, &chq->active_xfers, c_activechain) {
if (xfer->c_slot == hwslot)
- return xfer;
+ break;
}
- panic("%s: xfer with slot %d not found (active %x)", __func__, hwslot,
- chq->active_xfers_used);
+ mutex_exit(&chp->ch_lock);
+
+ KASSERTMSG((xfer != NULL),
+ "%s: xfer with slot %d not found (active %x)", __func__,
+ hwslot, chq->active_xfers_used);
+
+ return xfer;
}
/*
@@ -220,10 +228,18 @@
* is preferred in all NCQ cases.
*/
struct ata_xfer *
-ata_queue_get_active_xfer(struct ata_queue *chq)
+ata_queue_get_active_xfer(struct ata_channel *chp)
{
- KASSERT(chq->queue_active <= 1);
- return TAILQ_FIRST(&chq->active_xfers);
+ struct ata_xfer *xfer = NULL;
+
+ mutex_enter(&chp->ch_lock);
+
+ KASSERT(chp->ch_queue->queue_active <= 1);
+ xfer = TAILQ_FIRST(&chp->ch_queue->active_xfers);
+
+ mutex_exit(&chp->ch_lock);
+
+ return xfer;
}
static void
diff -r 23159c4c7d0c -r c43f92c7c79f sys/dev/ata/atavar.h
--- a/sys/dev/ata/atavar.h Wed Jun 21 19:21:25 2017 +0000
+++ b/sys/dev/ata/atavar.h Wed Jun 21 19:38:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atavar.h,v 1.92.8.12 2017/06/21 19:21:25 jdolecek Exp $ */
+/* $NetBSD: atavar.h,v 1.92.8.13 2017/06/21 19:38:43 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -516,9 +516,9 @@
ata_queue_alloc(uint8_t openings);
void ata_queue_free(struct ata_queue *);
struct ata_xfer *
- ata_queue_hwslot_to_xfer(struct ata_queue *, int);
+ ata_queue_hwslot_to_xfer(struct ata_channel *, int);
struct ata_xfer *
- ata_queue_get_active_xfer(struct ata_queue *);
+ ata_queue_get_active_xfer(struct ata_channel *);
void ata_delay(int, const char *, int);
diff -r 23159c4c7d0c -r c43f92c7c79f sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c Wed Jun 21 19:21:25 2017 +0000
+++ b/sys/dev/ic/ahcisata_core.c Wed Jun 21 19:38:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ahcisata_core.c,v 1.57.6.15 2017/06/20 20:58:22 jdolecek Exp $ */
+/* $NetBSD: ahcisata_core.c,v 1.57.6.16 2017/06/21 19:38:42 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.15 2017/06/20 20:58:22 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.57.6.16 2017/06/21 19:38:42 jdolecek Exp $");
#include <sys/types.h>
#include <sys/malloc.h>
@@ -577,8 +577,7 @@
if ((achp->ahcic_cmds_active & (1 << slot)) == 0)
continue;
if ((active & (1 << slot)) == 0) {
- xfer = ata_queue_hwslot_to_xfer(chp->ch_queue,
- slot);
+ xfer = ata_queue_hwslot_to_xfer(chp, slot);
xfer->c_intr(chp, xfer, 0);
}
}
@@ -608,8 +607,7 @@
if ((achp->ahcic_cmds_active & (1 << slot)) == 0)
continue;
if ((active & (1 << slot)) == 1) {
- xfer = ata_queue_hwslot_to_xfer(chp->ch_queue,
- slot);
+ xfer = ata_queue_hwslot_to_xfer(chp, slot);
xfer->c_intr(chp, xfer, is);
}
}
diff -r 23159c4c7d0c -r c43f92c7c79f sys/dev/ic/mvsata.c
--- a/sys/dev/ic/mvsata.c Wed Jun 21 19:21:25 2017 +0000
+++ b/sys/dev/ic/mvsata.c Wed Jun 21 19:38:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mvsata.c,v 1.35.6.13 2017/06/20 20:58:22 jdolecek Exp $ */
+/* $NetBSD: mvsata.c,v 1.35.6.14 2017/06/21 19:38:43 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.13 2017/06/20 20:58:22 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.35.6.14 2017/06/21 19:38:43 jdolecek Exp $");
#include "opt_mvsata.h"
@@ -447,7 +447,7 @@
}
KASSERT(quetag < MVSATA_EDMAQ_LEN);
- xfer = ata_queue_hwslot_to_xfer(chp->ch_queue, quetag);
+ xfer = ata_queue_hwslot_to_xfer(chp, quetag);
chp->ch_flags &= ~ATACH_IRQ_WAIT;
KASSERT(xfer->c_intr != NULL);
ret = xfer->c_intr(chp, xfer, 1);
@@ -2587,7 +2587,7 @@
crpb = mvport->port_crpb + erpqop;
quetag = CRPB_CHOSTQUETAG(le16toh(crpb->id));
- xfer = ata_queue_hwslot_to_xfer(chp->ch_queue, quetag);
+ xfer = ata_queue_hwslot_to_xfer(chp, quetag);
bus_dmamap_sync(mvport->port_dmat, mvport->port_eprd_dmamap,
mvport->port_reqtbl[xfer->c_slot].eprd_offset,
@@ -2720,7 +2720,7 @@
continue;
}
- rqxfer = ata_queue_hwslot_to_xfer(chp->ch_queue, i);
+ rqxfer = ata_queue_hwslot_to_xfer(chp, i);
sc->sc_edma_setup_crqb(mvport, erqqip, rqxfer);
erqqip++;
}
diff -r 23159c4c7d0c -r c43f92c7c79f sys/dev/ic/siisata.c
--- a/sys/dev/ic/siisata.c Wed Jun 21 19:21:25 2017 +0000
+++ b/sys/dev/ic/siisata.c Wed Jun 21 19:38:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.30.4.18 2017/06/20 21:00:47 jdolecek Exp $ */
+/* $NetBSD: siisata.c,v 1.30.4.19 2017/06/21 19:38:43 jdolecek Exp $ */
/* from ahcisata_core.c */
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.30.4.18 2017/06/20 21:00:47 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.30.4.19 2017/06/21 19:38:43 jdolecek Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -494,7 +494,7 @@
if (((pss >> slot) & 1) != 0)
/* execution is incomplete or unsuccessful, skip for now */
continue;
- xfer = ata_queue_hwslot_to_xfer(chp->ch_queue, slot);
+ xfer = ata_queue_hwslot_to_xfer(chp, slot);
if (xfer->c_intr == NULL) {
wakeup(schp);
continue;
@@ -556,7 +556,7 @@
/* there's nothing executing here, skip */
if (((schp->sch_active_slots >> slot) & 1) == 0)
continue;
- xfer = ata_queue_hwslot_to_xfer(chp->ch_queue, slot);
+ xfer = ata_queue_hwslot_to_xfer(chp, slot);
if (xfer == NULL)
continue;
xfer->c_intr(chp, xfer, 0);
diff -r 23159c4c7d0c -r c43f92c7c79f sys/dev/ic/wdc.c
--- a/sys/dev/ic/wdc.c Wed Jun 21 19:21:25 2017 +0000
+++ b/sys/dev/ic/wdc.c Wed Jun 21 19:38:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wdc.c,v 1.283.2.8 2017/06/21 19:21:25 jdolecek Exp $ */
+/* $NetBSD: wdc.c,v 1.283.2.9 2017/06/21 19:38:43 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.283.2.8 2017/06/21 19:21:25 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.283.2.9 2017/06/21 19:38:43 jdolecek Exp $");
#include "opt_ata.h"
#include "opt_wdc.h"
@@ -873,7 +873,7 @@
}
ATADEBUG_PRINT(("wdcintr\n"), DEBUG_INTR);
- xfer = ata_queue_get_active_xfer(chp->ch_queue);
+ xfer = ata_queue_get_active_xfer(chp);
KASSERT(xfer != NULL);
#ifdef DIAGNOSTIC
if (xfer->c_chp != chp) {
@@ -931,7 +931,7 @@
* if the current command is on an ATAPI device, issue a
* ATAPI_SOFT_RESET
*/
- xfer = ata_queue_get_active_xfer(chp->ch_queue);
+ xfer = ata_queue_get_active_xfer(chp);
if (xfer && xfer->c_chp == chp && (xfer->c_flags & C_ATAPI)) {
wdccommandshort(chp, xfer->c_drive, ATAPI_SOFT_RESET);
if (flags & AT_WAIT)
@@ -1204,7 +1204,7 @@
if (!cold && xtime > WDCNDELAY_DEBUG) {
struct ata_xfer *xfer;
- xfer = ata_queue_get_active_xfer(chp->ch_queue);
+ xfer = ata_queue_get_active_xfer(chp);
if (xfer == NULL)
printf("%s channel %d: warning: busy-wait took %dus\n",
device_xname(chp->ch_atac->atac_dev),
@@ -1812,7 +1812,7 @@
__wdcerror(struct ata_channel *chp, const char *msg)
{
struct atac_softc *atac = chp->ch_atac;
- struct ata_xfer *xfer = ata_queue_get_active_xfer(chp->ch_queue);
+ struct ata_xfer *xfer = ata_queue_get_active_xfer(chp);
if (xfer == NULL)
aprint_error("%s:%d: %s\n", device_xname(atac->atac_dev),
diff -r 23159c4c7d0c -r c43f92c7c79f sys/dev/usb/umass_isdata.c
--- a/sys/dev/usb/umass_isdata.c Wed Jun 21 19:21:25 2017 +0000
+++ b/sys/dev/usb/umass_isdata.c Wed Jun 21 19:38:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umass_isdata.c,v 1.33.4.4 2017/06/20 20:58:22 jdolecek Exp $ */
+/* $NetBSD: umass_isdata.c,v 1.33.4.5 2017/06/21 19:38:43 jdolecek Exp $ */
/*
* TODO:
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.33.4.4 2017/06/20 20:58:22 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.33.4.5 2017/06/21 19:38:43 jdolecek Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -502,7 +502,7 @@
struct ata_channel *chp = drv->chnl_softc;
struct umass_softc *sc = CH2SELF(chp);
struct uisdata_softc *scbus = (struct uisdata_softc *)sc->bus;
- struct ata_xfer *xfer = ata_queue_get_active_xfer(chp->ch_queue);
+ struct ata_xfer *xfer = ata_queue_get_active_xfer(chp);
struct ata_bio *ata_bio = &xfer->c_bio;
DPRINTFN(-1,("%s\n", __func__));
Home |
Main Index |
Thread Index |
Old Index