PERFORCE change 92313 for review
Marcel Moolenaar
marcel at FreeBSD.org
Thu Feb 23 17:55:26 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=92313
Change 92313 by marcel at marcel_nfs on 2006/02/24 01:54:27
IFC @92311
Affected files ...
.. //depot/projects/uart/conf/kmod.mk#19 integrate
.. //depot/projects/uart/dev/amr/amr_linux.c#2 integrate
.. //depot/projects/uart/dev/ata/ata-all.h#11 integrate
.. //depot/projects/uart/dev/ata/ata-chipset.c#17 integrate
.. //depot/projects/uart/dev/ata/ata-queue.c#13 integrate
.. //depot/projects/uart/dev/fdc/fdc.c#10 integrate
.. //depot/projects/uart/dev/sound/pcm/feeder.c#8 integrate
.. //depot/projects/uart/kern/kern_timeout.c#8 integrate
.. //depot/projects/uart/modules/uart/Makefile#13 integrate
.. //depot/projects/uart/netinet/tcp_input.c#16 integrate
.. //depot/projects/uart/netinet/tcp_output.c#9 integrate
Differences ...
==== //depot/projects/uart/conf/kmod.mk#19 (text+ko) ====
@@ -1,5 +1,5 @@
# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
-# $FreeBSD: src/sys/conf/kmod.mk,v 1.205 2006/02/20 01:08:33 mlaier Exp $
+# $FreeBSD: src/sys/conf/kmod.mk,v 1.206 2006/02/24 01:49:36 marcel Exp $
#
# The include file <bsd.kmod.mk> handles building and installing loadable
# kernel modules.
@@ -318,11 +318,11 @@
dev/iicbus/iicbb_if.m dev/iicbus/iicbus_if.m \
dev/mii/miibus_if.m dev/ofw/ofw_bus_if.m \
dev/pccard/card_if.m dev/pccard/power_if.m dev/pci/pci_if.m \
- dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/scc/scc_if.m \
- dev/smbus/smbus_if.m dev/sound/pcm/ac97_if.m \
- dev/sound/pcm/channel_if.m dev/sound/pcm/feeder_if.m \
- dev/sound/pcm/mixer_if.m dev/uart/uart_if.m dev/usb/usb_if.m \
- isa/isa_if.m kern/bus_if.m kern/cpufreq_if.m kern/device_if.m \
+ dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m \
+ dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
+ dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m \
+ dev/usb/usb_if.m isa/isa_if.m \
+ kern/bus_if.m kern/cpufreq_if.m kern/device_if.m \
libkern/iconv_converter_if.m opencrypto/crypto_if.m \
pc98/pc98/canbus_if.m pci/agp_if.m
==== //depot/projects/uart/dev/amr/amr_linux.c#2 (text+ko) ====
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/amr/amr_linux.c,v 1.1 2006/01/24 21:13:49 ambrisko Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/amr/amr_linux.c,v 1.2 2006/02/23 18:05:38 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -170,13 +170,15 @@
devclass_t devclass;
struct amr_softc *sc;
struct amr_linux_ioctl ali;
- int adapter;
+ int adapter, error;
devclass = devclass_find("amr");
if (devclass == NULL)
return (ENOENT);
- copyin((caddr_t)args->arg, &ali, sizeof(ali));
+ error = copyin((caddr_t)args->arg, &ali, sizeof(ali));
+ if (error)
+ return (error);
if (ali.ui.fcs.opcode == 0x82)
adapter = 0;
else
==== //depot/projects/uart/dev/ata/ata-all.h#11 (text+ko) ====
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/ata/ata-all.h,v 1.113 2006/02/09 20:54:42 sos Exp $
+ * $FreeBSD: src/sys/dev/ata/ata-all.h,v 1.114 2006/02/23 20:15:22 sos Exp $
*/
/* ATA register defines */
@@ -338,6 +338,7 @@
/* structure used to queue an ATA/ATAPI request */
struct ata_request {
device_t dev; /* device handle */
+ device_t parent; /* channel handle */
union {
struct {
u_int8_t command; /* command reg */
==== //depot/projects/uart/dev/ata/ata-chipset.c#17 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-chipset.c,v 1.159 2006/02/16 17:09:24 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-chipset.c,v 1.160 2006/02/23 18:52:15 sos Exp $");
#include "opt_ata.h"
#include <sys/param.h>
@@ -4075,7 +4075,6 @@
/* setup the usual register normal pci style */
if (ata_pci_allocate(dev))
return ENXIO;
- ata_pci_allocate(dev);
if (ctlr->chip->cfg2 & SIIINTR)
ch->hw.status = ata_cmd_status;
==== //depot/projects/uart/dev/ata/ata-queue.c#13 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-queue.c,v 1.55 2006/01/18 13:10:17 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-queue.c,v 1.56 2006/02/23 20:15:22 sos Exp $");
#include "opt_ata.h"
#include <sys/param.h>
@@ -55,6 +55,7 @@
/* mark request as virgin (this might be a ATA_R_REQUEUE) */
request->result = request->status = request->error = 0;
+ request->parent = device_get_parent(request->dev);
callout_init_mtx(&request->callout, &ch->state_mtx, CALLOUT_RETURNUNLOCKED);
if (!request->callback && !(request->flags & ATA_R_REQUEUE))
@@ -218,7 +219,7 @@
void
ata_finish(struct ata_request *request)
{
- struct ata_channel *ch = device_get_softc(device_get_parent(request->dev));
+ struct ata_channel *ch = device_get_softc(request->parent);
/*
* if in ATA_STALL_QUEUE state or request has ATA_R_DIRECT flags set
@@ -247,7 +248,7 @@
ata_completed(void *context, int dummy)
{
struct ata_request *request = (struct ata_request *)context;
- struct ata_channel *ch = device_get_softc(device_get_parent(request->dev));
+ struct ata_channel *ch = device_get_softc(request->parent);
struct ata_device *atadev = device_get_softc(request->dev);
struct ata_composite *composite;
@@ -466,7 +467,7 @@
void
ata_timeout(struct ata_request *request)
{
- struct ata_channel *ch = device_get_softc(device_get_parent(request->dev));
+ struct ata_channel *ch = device_get_softc(request->parent);
//request->flags |= ATA_R_DEBUG;
ATA_DEBUG_RQ(request, "timeout");
@@ -479,7 +480,6 @@
*/
if (ch->state == ATA_ACTIVE) {
request->flags |= ATA_R_TIMEOUT;
- ch->running = NULL;
mtx_unlock(&ch->state_mtx);
ATA_LOCKING(ch->dev, ATA_LF_UNLOCK);
ata_finish(request);
@@ -493,34 +493,43 @@
ata_fail_requests(device_t dev)
{
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
- struct ata_request *request;
+ struct ata_request *request, *tmp;
+ TAILQ_HEAD(, ata_request) fail_requests;
+ TAILQ_INIT(&fail_requests);
- /* do we have any outstanding request to care about ?*/
+ /* grap all channel locks to avoid races */
+ mtx_lock(&ch->queue_mtx);
mtx_lock(&ch->state_mtx);
+
+ /* do we have any running request to care about ? */
if ((request = ch->running) && (!dev || request->dev == dev)) {
callout_stop(&request->callout);
ch->running = NULL;
- }
- else
- request = NULL;
- mtx_unlock(&ch->state_mtx);
- if (request) {
+ ch->state = ATA_IDLE;
request->result = ENXIO;
- ata_finish(request);
+ TAILQ_INSERT_TAIL(&fail_requests, request, chain);
}
/* fail all requests queued on this channel for device dev if !NULL */
- mtx_lock(&ch->queue_mtx);
- while ((request = TAILQ_FIRST(&ch->ata_queue))) {
+ TAILQ_FOREACH_SAFE(request, &ch->ata_queue, chain, tmp) {
if (!dev || request->dev == dev) {
TAILQ_REMOVE(&ch->ata_queue, request, chain);
- mtx_unlock(&ch->queue_mtx);
request->result = ENXIO;
- ata_finish(request);
- mtx_lock(&ch->queue_mtx);
+ TAILQ_INSERT_TAIL(&fail_requests, request, chain);
}
}
+
+ mtx_unlock(&ch->state_mtx);
mtx_unlock(&ch->queue_mtx);
+
+ /* finish up all requests collected above */
+ TAILQ_FOREACH_SAFE(request, &fail_requests, chain, tmp) {
+ TAILQ_REMOVE(&fail_requests, request, chain);
+ ata_finish(request);
+ }
+
+ /* we might have work for the other device on this channel */
+ ata_start(ch->dev);
}
static u_int64_t
==== //depot/projects/uart/dev/fdc/fdc.c#10 (text+ko) ====
@@ -51,7 +51,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc.c,v 1.308 2005/08/30 23:12:18 rodrigc Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc.c,v 1.309 2006/02/23 19:11:16 jhb Exp $");
#include "opt_fdc.h"
@@ -250,7 +250,6 @@
#define FD_NO_TRACK -2
int options; /* FDOPT_* */
struct callout toffhandle;
- struct callout tohandle;
struct g_geom *fd_geom;
struct g_provider *fd_provider;
device_t dev;
@@ -617,7 +616,7 @@
int once;
fd = arg;
- mtx_lock(&fd->fdc->fdc_mtx);
+ mtx_assert(&fd->fdc->fdc_mtx, MA_OWNED);
fd->flags &= ~FD_MOTORWAIT;
fd->flags |= FD_MOTOR;
once = 0;
@@ -628,7 +627,6 @@
bioq_disksort(&fd->fdc->head, bp);
once = 1;
}
- mtx_unlock(&fd->fdc->fdc_mtx);
if (once)
wakeup(&fd->fdc->head);
}
@@ -647,7 +645,7 @@
fdc->fdout |= (FDO_MOEN0 << fd->fdsu);
callout_reset(&fd->toffhandle, hz, fd_turnon, fd);
} else {
- callout_drain(&fd->toffhandle);
+ callout_stop(&fd->toffhandle);
fd->flags &= ~(FD_MOTOR|FD_MOTORWAIT);
fdc->fdout &= ~(FDO_MOEN0 << fd->fdsu);
}
@@ -659,9 +657,8 @@
{
struct fd_data *fd = xfd;
- mtx_lock(&fd->fdc->fdc_mtx);
+ mtx_assert(&fd->fdc->fdc_mtx, MA_OWNED);
fd_motor(fd, 0);
- mtx_unlock(&fd->fdc->fdc_mtx);
}
/*
@@ -1199,7 +1196,7 @@
mtx_lock(&fdc->fdc_mtx);
/* If we go from idle, cancel motor turnoff */
if (fd->fd_iocount++ == 0)
- callout_drain(&fd->toffhandle);
+ callout_stop(&fd->toffhandle);
if (fd->flags & FD_MOTOR) {
/* The motor is on, send it directly to the controller */
bioq_disksort(&fdc->head, bp);
@@ -1939,8 +1936,7 @@
fd->fdc = fdc;
fd->fdsu = fdsu;
fd->options = 0;
- callout_init(&fd->toffhandle, 1);
- callout_init(&fd->tohandle, 1);
+ callout_init_mtx(&fd->toffhandle, &fd->fdc->fdc_mtx, 0);
/* initialize densities for subdevices */
fdsettype(fd, fd_native_types[fd->type]);
==== //depot/projects/uart/dev/sound/pcm/feeder.c#8 (text+ko) ====
@@ -28,7 +28,7 @@
#include "feeder_if.h"
-SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/feeder.c,v 1.36 2006/01/29 01:32:37 ariff Exp $");
+SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/feeder.c,v 1.37 2006/02/23 19:23:55 jhb Exp $");
MALLOC_DEFINE(M_FEEDER, "feeder", "pcm feeder");
@@ -385,10 +385,8 @@
}
} else if (best2 == 0)
return best1;
- else if (best1 == 0)
+ else
return best2;
-
- return best1;
}
u_int32_t
==== //depot/projects/uart/kern/kern_timeout.c#8 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_timeout.c,v 1.100 2005/09/15 20:20:36 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_timeout.c,v 1.101 2006/02/23 19:13:12 jhb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -78,37 +78,22 @@
/**
* Locked by callout_lock:
* curr_callout - If a callout is in progress, it is curr_callout.
- * If curr_callout is non-NULL, threads waiting on
- * callout_wait will be woken up as soon as the
+ * If curr_callout is non-NULL, threads waiting in
+ * callout_drain() will be woken up as soon as the
* relevant callout completes.
* curr_cancelled - Changing to 1 with both callout_lock and c_mtx held
* guarantees that the current callout will not run.
* The softclock() function sets this to 0 before it
* drops callout_lock to acquire c_mtx, and it calls
- * the handler only if curr_cancelled still 0 when
+ * the handler only if curr_cancelled is still 0 after
* c_mtx is successfully acquired.
- * wakeup_ctr - Incremented every time a thread wants to wait
- * for a callout to complete. Modified only when
+ * callout_wait - If a thread is waiting in callout_drain(), then
+ * callout_wait is nonzero. Set only when
* curr_callout is non-NULL.
- * wakeup_needed - If a thread is waiting on callout_wait, then
- * wakeup_needed is nonzero. Increased only when
- * cutt_callout is non-NULL.
*/
static struct callout *curr_callout;
static int curr_cancelled;
-static int wakeup_ctr;
-static int wakeup_needed;
-
-/**
- * Locked by callout_wait_lock:
- * callout_wait - If wakeup_needed is set, callout_wait will be
- * triggered after the current callout finishes.
- * wakeup_done_ctr - Set to the current value of wakeup_ctr after
- * callout_wait is triggered.
- */
-static struct mtx callout_wait_lock;
-static struct cv callout_wait;
-static int wakeup_done_ctr;
+static int callout_wait;
/*
* kern_timeout_callwheel_alloc() - kernel low level callwheel initialization
@@ -157,8 +142,6 @@
TAILQ_INIT(&callwheel[i]);
}
mtx_init(&callout_lock, "callout", NULL, MTX_SPIN | MTX_RECURSE);
- mtx_init(&callout_wait_lock, "callout_wait_lock", NULL, MTX_DEF);
- cv_init(&callout_wait, "callout_wait");
}
/*
@@ -188,7 +171,6 @@
int mpcalls;
int mtxcalls;
int gcalls;
- int wakeup_cookie;
#ifdef DIAGNOSTIC
struct bintime bt1, bt2;
struct timespec ts2;
@@ -262,8 +244,7 @@
*/
if (curr_cancelled) {
mtx_unlock(c_mtx);
- mtx_lock_spin(&callout_lock);
- goto done_locked;
+ goto skip;
}
/* The callout cannot be stopped now. */
curr_cancelled = 1;
@@ -308,22 +289,16 @@
#endif
if ((c_flags & CALLOUT_RETURNUNLOCKED) == 0)
mtx_unlock(c_mtx);
+ skip:
mtx_lock_spin(&callout_lock);
-done_locked:
curr_callout = NULL;
- if (wakeup_needed) {
+ if (callout_wait) {
/*
- * There might be someone waiting
+ * There is someone waiting
* for the callout to complete.
*/
- wakeup_cookie = wakeup_ctr;
- mtx_unlock_spin(&callout_lock);
- mtx_lock(&callout_wait_lock);
- cv_broadcast(&callout_wait);
- wakeup_done_ctr = wakeup_cookie;
- mtx_unlock(&callout_wait_lock);
- mtx_lock_spin(&callout_lock);
- wakeup_needed = 0;
+ wakeup(&callout_wait);
+ callout_wait = 0;
}
steps = 0;
c = nextsoftcheck;
@@ -445,7 +420,7 @@
*/
if (c->c_mtx != NULL && !curr_cancelled)
cancelled = curr_cancelled = 1;
- if (wakeup_needed) {
+ if (callout_wait) {
/*
* Someone has called callout_drain to kill this
* callout. Don't reschedule.
@@ -497,7 +472,7 @@
struct callout *c;
int safe;
{
- int use_mtx, wakeup_cookie;
+ int use_mtx;
if (!safe && c->c_mtx != NULL) {
#ifdef notyet /* Some callers do not hold Giant for Giant-locked callouts. */
@@ -512,37 +487,47 @@
mtx_lock_spin(&callout_lock);
/*
- * Don't attempt to delete a callout that's not on the queue.
+ * If the callout isn't pending, it's not on the queue, so
+ * don't attempt to remove it from the queue. We can try to
+ * stop it by other means however.
*/
if (!(c->c_flags & CALLOUT_PENDING)) {
c->c_flags &= ~CALLOUT_ACTIVE;
+
+ /*
+ * If it wasn't on the queue and it isn't the current
+ * callout, then we can't stop it, so just bail.
+ */
if (c != curr_callout) {
mtx_unlock_spin(&callout_lock);
return (0);
}
+
if (safe) {
- /* We need to wait until the callout is finished. */
- wakeup_needed = 1;
- wakeup_cookie = wakeup_ctr++;
- mtx_unlock_spin(&callout_lock);
- mtx_lock(&callout_wait_lock);
-
/*
- * Check to make sure that softclock() didn't
- * do the wakeup in between our dropping
- * callout_lock and picking up callout_wait_lock
+ * The current callout is running (or just
+ * about to run) and blocking is allowed, so
+ * just wait for the current invocation to
+ * finish.
*/
- if (wakeup_cookie - wakeup_done_ctr > 0)
- cv_wait(&callout_wait, &callout_wait_lock);
-
- mtx_unlock(&callout_wait_lock);
+ while (c == curr_callout) {
+ callout_wait = 1;
+ msleep_spin(&callout_wait, &callout_lock,
+ "codrain", 0);
+ }
} else if (use_mtx && !curr_cancelled) {
- /* We can stop the callout before it runs. */
+ /*
+ * The current callout is waiting for it's
+ * mutex which we hold. Cancel the callout
+ * and return. After our caller drops the
+ * mutex, the callout will be skipped in
+ * softclock().
+ */
curr_cancelled = 1;
mtx_unlock_spin(&callout_lock);
return (1);
- } else
- mtx_unlock_spin(&callout_lock);
+ }
+ mtx_unlock_spin(&callout_lock);
return (0);
}
c->c_flags &= ~(CALLOUT_ACTIVE | CALLOUT_PENDING);
==== //depot/projects/uart/modules/uart/Makefile#13 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/modules/uart/Makefile,v 1.13 2004/11/20 23:38:48 marcel Exp $
+# $FreeBSD: src/sys/modules/uart/Makefile,v 1.14 2006/02/24 01:49:36 marcel Exp $
.PATH: ${.CURDIR}/../../dev/uart
@@ -15,4 +15,8 @@
SRCS+= bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} pci_if.h \
power_if.h uart_if.h pccarddevs.h
+MFILES= dev/pccard/card_if.m dev/pccard/power_if.m dev/pci/pci_if.m \
+ dev/ofw/ofw_bus_if.m dev/uart/uart_if.m isa/isa_if.m kern/bus_if.m \
+ kern/device_if.m
+
.include <bsd.kmod.mk>
==== //depot/projects/uart/netinet/tcp_input.c#16 (text+ko) ====
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_input.c 8.12 (Berkeley) 5/24/95
- * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.289 2006/02/18 17:05:00 andre Exp $
+ * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.290 2006/02/23 21:14:34 qingli Exp $
*/
#include "opt_ipfw.h" /* for ipfw_fwd */
@@ -1421,7 +1421,7 @@
* SYN-SENT* -> SYN-RECEIVED*
* If there was no CC option, clear cached CC value.
*/
- tp->t_flags |= TF_ACKNOW;
+ tp->t_flags |= (TF_ACKNOW | TF_NEEDSYN);
callout_stop(tp->tt_rexmt);
tp->t_state = TCPS_SYN_RECEIVED;
}
==== //depot/projects/uart/netinet/tcp_output.c#9 (text+ko) ====
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_output.c 8.4 (Berkeley) 5/24/95
- * $FreeBSD: src/sys/netinet/tcp_output.c,v 1.114 2005/11/18 20:12:39 andre Exp $
+ * $FreeBSD: src/sys/netinet/tcp_output.c,v 1.115 2006/02/23 21:14:34 qingli Exp $
*/
#include "opt_inet.h"
@@ -338,7 +338,8 @@
* know that foreign host supports TAO, suppress sending segment.
*/
if ((flags & TH_SYN) && SEQ_GT(tp->snd_nxt, tp->snd_una)) {
- flags &= ~TH_SYN;
+ if (tp->t_state != TCPS_SYN_RECEIVED)
+ flags &= ~TH_SYN;
off--, len++;
}
More information about the p4-projects
mailing list