Date: Thu, 21 Apr 2005 13:38:25 GMT From: David Xu <davidxu@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 75666 for review Message-ID: <200504211338.j3LDcPDO016245@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=75666 Change 75666 by davidxu@davidxu_alona on 2005/04/21 13:37:37 IFC. Affected files ... .. //depot/projects/davidxu_thread/src/lib/Makefile#7 integrate .. //depot/projects/davidxu_thread/src/lib/libpmc/libpmc.c#3 integrate .. //depot/projects/davidxu_thread/src/share/man/man9/Makefile#10 integrate .. //depot/projects/davidxu_thread/src/share/man/man9/alloc_unr.9#1 branch .. //depot/projects/davidxu_thread/src/share/mklocale/be_BY.CP1131.src#2 integrate .. //depot/projects/davidxu_thread/src/sys/alpha/include/pmc_mdep.h#1 branch .. //depot/projects/davidxu_thread/src/sys/amd64/amd64/trap.c#3 integrate .. //depot/projects/davidxu_thread/src/sys/amd64/conf/NOTES#8 integrate .. //depot/projects/davidxu_thread/src/sys/amd64/include/pmc_mdep.h#2 integrate .. //depot/projects/davidxu_thread/src/sys/arm/include/pmc_mdep.h#1 branch .. //depot/projects/davidxu_thread/src/sys/conf/NOTES#11 integrate .. //depot/projects/davidxu_thread/src/sys/ddb/ddb.h#2 integrate .. //depot/projects/davidxu_thread/src/sys/dev/acpica/Osd/OsdSchedule.c#3 integrate .. //depot/projects/davidxu_thread/src/sys/dev/acpica/acpivar.h#11 integrate .. //depot/projects/davidxu_thread/src/sys/dev/ata/ata-all.c#9 integrate .. //depot/projects/davidxu_thread/src/sys/dev/ata/ata-all.h#10 integrate .. //depot/projects/davidxu_thread/src/sys/dev/ata/ata-lowlevel.c#11 integrate .. //depot/projects/davidxu_thread/src/sys/dev/ata/ata-queue.c#6 integrate .. //depot/projects/davidxu_thread/src/sys/dev/ata/ata-raid.c#6 integrate .. //depot/projects/davidxu_thread/src/sys/dev/fxp/if_fxp.c#8 integrate .. //depot/projects/davidxu_thread/src/sys/hwpmc/hwpmc_amd.c#2 integrate .. //depot/projects/davidxu_thread/src/sys/hwpmc/hwpmc_intel.c#2 integrate .. //depot/projects/davidxu_thread/src/sys/hwpmc/hwpmc_mod.c#3 integrate .. //depot/projects/davidxu_thread/src/sys/hwpmc/hwpmc_pentium.c#2 integrate .. //depot/projects/davidxu_thread/src/sys/hwpmc/hwpmc_piv.c#2 integrate .. //depot/projects/davidxu_thread/src/sys/hwpmc/hwpmc_ppro.c#2 integrate .. //depot/projects/davidxu_thread/src/sys/i386/conf/NOTES#10 integrate .. //depot/projects/davidxu_thread/src/sys/i386/i386/trap.c#3 integrate .. //depot/projects/davidxu_thread/src/sys/i386/include/pmc_mdep.h#2 integrate .. //depot/projects/davidxu_thread/src/sys/ia64/include/pmc_mdep.h#1 branch .. //depot/projects/davidxu_thread/src/sys/kern/kern_pmc.c#2 integrate .. //depot/projects/davidxu_thread/src/sys/modules/Makefile#13 integrate .. //depot/projects/davidxu_thread/src/sys/netgraph/ng_eiface.c#6 integrate .. //depot/projects/davidxu_thread/src/sys/netgraph/ng_vlan.c#2 integrate .. //depot/projects/davidxu_thread/src/sys/netinet/tcp_output.c#4 integrate .. //depot/projects/davidxu_thread/src/sys/netinet/tcp_subr.c#9 integrate .. //depot/projects/davidxu_thread/src/sys/netinet/tcp_var.h#8 integrate .. //depot/projects/davidxu_thread/src/sys/pc98/conf/NOTES#9 integrate .. //depot/projects/davidxu_thread/src/sys/powerpc/include/pmc_mdep.h#1 branch .. //depot/projects/davidxu_thread/src/sys/powerpc/powerpc/trap.c#7 integrate .. //depot/projects/davidxu_thread/src/sys/sparc64/include/pmc_mdep.h#1 branch .. //depot/projects/davidxu_thread/src/sys/sys/kdb.h#3 integrate .. //depot/projects/davidxu_thread/src/sys/sys/pmc.h#2 integrate .. //depot/projects/davidxu_thread/src/usr.sbin/Makefile#7 integrate Differences ... ==== //depot/projects/davidxu_thread/src/lib/Makefile#7 (text+ko) ==== @@ -1,5 +1,5 @@ # @(#)Makefile 8.1 (Berkeley) 6/4/93 -# $FreeBSD: src/lib/Makefile,v 1.204 2005/04/19 04:01:21 jkoshy Exp $ +# $FreeBSD: src/lib/Makefile,v 1.205 2005/04/20 20:50:32 marcel Exp $ # To satisfy shared library or ELF linkage when only the libraries being # built are visible: @@ -31,7 +31,7 @@ ${_libio} libipsec \ libipx libkiconv libmagic libmenu ${_libmilter} ${_libmp} \ ${_libncp} ${_libngatm} libopie libpam libpanel libpcap \ - ${_libpmc} ${_libpthread} ${_libsdp} ${_libsm} ${_libsmb} ${_libsmdb} \ + libpmc ${_libpthread} ${_libsdp} ${_libsm} ${_libsmb} ${_libsmdb} \ ${_libsmutil} libstand libtelnet ${_libthr} ${_libthread_db} libufs \ libugidfw ${_libusbhid} ${_libvgl} libwrap liby libz ${_bind} @@ -59,7 +59,6 @@ .if ${MACHINE_ARCH} == "i386" _libncp= libncp -_libpmc= libpmc _libsmb= libsmb _libvgl= libvgl .endif @@ -90,7 +89,6 @@ .if ${MACHINE_ARCH} == "amd64" _libncp= libncp -_libpmc= libpmc _libsmb= libsmb .endif ==== //depot/projects/davidxu_thread/src/lib/libpmc/libpmc.c#3 (text+ko) ==== @@ -25,15 +25,13 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/lib/libpmc/libpmc.c,v 1.2 2005/04/20 05:36:43 jkoshy Exp $"); +__FBSDID("$FreeBSD: src/lib/libpmc/libpmc.c,v 1.4 2005/04/21 05:50:25 jkoshy Exp $"); #include <sys/types.h> #include <sys/module.h> #include <sys/pmc.h> #include <sys/syscall.h> -#include <machine/pmc_mdep.h> - #include <ctype.h> #include <errno.h> #include <fcntl.h> @@ -45,7 +43,7 @@ #include <unistd.h> /* Function prototypes */ -#if __i386__ +#if defined(__i386__) static int k7_allocate_pmc(enum pmc_event _pe, char *_ctrspec, struct pmc_op_pmcallocate *_pmc_config); static int p6_allocate_pmc(enum pmc_event _pe, char *_ctrspec, @@ -54,7 +52,7 @@ struct pmc_op_pmcallocate *_pmc_config); static int p5_allocate_pmc(enum pmc_event _pe, char *_ctrspec, struct pmc_op_pmcallocate *_pmc_config); -#elif __amd64__ +#elif defined(__amd64__) static int k8_allocate_pmc(enum pmc_event _pe, char *_ctrspec, struct pmc_op_pmcallocate *_pmc_config); #endif @@ -152,6 +150,7 @@ #define PMCMASK(N,V) { .pm_name = #N, .pm_value = (V) } #define NULLMASK PMCMASK(NULL,0) +#if defined(__i386__) || defined(__amd64__) static int pmc_parse_mask(const struct pmc_masks *pmask, char *p, uint32_t *evmask) { @@ -175,26 +174,27 @@ } return c; } +#endif #define KWMATCH(p,kw) (strcasecmp((p), (kw)) == 0) #define KWPREFIXMATCH(p,kw) (strncasecmp((p), (kw), sizeof((kw)) - 1) == 0) #define EV_ALIAS(N,S) { .pm_alias = N, .pm_spec = S } -#if __i386__ +#if defined(__i386__) /* * AMD K7 (Athlon) CPUs. */ static struct pmc_event_alias k7_aliases[] = { -EV_ALIAS("branches", "k7-retired-branches"), -EV_ALIAS("branch-mispredicts", "k7-retired-branches-mispredicted"), -EV_ALIAS("cycles", "tsc"), -EV_ALIAS("dc-misses", "k7-dc-misses,mask=moesi"), -EV_ALIAS("ic-misses", "k7-ic-misses"), -EV_ALIAS("instructions", "k7-retired-instructions"), -EV_ALIAS("interrupts", "k7-hardware-interrupts"), -EV_ALIAS(NULL, NULL) + EV_ALIAS("branches", "k7-retired-branches"), + EV_ALIAS("branch-mispredicts", "k7-retired-branches-mispredicted"), + EV_ALIAS("cycles", "tsc"), + EV_ALIAS("dc-misses", "k7-dc-misses,mask=moesi"), + EV_ALIAS("ic-misses", "k7-ic-misses"), + EV_ALIAS("instructions", "k7-retired-instructions"), + EV_ALIAS("interrupts", "k7-hardware-interrupts"), + EV_ALIAS(NULL, NULL) }; #define K7_KW_COUNT "count" @@ -299,7 +299,11 @@ */ static struct pmc_event_alias p4_aliases[] = { - EV_ALIAS("cycles", "tsc"), + EV_ALIAS("branches", "p4-branch-retired,mask=mmtp+mmtm"), + EV_ALIAS("branch-mispredicts", "p4-mispred-branch-retired"), + EV_ALIAS("cycles", "tsc"), + EV_ALIAS("instructions", + "p4-instr-retired,mask=nbogusntag+nbogustag"), EV_ALIAS(NULL, NULL) }; @@ -512,7 +516,8 @@ NULLMASK }; -static const struct pmc_masks p4_mask_rmbt[] = { /* retired mispred branch type */ +static const struct pmc_masks p4_mask_rmbt[] = { + /* retired mispred branch type */ __P4MASK(conditional, 1), __P4MASK(call, 2), __P4MASK(return, 3), @@ -902,12 +907,14 @@ */ static struct pmc_event_alias p6_aliases[] = { -EV_ALIAS("branches", "p6-br-inst-retired"), -EV_ALIAS("branch-mispredicts", "p6-br-miss-pred-retired"), -EV_ALIAS("cycles", "tsc"), -EV_ALIAS("instructions", "p6-inst-retired"), -EV_ALIAS("interrupts", "p6-hw-int-rx"), -EV_ALIAS(NULL, NULL) + EV_ALIAS("branches", "p6-br-inst-retired"), + EV_ALIAS("branch-mispredicts", "p6-br-miss-pred-retired"), + EV_ALIAS("cycles", "tsc"), + EV_ALIAS("dc-misses", "p6-dcu-lines-in"), + EV_ALIAS("ic-misses", "p6-ifu-ifetch-miss"), + EV_ALIAS("instructions", "p6-inst-retired"), + EV_ALIAS("interrupts", "p6-hw-int-rx"), + EV_ALIAS(NULL, NULL) }; #define P6_KW_CMASK "cmask" @@ -1236,7 +1243,7 @@ return -1 || pe || ctrspec || pmc_config; /* shut up gcc */ } -#elif __amd64__ +#elif defined(__amd64__) /* * AMD K8 PMCs. @@ -1246,7 +1253,14 @@ */ static struct pmc_event_alias k8_aliases[] = { - EV_ALIAS("cycles", "tsc"), + EV_ALIAS("branches", "k8-fr-retired-taken-branches"), + EV_ALIAS("branch-mispredicts", + "k8-fr-retired-taken-branches-mispredicted"), + EV_ALIAS("cycles", "tsc"), + EV_ALIAS("dc-misses", "k8-dc-miss"), + EV_ALIAS("ic-misses", "k8-ic-miss"), + EV_ALIAS("instructions", "k8-fr-retired-x86-instructions"), + EV_ALIAS("interrupts", "k8-fr-taken-hardware-interrupts"), EV_ALIAS(NULL, NULL) }; @@ -1634,7 +1648,7 @@ /* set parser pointer */ switch (cpu_info.pm_cputype) { -#if __i386__ +#if defined(__i386__) case PMC_CPU_AMD_K7: pmc_mdep_event_aliases = k7_aliases; pmc_mdep_allocate_pmc = k7_allocate_pmc; @@ -1654,7 +1668,7 @@ pmc_mdep_event_aliases = p4_aliases; pmc_mdep_allocate_pmc = p4_allocate_pmc; break; -#elif __amd64__ +#elif defined(__amd64__) case PMC_CPU_AMD_K8: pmc_mdep_event_aliases = k8_aliases; pmc_mdep_allocate_pmc = k8_allocate_pmc; @@ -2117,7 +2131,7 @@ * Architecture specific APIs */ -#if __i386__ || __amd64__ +#if defined(__i386__) || defined(__amd64__) int pmc_x86_get_msr(pmc_id_t pmc, uint32_t *msr) ==== //depot/projects/davidxu_thread/src/share/man/man9/Makefile#10 (text+ko) ==== @@ -1,9 +1,10 @@ -# $FreeBSD: src/share/man/man9/Makefile,v 1.257 2005/04/15 10:57:34 pjd Exp $ +# $FreeBSD: src/share/man/man9/Makefile,v 1.258 2005/04/20 19:11:05 glebius Exp $ MAN= accept_filter.9 \ accf_data.9 \ accf_http.9 \ acl.9 \ + alloc_unr.9 \ alq.9 \ altq.9 \ atomic.9 \ @@ -334,7 +335,11 @@ zero_copy.9 \ zone.9 -MLINKS= alq.9 ALQ.9 \ +MLINKS= alloc_unr.9 alloc_unrl.9 \ + alloc_unr.9 delete_unrhdr.9 \ + alloc_unr.9 free_unr.9 \ + alloc_unr.9 new_unrhdr.9 +MLINKS+=alq.9 ALQ.9 \ alq.9 alq_close.9 \ alq.9 alq_flush.9 \ alq.9 alq_get.9 \ ==== //depot/projects/davidxu_thread/src/share/mklocale/be_BY.CP1131.src#2 (text+ko) ==== @@ -1,11 +1,11 @@ /* - * Belarusian language. Standard (1933) grammar. + * Belarusian language. Modern/standard (1959) grammar. * Prepared by Yury Tarasievich <spytar@yahoo.com> - * $FreeBSD: src/share/mklocale/be_BY.CP1131.src,v 1.1 2003/12/20 11:18:42 ache Exp $ + * $FreeBSD: src/share/mklocale/be_BY.CP1131.src,v 1.2 2005/04/21 09:15:19 ache Exp $ */ ENCODING "NONE" -VARIABLE Belarusian CP1131 (based on: Russian Alternative code table (CP866) by <ache@nagual.pp.ru>) +VARIABLE Belarusian CP1131 (extending the and based on: Russian Alternative code table (CP866) by <ache@nagual.pp.ru>) # # This is a comment ==== //depot/projects/davidxu_thread/src/sys/amd64/amd64/trap.c#3 (text+ko) ==== @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.282 2005/04/12 23:18:53 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/trap.c,v 1.283 2005/04/20 20:52:45 ps Exp $"); /* * AMD64 Trap and System call handling @@ -623,7 +623,7 @@ } #ifdef KDB - if (kdb_trap(type, 0, frame)) + if ((debugger_on_panic || kdb_active) && kdb_trap(type, 0, frame)) return; #endif printf("trap number = %d\n", type); ==== //depot/projects/davidxu_thread/src/sys/amd64/conf/NOTES#8 (text+ko) ==== @@ -4,7 +4,7 @@ # This file contains machine dependent kernel configuration notes. For # machine independent notes, look in /sys/conf/NOTES. # -# $FreeBSD: src/sys/amd64/conf/NOTES,v 1.31 2005/04/19 22:16:46 imp Exp $ +# $FreeBSD: src/sys/amd64/conf/NOTES,v 1.32 2005/04/20 22:19:51 marcel Exp $ # # @@ -56,19 +56,6 @@ ##################################################################### -# PERFORMANCE MONITORING OPTIONS - -# -# The hwpmc driver that allows the use of in-CPU performance monitoring -# counters for performance monitoring. The base kernel needs to configured -# with the 'options' line, while the hwpmc device can be either compiled -# in or loaded as a loadable kernel module. -# -device hwpmc # Driver (also a loadable module) -options HWPMC_HOOKS # Other necessary kernel hooks - - -##################################################################### # NETWORKING OPTIONS # ==== //depot/projects/davidxu_thread/src/sys/amd64/include/pmc_mdep.h#2 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/amd64/include/pmc_mdep.h,v 1.1 2005/04/19 04:01:22 jkoshy Exp $ + * $FreeBSD: src/sys/amd64/include/pmc_mdep.h,v 1.2 2005/04/20 20:22:33 marcel Exp $ */ /* Machine dependent interfaces */ @@ -31,7 +31,7 @@ #ifndef _MACHINE_PMC_MDEP_H #define _MACHINE_PMC_MDEP_H 1 -#include <sys/pmc.h> +#include <machine/specialreg.h> /* AMD K7 PMCs */ ==== //depot/projects/davidxu_thread/src/sys/conf/NOTES#11 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/NOTES,v 1.1311 2005/04/19 22:16:45 imp Exp $ +# $FreeBSD: src/sys/conf/NOTES,v 1.1312 2005/04/20 22:19:51 marcel Exp $ # # NOTES -- Lines that can be cut/pasted into kernel and hints configs. # @@ -422,6 +422,19 @@ ##################################################################### +# PERFORMANCE MONITORING OPTIONS + +# +# The hwpmc driver that allows the use of in-CPU performance monitoring +# counters for performance monitoring. The base kernel needs to configured +# with the 'options' line, while the hwpmc device can be either compiled +# in or loaded as a loadable kernel module. +# +device hwpmc # Driver (also a loadable module) +options HWPMC_HOOKS # Other necessary kernel hooks + + +##################################################################### # NETWORKING OPTIONS # ==== //depot/projects/davidxu_thread/src/sys/ddb/ddb.h#2 (text+ko) ==== @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/ddb/ddb.h,v 1.37 2004/11/01 22:15:14 jhb Exp $ + * $FreeBSD: src/sys/ddb/ddb.h,v 1.38 2005/04/20 20:52:45 ps Exp $ */ /* @@ -71,7 +71,6 @@ extern int db_indent; extern int db_inst_count; extern int db_load_count; -extern int debugger_on_panic; extern int db_store_count; extern db_expr_t db_radix; extern db_expr_t db_max_width; ==== //depot/projects/davidxu_thread/src/sys/dev/acpica/Osd/OsdSchedule.c#3 (text+ko) ==== @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/Osd/OsdSchedule.c,v 1.30 2004/12/02 00:25:35 marks Exp $ + * $FreeBSD: src/sys/dev/acpica/Osd/OsdSchedule.c,v 1.31 2005/04/21 06:13:48 njl Exp $ */ /* @@ -50,6 +50,13 @@ ACPI_MODULE_NAME("SCHEDULE") /* + * Allow the user to tune the number of task threads we start. It seems + * some systems have problems with increased parallelism. + */ +static int acpi_max_threads = ACPI_MAX_THREADS; +TUNABLE_INT("debug.acpi.max_threads", &acpi_max_threads); + +/* * This is a little complicated due to the fact that we need to build and then * free a 'struct task' for each task we enqueue. */ @@ -130,7 +137,7 @@ err = 0; STAILQ_INIT(&acpi_task_queue); - for (i = 0; i < ACPI_MAX_THREADS; i++) { + for (i = 0; i < acpi_max_threads; i++) { err = kthread_create(acpi_task_thread, NULL, &acpi_kthread_proc, 0, 0, "acpi_task%d", i); if (err != 0) { ==== //depot/projects/davidxu_thread/src/sys/dev/acpica/acpivar.h#11 (text+ko) ==== @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/acpivar.h,v 1.93 2005/04/10 19:07:08 njl Exp $ + * $FreeBSD: src/sys/dev/acpica/acpivar.h,v 1.94 2005/04/21 06:13:48 njl Exp $ */ #ifndef _ACPIVAR_H_ @@ -421,9 +421,8 @@ int *rid, struct resource **dst); ACPI_HANDLE acpi_GetReference(ACPI_HANDLE scope, ACPI_OBJECT *obj); -#ifndef ACPI_MAX_THREADS -#define ACPI_MAX_THREADS 1 -#endif +/* Default number of task queue threads to start. */ +#define ACPI_MAX_THREADS 3 /* ACPI task kernel thread initialization. */ int acpi_task_thread_init(void); ==== //depot/projects/davidxu_thread/src/sys/dev/ata/ata-all.c#9 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-all.c,v 1.244 2005/04/20 12:51:54 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-all.c,v 1.245 2005/04/21 11:13:39 sos Exp $"); #include "opt_ata.h" #include <sys/param.h> @@ -60,7 +60,7 @@ static d_ioctl_t ata_ioctl; static struct cdevsw ata_cdevsw = { .d_version = D_VERSION, - .d_flags = D_NEEDGIANT, /* we need this as newbus isn't safe */ + .d_flags = D_NEEDGIANT, /* we need this as newbus isn't mpsafe */ .d_ioctl = ata_ioctl, .d_name = "ata", }; @@ -68,7 +68,7 @@ /* prototypes */ static void ata_interrupt(void *); static void ata_boot_attach(void); -device_t ata_add_child(device_t parent, struct ata_device *atadev, int unit); +static device_t ata_add_child(device_t parent, struct ata_device *atadev, int unit); /* global vars */ MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer"); @@ -80,7 +80,6 @@ /* local vars */ static struct intr_config_hook *ata_delayed_attach = NULL; -static struct root_hold_token *ata_root_hold_token; static int ata_dma = 1; static int atapi_dma = 1; @@ -144,12 +143,9 @@ return error; } - /* do not attach devices if we are in early boot */ - if (ata_delayed_attach) - return 0; - - /* probe and attach devices on this channel */ - ata_identify(dev); + /* probe and attach devices on this channel unless we are in early boot */ + if (!ata_delayed_attach) + ata_identify(dev); return 0; } @@ -188,6 +184,7 @@ device_t *children; int nchildren, i; + /* check that we have a vaild channel to reinit */ if (!ch || !ch->r_irq) return ENXIO; @@ -198,7 +195,7 @@ while (ATA_LOCKING(dev, ATA_LF_LOCK) != ch->unit) tsleep(&dev, PRIBIO, "atarini", 1); - /* grap the channel lock */ + /* unconditionally grap the channel lock */ mtx_lock(&ch->state_mtx); ch->state = ATA_STALL_QUEUE; mtx_unlock(&ch->state_mtx); @@ -212,7 +209,12 @@ for (i = 0; i < nchildren; i++) { if (children[i] && device_is_attached(children[i])) if (ATA_REINIT(children[i])) { - if (ch->running->dev == children[i]) { + /* + * if we have a running request and its device matches + * this child we need to inform the request that the + * device is gone and remove it from ch->running + */ + if (ch->running && ch->running->dev == children[i]) { device_printf(ch->running->dev, "FAILURE - device detached\n"); ch->running->dev = NULL; @@ -225,7 +227,7 @@ mtx_unlock(&Giant); /* newbus suckage dealt with, release Giant */ } - /* catch running request if any */ + /* catch request in ch->running if we havn't already */ ata_catch_inflight(ch); /* we're done release the channel for new work */ @@ -247,10 +249,11 @@ { struct ata_channel *ch; + /* check for valid device */ if (!dev || !(ch = device_get_softc(dev))) return ENXIO; - /* wait for the channel to be IDLE before when enter suspend mode */ + /* wait for the channel to be IDLE before entering suspend mode */ while (1) { mtx_lock(&ch->state_mtx); if (ch->state == ATA_IDLE) { @@ -271,10 +274,11 @@ struct ata_channel *ch; int error; + /* check for valid device */ if (!dev || !(ch = device_get_softc(dev))) return ENXIO; - /* reinit the devices, we dont know what mode/state they have */ + /* reinit the devices, we dont know what mode/state they are in */ error = ata_reinit(dev); /* kick off requests on the queue */ @@ -304,18 +308,15 @@ } /* check for the right state */ - if (ch->state == ATA_ACTIVE || ch->state == ATA_STALL_QUEUE) { - request->flags |= ATA_R_INTR_SEEN; - } - else { + if (ch->state != ATA_ACTIVE && ch->state != ATA_STALL_QUEUE) { device_printf(request->dev, "interrupt state=%d unexpected\n", ch->state); break; } /* - * we have the HW locks, so start the tranaction for this request - * if it finishes immediately we dont need to wait for interrupt + * we have the HW locks, so end the tranaction for this request + * if it finishes immediately otherwise wait for next interrupt */ if (ch->hw.end_transaction(request) == ATA_OP_FINISHED) { ch->running = NULL; @@ -326,9 +327,6 @@ ata_finish(request); return; } - else { - request->flags &= ~ATA_R_INTR_SEEN; - } } while (0); mtx_unlock(&ch->state_mtx); } @@ -559,13 +557,13 @@ ata_identify(ch->dev); } } - root_mount_rel(ata_root_hold_token); } + /* * misc support functions */ -device_t +static device_t ata_add_child(device_t parent, struct ata_device *atadev, int unit) { struct ata_channel *ch = device_get_softc(parent); @@ -815,7 +813,6 @@ return EIO; } ata_delayed_attach->ich_func = (void*)ata_boot_attach; - ata_root_hold_token = root_mount_hold("ATA"); if (config_intrhook_establish(ata_delayed_attach) != 0) { printf("ata: config_intrhook_establish failed\n"); free(ata_delayed_attach, M_TEMP); ==== //depot/projects/davidxu_thread/src/sys/dev/ata/ata-all.h#10 (text+ko) ==== @@ -25,7 +25,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.96 2005/04/20 12:51:54 sos Exp $ + * $FreeBSD: src/sys/dev/ata/ata-all.h,v 1.97 2005/04/21 11:13:39 sos Exp $ */ /* ATA register defines */ @@ -277,12 +277,10 @@ #define ATA_R_CONTROL 0x00000001 #define ATA_R_READ 0x00000002 #define ATA_R_WRITE 0x00000004 -#define ATA_R_DMA 0x00000008 - -#define ATA_R_ATAPI 0x00000010 +#define ATA_R_ATAPI 0x00000008 +#define ATA_R_DMA 0x00000010 #define ATA_R_QUIET 0x00000020 -#define ATA_R_INTR_SEEN 0x00000040 -#define ATA_R_TIMEOUT 0x00000080 +#define ATA_R_TIMEOUT 0x00000040 #define ATA_R_ORDERED 0x00000100 #define ATA_R_AT_HEAD 0x00000200 @@ -468,6 +466,7 @@ void ata_queue_request(struct ata_request *request); void ata_start(device_t dev); void ata_finish(struct ata_request *request); +void ata_timeout(struct ata_request *); void ata_catch_inflight(struct ata_channel *ch); void ata_fail_requests(struct ata_channel *ch, device_t dev); char *ata_cmd2str(struct ata_request *request); ==== //depot/projects/davidxu_thread/src/sys/dev/ata/ata-lowlevel.c#11 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/ata/ata-lowlevel.c,v 1.60 2005/04/14 08:48:45 sos Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ata/ata-lowlevel.c,v 1.61 2005/04/21 11:13:39 sos Exp $"); #include "opt_ata.h" #include <sys/param.h> @@ -162,7 +162,7 @@ ch->hw.command = ata_generic_command; } -/* must be called with ATA channel locked */ +/* must be called with ATA channel locked and state_mtx held */ static int ata_begin_transaction(struct ata_request *request) { @@ -192,7 +192,7 @@ device_printf(request->dev, "error issueing %s command\n", ata_cmd2str(request)); request->result = EIO; - break; + goto begin_finished; } /* device reset doesn't interrupt */ @@ -204,7 +204,7 @@ } while (request->status & ATA_S_BUSY && timeout--); if (request->status & ATA_S_ERROR) request->error = ATA_IDX_INB(ch, ATA_ERROR); - break; + goto begin_finished; } /* if write command output the data */ @@ -213,12 +213,12 @@ (ATA_S_READY | ATA_S_DSC | ATA_S_DRQ)) < 0) { device_printf(request->dev,"timeout waiting for write DRQ"); request->result = EIO; - break; + goto begin_finished; } ata_pio_write(request, request->transfersize); } } - return ATA_OP_CONTINUES; + goto begin_continue; /* ATA DMA data transfer commands */ case ATA_R_DMA: @@ -227,7 +227,7 @@ request->flags & ATA_R_READ)) { device_printf(request->dev, "setting up DMA failed\n"); request->result = EIO; - break; + goto begin_finished; } /* issue command */ @@ -237,16 +237,16 @@ device_printf(request->dev, "error issueing %s command\n", ata_cmd2str(request)); request->result = EIO; - break; + goto begin_finished; } /* start DMA engine */ if (ch->dma->start(ch)) { device_printf(request->dev, "error starting DMA\n"); request->result = EIO; - break; + goto begin_finished; } - return ATA_OP_CONTINUES; + goto begin_continue; /* ATAPI PIO commands */ case ATA_R_ATAPI: @@ -256,7 +256,7 @@ DELAY(10); if (!(ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_DSC)) request->result = EBUSY; - break; + goto begin_finished; } /* start ATAPI operation */ @@ -264,12 +264,12 @@ request->transfersize << 8, 0, 0)) { device_printf(request->dev, "error issuing ATA PACKET command\n"); request->result = EIO; - break; + goto begin_finished; } /* command interrupt device ? just return and wait for interrupt */ if ((atadev->param.config & ATA_DRQ_MASK) == ATA_DRQ_INTR) - return ATA_OP_CONTINUES; + goto begin_continue; /* wait for ready to write ATAPI command block */ { @@ -286,7 +286,7 @@ if (timeout <= 0) { device_printf(request->dev,"timeout waiting for ATAPI ready\n"); request->result = EIO; - break; + goto begin_finished; } } @@ -298,7 +298,7 @@ (int16_t *)request->u.atapi.ccb, (atadev->param.config & ATA_PROTO_MASK) == ATA_PROTO_ATAPI_12 ? 6 : 8); - return ATA_OP_CONTINUES; + goto begin_continue; case ATA_R_ATAPI|ATA_R_DMA: /* is this just a POLL DSC command ? */ @@ -307,7 +307,7 @@ DELAY(10); if (!(ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_DSC)) request->result = EBUSY; - break; + goto begin_finished; } /* check sanity, setup SG list and DMA engine */ @@ -315,14 +315,14 @@ request->flags & ATA_R_READ)) { device_printf(request->dev, "setting up DMA failed\n"); request->result = EIO; - break; + goto begin_finished; } /* start ATAPI operation */ if (ch->hw.command(atadev, ATA_PACKET_CMD, 0, 0, ATA_F_DMA)) { device_printf(request->dev, "error issuing ATAPI packet command\n"); request->result = EIO; - break; + goto begin_finished; } /* wait for ready to write ATAPI command block */ @@ -340,7 +340,7 @@ if (timeout <= 0) { device_printf(request->dev,"timeout waiting for ATAPI ready\n"); request->result = EIO; - break; + goto begin_finished; } } @@ -356,17 +356,25 @@ /* start DMA engine */ if (ch->dma->start(ch)) { request->result = EIO; - break; + goto begin_finished; } - return ATA_OP_CONTINUES; + goto begin_continue; } + /* NOT REACHED */ + printf("ata_begin_transaction OOPS!!!\n"); - /* request finish here */ +begin_finished: if (ch->dma && ch->dma->flags & ATA_DMA_LOADED) ch->dma->unload(ch); return ATA_OP_FINISHED; + +begin_continue: + callout_reset(&request->callout, request->timeout * hz, + (timeout_t*)ata_timeout, request); + return ATA_OP_CONTINUES; } +/* must be called with ATA channel locked and state_mtx held */ static int ata_end_transaction(struct ata_request *request) { @@ -386,8 +394,7 @@ /* on timeouts we have no data or anything so just return */ if (request->flags & ATA_R_TIMEOUT) - //return ATA_OP_FINISHED; - break; + goto end_finished; /* on control commands read back registers to the request struct */ if (request->flags & ATA_R_CONTROL) { @@ -418,8 +425,7 @@ /* if we got an error we are done with the HW */ if (request->status & ATA_S_ERROR) { request->error = ATA_IDX_INB(ch, ATA_ERROR); - //return ATA_OP_FINISHED; - break; + goto end_finished; } /* are we moving data ? */ @@ -431,8 +437,7 @@ (ATA_S_READY | ATA_S_DSC | ATA_S_DRQ)) < 0) { device_printf(request->dev, "timeout waiting for read DRQ"); request->result = EIO; - //return ATA_OP_FINISHED; - break; + goto end_finished; } ata_pio_read(request, request->transfersize); } @@ -457,23 +462,21 @@ device_printf(request->dev, "timeout waiting for write DRQ"); request->status = ATA_IDX_INB(ch, ATA_STATUS); - //return ATA_OP_FINISHED; - break; + goto end_finished; } /* output data and return waiting for new interrupt */ ata_pio_write(request, request->transfersize); - return ATA_OP_CONTINUES; + goto end_continue; } /* if data read command, return & wait for interrupt */ if (request->flags & ATA_R_READ) - return ATA_OP_CONTINUES; + goto end_continue; } } /* done with HW */ - //return ATA_OP_FINISHED; - break; + goto end_finished; /* ATA DMA data transfer commands */ case ATA_R_DMA: @@ -494,8 +497,7 @@ ch->dma->unload(ch); /* done with HW */ - //return ATA_OP_FINISHED; - break; + goto end_finished; /* ATAPI PIO commands */ case ATA_R_ATAPI: @@ -503,8 +505,7 @@ /* on timeouts we have no data or anything so just return */ if (request->flags & ATA_R_TIMEOUT) - //return ATA_OP_FINISHED; - break; + goto end_finished; switch ((ATA_IDX_INB(ch, ATA_IREASON) & (ATA_I_CMD | ATA_I_IN)) | (request->status & ATA_S_DRQ)) { @@ -516,14 +517,13 @@ if (!(request->status & ATA_S_DRQ)) { device_printf(request->dev, "command interrupt without DRQ\n"); request->status = ATA_S_ERROR; - //return ATA_OP_FINISHED; - break; + goto end_finished; } ATA_IDX_OUTSW_STRM(ch, ATA_DATA, (int16_t *)request->u.atapi.ccb, (atadev->param.config & ATA_PROTO_MASK)== ATA_PROTO_ATAPI_12 ? 6 : 8); /* return wait for interrupt */ - return ATA_OP_CONTINUES; + goto end_continue; case ATAPI_P_WRITE: if (request->flags & ATA_R_READ) { @@ -531,7 +531,7 @@ device_printf(request->dev, "%s trying to write on read buffer\n", ata_cmd2str(request)); - //return ATA_OP_FINISHED; + goto end_finished; break; } ata_pio_write(request, length); @@ -541,7 +541,7 @@ >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200504211338.j3LDcPDO016245>