Kill ATACH_TH_RUN and use cpu_intr_p() instead.

This commit is contained in:
bouyer 2008-10-02 21:05:17 +00:00
parent 21150ac7ce
commit 2887906e27
5 changed files with 18 additions and 32 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata.c,v 1.100 2008/10/01 18:23:55 bouyer Exp $ */
/* $NetBSD: ata.c,v 1.101 2008/10/02 21:05:17 bouyer Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.100 2008/10/01 18:23:55 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.101 2008/10/02 21:05:17 bouyer Exp $");
#include "opt_ata.h"
@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.100 2008/10/01 18:23:55 bouyer Exp $");
#include <sys/conf.h>
#include <sys/fcntl.h>
#include <sys/proc.h>
#include <sys/cpu.h>
#include <sys/pool.h>
#include <sys/kthread.h>
#include <sys/errno.h>
@ -179,12 +180,7 @@ atabusconfig(struct atabus_softc *atabus_sc)
struct ata_channel *chp = atabus_sc->sc_chan;
struct atac_softc *atac = chp->ch_atac;
struct atabus_initq *atabus_initq = NULL;
int i, s, error;
/* we are in the atabus's thread context */
s = splbio();
chp->ch_flags |= ATACH_TH_RUN;
splx(s);
int i, error;
/* Probe for the drives. */
/* XXX for SATA devices we will power up all drives at once */
@ -194,11 +190,6 @@ atabusconfig(struct atabus_softc *atabus_sc)
chp->ch_drive[0].drive_flags, chp->ch_drive[1].drive_flags),
DEBUG_PROBE);
/* next operations will occurs in a separate thread */
s = splbio();
chp->ch_flags &= ~ATACH_TH_RUN;
splx(s);
/* Make sure the devices probe in atabus order to avoid jitter. */
simple_lock(&atabus_interlock);
while(1) {
@ -357,8 +348,6 @@ atabus_thread(void *arg)
int i, s;
s = splbio();
chp->ch_flags |= ATACH_TH_RUN;
/*
* Probe the drives. Reset all flags to 0 to indicate to controllers
* that can re-probe that all drives must be probed..
@ -377,9 +366,7 @@ atabus_thread(void *arg)
if ((chp->ch_flags & (ATACH_TH_RESET | ATACH_SHUTDOWN)) == 0 &&
(chp->ch_queue->active_xfer == NULL ||
chp->ch_queue->queue_freeze == 0)) {
chp->ch_flags &= ~ATACH_TH_RUN;
(void) tsleep(&chp->ch_thread, PRIBIO, "atath", 0);
chp->ch_flags |= ATACH_TH_RUN;
}
if (chp->ch_flags & ATACH_SHUTDOWN) {
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata_wdc.c,v 1.89 2008/04/28 20:23:47 martin Exp $ */
/* $NetBSD: ata_wdc.c,v 1.90 2008/10/02 21:05:17 bouyer Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer.
@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.89 2008/04/28 20:23:47 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.90 2008/10/02 21:05:17 bouyer Exp $");
#include "opt_ata.h"
@ -75,6 +75,7 @@ __KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.89 2008/04/28 20:23:47 martin Exp $");
#include <sys/disklabel.h>
#include <sys/syslog.h>
#include <sys/proc.h>
#include <sys/cpu.h>
#include <sys/intr.h>
#include <sys/bus.h>
@ -198,8 +199,7 @@ wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
* that we never get to this point if that's the case.
*/
/* If it's not a polled command, we need the kernel thread */
if ((xfer->c_flags & C_POLL) == 0 &&
(chp->ch_flags & ATACH_TH_RUN) == 0) {
if ((xfer->c_flags & C_POLL) == 0 && cpu_intr_p()) {
chp->ch_queue->queue_freeze++;
wakeup(&chp->ch_thread);
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: atavar.h,v 1.76 2008/03/18 20:46:36 cube Exp $ */
/* $NetBSD: atavar.h,v 1.77 2008/10/02 21:05:17 bouyer Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@ -340,7 +340,6 @@ struct ata_channel {
#define ATACH_DMA_WAIT 0x20 /* controller is waiting for DMA */
#define ATACH_PIOBM_WAIT 0x40 /* controller is waiting for busmastering PIO */
#define ATACH_DISABLED 0x80 /* channel is disabled */
#define ATACH_TH_RUN 0x100 /* the kernel thread is working */
#define ATACH_TH_RESET 0x200 /* someone ask the thread to reset */
u_int8_t ch_status; /* copy of status register */
u_int8_t ch_error; /* copy of error register */

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc.c,v 1.254 2008/04/28 20:23:51 martin Exp $ */
/* $NetBSD: wdc.c,v 1.255 2008/10/02 21:05:17 bouyer Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved.
@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.254 2008/04/28 20:23:51 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.255 2008/10/02 21:05:17 bouyer Exp $");
#include "opt_ata.h"
@ -76,6 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.254 2008/04/28 20:23:51 martin Exp $");
#include <sys/malloc.h>
#include <sys/syslog.h>
#include <sys/proc.h>
#include <sys/cpu.h>
#include <sys/intr.h>
#include <sys/bus.h>
@ -1257,8 +1258,7 @@ wdcwait(struct ata_channel *chp, int mask, int bits, int timeout, int flags)
else {
error = __wdcwait(chp, mask, bits, WDCDELAY_POLL);
if (error != 0) {
if ((chp->ch_flags & ATACH_TH_RUN) ||
(flags & AT_WAIT)) {
if (!cpu_intr_p()) {
/*
* we're running in the channel thread
* or some userland thread context
@ -1273,7 +1273,7 @@ wdcwait(struct ata_channel *chp, int mask, int bits, int timeout, int flags)
}
} else {
/*
* we're probably in interrupt context,
* we're in interrupt context,
* ask the thread to come back here
*/
#ifdef DIAGNOSTIC

View File

@ -1,4 +1,4 @@
/* $NetBSD: atapi_wdc.c,v 1.107 2008/03/24 14:44:26 cube Exp $ */
/* $NetBSD: atapi_wdc.c,v 1.108 2008/10/02 21:05:17 bouyer Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.107 2008/03/24 14:44:26 cube Exp $");
__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.108 2008/10/02 21:05:17 bouyer Exp $");
#ifndef ATADEBUG
#define ATADEBUG
@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.107 2008/03/24 14:44:26 cube Exp $")
#include <sys/device.h>
#include <sys/syslog.h>
#include <sys/proc.h>
#include <sys/cpu.h>
#include <sys/dvdio.h>
#include <sys/intr.h>
@ -470,8 +471,7 @@ wdc_atapi_start(struct ata_channel *chp, struct ata_xfer *xfer)
/* Do control operations specially. */
if (__predict_false(drvp->state < READY)) {
/* If it's not a polled command, we need the kernel thread */
if ((sc_xfer->xs_control & XS_CTL_POLL) == 0 &&
(chp->ch_flags & ATACH_TH_RUN) == 0) {
if ((sc_xfer->xs_control & XS_CTL_POLL) == 0 && cpu_intr_p()) {
chp->ch_queue->queue_freeze++;
wakeup(&chp->ch_thread);
return;