From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 01:54:42 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA72C106566C; Sun, 10 Apr 2011 01:54:42 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C919C8FC13; Sun, 10 Apr 2011 01:54:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3A1sgvQ031717; Sun, 10 Apr 2011 01:54:42 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3A1sgRf031715; Sun, 10 Apr 2011 01:54:42 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201104100154.p3A1sgRf031715@svn.freebsd.org> From: Rick Macklem Date: Sun, 10 Apr 2011 01:54:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220510 - head/usr.sbin/nfsd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 01:54:42 -0000 Author: rmacklem Date: Sun Apr 10 01:54:42 2011 New Revision: 220510 URL: http://svn.freebsd.org/changeset/base/220510 Log: Add support for a backup stable restart file to the nfsd, used for NFSv4 restart. This permits the nfsd to create the stable restart file as required and minimizes the risk of trouble if the file is lost. Suggested by: Tim Kientzle Reviewed by: jhb MFC after: 2 weeks Modified: head/usr.sbin/nfsd/nfsd.c Modified: head/usr.sbin/nfsd/nfsd.c ============================================================================== --- head/usr.sbin/nfsd/nfsd.c Sun Apr 10 01:21:02 2011 (r220509) +++ head/usr.sbin/nfsd/nfsd.c Sun Apr 10 01:54:42 2011 (r220510) @@ -51,6 +51,9 @@ static const char rcsid[] = #include #include #include +#include +#include +#include #include #include @@ -79,6 +82,7 @@ int debug = 0; #endif #define NFSD_STABLERESTART "/var/db/nfs-stablerestart" +#define NFSD_STABLEBACKUP "/var/db/nfs-stablerestart.bak" #define MAXNFSDCNT 256 #define DEFNFSDCNT 4 pid_t children[MAXNFSDCNT]; /* PIDs of children */ @@ -86,6 +90,8 @@ int nfsdcnt; /* number of children */ int new_syscall; int run_v4server = 0; /* Force running of nfsv4 server */ int nfssvc_nfsd; /* Set to correct NFSSVC_xxx flag */ +int stablefd = -1; /* Fd for the stable restart file */ +int backupfd; /* Fd for the backup stable restart file */ void cleanup(int); void child_cleanup(int); @@ -98,6 +104,9 @@ int setbindhost(struct addrinfo **ia, co void start_server(int); void unregistration(void); void usage(void); +void open_stable(int *, int *); +void copy_stable(int, int); +void backup_stable(int); /* * Nfs server daemon mostly just a user context for nfssvc() @@ -136,7 +145,7 @@ main(int argc, char **argv) int tcp6sock, ip6flag, tcpflag, tcpsock; int udpflag, ecode, error, s, srvcnt; int bindhostc, bindanyflag, rpcbreg, rpcbregcnt; - int stablefd, nfssvc_addsock; + int nfssvc_addsock; char **bindhost = NULL; pid_t pid; @@ -346,6 +355,7 @@ main(int argc, char **argv) } (void)signal(SIGSYS, nonfs); (void)signal(SIGCHLD, reapchild); + (void)signal(SIGUSR2, backup_stable); openlog("nfsd", LOG_PID, LOG_DAEMON); @@ -355,22 +365,21 @@ main(int argc, char **argv) * regular nfssvc() call to service NFS requests. * (This way the file remains open until the last nfsd is killed * off.) - * Note that this file is not created by this daemon and can - * only be relocated by recompiling the daemon, in order to - * minimize accidentally starting up with the wrong file. - * If should be created as an empty file Read and Write for - * root before the first time you run NFS v4 and should never - * be re-initialized if at all possible. It should live on a + * It and the backup copy will be created as empty files + * the first time this nfsd is started and should never be + * deleted/replaced if at all possible. It should live on a * local, non-volatile storage device that does not do hardware * level write-back caching. (See SCSI doc for more information * on how to prevent write-back caching on SCSI disks.) */ if (run_v4server > 0) { - stablefd = open(NFSD_STABLERESTART, O_RDWR, 0); + open_stable(&stablefd, &backupfd); if (stablefd < 0) { syslog(LOG_ERR, "Can't open %s\n", NFSD_STABLERESTART); exit(1); } + /* This system call will fail for old kernels, but that's ok. */ + nfssvc(NFSSVC_BACKUPSTABLE, NULL); if (nfssvc(NFSSVC_STABLERESTART, (caddr_t)&stablefd) < 0) { syslog(LOG_ERR, "Can't read stable storage file\n"); exit(1); @@ -739,9 +748,9 @@ main(int argc, char **argv) if (select(maxsock + 1, &ready, NULL, NULL, NULL) < 1) { error = errno; - syslog(LOG_ERR, "select failed: %m"); if (error == EINTR) continue; + syslog(LOG_ERR, "select failed: %m"); nfsd_exit(1); } } @@ -973,3 +982,95 @@ start_server(int master) else exit(status); } + +/* + * Open the stable restart file and return the file descriptor for it. + */ +void +open_stable(int *stable_fdp, int *backup_fdp) +{ + int stable_fd, backup_fd = -1, ret; + struct stat st, backup_st; + + /* Open and stat the stable restart file. */ + stable_fd = open(NFSD_STABLERESTART, O_RDWR, 0); + if (stable_fd < 0) + stable_fd = open(NFSD_STABLERESTART, O_RDWR | O_CREAT, 0600); + if (stable_fd >= 0) { + ret = fstat(stable_fd, &st); + if (ret < 0) { + close(stable_fd); + stable_fd = -1; + } + } + + /* Open and stat the backup stable restart file. */ + if (stable_fd >= 0) { + backup_fd = open(NFSD_STABLEBACKUP, O_RDWR, 0); + if (backup_fd < 0) + backup_fd = open(NFSD_STABLEBACKUP, O_RDWR | O_CREAT, + 0600); + if (backup_fd >= 0) { + ret = fstat(backup_fd, &backup_st); + if (ret < 0) { + close(backup_fd); + backup_fd = -1; + } + } + if (backup_fd < 0) { + close(stable_fd); + stable_fd = -1; + } + } + + *stable_fdp = stable_fd; + *backup_fdp = backup_fd; + if (stable_fd < 0) + return; + + /* Sync up the 2 files, as required. */ + if (st.st_size > 0) + copy_stable(stable_fd, backup_fd); + else if (backup_st.st_size > 0) + copy_stable(backup_fd, stable_fd); +} + +/* + * Copy the stable restart file to the backup or vice versa. + */ +void +copy_stable(int from_fd, int to_fd) +{ + int cnt, ret; + static char buf[1024]; + + ret = lseek(from_fd, (off_t)0, SEEK_SET); + if (ret >= 0) + ret = lseek(to_fd, (off_t)0, SEEK_SET); + if (ret >= 0) + ret = ftruncate(to_fd, (off_t)0); + if (ret >= 0) + do { + cnt = read(from_fd, buf, 1024); + if (cnt > 0) + ret = write(to_fd, buf, cnt); + else if (cnt < 0) + ret = cnt; + } while (cnt > 0 && ret >= 0); + if (ret >= 0) + ret = fsync(to_fd); + if (ret < 0) + syslog(LOG_ERR, "stable restart copy failure: %m"); +} + +/* + * Back up the stable restart file when indicated by the kernel. + */ +void +backup_stable(__unused int signo) +{ + + if (stablefd >= 0) + copy_stable(stablefd, backupfd); +} + From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 03:49:54 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 336C4106564A; Sun, 10 Apr 2011 03:49:54 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 214748FC17; Sun, 10 Apr 2011 03:49:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3A3ns7h034156; Sun, 10 Apr 2011 03:49:54 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3A3nsAd034153; Sun, 10 Apr 2011 03:49:54 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201104100349.p3A3nsAd034153@svn.freebsd.org> From: Jeff Roberson Date: Sun, 10 Apr 2011 03:49:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220511 - head/sys/ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 03:49:54 -0000 Author: jeff Date: Sun Apr 10 03:49:53 2011 New Revision: 220511 URL: http://svn.freebsd.org/changeset/base/220511 Log: Fix a long standing SUJ performance problem: - Keep a hash of indirect blocks that have recently been freed and are still referenced in the journal. - Lookup blocks in this hash before forcing a new block write to wait on the journal entry to hit the disk. This is only necessary to avoid confusion between old identities as indirects and new identities as file blocks. - Don't free jseg structures until the journal has written a record that invalidates it. This keeps the indirect block information around for as long as is required to be safe. - Force an empty journal block write when required to flush out stale journal data that is simply waiting for the oldest valid sequence number to advance beyond it. Modified: head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ffs/softdep.h Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Sun Apr 10 01:54:42 2011 (r220510) +++ head/sys/ufs/ffs/ffs_softdep.c Sun Apr 10 03:49:53 2011 (r220511) @@ -753,8 +753,7 @@ static void handle_written_jnewblk(struc static void handle_written_jfreeblk(struct jfreeblk *); static void handle_written_jfreefrag(struct jfreefrag *); static void complete_jseg(struct jseg *); -static void jseg_write(struct ufsmount *ump, struct jblocks *, struct jseg *, - uint8_t *); +static void jseg_write(struct ufsmount *ump, struct jseg *, uint8_t *); static void jaddref_write(struct jaddref *, struct jseg *, uint8_t *); static void jremref_write(struct jremref *, struct jseg *, uint8_t *); static void jmvref_write(struct jmvref *, struct jseg *, uint8_t *); @@ -769,6 +768,7 @@ static void handle_allocdirect_partdone( static struct jnewblk *cancel_newblk(struct newblk *, struct worklist *, struct workhead *); static void indirdep_complete(struct indirdep *); +static int indirblk_inseg(struct mount *, ufs2_daddr_t); static void handle_allocindir_partdone(struct allocindir *); static void initiate_write_filepage(struct pagedep *, struct buf *); static void initiate_write_indirdep(struct indirdep*, struct buf *); @@ -802,7 +802,9 @@ static void free_newdirblk(struct newdir static void free_jremref(struct jremref *); static void free_jaddref(struct jaddref *); static void free_jsegdep(struct jsegdep *); -static void free_jseg(struct jseg *); +static void free_jsegs(struct jblocks *); +static void rele_jseg(struct jseg *); +static void free_jseg(struct jseg *, struct jblocks *); static void free_jnewblk(struct jnewblk *); static void free_jfreeblk(struct jfreeblk *); static void free_jfreefrag(struct jfreefrag *); @@ -872,7 +874,7 @@ static int journal_unsuspend(struct ufsm static void softdep_prelink(struct vnode *, struct vnode *); static void add_to_journal(struct worklist *); static void remove_from_journal(struct worklist *); -static void softdep_process_journal(struct mount *, int); +static void softdep_process_journal(struct mount *, struct worklist *, int); static struct jremref *newjremref(struct dirrem *, struct inode *, struct inode *ip, off_t, nlink_t); static struct jaddref *newjaddref(struct inode *, ino_t, off_t, int16_t, @@ -1376,7 +1378,7 @@ softdep_process_worklist(mp, full) ump = VFSTOUFS(mp); ACQUIRE_LOCK(&lk); starttime = time_second; - softdep_process_journal(mp, full?MNT_WAIT:0); + softdep_process_journal(mp, NULL, full?MNT_WAIT:0); while (ump->softdep_on_worklist > 0) { if ((cnt = process_worklist_item(mp, LK_NOWAIT)) == -1) break; @@ -1999,6 +2001,37 @@ newblk_lookup(mp, newblkno, flags, newbl } /* + * Structures and routines associated with indir caching. + */ +struct workhead *indir_hashtbl; +u_long indir_hash; /* size of hash table - 1 */ +#define INDIR_HASH(mp, blkno) \ + (&indir_hashtbl[((((register_t)(mp)) >> 13) + (blkno)) & indir_hash]) + +static int +indirblk_inseg(mp, blkno) + struct mount *mp; + ufs2_daddr_t blkno; +{ + struct freework *freework; + struct workhead *wkhd; + struct worklist *wk; + + wkhd = INDIR_HASH(mp, blkno); + LIST_FOREACH(wk, wkhd, wk_list) { + freework = WK_FREEWORK(wk); + if (freework->fw_blkno == blkno && + freework->fw_list.wk_mp == mp) { + LIST_REMOVE(freework, fw_next); + WORKLIST_REMOVE(&freework->fw_list); + WORKITEM_FREE(freework, D_FREEWORK); + return (1); + } + } + return (0); +} + +/* * Executed during filesystem system initialization before * mounting any filesystems. */ @@ -2012,6 +2045,7 @@ softdep_initialize() inodedep_hashtbl = hashinit(desiredvnodes, M_INODEDEP, &inodedep_hash); newblk_hashtbl = hashinit(desiredvnodes / 5, M_NEWBLK, &newblk_hash); bmsafemap_hashtbl = hashinit(1024, M_BMSAFEMAP, &bmsafemap_hash); + indir_hashtbl = hashinit(desiredvnodes / 10, M_FREEWORK, &indir_hash); /* initialise bioops hack */ bioops.io_start = softdep_disk_io_initiation; @@ -2120,9 +2154,12 @@ softdep_unmount(mp) struct jblocks { struct jseglst jb_segs; /* TAILQ of current segments. */ struct jseg *jb_writeseg; /* Next write to complete. */ + struct jseg *jb_oldestseg; /* Oldest segment with valid entries. */ struct jextent *jb_extent; /* Extent array. */ uint64_t jb_nextseq; /* Next sequence number. */ - uint64_t jb_oldestseq; /* Oldest active sequence number. */ + uint64_t jb_oldestwrseq; /* Oldest written sequence number. */ + uint8_t jb_needseg; /* Need a forced segment. */ + uint8_t jb_suspended; /* Did journal suspend writes? */ int jb_avail; /* Available extents. */ int jb_used; /* Last used extent. */ int jb_head; /* Allocator head. */ @@ -2132,7 +2169,6 @@ struct jblocks { int jb_min; /* Minimum free space. */ int jb_low; /* Low on space. */ int jb_age; /* Insertion time of oldest rec. */ - int jb_suspended; /* Did journal suspend writes? */ }; struct jextent { @@ -2575,9 +2611,8 @@ softdep_prelink(dvp, vp) } static void -jseg_write(ump, jblocks, jseg, data) +jseg_write(ump, jseg, data) struct ufsmount *ump; - struct jblocks *jblocks; struct jseg *jseg; uint8_t *data; { @@ -2585,7 +2620,7 @@ jseg_write(ump, jblocks, jseg, data) rec = (struct jsegrec *)data; rec->jsr_seq = jseg->js_seq; - rec->jsr_oldest = jblocks->jb_oldestseq; + rec->jsr_oldest = jseg->js_oldseq; rec->jsr_cnt = jseg->js_cnt; rec->jsr_blocks = jseg->js_size / ump->um_devvp->v_bufobj.bo_bsize; rec->jsr_crc = 0; @@ -2722,8 +2757,9 @@ jtrunc_write(jtrunc, jseg, data) * Flush some journal records to disk. */ static void -softdep_process_journal(mp, flags) +softdep_process_journal(mp, needwk, flags) struct mount *mp; + struct worklist *needwk; int flags; { struct jblocks *jblocks; @@ -2755,17 +2791,23 @@ softdep_process_journal(mp, flags) jrecmin = (devbsize / JREC_SIZE) - 1; /* -1 for seg header */ jrecmax = (fs->fs_bsize / devbsize) * jrecmin; segwritten = 0; - while ((cnt = ump->softdep_on_journal) != 0) { + for (;;) { + cnt = ump->softdep_on_journal; /* - * Create a new segment to hold as many as 'cnt' journal - * entries and add them to the segment. Notice cnt is - * off by one to account for the space required by the - * jsegrec. If we don't have a full block to log skip it - * unless we haven't written anything. + * Criteria for writing a segment: + * 1) We have a full block. + * 2) We're called from jwait() and haven't found the + * journal item yet. + * 3) Always write if needseg is set. + * 4) If we are called from process_worklist and have + * not yet written anything we write a partial block + * to enforce a 1 second maximum latency on journal + * entries. */ - cnt++; - if (cnt < jrecmax && segwritten) + if (cnt < (jrecmax - 1) && needwk == NULL && + jblocks->jb_needseg == 0 && (segwritten || cnt == 0)) break; + cnt++; /* * Verify some free journal space. softdep_prealloc() should * guarantee that we don't run out so this is indicative of @@ -2783,6 +2825,7 @@ softdep_process_journal(mp, flags) jseg = malloc(sizeof(*jseg), M_JSEG, M_SOFTDEP_FLAGS); workitem_alloc(&jseg->js_list, D_JSEG, mp); LIST_INIT(&jseg->js_entries); + LIST_INIT(&jseg->js_indirs); jseg->js_state = ATTACHED; jseg->js_jblocks = jblocks; bp = geteblk(fs->fs_bsize, 0); @@ -2794,7 +2837,8 @@ softdep_process_journal(mp, flags) * the caller will loop if the entry it cares about is * not written. */ - if (ump->softdep_on_journal == 0 || jblocks->jb_free == 0) { + cnt = ump->softdep_on_journal; + if (cnt + jblocks->jb_needseg == 0 || jblocks->jb_free == 0) { bp->b_flags |= B_INVAL | B_NOCACHE; WORKITEM_FREE(jseg, D_JSEG); FREE_LOCK(&lk); @@ -2806,8 +2850,9 @@ softdep_process_journal(mp, flags) * Calculate the disk block size required for the available * records rounded to the min size. */ - cnt = ump->softdep_on_journal; - if (cnt < jrecmax) + if (cnt == 0) + size = devbsize; + else if (cnt < jrecmax) size = howmany(cnt, jrecmin) * devbsize; else size = fs->fs_bsize; @@ -2827,15 +2872,15 @@ softdep_process_journal(mp, flags) * Initialize our jseg with cnt records. Assign the next * sequence number to it and link it in-order. */ - cnt = MIN(ump->softdep_on_journal, - (size / devbsize) * jrecmin); + cnt = MIN(cnt, (size / devbsize) * jrecmin); jseg->js_buf = bp; jseg->js_cnt = cnt; jseg->js_refs = cnt + 1; /* Self ref. */ jseg->js_size = size; jseg->js_seq = jblocks->jb_nextseq++; - if (TAILQ_EMPTY(&jblocks->jb_segs)) - jblocks->jb_oldestseq = jseg->js_seq; + if (jblocks->jb_oldestseg == NULL) + jblocks->jb_oldestseg = jseg; + jseg->js_oldseq = jblocks->jb_oldestseg->js_seq; TAILQ_INSERT_TAIL(&jblocks->jb_segs, jseg, js_next); if (jblocks->jb_writeseg == NULL) jblocks->jb_writeseg = jseg; @@ -2846,12 +2891,16 @@ softdep_process_journal(mp, flags) off = 0; while ((wk = LIST_FIRST(&ump->softdep_journal_pending)) != NULL) { + if (cnt == 0) + break; /* Place a segment header on every device block. */ if ((off % devbsize) == 0) { - jseg_write(ump, jblocks, jseg, data); + jseg_write(ump, jseg, data); off += JREC_SIZE; data = bp->b_data + off; } + if (wk == needwk) + needwk = NULL; remove_from_journal(wk); wk->wk_state |= IOSTARTED; WORKLIST_INSERT(&jseg->js_entries, wk); @@ -2882,23 +2931,28 @@ softdep_process_journal(mp, flags) TYPENAME(wk->wk_type)); /* NOTREACHED */ } - if (--cnt == 0) - break; off += JREC_SIZE; data = bp->b_data + off; + cnt--; } /* * Write this one buffer and continue. */ + segwritten = 1; + jblocks->jb_needseg = 0; WORKLIST_INSERT(&bp->b_dep, &jseg->js_list); FREE_LOCK(&lk); BO_LOCK(bp->b_bufobj); bgetvp(ump->um_devvp, bp); BO_UNLOCK(bp->b_bufobj); - if (flags == MNT_NOWAIT) - bawrite(bp); - else + /* + * We only do the blocking wait once we find the journal + * entry we're looking for. + */ + if (needwk == NULL && flags & MNT_WAIT) bwrite(bp); + else + bawrite(bp); ACQUIRE_LOCK(&lk); } /* @@ -2949,7 +3003,7 @@ complete_jseg(jseg) break; case D_JMVREF: /* No jsegdep here. */ - free_jseg(jseg); + rele_jseg(jseg); jmvref = WK_JMVREF(wk); LIST_REMOVE(jmvref, jm_deps); free_pagedep(jmvref->jm_pagedep); @@ -2977,7 +3031,7 @@ complete_jseg(jseg) wakeup(wk); } /* Release the self reference so the structure may be freed. */ - free_jseg(jseg); + rele_jseg(jseg); } /* @@ -3009,11 +3063,16 @@ handle_written_jseg(jseg, bp) return; /* Iterate through available jsegs processing their entries. */ do { + jblocks->jb_oldestwrseq = jseg->js_oldseq; jsegn = TAILQ_NEXT(jseg, js_next); complete_jseg(jseg); jseg = jsegn; } while (jseg && jseg->js_state & DEPCOMPLETE); jblocks->jb_writeseg = jseg; + /* + * Attempt to free jsegs now that oldestwrseq may have advanced. + */ + free_jsegs(jblocks); } static inline struct jsegdep * @@ -3682,6 +3741,8 @@ cancel_jnewblk(jnewblk, wkhd) struct jsegdep *jsegdep; jsegdep = jnewblk->jn_jsegdep; + if (jnewblk->jn_jsegdep == NULL || jnewblk->jn_dep == NULL) + panic("cancel_jnewblk: Invalid state"); jnewblk->jn_jsegdep = NULL; jnewblk->jn_dep = NULL; jnewblk->jn_state |= GOINGAWAY; @@ -3709,34 +3770,97 @@ free_jfreeblk(jfreeblk) } /* - * Release one reference to a jseg and free it if the count reaches 0. This - * should eventually reclaim journal space as well. + * Free a single jseg once it is no longer referenced in memory or on + * disk. Reclaim journal blocks and dependencies waiting for the segment + * to disappear. */ static void -free_jseg(jseg) +free_jseg(jseg, jblocks) struct jseg *jseg; + struct jblocks *jblocks; { + struct freework *freework; + + /* + * Free freework structures that were lingering to indicate freed + * indirect blocks that forced journal write ordering on reallocate. + */ + while ((freework = LIST_FIRST(&jseg->js_indirs)) != NULL) { + LIST_REMOVE(freework, fw_next); + WORKLIST_REMOVE(&freework->fw_list); + WORKITEM_FREE(freework, D_FREEWORK); + } + if (jblocks->jb_oldestseg == jseg) + jblocks->jb_oldestseg = TAILQ_NEXT(jseg, js_next); + TAILQ_REMOVE(&jblocks->jb_segs, jseg, js_next); + jblocks_free(jblocks, jseg->js_list.wk_mp, jseg->js_size); + KASSERT(LIST_EMPTY(&jseg->js_entries), + ("free_jseg: Freed jseg has valid entries.")); + WORKITEM_FREE(jseg, D_JSEG); +} + +/* + * Free all jsegs that meet the criteria for being reclaimed and update + * oldestseg. + */ +static void +free_jsegs(jblocks) struct jblocks *jblocks; +{ + struct jseg *jseg; - KASSERT(jseg->js_refs > 0, - ("free_jseg: Invalid refcnt %d", jseg->js_refs)); - if (--jseg->js_refs != 0) - return; /* * Free only those jsegs which have none allocated before them to * preserve the journal space ordering. */ - jblocks = jseg->js_jblocks; while ((jseg = TAILQ_FIRST(&jblocks->jb_segs)) != NULL) { - jblocks->jb_oldestseq = jseg->js_seq; - if (jseg->js_refs != 0) + /* + * Only reclaim space when nothing depends on this journal + * set and another set has written that it is no longer + * valid. + */ + if (jseg->js_refs != 0) { + jblocks->jb_oldestseg = jseg; + return; + } + if (!LIST_EMPTY(&jseg->js_indirs) && + jseg->js_seq >= jblocks->jb_oldestwrseq) break; - TAILQ_REMOVE(&jblocks->jb_segs, jseg, js_next); - jblocks_free(jblocks, jseg->js_list.wk_mp, jseg->js_size); - KASSERT(LIST_EMPTY(&jseg->js_entries), - ("free_jseg: Freed jseg has valid entries.")); - WORKITEM_FREE(jseg, D_JSEG); + free_jseg(jseg, jblocks); } + /* + * If we exited the loop above we still must discover the + * oldest valid segment. + */ + if (jseg) + for (jseg = jblocks->jb_oldestseg; jseg != NULL; + jseg = TAILQ_NEXT(jseg, js_next)) + if (jseg->js_refs != 0) + break; + jblocks->jb_oldestseg = jseg; + /* + * The journal has no valid records but some jsegs may still be + * waiting on oldestwrseq to advance. We force a small record + * out to permit these lingering records to be reclaimed. + */ + if (jblocks->jb_oldestseg == NULL && !TAILQ_EMPTY(&jblocks->jb_segs)) + jblocks->jb_needseg = 1; +} + +/* + * Release one reference to a jseg and free it if the count reaches 0. This + * should eventually reclaim journal space as well. + */ +static void +rele_jseg(jseg) + struct jseg *jseg; +{ + + KASSERT(jseg->js_refs > 0, + ("free_jseg: Invalid refcnt %d", jseg->js_refs)); + if (--jseg->js_refs != 0) + return; + free_jsegs(jseg->js_jblocks); } /* @@ -3748,7 +3872,7 @@ free_jsegdep(jsegdep) { if (jsegdep->jd_seg) - free_jseg(jsegdep->jd_seg); + rele_jseg(jsegdep->jd_seg); WORKITEM_FREE(jsegdep, D_JSEGDEP); } @@ -3769,7 +3893,7 @@ jwait(wk) * this point. The caller may call back in and re-issue the request. */ if ((wk->wk_state & IOSTARTED) == 0) { - softdep_process_journal(wk->wk_mp, MNT_WAIT); + softdep_process_journal(wk->wk_mp, wk, MNT_WAIT); return; } wk->wk_state |= IOWAITING; @@ -6004,7 +6128,9 @@ freework_freeblock(freework) LIST_SWAP(&wkhd, &freework->fw_jwork, worklist, wk_list); jnewblk = freework->fw_jnewblk; if (jnewblk != NULL) { - cancel_jnewblk(jnewblk, &wkhd); + /* Could've already been canceled in indir_trunc(). */ + if ((jnewblk->jn_state & GOINGAWAY) == 0) + cancel_jnewblk(jnewblk, &wkhd); needj = 0; } else if (needj) WORKLIST_INSERT(&wkhd, &freework->fw_list); @@ -6068,16 +6194,40 @@ handle_written_freework(freework) { struct freeblks *freeblks; struct freework *parent; + struct jsegdep *jsegdep; + struct worklist *wk; + int needj; + needj = 0; freeblks = freework->fw_freeblks; parent = freework->fw_parent; + /* + * SUJ needs to wait for the segment referencing freed indirect + * blocks to expire so that we know the checker will not confuse + * a re-allocated indirect block with its old contents. + */ + if (freework->fw_lbn <= -NDADDR && + freework->fw_list.wk_mp->mnt_kern_flag & MNTK_SUJ) { + LIST_FOREACH(wk, &freeblks->fb_jwork, wk_list) + if (wk->wk_type == D_JSEGDEP) + break; + if (wk) { + jsegdep = WK_JSEGDEP(wk); + LIST_INSERT_HEAD(&jsegdep->jd_seg->js_indirs, + freework, fw_next); + WORKLIST_INSERT(INDIR_HASH(freework->fw_list.wk_mp, + freework->fw_blkno), &freework->fw_list); + needj = 1; + } + } if (parent) { if (--parent->fw_ref != 0) parent = NULL; freeblks = NULL; } else if (--freeblks->fb_ref != 0) freeblks = NULL; - WORKITEM_FREE(freework, D_FREEWORK); + if (needj == 0) + WORKITEM_FREE(freework, D_FREEWORK); /* * Don't delay these block frees or it takes an intolerable amount * of time to process truncates and free their journal entries. @@ -6251,6 +6401,10 @@ indir_trunc(freework, dbn, lbn) LIST_SWAP(&wkhd, &indirdep->ir_jwork, worklist, wk_list); LIST_FOREACH_SAFE(jnewblk, &indirdep->ir_jnewblkhd, jn_indirdeps, jnewblkn) { + /* + * XXX This cancel may cause some lengthy delay + * before the record is reclaimed below. + */ LIST_REMOVE(jnewblk, jn_indirdeps); cancel_jnewblk(jnewblk, &wkhd); } @@ -8165,13 +8319,15 @@ softdep_disk_io_initiation(bp) case D_ALLOCINDIR: /* * We have to wait for the jnewblk to be journaled - * before we can write to a block otherwise the - * contents may be confused with an earlier file + * before we can write to a block if the contents + * may be confused with an earlier file's indirect * at recovery time. Handle the marker as described * above. */ newblk = WK_NEWBLK(wk); - if (newblk->nb_jnewblk != NULL) { + if (newblk->nb_jnewblk != NULL && + indirblk_inseg(newblk->nb_list.wk_mp, + newblk->nb_newblkno)) { LIST_REMOVE(&marker, wk_list); LIST_INSERT_BEFORE(wk, &marker, wk_list); stat_jwait_newblk++; Modified: head/sys/ufs/ffs/softdep.h ============================================================================== --- head/sys/ufs/ffs/softdep.h Sun Apr 10 01:54:42 2011 (r220510) +++ head/sys/ufs/ffs/softdep.h Sun Apr 10 03:49:53 2011 (r220511) @@ -538,7 +538,7 @@ struct freeblks { struct freework { struct worklist fw_list; /* Delayed worklist. */ # define fw_state fw_list.wk_state - LIST_ENTRY(freework) fw_next; /* Queue for freeblk list. */ + LIST_ENTRY(freework) fw_next; /* For seg journal list. */ struct jnewblk *fw_jnewblk; /* Journal entry to cancel. */ struct freeblks *fw_freeblks; /* Root of operation. */ struct freework *fw_parent; /* Parent indirect. */ @@ -888,10 +888,12 @@ struct jseg { struct worklist js_list; /* b_deps link for journal */ # define js_state js_list.wk_state struct workhead js_entries; /* Entries awaiting write */ + LIST_HEAD(, freework) js_indirs;/* List of indirects in this seg. */ TAILQ_ENTRY(jseg) js_next; /* List of all unfinished segments. */ struct jblocks *js_jblocks; /* Back pointer to block/seg list */ struct buf *js_buf; /* Buffer while unwritten */ uint64_t js_seq; /* Journal record sequence number. */ + uint64_t js_oldseq; /* Oldest valid sequence number. */ int js_size; /* Size of journal record in bytes. */ int js_cnt; /* Total items allocated. */ int js_refs; /* Count of js_entries items. */ From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 03:53:07 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0839F106566B; Sun, 10 Apr 2011 03:53:07 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EB9F48FC08; Sun, 10 Apr 2011 03:53:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3A3r6SR034248; Sun, 10 Apr 2011 03:53:06 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3A3r61C034246; Sun, 10 Apr 2011 03:53:06 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201104100353.p3A3r61C034246@svn.freebsd.org> From: Doug Barton Date: Sun, 10 Apr 2011 03:53:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220512 - head X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 03:53:07 -0000 Author: dougb Date: Sun Apr 10 03:53:06 2011 New Revision: 220512 URL: http://svn.freebsd.org/changeset/base/220512 Log: Update recommendation for mergemaster. The -a and -i options are exclusive. PR: docs/156271 Submitted by: Fedor Dikarev Modified: head/Makefile Modified: head/Makefile ============================================================================== --- head/Makefile Sun Apr 10 03:49:53 2011 (r220511) +++ head/Makefile Sun Apr 10 03:53:06 2011 (r220512) @@ -65,7 +65,7 @@ # 6. `mergemaster -p' # 7. `make installworld' # 8. `make delete-old' -# 9. `mergemaster' (you may wish to use -U or -ai). +# 9. `mergemaster' (you may wish to use -i, along with -U or -F). # 10. `reboot' # 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) # From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 03:55:55 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33F3E106564A; Sun, 10 Apr 2011 03:55:55 +0000 (UTC) (envelope-from jroberson@jroberson.net) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id A1FC68FC16; Sun, 10 Apr 2011 03:55:54 +0000 (UTC) Received: by gxk28 with SMTP id 28so2158423gxk.13 for ; Sat, 09 Apr 2011 20:55:54 -0700 (PDT) Received: by 10.91.210.12 with SMTP id m12mr3449347agq.67.1302407752893; Sat, 09 Apr 2011 20:55:52 -0700 (PDT) Received: from [10.0.1.198] ([72.253.42.56]) by mx.google.com with ESMTPS id 6sm4617647anx.20.2011.04.09.20.55.49 (version=SSLv3 cipher=OTHER); Sat, 09 Apr 2011 20:55:51 -0700 (PDT) Date: Sat, 9 Apr 2011 17:59:16 -1000 (HST) From: Jeff Roberson X-X-Sender: jroberson@desktop To: Jeff Roberson In-Reply-To: <201104100349.p3A3nsAd034153@svn.freebsd.org> Message-ID: References: <201104100349.p3A3nsAd034153@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220511 - head/sys/ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 03:55:55 -0000 On Sun, 10 Apr 2011, Jeff Roberson wrote: > Author: jeff > Date: Sun Apr 10 03:49:53 2011 > New Revision: 220511 > URL: http://svn.freebsd.org/changeset/base/220511 > > Log: > Fix a long standing SUJ performance problem: This brought my dbench performance to within 10-15% of softupdates on a real disk depending on concurrency. There are cases where it outperforms softupdates as well. Over time I can eliminate the extra blocking IO waits that cause the remaining degradation on this test. For now I'm going to focus on the mksnap bug that has been reported in several forms. Thanks, Jeff > > - Keep a hash of indirect blocks that have recently been freed and are > still referenced in the journal. > - Lookup blocks in this hash before forcing a new block write to wait on > the journal entry to hit the disk. This is only necessary to avoid > confusion between old identities as indirects and new identities as > file blocks. > - Don't free jseg structures until the journal has written a record that > invalidates it. This keeps the indirect block information around for > as long as is required to be safe. > - Force an empty journal block write when required to flush out stale > journal data that is simply waiting for the oldest valid sequence > number to advance beyond it. > > Modified: > head/sys/ufs/ffs/ffs_softdep.c > head/sys/ufs/ffs/softdep.h > > Modified: head/sys/ufs/ffs/ffs_softdep.c > ============================================================================== > --- head/sys/ufs/ffs/ffs_softdep.c Sun Apr 10 01:54:42 2011 (r220510) > +++ head/sys/ufs/ffs/ffs_softdep.c Sun Apr 10 03:49:53 2011 (r220511) > @@ -753,8 +753,7 @@ static void handle_written_jnewblk(struc > static void handle_written_jfreeblk(struct jfreeblk *); > static void handle_written_jfreefrag(struct jfreefrag *); > static void complete_jseg(struct jseg *); > -static void jseg_write(struct ufsmount *ump, struct jblocks *, struct jseg *, > - uint8_t *); > +static void jseg_write(struct ufsmount *ump, struct jseg *, uint8_t *); > static void jaddref_write(struct jaddref *, struct jseg *, uint8_t *); > static void jremref_write(struct jremref *, struct jseg *, uint8_t *); > static void jmvref_write(struct jmvref *, struct jseg *, uint8_t *); > @@ -769,6 +768,7 @@ static void handle_allocdirect_partdone( > static struct jnewblk *cancel_newblk(struct newblk *, struct worklist *, > struct workhead *); > static void indirdep_complete(struct indirdep *); > +static int indirblk_inseg(struct mount *, ufs2_daddr_t); > static void handle_allocindir_partdone(struct allocindir *); > static void initiate_write_filepage(struct pagedep *, struct buf *); > static void initiate_write_indirdep(struct indirdep*, struct buf *); > @@ -802,7 +802,9 @@ static void free_newdirblk(struct newdir > static void free_jremref(struct jremref *); > static void free_jaddref(struct jaddref *); > static void free_jsegdep(struct jsegdep *); > -static void free_jseg(struct jseg *); > +static void free_jsegs(struct jblocks *); > +static void rele_jseg(struct jseg *); > +static void free_jseg(struct jseg *, struct jblocks *); > static void free_jnewblk(struct jnewblk *); > static void free_jfreeblk(struct jfreeblk *); > static void free_jfreefrag(struct jfreefrag *); > @@ -872,7 +874,7 @@ static int journal_unsuspend(struct ufsm > static void softdep_prelink(struct vnode *, struct vnode *); > static void add_to_journal(struct worklist *); > static void remove_from_journal(struct worklist *); > -static void softdep_process_journal(struct mount *, int); > +static void softdep_process_journal(struct mount *, struct worklist *, int); > static struct jremref *newjremref(struct dirrem *, struct inode *, > struct inode *ip, off_t, nlink_t); > static struct jaddref *newjaddref(struct inode *, ino_t, off_t, int16_t, > @@ -1376,7 +1378,7 @@ softdep_process_worklist(mp, full) > ump = VFSTOUFS(mp); > ACQUIRE_LOCK(&lk); > starttime = time_second; > - softdep_process_journal(mp, full?MNT_WAIT:0); > + softdep_process_journal(mp, NULL, full?MNT_WAIT:0); > while (ump->softdep_on_worklist > 0) { > if ((cnt = process_worklist_item(mp, LK_NOWAIT)) == -1) > break; > @@ -1999,6 +2001,37 @@ newblk_lookup(mp, newblkno, flags, newbl > } > > /* > + * Structures and routines associated with indir caching. > + */ > +struct workhead *indir_hashtbl; > +u_long indir_hash; /* size of hash table - 1 */ > +#define INDIR_HASH(mp, blkno) \ > + (&indir_hashtbl[((((register_t)(mp)) >> 13) + (blkno)) & indir_hash]) > + > +static int > +indirblk_inseg(mp, blkno) > + struct mount *mp; > + ufs2_daddr_t blkno; > +{ > + struct freework *freework; > + struct workhead *wkhd; > + struct worklist *wk; > + > + wkhd = INDIR_HASH(mp, blkno); > + LIST_FOREACH(wk, wkhd, wk_list) { > + freework = WK_FREEWORK(wk); > + if (freework->fw_blkno == blkno && > + freework->fw_list.wk_mp == mp) { > + LIST_REMOVE(freework, fw_next); > + WORKLIST_REMOVE(&freework->fw_list); > + WORKITEM_FREE(freework, D_FREEWORK); > + return (1); > + } > + } > + return (0); > +} > + > +/* > * Executed during filesystem system initialization before > * mounting any filesystems. > */ > @@ -2012,6 +2045,7 @@ softdep_initialize() > inodedep_hashtbl = hashinit(desiredvnodes, M_INODEDEP, &inodedep_hash); > newblk_hashtbl = hashinit(desiredvnodes / 5, M_NEWBLK, &newblk_hash); > bmsafemap_hashtbl = hashinit(1024, M_BMSAFEMAP, &bmsafemap_hash); > + indir_hashtbl = hashinit(desiredvnodes / 10, M_FREEWORK, &indir_hash); > > /* initialise bioops hack */ > bioops.io_start = softdep_disk_io_initiation; > @@ -2120,9 +2154,12 @@ softdep_unmount(mp) > struct jblocks { > struct jseglst jb_segs; /* TAILQ of current segments. */ > struct jseg *jb_writeseg; /* Next write to complete. */ > + struct jseg *jb_oldestseg; /* Oldest segment with valid entries. */ > struct jextent *jb_extent; /* Extent array. */ > uint64_t jb_nextseq; /* Next sequence number. */ > - uint64_t jb_oldestseq; /* Oldest active sequence number. */ > + uint64_t jb_oldestwrseq; /* Oldest written sequence number. */ > + uint8_t jb_needseg; /* Need a forced segment. */ > + uint8_t jb_suspended; /* Did journal suspend writes? */ > int jb_avail; /* Available extents. */ > int jb_used; /* Last used extent. */ > int jb_head; /* Allocator head. */ > @@ -2132,7 +2169,6 @@ struct jblocks { > int jb_min; /* Minimum free space. */ > int jb_low; /* Low on space. */ > int jb_age; /* Insertion time of oldest rec. */ > - int jb_suspended; /* Did journal suspend writes? */ > }; > > struct jextent { > @@ -2575,9 +2611,8 @@ softdep_prelink(dvp, vp) > } > > static void > -jseg_write(ump, jblocks, jseg, data) > +jseg_write(ump, jseg, data) > struct ufsmount *ump; > - struct jblocks *jblocks; > struct jseg *jseg; > uint8_t *data; > { > @@ -2585,7 +2620,7 @@ jseg_write(ump, jblocks, jseg, data) > > rec = (struct jsegrec *)data; > rec->jsr_seq = jseg->js_seq; > - rec->jsr_oldest = jblocks->jb_oldestseq; > + rec->jsr_oldest = jseg->js_oldseq; > rec->jsr_cnt = jseg->js_cnt; > rec->jsr_blocks = jseg->js_size / ump->um_devvp->v_bufobj.bo_bsize; > rec->jsr_crc = 0; > @@ -2722,8 +2757,9 @@ jtrunc_write(jtrunc, jseg, data) > * Flush some journal records to disk. > */ > static void > -softdep_process_journal(mp, flags) > +softdep_process_journal(mp, needwk, flags) > struct mount *mp; > + struct worklist *needwk; > int flags; > { > struct jblocks *jblocks; > @@ -2755,17 +2791,23 @@ softdep_process_journal(mp, flags) > jrecmin = (devbsize / JREC_SIZE) - 1; /* -1 for seg header */ > jrecmax = (fs->fs_bsize / devbsize) * jrecmin; > segwritten = 0; > - while ((cnt = ump->softdep_on_journal) != 0) { > + for (;;) { > + cnt = ump->softdep_on_journal; > /* > - * Create a new segment to hold as many as 'cnt' journal > - * entries and add them to the segment. Notice cnt is > - * off by one to account for the space required by the > - * jsegrec. If we don't have a full block to log skip it > - * unless we haven't written anything. > + * Criteria for writing a segment: > + * 1) We have a full block. > + * 2) We're called from jwait() and haven't found the > + * journal item yet. > + * 3) Always write if needseg is set. > + * 4) If we are called from process_worklist and have > + * not yet written anything we write a partial block > + * to enforce a 1 second maximum latency on journal > + * entries. > */ > - cnt++; > - if (cnt < jrecmax && segwritten) > + if (cnt < (jrecmax - 1) && needwk == NULL && > + jblocks->jb_needseg == 0 && (segwritten || cnt == 0)) > break; > + cnt++; > /* > * Verify some free journal space. softdep_prealloc() should > * guarantee that we don't run out so this is indicative of > @@ -2783,6 +2825,7 @@ softdep_process_journal(mp, flags) > jseg = malloc(sizeof(*jseg), M_JSEG, M_SOFTDEP_FLAGS); > workitem_alloc(&jseg->js_list, D_JSEG, mp); > LIST_INIT(&jseg->js_entries); > + LIST_INIT(&jseg->js_indirs); > jseg->js_state = ATTACHED; > jseg->js_jblocks = jblocks; > bp = geteblk(fs->fs_bsize, 0); > @@ -2794,7 +2837,8 @@ softdep_process_journal(mp, flags) > * the caller will loop if the entry it cares about is > * not written. > */ > - if (ump->softdep_on_journal == 0 || jblocks->jb_free == 0) { > + cnt = ump->softdep_on_journal; > + if (cnt + jblocks->jb_needseg == 0 || jblocks->jb_free == 0) { > bp->b_flags |= B_INVAL | B_NOCACHE; > WORKITEM_FREE(jseg, D_JSEG); > FREE_LOCK(&lk); > @@ -2806,8 +2850,9 @@ softdep_process_journal(mp, flags) > * Calculate the disk block size required for the available > * records rounded to the min size. > */ > - cnt = ump->softdep_on_journal; > - if (cnt < jrecmax) > + if (cnt == 0) > + size = devbsize; > + else if (cnt < jrecmax) > size = howmany(cnt, jrecmin) * devbsize; > else > size = fs->fs_bsize; > @@ -2827,15 +2872,15 @@ softdep_process_journal(mp, flags) > * Initialize our jseg with cnt records. Assign the next > * sequence number to it and link it in-order. > */ > - cnt = MIN(ump->softdep_on_journal, > - (size / devbsize) * jrecmin); > + cnt = MIN(cnt, (size / devbsize) * jrecmin); > jseg->js_buf = bp; > jseg->js_cnt = cnt; > jseg->js_refs = cnt + 1; /* Self ref. */ > jseg->js_size = size; > jseg->js_seq = jblocks->jb_nextseq++; > - if (TAILQ_EMPTY(&jblocks->jb_segs)) > - jblocks->jb_oldestseq = jseg->js_seq; > + if (jblocks->jb_oldestseg == NULL) > + jblocks->jb_oldestseg = jseg; > + jseg->js_oldseq = jblocks->jb_oldestseg->js_seq; > TAILQ_INSERT_TAIL(&jblocks->jb_segs, jseg, js_next); > if (jblocks->jb_writeseg == NULL) > jblocks->jb_writeseg = jseg; > @@ -2846,12 +2891,16 @@ softdep_process_journal(mp, flags) > off = 0; > while ((wk = LIST_FIRST(&ump->softdep_journal_pending)) > != NULL) { > + if (cnt == 0) > + break; > /* Place a segment header on every device block. */ > if ((off % devbsize) == 0) { > - jseg_write(ump, jblocks, jseg, data); > + jseg_write(ump, jseg, data); > off += JREC_SIZE; > data = bp->b_data + off; > } > + if (wk == needwk) > + needwk = NULL; > remove_from_journal(wk); > wk->wk_state |= IOSTARTED; > WORKLIST_INSERT(&jseg->js_entries, wk); > @@ -2882,23 +2931,28 @@ softdep_process_journal(mp, flags) > TYPENAME(wk->wk_type)); > /* NOTREACHED */ > } > - if (--cnt == 0) > - break; > off += JREC_SIZE; > data = bp->b_data + off; > + cnt--; > } > /* > * Write this one buffer and continue. > */ > + segwritten = 1; > + jblocks->jb_needseg = 0; > WORKLIST_INSERT(&bp->b_dep, &jseg->js_list); > FREE_LOCK(&lk); > BO_LOCK(bp->b_bufobj); > bgetvp(ump->um_devvp, bp); > BO_UNLOCK(bp->b_bufobj); > - if (flags == MNT_NOWAIT) > - bawrite(bp); > - else > + /* > + * We only do the blocking wait once we find the journal > + * entry we're looking for. > + */ > + if (needwk == NULL && flags & MNT_WAIT) > bwrite(bp); > + else > + bawrite(bp); > ACQUIRE_LOCK(&lk); > } > /* > @@ -2949,7 +3003,7 @@ complete_jseg(jseg) > break; > case D_JMVREF: > /* No jsegdep here. */ > - free_jseg(jseg); > + rele_jseg(jseg); > jmvref = WK_JMVREF(wk); > LIST_REMOVE(jmvref, jm_deps); > free_pagedep(jmvref->jm_pagedep); > @@ -2977,7 +3031,7 @@ complete_jseg(jseg) > wakeup(wk); > } > /* Release the self reference so the structure may be freed. */ > - free_jseg(jseg); > + rele_jseg(jseg); > } > > /* > @@ -3009,11 +3063,16 @@ handle_written_jseg(jseg, bp) > return; > /* Iterate through available jsegs processing their entries. */ > do { > + jblocks->jb_oldestwrseq = jseg->js_oldseq; > jsegn = TAILQ_NEXT(jseg, js_next); > complete_jseg(jseg); > jseg = jsegn; > } while (jseg && jseg->js_state & DEPCOMPLETE); > jblocks->jb_writeseg = jseg; > + /* > + * Attempt to free jsegs now that oldestwrseq may have advanced. > + */ > + free_jsegs(jblocks); > } > > static inline struct jsegdep * > @@ -3682,6 +3741,8 @@ cancel_jnewblk(jnewblk, wkhd) > struct jsegdep *jsegdep; > > jsegdep = jnewblk->jn_jsegdep; > + if (jnewblk->jn_jsegdep == NULL || jnewblk->jn_dep == NULL) > + panic("cancel_jnewblk: Invalid state"); > jnewblk->jn_jsegdep = NULL; > jnewblk->jn_dep = NULL; > jnewblk->jn_state |= GOINGAWAY; > @@ -3709,34 +3770,97 @@ free_jfreeblk(jfreeblk) > } > > /* > - * Release one reference to a jseg and free it if the count reaches 0. This > - * should eventually reclaim journal space as well. > + * Free a single jseg once it is no longer referenced in memory or on > + * disk. Reclaim journal blocks and dependencies waiting for the segment > + * to disappear. > */ > static void > -free_jseg(jseg) > +free_jseg(jseg, jblocks) > struct jseg *jseg; > + struct jblocks *jblocks; > { > + struct freework *freework; > + > + /* > + * Free freework structures that were lingering to indicate freed > + * indirect blocks that forced journal write ordering on reallocate. > + */ > + while ((freework = LIST_FIRST(&jseg->js_indirs)) != NULL) { > + LIST_REMOVE(freework, fw_next); > + WORKLIST_REMOVE(&freework->fw_list); > + WORKITEM_FREE(freework, D_FREEWORK); > + } > + if (jblocks->jb_oldestseg == jseg) > + jblocks->jb_oldestseg = TAILQ_NEXT(jseg, js_next); > + TAILQ_REMOVE(&jblocks->jb_segs, jseg, js_next); > + jblocks_free(jblocks, jseg->js_list.wk_mp, jseg->js_size); > + KASSERT(LIST_EMPTY(&jseg->js_entries), > + ("free_jseg: Freed jseg has valid entries.")); > + WORKITEM_FREE(jseg, D_JSEG); > +} > + > +/* > + * Free all jsegs that meet the criteria for being reclaimed and update > + * oldestseg. > + */ > +static void > +free_jsegs(jblocks) > struct jblocks *jblocks; > +{ > + struct jseg *jseg; > > - KASSERT(jseg->js_refs > 0, > - ("free_jseg: Invalid refcnt %d", jseg->js_refs)); > - if (--jseg->js_refs != 0) > - return; > /* > * Free only those jsegs which have none allocated before them to > * preserve the journal space ordering. > */ > - jblocks = jseg->js_jblocks; > while ((jseg = TAILQ_FIRST(&jblocks->jb_segs)) != NULL) { > - jblocks->jb_oldestseq = jseg->js_seq; > - if (jseg->js_refs != 0) > + /* > + * Only reclaim space when nothing depends on this journal > + * set and another set has written that it is no longer > + * valid. > + */ > + if (jseg->js_refs != 0) { > + jblocks->jb_oldestseg = jseg; > + return; > + } > + if (!LIST_EMPTY(&jseg->js_indirs) && > + jseg->js_seq >= jblocks->jb_oldestwrseq) > break; > - TAILQ_REMOVE(&jblocks->jb_segs, jseg, js_next); > - jblocks_free(jblocks, jseg->js_list.wk_mp, jseg->js_size); > - KASSERT(LIST_EMPTY(&jseg->js_entries), > - ("free_jseg: Freed jseg has valid entries.")); > - WORKITEM_FREE(jseg, D_JSEG); > + free_jseg(jseg, jblocks); > } > + /* > + * If we exited the loop above we still must discover the > + * oldest valid segment. > + */ > + if (jseg) > + for (jseg = jblocks->jb_oldestseg; jseg != NULL; > + jseg = TAILQ_NEXT(jseg, js_next)) > + if (jseg->js_refs != 0) > + break; > + jblocks->jb_oldestseg = jseg; > + /* > + * The journal has no valid records but some jsegs may still be > + * waiting on oldestwrseq to advance. We force a small record > + * out to permit these lingering records to be reclaimed. > + */ > + if (jblocks->jb_oldestseg == NULL && !TAILQ_EMPTY(&jblocks->jb_segs)) > + jblocks->jb_needseg = 1; > +} > + > +/* > + * Release one reference to a jseg and free it if the count reaches 0. This > + * should eventually reclaim journal space as well. > + */ > +static void > +rele_jseg(jseg) > + struct jseg *jseg; > +{ > + > + KASSERT(jseg->js_refs > 0, > + ("free_jseg: Invalid refcnt %d", jseg->js_refs)); > + if (--jseg->js_refs != 0) > + return; > + free_jsegs(jseg->js_jblocks); > } > > /* > @@ -3748,7 +3872,7 @@ free_jsegdep(jsegdep) > { > > if (jsegdep->jd_seg) > - free_jseg(jsegdep->jd_seg); > + rele_jseg(jsegdep->jd_seg); > WORKITEM_FREE(jsegdep, D_JSEGDEP); > } > > @@ -3769,7 +3893,7 @@ jwait(wk) > * this point. The caller may call back in and re-issue the request. > */ > if ((wk->wk_state & IOSTARTED) == 0) { > - softdep_process_journal(wk->wk_mp, MNT_WAIT); > + softdep_process_journal(wk->wk_mp, wk, MNT_WAIT); > return; > } > wk->wk_state |= IOWAITING; > @@ -6004,7 +6128,9 @@ freework_freeblock(freework) > LIST_SWAP(&wkhd, &freework->fw_jwork, worklist, wk_list); > jnewblk = freework->fw_jnewblk; > if (jnewblk != NULL) { > - cancel_jnewblk(jnewblk, &wkhd); > + /* Could've already been canceled in indir_trunc(). */ > + if ((jnewblk->jn_state & GOINGAWAY) == 0) > + cancel_jnewblk(jnewblk, &wkhd); > needj = 0; > } else if (needj) > WORKLIST_INSERT(&wkhd, &freework->fw_list); > @@ -6068,16 +6194,40 @@ handle_written_freework(freework) > { > struct freeblks *freeblks; > struct freework *parent; > + struct jsegdep *jsegdep; > + struct worklist *wk; > + int needj; > > + needj = 0; > freeblks = freework->fw_freeblks; > parent = freework->fw_parent; > + /* > + * SUJ needs to wait for the segment referencing freed indirect > + * blocks to expire so that we know the checker will not confuse > + * a re-allocated indirect block with its old contents. > + */ > + if (freework->fw_lbn <= -NDADDR && > + freework->fw_list.wk_mp->mnt_kern_flag & MNTK_SUJ) { > + LIST_FOREACH(wk, &freeblks->fb_jwork, wk_list) > + if (wk->wk_type == D_JSEGDEP) > + break; > + if (wk) { > + jsegdep = WK_JSEGDEP(wk); > + LIST_INSERT_HEAD(&jsegdep->jd_seg->js_indirs, > + freework, fw_next); > + WORKLIST_INSERT(INDIR_HASH(freework->fw_list.wk_mp, > + freework->fw_blkno), &freework->fw_list); > + needj = 1; > + } > + } > if (parent) { > if (--parent->fw_ref != 0) > parent = NULL; > freeblks = NULL; > } else if (--freeblks->fb_ref != 0) > freeblks = NULL; > - WORKITEM_FREE(freework, D_FREEWORK); > + if (needj == 0) > + WORKITEM_FREE(freework, D_FREEWORK); > /* > * Don't delay these block frees or it takes an intolerable amount > * of time to process truncates and free their journal entries. > @@ -6251,6 +6401,10 @@ indir_trunc(freework, dbn, lbn) > LIST_SWAP(&wkhd, &indirdep->ir_jwork, worklist, wk_list); > LIST_FOREACH_SAFE(jnewblk, &indirdep->ir_jnewblkhd, > jn_indirdeps, jnewblkn) { > + /* > + * XXX This cancel may cause some lengthy delay > + * before the record is reclaimed below. > + */ > LIST_REMOVE(jnewblk, jn_indirdeps); > cancel_jnewblk(jnewblk, &wkhd); > } > @@ -8165,13 +8319,15 @@ softdep_disk_io_initiation(bp) > case D_ALLOCINDIR: > /* > * We have to wait for the jnewblk to be journaled > - * before we can write to a block otherwise the > - * contents may be confused with an earlier file > + * before we can write to a block if the contents > + * may be confused with an earlier file's indirect > * at recovery time. Handle the marker as described > * above. > */ > newblk = WK_NEWBLK(wk); > - if (newblk->nb_jnewblk != NULL) { > + if (newblk->nb_jnewblk != NULL && > + indirblk_inseg(newblk->nb_list.wk_mp, > + newblk->nb_newblkno)) { > LIST_REMOVE(&marker, wk_list); > LIST_INSERT_BEFORE(wk, &marker, wk_list); > stat_jwait_newblk++; > > Modified: head/sys/ufs/ffs/softdep.h > ============================================================================== > --- head/sys/ufs/ffs/softdep.h Sun Apr 10 01:54:42 2011 (r220510) > +++ head/sys/ufs/ffs/softdep.h Sun Apr 10 03:49:53 2011 (r220511) > @@ -538,7 +538,7 @@ struct freeblks { > struct freework { > struct worklist fw_list; /* Delayed worklist. */ > # define fw_state fw_list.wk_state > - LIST_ENTRY(freework) fw_next; /* Queue for freeblk list. */ > + LIST_ENTRY(freework) fw_next; /* For seg journal list. */ > struct jnewblk *fw_jnewblk; /* Journal entry to cancel. */ > struct freeblks *fw_freeblks; /* Root of operation. */ > struct freework *fw_parent; /* Parent indirect. */ > @@ -888,10 +888,12 @@ struct jseg { > struct worklist js_list; /* b_deps link for journal */ > # define js_state js_list.wk_state > struct workhead js_entries; /* Entries awaiting write */ > + LIST_HEAD(, freework) js_indirs;/* List of indirects in this seg. */ > TAILQ_ENTRY(jseg) js_next; /* List of all unfinished segments. */ > struct jblocks *js_jblocks; /* Back pointer to block/seg list */ > struct buf *js_buf; /* Buffer while unwritten */ > uint64_t js_seq; /* Journal record sequence number. */ > + uint64_t js_oldseq; /* Oldest valid sequence number. */ > int js_size; /* Size of journal record in bytes. */ > int js_cnt; /* Total items allocated. */ > int js_refs; /* Count of js_entries items. */ > From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 10:15:50 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D757106566C; Sun, 10 Apr 2011 10:15:50 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0F1838FC12; Sun, 10 Apr 2011 10:15:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AAFnXZ043260; Sun, 10 Apr 2011 10:15:49 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AAFnMT043258; Sun, 10 Apr 2011 10:15:49 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201104101015.p3AAFnMT043258@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sun, 10 Apr 2011 10:15:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220515 - head/sys/compat/svr4 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 10:15:50 -0000 Author: trasz Date: Sun Apr 10 10:15:49 2011 New Revision: 220515 URL: http://svn.freebsd.org/changeset/base/220515 Log: Remove stray semicolon. Modified: head/sys/compat/svr4/imgact_svr4.c Modified: head/sys/compat/svr4/imgact_svr4.c ============================================================================== --- head/sys/compat/svr4/imgact_svr4.c Sun Apr 10 09:35:44 2011 (r220514) +++ head/sys/compat/svr4/imgact_svr4.c Sun Apr 10 10:15:49 2011 (r220515) @@ -110,7 +110,7 @@ exec_svr4_imgact(imgp) PROC_LOCK(imgp->proc); if (a_out->a_text > maxtsiz || a_out->a_data + bss_size > lim_cur(imgp->proc, RLIMIT_DATA) || - racct_set(imgp->proc, RACCT_DATA, a_out->a_data + bss_size) != 0) {; + racct_set(imgp->proc, RACCT_DATA, a_out->a_data + bss_size) != 0) { PROC_UNLOCK(imgp->proc); return (ENOMEM); } From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 10:17:01 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94BC4106566C; Sun, 10 Apr 2011 10:17:01 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 866BF8FC17; Sun, 10 Apr 2011 10:17:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AAH1eI043330; Sun, 10 Apr 2011 10:17:01 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AAH1fu043328; Sun, 10 Apr 2011 10:17:01 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201104101017.p3AAH1fu043328@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sun, 10 Apr 2011 10:17:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220516 - head/usr.bin/limits X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 10:17:01 -0000 Author: trasz Date: Sun Apr 10 10:17:01 2011 New Revision: 220516 URL: http://svn.freebsd.org/changeset/base/220516 Log: Add link to rctl(8). Modified: head/usr.bin/limits/limits.1 Modified: head/usr.bin/limits/limits.1 ============================================================================== --- head/usr.bin/limits/limits.1 Sun Apr 10 10:15:49 2011 (r220515) +++ head/usr.bin/limits/limits.1 Sun Apr 10 10:17:01 2011 (r220516) @@ -19,7 +19,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 5, 2011 +.Dd April 10, 2011 .Dt LIMITS 1 .Os .Sh NAME @@ -373,6 +373,7 @@ will be whatever the executed program re .Xr setrlimit 2 , .Xr login_cap 3 , .Xr login.conf 5 , +.Xr rctl 8 , .Xr sysctl 8 .Sh BUGS The From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 12:43:14 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 870541065673; Sun, 10 Apr 2011 12:43:14 +0000 (UTC) (envelope-from uqs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 774558FC0A; Sun, 10 Apr 2011 12:43:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AChEEp048555; Sun, 10 Apr 2011 12:43:14 GMT (envelope-from uqs@svn.freebsd.org) Received: (from uqs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AChEgs048553; Sun, 10 Apr 2011 12:43:14 GMT (envelope-from uqs@svn.freebsd.org) Message-Id: <201104101243.p3AChEgs048553@svn.freebsd.org> From: Ulrich Spoerlein Date: Sun, 10 Apr 2011 12:43:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220517 - in head/share/doc/smm: . 07.lpd 07.lpr X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 12:43:14 -0000 Author: uqs Date: Sun Apr 10 12:43:13 2011 New Revision: 220517 URL: http://svn.freebsd.org/changeset/base/220517 Log: Rename 07.lpr to 07.lpd and re-connect to the build. This was forgotten in r216178. Submitted by: antoine Pointyhat: uqs Added: head/share/doc/smm/07.lpd/ - copied from r220454, head/share/doc/smm/07.lpr/ Deleted: head/share/doc/smm/07.lpr/ Modified: head/share/doc/smm/Makefile Modified: head/share/doc/smm/Makefile ============================================================================== --- head/share/doc/smm/Makefile Sun Apr 10 10:17:01 2011 (r220516) +++ head/share/doc/smm/Makefile Sun Apr 10 12:43:13 2011 (r220517) @@ -10,9 +10,6 @@ # 13.amd (documentation is TeXinfo) # 16.security 17.password (encumbered) -# The following modules are built with their programs: -# 07.lpd - SUBDIR= title \ contents \ 01.setup \ @@ -21,6 +18,7 @@ SUBDIR= title \ 04.quotas \ 05.fastfs \ 06.nfs \ + 07.lpd \ ${_08.sendmailop} \ 11.timedop \ 12.timed \ From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 13:45:47 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35EC7106566B; Sun, 10 Apr 2011 13:45:47 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 242F28FC13; Sun, 10 Apr 2011 13:45:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3ADjluD049947; Sun, 10 Apr 2011 13:45:47 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3ADjl1n049944; Sun, 10 Apr 2011 13:45:47 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201104101345.p3ADjl1n049944@svn.freebsd.org> From: Rick Macklem Date: Sun, 10 Apr 2011 13:45:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220518 - head/usr.sbin/nfsd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 13:45:47 -0000 Author: rmacklem Date: Sun Apr 10 13:45:46 2011 New Revision: 220518 URL: http://svn.freebsd.org/changeset/base/220518 Log: Modify the man pages to reflect the addition of a backup stable restart file, as done by r220510. This is a content change. MFC after: 2 weeks Modified: head/usr.sbin/nfsd/nfsv4.4 head/usr.sbin/nfsd/stablerestart.5 Modified: head/usr.sbin/nfsd/nfsv4.4 ============================================================================== --- head/usr.sbin/nfsd/nfsv4.4 Sun Apr 10 12:43:13 2011 (r220517) +++ head/usr.sbin/nfsd/nfsv4.4 Sun Apr 10 13:45:46 2011 (r220518) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 3, 2009 +.Dd April 10, 2011 .Dt NFSV4 4 .Os .Sh NAME @@ -54,12 +54,13 @@ open/lock state changing operations. To provide for correct recovery semantics, a small file described by .Xr stablerestart 5 is used by the server during the recovery phase. -If this file is missing, -the server will not start. -If this file is lost, it should be recovered from backups, since creating -an empty -.Xr stablerestart 5 -file will result in the server starting without providing a grace period +If this file is missing or empty, there is a backup copy maintained by +.Xr nfsd 8 +that will be used. If either file is missing, they will be +created by the +.Xr nfsd 8 . +If both the file and the backup copy are empty, +it will result in the server starting without providing a grace period for recovery. Note that recovery only occurs when the server machine is rebooted, not when the @@ -185,25 +186,9 @@ are set in .Pp You will also need to add at least one ``V4:'' line to the .Xr exports 5 -file and, before starting the server for the first time, create an empty -.sp -.Bd -literal -offset indent -compact -/var/db/nfs-stablerestart -.Ed -.sp -file. -The command -.sp -.Bd -literal -offset indent -compact -install -o root -g wheel -m 600 /dev/null /var/db/nfs-stablerestart -.Ed -.sp -executed as ``su'' should suffice. -This can only be done when the server is not running and there are no +file for .Nm -file system mounts against the server. -If this file is lost during a crash, recovery from backups is -recommended. +to work. .Pp If the file systems you are exporting are only being accessed via .Nm @@ -311,9 +296,11 @@ daemons at boot time via the ``nfsuserd_ .Xr rc.conf 5 variables. .Sh FILES -.Bl -tag -width /var/db/nfs-stablerestart -compact +.Bl -tag -width /var/db/nfs-stablerestart.bak -compact .It Pa /var/db/nfs-stablerestart NFS V4 stable restart file +.It Pa /var/db/nfs-stablerestart.bak +backup copy of the file .El .Sh SEE ALSO .Xr stablerestart 5 , Modified: head/usr.sbin/nfsd/stablerestart.5 ============================================================================== --- head/usr.sbin/nfsd/stablerestart.5 Sun Apr 10 12:43:13 2011 (r220517) +++ head/usr.sbin/nfsd/stablerestart.5 Sun Apr 10 13:45:46 2011 (r220518) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 3, 2009 +.Dd April 10, 2011 .Dt STABLERESTART 5 .Os .Sh NAME @@ -75,9 +75,11 @@ is written to stable storage by the time has returned. This might require hardware level caching to be disabled for a local disk drive that holds the file, or similar. .Sh FILES -.Bl -tag -width /var/db/nfs-stablerestart -compact +.Bl -tag -width /var/db/nfs-stablerestart.bak -compact .It Pa /var/db/nfs-stablerestart NFSv4 stable restart file +.It Pa /var/db/nfs-stablerestart.bak +backup copy of the file .El .Sh SEE ALSO .Xr nfsv4 4 , @@ -86,8 +88,10 @@ NFSv4 stable restart file If the file is empty, the NFSv4 server has no choice but to return NFSERR_NOGRACE for all reclaim requests. Although correct, this is a highly undesirable occurrence, so the file should not be lost if -at all possible. Nfsd will not create the file if it does not -exist and will simply log a failure to start, in the hopes that the -file can be recovered from a backup. To move the file, you must edit +at all possible. The backup copy of the file is maintained +and used by the +.Xr nfsd 8 +to minimize the risk of this occurring. +To move the file, you must edit the nfsd sources and recompile it. This was done to discourage accidental relocation of the file. From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 14:11:08 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5757D106566C; Sun, 10 Apr 2011 14:11:08 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 45CBE8FC16; Sun, 10 Apr 2011 14:11:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AEB8lE050465; Sun, 10 Apr 2011 14:11:08 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AEB8jV050463; Sun, 10 Apr 2011 14:11:08 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201104101411.p3AEB8jV050463@svn.freebsd.org> From: Rick Macklem Date: Sun, 10 Apr 2011 14:11:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220519 - head/lib/libc/rpc X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 14:11:08 -0000 Author: rmacklem Date: Sun Apr 10 14:11:07 2011 New Revision: 220519 URL: http://svn.freebsd.org/changeset/base/220519 Log: Fix a bug in the userland rpc library, where it would use a negative return value from write to update its position in a buffer. The patch, courtesy of Andrey Simonenko, also simplifies a conditional by removing the "i != cnt" clause, since it is always true at this point in the code. The bug caused problems for mountd, when it generated a large reply to an exports RPC request. Submitted by: simon at comsys.ntu-kpi.kiev.ua MFC after: 2 weeks Modified: head/lib/libc/rpc/svc_vc.c Modified: head/lib/libc/rpc/svc_vc.c ============================================================================== --- head/lib/libc/rpc/svc_vc.c Sun Apr 10 13:45:46 2011 (r220518) +++ head/lib/libc/rpc/svc_vc.c Sun Apr 10 14:11:07 2011 (r220519) @@ -546,7 +546,7 @@ write_vc(xprtp, buf, len) cd->strm_stat = XPRT_DIED; return (-1); } - if (cd->nonblock && i != cnt) { + if (cd->nonblock) { /* * For non-blocking connections, do not * take more than 2 seconds writing the @@ -560,6 +560,7 @@ write_vc(xprtp, buf, len) return (-1); } } + i = 0; } } From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 15:07:54 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9777C1065672; Sun, 10 Apr 2011 15:07:54 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 84D268FC1E; Sun, 10 Apr 2011 15:07:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AF7swR051708; Sun, 10 Apr 2011 15:07:54 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AF7sZn051706; Sun, 10 Apr 2011 15:07:54 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201104101507.p3AF7sZn051706@svn.freebsd.org> From: Mikolaj Golub Date: Sun, 10 Apr 2011 15:07:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220520 - head/sbin/hastctl X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 15:07:54 -0000 Author: trociny Date: Sun Apr 10 15:07:54 2011 New Revision: 220520 URL: http://svn.freebsd.org/changeset/base/220520 Log: hastd(8) maintains a map of dirty extents, not hastctl(8). Fix this. Approved by: pjd (mentor) MFC after: 3 days Modified: head/sbin/hastctl/hastctl.8 Modified: head/sbin/hastctl/hastctl.8 ============================================================================== --- head/sbin/hastctl/hastctl.8 Sun Apr 10 14:11:07 2011 (r220519) +++ head/sbin/hastctl/hastctl.8 Sun Apr 10 15:07:54 2011 (r220520) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 13, 2011 +.Dd April 10, 2011 .Dt HASTCTL 8 .Os .Sh NAME @@ -88,7 +88,7 @@ Additional options include: .It Fl e Ar extentsize Size of an extent. Extent is a block which is used for synchronization. -.Nm +.Xr hastd 8 maintains a map of dirty extents and extent is the smallest region that can be marked as dirty. If any part of an extent is modified, entire extent will be synchronized From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 15:11:19 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB561106566B; Sun, 10 Apr 2011 15:11:19 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B8BC58FC08; Sun, 10 Apr 2011 15:11:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AFBJMF051836; Sun, 10 Apr 2011 15:11:19 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AFBJG5051834; Sun, 10 Apr 2011 15:11:19 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201104101511.p3AFBJG5051834@svn.freebsd.org> From: Mikolaj Golub Date: Sun, 10 Apr 2011 15:11:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220521 - head/sbin/hastd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 15:11:19 -0000 Author: trociny Date: Sun Apr 10 15:11:19 2011 New Revision: 220521 URL: http://svn.freebsd.org/changeset/base/220521 Log: Fix a typo in comments. Approved by: pjd (mentor) MFC after: 3 days Modified: head/sbin/hastd/activemap.c Modified: head/sbin/hastd/activemap.c ============================================================================== --- head/sbin/hastd/activemap.c Sun Apr 10 15:07:54 2011 (r220520) +++ head/sbin/hastd/activemap.c Sun Apr 10 15:11:19 2011 (r220521) @@ -470,7 +470,7 @@ activemap_copyin(struct activemap *amp, } /* - * Function merges the given bitmap with existng one. + * Function merges the given bitmap with existing one. */ void activemap_merge(struct activemap *amp, const unsigned char *buf, size_t size) From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 15:21:47 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 07E3C106564A; Sun, 10 Apr 2011 15:21:47 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E96748FC13; Sun, 10 Apr 2011 15:21:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AFLkPF052103; Sun, 10 Apr 2011 15:21:46 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AFLkX6052101; Sun, 10 Apr 2011 15:21:46 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201104101521.p3AFLkX6052101@svn.freebsd.org> From: Mikolaj Golub Date: Sun, 10 Apr 2011 15:21:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220522 - head/sbin/hastd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 15:21:47 -0000 Author: trociny Date: Sun Apr 10 15:21:46 2011 New Revision: 220522 URL: http://svn.freebsd.org/changeset/base/220522 Log: In hast_proto_recv_data() check that the size of the data to be received does not exceed the buffer size. Approved by: pjd (mentor) MFC after: 1 week Modified: head/sbin/hastd/hast_proto.c Modified: head/sbin/hastd/hast_proto.c ============================================================================== --- head/sbin/hastd/hast_proto.c Sun Apr 10 15:11:19 2011 (r220521) +++ head/sbin/hastd/hast_proto.c Sun Apr 10 15:21:46 2011 (r220522) @@ -189,9 +189,12 @@ hast_proto_recv_data(const struct hast_r dptr = data; dsize = nv_get_uint32(nv, "size"); - if (dsize == 0) + if (dsize > size) { + errno = EINVAL; + goto end; + } else if (dsize == 0) { (void)nv_set_error(nv, 0); - else { + } else { if (proto_recv(conn, data, dsize) < 0) goto end; for (ii = sizeof(pipeline) / sizeof(pipeline[0]); ii > 0; From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 15:28:37 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A5AF106566B; Sun, 10 Apr 2011 15:28:37 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 77A378FC08; Sun, 10 Apr 2011 15:28:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AFSbpY052268; Sun, 10 Apr 2011 15:28:37 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AFSbOV052266; Sun, 10 Apr 2011 15:28:37 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201104101528.p3AFSbOV052266@svn.freebsd.org> From: Mikolaj Golub Date: Sun, 10 Apr 2011 15:28:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220523 - head/sbin/hastd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 15:28:37 -0000 Author: trociny Date: Sun Apr 10 15:28:37 2011 New Revision: 220523 URL: http://svn.freebsd.org/changeset/base/220523 Log: In hast_proto_recv() remove unnecessary check. The size is checked later in hast_proto_recv_data(). Approved by: pjd (mentor) MFC after: 1 week Modified: head/sbin/hastd/hast_proto.c Modified: head/sbin/hastd/hast_proto.c ============================================================================== --- head/sbin/hastd/hast_proto.c Sun Apr 10 15:21:46 2011 (r220522) +++ head/sbin/hastd/hast_proto.c Sun Apr 10 15:28:37 2011 (r220523) @@ -225,17 +225,12 @@ hast_proto_recv(const struct hast_resour struct nv **nvp, void *data, size_t size) { struct nv *nv; - size_t dsize; int ret; ret = hast_proto_recv_hdr(conn, &nv); if (ret < 0) return (ret); - dsize = nv_get_uint32(nv, "size"); - if (dsize == 0) - (void)nv_set_error(nv, 0); - else - ret = hast_proto_recv_data(res, conn, nv, data, size); + ret = hast_proto_recv_data(res, conn, nv, data, size); if (ret < 0) nv_free(nv); else From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 17:07:03 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 47754106564A; Sun, 10 Apr 2011 17:07:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 35D438FC15; Sun, 10 Apr 2011 17:07:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AH73FS054349; Sun, 10 Apr 2011 17:07:03 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AH736T054347; Sun, 10 Apr 2011 17:07:03 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104101707.p3AH736T054347@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 10 Apr 2011 17:07:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220526 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 17:07:03 -0000 Author: kib Date: Sun Apr 10 17:07:02 2011 New Revision: 220526 URL: http://svn.freebsd.org/changeset/base/220526 Log: Some callers of proc_reparent() already have the parent process locked. Detect the situation and avoid process lock recursion. Reported by: Fabian Keil Modified: head/sys/kern/kern_exit.c Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Sun Apr 10 15:48:16 2011 (r220525) +++ head/sys/kern/kern_exit.c Sun Apr 10 17:07:02 2011 (r220526) @@ -903,15 +903,19 @@ loop: void proc_reparent(struct proc *child, struct proc *parent) { + int locked; sx_assert(&proctree_lock, SX_XLOCKED); PROC_LOCK_ASSERT(child, MA_OWNED); if (child->p_pptr == parent) return; - PROC_LOCK(parent); + locked = PROC_LOCKED(parent); + if (!locked) + PROC_LOCK(parent); racct_add_force(parent, RACCT_NPROC, 1); - PROC_UNLOCK(parent); + if (!locked) + PROC_UNLOCK(parent); PROC_LOCK(child->p_pptr); racct_sub(child->p_pptr, RACCT_NPROC, 1); sigqueue_take(child->p_ksi); From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 18:35:44 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E56F106566B; Sun, 10 Apr 2011 18:35:44 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F18D98FC15; Sun, 10 Apr 2011 18:35:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AIZhdd056051; Sun, 10 Apr 2011 18:35:43 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AIZhO8056047; Sun, 10 Apr 2011 18:35:43 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201104101835.p3AIZhO8056047@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sun, 10 Apr 2011 18:35:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220527 - in head/sys: kern sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 18:35:44 -0000 Author: trasz Date: Sun Apr 10 18:35:43 2011 New Revision: 220527 URL: http://svn.freebsd.org/changeset/base/220527 Log: Rename a misnamed structure field (hr_loginclass), and reorder priv(9) constants to match the order and naming of syscalls. No functional changes. Modified: head/sys/kern/kern_rctl.c head/sys/sys/priv.h head/sys/sys/rctl.h Modified: head/sys/kern/kern_rctl.c ============================================================================== --- head/sys/kern/kern_rctl.c Sun Apr 10 17:07:02 2011 (r220526) +++ head/sys/kern/kern_rctl.c Sun Apr 10 18:35:43 2011 (r220527) @@ -475,9 +475,9 @@ rctl_rule_matches(const struct rctl_rule return (0); break; case RCTL_SUBJECT_TYPE_LOGINCLASS: - if (filter->rr_subject.hr_loginclass != NULL && - rule->rr_subject.hr_loginclass != - filter->rr_subject.hr_loginclass) + if (filter->rr_subject.rs_loginclass != NULL && + rule->rr_subject.rs_loginclass != + filter->rr_subject.rs_loginclass) return (0); break; case RCTL_SUBJECT_TYPE_JAIL: @@ -642,8 +642,8 @@ rctl_rule_acquire_subject(struct rctl_ru uihold(rule->rr_subject.rs_uip); break; case RCTL_SUBJECT_TYPE_LOGINCLASS: - if (rule->rr_subject.hr_loginclass != NULL) - loginclass_hold(rule->rr_subject.hr_loginclass); + if (rule->rr_subject.rs_loginclass != NULL) + loginclass_hold(rule->rr_subject.rs_loginclass); break; default: panic("rctl_rule_acquire_subject: unknown subject type %d", @@ -665,8 +665,8 @@ rctl_rule_release_subject(struct rctl_ru uifree(rule->rr_subject.rs_uip); break; case RCTL_SUBJECT_TYPE_LOGINCLASS: - if (rule->rr_subject.hr_loginclass != NULL) - loginclass_free(rule->rr_subject.hr_loginclass); + if (rule->rr_subject.rs_loginclass != NULL) + loginclass_free(rule->rr_subject.rs_loginclass); break; default: panic("rctl_rule_release_subject: unknown subject type %d", @@ -685,7 +685,7 @@ rctl_rule_alloc(int flags) rule->rr_subject_type = RCTL_SUBJECT_TYPE_UNDEFINED; rule->rr_subject.rs_proc = NULL; rule->rr_subject.rs_uip = NULL; - rule->rr_subject.hr_loginclass = NULL; + rule->rr_subject.rs_loginclass = NULL; rule->rr_subject.rs_prison = NULL; rule->rr_per = RCTL_SUBJECT_TYPE_UNDEFINED; rule->rr_resource = RACCT_UNDEFINED; @@ -707,7 +707,7 @@ rctl_rule_duplicate(const struct rctl_ru copy->rr_subject_type = rule->rr_subject_type; copy->rr_subject.rs_proc = rule->rr_subject.rs_proc; copy->rr_subject.rs_uip = rule->rr_subject.rs_uip; - copy->rr_subject.hr_loginclass = rule->rr_subject.hr_loginclass; + copy->rr_subject.rs_loginclass = rule->rr_subject.rs_loginclass; copy->rr_subject.rs_prison = rule->rr_subject.rs_prison; copy->rr_per = rule->rr_per; copy->rr_resource = rule->rr_resource; @@ -780,7 +780,7 @@ rctl_rule_fully_specified(const struct r return (0); break; case RCTL_SUBJECT_TYPE_LOGINCLASS: - if (rule->rr_subject.hr_loginclass == NULL) + if (rule->rr_subject.rs_loginclass == NULL) return (0); break; case RCTL_SUBJECT_TYPE_JAIL: @@ -832,7 +832,7 @@ rctl_string_to_rule(char *rulestr, struc if (subject_idstr == NULL || subject_idstr[0] == '\0') { rule->rr_subject.rs_proc = NULL; rule->rr_subject.rs_uip = NULL; - rule->rr_subject.hr_loginclass = NULL; + rule->rr_subject.rs_loginclass = NULL; rule->rr_subject.rs_prison = NULL; } else { switch (rule->rr_subject_type) { @@ -858,9 +858,9 @@ rctl_string_to_rule(char *rulestr, struc rule->rr_subject.rs_uip = uifind(id); break; case RCTL_SUBJECT_TYPE_LOGINCLASS: - rule->rr_subject.hr_loginclass = + rule->rr_subject.rs_loginclass = loginclass_find(subject_idstr); - if (rule->rr_subject.hr_loginclass == NULL) { + if (rule->rr_subject.rs_loginclass == NULL) { error = ENAMETOOLONG; goto out; } @@ -1002,7 +1002,7 @@ rctl_rule_add(struct rctl_rule *rule) break; case RCTL_SUBJECT_TYPE_LOGINCLASS: - lc = rule->rr_subject.hr_loginclass; + lc = rule->rr_subject.rs_loginclass; KASSERT(lc != NULL, ("rctl_rule_add: NULL loginclass")); rctl_racct_add_rule(lc->lc_racct, rule); break; @@ -1034,7 +1034,7 @@ rctl_rule_add(struct rctl_rule *rule) break; continue; case RCTL_SUBJECT_TYPE_LOGINCLASS: - if (cred->cr_loginclass == rule->rr_subject.hr_loginclass) + if (cred->cr_loginclass == rule->rr_subject.rs_loginclass) break; continue; case RCTL_SUBJECT_TYPE_JAIL: @@ -1137,11 +1137,11 @@ rctl_rule_to_sbuf(struct sbuf *sb, const rule->rr_subject.rs_uip->ui_uid); break; case RCTL_SUBJECT_TYPE_LOGINCLASS: - if (rule->rr_subject.hr_loginclass == NULL) + if (rule->rr_subject.rs_loginclass == NULL) sbuf_printf(sb, ":"); else sbuf_printf(sb, "%s:", - rule->rr_subject.hr_loginclass->lc_name); + rule->rr_subject.rs_loginclass->lc_name); break; case RCTL_SUBJECT_TYPE_JAIL: if (rule->rr_subject.rs_prison == NULL) @@ -1247,7 +1247,7 @@ rctl_get_racct(struct thread *td, struct struct loginclass *lc; struct prison *pr; - error = priv_check(td, PRIV_RCTL_GET_USAGE); + error = priv_check(td, PRIV_RCTL_GET_RACCT); if (error != 0) return (error); @@ -1287,7 +1287,7 @@ rctl_get_racct(struct thread *td, struct outputsbuf = rctl_racct_to_sbuf(uip->ui_racct, 1); break; case RCTL_SUBJECT_TYPE_LOGINCLASS: - lc = filter->rr_subject.hr_loginclass; + lc = filter->rr_subject.rs_loginclass; if (lc == NULL) { error = EINVAL; goto out; Modified: head/sys/sys/priv.h ============================================================================== --- head/sys/sys/priv.h Sun Apr 10 17:07:02 2011 (r220526) +++ head/sys/sys/priv.h Sun Apr 10 18:35:43 2011 (r220527) @@ -486,11 +486,11 @@ /* * Resource Limits privileges. */ -#define PRIV_RCTL_GET_RULES 670 -#define PRIV_RCTL_ADD_RULE 671 -#define PRIV_RCTL_REMOVE_RULE 672 -#define PRIV_RCTL_GET_USAGE 673 -#define PRIV_RCTL_GET_LIMITS 674 +#define PRIV_RCTL_GET_RACCT 670 +#define PRIV_RCTL_GET_RULES 671 +#define PRIV_RCTL_GET_LIMITS 672 +#define PRIV_RCTL_ADD_RULE 673 +#define PRIV_RCTL_REMOVE_RULE 674 /* * Track end of privilege list. Modified: head/sys/sys/rctl.h ============================================================================== --- head/sys/sys/rctl.h Sun Apr 10 17:07:02 2011 (r220526) +++ head/sys/sys/rctl.h Sun Apr 10 18:35:43 2011 (r220527) @@ -67,10 +67,10 @@ struct rctl_rule_link; struct rctl_rule { int rr_subject_type; union { - struct proc *rs_proc; - struct uidinfo *rs_uip; - struct loginclass *hr_loginclass; - struct prison *rs_prison; + struct proc *rs_proc; + struct uidinfo *rs_uip; + struct loginclass *rs_loginclass; + struct prison *rs_prison; } rr_subject; int rr_per; int rr_resource; From owner-svn-src-head@FreeBSD.ORG Sun Apr 10 20:43:08 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1DDEF106566B; Sun, 10 Apr 2011 20:43:08 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0DFCD8FC1E; Sun, 10 Apr 2011 20:43:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3AKh7Os059256; Sun, 10 Apr 2011 20:43:07 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3AKh7W6059252; Sun, 10 Apr 2011 20:43:07 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201104102043.p3AKh7W6059252@svn.freebsd.org> From: Rick Macklem Date: Sun, 10 Apr 2011 20:43:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220530 - in head/sys/fs: nfs nfsserver X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Apr 2011 20:43:08 -0000 Author: rmacklem Date: Sun Apr 10 20:43:07 2011 New Revision: 220530 URL: http://svn.freebsd.org/changeset/base/220530 Log: Add some cleanup code to the module unload operation for the experimental NFS server, so that it doesn't leak memory when unloaded. However, unloading the NFSv4 server is not recommended, since all NFSv4 state will be lost by the unload and clients will have to recover the state after a server reload/restart as if the server crashed/rebooted. MFC after: 2 weeks Modified: head/sys/fs/nfs/nfs_var.h head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/fs/nfsserver/nfs_nfsdstate.c Modified: head/sys/fs/nfs/nfs_var.h ============================================================================== --- head/sys/fs/nfs/nfs_var.h Sun Apr 10 19:31:00 2011 (r220529) +++ head/sys/fs/nfs/nfs_var.h Sun Apr 10 20:43:07 2011 (r220530) @@ -124,6 +124,7 @@ int nfsrv_checkgetattr(struct nfsrv_desc struct nfsvattr *, nfsattrbit_t *, struct ucred *, NFSPROC_T *); int nfsrv_nfsuserdport(u_short, NFSPROC_T *); void nfsrv_nfsuserddelport(void); +void nfsrv_throwawayallstate(NFSPROC_T *); /* nfs_nfsdserv.c */ int nfsrvd_access(struct nfsrv_descript *, int, Modified: head/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdport.c Sun Apr 10 19:31:00 2011 (r220529) +++ head/sys/fs/nfsserver/nfs_nfsdport.c Sun Apr 10 20:43:07 2011 (r220530) @@ -54,6 +54,7 @@ extern int newnfs_numnfsd; extern struct mount nfsv4root_mnt; extern struct nfsrv_stablefirst nfsrv_stablefirst; extern void (*nfsd_call_servertimer)(void); +extern SVCPOOL *nfsrvd_pool; struct vfsoptlist nfsv4root_opt, nfsv4root_newopt; NFSDLOCKMUTEX; struct mtx nfs_cache_mutex; @@ -3125,9 +3126,16 @@ nfsd_modevent(module_t mod, int type, vo nfsd_call_servertimer = NULL; nfsd_call_nfsd = NULL; + /* Clean out all NFSv4 state. */ + nfsrv_throwawayallstate(curthread); + /* Clean the NFS server reply cache */ nfsrvd_cleancache(); + /* Free up the krpc server pool. */ + if (nfsrvd_pool != NULL) + svcpool_destroy(nfsrvd_pool); + /* and get rid of the locks */ mtx_destroy(&nfs_cache_mutex); mtx_destroy(&nfs_v4root_mutex); Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdstate.c Sun Apr 10 19:31:00 2011 (r220529) +++ head/sys/fs/nfsserver/nfs_nfsdstate.c Sun Apr 10 20:43:07 2011 (r220530) @@ -5194,3 +5194,37 @@ nfsrv_unlocklf(struct nfslockfile *lfp) nfsv4_unlock(&lfp->lf_locallock_lck, 0); } +/* + * Clear out all state for the NFSv4 server. + * Must be called by a thread that can sleep when no nfsds are running. + */ +void +nfsrv_throwawayallstate(NFSPROC_T *p) +{ + struct nfsclient *clp, *nclp; + struct nfslockfile *lfp, *nlfp; + int i; + + /* + * For each client, clean out the state and then free the structure. + */ + for (i = 0; i < NFSCLIENTHASHSIZE; i++) { + LIST_FOREACH_SAFE(clp, &nfsclienthash[i], lc_hash, nclp) { + nfsrv_cleanclient(clp, p); + nfsrv_freedeleglist(&clp->lc_deleg); + nfsrv_freedeleglist(&clp->lc_olddeleg); + free(clp, M_NFSDCLIENT); + } + } + + /* + * Also, free up any remaining lock file structures. + */ + for (i = 0; i < NFSLOCKHASHSIZE; i++) { + LIST_FOREACH_SAFE(lfp, &nfslockhash[i], lf_hash, nlfp) { + printf("nfsd unload: fnd a lock file struct\n"); + nfsrv_freenfslockfile(lfp); + } + } +} + From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 01:43:59 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC5AA106564A; Mon, 11 Apr 2011 01:43:59 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BA6548FC0C; Mon, 11 Apr 2011 01:43:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3B1hxPM066112; Mon, 11 Apr 2011 01:43:59 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3B1hx8T066110; Mon, 11 Apr 2011 01:43:59 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201104110143.p3B1hx8T066110@svn.freebsd.org> From: Jeff Roberson Date: Mon, 11 Apr 2011 01:43:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220532 - head/sys/ufs/ffs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 01:43:59 -0000 Author: jeff Date: Mon Apr 11 01:43:59 2011 New Revision: 220532 URL: http://svn.freebsd.org/changeset/base/220532 Log: - Refactor softdep_setup_freeblocks() into a set of functions to prepare for a new journal specific partial truncate routine. - Use dep_current[] in place of specific dependency counts. This is automatically maintained when workitems are allocated and has less risk of becoming incorrect. Modified: head/sys/ufs/ffs/ffs_softdep.c Modified: head/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- head/sys/ufs/ffs/ffs_softdep.c Mon Apr 11 01:19:02 2011 (r220531) +++ head/sys/ufs/ffs/ffs_softdep.c Mon Apr 11 01:43:59 2011 (r220532) @@ -815,9 +815,19 @@ static void cancel_jnewblk(struct jnewbl static int cancel_jaddref(struct jaddref *, struct inodedep *, struct workhead *); static void cancel_jfreefrag(struct jfreefrag *); +static inline void setup_freedirect(struct freeblks *, struct inode *, + int, int); +static inline void setup_freeext(struct freeblks *, struct inode *, int, int); +static inline void setup_freeindir(struct freeblks *, struct inode *, int i, + ufs_lbn_t, int); +static inline struct freeblks *newfreeblks(struct mount *, struct inode *); static void indir_trunc(struct freework *, ufs2_daddr_t, ufs_lbn_t); -static int deallocate_dependencies(struct buf *, struct inodedep *, +static void softdep_trunc_deps(struct vnode *, struct freeblks *, ufs_lbn_t, + int, int); +static int cancel_pagedep(struct pagedep *, struct inodedep *, struct freeblks *); +static int deallocate_dependencies(struct buf *, struct inodedep *, + struct freeblks *, int off); static void free_newblk(struct newblk *); static void cancel_allocdirect(struct allocdirectlst *, struct allocdirect *, struct freeblks *, int); @@ -1114,7 +1124,6 @@ static struct callout softdep_callout; static int req_pending; static int req_clear_inodedeps; /* syncer process flush some inodedeps */ static int req_clear_remove; /* syncer process flush some freeblks */ -static long num_freeblkdep; /* number of freeblks workitems allocated */ /* * runtime statistics @@ -1832,7 +1841,6 @@ pagedep_lookup(mp, ino, lbn, flags, page */ LIST_HEAD(inodedep_hashhead, inodedep) *inodedep_hashtbl; static u_long inodedep_hash; /* size of hash table - 1 */ -static long num_inodedep; /* number of inodedep allocated */ #define INODEDEP_HASH(fs, inum) \ (&inodedep_hashtbl[((((register_t)(fs)) >> 13) + (inum)) & inodedep_hash]) @@ -1884,7 +1892,7 @@ inodedep_lookup(mp, inum, flags, inodede /* * If we are over our limit, try to improve the situation. */ - if (num_inodedep > max_softdeps && (flags & NODELAY) == 0) + if (dep_current[D_INODEDEP] > max_softdeps && (flags & NODELAY) == 0) request_cleanup(mp, FLUSH_INODES); FREE_LOCK(&lk); inodedep = malloc(sizeof(struct inodedep), @@ -1895,7 +1903,6 @@ inodedep_lookup(mp, inum, flags, inodede WORKITEM_FREE(inodedep, D_INODEDEP); return (1); } - num_inodedep += 1; inodedep->id_fs = fs; inodedep->id_ino = inum; inodedep->id_state = ALLCOMPLETE; @@ -2472,7 +2479,7 @@ journal_space(ump, thresh) * We use a tighter restriction here to prevent request_cleanup() * running in threads from running into locks we currently hold. */ - if (num_inodedep > (max_softdeps / 10) * 9) + if (dep_current[D_INODEDEP] > (max_softdeps / 10) * 9) return (0); if (thresh) thresh = jblocks->jb_min; @@ -5340,6 +5347,83 @@ allocindir_merge(aip, oldaip) return (freefrag); } +static inline void +setup_freedirect(freeblks, ip, i, needj) + struct freeblks *freeblks; + struct inode *ip; + int i; + int needj; +{ + ufs2_daddr_t blkno; + int frags; + + blkno = DIP(ip, i_db[i]); + if (blkno == 0) + return; + DIP_SET(ip, i_db[i], 0); + frags = sblksize(ip->i_fs, ip->i_size, i); + frags = numfrags(ip->i_fs, frags); + newfreework(ip->i_ump, freeblks, NULL, i, blkno, frags, needj); +} + +static inline void +setup_freeext(freeblks, ip, i, needj) + struct freeblks *freeblks; + struct inode *ip; + int i; + int needj; +{ + ufs2_daddr_t blkno; + int frags; + + blkno = ip->i_din2->di_extb[i]; + if (blkno == 0) + return; + ip->i_din2->di_extb[i] = 0; + frags = sblksize(ip->i_fs, ip->i_din2->di_extsize, i); + frags = numfrags(ip->i_fs, frags); + newfreework(ip->i_ump, freeblks, NULL, -1 - i, blkno, frags, needj); +} + +static inline void +setup_freeindir(freeblks, ip, i, lbn, needj) + struct freeblks *freeblks; + struct inode *ip; + ufs_lbn_t lbn; + int i; + int needj; +{ + ufs2_daddr_t blkno; + + blkno = DIP(ip, i_ib[i]); + if (blkno == 0) + return; + DIP_SET(ip, i_ib[i], 0); + newfreework(ip->i_ump, freeblks, NULL, lbn, blkno, ip->i_fs->fs_frag, + needj); +} + +static inline struct freeblks * +newfreeblks(mp, ip) + struct mount *mp; + struct inode *ip; +{ + struct freeblks *freeblks; + + freeblks = malloc(sizeof(struct freeblks), + M_FREEBLKS, M_SOFTDEP_FLAGS|M_ZERO); + workitem_alloc(&freeblks->fb_list, D_FREEBLKS, mp); + LIST_INIT(&freeblks->fb_jfreeblkhd); + LIST_INIT(&freeblks->fb_jwork); + freeblks->fb_state = ATTACHED; + freeblks->fb_uid = ip->i_uid; + freeblks->fb_previousinum = ip->i_number; + freeblks->fb_devvp = ip->i_devvp; + freeblks->fb_chkcnt = 0; + + return (freeblks); +} + /* * Block de-allocation dependencies. * @@ -5381,35 +5465,20 @@ softdep_setup_freeblocks(ip, length, fla struct inodedep *inodedep; struct allocdirect *adp; struct jfreeblk *jfreeblk; - struct bufobj *bo; - struct vnode *vp; struct buf *bp; struct fs *fs; ufs2_daddr_t extblocks, datablocks; struct mount *mp; int i, delay, error; - ufs2_daddr_t blkno; ufs_lbn_t tmpval; ufs_lbn_t lbn; - long oldextsize; - long oldsize; - int frags; int needj; fs = ip->i_fs; mp = UFSTOVFS(ip->i_ump); if (length != 0) panic("softdep_setup_freeblocks: non-zero length"); - freeblks = malloc(sizeof(struct freeblks), - M_FREEBLKS, M_SOFTDEP_FLAGS|M_ZERO); - workitem_alloc(&freeblks->fb_list, D_FREEBLKS, mp); - LIST_INIT(&freeblks->fb_jfreeblkhd); - LIST_INIT(&freeblks->fb_jwork); - freeblks->fb_state = ATTACHED; - freeblks->fb_uid = ip->i_uid; - freeblks->fb_previousinum = ip->i_number; - freeblks->fb_devvp = ip->i_devvp; - freeblks->fb_chkcnt = 0; + freeblks = newfreeblks(mp, ip); ACQUIRE_LOCK(&lk); /* * If we're truncating a removed file that will never be written @@ -5422,54 +5491,29 @@ softdep_setup_freeblocks(ip, length, fla needj = 0; else needj = 1; - num_freeblkdep++; FREE_LOCK(&lk); extblocks = 0; if (fs->fs_magic == FS_UFS2_MAGIC) extblocks = btodb(fragroundup(fs, ip->i_din2->di_extsize)); datablocks = DIP(ip, i_blocks) - extblocks; if ((flags & IO_NORMAL) != 0) { - oldsize = ip->i_size; + for (i = 0; i < NDADDR; i++) + setup_freedirect(freeblks, ip, i, needj); + for (i = 0, tmpval = NINDIR(fs), lbn = NDADDR; i < NIADDR; + i++, lbn += tmpval, tmpval *= NINDIR(fs)) + setup_freeindir(freeblks, ip, i, -lbn -i, needj); ip->i_size = 0; DIP_SET(ip, i_size, 0); freeblks->fb_chkcnt = datablocks; - for (i = 0; i < NDADDR; i++) { - blkno = DIP(ip, i_db[i]); - DIP_SET(ip, i_db[i], 0); - if (blkno == 0) - continue; - frags = sblksize(fs, oldsize, i); - frags = numfrags(fs, frags); - newfreework(ip->i_ump, freeblks, NULL, i, blkno, frags, - needj); - } - for (i = 0, tmpval = NINDIR(fs), lbn = NDADDR; i < NIADDR; - i++, tmpval *= NINDIR(fs)) { - blkno = DIP(ip, i_ib[i]); - DIP_SET(ip, i_ib[i], 0); - if (blkno) - newfreework(ip->i_ump, freeblks, NULL, -lbn - i, - blkno, fs->fs_frag, needj); - lbn += tmpval; - } UFS_LOCK(ip->i_ump); fs->fs_pendingblocks += datablocks; UFS_UNLOCK(ip->i_ump); } if ((flags & IO_EXT) != 0) { - oldextsize = ip->i_din2->di_extsize; + for (i = 0; i < NXADDR; i++) + setup_freeext(freeblks, ip, i, needj); ip->i_din2->di_extsize = 0; freeblks->fb_chkcnt += extblocks; - for (i = 0; i < NXADDR; i++) { - blkno = ip->i_din2->di_extb[i]; - ip->i_din2->di_extb[i] = 0; - if (blkno == 0) - continue; - frags = sblksize(fs, oldextsize, i); - frags = numfrags(fs, frags); - newfreework(ip->i_ump, freeblks, NULL, -1 - i, blkno, - frags, needj); - } } if (LIST_EMPTY(&freeblks->fb_jfreeblkhd)) needj = 0; @@ -5543,13 +5587,62 @@ softdep_setup_freeblocks(ip, length, fla FREE_LOCK(&lk); bdwrite(bp); + softdep_trunc_deps(ITOV(ip), freeblks, 0, 0, flags); + ACQUIRE_LOCK(&lk); + if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) != 0) + (void) free_inodedep(inodedep); + + if (delay || needj) + freeblks->fb_state |= DEPCOMPLETE; + if (delay) { + /* + * If the inode with zeroed block pointers is now on disk + * we can start freeing blocks. Add freeblks to the worklist + * instead of calling handle_workitem_freeblocks directly as + * it is more likely that additional IO is needed to complete + * the request here than in the !delay case. + */ + if ((freeblks->fb_state & ALLCOMPLETE) == ALLCOMPLETE) + add_to_worklist(&freeblks->fb_list, 1); + } + if (needj && LIST_EMPTY(&freeblks->fb_jfreeblkhd)) + needj = 0; + + FREE_LOCK(&lk); + /* + * If the inode has never been written to disk (delay == 0) and + * we're not waiting on any journal writes, then we can process the + * freeblks now that we have deleted the dependencies. + */ + if (!delay && !needj) + handle_workitem_freeblocks(freeblks, 0); +} + +/* + * Eliminate any dependencies that exist in memory beyond lblkno:off + */ +static void +softdep_trunc_deps(vp, freeblks, lblkno, off, flags) + struct vnode *vp; + struct freeblks *freeblks; + ufs_lbn_t lblkno; + int off; + int flags; +{ + struct inodedep *inodedep; + struct bufobj *bo; + struct buf *bp; + struct mount *mp; + ino_t ino; + /* * We must wait for any I/O in progress to finish so that * all potential buffers on the dirty list will be visible. * Once they are all there, walk the list and get rid of * any dependencies. */ - vp = ITOV(ip); + ino = VTOI(vp)->i_number; + mp = vp->v_mount; bo = &vp->v_bufobj; BO_LOCK(bo); drain_output(vp); @@ -5563,8 +5656,8 @@ restart: goto restart; BO_UNLOCK(bo); ACQUIRE_LOCK(&lk); - (void) inodedep_lookup(mp, ip->i_number, 0, &inodedep); - if (deallocate_dependencies(bp, inodedep, freeblks)) + (void) inodedep_lookup(mp, ino, 0, &inodedep); + if (deallocate_dependencies(bp, inodedep, freeblks, 0)) bp->b_flags |= B_INVAL | B_NOCACHE; FREE_LOCK(&lk); brelse(bp); @@ -5572,34 +5665,73 @@ restart: goto restart; } BO_UNLOCK(bo); - ACQUIRE_LOCK(&lk); - if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) != 0) - (void) free_inodedep(inodedep); +} - if (delay || needj) - freeblks->fb_state |= DEPCOMPLETE; - if (delay) { - /* - * If the inode with zeroed block pointers is now on disk - * we can start freeing blocks. Add freeblks to the worklist - * instead of calling handle_workitem_freeblocks directly as - * it is more likely that additional IO is needed to complete - * the request here than in the !delay case. - */ - if ((freeblks->fb_state & ALLCOMPLETE) == ALLCOMPLETE) - add_to_worklist(&freeblks->fb_list, 1); - } - if (needj && LIST_EMPTY(&freeblks->fb_jfreeblkhd)) - needj = 0; +static int +cancel_pagedep(pagedep, inodedep, freeblks) + struct pagedep *pagedep; + struct inodedep *inodedep; + struct freeblks *freeblks; +{ + struct newdirblk *newdirblk; + struct jremref *jremref; + struct jmvref *jmvref; + struct dirrem *dirrem; + int i; - FREE_LOCK(&lk); /* - * If the inode has never been written to disk (delay == 0) and - * we're not waiting on any journal writes, then we can process the - * freeblks now that we have deleted the dependencies. + * There should be no directory add dependencies present + * as the directory could not be truncated until all + * children were removed. */ - if (!delay && !needj) - handle_workitem_freeblocks(freeblks, 0); + KASSERT(LIST_FIRST(&pagedep->pd_pendinghd) == NULL, + ("deallocate_dependencies: pendinghd != NULL")); + for (i = 0; i < DAHASHSZ; i++) + KASSERT(LIST_FIRST(&pagedep->pd_diraddhd[i]) == NULL, + ("deallocate_dependencies: diraddhd != NULL")); + /* + * Copy any directory remove dependencies to the list + * to be processed after the zero'ed inode is written. + * If the inode has already been written, then they + * can be dumped directly onto the work list. + */ + LIST_FOREACH(dirrem, &pagedep->pd_dirremhd, dm_next) { + /* + * If there are any dirrems we wait for + * the journal write to complete and + * then restart the buf scan as the lock + * has been dropped. + */ + while ((jremref = LIST_FIRST(&dirrem->dm_jremrefhd)) + != NULL) { + stat_jwait_filepage++; + jwait(&jremref->jr_list); + return (ERESTART); + } + LIST_REMOVE(dirrem, dm_next); + dirrem->dm_dirinum = pagedep->pd_ino; + if (inodedep == NULL || + (inodedep->id_state & ALLCOMPLETE) == ALLCOMPLETE) { + dirrem->dm_state |= COMPLETE; + add_to_worklist(&dirrem->dm_list, 0); + } else + WORKLIST_INSERT(&inodedep->id_bufwait, + &dirrem->dm_list); + } + if ((pagedep->pd_state & NEWBLOCK) != 0) { + newdirblk = pagedep->pd_newdirblk; + WORKLIST_REMOVE(&newdirblk->db_list); + free_newdirblk(newdirblk); + } + while ((jmvref = LIST_FIRST(&pagedep->pd_jmvrefhd)) != NULL) { + stat_jwait_filepage++; + jwait(&jmvref->jm_list); + return (ERESTART); + } + WORKLIST_REMOVE(&pagedep->pd_list); + LIST_REMOVE(pagedep, pd_hash); + WORKITEM_FREE(pagedep, D_PAGEDEP); + return (0); } /* @@ -5611,20 +5743,16 @@ restart: * all dependencies were cleared, 0 otherwise. */ static int -deallocate_dependencies(bp, inodedep, freeblks) +deallocate_dependencies(bp, inodedep, freeblks, off) struct buf *bp; struct inodedep *inodedep; struct freeblks *freeblks; + int off; { struct worklist *wk; struct indirdep *indirdep; - struct newdirblk *newdirblk; struct allocindir *aip; struct pagedep *pagedep; - struct jremref *jremref; - struct jmvref *jmvref; - struct dirrem *dirrem; - int i; mtx_assert(&lk, MA_OWNED); while ((wk = LIST_FIRST(&bp->b_dep)) != NULL) { @@ -5640,61 +5768,8 @@ deallocate_dependencies(bp, inodedep, fr case D_PAGEDEP: pagedep = WK_PAGEDEP(wk); - /* - * There should be no directory add dependencies present - * as the directory could not be truncated until all - * children were removed. - */ - KASSERT(LIST_FIRST(&pagedep->pd_pendinghd) == NULL, - ("deallocate_dependencies: pendinghd != NULL")); - for (i = 0; i < DAHASHSZ; i++) - KASSERT(LIST_FIRST(&pagedep->pd_diraddhd[i]) == NULL, - ("deallocate_dependencies: diraddhd != NULL")); - /* - * Copy any directory remove dependencies to the list - * to be processed after the zero'ed inode is written. - * If the inode has already been written, then they - * can be dumped directly onto the work list. - */ - LIST_FOREACH(dirrem, &pagedep->pd_dirremhd, dm_next) { - /* - * If there are any dirrems we wait for - * the journal write to complete and - * then restart the buf scan as the lock - * has been dropped. - */ - while ((jremref = - LIST_FIRST(&dirrem->dm_jremrefhd)) - != NULL) { - stat_jwait_filepage++; - jwait(&jremref->jr_list); - return (0); - } - LIST_REMOVE(dirrem, dm_next); - dirrem->dm_dirinum = pagedep->pd_ino; - if (inodedep == NULL || - (inodedep->id_state & ALLCOMPLETE) == - ALLCOMPLETE) { - dirrem->dm_state |= COMPLETE; - add_to_worklist(&dirrem->dm_list, 0); - } else - WORKLIST_INSERT(&inodedep->id_bufwait, - &dirrem->dm_list); - } - if ((pagedep->pd_state & NEWBLOCK) != 0) { - newdirblk = pagedep->pd_newdirblk; - WORKLIST_REMOVE(&newdirblk->db_list); - free_newdirblk(newdirblk); - } - while ((jmvref = LIST_FIRST(&pagedep->pd_jmvrefhd)) - != NULL) { - stat_jwait_filepage++; - jwait(&jmvref->jm_list); + if (cancel_pagedep(pagedep, inodedep, freeblks)) return (0); - } - WORKLIST_REMOVE(&pagedep->pd_list); - LIST_REMOVE(pagedep, pd_hash); - WORKITEM_FREE(pagedep, D_PAGEDEP); continue; case D_ALLOCINDIR: @@ -6087,7 +6162,6 @@ free_inodedep(inodedep) LIST_REMOVE(inodedep, id_deps); LIST_REMOVE(inodedep, id_hash); WORKITEM_FREE(inodedep, D_INODEDEP); - num_inodedep -= 1; return (1); } @@ -6326,7 +6400,6 @@ handle_complete_freeblocks(freeblks) */ handle_jwork(&freeblks->fb_jwork); WORKITEM_FREE(freeblks, D_FREEBLKS); - num_freeblkdep--; FREE_LOCK(&lk); } @@ -7397,7 +7470,6 @@ dirrem_journal(dirrem, jremref, dotremre * Allocate a new dirrem if appropriate and return it along with * its associated pagedep. Called without a lock, returns with lock. */ -static long num_dirrem; /* number of dirrem allocated */ static struct dirrem * newdirrem(bp, dp, ip, isrmdir, prevdirremp) struct buf *bp; /* buffer containing directory block */ @@ -7428,9 +7500,9 @@ newdirrem(bp, dp, ip, isrmdir, prevdirre * the number of freefile and freeblks structures. */ ACQUIRE_LOCK(&lk); - if (!(ip->i_flags & SF_SNAPSHOT) && num_dirrem > max_softdeps / 2) + if (!(ip->i_flags & SF_SNAPSHOT) && + dep_current[D_DIRREM] > max_softdeps / 2) (void) request_cleanup(ITOV(dp)->v_mount, FLUSH_BLOCKS); - num_dirrem += 1; FREE_LOCK(&lk); dirrem = malloc(sizeof(struct dirrem), M_DIRREM, M_SOFTDEP_FLAGS|M_ZERO); @@ -8086,7 +8158,6 @@ handle_workitem_remove(dirrem, xp) if (ip->i_nlink == 0) unlinked_inodedep(mp, inodedep); inodedep->id_nlinkdelta = ip->i_nlink - ip->i_effnlink; - num_dirrem -= 1; KASSERT(LIST_EMPTY(&dirrem->dm_jwork), ("handle_workitem_remove: worklist not empty. %s", TYPENAME(LIST_FIRST(&dirrem->dm_jwork)->wk_type))); @@ -8116,7 +8187,6 @@ handle_workitem_remove(dirrem, xp) if (dirrem->dm_state & DIRCHG) { KASSERT(LIST_EMPTY(&dirrem->dm_jwork), ("handle_workitem_remove: DIRCHG and worklist not empty.")); - num_dirrem -= 1; WORKITEM_FREE(dirrem, D_DIRREM); FREE_LOCK(&lk); goto out; @@ -11156,10 +11226,10 @@ softdep_slowdown(vp) jlow = 1; } max_softdeps_hard = max_softdeps * 11 / 10; - if (num_dirrem < max_softdeps_hard / 2 && - num_inodedep < max_softdeps_hard && + if (dep_current[D_DIRREM] < max_softdeps_hard / 2 && + dep_current[D_INODEDEP] < max_softdeps_hard && VFSTOUFS(vp->v_mount)->um_numindirdeps < maxindirdeps && - num_freeblkdep < max_softdeps_hard && jlow == 0) { + dep_current[D_FREEBLKS] < max_softdeps_hard && jlow == 0) { FREE_LOCK(&lk); return (0); } From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 06:53:45 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CCBC0106566B; Mon, 11 Apr 2011 06:53:45 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BC5EF8FC21; Mon, 11 Apr 2011 06:53:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3B6rjg9076656; Mon, 11 Apr 2011 06:53:45 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3B6rjEC076650; Mon, 11 Apr 2011 06:53:45 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104110653.p3B6rjEC076650@svn.freebsd.org> From: Adrian Chadd Date: Mon, 11 Apr 2011 06:53:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220534 - in head/tools/tools/ath: athdecode athkey athpoke athprom athregs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 06:53:46 -0000 Author: adrian Date: Mon Apr 11 06:53:45 2011 New Revision: 220534 URL: http://svn.freebsd.org/changeset/base/220534 Log: Generate opt_ah.h now for all ath tools, a recent HAL change of mine now requires it. Modified: head/tools/tools/ath/athdecode/Makefile head/tools/tools/ath/athkey/Makefile head/tools/tools/ath/athpoke/Makefile head/tools/tools/ath/athprom/Makefile head/tools/tools/ath/athregs/Makefile Modified: head/tools/tools/ath/athdecode/Makefile ============================================================================== --- head/tools/tools/ath/athdecode/Makefile Mon Apr 11 03:12:10 2011 (r220533) +++ head/tools/tools/ath/athdecode/Makefile Mon Apr 11 06:53:45 2011 (r220534) @@ -10,6 +10,14 @@ SRCS+= dumpregs_5210.c SRCS+= dumpregs_5211.c SRCS+= dumpregs_5212.c SRCS+= dumpregs_5416.c +SRCS+= opt_ah.h + +CLEANFILES+= opt_ah.h + +opt_ah.h: + echo "#define AH_DEBUG 1" > opt_ah.h + echo "#define AH_DEBUG_COUNTRY 1" >> opt_ah.h + echo "#define AH_SUPPORT_AR5416 1" >> opt_ah.h .include <../Makefile.inc> Modified: head/tools/tools/ath/athkey/Makefile ============================================================================== --- head/tools/tools/ath/athkey/Makefile Mon Apr 11 03:12:10 2011 (r220533) +++ head/tools/tools/ath/athkey/Makefile Mon Apr 11 06:53:45 2011 (r220534) @@ -2,6 +2,17 @@ PROG= athkey +SRCS= athkey.c +SRCS+= opt_ah.h + +CLEANFILES+= opt_ah.h + +opt_ah.h: + echo "#define AH_DEBUG 1" > opt_ah.h + echo "#define AH_DEBUG_COUNTRY 1" >> opt_ah.h + echo "#define AH_SUPPORT_AR5416 1" >> opt_ah.h + + .include <../Makefile.inc> .include Modified: head/tools/tools/ath/athpoke/Makefile ============================================================================== --- head/tools/tools/ath/athpoke/Makefile Mon Apr 11 03:12:10 2011 (r220533) +++ head/tools/tools/ath/athpoke/Makefile Mon Apr 11 06:53:45 2011 (r220534) @@ -10,6 +10,14 @@ SRCS+= dumpregs_5210.c SRCS+= dumpregs_5211.c SRCS+= dumpregs_5212.c SRCS+= dumpregs_5416.c +SRCS+= opt_ah.h + +CLEANFILES+= opt_ah.h + +opt_ah.h: + echo "#define AH_DEBUG 1" > opt_ah.h + echo "#define AH_DEBUG_COUNTRY 1" >> opt_ah.h + echo "#define AH_SUPPORT_AR5416 1" >> opt_ah.h .include <../Makefile.inc> Modified: head/tools/tools/ath/athprom/Makefile ============================================================================== --- head/tools/tools/ath/athprom/Makefile Mon Apr 11 03:12:10 2011 (r220533) +++ head/tools/tools/ath/athprom/Makefile Mon Apr 11 06:53:45 2011 (r220534) @@ -7,6 +7,15 @@ PROG= athprom TEMPLATEDIR= /usr/local/libdata/athprom TEXTMODE?= 444 +SRCS= athprom.c +SRCS+= opt_ah.h +CLEANFILES+= opt_ah.h + +opt_ah.h: + echo "#define AH_DEBUG 1" > opt_ah.h + echo "#define AH_DEBUG_COUNTRY 1" >> opt_ah.h + echo "#define AH_SUPPORT_AR5416 1" >> opt_ah.h + CFLAGS+=-DDIR_TEMPLATE='"${TEMPLATEDIR}"' beforeinstall: Modified: head/tools/tools/ath/athregs/Makefile ============================================================================== --- head/tools/tools/ath/athregs/Makefile Mon Apr 11 03:12:10 2011 (r220533) +++ head/tools/tools/ath/athregs/Makefile Mon Apr 11 06:53:45 2011 (r220534) @@ -9,6 +9,14 @@ SRCS+= dumpregs_5210.c SRCS+= dumpregs_5211.c SRCS+= dumpregs_5212.c SRCS+= dumpregs_5416.c +SRCS+= opt_ah.h + +CLEANFILES+= opt_ah.h + +opt_ah.h: + echo "#define AH_DEBUG 1" > opt_ah.h + echo "#define AH_DEBUG_COUNTRY 1" >> opt_ah.h + echo "#define AH_SUPPORT_AR5416 1" >> opt_ah.h .include <../Makefile.inc> From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 08:23:27 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA8731065672; Mon, 11 Apr 2011 08:23:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B13518FC12; Mon, 11 Apr 2011 08:23:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3B8NRJg078757; Mon, 11 Apr 2011 08:23:27 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3B8NR6T078755; Mon, 11 Apr 2011 08:23:27 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201104110823.p3B8NR6T078755@svn.freebsd.org> From: Alexander Motin Date: Mon, 11 Apr 2011 08:23:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220535 - head/sys/dev/usb/storage X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 08:23:27 -0000 Author: mav Date: Mon Apr 11 08:23:27 2011 New Revision: 220535 URL: http://svn.freebsd.org/changeset/base/220535 Log: Rework change made at r203146. Instead of reporting all wire errors as SCSI status errors to CAM (that was wrong, as it too often turned retriable wire errors into non-retriable REQUEST SENSE errors), do it only for STALL errors on control pipe of the CBI devices. STALL on control pipe is just a one of the ways to report error for CBI devices. PR: usb/150401, usb/154593. Reviewed by: hselasky MFC after: 1 week Modified: head/sys/dev/usb/storage/umass.c Modified: head/sys/dev/usb/storage/umass.c ============================================================================== --- head/sys/dev/usb/storage/umass.c Mon Apr 11 06:53:45 2011 (r220534) +++ head/sys/dev/usb/storage/umass.c Mon Apr 11 08:23:27 2011 (r220535) @@ -1849,9 +1849,23 @@ umass_t_cbi_command_callback(struct usb_ break; default: /* Error */ - umass_tr_error(xfer, error); - /* skip reset */ - sc->sc_last_xfer_index = UMASS_T_CBI_COMMAND; + /* + * STALL on the control pipe can be result of the command error. + * Attempt to clear this STALL same as for bulk pipe also + * results in command completion interrupt, but ASC/ASCQ there + * look like not always valid, so don't bother about it. + */ + if ((error == USB_ERR_STALLED) || + (sc->sc_transfer.callback == &umass_cam_cb)) { + sc->sc_transfer.ccb = NULL; + (sc->sc_transfer.callback) + (sc, ccb, sc->sc_transfer.data_len, + STATUS_CMD_UNKNOWN); + } else { + umass_tr_error(xfer, error); + /* skip reset */ + sc->sc_last_xfer_index = UMASS_T_CBI_COMMAND; + } break; } } @@ -2605,17 +2619,9 @@ umass_cam_cb(struct umass_softc *sc, uni /* * The wire protocol failed and will hopefully have * recovered. We return an error to CAM and let CAM - * retry the command if necessary. In case of SCSI IO - * commands we ask the CAM layer to check the - * condition first. This is a quick hack to make - * certain devices work. + * retry the command if necessary. */ - if (ccb->ccb_h.func_code == XPT_SCSI_IO) { - ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR; - ccb->csio.scsi_status = SCSI_STATUS_CHECK_COND; - } else { - ccb->ccb_h.status = CAM_REQ_CMP_ERR; - } + ccb->ccb_h.status = CAM_REQ_CMP_ERR; xpt_done(ccb); break; } From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 11:15:35 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38619106566C; Mon, 11 Apr 2011 11:15:35 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2844B8FC20; Mon, 11 Apr 2011 11:15:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3BBFZdK085796; Mon, 11 Apr 2011 11:15:35 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3BBFZbf085792; Mon, 11 Apr 2011 11:15:35 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104111115.p3BBFZbf085792@svn.freebsd.org> From: Adrian Chadd Date: Mon, 11 Apr 2011 11:15:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220539 - in head/sys/dev/ath/ath_hal: ar5416 ar9002 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 11:15:35 -0000 Author: adrian Date: Mon Apr 11 11:15:34 2011 New Revision: 220539 URL: http://svn.freebsd.org/changeset/base/220539 Log: De-dup the ar5416 rates array definition. Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416.h head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416.h Mon Apr 11 09:28:28 2011 (r220538) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416.h Mon Apr 11 11:15:34 2011 (r220539) @@ -37,6 +37,19 @@ typedef struct { uint16_t ext_center; } CHAN_CENTERS; +typedef enum Ar5416_Rates { + rate6mb, rate9mb, rate12mb, rate18mb, + rate24mb, rate36mb, rate48mb, rate54mb, + rate1l, rate2l, rate2s, rate5_5l, + rate5_5s, rate11l, rate11s, rateXr, + rateHt20_0, rateHt20_1, rateHt20_2, rateHt20_3, + rateHt20_4, rateHt20_5, rateHt20_6, rateHt20_7, + rateHt40_0, rateHt40_1, rateHt40_2, rateHt40_3, + rateHt40_4, rateHt40_5, rateHt40_6, rateHt40_7, + rateDupCck, rateDupOfdm, rateExtCck, rateExtOfdm, + Ar5416RateSize +} AR5416_RATES; + #define AR5416_DEFAULT_RXCHAINMASK 7 #define AR5416_DEFAULT_TXCHAINMASK 1 #define AR5416_MAX_RATE_POWER 63 Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Mon Apr 11 09:28:28 2011 (r220538) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Mon Apr 11 11:15:34 2011 (r220539) @@ -794,20 +794,6 @@ ar5416GetChipPowerLimits(struct ath_hal return AH_TRUE; } -/* XXX gag, this is sick */ -typedef enum Ar5416_Rates { - rate6mb, rate9mb, rate12mb, rate18mb, - rate24mb, rate36mb, rate48mb, rate54mb, - rate1l, rate2l, rate2s, rate5_5l, - rate5_5s, rate11l, rate11s, rateXr, - rateHt20_0, rateHt20_1, rateHt20_2, rateHt20_3, - rateHt20_4, rateHt20_5, rateHt20_6, rateHt20_7, - rateHt40_0, rateHt40_1, rateHt40_2, rateHt40_3, - rateHt40_4, rateHt40_5, rateHt40_6, rateHt40_7, - rateDupCck, rateDupOfdm, rateExtCck, rateExtOfdm, - Ar5416RateSize -} AR5416_RATES; - /************************************************************** * ar5416SetTransmitPower * Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c Mon Apr 11 09:28:28 2011 (r220538) +++ head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c Mon Apr 11 11:15:34 2011 (r220539) @@ -67,20 +67,6 @@ static void ar9285GetGainBoundariesAndPd uint16_t numXpdGains); static uint16_t ar9285GetMaxEdgePower(uint16_t, CAL_CTL_EDGES *); -/* XXX gag, this is sick */ -typedef enum Ar5416_Rates { - rate6mb, rate9mb, rate12mb, rate18mb, - rate24mb, rate36mb, rate48mb, rate54mb, - rate1l, rate2l, rate2s, rate5_5l, - rate5_5s, rate11l, rate11s, rateXr, - rateHt20_0, rateHt20_1, rateHt20_2, rateHt20_3, - rateHt20_4, rateHt20_5, rateHt20_6, rateHt20_7, - rateHt40_0, rateHt40_1, rateHt40_2, rateHt40_3, - rateHt40_4, rateHt40_5, rateHt40_6, rateHt40_7, - rateDupCck, rateDupOfdm, rateExtCck, rateExtOfdm, - Ar5416RateSize -} AR5416_RATES; - HAL_BOOL ar9285SetTransmitPower(struct ath_hal *ah, const struct ieee80211_channel *chan, uint16_t *rfXpdGain) From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 14:30:46 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5040C106566C; Mon, 11 Apr 2011 14:30:46 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3D5DF8FC34; Mon, 11 Apr 2011 14:30:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3BEUkBk090134; Mon, 11 Apr 2011 14:30:46 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3BEUk3v090130; Mon, 11 Apr 2011 14:30:46 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201104111430.p3BEUk3v090130@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 11 Apr 2011 14:30:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220540 - in head: release share/man/man7 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 14:30:46 -0000 Author: nwhitehorn Date: Mon Apr 11 14:30:45 2011 New Revision: 220540 URL: http://svn.freebsd.org/changeset/base/220540 Log: Add an install target to release/Makefile instead of grubbing around (and requesting that users grub around) in /usr/obj. Also make sure that make clean removes the bootonly media and clean up that target a little. Modified: head/release/Makefile head/release/generate-release.sh head/share/man/man7/release.7 Modified: head/release/Makefile ============================================================================== --- head/release/Makefile Mon Apr 11 11:15:34 2011 (r220539) +++ head/release/Makefile Mon Apr 11 14:30:45 2011 (r220540) @@ -6,6 +6,7 @@ # cdrom: Builds release CD-ROM media (release.iso) # ftp: Sets up FTP distribution area (ftp) # release: Build all media and FTP distribution area +# install: Copies all release media into ${DESTDIR} # # Variables affecting the build process: # WORLDDIR: location of src tree -- must have built world and default kernel @@ -159,22 +160,26 @@ memstick: system packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES} sh ${.CURDIR}/scripts/make-manifest.sh ${.OBJDIR}/*.txz > ${.OBJDIR}/MANIFEST - touch ${.OBJDIR}/${.TARGET} + touch ${.TARGET} cdrom: release.iso bootonly.iso ftp: packagesystem - rm -rf ${.OBJDIR}/ftp - mkdir ${.OBJDIR}/ftp - cp ${.OBJDIR}/*.txz ${.OBJDIR}/MANIFEST ${.OBJDIR}/ftp + rm -rf ftp + mkdir ftp + cp *.txz MANIFEST ftp release: obj ${RELEASE_TARGETS} clean: chflags -R noschg ${.OBJDIR} - rm -rf ${.OBJDIR}/dist ${.OBJDIR}/ftp + rm -rf dist ftp rm -f packagesystem - rm -f ${.OBJDIR}/*.txz ${.OBJDIR}/MANIFEST + rm -f *.txz MANIFEST rm -f system - rm -rf ${.OBJDIR}/release - rm -f ${.OBJDIR}/release.iso ${.OBJDIR}/memstick + rm -rf release bootonly + rm -f release.iso bootonly.iso memstick + +install: + -mkdir ${DESTDIR} + cp -a *.iso memstick ftp ${DESTDIR}/ Modified: head/release/generate-release.sh ============================================================================== --- head/release/generate-release.sh Mon Apr 11 11:15:34 2011 (r220539) +++ head/release/generate-release.sh Mon Apr 11 14:30:45 2011 (r220540) @@ -60,7 +60,5 @@ if [ -d $2/usr/doc ]; then fi chroot $2 /bin/sh -c "cd /usr/src && make $MAKE_FLAGS buildworld buildkernel" || exit 1 -chroot $2 /bin/sh -c "cd /usr/src/release && make release" || exit 1 -mkdir $2/R -cp -pRP $2/usr/obj/usr/src/release/*.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R +chroot $2 /bin/sh -c "cd /usr/src/release && make release install DESTDIR=/R" || exit 1 Modified: head/share/man/man7/release.7 ============================================================================== --- head/share/man/man7/release.7 Mon Apr 11 11:15:34 2011 (r220539) +++ head/share/man/man7/release.7 Mon Apr 11 14:30:45 2011 (r220540) @@ -153,17 +153,17 @@ The release makefile is fairly abstruse. Most developers will only be concerned with the .Cm release -target. +and +.Cm install +targets. .\" XXX: Some sort of introduction to this list? All the others have one. .Bl -tag -width ".Cm packagesystem" .It Cm release Meta-target to build all release media and distributions applicable to this -platform. All output goes to -.Pa ${.OBJDIR} , -which will likely be either -.Pa src/release -or the equivalent path in -.Pa /usr/obj . +platform. +.It Cm install +Copy all produced release media to +.Pa ${DESTDIR} . .It Cm cdrom Builds installation CD-ROM images. On some systems, this may require that .Xr mkisofs 8 @@ -173,8 +173,10 @@ and possibly that the .Xr md 4 (memory disk) device driver be present in the kernel (either by being compiled in or available as a module). This target -produces a file called +produces files called .Pa release.iso +and +.Pa bootonly.iso as its output. .It Cm memstick Builds an installation memory stick image named @@ -293,12 +295,12 @@ svn co svn://svn.freebsd.org/base/head s cd src make buildworld cd release -make obj release +make release install DESTDIR=/var/freebsd-snapshot .Ed .Pp -After running these commands, a complete system suitable for FTP or -CD-ROM distribution is available in the -.Pa /usr/obj/usr/src/release +After running these commands, all produced distribution files (tarballs +for FTP, CD-ROM images, etc.) are available in the +.Pa /var/freebsd-snapshot directory. .Pp The following sequence of commands can be used to build a From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 14:46:41 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1CEEF106568D; Mon, 11 Apr 2011 14:46:41 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A8798FC14; Mon, 11 Apr 2011 14:46:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3BEker3090500; Mon, 11 Apr 2011 14:46:40 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3BEkeb5090498; Mon, 11 Apr 2011 14:46:40 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201104111446.p3BEkeb5090498@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 11 Apr 2011 14:46:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220541 - head/usr.sbin/bsdinstall/scripts X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 14:46:41 -0000 Author: nwhitehorn Date: Mon Apr 11 14:46:40 2011 New Revision: 220541 URL: http://svn.freebsd.org/changeset/base/220541 Log: Make the keymap script continue to work now that stderr is being redirected to the log file. Modified: head/usr.sbin/bsdinstall/scripts/keymap Modified: head/usr.sbin/bsdinstall/scripts/keymap ============================================================================== --- head/usr.sbin/bsdinstall/scripts/keymap Mon Apr 11 14:30:45 2011 (r220540) +++ head/usr.sbin/bsdinstall/scripts/keymap Mon Apr 11 14:46:40 2011 (r220541) @@ -28,5 +28,6 @@ kbdcontrol -d >/dev/null 2>&1 if [ $? -eq 0 ]; then - kbdmap 3>&2 2>&1 1>&3 | grep 'keymap=' > $BSDINSTALL_TMPETC/rc.conf.keymap + exec 3>&1 + kbdmap 2>&1 1>&3 | grep 'keymap=' > $BSDINSTALL_TMPETC/rc.conf.keymap fi From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 15:03:02 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61ED2106566B; Mon, 11 Apr 2011 15:03:01 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4EE868FC18; Mon, 11 Apr 2011 15:03:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3BF31wl090857; Mon, 11 Apr 2011 15:03:01 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3BF31wA090854; Mon, 11 Apr 2011 15:03:01 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201104111503.p3BF31wA090854@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 11 Apr 2011 15:03:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220542 - in head: release share/man/man7 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 15:03:02 -0000 Author: nwhitehorn Date: Mon Apr 11 15:03:01 2011 New Revision: 220542 URL: http://svn.freebsd.org/changeset/base/220542 Log: Don't do make release and make install in one step. Setting DESTDIR for make release has deleterious consequences. Modified: head/release/generate-release.sh head/share/man/man7/release.7 Modified: head/release/generate-release.sh ============================================================================== --- head/release/generate-release.sh Mon Apr 11 14:46:40 2011 (r220541) +++ head/release/generate-release.sh Mon Apr 11 15:03:01 2011 (r220542) @@ -60,5 +60,6 @@ if [ -d $2/usr/doc ]; then fi chroot $2 /bin/sh -c "cd /usr/src && make $MAKE_FLAGS buildworld buildkernel" || exit 1 -chroot $2 /bin/sh -c "cd /usr/src/release && make release install DESTDIR=/R" || exit 1 +chroot $2 /bin/sh -c "cd /usr/src/release && make release" || exit 1 +chroot $2 /bin/sh -c "cd /usr/src/release && make install DESTDIR=/R" || exit 1 Modified: head/share/man/man7/release.7 ============================================================================== --- head/share/man/man7/release.7 Mon Apr 11 14:46:40 2011 (r220541) +++ head/share/man/man7/release.7 Mon Apr 11 15:03:01 2011 (r220542) @@ -295,7 +295,8 @@ svn co svn://svn.freebsd.org/base/head s cd src make buildworld cd release -make release install DESTDIR=/var/freebsd-snapshot +make release +make install DESTDIR=/var/freebsd-snapshot .Ed .Pp After running these commands, all produced distribution files (tarballs From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 16:16:20 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id E99261065670; Mon, 11 Apr 2011 16:16:17 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: Bruce Evans Date: Mon, 11 Apr 2011 12:15:59 -0400 User-Agent: KMail/1.6.2 References: <201104081954.p38JsTED090284@svn.freebsd.org> <20110409075110.L834@besplex.bde.org> In-Reply-To: <20110409075110.L834@besplex.bde.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201104111216.04972.jkim@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r220459 - head/sys/x86/isa X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 16:16:20 -0000 On Friday 08 April 2011 06:29 pm, Bruce Evans wrote: > On Fri, 8 Apr 2011, Jung-uk Kim wrote: > > Log: > > Refactor DELAYDEBUG as it is only useful for correcting i8254 > > frequency. > > Er, DELAYDEBUG has nothing to do with the i8254 except that the > non-i8254 case was broken (mostly in unreachable code, and missing > instrumentation corresponding to the getit_calls counter). Now it > is more broken -- e.g., configuring DELAYDEBUG now prevents the > non-i8254 timers from even being compiled. Non-i8254 case was broken far too long and nobody cared to fix it. So, I concluded it isn't "useful". If you need to fix it, please feel free. :-) Jung-uk Kim From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 19:27:45 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 544991065673; Mon, 11 Apr 2011 19:27:45 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2B7BF8FC1C; Mon, 11 Apr 2011 19:27:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3BJRjDd097469; Mon, 11 Apr 2011 19:27:45 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3BJRjw8097467; Mon, 11 Apr 2011 19:27:45 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201104111927.p3BJRjw8097467@svn.freebsd.org> From: Jung-uk Kim Date: Mon, 11 Apr 2011 19:27:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220545 - head/sys/x86/isa X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 19:27:45 -0000 Author: jkim Date: Mon Apr 11 19:27:44 2011 New Revision: 220545 URL: http://svn.freebsd.org/changeset/base/220545 Log: Merge two similar functions to reduce duplication. Modified: head/sys/x86/isa/clock.c Modified: head/sys/x86/isa/clock.c ============================================================================== --- head/sys/x86/isa/clock.c Mon Apr 11 17:49:26 2011 (r220544) +++ head/sys/x86/isa/clock.c Mon Apr 11 19:27:44 2011 (r220545) @@ -246,40 +246,50 @@ getit(void) } #ifndef DELAYDEBUG -static __inline void -delay_tsc(int n, uint64_t freq) +static u_int +get_tsc(__unused struct timecounter *tc) { - uint64_t start, end, now; - sched_pin(); - start = rdtsc(); - end = start + (freq * n) / 1000000; - do { - cpu_spinwait(); - now = rdtsc(); - } while (now < end || (now > start && end < start)); - sched_unpin(); + return (rdtsc()); } -static __inline void -delay_timecounter(struct timecounter *tc, int n) +static __inline int +delay_tc(int n) { - uint64_t end, now; + struct timecounter *tc; + timecounter_get_t *func; + uint64_t end, freq, now; u_int last, mask, u; - mask = tc->tc_counter_mask; - last = tc->tc_get_timecount(tc) & mask; - end = tc->tc_frequency * n / 1000000; + tc = timecounter; + freq = atomic_load_acq_64(&tsc_freq); + if (freq != 0) { + func = get_tsc; + mask = ~0u; + } else { + if (tc->tc_quality <= 0) + return (0); + func = tc->tc_get_timecount; + mask = tc->tc_counter_mask; + freq = tc->tc_frequency; + } now = 0; + end = freq * n / 1000000; + if (func == get_tsc) + sched_pin(); + last = func(tc) & mask; do { cpu_spinwait(); - u = tc->tc_get_timecount(tc) & mask; + u = func(tc) & mask; if (u < last) now += mask - last + u + 1; else now += u - last; last = u; } while (now < end); + if (func == get_tsc) + sched_unpin(); + return (1); } #endif @@ -306,19 +316,8 @@ DELAY(int n) if (state == 1) printf("DELAY(%d)...", n); #else - struct timecounter *tc; - uint64_t freq; - - freq = atomic_load_acq_64(&tsc_freq); - if (freq != 0) { - delay_tsc(n, freq); + if (delay_tc(n)) return; - } - tc = timecounter; - if (tc->tc_quality > 0) { - delay_timecounter(tc, n); - return; - } #endif /* * Read the counter first, so that the rest of the setup overhead is From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 20:54:30 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57673106564A; Mon, 11 Apr 2011 20:54:30 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 486358FC1D; Mon, 11 Apr 2011 20:54:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3BKsUmI099230; Mon, 11 Apr 2011 20:54:30 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3BKsUxw099228; Mon, 11 Apr 2011 20:54:30 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201104112054.p3BKsUxw099228@svn.freebsd.org> From: Rick Macklem Date: Mon, 11 Apr 2011 20:54:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220546 - head/sys/fs/nfsserver X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 20:54:30 -0000 Author: rmacklem Date: Mon Apr 11 20:54:30 2011 New Revision: 220546 URL: http://svn.freebsd.org/changeset/base/220546 Log: Vrele ni_startdir in the experimental NFS server for the case of NFSv2 getting an error return from VOP_MKNOD(). Without this patch, the server file system remains busy after an NFSv2 VOP_MKNOD() fails. MFC after: 2 weeks Modified: head/sys/fs/nfsserver/nfs_nfsdport.c Modified: head/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdport.c Mon Apr 11 19:27:44 2011 (r220545) +++ head/sys/fs/nfsserver/nfs_nfsdport.c Mon Apr 11 20:54:30 2011 (r220546) @@ -765,10 +765,9 @@ nfsvno_createsub(struct nfsrv_descript * &ndp->ni_cnd, &nvap->na_vattr); vput(ndp->ni_dvp); nfsvno_relpathbuf(ndp); - if (error) { - vrele(ndp->ni_startdir); + vrele(ndp->ni_startdir); + if (error) return (error); - } } else { vrele(ndp->ni_startdir); nfsvno_relpathbuf(ndp); From owner-svn-src-head@FreeBSD.ORG Mon Apr 11 21:57:59 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92D271065670; Mon, 11 Apr 2011 21:57:59 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 681838FC1C; Mon, 11 Apr 2011 21:57:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3BLvxuP000812; Mon, 11 Apr 2011 21:57:59 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3BLvxr4000810; Mon, 11 Apr 2011 21:57:59 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201104112157.p3BLvxr4000810@svn.freebsd.org> From: Edwin Groothuis Date: Mon, 11 Apr 2011 21:57:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220549 - head/contrib/tzdata X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Apr 2011 21:57:59 -0000 Author: edwin Date: Mon Apr 11 21:57:59 2011 New Revision: 220549 URL: http://svn.freebsd.org/changeset/base/220549 Log: MFV of r220547, tzdata2011f: - During 2011 the Falkland Islands will remain on Summer time. Obtained from: ftp://elsie.nci.nih.gov/pub/ Modified: head/contrib/tzdata/southamerica Directory Properties: head/contrib/tzdata/ (props changed) Modified: head/contrib/tzdata/southamerica ============================================================================== --- head/contrib/tzdata/southamerica Mon Apr 11 21:55:09 2011 (r220548) +++ head/contrib/tzdata/southamerica Mon Apr 11 21:57:59 2011 (r220549) @@ -1,5 +1,5 @@ #
-# @(#)southamerica	8.47
+# @(#)southamerica	8.48
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -1343,6 +1343,24 @@ Zone Pacific/Galapagos	-5:58:24 -	LMT	19
 # For now, we'll just record the time in Stanley, since we have no
 # better info.
 
+# From Steffen Thorsen (2011-04-01):
+# The Falkland Islands will not turn back clocks this winter, but stay on
+# daylight saving time.
+#
+# One source:
+# 
+# http://www.falklandnews.com/public/story.cfm?get=5914&source=3
+# 
+#
+# We have gotten this confirmed by a clerk of the legislative assembly:
+# Normally the clocks revert to Local Mean Time (UTC/GMT -4 hours) on the
+# third Sunday of April at 0200hrs and advance to Summer Time (UTC/GMT -3
+# hours) on the first Sunday of September at 0200hrs.
+#
+# IMPORTANT NOTE: During 2011, on a trial basis, the Falkland Islands
+# will not revert to local mean time, but clocks will remain on Summer
+# time (UTC/GMT - 3 hours) throughout the whole of 2011.  Any long term
+# change to local time following the trial period will be notified.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Falk	1937	1938	-	Sep	lastSun	0:00	1:00	S
 Rule	Falk	1938	1942	-	Mar	Sun>=19	0:00	0	-
@@ -1354,7 +1372,8 @@ Rule	Falk	1984	1985	-	Apr	lastSun	0:00	0
 Rule	Falk	1984	only	-	Sep	16	0:00	1:00	S
 Rule	Falk	1985	2000	-	Sep	Sun>=9	0:00	1:00	S
 Rule	Falk	1986	2000	-	Apr	Sun>=16	0:00	0	-
-Rule	Falk	2001	max	-	Apr	Sun>=15	2:00	0	-
+Rule	Falk	2001	2010	-	Apr	Sun>=15	2:00	0	-
+Rule	Falk	2012	max	-	Apr	Sun>=15	2:00	0	-
 Rule	Falk	2001	max	-	Sep	Sun>=1	2:00	1:00	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Atlantic/Stanley	-3:51:24 -	LMT	1890

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 01:19:24 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4B44E106564A;
	Tue, 12 Apr 2011 01:19:24 +0000 (UTC) (envelope-from bz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3779B8FC08;
	Tue, 12 Apr 2011 01:19:24 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3C1JORI005236;
	Tue, 12 Apr 2011 01:19:24 GMT (envelope-from bz@svn.freebsd.org)
Received: (from bz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3C1JOFq005234;
	Tue, 12 Apr 2011 01:19:24 GMT (envelope-from bz@svn.freebsd.org)
Message-Id: <201104120119.p3C1JOFq005234@svn.freebsd.org>
From: "Bjoern A. Zeeb" 
Date: Tue, 12 Apr 2011 01:19:24 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220555 - head/sys/ofed/drivers/infiniband/ulp/ipoib
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 01:19:24 -0000

Author: bz
Date: Tue Apr 12 01:19:23 2011
New Revision: 220555
URL: http://svn.freebsd.org/changeset/base/220555

Log:
  Even though this block is not compiled currently, properly assign
  CSUM_TSO to if_hwassist rather than if_capabilities to avoid future
  errors.
  
  Reviewed by:	jeff

Modified:
  head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c

Modified: head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c	Tue Apr 12 00:38:22 2011	(r220554)
+++ head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c	Tue Apr 12 01:19:23 2011	(r220555)
@@ -924,8 +924,10 @@ ipoib_set_dev_features(struct ipoib_dev_
 	}
 
 #if 0
-	if (priv->dev->features & NETIF_F_SG && priv->hca_caps & IB_DEVICE_UD_TSO)
-		priv->dev->if_capabilities |= IFCAP_TSO4 | CSUM_TSO;
+	if (priv->dev->features & NETIF_F_SG && priv->hca_caps & IB_DEVICE_UD_TSO) {
+		priv->dev->if_capabilities |= IFCAP_TSO4;
+		priv->dev->if_hwassist |= CSUM_TSO;
+	}
 #endif
 #endif
 	priv->dev->if_capabilities |=

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 02:07:24 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 193C9106564A;
	Tue, 12 Apr 2011 02:07:24 +0000 (UTC) (envelope-from bz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 067358FC13;
	Tue, 12 Apr 2011 02:07:24 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3C27NkZ006178;
	Tue, 12 Apr 2011 02:07:23 GMT (envelope-from bz@svn.freebsd.org)
Received: (from bz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3C27N1u006176;
	Tue, 12 Apr 2011 02:07:23 GMT (envelope-from bz@svn.freebsd.org)
Message-Id: <201104120207.p3C27N1u006176@svn.freebsd.org>
From: "Bjoern A. Zeeb" 
Date: Tue, 12 Apr 2011 02:07:23 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220556 - head
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 02:07:24 -0000

Author: bz
Date: Tue Apr 12 02:07:23 2011
New Revision: 220556
URL: http://svn.freebsd.org/changeset/base/220556

Log:
  If building (custom) FreeBSD images people tend to patch param.h.  In case
  this happens just before the build is started (within the same second)
  CHECK_TIME actually triggers thinking param.h is in the future (see f_Xtime,
  c_Xtime logi in find(1) sources for the details in !F_EXACTTIME case).
  Using the -mtime -0s (seconds, rather than no unit) avoids this 1s race.
  
  Submitted by:	ed (2009-05-03)
  Reviewed by:	cperciva (2009-05-03), emaste
  Tested by:	bz (for almost two years)
  MFC after:	4 days

Modified:
  head/Makefile

Modified: head/Makefile
==============================================================================
--- head/Makefile	Tue Apr 12 01:19:23 2011	(r220555)
+++ head/Makefile	Tue Apr 12 02:07:23 2011	(r220556)
@@ -214,7 +214,7 @@ ${TGTS}:
 .MAIN:	all
 
 STARTTIME!= LC_ALL=C date
-CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0
+CHECK_TIME!= find ${.CURDIR}/sys/sys/param.h -mtime -0s
 .if !empty(CHECK_TIME)
 .error check your date/time: ${STARTTIME}
 .endif

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 07:49:12 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0D9B4106564A;
	Tue, 12 Apr 2011 07:49:12 +0000 (UTC)
	(envelope-from hselasky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F21B68FC14;
	Tue, 12 Apr 2011 07:49:11 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3C7nBEg014205;
	Tue, 12 Apr 2011 07:49:11 GMT
	(envelope-from hselasky@svn.freebsd.org)
Received: (from hselasky@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3C7nBDQ014198;
	Tue, 12 Apr 2011 07:49:11 GMT
	(envelope-from hselasky@svn.freebsd.org)
Message-Id: <201104120749.p3C7nBDQ014198@svn.freebsd.org>
From: Hans Petter Selasky 
Date: Tue, 12 Apr 2011 07:49:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220558 - in head/sys: arm/econa dev/usb/controller
	mips/atheros mips/rmi
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 07:49:12 -0000

Author: hselasky
Date: Tue Apr 12 07:49:11 2011
New Revision: 220558
URL: http://svn.freebsd.org/changeset/base/220558

Log:
  We don't need to call EOWRITE4(sc, EHCI_USBINTR, 0) directly from each EHCI
  bus driver at detach, hence ehci_detach() does exactly this since r199718.
  
  Submitted by:	Luiz Otavio O Souza
  MFC after:	7 days
  Approved by:	thompsa (mentor)

Modified:
  head/sys/arm/econa/ehci_ebus.c
  head/sys/dev/usb/controller/ehci_ixp4xx.c
  head/sys/dev/usb/controller/ehci_mv.c
  head/sys/dev/usb/controller/ehci_pci.c
  head/sys/mips/atheros/ar71xx_ehci.c
  head/sys/mips/rmi/xls_ehci.c

Modified: head/sys/arm/econa/ehci_ebus.c
==============================================================================
--- head/sys/arm/econa/ehci_ebus.c	Tue Apr 12 04:48:37 2011	(r220557)
+++ head/sys/arm/econa/ehci_ebus.c	Tue Apr 12 07:49:11 2011	(r220558)
@@ -238,10 +238,10 @@ ehci_ebus_detach(device_t self)
 	device_delete_all_children(self);
 
 	/*
-	 * disable interrupts that might have been switched on in ehci_init
+	 * disable interrupts that might have been switched on in
+	 * ehci_ebus_attach()
 	 */
 	if (sc->sc_io_res) {
-		EOWRITE4(sc, EHCI_USBINTR, 0);
 		EWRITE4(sc, USB_BRIDGE_INTR_MASK, 0);
 	}
 	if (sc->sc_irq_res && sc->sc_intr_hdl) {

Modified: head/sys/dev/usb/controller/ehci_ixp4xx.c
==============================================================================
--- head/sys/dev/usb/controller/ehci_ixp4xx.c	Tue Apr 12 04:48:37 2011	(r220557)
+++ head/sys/dev/usb/controller/ehci_ixp4xx.c	Tue Apr 12 07:49:11 2011	(r220558)
@@ -259,13 +259,6 @@ ehci_ixp_detach(device_t self)
 	/* during module unload there are lots of children leftover */
 	device_delete_all_children(self);
 
-	/*
-	 * disable interrupts that might have been switched on in ehci_init
-	 */
-	if (sc->sc_io_res) {
-		EOWRITE4(sc, EHCI_USBINTR, 0);
-	}
-
  	if (sc->sc_irq_res && sc->sc_intr_hdl) {
 		/*
 		 * only call ehci_detach() after ehci_init()

Modified: head/sys/dev/usb/controller/ehci_mv.c
==============================================================================
--- head/sys/dev/usb/controller/ehci_mv.c	Tue Apr 12 04:48:37 2011	(r220557)
+++ head/sys/dev/usb/controller/ehci_mv.c	Tue Apr 12 07:49:11 2011	(r220558)
@@ -292,10 +292,9 @@ mv_ehci_detach(device_t self)
 	device_delete_all_children(self);
 
 	/*
-	 * disable interrupts that might have been switched on in ehci_init
+	 * disable interrupts that might have been switched on in mv_ehci_attach
 	 */
 	if (sc->sc_io_res) {
-		EOWRITE4(sc, EHCI_USBINTR, 0);
 		EWRITE4(sc, USB_BRIDGE_INTR_MASK, 0);
 	}
 	if (sc->sc_irq_res && sc->sc_intr_hdl) {

Modified: head/sys/dev/usb/controller/ehci_pci.c
==============================================================================
--- head/sys/dev/usb/controller/ehci_pci.c	Tue Apr 12 04:48:37 2011	(r220557)
+++ head/sys/dev/usb/controller/ehci_pci.c	Tue Apr 12 07:49:11 2011	(r220558)
@@ -502,12 +502,6 @@ ehci_pci_detach(device_t self)
 
 	pci_disable_busmaster(self);
 
-	/*
-	 * disable interrupts that might have been switched on in ehci_init
-	 */
-	if (sc->sc_io_res) {
-		EOWRITE4(sc, EHCI_USBINTR, 0);
-	}
 	if (sc->sc_irq_res && sc->sc_intr_hdl) {
 		/*
 		 * only call ehci_detach() after ehci_init()

Modified: head/sys/mips/atheros/ar71xx_ehci.c
==============================================================================
--- head/sys/mips/atheros/ar71xx_ehci.c	Tue Apr 12 04:48:37 2011	(r220557)
+++ head/sys/mips/atheros/ar71xx_ehci.c	Tue Apr 12 07:49:11 2011	(r220558)
@@ -246,13 +246,6 @@ ar71xx_ehci_detach(device_t self)
 	/* during module unload there are lots of children leftover */
 	device_delete_all_children(self);
 
-	/*
-	 * disable interrupts that might have been switched on in ehci_init
-	 */
-	if (sc->sc_io_res) {
-		EOWRITE4(sc, EHCI_USBINTR, 0);
-	}
-
  	if (sc->sc_irq_res && sc->sc_intr_hdl) {
 		/*
 		 * only call ehci_detach() after ehci_init()

Modified: head/sys/mips/rmi/xls_ehci.c
==============================================================================
--- head/sys/mips/rmi/xls_ehci.c	Tue Apr 12 04:48:37 2011	(r220557)
+++ head/sys/mips/rmi/xls_ehci.c	Tue Apr 12 07:49:11 2011	(r220558)
@@ -216,13 +216,6 @@ ehci_xls_detach(device_t self)
 	/* during module unload there are lots of children leftover */
 	device_delete_all_children(self);
 
-	/*
-	 * disable interrupts that might have been switched on in ehci_init
-	 */
-	if (sc->sc_io_res) {
-		EOWRITE4(sc, EHCI_USBINTR, 0);
-	}
-
 	if (sc->sc_irq_res && sc->sc_intr_hdl) {
 		ehci_detach(sc);
 

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 08:10:26 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 60734106566B;
	Tue, 12 Apr 2011 08:10:26 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 48D218FC19;
	Tue, 12 Apr 2011 08:10:26 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3C8AQrc014707;
	Tue, 12 Apr 2011 08:10:26 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3C8AQs0014704;
	Tue, 12 Apr 2011 08:10:26 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104120810.p3C8AQs0014704@svn.freebsd.org>
From: Adrian Chadd 
Date: Tue, 12 Apr 2011 08:10:26 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220559 - in head/sys: conf geom
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 08:10:26 -0000

Author: adrian
Date: Tue Apr 12 08:10:25 2011
New Revision: 220559
URL: http://svn.freebsd.org/changeset/base/220559

Log:
  Introduce geom_map, a GEOM provider designed for use by
  embedded flash stores.
  
  Some devices - notably those with uboot - don't have an
  explicit partition table (eg like Redboot's FIS.)
  geom_map thus provides an easy way to export the hard-coded
  flash layout as geom providers for use by filesystems and
  other tools.
  
  It also includes a "search" function which allows for
  dynamic creation of partition layouts where the device only
  has a single hard-coded partition. For example, if
  there is a "kernel+rootfs" partition, a single image can
  be created which appends the rootfs after the kernel with
  an appropriate search string. geom_map can be told to
  search for said search string and create a partition
  beginning after it.
  
  Submitted by:	Aleksandr Rybalko 

Added:
  head/sys/geom/geom_map.c   (contents, props changed)
Modified:
  head/sys/conf/files

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Tue Apr 12 07:49:11 2011	(r220558)
+++ head/sys/conf/files	Tue Apr 12 08:10:25 2011	(r220559)
@@ -2083,6 +2083,7 @@ geom/geom_event.c		standard
 geom/geom_fox.c			optional geom_fox
 geom/geom_io.c			standard
 geom/geom_kern.c		standard
+geom/geom_map.c			optional geom_map
 geom/geom_mbr.c			optional geom_mbr
 geom/geom_mbr_enc.c		optional geom_mbr
 geom/geom_pc98.c		optional geom_pc98

Added: head/sys/geom/geom_map.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/geom/geom_map.c	Tue Apr 12 08:10:25 2011	(r220559)
@@ -0,0 +1,356 @@
+/*-
+ * Copyright (c) 2010-2011 Aleksandr Rybalko 
+ *   based on geom_redboot.c
+ * Copyright (c) 2009 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ *    redistribution must be conditioned upon including a substantially
+ *    similar Disclaimer requirement for further binary redistribution.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define MAP_CLASS_NAME "MAP"
+
+struct map_desc {
+	uint8_t		name   [16];	/* null-terminated name */
+	uint32_t	offset;	/* offset in flash */
+	uint32_t	addr;	/* address in memory */
+	uint32_t	size;	/* image size in bytes */
+	uint32_t	entry;	/* offset in image for entry point */
+	uint32_t	dsize;	/* data size in bytes */
+};
+
+#define	MAP_MAXSLICE	64
+
+struct g_map_softc {
+	uint32_t	entry  [MAP_MAXSLICE];
+	uint32_t	dsize  [MAP_MAXSLICE];
+	uint8_t		readonly[MAP_MAXSLICE];
+	g_access_t     *parent_access;
+};
+
+static int
+g_map_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td)
+{
+	return (ENOIOCTL);
+}
+
+static int
+g_map_access(struct g_provider *pp, int dread, int dwrite, int dexcl)
+{
+	struct g_geom  *gp = pp->geom;
+	struct g_slicer *gsp = gp->softc;
+	struct g_map_softc *sc = gsp->softc;
+
+	if (dwrite > 0 && sc->readonly[pp->index])
+		return (EPERM);
+	return (sc->parent_access(pp, dread, dwrite, dexcl)); 
+	/* 
+	 * no (sc->parent_access(pp, dread, dwrite, dexcl));,
+	 * We need to have way for update flash 
+	 */ 
+}
+
+static int
+g_map_start(struct bio *bp)
+{
+	struct g_provider *pp;
+	struct g_geom  *gp;
+	struct g_map_softc *sc;
+	struct g_slicer *gsp;
+	int		idx;
+
+	pp = bp->bio_to;
+	idx = pp->index;
+	gp = pp->geom;
+	gsp = gp->softc;
+	sc = gsp->softc;
+	if (bp->bio_cmd == BIO_GETATTR) {
+		if (g_handleattr_int(bp, MAP_CLASS_NAME "::entry",
+				     sc->entry[idx]))
+			return (1);
+		if (g_handleattr_int(bp, MAP_CLASS_NAME "::dsize",
+				     sc->dsize[idx]))
+			return (1);
+	}
+	return (0);
+}
+
+static void
+g_map_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
+	       struct g_consumer *cp __unused, struct g_provider *pp)
+{
+	struct g_map_softc *sc;
+	struct g_slicer *gsp;
+
+	gsp = gp->softc;
+	sc = gsp->softc;
+	g_slice_dumpconf(sb, indent, gp, cp, pp);
+	if (pp != NULL) {
+		if (indent == NULL) {
+			sbuf_printf(sb, " entry %d", sc->entry[pp->index]);
+			sbuf_printf(sb, " dsize %d", sc->dsize[pp->index]);
+		} else {
+			sbuf_printf(sb, "%s%d\n", indent,
+				    sc->entry[pp->index]);
+			sbuf_printf(sb, "%s%d\n", indent,
+				    sc->dsize[pp->index]);
+		}
+	}
+}
+
+#include 
+
+
+static struct g_geom *
+g_map_taste(struct g_class *mp, struct g_provider *pp, int insist)
+{
+	struct g_geom  *gp;
+	struct g_consumer *cp;
+	struct g_map_softc *sc;
+	int		error     , sectorsize, i, ret;
+	struct map_desc *head;
+	u_int32_t	start = 0, end = 0, size = 0, off, readonly;
+	const char     *name;
+	const char     *at;
+	const char     *search;
+	int		search_start = 0, search_end = 0;
+	u_char         *buf;
+	uint32_t	offmask;
+	u_int		blksize;/* NB: flash block size stored as stripesize */
+	off_t		offset;
+
+	g_trace(G_T_TOPOLOGY, "map_taste(%s,%s)", mp->name, pp->name);
+	g_topology_assert();
+	if (!strcmp(pp->geom->class->name, MAP_CLASS_NAME))
+		return (NULL);
+
+	gp = g_slice_new(mp, MAP_MAXSLICE, pp, &cp, &sc, sizeof(*sc),
+			 g_map_start);
+	if (gp == NULL)
+		return (NULL);
+
+	/* interpose our access method */
+	sc->parent_access = gp->access;
+	gp->access = g_map_access;
+
+	sectorsize = cp->provider->sectorsize;
+	blksize = cp->provider->stripesize;
+	if (powerof2(cp->provider->mediasize))
+		offmask = cp->provider->mediasize - 1;
+	else
+		offmask = 0xffffffff;	/* XXX */
+
+	g_topology_unlock();
+	head = NULL;
+	offset = cp->provider->mediasize - blksize;
+	g_topology_lock();
+
+	for (i = 0; i < MAP_MAXSLICE; i++) {
+		search_start = search_end = start = end = off = readonly = 0;
+
+		ret = resource_string_value("map", i, "at", &at);
+		if (ret)
+			continue;
+
+		/* Check if my provider */
+		if (strncmp(pp->name, at, strlen(at)))
+			continue;
+
+		ret = resource_string_value("map", i, "start", &search);
+
+		if (!ret && strncmp(search, "search", 6) == 0) {
+			uint32_t search_offset, search_start = 0;
+			uint32_t search_step = 0;
+			const char *search_key;
+			char key[255];
+			int c;
+
+			ret = resource_int_value("map", i, "searchstart",
+						 &search_start);
+			ret = resource_int_value("map", i, "searchstep",
+						 &search_step);
+			if (ret)
+				search_step = 0x10000U;
+			ret = resource_string_value("map", i, "searchkey", &search_key);
+			if (ret)
+				continue;
+
+			printf("GEOM_MAP: searchkey=\"%s\"\n", search_key);
+			for (search_offset = search_start;
+			     search_offset < cp->provider->mediasize && start == 0;
+			     search_offset += search_step) {
+				buf = g_read_data(cp, 
+					rounddown(search_offset, sectorsize), 
+					roundup(strlen(search_key), sectorsize), 
+					NULL);
+
+				/* Wildcard, replace '.' with byte from data */
+				strncpy(key, search_key, 255);
+				for (c = 0; c < 255 && key[c]; c++)
+					if (key[c] == '.')
+						key[c] = ((char *)(buf + search_offset % sectorsize))[c];
+
+				if (buf != NULL && strncmp(
+					buf + search_offset % sectorsize, 
+					key, strlen(search_key)) == 0)
+					start = search_offset;
+				g_free(buf);
+			}
+			if (!start)
+				continue;
+		} else {
+			ret = resource_int_value("map", i, "start", &start);
+			if (ret)
+				continue;
+		}
+
+		ret = resource_string_value("map", i, "end", &search);
+
+		if (!ret && strncmp(search, "search", 6) == 0) {
+			uint32_t search_offset, search_start = 0, search_step = 0;
+			const char *search_key;
+			char key[255];
+			int c;
+
+			ret = resource_int_value("map", i, "searchstart", &search_start);
+			ret = resource_int_value("map", i, "searchstep", &search_step);
+			if (ret)
+				search_step = 0x10000U;
+			ret = resource_string_value("map", i, "searchkey", &search_key);
+			if (ret)
+				continue;
+
+			for (search_offset = search_start;
+			     search_offset < cp->provider->mediasize && end == 0;
+			     search_offset += search_step) {
+				buf = g_read_data(cp, 
+					rounddown(search_offset, sectorsize), 
+					roundup(strlen(search_key), sectorsize), 
+					NULL);
+
+				/* Wildcard, replace '.' with byte from data */
+				strncpy(key, search_key, 255);
+				for (c = 0; c < 255 && key[c]; c++)
+					if (key[c] == '.')
+						key[c] = ((char *)(buf + search_offset % sectorsize))[c];
+
+				if (buf != NULL && strncmp(
+					buf + search_offset % sectorsize, 
+					key, strlen(search_key)) == 0)
+					end = search_offset;
+				g_free(buf);
+			}
+			if (!end)
+				continue;
+		} else {
+			ret = resource_int_value("map", i, "end", &end);
+			if (ret)
+				continue;
+		}
+		size = end - start;
+
+		/* end is 0 or size is 0, No MAP - so next */
+		if (end == 0 || size == 0)
+			continue;
+		ret = resource_int_value("map", i, "offset", &off);
+		ret = resource_int_value("map", i, "readonly", &readonly);
+		ret = resource_string_value("map", i, "name", &name);
+		/* No name or error read name */
+		if (ret)
+			continue;
+
+		if (off > size)
+			printf("%s: off(%d) > size(%d) for \"%s\"\n", 
+				__func__, off, size, name);
+
+		error = g_slice_config(gp, i, G_SLICE_CONFIG_SET, start + off, 
+			size - off, sectorsize, "map/%s", name);
+		printf("MAP: %08x-%08x, offset=%08x \"map/%s\"\n",
+			       (uint32_t) start,
+			       (uint32_t) size,
+			       (uint32_t) off,
+			       name
+			       );
+
+		if (error)
+			printf("%s g_slice_config returns %d for \"%s\"\n", 
+				__func__, error, name);
+
+		sc->entry[i] = off;
+		sc->dsize[i] = size - off;
+		sc->readonly[i] = readonly ? 1 : 0;
+	}
+	
+
+	if (i == 0)
+		return (NULL);
+
+	g_access(cp, -1, 0, 0);
+	if (LIST_EMPTY(&gp->provider)) {
+		g_slice_spoiled(cp);
+		return (NULL);
+	}
+	return (gp);
+}
+
+static void
+g_map_config(struct gctl_req *req, struct g_class *mp, const char *verb)
+{
+	struct g_geom  *gp;
+
+	g_topology_assert();
+	gp = gctl_get_geom(req, mp, "geom");
+	if (gp == NULL)
+		return;
+	gctl_error(req, "Unknown verb");
+}
+
+static struct g_class g_map_class = {
+	.name = MAP_CLASS_NAME,
+	.version = G_VERSION,
+	.taste = g_map_taste,
+	.dumpconf = g_map_dumpconf,
+	.ctlreq = g_map_config,
+	.ioctl = g_map_ioctl,
+};
+DECLARE_GEOM_CLASS(g_map_class, g_map);

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 08:13:18 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DC05A1065672;
	Tue, 12 Apr 2011 08:13:18 +0000 (UTC)
	(envelope-from lstewart@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CAD778FC16;
	Tue, 12 Apr 2011 08:13:18 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3C8DI52014858;
	Tue, 12 Apr 2011 08:13:18 GMT
	(envelope-from lstewart@svn.freebsd.org)
Received: (from lstewart@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3C8DIw2014826;
	Tue, 12 Apr 2011 08:13:18 GMT
	(envelope-from lstewart@svn.freebsd.org)
Message-Id: <201104120813.p3C8DIw2014826@svn.freebsd.org>
From: Lawrence Stewart 
Date: Tue, 12 Apr 2011 08:13:18 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220560 - in head: share/man/man4 share/man/man9
	sys/kern sys/netinet sys/netinet/cc sys/netinet/khelp sys/sys
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 08:13:19 -0000

Author: lstewart
Date: Tue Apr 12 08:13:18 2011
New Revision: 220560
URL: http://svn.freebsd.org/changeset/base/220560

Log:
  Use the full and proper company name for Swinburne University of Technology
  throughout the source tree.
  
  Requested by:	Grenville Armitage, Director of CAIA at Swinburne University of
  			Technology
  MFC after:	3 days

Modified:
  head/share/man/man4/cc.4
  head/share/man/man4/cc_chd.4
  head/share/man/man4/cc_cubic.4
  head/share/man/man4/cc_hd.4
  head/share/man/man4/cc_htcp.4
  head/share/man/man4/cc_newreno.4
  head/share/man/man4/cc_vegas.4
  head/share/man/man4/h_ertt.4
  head/share/man/man4/siftr.4
  head/share/man/man9/cc.9
  head/share/man/man9/hhook.9
  head/share/man/man9/khelp.9
  head/sys/kern/kern_hhook.c
  head/sys/kern/kern_khelp.c
  head/sys/netinet/cc.h
  head/sys/netinet/cc/cc.c
  head/sys/netinet/cc/cc_chd.c
  head/sys/netinet/cc/cc_cubic.c
  head/sys/netinet/cc/cc_cubic.h
  head/sys/netinet/cc/cc_hd.c
  head/sys/netinet/cc/cc_htcp.c
  head/sys/netinet/cc/cc_module.h
  head/sys/netinet/cc/cc_newreno.c
  head/sys/netinet/cc/cc_vegas.c
  head/sys/netinet/khelp/h_ertt.c
  head/sys/netinet/khelp/h_ertt.h
  head/sys/netinet/siftr.c
  head/sys/netinet/tcp_input.c
  head/sys/sys/hhook.h
  head/sys/sys/khelp.h
  head/sys/sys/module_khelp.h

Modified: head/share/man/man4/cc.4
==============================================================================
--- head/share/man/man4/cc.4	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man4/cc.4	Tue Apr 12 08:13:18 2011	(r220560)
@@ -3,8 +3,9 @@
 .\" All rights reserved.
 .\"
 .\" This documentation was written at the Centre for Advanced Internet
-.\" Architectures, Swinburne University, Melbourne, Australia by David Hayes and
-.\" Lawrence Stewart under sponsorship from the FreeBSD Foundation.
+.\" Architectures, Swinburne University of Technology, Melbourne, Australia by
+.\" David Hayes and Lawrence Stewart under sponsorship from the FreeBSD
+.\" Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -93,10 +94,10 @@ modular congestion control framework fir
 .Fx 9.0 .
 .Pp
 The framework was first released in 2007 by James Healy and Lawrence Stewart
-whilst working on the NewTCP research project at Swinburne University's Centre
-for Advanced Internet Architectures, Melbourne, Australia, which was made
-possible in part by a grant from the Cisco University Research Program Fund at
-Community Foundation Silicon Valley.
+whilst working on the NewTCP research project at Swinburne University of
+Technology's Centre for Advanced Internet Architectures, Melbourne, Australia,
+which was made possible in part by a grant from the Cisco University Research
+Program Fund at Community Foundation Silicon Valley.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man4/cc_chd.4
==============================================================================
--- head/share/man/man4/cc_chd.4	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man4/cc_chd.4	Tue Apr 12 08:13:18 2011	(r220560)
@@ -3,8 +3,8 @@
 .\" All rights reserved.
 .\"
 .\" This documentation was written at the Centre for Advanced Internet
-.\" Architectures, Swinburne University, Melbourne, Australia by David Hayes
-.\" under sponsorship from the FreeBSD Foundation.
+.\" Architectures, Swinburne University of Technology, Melbourne, Australia by
+.\" David Hayes under sponsorship from the FreeBSD Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -115,8 +115,8 @@ congestion control module first appeared
 .Fx 9.0 .
 .Pp
 The module was first released in 2010 by David Hayes whilst working on the
-NewTCP research project at Swinburne University's Centre for Advanced Internet
-Architectures, Melbourne, Australia.
+NewTCP research project at Swinburne University of Technology's Centre for
+Advanced Internet Architectures, Melbourne, Australia.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man4/cc_cubic.4
==============================================================================
--- head/share/man/man4/cc_cubic.4	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man4/cc_cubic.4	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,8 +4,8 @@
 .\" All rights reserved.
 .\"
 .\" Portions of this documentation were written at the Centre for Advanced
-.\" Internet Architectures, Swinburne University, Melbourne, Australia by
-.\" David Hayes under sponsorship from the FreeBSD Foundation.
+.\" Internet Architectures, Swinburne University of Technology, Melbourne,
+.\" Australia by David Hayes under sponsorship from the FreeBSD Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -99,8 +99,8 @@ congestion control module first appeared
 .Fx 9.0 .
 .Pp
 The module was first released in 2009 by Lawrence Stewart whilst studying at
-Swinburne University's Centre for Advanced Internet Architectures, Melbourne,
-Australia.
+Swinburne University of Technology's Centre for Advanced Internet Architectures,
+Melbourne, Australia.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man4/cc_hd.4
==============================================================================
--- head/share/man/man4/cc_hd.4	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man4/cc_hd.4	Tue Apr 12 08:13:18 2011	(r220560)
@@ -3,8 +3,8 @@
 .\" All rights reserved.
 .\"
 .\" This documentation was written at the Centre for Advanced Internet
-.\" Architectures, Swinburne University, Melbourne, Australia by David Hayes
-.\" under sponsorship from the FreeBSD Foundation.
+.\" Architectures, Swinburne University of Technology, Melbourne, Australia by
+.\" David Hayes under sponsorship from the FreeBSD Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -107,8 +107,8 @@ congestion control module first appeared
 .Fx 9.0 .
 .Pp
 The module was first released in 2010 by David Hayes whilst working on the
-NewTCP research project at Swinburne University's Centre for Advanced Internet
-Architectures, Melbourne, Australia.
+NewTCP research project at Swinburne University of Technology's Centre for
+Advanced Internet Architectures, Melbourne, Australia.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man4/cc_htcp.4
==============================================================================
--- head/share/man/man4/cc_htcp.4	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man4/cc_htcp.4	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,8 +4,8 @@
 .\" All rights reserved.
 .\"
 .\" Portions of this documentation were written at the Centre for Advanced
-.\" Internet Architectures, Swinburne University, Melbourne, Australia by
-.\" David Hayes under sponsorship from the FreeBSD Foundation.
+.\" Internet Architectures, Swinburne University of Technology, Melbourne,
+.\" Australia by David Hayes under sponsorship from the FreeBSD Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -114,10 +114,10 @@ congestion control module first appeared
 .Fx 9.0 .
 .Pp
 The module was first released in 2007 by James Healy and Lawrence Stewart whilst
-working on the NewTCP research project at Swinburne University's Centre for
-Advanced Internet Architectures, Melbourne, Australia, which was made possible
-in part by a grant from the Cisco University Research Program Fund at Community
-Foundation Silicon Valley.
+working on the NewTCP research project at Swinburne University of Technology's
+Centre for Advanced Internet Architectures, Melbourne, Australia, which was made
+possible in part by a grant from the Cisco University Research Program Fund at
+Community Foundation Silicon Valley.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man4/cc_newreno.4
==============================================================================
--- head/share/man/man4/cc_newreno.4	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man4/cc_newreno.4	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,8 +4,8 @@
 .\" All rights reserved.
 .\"
 .\" Portions of this documentation were written at the Centre for Advanced
-.\" Internet Architectures, Swinburne University, Melbourne, Australia by
-.\" Lawrence Stewart under sponsorship from the FreeBSD Foundation.
+.\" Internet Architectures, Swinburne University of Technology, Melbourne,
+.\" Australia by Lawrence Stewart under sponsorship from the FreeBSD Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -61,10 +61,10 @@ congestion control algorithm first appea
 .Fx 9.0 .
 .Pp
 The module was first released in 2007 by James Healy and Lawrence Stewart whilst
-working on the NewTCP research project at Swinburne University's Centre for
-Advanced Internet Architectures, Melbourne, Australia, which was made possible
-in part by a grant from the Cisco University Research Program Fund at Community
-Foundation Silicon Valley.
+working on the NewTCP research project at Swinburne University of Technology's
+Centre for Advanced Internet Architectures, Melbourne, Australia, which was made
+possible in part by a grant from the Cisco University Research Program Fund at
+Community Foundation Silicon Valley.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man4/cc_vegas.4
==============================================================================
--- head/share/man/man4/cc_vegas.4	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man4/cc_vegas.4	Tue Apr 12 08:13:18 2011	(r220560)
@@ -3,8 +3,8 @@
 .\" All rights reserved.
 .\"
 .\" This documentation was written at the Centre for Advanced Internet
-.\" Architectures, Swinburne University, Melbourne, Australia by David Hayes
-.\" under sponsorship from the FreeBSD Foundation.
+.\" Architectures, Swinburne University of Technology, Melbourne, Australia by
+.\" David Hayes under sponsorship from the FreeBSD Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -125,8 +125,8 @@ congestion control module first appeared
 .Fx 9.0 .
 .Pp
 The module was first released in 2010 by David Hayes whilst working on the
-NewTCP research project at Swinburne University's Centre for Advanced Internet
-Architectures, Melbourne, Australia.
+NewTCP research project at Swinburne University of Technology's Centre for
+Advanced Internet Architectures, Melbourne, Australia.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man4/h_ertt.4
==============================================================================
--- head/share/man/man4/h_ertt.4	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man4/h_ertt.4	Tue Apr 12 08:13:18 2011	(r220560)
@@ -3,8 +3,8 @@
 .\" All rights reserved.
 .\"
 .\" This documentation was written at the Centre for Advanced Internet
-.\" Architectures, Swinburne University, Melbourne, Australia by David Hayes
-.\" under sponsorship from the FreeBSD Foundation.
+.\" Architectures, Swinburne University of Technology, Melbourne, Australia by
+.\" David Hayes under sponsorship from the FreeBSD Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -125,8 +125,8 @@ module first appeared in
 .Fx 9.0 .
 .Pp
 The module was first released in 2010 by David Hayes whilst working on the
-NewTCP research project at Swinburne University's Centre for Advanced Internet
-Architectures, Melbourne, Australia.
+NewTCP research project at Swinburne University of Technology's Centre for
+Advanced Internet Architectures, Melbourne, Australia.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man4/siftr.4
==============================================================================
--- head/share/man/man4/siftr.4	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man4/siftr.4	Tue Apr 12 08:13:18 2011	(r220560)
@@ -616,10 +616,10 @@ and
 .Pp
 .Nm
 was first released in 2007 by Lawrence Stewart and James Healy whilst working on
-the NewTCP research project at Swinburne University's Centre for Advanced
-Internet Architectures, Melbourne, Australia, which was made possible in part by
-a grant from the Cisco University Research Program Fund at Community Foundation
-Silicon Valley.
+the NewTCP research project at Swinburne University of Technology's Centre for
+Advanced Internet Architectures, Melbourne, Australia, which was made possible
+in part by a grant from the Cisco University Research Program Fund at Community
+Foundation Silicon Valley.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man9/cc.9
==============================================================================
--- head/share/man/man9/cc.9	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man9/cc.9	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,8 +4,8 @@
 .\" All rights reserved.
 .\"
 .\" Portions of this documentation were written at the Centre for Advanced
-.\" Internet Architectures, Swinburne University, Melbourne, Australia by
-.\" David Hayes and Lawrence Stewart under sponsorship from the
+.\" Internet Architectures, Swinburne University of Technology, Melbourne,
+.\" Australia by David Hayes and Lawrence Stewart under sponsorship from the
 .\" FreeBSD Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -310,10 +310,10 @@ The modular Congestion Control (CC) fram
 .Fx 9.0 .
 .Pp
 The framework was first released in 2007 by James Healy and Lawrence Stewart
-whilst working on the NewTCP research project at Swinburne University's Centre
-for Advanced Internet Architectures, Melbourne, Australia, which was made
-possible in part by a grant from the Cisco University Research Program Fund at
-Community Foundation Silicon Valley.
+whilst working on the NewTCP research project at Swinburne University of
+Technology's Centre for Advanced Internet Architectures, Melbourne, Australia,
+which was made possible in part by a grant from the Cisco University Research
+Program Fund at Community Foundation Silicon Valley.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man9/hhook.9
==============================================================================
--- head/share/man/man9/hhook.9	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man9/hhook.9	Tue Apr 12 08:13:18 2011	(r220560)
@@ -3,8 +3,9 @@
 .\" All rights reserved.
 .\"
 .\" This documentation was written at the Centre for Advanced Internet
-.\" Architectures, Swinburne University, Melbourne, Australia by David Hayes and
-.\" Lawrence Stewart under sponsorship from the FreeBSD Foundation.
+.\" Architectures, Swinburne University of Technology, Melbourne, Australia by
+.\" David Hayes and Lawrence Stewart under sponsorship from the FreeBSD
+.\" Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -363,8 +364,8 @@ framework first appeared in
 The
 .Nm
 framework was first released in 2010 by Lawrence Stewart whilst studying at
-Swinburne University's Centre for Advanced Internet Architectures, Melbourne,
-Australia.
+Swinburne University of Technology's Centre for Advanced Internet Architectures,
+Melbourne, Australia.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/share/man/man9/khelp.9
==============================================================================
--- head/share/man/man9/khelp.9	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/share/man/man9/khelp.9	Tue Apr 12 08:13:18 2011	(r220560)
@@ -3,8 +3,9 @@
 .\" All rights reserved.
 .\"
 .\" This documentation was written at the Centre for Advanced Internet
-.\" Architectures, Swinburne University, Melbourne, Australia by David Hayes and
-.\" Lawrence Stewart under sponsorship from the FreeBSD Foundation.
+.\" Architectures, Swinburne University of Technology, Melbourne, Australia by
+.\" David Hayes and Lawrence Stewart under sponsorship from the FreeBSD
+.\" Foundation.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
@@ -419,8 +420,8 @@ kernel helper framework first appeared i
 The
 .Nm
 framework was first released in 2010 by Lawrence Stewart whilst studying at
-Swinburne University's Centre for Advanced Internet Architectures, Melbourne,
-Australia.
+Swinburne University of Technology's Centre for Advanced Internet Architectures,
+Melbourne, Australia.
 More details are available at:
 .Pp
 http://caia.swin.edu.au/urp/newtcp/

Modified: head/sys/kern/kern_hhook.c
==============================================================================
--- head/sys/kern/kern_hhook.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/kern/kern_hhook.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,9 +4,9 @@
  * All rights reserved.
  *
  * This software was developed by Lawrence Stewart while studying at the Centre
- * for Advanced Internet Architectures, Swinburne University, made possible in
- * part by grants from the FreeBSD Foundation and Cisco University Research
- * Program Fund at Community Foundation Silicon Valley.
+ * for Advanced Internet Architectures, Swinburne University of Technology,
+ * made possible in part by grants from the FreeBSD Foundation and Cisco
+ * University Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,

Modified: head/sys/kern/kern_khelp.c
==============================================================================
--- head/sys/kern/kern_khelp.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/kern/kern_khelp.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,9 +4,9 @@
  * All rights reserved.
  *
  * This software was developed by Lawrence Stewart while studying at the Centre
- * for Advanced Internet Architectures, Swinburne University, made possible in
- * part by grants from the FreeBSD Foundation and Cisco University Research
- * Program Fund at Community Foundation Silicon Valley.
+ * for Advanced Internet Architectures, Swinburne University of Technology,
+ * made possible in part by grants from the FreeBSD Foundation and Cisco
+ * University Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,

Modified: head/sys/netinet/cc.h
==============================================================================
--- head/sys/netinet/cc.h	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/cc.h	Tue Apr 12 08:13:18 2011	(r220560)
@@ -6,9 +6,9 @@
  * All rights reserved.
  *
  * This software was developed at the Centre for Advanced Internet
- * Architectures, Swinburne University, by Lawrence Stewart and James Healy,
- * made possible in part by a grant from the Cisco University Research Program
- * Fund at Community Foundation Silicon Valley.
+ * Architectures, Swinburne University of Technology, by Lawrence Stewart and
+ * James Healy, made possible in part by a grant from the Cisco University
+ * Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,
@@ -40,10 +40,11 @@
 
 /*
  * This software was first released in 2007 by James Healy and Lawrence Stewart
- * whilst working on the NewTCP research project at Swinburne University's
- * Centre for Advanced Internet Architectures, Melbourne, Australia, which was
- * made possible in part by a grant from the Cisco University Research Program
- * Fund at Community Foundation Silicon Valley. More details are available at:
+ * whilst working on the NewTCP research project at Swinburne University of
+ * Technology's Centre for Advanced Internet Architectures, Melbourne,
+ * Australia, which was made possible in part by a grant from the Cisco
+ * University Research Program Fund at Community Foundation Silicon Valley.
+ * More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/netinet/cc/cc.c
==============================================================================
--- head/sys/netinet/cc/cc.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/cc/cc.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -6,9 +6,9 @@
  * All rights reserved.
  *
  * This software was developed at the Centre for Advanced Internet
- * Architectures, Swinburne University, by Lawrence Stewart and James Healy,
- * made possible in part by a grant from the Cisco University Research Program
- * Fund at Community Foundation Silicon Valley.
+ * Architectures, Swinburne University of Technology, by Lawrence Stewart and
+ * James Healy, made possible in part by a grant from the Cisco University
+ * Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,
@@ -38,10 +38,11 @@
 
 /*
  * This software was first released in 2007 by James Healy and Lawrence Stewart
- * whilst working on the NewTCP research project at Swinburne University's
- * Centre for Advanced Internet Architectures, Melbourne, Australia, which was
- * made possible in part by a grant from the Cisco University Research Program
- * Fund at Community Foundation Silicon Valley. More details are available at:
+ * whilst working on the NewTCP research project at Swinburne University of
+ * Technology's Centre for Advanced Internet Architectures, Melbourne,
+ * Australia, which was made possible in part by a grant from the Cisco
+ * University Research Program Fund at Community Foundation Silicon Valley.
+ * More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/netinet/cc/cc_chd.c
==============================================================================
--- head/sys/netinet/cc/cc_chd.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/cc/cc_chd.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -5,9 +5,9 @@
  * All rights reserved.
  *
  * This software was developed at the Centre for Advanced Internet
- * Architectures, Swinburne University, by David Hayes and Lawrence Stewart,
- * made possible in part by a grant from the Cisco University Research Program
- * Fund at Community Foundation Silicon Valley.
+ * Architectures, Swinburne University of Technology, by David Hayes and
+ * Lawrence Stewart, made possible in part by a grant from the Cisco University
+ * Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced Internet
  * Architectures, Swinburne University of Technology, Melbourne, Australia by
@@ -43,10 +43,10 @@
  * 11-14 October 2010.
  *
  * Originally released as part of the NewTCP research project at Swinburne
- * University's Centre for Advanced Internet Architectures, Melbourne,
- * Australia, which was made possible in part by a grant from the Cisco
- * University Research Program Fund at Community Foundation Silicon Valley. More
- * details are available at:
+ * University of Technology's Centre for Advanced Internet Architectures,
+ * Melbourne, Australia, which was made possible in part by a grant from the
+ * Cisco University Research Program Fund at Community Foundation Silicon
+ * Valley. More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/netinet/cc/cc_cubic.c
==============================================================================
--- head/sys/netinet/cc/cc_cubic.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/cc/cc_cubic.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,9 +4,9 @@
  * All rights reserved.
  *
  * This software was developed by Lawrence Stewart while studying at the Centre
- * for Advanced Internet Architectures, Swinburne University, made possible in
- * part by a grant from the Cisco University Research Program Fund at Community
- * Foundation Silicon Valley.
+ * for Advanced Internet Architectures, Swinburne University of Technology, made
+ * possible in part by a grant from the Cisco University Research Program Fund
+ * at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,
@@ -38,10 +38,10 @@
  * An implementation of the CUBIC congestion control algorithm for FreeBSD,
  * based on the Internet Draft "draft-rhee-tcpm-cubic-02" by Rhee, Xu and Ha.
  * Originally released as part of the NewTCP research project at Swinburne
- * University's Centre for Advanced Internet Architectures, Melbourne,
- * Australia, which was made possible in part by a grant from the Cisco
- * University Research Program Fund at Community Foundation Silicon Valley. More
- * details are available at:
+ * University of Technology's Centre for Advanced Internet Architectures,
+ * Melbourne, Australia, which was made possible in part by a grant from the
+ * Cisco University Research Program Fund at Community Foundation Silicon
+ * Valley. More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/netinet/cc/cc_cubic.h
==============================================================================
--- head/sys/netinet/cc/cc_cubic.h	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/cc/cc_cubic.h	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,9 +4,9 @@
  * All rights reserved.
  *
  * This software was developed by Lawrence Stewart while studying at the Centre
- * for Advanced Internet Architectures, Swinburne University, made possible in
- * part by a grant from the Cisco University Research Program Fund at Community
- * Foundation Silicon Valley.
+ * for Advanced Internet Architectures, Swinburne University of Technology, made
+ * possible in part by a grant from the Cisco University Research Program Fund
+ * at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,

Modified: head/sys/netinet/cc/cc_hd.c
==============================================================================
--- head/sys/netinet/cc/cc_hd.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/cc/cc_hd.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -6,9 +6,9 @@
  * All rights reserved.
  *
  * This software was developed at the Centre for Advanced Internet
- * Architectures, Swinburne University, by David Hayes and Lawrence Stewart,
- * made possible in part by a grant from the Cisco University Research Program
- * Fund at Community Foundation Silicon Valley.
+ * Architectures, Swinburne University of Technology, by David Hayes and
+ * Lawrence Stewart, made possible in part by a grant from the Cisco University
+ * Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced Internet
  * Architectures, Swinburne University of Technology, Melbourne, Australia by
@@ -44,10 +44,10 @@
  * 2009.
  *
  * Originally released as part of the NewTCP research project at Swinburne
- * University's Centre for Advanced Internet Architectures, Melbourne,
- * Australia, which was made possible in part by a grant from the Cisco
- * University Research Program Fund at Community Foundation Silicon Valley. More
- * details are available at:
+ * University of Technology's Centre for Advanced Internet Architectures,
+ * Melbourne, Australia, which was made possible in part by a grant from the
+ * Cisco University Research Program Fund at Community Foundation Silicon
+ * Valley. More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/netinet/cc/cc_htcp.c
==============================================================================
--- head/sys/netinet/cc/cc_htcp.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/cc/cc_htcp.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -6,9 +6,9 @@
  * All rights reserved.
  *
  * This software was developed at the Centre for Advanced Internet
- * Architectures, Swinburne University, by Lawrence Stewart and James Healy,
- * made possible in part by a grant from the Cisco University Research Program
- * Fund at Community Foundation Silicon Valley.
+ * Architectures, Swinburne University of Technology, by Lawrence Stewart and
+ * James Healy, made possible in part by a grant from the Cisco University
+ * Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,
@@ -40,10 +40,10 @@
  * An implementation of the H-TCP congestion control algorithm for FreeBSD,
  * based on the Internet Draft "draft-leith-tcp-htcp-06.txt" by Leith and
  * Shorten. Originally released as part of the NewTCP research project at
- * Swinburne University's Centre for Advanced Internet Architectures, Melbourne,
- * Australia, which was made possible in part by a grant from the Cisco
- * University Research Program Fund at Community Foundation Silicon Valley. More
- * details are available at:
+ * Swinburne University of Technology's Centre for Advanced Internet
+ * Architectures, Melbourne, Australia, which was made possible in part by a
+ * grant from the Cisco University Research Program Fund at Community Foundation
+ * Silicon Valley. More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/netinet/cc/cc_module.h
==============================================================================
--- head/sys/netinet/cc/cc_module.h	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/cc/cc_module.h	Tue Apr 12 08:13:18 2011	(r220560)
@@ -3,9 +3,9 @@
  * All rights reserved.
  *
  * This software was developed by Lawrence Stewart while studying at the Centre
- * for Advanced Internet Architectures, Swinburne University, made possible in
- * part by a grant from the Cisco University Research Program Fund at Community
- * Foundation Silicon Valley.
+ * for Advanced Internet Architectures, Swinburne University of Technology, made
+ * possible in part by a grant from the Cisco University Research Program Fund
+ * at Community Foundation Silicon Valley.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -33,10 +33,10 @@
 
 /*
  * This software was first released in 2009 by Lawrence Stewart as part of the
- * NewTCP research project at Swinburne University's Centre for Advanced
- * Internet Architectures, Melbourne, Australia, which was made possible in part
- * by a grant from the Cisco University Research Program Fund at Community
- * Foundation Silicon Valley. More details are available at:
+ * NewTCP research project at Swinburne University of Technology's Centre for
+ * Advanced Internet Architectures, Melbourne, Australia, which was made
+ * possible in part by a grant from the Cisco University Research Program Fund
+ * at Community Foundation Silicon Valley. More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/netinet/cc/cc_newreno.c
==============================================================================
--- head/sys/netinet/cc/cc_newreno.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/cc/cc_newreno.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -8,9 +8,9 @@
  * All rights reserved.
  *
  * This software was developed at the Centre for Advanced Internet
- * Architectures, Swinburne University, by Lawrence Stewart, James Healy and
- * David Hayes, made possible in part by a grant from the Cisco University
- * Research Program Fund at Community Foundation Silicon Valley.
+ * Architectures, Swinburne University of Technology, by Lawrence Stewart, James
+ * Healy and David Hayes, made possible in part by a grant from the Cisco
+ * University Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,
@@ -40,10 +40,11 @@
 
 /*
  * This software was first released in 2007 by James Healy and Lawrence Stewart
- * whilst working on the NewTCP research project at Swinburne University's
- * Centre for Advanced Internet Architectures, Melbourne, Australia, which was
- * made possible in part by a grant from the Cisco University Research Program
- * Fund at Community Foundation Silicon Valley. More details are available at:
+ * whilst working on the NewTCP research project at Swinburne University of
+ * Technology's Centre for Advanced Internet Architectures, Melbourne,
+ * Australia, which was made possible in part by a grant from the Cisco
+ * University Research Program Fund at Community Foundation Silicon Valley.
+ * More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/netinet/cc/cc_vegas.c
==============================================================================
--- head/sys/netinet/cc/cc_vegas.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/cc/cc_vegas.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -6,9 +6,9 @@
  * All rights reserved.
  *
  * This software was developed at the Centre for Advanced Internet
- * Architectures, Swinburne University, by David Hayes and Lawrence Stewart,
- * made possible in part by a grant from the Cisco University Research Program
- * Fund at Community Foundation Silicon Valley.
+ * Architectures, Swinburne University of Technology, by David Hayes and
+ * Lawrence Stewart, made possible in part by a grant from the Cisco University
+ * Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced Internet
  * Architectures, Swinburne University of Technology, Melbourne, Australia by
@@ -46,10 +46,10 @@
  * the original paper.
  *
  * Originally released as part of the NewTCP research project at Swinburne
- * University's Centre for Advanced Internet Architectures, Melbourne,
- * Australia, which was made possible in part by a grant from the Cisco
- * University Research Program Fund at Community Foundation Silicon Valley. More
- * details are available at:
+ * University of Technology's Centre for Advanced Internet Architectures,
+ * Melbourne, Australia, which was made possible in part by a grant from the
+ * Cisco University Research Program Fund at Community Foundation Silicon
+ * Valley. More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/netinet/khelp/h_ertt.c
==============================================================================
--- head/sys/netinet/khelp/h_ertt.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/khelp/h_ertt.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -6,9 +6,9 @@
  * All rights reserved.
  *
  * This software was developed at the Centre for Advanced Internet
- * Architectures, Swinburne University, by David Hayes, made possible in part by
- * a grant from the Cisco University Research Program Fund at Community
- * Foundation Silicon Valley.
+ * Architectures, Swinburne University of Technology, by David Hayes, made
+ * possible in part by a grant from the Cisco University Research Program Fund
+ * at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,

Modified: head/sys/netinet/khelp/h_ertt.h
==============================================================================
--- head/sys/netinet/khelp/h_ertt.h	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/khelp/h_ertt.h	Tue Apr 12 08:13:18 2011	(r220560)
@@ -5,9 +5,9 @@
  * All rights reserved.
  *
  * This software was developed at the Centre for Advanced Internet
- * Architectures, Swinburne University, by David Hayes, made possible in part by
- * a grant from the Cisco University Research Program Fund at Community
- * Foundation Silicon Valley.
+ * Architectures, Swinburne University of Technology, by David Hayes, made
+ * possible in part by a grant from the Cisco University Research Program Fund
+ * at Community Foundation Silicon Valley.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,12 +41,12 @@
  * "struct ertt".
  *
  * This software was first released in 2010 by David Hayes and Lawrence Stewart
- * whilst working on the NewTCP research project at Swinburne University's
- * Centre for Advanced Internet Architectures, Melbourne, Australia, which was
- * made possible in part by a grant from the Cisco University Research Program
- * Fund at Community Foundation Silicon Valley. Testing and development was
- * further assisted by a grant from the FreeBSD Foundation. More details are
- * available at:
+ * whilst working on the NewTCP research project at Swinburne University of
+ * Technology's Centre for Advanced Internet Architectures, Melbourne,
+ * Australia, which was made possible in part by a grant from the Cisco
+ * University Research Program Fund at Community Foundation Silicon Valley.
+ * Testing and development was further assisted by a grant from the FreeBSD
+ * Foundation. More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/netinet/siftr.c
==============================================================================
--- head/sys/netinet/siftr.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/siftr.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -38,10 +38,11 @@
  * for experimental, debugging and performance analysis purposes.
  *
  * SIFTR was first released in 2007 by James Healy and Lawrence Stewart whilst
- * working on the NewTCP research project at Swinburne University's Centre for
- * Advanced Internet Architectures, Melbourne, Australia, which was made
- * possible in part by a grant from the Cisco University Research Program Fund
- * at Community Foundation Silicon Valley. More details are available at:
+ * working on the NewTCP research project at Swinburne University of
+ * Technology's Centre for Advanced Internet Architectures, Melbourne,
+ * Australia, which was made possible in part by a grant from the Cisco
+ * University Research Program Fund at Community Foundation Silicon Valley.
+ * More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  *
  * Work on SIFTR v1.2.x was sponsored by the FreeBSD Foundation as part of

Modified: head/sys/netinet/tcp_input.c
==============================================================================
--- head/sys/netinet/tcp_input.c	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/netinet/tcp_input.c	Tue Apr 12 08:13:18 2011	(r220560)
@@ -8,9 +8,9 @@
  * All rights reserved.
  *
  * Portions of this software were developed at the Centre for Advanced Internet
- * Architectures, Swinburne University, by Lawrence Stewart, James Healy and
- * David Hayes, made possible in part by a grant from the Cisco University
- * Research Program Fund at Community Foundation Silicon Valley.
+ * Architectures, Swinburne University of Technology, by Lawrence Stewart,
+ * James Healy and David Hayes, made possible in part by a grant from the Cisco
+ * University Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,

Modified: head/sys/sys/hhook.h
==============================================================================
--- head/sys/sys/hhook.h	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/sys/hhook.h	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,9 +4,9 @@
  * All rights reserved.
  *
  * This software was developed by Lawrence Stewart while studying at the Centre
- * for Advanced Internet Architectures, Swinburne University, made possible in
- * part by grants from the FreeBSD Foundation and Cisco University Research
- * Program Fund at Community Foundation Silicon Valley.
+ * for Advanced Internet Architectures, Swinburne University of Technology, made
+ * possible in part by grants from the FreeBSD Foundation and Cisco University
+ * Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,
@@ -39,10 +39,10 @@
 /*
  * A KPI modelled on the pfil framework for instantiating helper hook points
  * within the kernel for use by Khelp modules. Originally released as part of
- * the NewTCP research project at Swinburne University's Centre for Advanced
- * Internet Architectures, Melbourne, Australia, which was made possible in part
- * by a grant from the Cisco University Research Program Fund at Community
- * Foundation Silicon Valley. More details are available at:
+ * the NewTCP research project at Swinburne University of Technology's Centre
+ * for Advanced Internet Architectures, Melbourne, Australia, which was made
+ * possible in part by a grant from the Cisco University Research Program Fund
+ * at Community Foundation Silicon Valley. More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/sys/khelp.h
==============================================================================
--- head/sys/sys/khelp.h	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/sys/khelp.h	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,9 +4,9 @@
  * All rights reserved.
  *
  * This software was developed by Lawrence Stewart while studying at the Centre
- * for Advanced Internet Architectures, Swinburne University, made possible in
- * part by grants from the FreeBSD Foundation and Cisco University Research
- * Program Fund at Community Foundation Silicon Valley.
+ * for Advanced Internet Architectures, Swinburne University of Technology, made
+ * possible in part by grants from the FreeBSD Foundation and Cisco University
+ * Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,
@@ -38,11 +38,11 @@
 
 /*
  * A KPI for managing kernel helper modules which perform useful functionality
- * within the kernel. Originally released as part of the NewTCP research
- * project at Swinburne University's Centre for Advanced Internet Architectures,
- * Melbourne, Australia, which was made possible in part by a grant from the
- * Cisco University Research Program Fund at Community Foundation Silicon
- * Valley. More details are available at:
+ * within the kernel. Originally released as part of the NewTCP research project
+ * at Swinburne University of Technology's Centre for Advanced Internet
+ * Architectures, Melbourne, Australia, which was made possible in part by a
+ * grant from the Cisco University Research Program Fund at Community Foundation
+ * Silicon Valley. More details are available at:
  *   http://caia.swin.edu.au/urp/newtcp/
  */
 

Modified: head/sys/sys/module_khelp.h
==============================================================================
--- head/sys/sys/module_khelp.h	Tue Apr 12 08:10:25 2011	(r220559)
+++ head/sys/sys/module_khelp.h	Tue Apr 12 08:13:18 2011	(r220560)
@@ -4,9 +4,9 @@
  * All rights reserved.
  *
  * This software was developed by Lawrence Stewart while studying at the Centre
- * for Advanced Internet Architectures, Swinburne University, made possible in
- * part by grants from the FreeBSD Foundation and Cisco University Research
- * Program Fund at Community Foundation Silicon Valley.
+ * for Advanced Internet Architectures, Swinburne University of Technology, made
+ * possible in part by grants from the FreeBSD Foundation and Cisco University
+ * Research Program Fund at Community Foundation Silicon Valley.
  *
  * Portions of this software were developed at the Centre for Advanced
  * Internet Architectures, Swinburne University of Technology, Melbourne,

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 09:55:24 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9B2E8106566C;
	Tue, 12 Apr 2011 09:55:24 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8DA808FC13;
	Tue, 12 Apr 2011 09:55:24 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3C9tOAa017244;
	Tue, 12 Apr 2011 09:55:24 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3C9tOAA017241;
	Tue, 12 Apr 2011 09:55:24 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104120955.p3C9tOAA017241@svn.freebsd.org>
From: Alexander Motin 
Date: Tue, 12 Apr 2011 09:55:24 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220563 - head/sys/dev/ata
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 09:55:24 -0000

Author: mav
Date: Tue Apr 12 09:55:24 2011
New Revision: 220563
URL: http://svn.freebsd.org/changeset/base/220563

Log:
  Implement automatic SCSI sense fetching for ata(4) in ATA_CAM mode.
  While it could be successfully done by CAM error recovery code, I was
  told by several people that it is also a SIM obligation.

Modified:
  head/sys/dev/ata/ata-all.c
  head/sys/dev/ata/ata-all.h

Modified: head/sys/dev/ata/ata-all.c
==============================================================================
--- head/sys/dev/ata/ata-all.c	Tue Apr 12 09:36:38 2011	(r220562)
+++ head/sys/dev/ata/ata-all.c	Tue Apr 12 09:55:24 2011	(r220563)
@@ -1475,6 +1475,72 @@ ata_cam_begin_transaction(device_t dev, 
 	}
 }
 
+static void
+ata_cam_request_sense(device_t dev, struct ata_request *request)
+{
+	struct ata_channel *ch = device_get_softc(dev);
+	union ccb *ccb = request->ccb;
+
+	ch->requestsense = 1;
+
+	bzero(request, sizeof(&request));
+	request->dev = NULL;
+	request->parent = dev;
+	request->unit = ccb->ccb_h.target_id;
+	request->data = (void *)&ccb->csio.sense_data;
+	request->bytecount = ccb->csio.sense_len;
+	request->u.atapi.ccb[0] = ATAPI_REQUEST_SENSE;
+	request->u.atapi.ccb[4] = ccb->csio.sense_len;
+	request->flags |= ATA_R_ATAPI;
+	if (ch->curr[ccb->ccb_h.target_id].atapi == 16)
+		request->flags |= ATA_R_ATAPI16;
+	if (ch->curr[ccb->ccb_h.target_id].mode >= ATA_DMA)
+		request->flags |= ATA_R_DMA;
+	request->flags |= ATA_R_READ;
+	request->transfersize = min(request->bytecount,
+	    ch->curr[ccb->ccb_h.target_id].bytecount);
+	request->retries = 0;
+	request->timeout = (ccb->ccb_h.timeout + 999) / 1000;
+	callout_init_mtx(&request->callout, &ch->state_mtx, CALLOUT_RETURNUNLOCKED);
+	request->ccb = ccb;
+
+	ch->running = request;
+	ch->state = ATA_ACTIVE;
+	if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
+		ch->running = NULL;
+		ch->state = ATA_IDLE;
+		ata_cam_end_transaction(dev, request);
+		return;
+	}
+}
+
+static void
+ata_cam_process_sense(device_t dev, struct ata_request *request)
+{
+	struct ata_channel *ch = device_get_softc(dev);
+	union ccb *ccb = request->ccb;
+	int fatalerr = 0;
+
+	ch->requestsense = 0;
+
+	if (request->flags & ATA_R_TIMEOUT)
+		fatalerr = 1;
+	if ((request->flags & ATA_R_TIMEOUT) == 0 &&
+	    (request->status & ATA_S_ERROR) == 0 &&
+	    request->result == 0) {
+		ccb->ccb_h.status |= CAM_AUTOSNS_VALID;
+	} else {
+		ccb->ccb_h.status &= ~CAM_STATUS_MASK;
+		ccb->ccb_h.status |= CAM_AUTOSENSE_FAIL;
+	}
+
+	ata_free_request(request);
+	xpt_done(ccb);
+	/* Do error recovery if needed. */
+	if (fatalerr)
+		ata_reinit(dev);
+}
+
 void
 ata_cam_end_transaction(device_t dev, struct ata_request *request)
 {
@@ -1482,6 +1548,11 @@ ata_cam_end_transaction(device_t dev, st
 	union ccb *ccb = request->ccb;
 	int fatalerr = 0;
 
+	if (ch->requestsense) {
+		ata_cam_process_sense(dev, request);
+		return;
+	}
+
 	ccb->ccb_h.status &= ~CAM_STATUS_MASK;
 	if (request->flags & ATA_R_TIMEOUT) {
 		xpt_freeze_simq(ch->sim, 1);
@@ -1531,8 +1602,13 @@ ata_cam_end_transaction(device_t dev, st
 			    ccb->csio.dxfer_len - request->donecount;
 		}
 	}
-	ata_free_request(request);
-	xpt_done(ccb);
+	if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR &&
+	    (ccb->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0)
+		ata_cam_request_sense(dev, request);
+	else {
+		ata_free_request(request);
+		xpt_done(ccb);
+	}
 	/* Do error recovery if needed. */
 	if (fatalerr)
 		ata_reinit(dev);

Modified: head/sys/dev/ata/ata-all.h
==============================================================================
--- head/sys/dev/ata/ata-all.h	Tue Apr 12 09:36:38 2011	(r220562)
+++ head/sys/dev/ata/ata-all.h	Tue Apr 12 09:55:24 2011	(r220563)
@@ -585,8 +585,9 @@ struct ata_channel {
 #ifdef ATA_CAM
 	struct cam_sim		*sim;
 	struct cam_path		*path;
-	struct ata_cam_device	user[16];       /* User-specified settings */                             
-	struct ata_cam_device	curr[16];       /* Current settings */                                    
+	struct ata_cam_device	user[16];       /* User-specified settings */
+	struct ata_cam_device	curr[16];       /* Current settings */
+	int			requestsense;	/* CCB waiting for SENSE. */
 #endif
 	struct callout		poll_callout;	/* Periodic status poll. */
 };

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 11:25:00 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2EC56106564A;
	Tue, 12 Apr 2011 11:25:00 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1C9A88FC0A;
	Tue, 12 Apr 2011 11:25:00 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CBP08u022785;
	Tue, 12 Apr 2011 11:25:00 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CBOxw7022782;
	Tue, 12 Apr 2011 11:24:59 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104121124.p3CBOxw7022782@svn.freebsd.org>
From: Alexander Motin 
Date: Tue, 12 Apr 2011 11:24:59 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220565 - head/sys/dev/ahci
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 11:25:00 -0000

Author: mav
Date: Tue Apr 12 11:24:59 2011
New Revision: 220565
URL: http://svn.freebsd.org/changeset/base/220565

Log:
  Implement automatic SCSI sense fetching for ahci(4).

Modified:
  head/sys/dev/ahci/ahci.c
  head/sys/dev/ahci/ahci.h

Modified: head/sys/dev/ahci/ahci.c
==============================================================================
--- head/sys/dev/ahci/ahci.c	Tue Apr 12 11:17:46 2011	(r220564)
+++ head/sys/dev/ahci/ahci.c	Tue Apr 12 11:24:59 2011	(r220565)
@@ -91,8 +91,9 @@ static int ahci_sata_connect(struct ahci
 static int ahci_sata_phy_reset(device_t dev);
 static int ahci_wait_ready(device_t dev, int t);
 
-static void ahci_issue_read_log(device_t dev);
+static void ahci_issue_recovery(device_t dev);
 static void ahci_process_read_log(device_t dev, union ccb *ccb);
+static void ahci_process_request_sense(device_t dev, union ccb *ccb);
 
 static void ahciaction(struct cam_sim *sim, union ccb *ccb);
 static void ahcipoll(struct cam_sim *sim);
@@ -267,6 +268,12 @@ static struct {
 	{0x00000000, 0x00, NULL,		0}
 };
 
+#define recovery_type		spriv_field0
+#define RECOVERY_NONE		0
+#define RECOVERY_READ_LOG	1
+#define RECOVERY_REQUEST_SENSE	2
+#define recovery_slot		spriv_field1
+
 static int
 ahci_probe(device_t dev)
 {
@@ -1465,7 +1472,7 @@ ahci_ch_intr(void *data)
 		 * We can't reinit port if there are some other
 		 * commands active, use resume to complete them.
 		 */
-		if (ch->rslots != 0) 
+		if (ch->rslots != 0 && !ch->recoverycmd)
 			ATA_OUTL(ch->r_mem, AHCI_P_FBS, AHCI_P_FBS_EN | AHCI_P_FBS_DEC);
 	}
 	/* Process NOTIFY events */
@@ -1937,7 +1944,7 @@ ahci_end_transaction(struct ahci_slot *s
 	if (et != AHCI_ERR_NONE)
 		ch->eslots |= (1 << slot->slot);
 	/* In case of error, freeze device for proper recovery. */
-	if ((et != AHCI_ERR_NONE) && (!ch->readlog) &&
+	if ((et != AHCI_ERR_NONE) && (!ch->recoverycmd) &&
 	    !(ccb->ccb_h.status & CAM_DEV_QFRZN)) {
 		xpt_freeze_devq(ccb->ccb_h.path, 1);
 		ccb->ccb_h.status |= CAM_DEV_QFRZN;
@@ -1968,7 +1975,7 @@ ahci_end_transaction(struct ahci_slot *s
 		break;
 	case AHCI_ERR_SATA:
 		ch->fatalerr = 1;
-		if (!ch->readlog) {
+		if (!ch->recoverycmd) {
 			xpt_freeze_simq(ch->sim, 1);
 			ccb->ccb_h.status &= ~CAM_STATUS_MASK;
 			ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
@@ -1976,7 +1983,7 @@ ahci_end_transaction(struct ahci_slot *s
 		ccb->ccb_h.status |= CAM_UNCOR_PARITY;
 		break;
 	case AHCI_ERR_TIMEOUT:
-		if (!ch->readlog) {
+		if (!ch->recoverycmd) {
 			xpt_freeze_simq(ch->sim, 1);
 			ccb->ccb_h.status &= ~CAM_STATUS_MASK;
 			ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
@@ -2019,10 +2026,15 @@ ahci_end_transaction(struct ahci_slot *s
 		return;
 	}
 	/* If it was our READ LOG command - process it. */
-	if (ch->readlog) {
+	if (ccb->ccb_h.recovery_type == RECOVERY_READ_LOG) {
 		ahci_process_read_log(dev, ccb);
-	/* If it was NCQ command error, put result on hold. */
-	} else if (et == AHCI_ERR_NCQ) {
+	/* If it was our REQUEST SENSE command - process it. */
+	} else if (ccb->ccb_h.recovery_type == RECOVERY_REQUEST_SENSE) {
+		ahci_process_request_sense(dev, ccb);
+	/* If it was NCQ or ATAPI command error, put result on hold. */
+	} else if (et == AHCI_ERR_NCQ ||
+	    ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR &&
+	     (ccb->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0)) {
 		ch->hold[slot->slot] = ccb;
 		ch->numhslots++;
 	} else
@@ -2046,8 +2058,8 @@ ahci_end_transaction(struct ahci_slot *s
 				ahci_start(dev, 1);
 			}
 			/* if there commands on hold, we can do READ LOG. */
-			if (!ch->readlog && ch->numhslots)
-				ahci_issue_read_log(dev);
+			if (!ch->recoverycmd && ch->numhslots)
+				ahci_issue_recovery(dev);
 		}
 	/* If all the rest of commands are in timeout - give them chance. */
 	} else if ((ch->rslots & ~ch->toslots) == 0 &&
@@ -2062,14 +2074,15 @@ ahci_end_transaction(struct ahci_slot *s
 }
 
 static void
-ahci_issue_read_log(device_t dev)
+ahci_issue_recovery(device_t dev)
 {
 	struct ahci_channel *ch = device_get_softc(dev);
 	union ccb *ccb;
 	struct ccb_ataio *ataio;
+	struct ccb_scsiio *csio;
 	int i;
 
-	ch->readlog = 1;
+	ch->recoverycmd = 1;
 	/* Find some holden command. */
 	for (i = 0; i < ch->numslots; i++) {
 		if (ch->hold[i])
@@ -2081,26 +2094,45 @@ ahci_issue_read_log(device_t dev)
 		return; /* XXX */
 	}
 	ccb->ccb_h = ch->hold[i]->ccb_h;	/* Reuse old header. */
-	ccb->ccb_h.func_code = XPT_ATA_IO;
-	ccb->ccb_h.flags = CAM_DIR_IN;
-	ccb->ccb_h.timeout = 1000;	/* 1s should be enough. */
-	ataio = &ccb->ataio;
-	ataio->data_ptr = malloc(512, M_AHCI, M_NOWAIT);
-	if (ataio->data_ptr == NULL) {
-		xpt_free_ccb(ccb);
-		device_printf(dev, "Unable allocate memory for READ LOG command");
-		return; /* XXX */
+	if (ccb->ccb_h.func_code == XPT_ATA_IO) {
+		/* READ LOG */
+		ccb->ccb_h.recovery_type = RECOVERY_READ_LOG;
+		ccb->ccb_h.func_code = XPT_ATA_IO;
+		ccb->ccb_h.flags = CAM_DIR_IN;
+		ccb->ccb_h.timeout = 1000;	/* 1s should be enough. */
+		ataio = &ccb->ataio;
+		ataio->data_ptr = malloc(512, M_AHCI, M_NOWAIT);
+		if (ataio->data_ptr == NULL) {
+			xpt_free_ccb(ccb);
+			device_printf(dev, "Unable allocate memory for READ LOG command");
+			return; /* XXX */
+		}
+		ataio->dxfer_len = 512;
+		bzero(&ataio->cmd, sizeof(ataio->cmd));
+		ataio->cmd.flags = CAM_ATAIO_48BIT;
+		ataio->cmd.command = 0x2F;	/* READ LOG EXT */
+		ataio->cmd.sector_count = 1;
+		ataio->cmd.sector_count_exp = 0;
+		ataio->cmd.lba_low = 0x10;
+		ataio->cmd.lba_mid = 0;
+		ataio->cmd.lba_mid_exp = 0;
+	} else {
+		/* REQUEST SENSE */
+		ccb->ccb_h.recovery_type = RECOVERY_REQUEST_SENSE;
+		ccb->ccb_h.recovery_slot = i;
+		ccb->ccb_h.func_code = XPT_SCSI_IO;
+		ccb->ccb_h.flags = CAM_DIR_IN;
+		ccb->ccb_h.status = 0;
+		ccb->ccb_h.timeout = 1000;	/* 1s should be enough. */
+		csio = &ccb->csio;
+		csio->data_ptr = (void *)&ch->hold[i]->csio.sense_data;
+		csio->dxfer_len = ch->hold[i]->csio.sense_len;
+		csio->cdb_len = 6;
+		bzero(&csio->cdb_io, sizeof(csio->cdb_io));
+		csio->cdb_io.cdb_bytes[0] = 0x03;
+		csio->cdb_io.cdb_bytes[4] = csio->dxfer_len;
 	}
-	ataio->dxfer_len = 512;
-	bzero(&ataio->cmd, sizeof(ataio->cmd));
-	ataio->cmd.flags = CAM_ATAIO_48BIT;
-	ataio->cmd.command = 0x2F;	/* READ LOG EXT */
-	ataio->cmd.sector_count = 1;
-	ataio->cmd.sector_count_exp = 0;
-	ataio->cmd.lba_low = 0x10;
-	ataio->cmd.lba_mid = 0;
-	ataio->cmd.lba_mid_exp = 0;
-	/* Freeze SIM while doing READ LOG EXT. */
+	/* Freeze SIM while doing recovery. */
 	xpt_freeze_simq(ch->sim, 1);
 	ahci_begin_transaction(dev, ccb);
 }
@@ -2113,7 +2145,7 @@ ahci_process_read_log(device_t dev, unio
 	struct ata_res *res;
 	int i;
 
-	ch->readlog = 0;
+	ch->recoverycmd = 0;
 
 	data = ccb->ataio.data_ptr;
 	if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP &&
@@ -2121,6 +2153,8 @@ ahci_process_read_log(device_t dev, unio
 		for (i = 0; i < ch->numslots; i++) {
 			if (!ch->hold[i])
 				continue;
+			if (ch->hold[i]->ccb_h.func_code != XPT_ATA_IO)
+				continue;
 			if ((data[0] & 0x1F) == i) {
 				res = &ch->hold[i]->ataio.res;
 				res->status = data[2];
@@ -2151,6 +2185,8 @@ ahci_process_read_log(device_t dev, unio
 		for (i = 0; i < ch->numslots; i++) {
 			if (!ch->hold[i])
 				continue;
+			if (ch->hold[i]->ccb_h.func_code != XPT_ATA_IO)
+				continue;
 			xpt_done(ch->hold[i]);
 			ch->hold[i] = NULL;
 			ch->numhslots--;
@@ -2162,6 +2198,28 @@ ahci_process_read_log(device_t dev, unio
 }
 
 static void
+ahci_process_request_sense(device_t dev, union ccb *ccb)
+{
+	struct ahci_channel *ch = device_get_softc(dev);
+	int i;
+
+	ch->recoverycmd = 0;
+
+	i = ccb->ccb_h.recovery_slot;
+	if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
+		ch->hold[i]->ccb_h.status |= CAM_AUTOSNS_VALID;
+	} else {
+		ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK;
+		ch->hold[i]->ccb_h.status |= CAM_AUTOSENSE_FAIL;
+	}
+	xpt_done(ch->hold[i]);
+	ch->hold[i] = NULL;
+	ch->numhslots--;
+	xpt_free_ccb(ccb);
+	xpt_release_simq(ch->sim, TRUE);
+}
+
+static void
 ahci_start(device_t dev, int fbs)
 {
 	struct ahci_channel *ch = device_get_softc(dev);
@@ -2519,6 +2577,7 @@ ahciaction(struct cam_sim *sim, union cc
 			ccb->ccb_h.status = CAM_SEL_TIMEOUT;
 			break;
 		}
+		ccb->ccb_h.recovery_type = RECOVERY_NONE;
 		/* Check for command collision. */
 		if (ahci_check_collision(dev, ccb)) {
 			/* Freeze command. */

Modified: head/sys/dev/ahci/ahci.h
==============================================================================
--- head/sys/dev/ahci/ahci.h	Tue Apr 12 11:17:46 2011	(r220564)
+++ head/sys/dev/ahci/ahci.h	Tue Apr 12 11:24:59 2011	(r220565)
@@ -408,7 +408,7 @@ struct ahci_channel {
 	int			numtslots;	/* Number of tagged slots */
 	int			numtslotspd[16];/* Number of tagged slots per dev */
 	int			numhslots;	/* Number of holden slots */
-	int			readlog;	/* Our READ LOG active */
+	int			recoverycmd;	/* Our READ LOG active */
 	int			fatalerr;	/* Fatal error happend */
 	int			lastslot;	/* Last used slot */
 	int			taggedtarget;	/* Last tagged target */

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 11:29:16 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 116701065678;
	Tue, 12 Apr 2011 11:29:16 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F384E8FC0A;
	Tue, 12 Apr 2011 11:29:15 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CBTFeT022912;
	Tue, 12 Apr 2011 11:29:15 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CBTFV2022909;
	Tue, 12 Apr 2011 11:29:15 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104121129.p3CBTFV2022909@svn.freebsd.org>
From: Alexander Motin 
Date: Tue, 12 Apr 2011 11:29:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220566 - head/sys/dev/siis
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 11:29:16 -0000

Author: mav
Date: Tue Apr 12 11:29:15 2011
New Revision: 220566
URL: http://svn.freebsd.org/changeset/base/220566

Log:
  Implement automatic SCSI sense fetching for siis(4).
  
  Fix device freeze leak on recovery request (READ LOG, REQUEST SENSE)
  failure.

Modified:
  head/sys/dev/siis/siis.c
  head/sys/dev/siis/siis.h

Modified: head/sys/dev/siis/siis.c
==============================================================================
--- head/sys/dev/siis/siis.c	Tue Apr 12 11:24:59 2011	(r220565)
+++ head/sys/dev/siis/siis.c	Tue Apr 12 11:29:15 2011	(r220566)
@@ -84,8 +84,9 @@ static int siis_wait_ready(device_t dev,
 
 static int siis_sata_connect(struct siis_channel *ch);
 
-static void siis_issue_read_log(device_t dev);
+static void siis_issue_recovery(device_t dev);
 static void siis_process_read_log(device_t dev, union ccb *ccb);
+static void siis_process_request_sense(device_t dev, union ccb *ccb);
 
 static void siisaction(struct cam_sim *sim, union ccb *ccb);
 static void siispoll(struct cam_sim *sim);
@@ -110,6 +111,12 @@ static struct {
 	{0,		NULL,		0,	0}
 };
 
+#define recovery_type		spriv_field0
+#define RECOVERY_NONE		0
+#define RECOVERY_READ_LOG	1
+#define RECOVERY_REQUEST_SENSE	2
+#define recovery_slot		spriv_field1
+
 static int
 siis_probe(device_t dev)
 {
@@ -873,7 +880,7 @@ siis_ch_intr(void *data)
 //    __func__, sstatus, istatus, ch->rslots, estatus, ccs, port,
 //    ATA_INL(ch->r_mem, SIIS_P_SERR));
 
-		if (!ch->readlog && !ch->recovery) {
+		if (!ch->recoverycmd && !ch->recovery) {
 			xpt_freeze_simq(ch->sim, ch->numrslots);
 			ch->recovery = 1;
 		}
@@ -914,7 +921,7 @@ siis_ch_intr(void *data)
 			 * We can't reinit port if there are some other
 			 * commands active, use resume to complete them.
 			 */
-			if (ch->rslots != 0)
+			if (ch->rslots != 0 && !ch->recoverycmd)
 				ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_RESUME);
 		} else {
 			if (estatus == SIIS_P_CMDERR_SENDFIS ||
@@ -1021,7 +1028,7 @@ siis_dmasetprd(void *arg, bus_dma_segmen
 	mtx_assert(&ch->mtx, MA_OWNED);
 	if (error) {
 		device_printf(slot->dev, "DMA load error\n");
-		if (!ch->readlog)
+		if (!ch->recoverycmd)
 			xpt_freeze_simq(ch->sim, 1);
 		siis_end_transaction(slot, SIIS_ERR_INVALID);
 		return;
@@ -1101,7 +1108,7 @@ siis_execute_transaction(struct siis_slo
 	/* Setup the FIS for this request */
 	if (!siis_setup_fis(dev, ctp, ccb, slot->slot)) {
 		device_printf(ch->dev, "Setting up SATA FIS failed\n");
-		if (!ch->readlog)
+		if (!ch->recoverycmd)
 			xpt_freeze_simq(ch->sim, 1);
 		siis_end_transaction(slot, SIIS_ERR_INVALID);
 		return;
@@ -1129,7 +1136,7 @@ siis_process_timeout(device_t dev)
 	int i;
 
 	mtx_assert(&ch->mtx, MA_OWNED);
-	if (!ch->readlog && !ch->recovery) {
+	if (!ch->recoverycmd && !ch->recovery) {
 		xpt_freeze_simq(ch->sim, ch->numrslots);
 		ch->recovery = 1;
 	}
@@ -1251,7 +1258,7 @@ siis_end_transaction(struct siis_slot *s
 		ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
 	}
 	/* In case of error, freeze device for proper recovery. */
-	if (et != SIIS_ERR_NONE &&
+	if (et != SIIS_ERR_NONE && (!ch->recoverycmd) &&
 	    !(ccb->ccb_h.status & CAM_DEV_QFRZN)) {
 		xpt_freeze_devq(ccb->ccb_h.path, 1);
 		ccb->ccb_h.status |= CAM_DEV_QFRZN;
@@ -1310,10 +1317,15 @@ siis_end_transaction(struct siis_slot *s
 			xpt_release_simq(ch->sim, TRUE);
 	}
 	/* If it was our READ LOG command - process it. */
-	if (ch->readlog) {
+	if (ccb->ccb_h.recovery_type == RECOVERY_READ_LOG) {
 		siis_process_read_log(dev, ccb);
-	/* If it was NCQ command error, put result on hold. */
-	} else if (et == SIIS_ERR_NCQ) {
+	/* If it was our REQUEST SENSE command - process it. */
+	} else if (ccb->ccb_h.recovery_type == RECOVERY_REQUEST_SENSE) {
+		siis_process_request_sense(dev, ccb);
+	/* If it was NCQ or ATAPI command error, put result on hold. */
+	} else if (et == SIIS_ERR_NCQ ||
+	    ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR &&
+	     (ccb->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0)) {
 		ch->hold[slot->slot] = ccb;
 		ch->numhslots++;
 	} else
@@ -1334,9 +1346,9 @@ siis_end_transaction(struct siis_slot *s
 			/* if we have slots in error, we can reinit port. */
 			if (ch->eslots != 0)
 				siis_portinit(dev);
-			/* if there commands on hold, we can do READ LOG. */
-			if (!ch->readlog && ch->numhslots)
-				siis_issue_read_log(dev);
+			/* if there commands on hold, we can do recovery. */
+			if (!ch->recoverycmd && ch->numhslots)
+				siis_issue_recovery(dev);
 		}
 	/* If all the reset of commands are in timeout - abort them. */
 	} else if ((ch->rslots & ~ch->toslots) == 0 &&
@@ -1345,11 +1357,12 @@ siis_end_transaction(struct siis_slot *s
 }
 
 static void
-siis_issue_read_log(device_t dev)
+siis_issue_recovery(device_t dev)
 {
 	struct siis_channel *ch = device_get_softc(dev);
 	union ccb *ccb;
 	struct ccb_ataio *ataio;
+	struct ccb_scsiio *csio;
 	int i;
 
 	/* Find some holden command. */
@@ -1359,32 +1372,51 @@ siis_issue_read_log(device_t dev)
 	}
 	if (i == SIIS_MAX_SLOTS)
 		return;
-	ch->readlog = 1;
+	ch->recoverycmd = 1;
 	ccb = xpt_alloc_ccb_nowait();
 	if (ccb == NULL) {
 		device_printf(dev, "Unable allocate READ LOG command");
 		return; /* XXX */
 	}
 	ccb->ccb_h = ch->hold[i]->ccb_h;	/* Reuse old header. */
-	ccb->ccb_h.func_code = XPT_ATA_IO;
-	ccb->ccb_h.flags = CAM_DIR_IN;
-	ccb->ccb_h.timeout = 1000;	/* 1s should be enough. */
-	ataio = &ccb->ataio;
-	ataio->data_ptr = malloc(512, M_SIIS, M_NOWAIT);
-	if (ataio->data_ptr == NULL) {
-		xpt_free_ccb(ccb);
-		device_printf(dev, "Unable allocate memory for READ LOG command");
-		return; /* XXX */
+	if (ccb->ccb_h.func_code == XPT_ATA_IO) {
+		/* READ LOG */
+		ccb->ccb_h.recovery_type = RECOVERY_READ_LOG;
+		ccb->ccb_h.func_code = XPT_ATA_IO;
+		ccb->ccb_h.flags = CAM_DIR_IN;
+		ccb->ccb_h.timeout = 1000;	/* 1s should be enough. */
+		ataio = &ccb->ataio;
+		ataio->data_ptr = malloc(512, M_SIIS, M_NOWAIT);
+		if (ataio->data_ptr == NULL) {
+			xpt_free_ccb(ccb);
+			device_printf(dev, "Unable allocate memory for READ LOG command");
+			return; /* XXX */
+		}
+		ataio->dxfer_len = 512;
+		bzero(&ataio->cmd, sizeof(ataio->cmd));
+		ataio->cmd.flags = CAM_ATAIO_48BIT;
+		ataio->cmd.command = 0x2F;	/* READ LOG EXT */
+		ataio->cmd.sector_count = 1;
+		ataio->cmd.sector_count_exp = 0;
+		ataio->cmd.lba_low = 0x10;
+		ataio->cmd.lba_mid = 0;
+		ataio->cmd.lba_mid_exp = 0;
+	} else {
+		/* REQUEST SENSE */
+		ccb->ccb_h.recovery_type = RECOVERY_REQUEST_SENSE;
+		ccb->ccb_h.recovery_slot = i;
+		ccb->ccb_h.func_code = XPT_SCSI_IO;
+		ccb->ccb_h.flags = CAM_DIR_IN;
+		ccb->ccb_h.status = 0;
+		ccb->ccb_h.timeout = 1000;	/* 1s should be enough. */
+		csio = &ccb->csio;
+		csio->data_ptr = (void *)&ch->hold[i]->csio.sense_data;
+		csio->dxfer_len = ch->hold[i]->csio.sense_len;
+		csio->cdb_len = 6;
+		bzero(&csio->cdb_io, sizeof(csio->cdb_io));
+		csio->cdb_io.cdb_bytes[0] = 0x03;
+		csio->cdb_io.cdb_bytes[4] = csio->dxfer_len;
 	}
-	ataio->dxfer_len = 512;
-	bzero(&ataio->cmd, sizeof(ataio->cmd));
-	ataio->cmd.flags = CAM_ATAIO_48BIT;
-	ataio->cmd.command = 0x2F;	/* READ LOG EXT */
-	ataio->cmd.sector_count = 1;
-	ataio->cmd.sector_count_exp = 0;
-	ataio->cmd.lba_low = 0x10;
-	ataio->cmd.lba_mid = 0;
-	ataio->cmd.lba_mid_exp = 0;
 	siis_begin_transaction(dev, ccb);
 }
 
@@ -1396,7 +1428,7 @@ siis_process_read_log(device_t dev, unio
 	struct ata_res *res;
 	int i;
 
-	ch->readlog = 0;
+	ch->recoverycmd = 0;
 	data = ccb->ataio.data_ptr;
 	if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP &&
 	    (data[0] & 0x80) == 0) {
@@ -1447,6 +1479,27 @@ siis_process_read_log(device_t dev, unio
 }
 
 static void
+siis_process_request_sense(device_t dev, union ccb *ccb)
+{
+	struct siis_channel *ch = device_get_softc(dev);
+	int i;
+
+	ch->recoverycmd = 0;
+
+	i = ccb->ccb_h.recovery_slot;
+	if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
+		ch->hold[i]->ccb_h.status |= CAM_AUTOSNS_VALID;
+	} else {
+		ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK;
+		ch->hold[i]->ccb_h.status |= CAM_AUTOSENSE_FAIL;
+	}
+	xpt_done(ch->hold[i]);
+	ch->hold[i] = NULL;
+	ch->numhslots--;
+	xpt_free_ccb(ccb);
+}
+
+static void
 siis_portinit(device_t dev)
 {
 	struct siis_channel *ch = device_get_softc(dev);
@@ -1512,7 +1565,7 @@ siis_reset(device_t dev)
 	xpt_freeze_simq(ch->sim, 1);
 	if (bootverbose)
 		device_printf(dev, "SIIS reset...\n");
-	if (!ch->readlog && !ch->recovery)
+	if (!ch->recoverycmd && !ch->recovery)
 		xpt_freeze_simq(ch->sim, ch->numrslots);
 	/* Requeue frozen command. */
 	if (ch->frozen) {
@@ -1732,6 +1785,7 @@ siisaction(struct cam_sim *sim, union cc
 			ccb->ccb_h.status = CAM_SEL_TIMEOUT;
 			break;
 		}
+		ccb->ccb_h.recovery_type = RECOVERY_NONE;
 		/* Check for command collision. */
 		if (siis_check_collision(dev, ccb)) {
 			/* Freeze command. */

Modified: head/sys/dev/siis/siis.h
==============================================================================
--- head/sys/dev/siis/siis.h	Tue Apr 12 11:24:59 2011	(r220565)
+++ head/sys/dev/siis/siis.h	Tue Apr 12 11:29:15 2011	(r220566)
@@ -388,7 +388,7 @@ struct siis_channel {
 	int			numrslots;	/* Number of running slots */
 	int			numtslots[SIIS_MAX_SLOTS]; /* Number of tagged slots */
 	int			numhslots;	/* Number of holden slots */
-	int			readlog;	/* Our READ LOG active */
+	int			recoverycmd;	/* Our READ LOG active */
 	int			fatalerr;	/* Fatal error happend */
 	int			recovery;	/* Some slots are in error */
 	union ccb		*frozen;	/* Frozen command */

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 12:39:26 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 72EE31065673;
	Tue, 12 Apr 2011 12:39:26 +0000 (UTC)
	(envelope-from nwhitehorn@freebsd.org)
Received: from adsum.doit.wisc.edu (adsum.doit.wisc.edu [144.92.197.210])
	by mx1.freebsd.org (Postfix) with ESMTP id 43AED8FC19;
	Tue, 12 Apr 2011 12:39:26 +0000 (UTC)
MIME-version: 1.0
Content-transfer-encoding: 7BIT
Content-type: text/plain; CHARSET=US-ASCII; format=flowed
Received: from avs-daemon.smtpauth1.wiscmail.wisc.edu by
	smtpauth1.wiscmail.wisc.edu
	(Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30
	2009)) id <0LJJ00N06HTP3W00@smtpauth1.wiscmail.wisc.edu>; Tue,
	12 Apr 2011 07:39:25 -0500 (CDT)
Received: from comporellon.tachypleus.net ([unknown] [76.210.65.155])
	by smtpauth1.wiscmail.wisc.edu
	(Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30
	2009))
	with ESMTPSA id <0LJJ00KQ3HTJ7400@smtpauth1.wiscmail.wisc.edu>; Tue,
	12 Apr 2011 07:39:21 -0500 (CDT)
Date: Tue, 12 Apr 2011 07:39:19 -0500
From: Nathan Whitehorn 
In-reply-to: <201104120749.p3C7nBDQ014198@svn.freebsd.org>
To: Hans Petter Selasky 
Message-id: <4DA447F7.50104@freebsd.org>
X-Spam-Report: AuthenticatedSender=yes, SenderIP=76.210.65.155
X-Spam-PmxInfo: Server=avs-10, Version=5.6.0.2009776,
	Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.4.12.123323,
	SenderIP=76.210.65.155
References: <201104120749.p3C7nBDQ014198@svn.freebsd.org>
User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15)
	Gecko/20110305 Thunderbird/3.1.9
X-Mailman-Approved-At: Tue, 12 Apr 2011 12:52:37 +0000
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220558 - in head/sys: arm/econa dev/usb/controller
 mips/atheros mips/rmi
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 12:39:26 -0000

On 04/12/11 02:49, Hans Petter Selasky wrote:
> Author: hselasky
> Date: Tue Apr 12 07:49:11 2011
> New Revision: 220558
> URL: http://svn.freebsd.org/changeset/base/220558
>
> Log:
>    We don't need to call EOWRITE4(sc, EHCI_USBINTR, 0) directly from each EHCI
>    bus driver at detach, hence ehci_detach() does exactly this since r199718.
>
>

Just so you're aware, there's also another EHCI driver in the tree at 
/sys/powerpc/ps3/ehci_ps3.c. It might also need some modifications at 
various points when you're cleaning up EHCI drivers.
-Nathan


From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 12:57:47 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1963D106566C;
	Tue, 12 Apr 2011 12:57:47 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 078218FC14;
	Tue, 12 Apr 2011 12:57:47 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CCvkBr024943;
	Tue, 12 Apr 2011 12:57:46 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CCvkOY024941;
	Tue, 12 Apr 2011 12:57:46 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <201104121257.p3CCvkOY024941@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Tue, 12 Apr 2011 12:57:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220567 - head/share/man/man7
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 12:57:47 -0000

Author: nwhitehorn
Date: Tue Apr 12 12:57:46 2011
New Revision: 220567
URL: http://svn.freebsd.org/changeset/base/220567

Log:
  Update some terminology: floppies are no longer built, and FreeBSD is not
  necessarily distributed by CVS any longer.

Modified:
  head/share/man/man7/release.7

Modified: head/share/man/man7/release.7
==============================================================================
--- head/share/man/man7/release.7	Tue Apr 12 11:29:15 2011	(r220566)
+++ head/share/man/man7/release.7	Tue Apr 12 12:57:46 2011	(r220567)
@@ -37,11 +37,12 @@ full releases of the
 .Fx
 operating system.
 All of the tools necessary to build a release are available from the
-CVS repository in
+.Fx
+source code repository in
 .Pa src/release .
 A complete release can actually be built with only a single command,
 including the creation of ISO images suitable for burning to CD-ROM,
-installation floppies, and an FTP install directory.
+memory stick images, and an FTP install directory.
 This command is aptly named
 .Dq Li "make release" .
 .Pp

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 12:58:31 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2D396106566C;
	Tue, 12 Apr 2011 12:58:31 +0000 (UTC)
	(envelope-from hselasky@freebsd.org)
Received: from swip.net (mailfe07.c2i.net [212.247.154.194])
	by mx1.freebsd.org (Postfix) with ESMTP id 542908FC16;
	Tue, 12 Apr 2011 12:58:29 +0000 (UTC)
X-Cloudmark-Score: 0.000000 []
X-Cloudmark-Analysis: v=1.1 cv=118a5bn0tGnRZbUa9ClBty6BTuM1bA5mUZqmf2RHYp4=
	c=1 sm=1 a=IU0TiZmyZPMA:10 a=QSUqwWVUwJMA:10 a=dBRESv0yCI8A:10
	a=N659UExz7-8A:10 a=CL8lFSKtTFcA:10
	a=i9M/sDlu2rpZ9XS819oYzg==:17 a=6I5d2MoRAAAA:8
	a=yGPF2y0DA6eK0P-p5tsA:9 a=pILNOxqGKmIA:10
	a=i9M/sDlu2rpZ9XS819oYzg==:117
Received: from [188.126.198.129] (account mc467741@c2i.net HELO
	laptop002.hselasky.homeunix.org)
	by mailfe07.swip.net (CommuniGate Pro SMTP 5.2.19)
	with ESMTPA id 113062455; Tue, 12 Apr 2011 14:58:28 +0200
Received-SPF: softfail receiver=mailfe07.swip.net; client-ip=188.126.198.129;
	envelope-from=hselasky@freebsd.org
From: Hans Petter Selasky 
To: Nathan Whitehorn 
Date: Tue, 12 Apr 2011 14:57:26 +0200
User-Agent: KMail/1.13.5 (FreeBSD/8.2-PRERELEASE; KDE/4.4.5; amd64; ; )
References: <201104120749.p3C7nBDQ014198@svn.freebsd.org>
	<4DA447F7.50104@freebsd.org>
In-Reply-To: <4DA447F7.50104@freebsd.org>
X-Face: *nPdTl_}RuAI6^PVpA02T?$%Xa^>@hE0uyUIoiha$pC:9TVgl.Oq, NwSZ4V"|LR.+tj}g5
	%V,x^qOs~mnU3]Gn; cQLv&.N>TrxmSFf+p6(30a/{)KUU!s}w\IhQBj}[g}bj0I3^glmC(
	:AuzV9:.hESm-x4h240C`9=w
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="windows-1252"
Content-Transfer-Encoding: 7bit
Message-Id: <201104121457.26348.hselasky@freebsd.org>
Cc: "svn-src-head@freebsd.org" ,
	"svn-src-all@freebsd.org" ,
	"src-committers@freebsd.org" 
Subject: Re: svn commit: r220558 - in head/sys: arm/econa dev/usb/controller
	mips/atheros mips/rmi
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 12:58:31 -0000

On Tuesday 12 April 2011 14:39:19 Nathan Whitehorn wrote:
> On 04/12/11 02:49, Hans Petter Selasky wrote:
> > Author: hselasky
> > Date: Tue Apr 12 07:49:11 2011
> > New Revision: 220558
> > URL: http://svn.freebsd.org/changeset/base/220558
> > 
> > Log:
> >    We don't need to call EOWRITE4(sc, EHCI_USBINTR, 0) directly from each
> >    EHCI bus driver at detach, hence ehci_detach() does exactly this
> >    since r199718.
> 
> Just so you're aware, there's also another EHCI driver in the tree at
> /sys/powerpc/ps3/ehci_ps3.c. It might also need some modifications at
> various points when you're cleaning up EHCI drivers.

This driver doesn't have a detach method. The patches don't apply to this 
driver then. Should I add a detach method or is it superfluous?

Thanks for noticing!

--HPS

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 13:04:27 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 35842106566C;
	Tue, 12 Apr 2011 13:04:27 +0000 (UTC)
	(envelope-from nwhitehorn@freebsd.org)
Received: from adsum.doit.wisc.edu (adsum.doit.wisc.edu [144.92.197.210])
	by mx1.freebsd.org (Postfix) with ESMTP id 029B38FC15;
	Tue, 12 Apr 2011 13:04:26 +0000 (UTC)
MIME-version: 1.0
Content-transfer-encoding: 7BIT
Content-type: text/plain; CHARSET=US-ASCII; format=flowed
Received: from avs-daemon.smtpauth1.wiscmail.wisc.edu by
	smtpauth1.wiscmail.wisc.edu
	(Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30
	2009)) id <0LJJ0030AIZEVP00@smtpauth1.wiscmail.wisc.edu>; Tue,
	12 Apr 2011 08:04:26 -0500 (CDT)
Received: from comporellon.tachypleus.net ([unknown] [76.210.65.155])
	by smtpauth1.wiscmail.wisc.edu
	(Sun Java(tm) System Messaging Server 7u2-7.05 32bit (built Jul 30
	2009))
	with ESMTPSA id <0LJJ000MDIZ8JQ00@smtpauth1.wiscmail.wisc.edu>; Tue,
	12 Apr 2011 08:04:24 -0500 (CDT)
Date: Tue, 12 Apr 2011 08:04:20 -0500
From: Nathan Whitehorn 
In-reply-to: <201104121457.26348.hselasky@freebsd.org>
To: Hans Petter Selasky 
Message-id: <4DA44DD4.2090105@freebsd.org>
X-Spam-Report: AuthenticatedSender=yes, SenderIP=76.210.65.155
X-Spam-PmxInfo: Server=avs-14, Version=5.6.0.2009776,
	Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.4.12.125416,
	SenderIP=76.210.65.155
References: <201104120749.p3C7nBDQ014198@svn.freebsd.org>
	<4DA447F7.50104@freebsd.org> <201104121457.26348.hselasky@freebsd.org>
User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.15)
	Gecko/20110305 Thunderbird/3.1.9
Cc: "svn-src-head@freebsd.org" ,
	"svn-src-all@freebsd.org" ,
	"src-committers@freebsd.org" 
Subject: Re: svn commit: r220558 - in head/sys: arm/econa dev/usb/controller
 mips/atheros mips/rmi
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 13:04:27 -0000

On 04/12/11 07:57, Hans Petter Selasky wrote:
> On Tuesday 12 April 2011 14:39:19 Nathan Whitehorn wrote:
>> On 04/12/11 02:49, Hans Petter Selasky wrote:
>>> Author: hselasky
>>> Date: Tue Apr 12 07:49:11 2011
>>> New Revision: 220558
>>> URL: http://svn.freebsd.org/changeset/base/220558
>>>
>>> Log:
>>>     We don't need to call EOWRITE4(sc, EHCI_USBINTR, 0) directly from each
>>>     EHCI bus driver at detach, hence ehci_detach() does exactly this
>>>     since r199718.
>> Just so you're aware, there's also another EHCI driver in the tree at
>> /sys/powerpc/ps3/ehci_ps3.c. It might also need some modifications at
>> various points when you're cleaning up EHCI drivers.
> This driver doesn't have a detach method. The patches don't apply to this
> driver then. Should I add a detach method or is it superfluous?

No, neither it nor the bus to which it is attached support detaching 
devices (I was lazy when I wrote), so it's moot for this change. This 
was just a heads-up for future cleanups.
-Nathan

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 15:20:35 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3E9F6106564A;
	Tue, 12 Apr 2011 15:20:35 +0000 (UTC) (envelope-from ae@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2E3FB8FC08;
	Tue, 12 Apr 2011 15:20:35 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CFKZ6Y028190;
	Tue, 12 Apr 2011 15:20:35 GMT (envelope-from ae@svn.freebsd.org)
Received: (from ae@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CFKZS9028188;
	Tue, 12 Apr 2011 15:20:35 GMT (envelope-from ae@svn.freebsd.org)
Message-Id: <201104121520.p3CFKZS9028188@svn.freebsd.org>
From: "Andrey V. Elsukov" 
Date: Tue, 12 Apr 2011 15:20:35 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220568 - head/sys/netinet/ipfw
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 15:20:35 -0000

Author: ae
Date: Tue Apr 12 15:20:34 2011
New Revision: 220568
URL: http://svn.freebsd.org/changeset/base/220568

Log:
  Restore previous behaviour - always match rule when we doing tagging,
  even when tag is already exists.
  
  Reported by:	Vadim Goncharov
  MFC after:	1 week

Modified:
  head/sys/netinet/ipfw/ip_fw2.c

Modified: head/sys/netinet/ipfw/ip_fw2.c
==============================================================================
--- head/sys/netinet/ipfw/ip_fw2.c	Tue Apr 12 12:57:46 2011	(r220567)
+++ head/sys/netinet/ipfw/ip_fw2.c	Tue Apr 12 15:20:34 2011	(r220568)
@@ -1793,10 +1793,13 @@ do {								\
 					if (mtag != NULL)
 						m_tag_delete(m, mtag);
 					match = 0;
-				} else if (mtag == NULL) {
-					if ((mtag = m_tag_alloc(MTAG_IPFW,
-					    tag, 0, M_NOWAIT)) != NULL)
-						m_tag_prepend(m, mtag);
+				} else {
+					if (mtag == NULL) {
+						mtag = m_tag_alloc( MTAG_IPFW,
+						    tag, 0, M_NOWAIT);
+						if (mtag != NULL)
+							m_tag_prepend(m, mtag);
+					}
 					match = 1;
 				}
 				break;

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 16:01:28 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2DD3B1065676;
	Tue, 12 Apr 2011 16:01:28 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1BE5B8FC15;
	Tue, 12 Apr 2011 16:01:28 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CG1SJO029114;
	Tue, 12 Apr 2011 16:01:28 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CG1ReP029111;
	Tue, 12 Apr 2011 16:01:27 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104121601.p3CG1ReP029111@svn.freebsd.org>
From: Alexander Motin 
Date: Tue, 12 Apr 2011 16:01:27 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220569 - head/sys/dev/mvs
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 16:01:28 -0000

Author: mav
Date: Tue Apr 12 16:01:27 2011
New Revision: 220569
URL: http://svn.freebsd.org/changeset/base/220569

Log:
  Implement automatic SCSI sense fetching for mvs(4).
  
  Make few improvements/changes to ATAPI PIO support to pass most of scgcheck
  (cdrtools) tests.

Modified:
  head/sys/dev/mvs/mvs.c
  head/sys/dev/mvs/mvs.h

Modified: head/sys/dev/mvs/mvs.c
==============================================================================
--- head/sys/dev/mvs/mvs.c	Tue Apr 12 15:20:34 2011	(r220568)
+++ head/sys/dev/mvs/mvs.c	Tue Apr 12 16:01:27 2011	(r220569)
@@ -86,14 +86,21 @@ static void mvs_requeue_frozen(device_t 
 static void mvs_execute_transaction(struct mvs_slot *slot);
 static void mvs_end_transaction(struct mvs_slot *slot, enum mvs_err_type et);
 
-static void mvs_issue_read_log(device_t dev);
+static void mvs_issue_recovery(device_t dev);
 static void mvs_process_read_log(device_t dev, union ccb *ccb);
+static void mvs_process_request_sense(device_t dev, union ccb *ccb);
 
 static void mvsaction(struct cam_sim *sim, union ccb *ccb);
 static void mvspoll(struct cam_sim *sim);
 
 MALLOC_DEFINE(M_MVS, "MVS driver", "MVS driver data buffers");
 
+#define recovery_type		spriv_field0
+#define RECOVERY_NONE		0
+#define RECOVERY_READ_LOG	1
+#define RECOVERY_REQUEST_SENSE	2
+#define recovery_slot		spriv_field1
+
 static int
 mvs_ch_probe(device_t dev)
 {
@@ -822,7 +829,8 @@ mvs_legacy_intr(device_t dev)
 	union ccb *ccb = slot->ccb;
 	enum mvs_err_type et = MVS_ERR_NONE;
 	int port;
-	u_int length;
+	u_int length, resid, size;
+	uint8_t buf[2];
 	uint8_t status, ireason;
 
 	/* Clear interrupt and get status. */
@@ -895,6 +903,7 @@ mvs_legacy_intr(device_t dev)
 	} else {			/* ATAPI PIO */
 		length = ATA_INB(ch->r_mem,ATA_CYL_LSB) |
 		    (ATA_INB(ch->r_mem,ATA_CYL_MSB) << 8);
+		size = min(ch->transfersize, length);
 		ireason = ATA_INB(ch->r_mem,ATA_IREASON);
 		switch ((ireason & (ATA_I_CMD | ATA_I_IN)) |
 			(status & ATA_S_DRQ)) {
@@ -913,7 +922,10 @@ mvs_legacy_intr(device_t dev)
 		    }
 		    ATA_OUTSW_STRM(ch->r_mem, ATA_DATA,
 			(uint16_t *)(ccb->csio.data_ptr + ch->donecount),
-			length / 2);
+			(size + 1) / 2);
+		    for (resid = ch->transfersize + (size & 1);
+			resid < length; resid += sizeof(int16_t))
+			    ATA_OUTW(ch->r_mem, ATA_DATA, 0);
 		    ch->donecount += length;
 		    /* Set next transfer size according to HW capabilities */
 		    ch->transfersize = min(ccb->csio.dxfer_len - ch->donecount,
@@ -927,9 +939,19 @@ mvs_legacy_intr(device_t dev)
 			et = MVS_ERR_TFE;
 			goto end_finished;
 		    }
-		    ATA_INSW_STRM(ch->r_mem, ATA_DATA,
-			(uint16_t *)(ccb->csio.data_ptr + ch->donecount),
-			length / 2);
+		    if (size >= 2) {
+			ATA_INSW_STRM(ch->r_mem, ATA_DATA,
+			    (uint16_t *)(ccb->csio.data_ptr + ch->donecount),
+			    size / 2);
+		    }
+		    if (size & 1) {
+			ATA_INSW_STRM(ch->r_mem, ATA_DATA, (void*)buf, 1);
+			((uint8_t *)ccb->csio.data_ptr + ch->donecount +
+			    (size & ~1))[0] = buf[0];
+		    }
+		    for (resid = ch->transfersize + (size & 1);
+			resid < length; resid += sizeof(int16_t))
+			    ATA_INW(ch->r_mem, ATA_DATA);
 		    ch->donecount += length;
 		    /* Set next transfer size according to HW capabilities */
 		    ch->transfersize = min(ccb->csio.dxfer_len - ch->donecount,
@@ -1363,8 +1385,7 @@ mvs_legacy_execute_transaction(struct mv
 			ATA_OUTL(ch->r_mem, DMA_C, DMA_C_START |
 			    (((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) ?
 			    DMA_C_READ : 0));
-		} else if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE)
-			ch->fake_busy = 1;
+		}
 	}
 	/* Start command execution timeout */
 	callout_reset(&slot->timeout, (int)ccb->ccb_h.timeout * hz / 1000,
@@ -1579,6 +1600,10 @@ mvs_end_transaction(struct mvs_slot *slo
 			mvs_tfd_read(dev, ccb);
 		} else
 			bzero(res, sizeof(*res));
+	} else {
+		if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE &&
+		    ch->basic_dma == 0)
+			ccb->csio.resid = ccb->csio.dxfer_len - ch->donecount;
 	}
 	if (ch->numpslots == 0 || ch->basic_dma) {
 		if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
@@ -1591,7 +1616,7 @@ mvs_end_transaction(struct mvs_slot *slo
 	if (et != MVS_ERR_NONE)
 		ch->eslots |= (1 << slot->slot);
 	/* In case of error, freeze device for proper recovery. */
-	if ((et != MVS_ERR_NONE) && (!ch->readlog) &&
+	if ((et != MVS_ERR_NONE) && (!ch->recoverycmd) &&
 	    !(ccb->ccb_h.status & CAM_DEV_QFRZN)) {
 		xpt_freeze_devq(ccb->ccb_h.path, 1);
 		ccb->ccb_h.status |= CAM_DEV_QFRZN;
@@ -1622,7 +1647,7 @@ mvs_end_transaction(struct mvs_slot *slo
 		break;
 	case MVS_ERR_SATA:
 		ch->fatalerr = 1;
-		if (!ch->readlog) {
+		if (!ch->recoverycmd) {
 			xpt_freeze_simq(ch->sim, 1);
 			ccb->ccb_h.status &= ~CAM_STATUS_MASK;
 			ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
@@ -1630,7 +1655,7 @@ mvs_end_transaction(struct mvs_slot *slo
 		ccb->ccb_h.status |= CAM_UNCOR_PARITY;
 		break;
 	case MVS_ERR_TIMEOUT:
-		if (!ch->readlog) {
+		if (!ch->recoverycmd) {
 			xpt_freeze_simq(ch->sim, 1);
 			ccb->ccb_h.status &= ~CAM_STATUS_MASK;
 			ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
@@ -1672,10 +1697,15 @@ mvs_end_transaction(struct mvs_slot *slo
 			xpt_release_simq(ch->sim, TRUE);
 	}
 	/* If it was our READ LOG command - process it. */
-	if (ch->readlog) {
+	if (ccb->ccb_h.recovery_type == RECOVERY_READ_LOG) {
 		mvs_process_read_log(dev, ccb);
-	/* If it was NCQ command error, put result on hold. */
-	} else if (et == MVS_ERR_NCQ) {
+	/* If it was our REQUEST SENSE command - process it. */
+	} else if (ccb->ccb_h.recovery_type == RECOVERY_REQUEST_SENSE) {
+		mvs_process_request_sense(dev, ccb);
+	/* If it was NCQ or ATAPI command error, put result on hold. */
+	} else if (et == MVS_ERR_NCQ ||
+	    ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR &&
+	     (ccb->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0)) {
 		ch->hold[slot->slot] = ccb;
 		ch->holdtag[slot->slot] = slot->tag;
 		ch->numhslots++;
@@ -1700,8 +1730,8 @@ mvs_end_transaction(struct mvs_slot *slo
 				ch->eslots = 0;
 			}
 			/* if there commands on hold, we can do READ LOG. */
-			if (!ch->readlog && ch->numhslots)
-				mvs_issue_read_log(dev);
+			if (!ch->recoverycmd && ch->numhslots)
+				mvs_issue_recovery(dev);
 		}
 	/* If all the rest of commands are in timeout - give them chance. */
 	} else if ((ch->rslots & ~ch->toslots) == 0 &&
@@ -1716,14 +1746,15 @@ mvs_end_transaction(struct mvs_slot *slo
 }
 
 static void
-mvs_issue_read_log(device_t dev)
+mvs_issue_recovery(device_t dev)
 {
 	struct mvs_channel *ch = device_get_softc(dev);
 	union ccb *ccb;
 	struct ccb_ataio *ataio;
+	struct ccb_scsiio *csio;
 	int i;
 
-	ch->readlog = 1;
+	ch->recoverycmd = 1;
 	/* Find some holden command. */
 	for (i = 0; i < MVS_MAX_SLOTS; i++) {
 		if (ch->hold[i])
@@ -1735,25 +1766,44 @@ mvs_issue_read_log(device_t dev)
 		return; /* XXX */
 	}
 	ccb->ccb_h = ch->hold[i]->ccb_h;	/* Reuse old header. */
-	ccb->ccb_h.func_code = XPT_ATA_IO;
-	ccb->ccb_h.flags = CAM_DIR_IN;
-	ccb->ccb_h.timeout = 1000;	/* 1s should be enough. */
-	ataio = &ccb->ataio;
-	ataio->data_ptr = malloc(512, M_MVS, M_NOWAIT);
-	if (ataio->data_ptr == NULL) {
-		xpt_free_ccb(ccb);
-		device_printf(dev, "Unable allocate memory for READ LOG command");
-		return; /* XXX */
+	if (ccb->ccb_h.func_code == XPT_ATA_IO) {
+		/* READ LOG */
+		ccb->ccb_h.recovery_type = RECOVERY_READ_LOG;
+		ccb->ccb_h.func_code = XPT_ATA_IO;
+		ccb->ccb_h.flags = CAM_DIR_IN;
+		ccb->ccb_h.timeout = 1000;	/* 1s should be enough. */
+		ataio = &ccb->ataio;
+		ataio->data_ptr = malloc(512, M_MVS, M_NOWAIT);
+		if (ataio->data_ptr == NULL) {
+			xpt_free_ccb(ccb);
+			device_printf(dev, "Unable allocate memory for READ LOG command");
+			return; /* XXX */
+		}
+		ataio->dxfer_len = 512;
+		bzero(&ataio->cmd, sizeof(ataio->cmd));
+		ataio->cmd.flags = CAM_ATAIO_48BIT;
+		ataio->cmd.command = 0x2F;	/* READ LOG EXT */
+		ataio->cmd.sector_count = 1;
+		ataio->cmd.sector_count_exp = 0;
+		ataio->cmd.lba_low = 0x10;
+		ataio->cmd.lba_mid = 0;
+		ataio->cmd.lba_mid_exp = 0;
+	} else {
+		/* REQUEST SENSE */
+		ccb->ccb_h.recovery_type = RECOVERY_REQUEST_SENSE;
+		ccb->ccb_h.recovery_slot = i;
+		ccb->ccb_h.func_code = XPT_SCSI_IO;
+		ccb->ccb_h.flags = CAM_DIR_IN;
+		ccb->ccb_h.status = 0;
+		ccb->ccb_h.timeout = 1000;	/* 1s should be enough. */
+		csio = &ccb->csio;
+		csio->data_ptr = (void *)&ch->hold[i]->csio.sense_data;
+		csio->dxfer_len = ch->hold[i]->csio.sense_len;
+		csio->cdb_len = 6;
+		bzero(&csio->cdb_io, sizeof(csio->cdb_io));
+		csio->cdb_io.cdb_bytes[0] = 0x03;
+		csio->cdb_io.cdb_bytes[4] = csio->dxfer_len;
 	}
-	ataio->dxfer_len = 512;
-	bzero(&ataio->cmd, sizeof(ataio->cmd));
-	ataio->cmd.flags = CAM_ATAIO_48BIT;
-	ataio->cmd.command = 0x2F;	/* READ LOG EXT */
-	ataio->cmd.sector_count = 1;
-	ataio->cmd.sector_count_exp = 0;
-	ataio->cmd.lba_low = 0x10;
-	ataio->cmd.lba_mid = 0;
-	ataio->cmd.lba_mid_exp = 0;
 	/* Freeze SIM while doing READ LOG EXT. */
 	xpt_freeze_simq(ch->sim, 1);
 	mvs_begin_transaction(dev, ccb);
@@ -1767,7 +1817,7 @@ mvs_process_read_log(device_t dev, union
 	struct ata_res *res;
 	int i;
 
-	ch->readlog = 0;
+	ch->recoverycmd = 0;
 
 	data = ccb->ataio.data_ptr;
 	if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP &&
@@ -1820,6 +1870,28 @@ mvs_process_read_log(device_t dev, union
 	xpt_release_simq(ch->sim, TRUE);
 }
 
+static void
+mvs_process_request_sense(device_t dev, union ccb *ccb)
+{
+	struct mvs_channel *ch = device_get_softc(dev);
+	int i;
+
+	ch->recoverycmd = 0;
+
+	i = ccb->ccb_h.recovery_slot;
+	if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
+		ch->hold[i]->ccb_h.status |= CAM_AUTOSNS_VALID;
+	} else {
+		ch->hold[i]->ccb_h.status &= ~CAM_STATUS_MASK;
+		ch->hold[i]->ccb_h.status |= CAM_AUTOSENSE_FAIL;
+	}
+	xpt_done(ch->hold[i]);
+	ch->hold[i] = NULL;
+	ch->numhslots--;
+	xpt_free_ccb(ccb);
+	xpt_release_simq(ch->sim, TRUE);
+}
+
 static int
 mvs_wait(device_t dev, u_int s, u_int c, int t)
 {
@@ -2052,6 +2124,7 @@ mvsaction(struct cam_sim *sim, union ccb
 			ccb->ccb_h.status = CAM_SEL_TIMEOUT;
 			break;
 		}
+		ccb->ccb_h.recovery_type = RECOVERY_NONE;
 		/* Check for command collision. */
 		if (mvs_check_collision(dev, ccb)) {
 			/* Freeze command. */

Modified: head/sys/dev/mvs/mvs.h
==============================================================================
--- head/sys/dev/mvs/mvs.h	Tue Apr 12 15:20:34 2011	(r220568)
+++ head/sys/dev/mvs/mvs.h	Tue Apr 12 16:01:27 2011	(r220569)
@@ -557,7 +557,7 @@ struct mvs_channel {
 	int			numtslots;	/* Number of NCQ slots */
 	int			numtslotspd[16];/* Number of NCQ slots per dev */
 	int			numhslots;	/* Number of holden slots */
-	int			readlog;	/* Our READ LOG active */
+	int			recoverycmd;	/* Our READ LOG active */
 	int			fatalerr;	/* Fatal error happend */
 	int			lastslot;	/* Last used slot */
 	int			taggedtarget;	/* Last tagged target */

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 18:44:08 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 147A1106566B
	for ; Tue, 12 Apr 2011 18:44:08 +0000 (UTC)
	(envelope-from andy@fud.org.nz)
Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50])
	by mx1.freebsd.org (Postfix) with ESMTP id A913A8FC1B
	for ; Tue, 12 Apr 2011 18:44:07 +0000 (UTC)
Received: by wwc33 with SMTP id 33so7818711wwc.31
	for ; Tue, 12 Apr 2011 11:44:06 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.227.1.102 with SMTP id 38mr2377476wbe.109.1302632319338; Tue,
	12 Apr 2011 11:18:39 -0700 (PDT)
Sender: andy@fud.org.nz
Received: by 10.227.138.139 with HTTP; Tue, 12 Apr 2011 11:18:39 -0700 (PDT)
In-Reply-To: <201104120810.p3C8AQs0014704@svn.freebsd.org>
References: <201104120810.p3C8AQs0014704@svn.freebsd.org>
Date: Wed, 13 Apr 2011 06:18:39 +1200
X-Google-Sender-Auth: NQj6sEshReounJ7OjI-6mamEn6Q
Message-ID: 
From: Andrew Thompson 
To: Adrian Chadd 
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220559 - in head/sys: conf geom
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 18:44:08 -0000

On 12 April 2011 20:10, Adrian Chadd  wrote:
> Author: adrian
> Date: Tue Apr 12 08:10:25 2011
> New Revision: 220559
> URL: http://svn.freebsd.org/changeset/base/220559
>
> Log:
> =A0Introduce geom_map, a GEOM provider designed for use by
> =A0embedded flash stores.
>
> =A0Some devices - notably those with uboot - don't have an
> =A0explicit partition table (eg like Redboot's FIS.)
> =A0geom_map thus provides an easy way to export the hard-coded
> =A0flash layout as geom providers for use by filesystems and
> =A0other tools.
>
> =A0It also includes a "search" function which allows for
> =A0dynamic creation of partition layouts where the device only
> =A0has a single hard-coded partition. For example, if
> =A0there is a "kernel+rootfs" partition, a single image can
> =A0be created which appends the rootfs after the kernel with
> =A0an appropriate search string. geom_map can be told to
> =A0search for said search string and create a partition
> =A0beginning after it.
>
> =A0Submitted by: Aleksandr Rybalko 
>
> Added:
> =A0head/sys/geom/geom_map.c =A0 (contents, props changed)
> Modified:
> =A0head/sys/conf/files
>
> Added: head/sys/geom/geom_map.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- /dev/null =A0 00:00:00 1970 =A0 (empty, because file is newly added)
> +++ head/sys/geom/geom_map.c =A0 =A0Tue Apr 12 08:10:25 2011 =A0 =A0 =A0 =
=A0(r220559)
> @@ -0,0 +1,356 @@
> +
> +#define MAP_CLASS_NAME "MAP"
> +
> +struct map_desc {
> + =A0 =A0 =A0 uint8_t =A0 =A0 =A0 =A0 name =A0 [16]; =A0 =A0/* null-termi=
nated name */
> + =A0 =A0 =A0 uint32_t =A0 =A0 =A0 =A0offset; /* offset in flash */
> + =A0 =A0 =A0 uint32_t =A0 =A0 =A0 =A0addr; =A0 /* address in memory */
> + =A0 =A0 =A0 uint32_t =A0 =A0 =A0 =A0size; =A0 /* image size in bytes */
> + =A0 =A0 =A0 uint32_t =A0 =A0 =A0 =A0entry; =A0/* offset in image for en=
try point */
> + =A0 =A0 =A0 uint32_t =A0 =A0 =A0 =A0dsize; =A0/* data size in bytes */
> +};

It could at some point be used on larger storage, perhaps get rid of
the 4G limit now?


Andrew

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 19:13:10 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5CE58106566B;
	Tue, 12 Apr 2011 19:13:10 +0000 (UTC) (envelope-from pjd@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4BDDA8FC0C;
	Tue, 12 Apr 2011 19:13:10 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CJDAAC033118;
	Tue, 12 Apr 2011 19:13:10 GMT (envelope-from pjd@svn.freebsd.org)
Received: (from pjd@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CJDAgs033116;
	Tue, 12 Apr 2011 19:13:10 GMT (envelope-from pjd@svn.freebsd.org)
Message-Id: <201104121913.p3CJDAgs033116@svn.freebsd.org>
From: Pawel Jakub Dawidek 
Date: Tue, 12 Apr 2011 19:13:10 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220573 - head/sbin/hastd
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 19:13:10 -0000

Author: pjd
Date: Tue Apr 12 19:13:10 2011
New Revision: 220573
URL: http://svn.freebsd.org/changeset/base/220573

Log:
  The replication mode that is currently support is fullsync, not memsync.
  Correct this and print a warning if different replication mode is
  configured.
  
  MFC after:	1 week

Modified:
  head/sbin/hastd/parse.y

Modified: head/sbin/hastd/parse.y
==============================================================================
--- head/sbin/hastd/parse.y	Tue Apr 12 17:02:40 2011	(r220572)
+++ head/sbin/hastd/parse.y	Tue Apr 12 19:13:10 2011	(r220573)
@@ -169,7 +169,7 @@ yy_config_parse(const char *config, bool
 	lineno = 0;
 
 	depth0_timeout = HAST_TIMEOUT;
-	depth0_replication = HAST_REPLICATION_MEMSYNC;
+	depth0_replication = HAST_REPLICATION_FULLSYNC;
 	depth0_checksum = HAST_CHECKSUM_NONE;
 	depth0_compression = HAST_COMPRESSION_HOLE;
 	strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control));
@@ -228,6 +228,13 @@ yy_config_parse(const char *config, bool
 			 */
 			curres->hr_replication = depth0_replication;
 		}
+		if (curres->hr_replication == HAST_REPLICATION_MEMSYNC ||
+		    curres->hr_replication == HAST_REPLICATION_ASYNC) {
+			pjdlog_warning("Replication mode \"%s\" is not implemented, falling back to \"%s\".",
+			    curres->hr_replication == HAST_REPLICATION_MEMSYNC ?
+			    "memsync" : "async", "fullsync");
+			curres->hr_replication = HAST_REPLICATION_FULLSYNC;
+		}
 		if (curres->hr_checksum == -1) {
 			/*
 			 * Checksum is not set at resource-level.

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 20:10:15 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A2BF2106566B;
	Tue, 12 Apr 2011 20:10:15 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 913FA8FC19;
	Tue, 12 Apr 2011 20:10:15 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CKAFWn034380;
	Tue, 12 Apr 2011 20:10:15 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CKAFfv034376;
	Tue, 12 Apr 2011 20:10:15 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104122010.p3CKAFfv034376@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Tue, 12 Apr 2011 20:10:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220574 - head/bin/ps
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 20:10:15 -0000

Author: trasz
Date: Tue Apr 12 20:10:15 2011
New Revision: 220574
URL: http://svn.freebsd.org/changeset/base/220574

Log:
  Get rid of DSIZ; instead just call the sizing function if provided.

Modified:
  head/bin/ps/keyword.c
  head/bin/ps/ps.c
  head/bin/ps/ps.h

Modified: head/bin/ps/keyword.c
==============================================================================
--- head/bin/ps/keyword.c	Tue Apr 12 19:13:10 2011	(r220573)
+++ head/bin/ps/keyword.c	Tue Apr 12 20:10:15 2011	(r220574)
@@ -79,9 +79,9 @@ static VAR var[] = {
 		CHAR, NULL, 0},
 	{"blocked", "", "sigmask", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 	{"caught", "", "sigcatch", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
-	{"class", "CLASS", NULL, LJUST|DSIZ, loginclass, s_loginclass,
+	{"class", "CLASS", NULL, LJUST, loginclass, s_loginclass,
 		MAXLOGNAME-1, 0, CHAR, NULL, 0},
-	{"comm", "COMMAND", NULL, LJUST|DSIZ, ucomm, s_comm,
+	{"comm", "COMMAND", NULL, LJUST, ucomm, s_comm,
 		COMMLEN + OCOMMLEN + 1, 0, CHAR, NULL, 0},
 	{"command", "COMMAND", NULL, COMM|LJUST|USER, command, NULL, 16, 0,
 		CHAR, NULL, 0},
@@ -103,12 +103,12 @@ static VAR var[] = {
 		0},
 	{"ktrace", "KTRACE", NULL, 0, kvar, NULL, 8, KOFF(ki_traceflag), INT,
 		"x", 0},
-	{"label", "LABEL", NULL, LJUST|DSIZ, label, s_label, SHRT_MAX, 0, CHAR,
+	{"label", "LABEL", NULL, LJUST, label, s_label, SHRT_MAX, 0, CHAR,
 	    NULL, 0},
 	{"lim", "LIM", NULL, 0, maxrss, NULL, 5, 0, CHAR, NULL, 0},
 	{"lockname", "LOCK", NULL, LJUST, lockname, NULL, 6, 0, CHAR, NULL,
 		0},
-	{"login", "LOGIN", NULL, LJUST|DSIZ, logname, s_logname, MAXLOGNAME-1,
+	{"login", "LOGIN", NULL, LJUST, logname, s_logname, MAXLOGNAME-1,
 		0, CHAR, NULL, 0},
 	{"logname", "", "login", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 	{"lstart", "STARTED", NULL, LJUST|USER, lstarted, NULL, 28, 0, CHAR,
@@ -160,14 +160,14 @@ static VAR var[] = {
 		0},
 	{"rgid", "RGID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_rgid),
 		UINT, UIDFMT, 0},
-	{"rgroup", "RGROUP", NULL, LJUST|DSIZ, rgroupname, s_rgroupname,
+	{"rgroup", "RGROUP", NULL, LJUST, rgroupname, s_rgroupname,
 		USERLEN, 0, CHAR, NULL, 0},
 	{"rss", "RSS", NULL, 0, kvar, NULL, 6, KOFF(ki_rssize), PGTOK, "ld", 0},
 	{"rtprio", "RTPRIO", NULL, 0, priorityr, NULL, 7, KOFF(ki_pri), CHAR,
 		NULL, 0},
 	{"ruid", "RUID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_ruid),
 		UINT, UIDFMT, 0},
-	{"ruser", "RUSER", NULL, LJUST|DSIZ, runame, s_runame, USERLEN,
+	{"ruser", "RUSER", NULL, LJUST, runame, s_runame, USERLEN,
 		0, CHAR, NULL, 0},
 	{"sid", "SID", NULL, 0, kvar, NULL, PIDLEN, KOFF(ki_sid), UINT,
 		PIDFMT, 0},
@@ -189,13 +189,13 @@ static VAR var[] = {
 		UINT, UIDFMT, 0},
 	{"svuid", "SVUID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_svuid),
 		UINT, UIDFMT, 0},
-	{"systime", "SYSTIME", NULL, USER|DSIZ, systime, s_systime, 15, 0, CHAR,
+	{"systime", "SYSTIME", NULL, USER, systime, s_systime, 15, 0, CHAR,
 		NULL, 0},
 	{"tdaddr", "TDADDR", NULL, 0, kvar, NULL, sizeof(void *) * 2,
 		KOFF(ki_tdaddr), KPTR, "lx", 0},
 	{"tdev", "TDEV", NULL, 0, tdev, NULL, 5, 0, CHAR, NULL, 0},
 	{"tdnam", "TDNAM", NULL, LJUST, tdnam, NULL, COMMLEN, 0, CHAR, NULL, 0},
-	{"time", "TIME", NULL, USER|DSIZ, cputime, s_cputime, 15, 0, CHAR,
+	{"time", "TIME", NULL, USER, cputime, s_cputime, 15, 0, CHAR,
 		NULL, 0},
 	{"tpgid", "TPGID", NULL, 0, kvar, NULL, 4, KOFF(ki_tpgid), UINT,
 		PIDFMT, 0},
@@ -204,16 +204,16 @@ static VAR var[] = {
 	{"tsiz", "TSIZ", NULL, 0, kvar, NULL, 4, KOFF(ki_tsize), PGTOK, "ld", 0},
 	{"tt", "TT ", NULL, 0, tname, NULL, 4, 0, CHAR, NULL, 0},
 	{"tty", "TTY", NULL, LJUST, longtname, NULL, 8, 0, CHAR, NULL, 0},
-	{"ucomm", "UCOMM", NULL, LJUST|DSIZ, ucomm, s_comm,
+	{"ucomm", "UCOMM", NULL, LJUST, ucomm, s_comm,
 		COMMLEN + OCOMMLEN + 1, 0, CHAR, NULL, 0},
 	{"uid", "UID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_uid), UINT,
 		UIDFMT, 0},
 	{"upr", "UPR", NULL, 0, upr, NULL, 3, 0, CHAR, NULL, 0},
 	{"uprocp", "UPROCP", NULL, 0, kvar, NULL, sizeof(void *) * 2,
 		KOFF(ki_paddr), KPTR, "lx", 0},
-	{"user", "USER", NULL, LJUST|DSIZ, uname, s_uname, USERLEN, 0, CHAR,
+	{"user", "USER", NULL, LJUST, uname, s_uname, USERLEN, 0, CHAR,
 		NULL, 0},
-	{"usertime", "USERTIME", NULL, USER|DSIZ, usertime, s_usertime, 15, 0,
+	{"usertime", "USERTIME", NULL, USER, usertime, s_usertime, 15, 0,
 		CHAR, NULL, 0},
 	{"usrpri", "", "upr", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
 	{"vsize", "", "vsz", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},

Modified: head/bin/ps/ps.c
==============================================================================
--- head/bin/ps/ps.c	Tue Apr 12 19:13:10 2011	(r220573)
+++ head/bin/ps/ps.c	Tue Apr 12 20:10:15 2011	(r220574)
@@ -1078,7 +1078,7 @@ scanvars(void)
 
 	STAILQ_FOREACH(vent, &varlist, next_ve) {
 		v = vent->var;
-		if (v->flag & DSIZ) {
+		if (v->sproc != NULL) {
 			v->dwidth = v->width;
 			v->width = 0;
 		}
@@ -1098,9 +1098,9 @@ dynsizevars(KINFO *ki)
 
 	STAILQ_FOREACH(vent, &varlist, next_ve) {
 		v = vent->var;
-		if (!(v->flag & DSIZ))
+		if (v->sproc == NULL)
 			continue;
-		i = (v->sproc)( ki);
+		i = (v->sproc)(ki);
 		if (v->width < i)
 			v->width = i;
 		if (v->width > v->dwidth)

Modified: head/bin/ps/ps.h
==============================================================================
--- head/bin/ps/ps.h	Tue Apr 12 19:13:10 2011	(r220573)
+++ head/bin/ps/ps.h	Tue Apr 12 20:10:15 2011	(r220574)
@@ -62,12 +62,11 @@ typedef struct var {
 #define	COMM	0x01		/* needs exec arguments and environment (XXX) */
 #define	LJUST	0x02		/* left adjust on output (trailing blanks) */
 #define	USER	0x04		/* needs user structure */
-#define	DSIZ	0x08		/* field size is dynamic*/
 #define	INF127	0x10		/* values >127 displayed as 127 */
 	u_int	flag;
 				/* output routine */
 	void	(*oproc)(struct kinfo *, struct varent *);
-				/* sizing routine*/
+				/* sizing routine */
 	int	(*sproc)(struct kinfo *);
 	short	width;		/* printing width */
 	/*

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 20:31:33 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 96B4F106564A;
	Tue, 12 Apr 2011 20:31:33 +0000 (UTC) (envelope-from pjd@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8602F8FC0C;
	Tue, 12 Apr 2011 20:31:33 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CKVXtd034883;
	Tue, 12 Apr 2011 20:31:33 GMT (envelope-from pjd@svn.freebsd.org)
Received: (from pjd@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CKVX2q034881;
	Tue, 12 Apr 2011 20:31:33 GMT (envelope-from pjd@svn.freebsd.org)
Message-Id: <201104122031.p3CKVX2q034881@svn.freebsd.org>
From: Pawel Jakub Dawidek 
Date: Tue, 12 Apr 2011 20:31:33 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220575 -
	head/cddl/contrib/opensolaris/lib/libzfs/common
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 20:31:33 -0000

Author: pjd
Date: Tue Apr 12 20:31:33 2011
New Revision: 220575
URL: http://svn.freebsd.org/changeset/base/220575

Log:
  Fix 'zfs list ' handling. If the path was found, the 'ret' variable was
  uninitialized.
  
  PR:		kern/155940
  Submitted by:	KOIE Hidetaka 
  MFC after:	1 week

Modified:
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c	Tue Apr 12 20:10:15 2011	(r220574)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c	Tue Apr 12 20:31:33 2011	(r220575)
@@ -734,12 +734,13 @@ zfs_path_to_zhandle(libzfs_handle_t *hdl
 	{
 		struct statfs sfs;
 
-		if (statfs(path, &sfs) != 0) {
+		ret = statfs(path, &sfs);
+		if (ret == 0)
+			statfs2mnttab(&sfs, &entry);
+		else {
 			(void) fprintf(stderr, "%s: %s\n", path,
 			    strerror(errno));
-			ret = -1;
 		}
-		statfs2mnttab(&sfs, &entry);
 	}
 #endif	/* sun */
 	if (ret != 0) {

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 20:50:57 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 94ABE106564A;
	Tue, 12 Apr 2011 20:50:57 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 825158FC12;
	Tue, 12 Apr 2011 20:50:57 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CKov8A035269;
	Tue, 12 Apr 2011 20:50:57 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CKovnp035266;
	Tue, 12 Apr 2011 20:50:57 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104122050.p3CKovnp035266@svn.freebsd.org>
From: Alexander Motin 
Date: Tue, 12 Apr 2011 20:50:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220576 - head/sys/dev/ahci
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 20:50:57 -0000

Author: mav
Date: Tue Apr 12 20:50:57 2011
New Revision: 220576
URL: http://svn.freebsd.org/changeset/base/220576

Log:
  Refactor hard-reset implementation in ahci(4).
  
  Instead of spinning in a tight loop for up to 15 seconds, polling for device
  readiness while it spins up, return reset completion just after PHY reports
  "connect well" or 100ms connection timeout. If device was found, use callout
  for checking device readiness with 100ms period up to full 31 second timeout.
  
  This fixes system freeze for 5-10 seconds on drives hot plug-in.

Modified:
  head/sys/dev/ahci/ahci.c
  head/sys/dev/ahci/ahci.h

Modified: head/sys/dev/ahci/ahci.c
==============================================================================
--- head/sys/dev/ahci/ahci.c	Tue Apr 12 20:31:33 2011	(r220575)
+++ head/sys/dev/ahci/ahci.c	Tue Apr 12 20:50:57 2011	(r220576)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -89,7 +90,7 @@ static void ahci_stop_fr(device_t dev);
 
 static int ahci_sata_connect(struct ahci_channel *ch);
 static int ahci_sata_phy_reset(device_t dev);
-static int ahci_wait_ready(device_t dev, int t);
+static int ahci_wait_ready(device_t dev, int t, int t0);
 
 static void ahci_issue_recovery(device_t dev);
 static void ahci_process_read_log(device_t dev, union ccb *ccb);
@@ -889,6 +890,7 @@ ahci_ch_attach(device_t dev)
 	    device_get_unit(dev), "pm_level", &ch->pm_level);
 	if (ch->pm_level > 3)
 		callout_init_mtx(&ch->pm_timer, &ch->mtx, 0);
+	callout_init_mtx(&ch->reset_timer, &ch->mtx, 0);
 	/* Limit speed for my onboard JMicron external port.
 	 * It is not eSATA really. */
 	if (pci_get_devid(ctlr->dev) == 0x2363197b &&
@@ -1005,6 +1007,11 @@ ahci_ch_detach(device_t dev)
 
 	mtx_lock(&ch->mtx);
 	xpt_async(AC_LOST_DEVICE, ch->path, NULL);
+	/* Forget about reset. */
+	if (ch->resetting) {
+		ch->resetting = 0;
+		xpt_release_simq(ch->sim, TRUE);
+	}
 	xpt_free_path(ch->path);
 	xpt_bus_deregister(cam_sim_path(ch->sim));
 	cam_sim_free(ch->sim, /*free_devq*/TRUE);
@@ -1012,6 +1019,7 @@ ahci_ch_detach(device_t dev)
 
 	if (ch->pm_level > 3)
 		callout_drain(&ch->pm_timer);
+	callout_drain(&ch->reset_timer);
 	bus_teardown_intr(dev, ch->r_irq, ch->ih);
 	bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq);
 
@@ -1077,6 +1085,12 @@ ahci_ch_suspend(device_t dev)
 
 	mtx_lock(&ch->mtx);
 	xpt_freeze_simq(ch->sim, 1);
+	/* Forget about reset. */
+	if (ch->resetting) {
+		ch->resetting = 0;
+		callout_stop(&ch->reset_timer);
+		xpt_release_simq(ch->sim, TRUE);
+	}
 	while (ch->oslots)
 		msleep(ch, &ch->mtx, PRIBIO, "ahcisusp", hz/100);
 	ahci_ch_deinit(dev);
@@ -2320,7 +2334,7 @@ ahci_start_fr(device_t dev)
 }
 
 static int
-ahci_wait_ready(device_t dev, int t)
+ahci_wait_ready(device_t dev, int t, int t0)
 {
 	struct ahci_channel *ch = device_get_softc(dev);
 	int timeout = 0;
@@ -2328,19 +2342,50 @@ ahci_wait_ready(device_t dev, int t)
 
 	while ((val = ATA_INL(ch->r_mem, AHCI_P_TFD)) &
 	    (ATA_S_BUSY | ATA_S_DRQ)) {
-		DELAY(1000);
-		if (timeout++ > t) {
-			device_printf(dev, "device is not ready (timeout %dms) "
-			    "tfd = %08x\n", t, val);
+		if (timeout > t) {
+			if (t != 0) {
+				device_printf(dev,
+				    "AHCI reset: device not ready after %dms "
+				    "(tfd = %08x)\n",
+				    MAX(t, 0) + t0, val);
+			}
 			return (EBUSY);
 		}
-	} 
+		DELAY(1000);
+		timeout++;
+	}
 	if (bootverbose)
-		device_printf(dev, "ready wait time=%dms\n", timeout);
+		device_printf(dev, "AHCI reset: device ready after %dms\n",
+		    timeout + t0);
 	return (0);
 }
 
 static void
+ahci_reset_to(void *arg)
+{
+	device_t dev = arg;
+	struct ahci_channel *ch = device_get_softc(dev);
+
+	if (ch->resetting == 0)
+		return;
+	ch->resetting--;
+	if (ahci_wait_ready(dev, ch->resetting == 0 ? -1 : 0,
+	    (310 - ch->resetting) * 100) == 0) {
+		ch->resetting = 0;
+		xpt_release_simq(ch->sim, TRUE);
+		return;
+	}
+	if (ch->resetting == 0) {
+		ahci_stop(dev);
+		ahci_clo(dev);
+		ahci_start(dev, 1);
+		xpt_release_simq(ch->sim, TRUE);
+		return;
+	}
+	callout_schedule(&ch->reset_timer, hz / 10);
+}
+
+static void
 ahci_reset(device_t dev)
 {
 	struct ahci_channel *ch = device_get_softc(dev);
@@ -2350,6 +2395,12 @@ ahci_reset(device_t dev)
 	xpt_freeze_simq(ch->sim, 1);
 	if (bootverbose)
 		device_printf(dev, "AHCI reset...\n");
+	/* Forget about previous reset. */
+	if (ch->resetting) {
+		ch->resetting = 0;
+		callout_stop(&ch->reset_timer);
+		xpt_release_simq(ch->sim, TRUE);
+	}
 	/* Requeue freezed command. */
 	if (ch->frozen) {
 		union ccb *fccb = ch->frozen;
@@ -2390,7 +2441,7 @@ ahci_reset(device_t dev)
 	if (!ahci_sata_phy_reset(dev)) {
 		if (bootverbose)
 			device_printf(dev,
-			    "AHCI reset done: phy reset found no device\n");
+			    "AHCI reset: device not found\n");
 		ch->devices = 0;
 		/* Enable wanted port interrupts */
 		ATA_OUTL(ch->r_mem, AHCI_P_IE,
@@ -2398,9 +2449,15 @@ ahci_reset(device_t dev)
 		xpt_release_simq(ch->sim, TRUE);
 		return;
 	}
+	if (bootverbose)
+		device_printf(dev, "AHCI reset: device found\n");
 	/* Wait for clearing busy status. */
-	if (ahci_wait_ready(dev, 15000))
-		ahci_clo(dev);
+	if (ahci_wait_ready(dev, dumping ? 31000 : 0, 0)) {
+		if (dumping)
+			ahci_clo(dev);
+		else
+			ch->resetting = 310;
+	}
 	ahci_start(dev, 1);
 	ch->devices = 1;
 	/* Enable wanted port interrupts */
@@ -2410,9 +2467,10 @@ ahci_reset(device_t dev)
 	      ((ch->pm_level == 0) ? AHCI_P_IX_PRC | AHCI_P_IX_PC : 0) |
 	      AHCI_P_IX_DP | AHCI_P_IX_UF | (ctlr->ccc ? 0 : AHCI_P_IX_SDB) |
 	      AHCI_P_IX_DS | AHCI_P_IX_PS | (ctlr->ccc ? 0 : AHCI_P_IX_DHR)));
-	if (bootverbose)
-		device_printf(dev, "AHCI reset done: device found\n");
-	xpt_release_simq(ch->sim, TRUE);
+	if (ch->resetting)
+		callout_reset(&ch->reset_timer, hz / 10, ahci_reset_to, dev);
+	else
+		xpt_release_simq(ch->sim, TRUE);
 }
 
 static int

Modified: head/sys/dev/ahci/ahci.h
==============================================================================
--- head/sys/dev/ahci/ahci.h	Tue Apr 12 20:31:33 2011	(r220575)
+++ head/sys/dev/ahci/ahci.h	Tue Apr 12 20:50:57 2011	(r220576)
@@ -412,8 +412,10 @@ struct ahci_channel {
 	int			fatalerr;	/* Fatal error happend */
 	int			lastslot;	/* Last used slot */
 	int			taggedtarget;	/* Last tagged target */
+	int			resetting;	/* Hard-reset in progress. */
 	union ccb		*frozen;	/* Frozen command */
 	struct callout		pm_timer;	/* Power management events */
+	struct callout		reset_timer;	/* Hard-reset timeout */
 
 	struct ahci_device	user[16];	/* User-specified settings */
 	struct ahci_device	curr[16];	/* Current settings */

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 21:02:45 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5599E106564A;
	Tue, 12 Apr 2011 21:02:45 +0000 (UTC)
	(envelope-from mavbsd@gmail.com)
Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com
	[209.85.161.54])
	by mx1.freebsd.org (Postfix) with ESMTP id 8A11A8FC0A;
	Tue, 12 Apr 2011 21:02:44 +0000 (UTC)
Received: by fxm11 with SMTP id 11so55908fxm.13
	for ; Tue, 12 Apr 2011 14:02:43 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:sender:message-id:date:from:user-agent
	:mime-version:to:cc:subject:references:in-reply-to
	:x-enigmail-version:content-type:content-transfer-encoding;
	bh=VGQiNvSarlym0AElE4xRdRh0qLugFDBLwvhxqIBNP2M=;
	b=OrNsvZgOznjtA0BNXCoBpKYRFJBB9j0bvcqq+1lZQ1re0d56LS9xauFZGSAZv6Gb04
	+WOdfbhQt376ccLOgVCcJbg0TF7UnKzAKM1mpoq1uQcktXzBKwzOyoY32zNcSUGAUekj
	ZO+zNFZ334Wpzn5u9AIqqtq1QHQdHPGrFVV4g=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject
	:references:in-reply-to:x-enigmail-version:content-type
	:content-transfer-encoding;
	b=BcU9fJC3L3mog5ywJowwaN981R1zo40rk00hoqXLA5ceaGShCQzEXGfvrYD+bTPDM2
	A4wJdvVyryJrWWfLuSMwVgITc8r6R0ehVGNDJQ7Y+3XGNJN2ypWZUFHkCP2q63pWeVNh
	p+i5J/IXNXrQWbr9QdZHpkJGP3kESy90RoCnw=
Received: by 10.223.98.5 with SMTP id o5mr2003334fan.33.1302642163404;
	Tue, 12 Apr 2011 14:02:43 -0700 (PDT)
Received: from mavbook2.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226])
	by mx.google.com with ESMTPS id t2sm2066530faa.47.2011.04.12.14.02.41
	(version=SSLv3 cipher=OTHER); Tue, 12 Apr 2011 14:02:42 -0700 (PDT)
Sender: Alexander Motin 
Message-ID: <4DA4BDE4.7000709@FreeBSD.org>
Date: Wed, 13 Apr 2011 00:02:28 +0300
From: Alexander Motin 
User-Agent: Thunderbird 2.0.0.23 (X11/20091212)
MIME-Version: 1.0
To: Dmitry Morozovsky 
References: <201104122050.p3CKovnp035266@svn.freebsd.org>
	
In-Reply-To: 
X-Enigmail-Version: 0.96.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220576 - head/sys/dev/ahci
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 21:02:45 -0000

Dmitry Morozovsky wrote:
> On Tue, 12 Apr 2011, Alexander Motin wrote:
> 
> AM> Author: mav
> AM> Date: Tue Apr 12 20:50:57 2011
> AM> New Revision: 220576
> AM> URL: http://svn.freebsd.org/changeset/base/220576
> AM> 
> AM> Log:
> AM>   Refactor hard-reset implementation in ahci(4).
> AM>   
> AM>   Instead of spinning in a tight loop for up to 15 seconds, polling for device
> AM>   readiness while it spins up, return reset completion just after PHY reports
> AM>   "connect well" or 100ms connection timeout. If device was found, use callout
> AM>   for checking device readiness with 100ms period up to full 31 second timeout.
> AM>   
> AM>   This fixes system freeze for 5-10 seconds on drives hot plug-in.
> 
> Great, thank you!
> 
> Any plans to MFC this?

In 1-2 weeks if everything is fine.

-- 
Alexander Motin

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 21:06:08 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F17D91065670;
	Tue, 12 Apr 2011 21:06:08 +0000 (UTC) (envelope-from marck@rinet.ru)
Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68])
	by mx1.freebsd.org (Postfix) with ESMTP id 73F328FC0C;
	Tue, 12 Apr 2011 21:06:07 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
	by woozle.rinet.ru (8.14.4/8.14.4) with ESMTP id p3CKsF4Z080473;
	Wed, 13 Apr 2011 00:54:15 +0400 (MSD) (envelope-from marck@rinet.ru)
Date: Wed, 13 Apr 2011 00:54:15 +0400 (MSD)
From: Dmitry Morozovsky 
To: Alexander Motin 
In-Reply-To: <201104122050.p3CKovnp035266@svn.freebsd.org>
Message-ID: 
References: <201104122050.p3CKovnp035266@svn.freebsd.org>
User-Agent: Alpine 2.00 (BSF 1167 2008-08-23)
X-NCC-RegID: ru.rinet
X-OpenPGP-Key-ID: 6B691B03
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.6
	(woozle.rinet.ru [0.0.0.0]); Wed, 13 Apr 2011 00:54:15 +0400 (MSD)
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220576 - head/sys/dev/ahci
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 21:06:09 -0000

On Tue, 12 Apr 2011, Alexander Motin wrote:

AM> Author: mav
AM> Date: Tue Apr 12 20:50:57 2011
AM> New Revision: 220576
AM> URL: http://svn.freebsd.org/changeset/base/220576
AM> 
AM> Log:
AM>   Refactor hard-reset implementation in ahci(4).
AM>   
AM>   Instead of spinning in a tight loop for up to 15 seconds, polling for device
AM>   readiness while it spins up, return reset completion just after PHY reports
AM>   "connect well" or 100ms connection timeout. If device was found, use callout
AM>   for checking device readiness with 100ms period up to full 31 second timeout.
AM>   
AM>   This fixes system freeze for 5-10 seconds on drives hot plug-in.

Great, thank you!

Any plans to MFC this?

-- 
Sincerely,
D.Marck                                     [DM5020, MCK-RIPE, DM3-RIPN]
[ FreeBSD committer:                                 marck@FreeBSD.org ]
------------------------------------------------------------------------
*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru ***
------------------------------------------------------------------------

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 21:08:35 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4798C1065673;
	Tue, 12 Apr 2011 21:08:35 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 37A728FC19;
	Tue, 12 Apr 2011 21:08:35 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CL8ZF6035672;
	Tue, 12 Apr 2011 21:08:35 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CL8ZaP035670;
	Tue, 12 Apr 2011 21:08:35 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104122108.p3CL8ZaP035670@svn.freebsd.org>
From: Jung-uk Kim 
Date: Tue, 12 Apr 2011 21:08:35 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220577 - head/sys/x86/x86
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 21:08:35 -0000

Author: jkim
Date: Tue Apr 12 21:08:34 2011
New Revision: 220577
URL: http://svn.freebsd.org/changeset/base/220577

Log:
  Add a new tunable 'machdep.disable_tsc_calibration' to allow skipping TSC
  frequency calibration.  For Intel processors, if brand string from CPUID
  contains its nominal frequency, this frequency is used instead.

Modified:
  head/sys/x86/x86/tsc.c

Modified: head/sys/x86/x86/tsc.c
==============================================================================
--- head/sys/x86/x86/tsc.c	Tue Apr 12 20:50:57 2011	(r220576)
+++ head/sys/x86/x86/tsc.c	Tue Apr 12 21:08:34 2011	(r220577)
@@ -67,6 +67,11 @@ SYSCTL_INT(_machdep, OID_AUTO, disable_t
     "Disable x86 Time Stamp Counter");
 TUNABLE_INT("machdep.disable_tsc", &tsc_disabled);
 
+static int	tsc_skip_calibration;
+SYSCTL_INT(_machdep, OID_AUTO, disable_tsc_calibration, CTLFLAG_RDTUN,
+    &tsc_skip_calibration, 0, "Disable TSC frequency calibration");
+TUNABLE_INT("machdep.disable_tsc_calibration", &tsc_skip_calibration);
+
 static void tsc_freq_changed(void *arg, const struct cf_level *level,
     int status);
 static void tsc_freq_changing(void *arg, const struct cf_level *level,
@@ -83,24 +88,70 @@ static struct timecounter tsc_timecounte
 	800,			/* quality (adjusted in code) */
 };
 
-void
-init_TSC(void)
+static void
+tsc_freq_intel(void)
 {
-	u_int64_t tscval[2];
-
-	if ((cpu_feature & CPUID_TSC) == 0 || tsc_disabled)
-		return;
-
-	if (bootverbose)
-	        printf("Calibrating TSC clock ... ");
+	char brand[48];
+	u_int regs[4];
+	uint64_t freq;
+	char *p;
+	u_int i;
 
-	tscval[0] = rdtsc();
-	DELAY(1000000);
-	tscval[1] = rdtsc();
+	/*
+	 * Intel Processor Identification and the CPUID Instruction
+	 * Application Note 485.
+	 *
+	 * http://www.intel.com/assets/pdf/appnote/241618.pdf
+	 */
+	if (cpu_exthigh >= 0x80000004) {
+		p = brand;
+		for (i = 0x80000002; i < 0x80000005; i++) {
+			do_cpuid(i, regs);
+			memcpy(p, regs, sizeof(regs));
+			p += sizeof(regs);
+		}
+		p = NULL;
+		for (i = 0; i < sizeof(brand) - 1; i++)
+			if (brand[i] == 'H' && brand[i + 1] == 'z')
+				p = brand + i;
+		if (p != NULL) {
+			p -= 5;
+			switch (p[4]) {
+			case 'M':
+				i = 1;
+				break;
+			case 'G':
+				i = 1000;
+				break;
+			case 'T':
+				i = 1000000;
+				break;
+			default:
+				return;
+			}
+#define	C2D(c)	((c) - '0')
+			if (p[1] == '.') {
+				freq = C2D(p[0]) * 1000;
+				freq += C2D(p[2]) * 100;
+				freq += C2D(p[3]) * 10;
+				freq *= i * 1000;
+			} else {
+				freq = C2D(p[0]) * 1000;
+				freq += C2D(p[1]) * 100;
+				freq += C2D(p[2]) * 10;
+				freq += C2D(p[3]);
+				freq *= i * 1000000;
+			}
+#undef C2D
+			tsc_freq = freq;
+		}
+	}
+}
 
-	tsc_freq = tscval[1] - tscval[0];
-	if (bootverbose)
-		printf("TSC clock: %ju Hz\n", (intmax_t)tsc_freq);
+static void
+probe_tsc_freq(void)
+{
+	uint64_t tsc1, tsc2;
 
 	switch (cpu_vendor_id) {
 	case CPU_VENDOR_AMD:
@@ -127,12 +178,38 @@ init_TSC(void)
 		break;
 	}
 
+	if (tsc_skip_calibration) {
+		if (cpu_vendor_id == CPU_VENDOR_INTEL)
+			tsc_freq_intel();
+		return;
+	}
+
+	if (bootverbose)
+	        printf("Calibrating TSC clock ... ");
+	tsc1 = rdtsc();
+	DELAY(1000000);
+	tsc2 = rdtsc();
+	tsc_freq = tsc2 - tsc1;
+	if (bootverbose)
+		printf("TSC clock: %ju Hz\n", (intmax_t)tsc_freq);
+}
+
+void
+init_TSC(void)
+{
+
+	if ((cpu_feature & CPUID_TSC) == 0 || tsc_disabled)
+		return;
+
+	probe_tsc_freq();
+
 	/*
 	 * Inform CPU accounting about our boot-time clock rate.  This will
 	 * be updated if someone loads a cpufreq driver after boot that
 	 * discovers a new max frequency.
 	 */
-	set_cputicker(rdtsc, tsc_freq, 1);
+	if (tsc_freq != 0)
+		set_cputicker(rdtsc, tsc_freq, 1);
 
 	if (tsc_is_invariant)
 		return;

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 22:12:24 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 380CF1065676;
	Tue, 12 Apr 2011 22:12:24 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 27FF08FC0A;
	Tue, 12 Apr 2011 22:12:24 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CMCOIV037105;
	Tue, 12 Apr 2011 22:12:24 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CMCORX037102;
	Tue, 12 Apr 2011 22:12:24 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104122212.p3CMCORX037102@svn.freebsd.org>
From: Jung-uk Kim 
Date: Tue, 12 Apr 2011 22:12:24 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220578 - in head/sys: amd64/include i386/include
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 22:12:24 -0000

Author: jkim
Date: Tue Apr 12 22:12:23 2011
New Revision: 220578
URL: http://svn.freebsd.org/changeset/base/220578

Log:
  Add definitions for CPUID instruction 6, ECX information.

Modified:
  head/sys/amd64/include/specialreg.h
  head/sys/i386/include/specialreg.h

Modified: head/sys/amd64/include/specialreg.h
==============================================================================
--- head/sys/amd64/include/specialreg.h	Tue Apr 12 21:08:34 2011	(r220577)
+++ head/sys/amd64/include/specialreg.h	Tue Apr 12 22:12:23 2011	(r220578)
@@ -196,6 +196,12 @@
 #define	CPUID_HTT_CORES		0x00ff0000
 #define	CPUID_LOCAL_APIC_ID	0xff000000
 
+/*
+ * CPUID instruction 6 ecx info
+ */
+#define	CPUID_PERF_STAT		0x00000001
+#define	CPUID_PERF_BIAS		0x00000008
+
 /* 
  * CPUID instruction 0xb ebx info.
  */

Modified: head/sys/i386/include/specialreg.h
==============================================================================
--- head/sys/i386/include/specialreg.h	Tue Apr 12 21:08:34 2011	(r220577)
+++ head/sys/i386/include/specialreg.h	Tue Apr 12 22:12:23 2011	(r220578)
@@ -195,6 +195,12 @@
 #define	CPUID_HTT_CORES		0x00ff0000
 #define	CPUID_LOCAL_APIC_ID	0xff000000
 
+/*
+ * CPUID instruction 6 ecx info
+ */
+#define	CPUID_PERF_STAT		0x00000001
+#define	CPUID_PERF_BIAS		0x00000008
+
 /* 
  * CPUID instruction 0xb ebx info.
  */

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 22:15:46 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A76E41065673;
	Tue, 12 Apr 2011 22:15:46 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7CE968FC0A;
	Tue, 12 Apr 2011 22:15:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CMFkvg037200;
	Tue, 12 Apr 2011 22:15:46 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CMFkCZ037196;
	Tue, 12 Apr 2011 22:15:46 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104122215.p3CMFkCZ037196@svn.freebsd.org>
From: Jung-uk Kim 
Date: Tue, 12 Apr 2011 22:15:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220579 - in head/sys: amd64/amd64 i386/i386 x86/x86
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 22:15:46 -0000

Author: jkim
Date: Tue Apr 12 22:15:46 2011
New Revision: 220579
URL: http://svn.freebsd.org/changeset/base/220579

Log:
  Probe capability to find effective frequency.  When the TSC is P-state
  invariant, APERF/MPERF ratio can be used to find effective frequency.

Modified:
  head/sys/amd64/amd64/identcpu.c
  head/sys/i386/i386/identcpu.c
  head/sys/x86/x86/tsc.c

Modified: head/sys/amd64/amd64/identcpu.c
==============================================================================
--- head/sys/amd64/amd64/identcpu.c	Tue Apr 12 22:12:23 2011	(r220578)
+++ head/sys/amd64/amd64/identcpu.c	Tue Apr 12 22:15:46 2011	(r220579)
@@ -396,8 +396,11 @@ printcpuinfo(void)
 			 * If this CPU supports P-state invariant TSC then
 			 * mention the capability.
 			 */
-			if (tsc_is_invariant)
+			if (tsc_is_invariant) {
 				printf("\n  TSC: P-state invariant");
+				if (tsc_perf_stat)
+					printf(", performance statistics");
+			}
 
 		}
 	}

Modified: head/sys/i386/i386/identcpu.c
==============================================================================
--- head/sys/i386/i386/identcpu.c	Tue Apr 12 22:12:23 2011	(r220578)
+++ head/sys/i386/i386/identcpu.c	Tue Apr 12 22:15:46 2011	(r220579)
@@ -873,8 +873,11 @@ printcpuinfo(void)
 			 * If this CPU supports P-state invariant TSC then
 			 * mention the capability.
 			 */
-			if (tsc_is_invariant)
+			if (tsc_is_invariant) {
 				printf("\n  TSC: P-state invariant");
+				if (tsc_perf_stat)
+					printf(", performance statistics");
+			}
 
 		}
 	} else if (cpu_vendor_id == CPU_VENDOR_CYRIX) {

Modified: head/sys/x86/x86/tsc.c
==============================================================================
--- head/sys/x86/x86/tsc.c	Tue Apr 12 22:12:23 2011	(r220578)
+++ head/sys/x86/x86/tsc.c	Tue Apr 12 22:15:46 2011	(r220579)
@@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$");
 
 uint64_t	tsc_freq;
 int		tsc_is_invariant;
+int		tsc_perf_stat;
+
 static eventhandler_tag tsc_levels_tag, tsc_pre_tag, tsc_post_tag;
 
 SYSCTL_INT(_kern_timecounter, OID_AUTO, invariant_tsc, CTLFLAG_RDTUN,
@@ -151,6 +153,7 @@ tsc_freq_intel(void)
 static void
 probe_tsc_freq(void)
 {
+	u_int regs[4];
 	uint64_t tsc1, tsc2;
 
 	switch (cpu_vendor_id) {
@@ -178,6 +181,12 @@ probe_tsc_freq(void)
 		break;
 	}
 
+	if (cpu_high >= 6) {
+		do_cpuid(6, regs);
+		if ((regs[2] & CPUID_PERF_STAT) != 0)
+			tsc_perf_stat = 1;
+	}
+
 	if (tsc_skip_calibration) {
 		if (cpu_vendor_id == CPU_VENDOR_INTEL)
 			tsc_freq_intel();

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 22:22:02 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 23DA7106564A;
	Tue, 12 Apr 2011 22:22:02 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1069B8FC08;
	Tue, 12 Apr 2011 22:22:02 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CMM1Gr037348;
	Tue, 12 Apr 2011 22:22:01 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CMM15b037346;
	Tue, 12 Apr 2011 22:22:01 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104122222.p3CMM15b037346@svn.freebsd.org>
From: Jung-uk Kim 
Date: Tue, 12 Apr 2011 22:22:01 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220580 - in head/sys: amd64/include i386/include
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 22:22:02 -0000

Author: jkim
Date: Tue Apr 12 22:22:01 2011
New Revision: 220580
URL: http://svn.freebsd.org/changeset/base/220580

Log:
  Add forgotten declarations for tsc_perf_stat from the previous commit.

Modified:
  head/sys/amd64/include/clock.h
  head/sys/i386/include/clock.h

Modified: head/sys/amd64/include/clock.h
==============================================================================
--- head/sys/amd64/include/clock.h	Tue Apr 12 22:15:46 2011	(r220579)
+++ head/sys/amd64/include/clock.h	Tue Apr 12 22:22:01 2011	(r220580)
@@ -19,6 +19,7 @@ extern u_int	i8254_freq;
 extern int	i8254_max_count;
 extern uint64_t	tsc_freq;
 extern int	tsc_is_invariant;
+extern int	tsc_perf_stat;
 
 void	i8254_init(void);
 

Modified: head/sys/i386/include/clock.h
==============================================================================
--- head/sys/i386/include/clock.h	Tue Apr 12 22:15:46 2011	(r220579)
+++ head/sys/i386/include/clock.h	Tue Apr 12 22:22:01 2011	(r220580)
@@ -19,6 +19,7 @@ extern u_int	i8254_freq;
 extern int	i8254_max_count;
 extern uint64_t	tsc_freq;
 extern int	tsc_is_invariant;
+extern int	tsc_perf_stat;
 
 void	i8254_init(void);
 

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 22:41:53 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 463301065672;
	Tue, 12 Apr 2011 22:41:53 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3697B8FC16;
	Tue, 12 Apr 2011 22:41:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CMfr78037770;
	Tue, 12 Apr 2011 22:41:53 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CMfrhY037768;
	Tue, 12 Apr 2011 22:41:53 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104122241.p3CMfrhY037768@svn.freebsd.org>
From: Jung-uk Kim 
Date: Tue, 12 Apr 2011 22:41:53 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220581 - head/sys/x86/isa
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 22:41:53 -0000

Author: jkim
Date: Tue Apr 12 22:41:52 2011
New Revision: 220581
URL: http://svn.freebsd.org/changeset/base/220581

Log:
  Do not use TSC for DELAY(9) if it not P-state invariant to avoid possible
  foot-shooting.  DELAY() becomes unreliable when TSC frequency varies wildly,
  especially cpufreq(4) and powerd(8) are used at the same time.

Modified:
  head/sys/x86/isa/clock.c

Modified: head/sys/x86/isa/clock.c
==============================================================================
--- head/sys/x86/isa/clock.c	Tue Apr 12 22:22:01 2011	(r220580)
+++ head/sys/x86/isa/clock.c	Tue Apr 12 22:41:52 2011	(r220581)
@@ -263,7 +263,7 @@ delay_tc(int n)
 
 	tc = timecounter;
 	freq = atomic_load_acq_64(&tsc_freq);
-	if (freq != 0) {
+	if (tsc_is_invariant && freq != 0) {
 		func = get_tsc;
 		mask = ~0u;
 	} else {

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 22:48:04 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 05F85106566B;
	Tue, 12 Apr 2011 22:48:04 +0000 (UTC)
	(envelope-from delphij@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id E9AA48FC1C;
	Tue, 12 Apr 2011 22:48:03 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CMm3mZ037933;
	Tue, 12 Apr 2011 22:48:03 GMT (envelope-from delphij@svn.freebsd.org)
Received: (from delphij@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CMm3oL037929;
	Tue, 12 Apr 2011 22:48:03 GMT (envelope-from delphij@svn.freebsd.org)
Message-Id: <201104122248.p3CMm3oL037929@svn.freebsd.org>
From: Xin LI 
Date: Tue, 12 Apr 2011 22:48:03 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220582 - head/lib/libutil
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 22:48:04 -0000

Author: delphij
Date: Tue Apr 12 22:48:03 2011
New Revision: 220582
URL: http://svn.freebsd.org/changeset/base/220582

Log:
  Add support for IEE/IEC (and now also SI) power of two notions of
  prefixes (Ki, Mi, Gi...) for humanize_number(3).
  
  Note that applications has to pass HN_IEC_PREFIXES to use this
  feature for backward compatibility reasons.
  
  Reviewed by:	arundel
  MFC after:	2 weeks

Modified:
  head/lib/libutil/humanize_number.3
  head/lib/libutil/humanize_number.c
  head/lib/libutil/libutil.h

Modified: head/lib/libutil/humanize_number.3
==============================================================================
--- head/lib/libutil/humanize_number.3	Tue Apr 12 22:41:52 2011	(r220581)
+++ head/lib/libutil/humanize_number.3	Tue Apr 12 22:48:03 2011	(r220582)
@@ -28,7 +28,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 25, 2004
+.Dd Apr 12, 2011
 .Dt HUMANIZE_NUMBER 3
 .Os
 .Sh NAME
@@ -68,17 +68,24 @@ then divide
 by 1024 until it will.
 In this case, prefix
 .Fa suffix
-with the appropriate SI designator.
+with the appropriate designator.
 The
 .Fn humanize_number
-function
-follows the traditional computer science conventions rather than the proposed
-SI power of two convention.
+function follows the traditional computer science conventions by
+default, rather than the IEE/IEC (and now also SI) power of two
+convention or the power of ten notion.
+This behaviour however can be altered by specifying the
+.Dv HN_DIVISOR_1000
+and
+.Dv HN_IEC_PREFIXES
+flags.
 .Pp
-The prefixes are:
+The traditional
+.Pq default
+prefixes are:
 .Bl -column "Prefix" "Description" "1000000000000000000" -offset indent
 .It Sy "Prefix" Ta Sy "Description" Ta Sy "Multiplier" Ta Sy "Multiplier 1000x"
-.It Li k Ta No kilo Ta 1024 Ta 1000
+.It Li (note) Ta No kilo Ta 1024 Ta 1000
 .It Li M Ta No mega Ta 1048576 Ta 1000000
 .It Li G Ta No giga Ta 1073741824 Ta 1000000000
 .It Li T Ta No tera Ta 1099511627776 Ta 1000000000000
@@ -86,6 +93,20 @@ The prefixes are:
 .It Li E Ta No exa Ta 1152921504606846976 Ta 1000000000000000000
 .El
 .Pp
+Note:
+An uppercase K indicates a power of two, a lowercase k a power of ten.
+.Pp
+The IEE/IEC (and now also SI) power of two prefixes are:
+.Bl -column "Prefix" "Description" "1000000000000000000" -offset indent
+.It Sy "Prefix" Ta Sy "Description" Ta Sy "Multiplier"
+.It Li Ki Ta No kibi Ta 1024
+.It Li Mi Ta No mebi Ta 1048576
+.It Li Gi Ta No gibi Ta 1073741824
+.It Li Ti Ta No tebi Ta 1099511627776
+.It Li Pi Ta No pebi Ta 1125899906842624
+.It Li Ei Ta No exbi Ta 1152921504606846976
+.El
+.Pp
 The
 .Fa len
 argument must be at least 4 plus the length of
@@ -94,7 +115,12 @@ in order to ensure a useful result is ge
 .Fa buf .
 To use a specific prefix, specify this as
 .Fa scale
-(multiplier = 1024 ^ scale).
+.Po multiplier = 1024 ^ scale;
+when
+.Dv HN_DIVISOR_1000
+is specified,
+multiplier = 1000 ^ scale
+.Pc .
 This cannot be combined with any of the
 .Fa scale
 flags below.
@@ -127,6 +153,11 @@ Use
 Divide
 .Fa number
 with 1000 instead of 1024.
+.It Dv HN_IEC_PREFIXES
+Use the IEE/IEC notion of prefixes (Ki, Mi, Gi...).
+This flag has no effect when
+.Dv HN_DIVISOR_1000
+is also specified.
 .El
 .Sh RETURN VALUES
 The
@@ -141,6 +172,18 @@ If
 is specified, the prefix index number will be returned instead.
 .Sh SEE ALSO
 .Xr expand_number 3
+.Sh STANDARDS
+The
+.Dv HN_DIVISOR_1000
+and
+.Dv HN_IEC_PREFIXES
+flags
+conform to
+.Tn ISO/IEC
+Std\~80000-13:2008
+and
+.Tn IEEE
+Std\~1541-2002.
 .Sh HISTORY
 The
 .Fn humanize_number
@@ -148,3 +191,7 @@ function first appeared in
 .Nx 2.0
 and then in
 .Fx 5.3 .
+The
+.Dv HN_IEC_PREFIXES
+flag was introduced in
+.Fx 9.0 .

Modified: head/lib/libutil/humanize_number.c
==============================================================================
--- head/lib/libutil/humanize_number.c	Tue Apr 12 22:41:52 2011	(r220581)
+++ head/lib/libutil/humanize_number.c	Tue Apr 12 22:48:03 2011	(r220582)
@@ -42,45 +42,58 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+static const int maxscale = 7;
+
 int
 humanize_number(char *buf, size_t len, int64_t quotient,
     const char *suffix, int scale, int flags)
 {
 	const char *prefixes, *sep;
-	int	i, r, remainder, maxscale, s1, s2, sign;
+	int	i, r, remainder, s1, s2, sign;
 	int64_t	divisor, max;
 	size_t	baselen;
 
 	assert(buf != NULL);
 	assert(suffix != NULL);
 	assert(scale >= 0);
+	assert(scale < maxscale || (((scale & (HN_AUTOSCALE | HN_GETSCALE)) != 0)));
+	assert(!((flags & HN_DIVISOR_1000) && (flags & HN_IEC_PREFIXES)));
 
 	remainder = 0;
 
-	if (flags & HN_DIVISOR_1000) {
-		/* SI for decimal multiplies */
-		divisor = 1000;
-		if (flags & HN_B)
-			prefixes = "B\0k\0M\0G\0T\0P\0E";
-		else
-			prefixes = "\0\0k\0M\0G\0T\0P\0E";
-	} else {
+	if (flags & HN_IEC_PREFIXES) {
+		baselen = 2;
 		/*
-		 * binary multiplies
-		 * XXX IEC 60027-2 recommends Ki, Mi, Gi...
+		 * Use the prefixes for power of two recommended by
+		 * the International Electrotechnical Commission
+		 * (IEC) in IEC 80000-3 (i.e. Ki, Mi, Gi...).
+		 *
+		 * HN_IEC_PREFIXES implies a divisor of 1024 here
+		 * (use of HN_DIVISOR_1000 would have triggered
+		 * an assertion earlier).
 		 */
 		divisor = 1024;
 		if (flags & HN_B)
-			prefixes = "B\0K\0M\0G\0T\0P\0E";
+			prefixes = "B\0\0Ki\0Mi\0Gi\0Ti\0Pi\0Ei";
+		else
+			prefixes = "\0\0Ki\0Mi\0Gi\0Ti\0Pi\0Ei";
+	} else {
+		baselen = 1;
+		if (flags & HN_DIVISOR_1000)
+			divisor = 1000;
+		else
+			divisor = 1024;
+
+		if (flags & HN_B)
+			prefixes = "B\0\0k\0\0M\0\0G\0\0T\0\0P\0\0E";
 		else
-			prefixes = "\0\0K\0M\0G\0T\0P\0E";
+			prefixes = "\0\0\0k\0\0M\0\0G\0\0T\0\0P\0\0E";
 	}
 
-#define	SCALE2PREFIX(scale)	(&prefixes[(scale) << 1])
-	maxscale = 7;
+#define	SCALE2PREFIX(scale)	(&prefixes[(scale) * 3])
 
-	if (scale >= maxscale &&
-	    (scale & (HN_AUTOSCALE | HN_GETSCALE)) == 0)
+	if (scale < 0 || (scale >= maxscale &&
+	    (scale & (HN_AUTOSCALE | HN_GETSCALE)) == 0))
 		return (-1);
 
 	if (buf == NULL || suffix == NULL)
@@ -91,10 +104,10 @@ humanize_number(char *buf, size_t len, i
 	if (quotient < 0) {
 		sign = -1;
 		quotient = -quotient;
-		baselen = 3;		/* sign, digit, prefix */
+		baselen += 2;		/* sign, digit */
 	} else {
 		sign = 1;
-		baselen = 2;		/* digit, prefix */
+		baselen += 1;		/* digit */
 	}
 	if (flags & HN_NOSPACE)
 		sep = "";

Modified: head/lib/libutil/libutil.h
==============================================================================
--- head/lib/libutil/libutil.h	Tue Apr 12 22:41:52 2011	(r220581)
+++ head/lib/libutil/libutil.h	Tue Apr 12 22:48:03 2011	(r220582)
@@ -220,7 +220,9 @@ __END_DECLS
 #define HN_NOSPACE		0x02
 #define HN_B			0x04
 #define HN_DIVISOR_1000		0x08
+#define HN_IEC_PREFIXES		0x10
 
+/* maxscale = 0x07 */
 #define HN_GETSCALE		0x10
 #define HN_AUTOSCALE		0x20
 

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 23:04:02 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 61029106566C;
	Tue, 12 Apr 2011 23:04:02 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 504E48FC12;
	Tue, 12 Apr 2011 23:04:02 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CN42iC038264;
	Tue, 12 Apr 2011 23:04:02 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CN42O3038260;
	Tue, 12 Apr 2011 23:04:02 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104122304.p3CN42O3038260@svn.freebsd.org>
From: Jung-uk Kim 
Date: Tue, 12 Apr 2011 23:04:02 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220583 - in head/sys: amd64/amd64 i386/i386 pc98/pc98
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 23:04:02 -0000

Author: jkim
Date: Tue Apr 12 23:04:01 2011
New Revision: 220583
URL: http://svn.freebsd.org/changeset/base/220583

Log:
  Reinstate cpu_est_clockrate() support for P-state invariant TSC if APERF and
  MPERF MSRs are available.  It was disabled in r216443.  Remove the earlier
  hack to subtract 0.5% from the calibrated frequency as DELAY(9) is little
  bit more reliable now.

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/i386/i386/machdep.c
  head/sys/pc98/pc98/machdep.c

Modified: head/sys/amd64/amd64/machdep.c
==============================================================================
--- head/sys/amd64/amd64/machdep.c	Tue Apr 12 22:48:03 2011	(r220582)
+++ head/sys/amd64/amd64/machdep.c	Tue Apr 12 23:04:01 2011	(r220583)
@@ -545,23 +545,20 @@ cpu_flush_dcache(void *ptr, size_t len)
 int
 cpu_est_clockrate(int cpu_id, uint64_t *rate)
 {
+	uint64_t tsc1, tsc2;
+	uint64_t acnt, mcnt;
 	register_t reg;
-	uint64_t freq, tsc1, tsc2;
 
 	if (pcpu_find(cpu_id) == NULL || rate == NULL)
 		return (EINVAL);
-	freq = atomic_load_acq_64(&tsc_freq);
 
-	/* If TSC is P-state invariant, DELAY(9) based logic fails. */
-	if (tsc_is_invariant && freq != 0)
+	/*
+	 * If TSC is P-state invariant and APERF/MPERF MSRs do not exist,
+	 * DELAY(9) based logic fails.
+	 */
+	if (tsc_is_invariant && !tsc_perf_stat)
 		return (EOPNOTSUPP);
 
-	/* If we're booting, trust the rate calibrated moments ago. */
-	if (cold && freq != 0) {
-		*rate = freq;
-		return (0);
-	}
-
 #ifdef SMP
 	if (smp_cpus > 1) {
 		/* Schedule ourselves on the indicated cpu. */
@@ -573,10 +570,23 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 
 	/* Calibrate by measuring a short delay. */
 	reg = intr_disable();
-	tsc1 = rdtsc();
-	DELAY(1000);
-	tsc2 = rdtsc();
-	intr_restore(reg);
+	if (tsc_is_invariant) {
+		wrmsr(MSR_MPERF, 0);
+		wrmsr(MSR_APERF, 0);
+		tsc1 = rdtsc();
+		DELAY(1000);
+		mcnt = rdmsr(MSR_MPERF);
+		acnt = rdmsr(MSR_APERF);
+		tsc2 = rdtsc();
+		intr_restore(reg);
+		*rate = (tsc2 - tsc1) / 1000 * acnt / mcnt * 1000000;
+	} else {
+		tsc1 = rdtsc();
+		DELAY(1000);
+		tsc2 = rdtsc();
+		intr_restore(reg);
+		*rate = (tsc2 - tsc1) * 1000;
+	}
 
 #ifdef SMP
 	if (smp_cpus > 1) {
@@ -586,17 +596,6 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 	}
 #endif
 
-	tsc2 -= tsc1;
-	if (freq != 0) {
-		*rate = tsc2 * 1000;
-		return (0);
-	}
-
-	/*
-	 * Subtract 0.5% of the total.  Empirical testing has shown that
-	 * overhead in DELAY() works out to approximately this value.
-	 */
-	*rate = tsc2 * 1000 - tsc2 * 5;
 	return (0);
 }
 

Modified: head/sys/i386/i386/machdep.c
==============================================================================
--- head/sys/i386/i386/machdep.c	Tue Apr 12 22:48:03 2011	(r220582)
+++ head/sys/i386/i386/machdep.c	Tue Apr 12 23:04:01 2011	(r220583)
@@ -1136,25 +1136,22 @@ cpu_flush_dcache(void *ptr, size_t len)
 int
 cpu_est_clockrate(int cpu_id, uint64_t *rate)
 {
+	uint64_t tsc1, tsc2;
+	uint64_t acnt, mcnt;
 	register_t reg;
-	uint64_t freq, tsc1, tsc2;
 
 	if (pcpu_find(cpu_id) == NULL || rate == NULL)
 		return (EINVAL);
 	if ((cpu_feature & CPUID_TSC) == 0)
 		return (EOPNOTSUPP);
-	freq = atomic_load_acq_64(&tsc_freq);
 
-	/* If TSC is P-state invariant, DELAY(9) based logic fails. */
-	if (tsc_is_invariant && freq != 0)
+	/*
+	 * If TSC is P-state invariant and APERF/MPERF MSRs do not exist,
+	 * DELAY(9) based logic fails.
+	 */
+	if (tsc_is_invariant && !tsc_perf_stat)
 		return (EOPNOTSUPP);
 
-	/* If we're booting, trust the rate calibrated moments ago. */
-	if (cold && freq != 0) {
-		*rate = freq;
-		return (0);
-	}
-
 #ifdef SMP
 	if (smp_cpus > 1) {
 		/* Schedule ourselves on the indicated cpu. */
@@ -1166,10 +1163,23 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 
 	/* Calibrate by measuring a short delay. */
 	reg = intr_disable();
-	tsc1 = rdtsc();
-	DELAY(1000);
-	tsc2 = rdtsc();
-	intr_restore(reg);
+	if (tsc_is_invariant) {
+		wrmsr(MSR_MPERF, 0);
+		wrmsr(MSR_APERF, 0);
+		tsc1 = rdtsc();
+		DELAY(1000);
+		mcnt = rdmsr(MSR_MPERF);
+		acnt = rdmsr(MSR_APERF);
+		tsc2 = rdtsc();
+		intr_restore(reg);
+		*rate = (tsc2 - tsc1) / 1000 * acnt / mcnt * 1000000;
+	} else {
+		tsc1 = rdtsc();
+		DELAY(1000);
+		tsc2 = rdtsc();
+		intr_restore(reg);
+		*rate = (tsc2 - tsc1) * 1000;
+	}
 
 #ifdef SMP
 	if (smp_cpus > 1) {
@@ -1179,17 +1189,6 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 	}
 #endif
 
-	tsc2 -= tsc1;
-	if (freq != 0) {
-		*rate = tsc2 * 1000;
-		return (0);
-	}
-
-	/*
-	 * Subtract 0.5% of the total.  Empirical testing has shown that
-	 * overhead in DELAY() works out to approximately this value.
-	 */
-	*rate = tsc2 * 1000 - tsc2 * 5;
 	return (0);
 }
 

Modified: head/sys/pc98/pc98/machdep.c
==============================================================================
--- head/sys/pc98/pc98/machdep.c	Tue Apr 12 22:48:03 2011	(r220582)
+++ head/sys/pc98/pc98/machdep.c	Tue Apr 12 23:04:01 2011	(r220583)
@@ -1071,20 +1071,13 @@ cpu_flush_dcache(void *ptr, size_t len)
 int
 cpu_est_clockrate(int cpu_id, uint64_t *rate)
 {
+	uint64_t tsc1, tsc2;
 	register_t reg;
-	uint64_t freq, tsc1, tsc2;
 
 	if (pcpu_find(cpu_id) == NULL || rate == NULL)
 		return (EINVAL);
 	if ((cpu_feature & CPUID_TSC) == 0)
 		return (EOPNOTSUPP);
-	freq = atomic_load_acq_64(&tsc_freq);
-
-	/* If we're booting, trust the rate calibrated moments ago. */
-	if (cold && freq != 0) {
-		*rate = freq;
-		return (0);
-	}
 
 #ifdef SMP
 	if (smp_cpus > 1) {
@@ -1101,6 +1094,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 	DELAY(1000);
 	tsc2 = rdtsc();
 	intr_restore(reg);
+	*rate = (tsc2 - tsc1) * 1000;
 
 #ifdef SMP
 	if (smp_cpus > 1) {
@@ -1110,17 +1104,6 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 	}
 #endif
 
-	tsc2 -= tsc1;
-	if (freq != 0) {
-		*rate = tsc2 * 1000;
-		return (0);
-	}
-
-	/*
-	 * Subtract 0.5% of the total.  Empirical testing has shown that
-	 * overhead in DELAY() works out to approximately this value.
-	 */
-	*rate = tsc2 * 1000 - tsc2 * 5;
 	return (0);
 }
 

From owner-svn-src-head@FreeBSD.ORG  Tue Apr 12 23:49:08 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0CD34106564A;
	Tue, 12 Apr 2011 23:49:08 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id F0AD08FC08;
	Tue, 12 Apr 2011 23:49:07 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3CNn7ri039182;
	Tue, 12 Apr 2011 23:49:07 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3CNn7kK039179;
	Tue, 12 Apr 2011 23:49:07 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104122349.p3CNn7kK039179@svn.freebsd.org>
From: Jung-uk Kim 
Date: Tue, 12 Apr 2011 23:49:07 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Tue, 12 Apr 2011 23:49:08 -0000

Author: jkim
Date: Tue Apr 12 23:49:07 2011
New Revision: 220584
URL: http://svn.freebsd.org/changeset/base/220584

Log:
  Reduce errors in effective frequency calculation.

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/i386/i386/machdep.c

Modified: head/sys/amd64/amd64/machdep.c
==============================================================================
--- head/sys/amd64/amd64/machdep.c	Tue Apr 12 23:04:01 2011	(r220583)
+++ head/sys/amd64/amd64/machdep.c	Tue Apr 12 23:49:07 2011	(r220584)
@@ -546,7 +546,7 @@ int
 cpu_est_clockrate(int cpu_id, uint64_t *rate)
 {
 	uint64_t tsc1, tsc2;
-	uint64_t acnt, mcnt;
+	uint64_t acnt, mcnt, perf;
 	register_t reg;
 
 	if (pcpu_find(cpu_id) == NULL || rate == NULL)
@@ -579,7 +579,8 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 		acnt = rdmsr(MSR_APERF);
 		tsc2 = rdtsc();
 		intr_restore(reg);
-		*rate = (tsc2 - tsc1) / 1000 * acnt / mcnt * 1000000;
+		perf = 1000 * acnt / mcnt;
+		*rate = (tsc2 - tsc1) * perf;
 	} else {
 		tsc1 = rdtsc();
 		DELAY(1000);

Modified: head/sys/i386/i386/machdep.c
==============================================================================
--- head/sys/i386/i386/machdep.c	Tue Apr 12 23:04:01 2011	(r220583)
+++ head/sys/i386/i386/machdep.c	Tue Apr 12 23:49:07 2011	(r220584)
@@ -1137,7 +1137,7 @@ int
 cpu_est_clockrate(int cpu_id, uint64_t *rate)
 {
 	uint64_t tsc1, tsc2;
-	uint64_t acnt, mcnt;
+	uint64_t acnt, mcnt, perf;
 	register_t reg;
 
 	if (pcpu_find(cpu_id) == NULL || rate == NULL)
@@ -1172,7 +1172,8 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 		acnt = rdmsr(MSR_APERF);
 		tsc2 = rdtsc();
 		intr_restore(reg);
-		*rate = (tsc2 - tsc1) / 1000 * acnt / mcnt * 1000000;
+		perf = 1000 * acnt / mcnt;
+		*rate = (tsc2 - tsc1) * perf;
 	} else {
 		tsc1 = rdtsc();
 		DELAY(1000);

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 00:03:49 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E31D6106566C;
	Wed, 13 Apr 2011 00:03:49 +0000 (UTC)
	(envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D2E338FC14;
	Wed, 13 Apr 2011 00:03:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3D03nq2039529;
	Wed, 13 Apr 2011 00:03:49 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3D03nPn039526;
	Wed, 13 Apr 2011 00:03:49 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201104130003.p3D03nPn039526@svn.freebsd.org>
From: Rick Macklem 
Date: Wed, 13 Apr 2011 00:03:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220585 - head/sys/rpc
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 00:03:50 -0000

Author: rmacklem
Date: Wed Apr 13 00:03:49 2011
New Revision: 220585
URL: http://svn.freebsd.org/changeset/base/220585

Log:
  Fix a couple of mbuf leaks introduced by r217242. I do
  not believe that these leaks had a practical impact,
  since the situations in which they would have occurred
  would have been extremely rare.
  
  MFC after:	2 weeks

Modified:
  head/sys/rpc/clnt_dg.c
  head/sys/rpc/clnt_vc.c

Modified: head/sys/rpc/clnt_dg.c
==============================================================================
--- head/sys/rpc/clnt_dg.c	Tue Apr 12 23:49:07 2011	(r220584)
+++ head/sys/rpc/clnt_dg.c	Wed Apr 13 00:03:49 2011	(r220585)
@@ -1086,11 +1086,13 @@ clnt_dg_soupcall(struct socket *so, void
 		/*
 		 * The XID is in the first uint32_t of the reply.
 		 */
-		if (m->m_len < sizeof(xid) && m_length(m, NULL) < sizeof(xid))
+		if (m->m_len < sizeof(xid) && m_length(m, NULL) < sizeof(xid)) {
 			/*
 			 * Should never happen.
 			 */
+			m_freem(m);
 			continue;
+		}
 
 		m_copydata(m, 0, sizeof(xid), (char *)&xid);
 		xid = ntohl(xid);

Modified: head/sys/rpc/clnt_vc.c
==============================================================================
--- head/sys/rpc/clnt_vc.c	Tue Apr 12 23:49:07 2011	(r220584)
+++ head/sys/rpc/clnt_vc.c	Wed Apr 13 00:03:49 2011	(r220585)
@@ -973,8 +973,11 @@ clnt_vc_soupcall(struct socket *so, void
 				 * the reply.
 				 */
 				if (ct->ct_record->m_len < sizeof(xid) &&
-				    m_length(ct->ct_record, NULL) < sizeof(xid))
+				    m_length(ct->ct_record, NULL) <
+				    sizeof(xid)) {
+					m_freem(ct->ct_record);
 					break;
+				}
 				m_copydata(ct->ct_record, 0, sizeof(xid),
 				    (char *)&xid);
 				xid = ntohl(xid);

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 00:36:20 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 25F241065674;
	Wed, 13 Apr 2011 00:36:20 +0000 (UTC) (envelope-from gad@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1407C8FC16;
	Wed, 13 Apr 2011 00:36:20 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3D0aJMH040247;
	Wed, 13 Apr 2011 00:36:19 GMT (envelope-from gad@svn.freebsd.org)
Received: (from gad@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3D0aJYn040243;
	Wed, 13 Apr 2011 00:36:19 GMT (envelope-from gad@svn.freebsd.org)
Message-Id: <201104130036.p3D0aJYn040243@svn.freebsd.org>
From: Garance A Drosehn 
Date: Wed, 13 Apr 2011 00:36:19 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220586 - head/usr.sbin/lpr/common_source
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 00:36:20 -0000

Author: gad
Date: Wed Apr 13 00:36:19 2011
New Revision: 220586
URL: http://svn.freebsd.org/changeset/base/220586

Log:
  - Fix the code that matches userids in match_jobspec().  It needs to check
    the username-for-accounting field (P), not the username-for-headerpage (L).
    These are usually the same value, except that control files do not have
    the username-for-headerpage field if the user has requested no header page.
  - Also rename the cji_username field to cji_headruser, to make it clear that
    the value should only be used for the header page.  (aka banner page)
  
  MFC after:	3 weeks

Modified:
  head/usr.sbin/lpr/common_source/ctlinfo.c
  head/usr.sbin/lpr/common_source/ctlinfo.h
  head/usr.sbin/lpr/common_source/matchjobs.c

Modified: head/usr.sbin/lpr/common_source/ctlinfo.c
==============================================================================
--- head/usr.sbin/lpr/common_source/ctlinfo.c	Wed Apr 13 00:03:49 2011	(r220585)
+++ head/usr.sbin/lpr/common_source/ctlinfo.c	Wed Apr 13 00:36:19 2011	(r220586)
@@ -1,6 +1,6 @@
 /*
  * ------+---------+---------+---------+---------+---------+---------+---------*
- * Copyright (c) 2001  - Garance Alistair Drosehn .
+ * Copyright (c) 2001,2011  - Garance Alistair Drosehn .
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -248,7 +248,7 @@ ctl_freeinf(struct cjobinfo *cjinf)
 	/* [cpriv->pub.cji_fname is part of cpriv-malloced area] */
 	FREESTR(cpriv->pub.cji_jobname);
 	FREESTR(cpriv->pub.cji_mailto);
-	FREESTR(cpriv->pub.cji_username);
+	FREESTR(cpriv->pub.cji_headruser);
 
 	if (cpriv->cji_fstream != NULL) {
 		fclose(cpriv->cji_fstream);
@@ -343,7 +343,7 @@ ctl_readcf(const char *ptrname, const ch
 			cpriv->pub.cji_jobname = strdup(lbuff);
 			break;
 		case 'L':
-			cpriv->pub.cji_username = strdup(lbuff);
+			cpriv->pub.cji_headruser = strdup(lbuff);
 			break;
 		case 'M':
 			/*
@@ -586,8 +586,8 @@ ctl_renametf(const char *ptrname, const 
 		fprintf(newcf, "C%s\n", cjinf->cji_class);
 	if (cjinf->cji_jobname != NULL)
 		fprintf(newcf, "J%s\n", cjinf->cji_jobname);
-	if (cjinf->cji_username != NULL)
-		fprintf(newcf, "L%s\n", cjinf->cji_username);
+	if (cjinf->cji_headruser != NULL)
+		fprintf(newcf, "L%s\n", cjinf->cji_headruser);
 
 	/*
 	 * This should probably add more sanity checks on mailto value.
@@ -832,7 +832,7 @@ ctl_dumpcji(FILE *dbg_stream, const char
 	PRINTSTR("cf-fname", cpriv->pub.cji_fname);
 	PRINTSTR("jobname.J", cpriv->pub.cji_jobname);
 	PRINTSTR("mailto.M", cpriv->pub.cji_mailto);
-	PRINTSTR("hdruser.L", cpriv->pub.cji_username);
+	PRINTSTR("headruser.L", cpriv->pub.cji_headruser);
 
 	ctl_dbgline++;
 	fprintf(dbg_stream, "%4d] %12s = ", ctl_dbgline, "*cjprivate");

Modified: head/usr.sbin/lpr/common_source/ctlinfo.h
==============================================================================
--- head/usr.sbin/lpr/common_source/ctlinfo.h	Wed Apr 13 00:03:49 2011	(r220585)
+++ head/usr.sbin/lpr/common_source/ctlinfo.h	Wed Apr 13 00:36:19 2011	(r220586)
@@ -1,6 +1,6 @@
 /*
  * ------+---------+---------+---------+---------+---------+---------+---------*
- * Copyright (c) 2001  - Garance Alistair Drosehn .
+ * Copyright (c) 2001,2011  - Garance Alistair Drosehn .
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@ struct cjobinfo {
 	char	*cji_fname;		/* filename of the control file */
 	char	*cji_jobname;		/* job-name (for banner) */
 	char	*cji_mailto;		/* userid to send email to (or null) */
-	char	*cji_username;		/* "literal" user-name (for banner) or
+	char	*cji_headruser;		/* "literal" user-name (for banner) or
 					 * NULL if no banner-page is wanted */
 	struct cjprivate *cji_priv;
 };

Modified: head/usr.sbin/lpr/common_source/matchjobs.c
==============================================================================
--- head/usr.sbin/lpr/common_source/matchjobs.c	Wed Apr 13 00:03:49 2011	(r220585)
+++ head/usr.sbin/lpr/common_source/matchjobs.c	Wed Apr 13 00:36:19 2011	(r220586)
@@ -1,6 +1,6 @@
 /*
  * ------+---------+---------+---------+---------+---------+---------+---------*
- * Copyright (c) 2002   - Garance Alistair Drosehn .
+ * Copyright (c) 2002,2011   - Garance Alistair Drosehn .
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -453,7 +453,7 @@ match_jobspec(struct jobqueue *jq, struc
 		cfinf = ctl_readcf("fakeq", jq->job_cfname);
 		if (cfinf == NULL)
 			goto nomatch;
-		if (fnmatch(jspec->wanteduser, cfinf->cji_username, 0) != 0)
+		if (fnmatch(jspec->wanteduser, cfinf->cji_acctuser, 0) != 0)
 			goto nomatch;
 	}
 
@@ -467,7 +467,7 @@ match_jobspec(struct jobqueue *jq, struc
 		 * pattern), then the caller's "doentry()" routine might
 		 * want to know the userid of this job that matched.
 		 */
-		jspec->matcheduser = strdup(cfinf->cji_username);
+		jspec->matcheduser = strdup(cfinf->cji_acctuser);
 	}
 #if DEBUG_SCANJS
 	printf("\t [ job matched! ]\n");

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 02:40:45 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BE0601065676;
	Wed, 13 Apr 2011 02:40:45 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A9FD68FC1B;
	Wed, 13 Apr 2011 02:40:45 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3D2ejc3042746;
	Wed, 13 Apr 2011 02:40:45 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3D2ejqg042741;
	Wed, 13 Apr 2011 02:40:45 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104130240.p3D2ejqg042741@svn.freebsd.org>
From: Adrian Chadd 
Date: Wed, 13 Apr 2011 02:40:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220587 - in head/sys: conf dev/ath/ath_hal/ar9002
	modules/ath
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 02:40:45 -0000

Author: adrian
Date: Wed Apr 13 02:40:45 2011
New Revision: 220587
URL: http://svn.freebsd.org/changeset/base/220587

Log:
  Add the initial AR9285 PHY glue for supporting antenna diversity.
  This code isn't currently used anywhere; it's just linked into the build.

Added:
  head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.c   (contents, props changed)
  head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.h   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/modules/ath/Makefile

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Wed Apr 13 00:36:19 2011	(r220586)
+++ head/sys/conf/files	Wed Apr 13 02:40:45 2011	(r220587)
@@ -773,6 +773,8 @@ dev/ath/ath_hal/ar9002/ar9285_reset.c op
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9285_cal.c optional ath_hal | ath_ar9285 \ 
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
+dev/ath/ath_hal/ar9002/ar9285_phy.c optional ath_hal | ath_ar9285 \ 
+	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # rf backends
 dev/ath/ath_hal/ar5212/ar2316.c	optional ath_rf2316 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"

Added: head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.c	Wed Apr 13 02:40:45 2011	(r220587)
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2008-2010 Atheros Communications Inc.
+ * Copyright (c) 2010-2011 Adrian Chadd, Xenion Pty Ltd.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (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$
+ */
+#include "opt_ah.h"
+
+#include "ah.h"
+#include "ah_internal.h"
+#include "ah_devid.h"
+#include "ah_eeprom_v4k.h"
+
+#include "ar9002/ar9280.h"
+#include "ar9002/ar9285.h"
+#include "ar5416/ar5416reg.h"
+#include "ar5416/ar5416phy.h"
+#include "ar9002/ar9285phy.h"
+#include "ar9002/ar9285_phy.h"
+
+void
+ar9285_antdiv_comb_conf_get(struct ath_hal *ah,
+    struct ar9285_antcomb_conf *antconf)
+{
+	uint32_t regval;
+
+	regval = OS_REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL);
+	antconf->main_lna_conf = (regval & AR_PHY_9285_ANT_DIV_MAIN_LNACONF) >>
+				  AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S;
+	antconf->alt_lna_conf = (regval & AR_PHY_9285_ANT_DIV_ALT_LNACONF) >>
+				 AR_PHY_9285_ANT_DIV_ALT_LNACONF_S;
+	antconf->fast_div_bias = (regval & AR_PHY_9285_FAST_DIV_BIAS) >>
+				  AR_PHY_9285_FAST_DIV_BIAS_S;
+}
+
+void
+ar9285_antdiv_comb_conf_set(struct ath_hal *ah,
+    struct ar9285_antcomb_conf *antconf)
+{
+	uint32_t regval;
+
+	regval = OS_REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL);
+	regval &= ~(AR_PHY_9285_ANT_DIV_MAIN_LNACONF |
+		    AR_PHY_9285_ANT_DIV_ALT_LNACONF |
+		    AR_PHY_9285_FAST_DIV_BIAS);
+	regval |= ((antconf->main_lna_conf << AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S)
+		   & AR_PHY_9285_ANT_DIV_MAIN_LNACONF);
+	regval |= ((antconf->alt_lna_conf << AR_PHY_9285_ANT_DIV_ALT_LNACONF_S)
+		   & AR_PHY_9285_ANT_DIV_ALT_LNACONF);
+	regval |= ((antconf->fast_div_bias << AR_PHY_9285_FAST_DIV_BIAS_S)
+		   & AR_PHY_9285_FAST_DIV_BIAS);
+
+	OS_REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval);
+}
+
+/*
+ * Check whether antenna diversity should be enabled
+ */
+int
+ar9285_check_div_comb(struct ath_hal *ah)
+{
+	uint8_t ant_div_ctl1;
+	HAL_EEPROM_v4k *ee = AH_PRIVATE(ah)->ah_eeprom;
+        const MODAL_EEP4K_HEADER *pModal = &ee->ee_base.modalHeader;
+
+	if (! AR_SREV_KITE(ah))
+		return 0;
+
+	if (pModal->version < 3)
+		return 0;
+
+	ant_div_ctl1 = pModal->antdiv_ctl1;
+	if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1))
+		return 1;
+
+	return 0;
+}

Added: head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.h	Wed Apr 13 02:40:45 2011	(r220587)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008-2010 Atheros Communications Inc.
+ * Copyright (c) 2010-2011 Adrian Chadd, Xenion Pty Ltd.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (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$
+ */
+#ifndef	__AR9285_PHY_H__
+#define	__AR9285_PHY_H__
+
+/*
+ * Manipulate AR9285 antenna diversity configuration
+ */
+struct ar9285_antcomb_conf {
+	uint8_t main_lna_conf;
+	uint8_t alt_lna_conf;
+	uint8_t fast_div_bias;
+};
+
+extern	void ar9285_antdiv_comb_conf_set(struct ath_hal *ah,
+		struct ar9285_antcomb_conf *antconf);
+extern	void ar9285_antdiv_comb_conf_get(struct ath_hal *ah,
+		struct ar9285_antcomb_conf *antconf);
+extern	int ar9285_check_div_comb(struct ath_hal *ah);
+
+#endif

Modified: head/sys/modules/ath/Makefile
==============================================================================
--- head/sys/modules/ath/Makefile	Wed Apr 13 00:36:19 2011	(r220586)
+++ head/sys/modules/ath/Makefile	Wed Apr 13 02:40:45 2011	(r220587)
@@ -98,7 +98,7 @@ SRCS+=	ar9160_attach.c
 
 .PATH:	${.CURDIR}/../../dev/ath/ath_hal/ar9002
 SRCS+=	ar9280.c ar9280_attach.c ar9280_olc.c
-SRCS+=	ar9285.c ar9285_reset.c ar9285_attach.c ar9285_cal.c
+SRCS+=	ar9285.c ar9285_reset.c ar9285_attach.c ar9285_cal.c ar9285_phy.c
 
 # NB: rate control is bound to the driver by symbol names so only pick one
 .if ${ATH_RATE} == "sample"

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 02:55:07 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 014BE1065708;
	Wed, 13 Apr 2011 02:55:06 +0000 (UTC)
	(envelope-from adrian.chadd@gmail.com)
Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50])
	by mx1.freebsd.org (Postfix) with ESMTP id 2C0B68FC18;
	Wed, 13 Apr 2011 02:55:05 +0000 (UTC)
Received: by wwc33 with SMTP id 33so182624wwc.31
	for ; Tue, 12 Apr 2011 19:55:05 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:sender:in-reply-to:references:date
	:x-google-sender-auth:message-id:subject:from:to:cc:content-type;
	bh=wkpuXoU0oQ+ROvj0r5EbFwUwIVnQR5xC/VQepXsbtV0=;
	b=kFJ6QyeqvzWqOZhAAj6VbXRkikVpAU/4JThGrTizLzId9oi/YWBJFZTNNMqimz8Inm
	NCSVSLxvBP/fTqf2pcf5MrK5FQAGgE8eNzX2gTyn7QZPLtzbLu+tGe32K8oucixF4m+k
	RomRotUxpz1lOeWOZ80fJUgqwrL2AgW2HEEXI=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:sender:in-reply-to:references:date
	:x-google-sender-auth:message-id:subject:from:to:cc:content-type;
	b=lFTLcn6cpAn+EO6h4LqKQGhvupVtGnBiBw4lwkdAxKrAdb5sYNTh/hKBZzRFn3gUDs
	bN564pTemlKL3BhyxuKFoxQkJOqSoLb58Y2qjsw7DhV1FkGxRWRtO9KoBlLeXSfloiRy
	5vZA4p64XGrV4v3RCOEHFi/yqrhchM4NsqK80=
MIME-Version: 1.0
Received: by 10.227.173.141 with SMTP id p13mr3742667wbz.64.1302661977426;
	Tue, 12 Apr 2011 19:32:57 -0700 (PDT)
Sender: adrian.chadd@gmail.com
Received: by 10.227.132.199 with HTTP; Tue, 12 Apr 2011 19:32:57 -0700 (PDT)
In-Reply-To: 
References: <201104120810.p3C8AQs0014704@svn.freebsd.org>
	
Date: Wed, 13 Apr 2011 10:32:57 +0800
X-Google-Sender-Auth: fey1fQ9JrTBqxVrJj2Zocaq-7L8
Message-ID: 
From: Adrian Chadd 
To: Andrew Thompson 
Content-Type: text/plain; charset=ISO-8859-1
X-Content-Filtered-By: Mailman/MimeDel 2.1.5
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220559 - in head/sys: conf geom
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 02:55:07 -0000

On 13 April 2011 02:18, Andrew Thompson  wrote:

> +struct map_desc {
> > +       uint8_t         name   [16];    /* null-terminated name */
> > +       uint32_t        offset; /* offset in flash */
> > +       uint32_t        addr;   /* address in memory */
> > +       uint32_t        size;   /* image size in bytes */
> > +       uint32_t        entry;  /* offset in image for entry point */
> > +       uint32_t        dsize;  /* data size in bytes */
> > +};
>
> It could at some point be used on larger storage, perhaps get rid of
> the 4G limit now?
>

If someone would like to submit patches to implement this and they're
verified to work, I'll commit them.

Thanks,


Adrian

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 03:05:15 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 966491065675;
	Wed, 13 Apr 2011 03:05:15 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 841368FC15;
	Wed, 13 Apr 2011 03:05:15 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3D35F6i043363;
	Wed, 13 Apr 2011 03:05:15 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3D35F3f043361;
	Wed, 13 Apr 2011 03:05:15 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104130305.p3D35F3f043361@svn.freebsd.org>
From: Adrian Chadd 
Date: Wed, 13 Apr 2011 03:05:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220588 - head/sys/dev/ath/ath_hal
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 03:05:15 -0000

Author: adrian
Date: Wed Apr 13 03:05:15 2011
New Revision: 220588
URL: http://svn.freebsd.org/changeset/base/220588

Log:
  Add OS_REG_RMW, which mirrors ath9k's REG_RMW.
  
  This macro does a read-modify-write pass with register bits to set and clear.

Modified:
  head/sys/dev/ath/ath_hal/ah_internal.h

Modified: head/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_internal.h	Wed Apr 13 02:40:45 2011	(r220587)
+++ head/sys/dev/ath/ath_hal/ah_internal.h	Wed Apr 13 03:05:15 2011	(r220588)
@@ -468,6 +468,8 @@ isBigEndian(void)
  */
 #define	SM(_v, _f)	(((_v) << _f##_S) & (_f))
 #define	MS(_v, _f)	(((_v) & (_f)) >> _f##_S)
+#define OS_REG_RMW(_a, _r, _set, _clr)    \
+	OS_REG_WRITE(_a, _r, (OS_REG_READ(_a, _r) & ~(_clr)) | (_set))
 #define	OS_REG_RMW_FIELD(_a, _r, _f, _v) \
 	OS_REG_WRITE(_a, _r, \
 		(OS_REG_READ(_a, _r) &~ (_f)) | (((_v) << _f##_S) & (_f)))

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 03:05:42 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E76A9106566B;
	Wed, 13 Apr 2011 03:05:42 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D51A18FC0A;
	Wed, 13 Apr 2011 03:05:42 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3D35gFt043407;
	Wed, 13 Apr 2011 03:05:42 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3D35gMm043405;
	Wed, 13 Apr 2011 03:05:42 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104130305.p3D35gMm043405@svn.freebsd.org>
From: Adrian Chadd 
Date: Wed, 13 Apr 2011 03:05:42 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220589 - head/sys/dev/ath/ath_hal
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 03:05:43 -0000

Author: adrian
Date: Wed Apr 13 03:05:42 2011
New Revision: 220589
URL: http://svn.freebsd.org/changeset/base/220589

Log:
  Add new fields to the v4k EEPROM modal header.

Modified:
  head/sys/dev/ath/ath_hal/ah_eeprom_v4k.h

Modified: head/sys/dev/ath/ath_hal/ah_eeprom_v4k.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_eeprom_v4k.h	Wed Apr 13 03:05:15 2011	(r220588)
+++ head/sys/dev/ath/ath_hal/ah_eeprom_v4k.h	Wed Apr 13 03:05:42 2011	(r220589)
@@ -136,7 +136,11 @@ typedef struct ModalEepHeader4k {
 	uint8_t		db2_2:4, db2_3:4;
 	uint8_t		db2_4:4, reserved:4;
 #endif
-	uint8_t		futureModal[4];				// 4
+	uint8_t		tx_diversity;
+	uint8_t		flc_pwr_thresh;
+	uint8_t		bb_scale_smrt_antenna;
+#define	EEP_4K_BB_DESIRED_SCALE_MASK	0x1f
+	uint8_t		futureModal[1];
 
 	SPUR_CHAN spurChans[AR5416_EEPROM_MODAL_SPURS];	// 20 B
 } __packed MODAL_EEP4K_HEADER;				// == 68 B

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 04:41:00 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EC1C7106566B;
	Wed, 13 Apr 2011 04:40:59 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DACC98FC0C;
	Wed, 13 Apr 2011 04:40:59 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3D4expg045427;
	Wed, 13 Apr 2011 04:40:59 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3D4exUr045424;
	Wed, 13 Apr 2011 04:40:59 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104130440.p3D4exUr045424@svn.freebsd.org>
From: Adrian Chadd 
Date: Wed, 13 Apr 2011 04:40:59 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220590 - head/sys/dev/ath/ath_hal/ar9002
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 04:41:00 -0000

Author: adrian
Date: Wed Apr 13 04:40:59 2011
New Revision: 220590
URL: http://svn.freebsd.org/changeset/base/220590

Log:
  Port over a TX gain fix from ath9k specific to the AR9285 (Kite) and AR9271.
  Note: this HAL currently only supports the AR9285.
  
  From Linux ath9k:
  
  The problem is that when the attenuation is increased,
  the rate will start to drop from MCS7 -> MCS6, and finally
  will see MCS1 -> CCK_11Mbps. When the rate is changed b/w
  CCK and OFDM, it will use register desired_scale to calculate
  how much tx gain need to change.
  
  The output power with the same tx gain for CCK and OFDM modulated
  signals are different. This difference is constant for AR9280
  but not AR9285/AR9271. It has different PA architecture
  a constant. So it should be calibrated against this PA
  characteristic.
  
  The driver has to read the calibrated values from EEPROM and set
  the tx power registers accordingly.

Modified:
  head/sys/dev/ath/ath_hal/ar9002/ar9002phy.h
  head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9002phy.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9002/ar9002phy.h	Wed Apr 13 03:05:42 2011	(r220589)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9002phy.h	Wed Apr 13 04:40:59 2011	(r220590)
@@ -42,9 +42,16 @@
 #define	AR_PHY_TX_PWRCTRL_INIT_TX_GAIN		0x01F80000
 #define	AR_PHY_TX_PWRCTRL_INIT_TX_GAIN_S	19
 
+#define	AR_PHY_TX_PWRCTRL8			0xa278
+#define	AR_PHY_TX_PWRCTRL10			0xa394
 
 #define	AR_PHY_TX_GAIN_TBL1			0xa300
 #define	AR_PHY_TX_GAIN				0x0007F000
 #define	AR_PHY_TX_GAIN_S			12
 
+#define	AR_PHY_CH0_TX_PWRCTRL11			0xa398
+#define	AR_PHY_CH1_TX_PWRCTRL11			0xb398
+#define	AR_PHY_CH0_TX_PWRCTRL12			0xa3dc
+#define	AR_PHY_CH0_TX_PWRCTRL13			0xa3e0
+
 #endif

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c	Wed Apr 13 03:05:42 2011	(r220589)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c	Wed Apr 13 04:40:59 2011	(r220590)
@@ -35,7 +35,7 @@
 #include "ar5416/ar5416.h"
 #include "ar5416/ar5416reg.h"
 #include "ar5416/ar5416phy.h"
-
+#include "ar9002/ar9002phy.h"
 #include "ar9002/ar9285phy.h"
 
 /* Eeprom versioning macros. Returns true if the version is equal or newer than the ver specified */ 
@@ -415,6 +415,42 @@ ar9285SetBoardValues(struct ath_hal *ah,
 			    AR_PHY_SETTLING_SWITCH, pModal->swSettleHt40);
 	}
 
+	/*
+	 * Program the CCK TX gain factor appropriately if needed.
+	 * The AR9285/AR9271 has a non-constant PA tx gain behaviour
+	 * for CCK versus OFDM rates; other chips deal with this
+	 * differently.
+	 *
+	 * The mask/shift/multiply hackery is done so place the same
+	 * value (bb_desired_scale) into multiple 5-bit fields.
+	 * For example, AR_PHY_TX_PWRCTRL9 has bb_desired_scale written
+	 * to three fields: (0..4), (5..9) and (10..14).
+	 */
+	if (AR_SREV_9271(ah) || AR_SREV_KITE(ah)) {
+		uint8_t bb_desired_scale = (pModal->bb_scale_smrt_antenna & EEP_4K_BB_DESIRED_SCALE_MASK);
+		if ((eep->baseEepHeader.txGainType == 0) && (bb_desired_scale != 0)) {
+			uint32_t pwrctrl, mask, clr;
+
+			mask = (1<<0) | (1<<5) | (1<<10) | (1<<15) | (1<<20) | (1<<25);
+			pwrctrl = mask * bb_desired_scale;
+			clr = mask * 0x1f;
+			OS_REG_RMW(ah, AR_PHY_TX_PWRCTRL8, pwrctrl, clr);
+			OS_REG_RMW(ah, AR_PHY_TX_PWRCTRL10, pwrctrl, clr);
+			OS_REG_RMW(ah, AR_PHY_CH0_TX_PWRCTRL12, pwrctrl, clr);
+
+			mask = (1<<0) | (1<<5) | (1<<15);
+			pwrctrl = mask * bb_desired_scale;
+			clr = mask * 0x1f;
+			OS_REG_RMW(ah, AR_PHY_TX_PWRCTRL9, pwrctrl, clr);
+
+			mask = (1<<0) | (1<<5);
+			pwrctrl = mask * bb_desired_scale;
+			clr = mask * 0x1f;
+			OS_REG_RMW(ah, AR_PHY_CH0_TX_PWRCTRL11, pwrctrl, clr);
+			OS_REG_RMW(ah, AR_PHY_CH0_TX_PWRCTRL13, pwrctrl, clr);
+		}
+	}
+
 	return AH_TRUE;
 }
 

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 06:36:23 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 71DAB106566B;
	Wed, 13 Apr 2011 06:36:23 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2A8058FC0A;
	Wed, 13 Apr 2011 06:36:23 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3D6aNPQ054010;
	Wed, 13 Apr 2011 06:36:23 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3D6aNHf054008;
	Wed, 13 Apr 2011 06:36:23 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104130636.p3D6aNHf054008@svn.freebsd.org>
From: Alexander Motin 
Date: Wed, 13 Apr 2011 06:36:23 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220591 - head/sys/dev/siis
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 06:36:23 -0000

Author: mav
Date: Wed Apr 13 06:36:22 2011
New Revision: 220591
URL: http://svn.freebsd.org/changeset/base/220591

Log:
  As soon as siis_reset() doesn't waits for device readiness, but only for
  controller port readiness (that should set just after PHY ready signal),
  reduce wait time from 10s to 1s before trying more aggressive reset method.
  
  This should improve system responsibility in some failure conditions.

Modified:
  head/sys/dev/siis/siis.c

Modified: head/sys/dev/siis/siis.c
==============================================================================
--- head/sys/dev/siis/siis.c	Wed Apr 13 04:40:59 2011	(r220590)
+++ head/sys/dev/siis/siis.c	Wed Apr 13 06:36:22 2011	(r220591)
@@ -1631,9 +1631,9 @@ retry:
 		xpt_release_simq(ch->sim, TRUE);
 		return;
 	}
-	/* Wait for clearing busy status. */
-	if (siis_wait_ready(dev, 10000)) {
-		device_printf(dev, "device ready timeout\n");
+	/* Wait for port ready status. */
+	if (siis_wait_ready(dev, 1000)) {
+		device_printf(dev, "port ready timeout\n");
 		if (!retry) {
 			device_printf(dev, "trying full port reset ...\n");
 			/* Get port to the reset state. */

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 11:28:47 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 293C01065673;
	Wed, 13 Apr 2011 11:28:47 +0000 (UTC)
	(envelope-from pluknet@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 174788FC15;
	Wed, 13 Apr 2011 11:28:47 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DBSkOF078799;
	Wed, 13 Apr 2011 11:28:46 GMT (envelope-from pluknet@svn.freebsd.org)
Received: (from pluknet@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DBSkjs078792;
	Wed, 13 Apr 2011 11:28:46 GMT (envelope-from pluknet@svn.freebsd.org)
Message-Id: <201104131128.p3DBSkjs078792@svn.freebsd.org>
From: Sergey Kandaurov 
Date: Wed, 13 Apr 2011 11:28:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220592 - in head/sys: kern netinet netinet/cc
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 11:28:47 -0000

Author: pluknet
Date: Wed Apr 13 11:28:46 2011
New Revision: 220592
URL: http://svn.freebsd.org/changeset/base/220592

Log:
  Staticize malloc types.
  
  Approved by:	lstewart
  MFC after:	1 week

Modified:
  head/sys/kern/kern_hhook.c
  head/sys/netinet/cc/cc_chd.c
  head/sys/netinet/cc/cc_cubic.c
  head/sys/netinet/cc/cc_htcp.c
  head/sys/netinet/cc/cc_vegas.c
  head/sys/netinet/siftr.c

Modified: head/sys/kern/kern_hhook.c
==============================================================================
--- head/sys/kern/kern_hhook.c	Wed Apr 13 06:36:22 2011	(r220591)
+++ head/sys/kern/kern_hhook.c	Wed Apr 13 11:28:46 2011	(r220592)
@@ -58,8 +58,7 @@ struct hhook {
 	STAILQ_ENTRY(hhook)	hhk_next;
 };
 
-MALLOC_DECLARE(M_HHOOK);
-MALLOC_DEFINE(M_HHOOK, "hhook", "Helper hooks are linked off hhook_head lists");
+static MALLOC_DEFINE(M_HHOOK, "hhook", "Helper hooks are linked off hhook_head lists");
 
 LIST_HEAD(hhookheadhead, hhook_head);
 VNET_DEFINE(struct hhookheadhead, hhook_head_list);

Modified: head/sys/netinet/cc/cc_chd.c
==============================================================================
--- head/sys/netinet/cc/cc_chd.c	Wed Apr 13 06:36:22 2011	(r220591)
+++ head/sys/netinet/cc/cc_chd.c	Wed Apr 13 11:28:46 2011	(r220592)
@@ -127,8 +127,7 @@ static VNET_DEFINE(uint32_t, chd_qthresh
 #define	V_chd_loss_fair	VNET(chd_loss_fair)
 #define	V_chd_use_max	VNET(chd_use_max)
 
-MALLOC_DECLARE(M_CHD);
-MALLOC_DEFINE(M_CHD, "chd data",
+static MALLOC_DEFINE(M_CHD, "chd data",
     "Per connection data required for the CHD congestion control algorithm");
 
 struct cc_algo chd_cc_algo = {

Modified: head/sys/netinet/cc/cc_cubic.c
==============================================================================
--- head/sys/netinet/cc/cc_cubic.c	Wed Apr 13 06:36:22 2011	(r220591)
+++ head/sys/netinet/cc/cc_cubic.c	Wed Apr 13 11:28:46 2011	(r220592)
@@ -98,8 +98,7 @@ struct cubic {
 	int		t_last_cong;
 };
 
-MALLOC_DECLARE(M_CUBIC);
-MALLOC_DEFINE(M_CUBIC, "cubic data",
+static MALLOC_DEFINE(M_CUBIC, "cubic data",
     "Per connection data required for the CUBIC congestion control algorithm");
 
 struct cc_algo cubic_cc_algo = {

Modified: head/sys/netinet/cc/cc_htcp.c
==============================================================================
--- head/sys/netinet/cc/cc_htcp.c	Wed Apr 13 06:36:22 2011	(r220591)
+++ head/sys/netinet/cc/cc_htcp.c	Wed Apr 13 11:28:46 2011	(r220592)
@@ -173,8 +173,7 @@ static VNET_DEFINE(u_int, htcp_rtt_scali
 #define	V_htcp_adaptive_backoff    VNET(htcp_adaptive_backoff)
 #define	V_htcp_rtt_scaling    VNET(htcp_rtt_scaling)
 
-MALLOC_DECLARE(M_HTCP);
-MALLOC_DEFINE(M_HTCP, "htcp data",
+static MALLOC_DEFINE(M_HTCP, "htcp data",
     "Per connection data required for the HTCP congestion control algorithm");
 
 struct cc_algo htcp_cc_algo = {

Modified: head/sys/netinet/cc/cc_vegas.c
==============================================================================
--- head/sys/netinet/cc/cc_vegas.c	Wed Apr 13 06:36:22 2011	(r220591)
+++ head/sys/netinet/cc/cc_vegas.c	Wed Apr 13 11:28:46 2011	(r220592)
@@ -105,8 +105,7 @@ static VNET_DEFINE(uint32_t, vegas_beta)
 #define	V_vegas_alpha	VNET(vegas_alpha)
 #define	V_vegas_beta	VNET(vegas_beta)
 
-MALLOC_DECLARE(M_VEGAS);
-MALLOC_DEFINE(M_VEGAS, "vegas data",
+static MALLOC_DEFINE(M_VEGAS, "vegas data",
     "Per connection data required for the Vegas congestion control algorithm");
 
 struct cc_algo vegas_cc_algo = {

Modified: head/sys/netinet/siftr.c
==============================================================================
--- head/sys/netinet/siftr.c	Wed Apr 13 06:36:22 2011	(r220591)
+++ head/sys/netinet/siftr.c	Wed Apr 13 11:28:46 2011	(r220592)
@@ -156,14 +156,11 @@ __FBSDID("$FreeBSD$");
 #define THIRD_OCTET(X)	(((X) & 0x0000FF00) >> 8)
 #define FOURTH_OCTET(X)	((X) & 0x000000FF)
 
-MALLOC_DECLARE(M_SIFTR);
-MALLOC_DEFINE(M_SIFTR, "siftr", "dynamic memory used by SIFTR");
-
-MALLOC_DECLARE(M_SIFTR_PKTNODE);
-MALLOC_DEFINE(M_SIFTR_PKTNODE, "siftr_pktnode", "SIFTR pkt_node struct");
-
-MALLOC_DECLARE(M_SIFTR_HASHNODE);
-MALLOC_DEFINE(M_SIFTR_HASHNODE, "siftr_hashnode", "SIFTR flow_hash_node struct");
+static MALLOC_DEFINE(M_SIFTR, "siftr", "dynamic memory used by SIFTR");
+static MALLOC_DEFINE(M_SIFTR_PKTNODE, "siftr_pktnode",
+    "SIFTR pkt_node struct");
+static MALLOC_DEFINE(M_SIFTR_HASHNODE, "siftr_hashnode",
+    "SIFTR flow_hash_node struct");
 
 /* Used as links in the pkt manager queue. */
 struct pkt_node {

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 11:32:15 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6B5BA106564A;
	Wed, 13 Apr 2011 11:32:15 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 592268FC14;
	Wed, 13 Apr 2011 11:32:15 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DBWFYN079132;
	Wed, 13 Apr 2011 11:32:15 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DBWFQN079126;
	Wed, 13 Apr 2011 11:32:15 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104131132.p3DBWFQN079126@svn.freebsd.org>
From: Adrian Chadd 
Date: Wed, 13 Apr 2011 11:32:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220593 - in head/sys: conf dev/ath/ath_hal/ar9002
	modules/ath
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 11:32:15 -0000

Author: adrian
Date: Wed Apr 13 11:32:15 2011
New Revision: 220593
URL: http://svn.freebsd.org/changeset/base/220593

Log:
  Bring over the antenna diversity logic support for Kite.
  
  Again, this is just the code ported from ath9k and included in the build,
  it isn't yet enabled.

Added:
  head/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c   (contents, props changed)
  head/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.h   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/ath/ath_hal/ar9002/ar9285.h
  head/sys/modules/ath/Makefile

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Wed Apr 13 11:28:46 2011	(r220592)
+++ head/sys/conf/files	Wed Apr 13 11:32:15 2011	(r220593)
@@ -775,6 +775,8 @@ dev/ath/ath_hal/ar9002/ar9285_cal.c opti
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 dev/ath/ath_hal/ar9002/ar9285_phy.c optional ath_hal | ath_ar9285 \ 
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
+dev/ath/ath_hal/ar9002/ar9285_diversity.c optional ath_hal | ath_ar9285 \ 
+	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"
 # rf backends
 dev/ath/ath_hal/ar5212/ar2316.c	optional ath_rf2316 \
 	compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal"

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9002/ar9285.h	Wed Apr 13 11:28:46 2011	(r220592)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285.h	Wed Apr 13 11:32:15 2011	(r220593)
@@ -20,12 +20,49 @@
 
 #include "ar5416/ar5416.h"
 
+enum ar9285_ant_div_comb_lna_conf {
+	ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2,
+	ATH_ANT_DIV_COMB_LNA2,
+	ATH_ANT_DIV_COMB_LNA1,
+	ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2,
+};
+
+struct ar9285_ant_comb {
+	uint16_t count;
+	uint16_t total_pkt_count;
+	HAL_BOOL scan;
+	HAL_BOOL scan_not_start;
+	int main_total_rssi;
+	int alt_total_rssi;
+	int alt_recv_cnt;
+	int main_recv_cnt;
+	int rssi_lna1;
+	int rssi_lna2;
+	int rssi_add;
+	int rssi_sub;
+	int rssi_first;
+	int rssi_second;
+	int rssi_third;
+	HAL_BOOL alt_good;
+	int quick_scan_cnt;
+	int main_conf;
+	enum ar9285_ant_div_comb_lna_conf first_quick_scan_conf;
+	enum ar9285_ant_div_comb_lna_conf second_quick_scan_conf;
+	int first_bias;
+	int second_bias;
+	HAL_BOOL first_ratio;
+	HAL_BOOL second_ratio;
+	unsigned long scan_start_time;
+};
+
 struct ath_hal_9285 {
 	struct ath_hal_5416 ah_5416;
 
 	HAL_INI_ARRAY	ah_ini_txgain;
 	HAL_INI_ARRAY	ah_ini_rxgain;
 
+	struct ar9285_ant_comb ant_comb;	/* Kite Antenna comb/diversity */
+
 	struct {
 		int32_t prev_offset;	/* Previous value of PA offset value */
 		int8_t max_skipcount;	/* Max No. of times PACAL can be skipped */

Added: head/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c	Wed Apr 13 11:32:15 2011	(r220593)
@@ -0,0 +1,594 @@
+/*
+ * Copyright (c) 2008-2010 Atheros Communications Inc.
+ * Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (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$
+ */
+#include "opt_ah.h"
+
+#include "ah.h"
+#include "ah_desc.h"
+#include "ah_internal.h"
+#include "ah_eeprom_v4k.h"
+
+#include "ar9002/ar9280.h"
+#include "ar9002/ar9285_diversity.h"
+#include "ar9002/ar9285.h"
+#include "ar5416/ar5416reg.h"
+#include "ar5416/ar5416phy.h"
+#include "ar9002/ar9285phy.h"
+#include "ar9002/ar9285_phy.h"
+
+
+/* Linux compability macros */
+/*
+ * XXX these don't handle rounding, underflow, overflow, wrapping!
+ */
+#define	msecs_to_jiffies(a)		( (a) * hz / 1000 )
+#define	time_after(a, b)		( (long) (b) - (long) (a) < 0 )
+
+static HAL_BOOL
+ath_is_alt_ant_ratio_better(int alt_ratio, int maxdelta, int mindelta,
+    int main_rssi_avg, int alt_rssi_avg, int pkt_count)
+{
+	return (((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) &&
+		(alt_rssi_avg > main_rssi_avg + maxdelta)) ||
+		(alt_rssi_avg > main_rssi_avg + mindelta)) && (pkt_count > 50);
+}
+
+static void
+ath_lnaconf_alt_good_scan(struct ar9285_ant_comb *antcomb,
+    struct ar9285_antcomb_conf ant_conf, int main_rssi_avg)
+{
+	antcomb->quick_scan_cnt = 0;
+
+	if (ant_conf.main_lna_conf == ATH_ANT_DIV_COMB_LNA2)
+		antcomb->rssi_lna2 = main_rssi_avg;
+	else if (ant_conf.main_lna_conf == ATH_ANT_DIV_COMB_LNA1)
+		antcomb->rssi_lna1 = main_rssi_avg;
+
+	switch ((ant_conf.main_lna_conf << 4) | ant_conf.alt_lna_conf) {
+	case (0x10): /* LNA2 A-B */
+		antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
+		antcomb->first_quick_scan_conf =
+			ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
+		antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1;
+		break;
+	case (0x20): /* LNA1 A-B */
+		antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
+		antcomb->first_quick_scan_conf =
+			ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
+		antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA2;
+		break;
+	case (0x21): /* LNA1 LNA2 */
+		antcomb->main_conf = ATH_ANT_DIV_COMB_LNA2;
+		antcomb->first_quick_scan_conf =
+			ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
+		antcomb->second_quick_scan_conf =
+			ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
+		break;
+	case (0x12): /* LNA2 LNA1 */
+		antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1;
+		antcomb->first_quick_scan_conf =
+			ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
+		antcomb->second_quick_scan_conf =
+			ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
+		break;
+	case (0x13): /* LNA2 A+B */
+		antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
+		antcomb->first_quick_scan_conf =
+			ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
+		antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA1;
+		break;
+	case (0x23): /* LNA1 A+B */
+		antcomb->main_conf = ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
+		antcomb->first_quick_scan_conf =
+			ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
+		antcomb->second_quick_scan_conf = ATH_ANT_DIV_COMB_LNA2;
+		break;
+	default:
+		break;
+	}
+}
+
+static void
+ath_select_ant_div_from_quick_scan(struct ar9285_ant_comb *antcomb,
+    struct ar9285_antcomb_conf *div_ant_conf, int main_rssi_avg,
+    int alt_rssi_avg, int alt_ratio)
+{
+	/* alt_good */
+	switch (antcomb->quick_scan_cnt) {
+	case 0:
+		/* set alt to main, and alt to first conf */
+		div_ant_conf->main_lna_conf = antcomb->main_conf;
+		div_ant_conf->alt_lna_conf = antcomb->first_quick_scan_conf;
+		break;
+	case 1:
+		/* set alt to main, and alt to first conf */
+		div_ant_conf->main_lna_conf = antcomb->main_conf;
+		div_ant_conf->alt_lna_conf = antcomb->second_quick_scan_conf;
+		antcomb->rssi_first = main_rssi_avg;
+		antcomb->rssi_second = alt_rssi_avg;
+
+		if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) {
+			/* main is LNA1 */
+			if (ath_is_alt_ant_ratio_better(alt_ratio,
+						ATH_ANT_DIV_COMB_LNA1_DELTA_HI,
+						ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
+						main_rssi_avg, alt_rssi_avg,
+						antcomb->total_pkt_count))
+				antcomb->first_ratio = AH_TRUE;
+			else
+				antcomb->first_ratio = AH_FALSE;
+		} else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) {
+			if (ath_is_alt_ant_ratio_better(alt_ratio,
+						ATH_ANT_DIV_COMB_LNA1_DELTA_MID,
+						ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
+						main_rssi_avg, alt_rssi_avg,
+						antcomb->total_pkt_count))
+				antcomb->first_ratio = AH_TRUE;
+			else
+				antcomb->first_ratio = AH_FALSE;
+		} else {
+			if ((((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) &&
+			    (alt_rssi_avg > main_rssi_avg +
+			    ATH_ANT_DIV_COMB_LNA1_DELTA_HI)) ||
+			    (alt_rssi_avg > main_rssi_avg)) &&
+			    (antcomb->total_pkt_count > 50))
+				antcomb->first_ratio = AH_TRUE;
+			else
+				antcomb->first_ratio = AH_FALSE;
+		}
+		break;
+	case 2:
+		antcomb->alt_good = AH_FALSE;
+		antcomb->scan_not_start = AH_FALSE;
+		antcomb->scan = AH_FALSE;
+		antcomb->rssi_first = main_rssi_avg;
+		antcomb->rssi_third = alt_rssi_avg;
+
+		if (antcomb->second_quick_scan_conf == ATH_ANT_DIV_COMB_LNA1)
+			antcomb->rssi_lna1 = alt_rssi_avg;
+		else if (antcomb->second_quick_scan_conf ==
+			 ATH_ANT_DIV_COMB_LNA2)
+			antcomb->rssi_lna2 = alt_rssi_avg;
+		else if (antcomb->second_quick_scan_conf ==
+			 ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2) {
+			if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2)
+				antcomb->rssi_lna2 = main_rssi_avg;
+			else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1)
+				antcomb->rssi_lna1 = main_rssi_avg;
+		}
+
+		if (antcomb->rssi_lna2 > antcomb->rssi_lna1 +
+		    ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA)
+			div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
+		else
+			div_ant_conf->main_lna_conf = ATH_ANT_DIV_COMB_LNA1;
+
+		if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) {
+			if (ath_is_alt_ant_ratio_better(alt_ratio,
+						ATH_ANT_DIV_COMB_LNA1_DELTA_HI,
+						ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
+						main_rssi_avg, alt_rssi_avg,
+						antcomb->total_pkt_count))
+				antcomb->second_ratio = AH_TRUE;
+			else
+				antcomb->second_ratio = AH_FALSE;
+		} else if (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2) {
+			if (ath_is_alt_ant_ratio_better(alt_ratio,
+						ATH_ANT_DIV_COMB_LNA1_DELTA_MID,
+						ATH_ANT_DIV_COMB_LNA1_DELTA_LOW,
+						main_rssi_avg, alt_rssi_avg,
+						antcomb->total_pkt_count))
+				antcomb->second_ratio = AH_TRUE;
+			else
+				antcomb->second_ratio = AH_FALSE;
+		} else {
+			if ((((alt_ratio >= ATH_ANT_DIV_COMB_ALT_ANT_RATIO2) &&
+			    (alt_rssi_avg > main_rssi_avg +
+			    ATH_ANT_DIV_COMB_LNA1_DELTA_HI)) ||
+			    (alt_rssi_avg > main_rssi_avg)) &&
+			    (antcomb->total_pkt_count > 50))
+				antcomb->second_ratio = AH_TRUE;
+			else
+				antcomb->second_ratio = AH_FALSE;
+		}
+
+		/* set alt to the conf with maximun ratio */
+		if (antcomb->first_ratio && antcomb->second_ratio) {
+			if (antcomb->rssi_second > antcomb->rssi_third) {
+				/* first alt*/
+				if ((antcomb->first_quick_scan_conf ==
+				    ATH_ANT_DIV_COMB_LNA1) ||
+				    (antcomb->first_quick_scan_conf ==
+				    ATH_ANT_DIV_COMB_LNA2))
+					/* Set alt LNA1 or LNA2*/
+					if (div_ant_conf->main_lna_conf ==
+					    ATH_ANT_DIV_COMB_LNA2)
+						div_ant_conf->alt_lna_conf =
+							ATH_ANT_DIV_COMB_LNA1;
+					else
+						div_ant_conf->alt_lna_conf =
+							ATH_ANT_DIV_COMB_LNA2;
+				else
+					/* Set alt to A+B or A-B */
+					div_ant_conf->alt_lna_conf =
+						antcomb->first_quick_scan_conf;
+			} else if ((antcomb->second_quick_scan_conf ==
+				   ATH_ANT_DIV_COMB_LNA1) ||
+				   (antcomb->second_quick_scan_conf ==
+				   ATH_ANT_DIV_COMB_LNA2)) {
+				/* Set alt LNA1 or LNA2 */
+				if (div_ant_conf->main_lna_conf ==
+				    ATH_ANT_DIV_COMB_LNA2)
+					div_ant_conf->alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1;
+				else
+					div_ant_conf->alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA2;
+			} else {
+				/* Set alt to A+B or A-B */
+				div_ant_conf->alt_lna_conf =
+					antcomb->second_quick_scan_conf;
+			}
+		} else if (antcomb->first_ratio) {
+			/* first alt */
+			if ((antcomb->first_quick_scan_conf ==
+			    ATH_ANT_DIV_COMB_LNA1) ||
+			    (antcomb->first_quick_scan_conf ==
+			    ATH_ANT_DIV_COMB_LNA2))
+					/* Set alt LNA1 or LNA2 */
+				if (div_ant_conf->main_lna_conf ==
+				    ATH_ANT_DIV_COMB_LNA2)
+					div_ant_conf->alt_lna_conf =
+							ATH_ANT_DIV_COMB_LNA1;
+				else
+					div_ant_conf->alt_lna_conf =
+							ATH_ANT_DIV_COMB_LNA2;
+			else
+				/* Set alt to A+B or A-B */
+				div_ant_conf->alt_lna_conf =
+						antcomb->first_quick_scan_conf;
+		} else if (antcomb->second_ratio) {
+				/* second alt */
+			if ((antcomb->second_quick_scan_conf ==
+			    ATH_ANT_DIV_COMB_LNA1) ||
+			    (antcomb->second_quick_scan_conf ==
+			    ATH_ANT_DIV_COMB_LNA2))
+				/* Set alt LNA1 or LNA2 */
+				if (div_ant_conf->main_lna_conf ==
+				    ATH_ANT_DIV_COMB_LNA2)
+					div_ant_conf->alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1;
+				else
+					div_ant_conf->alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA2;
+			else
+				/* Set alt to A+B or A-B */
+				div_ant_conf->alt_lna_conf =
+						antcomb->second_quick_scan_conf;
+		} else {
+			/* main is largest */
+			if ((antcomb->main_conf == ATH_ANT_DIV_COMB_LNA1) ||
+			    (antcomb->main_conf == ATH_ANT_DIV_COMB_LNA2))
+				/* Set alt LNA1 or LNA2 */
+				if (div_ant_conf->main_lna_conf ==
+				    ATH_ANT_DIV_COMB_LNA2)
+					div_ant_conf->alt_lna_conf =
+							ATH_ANT_DIV_COMB_LNA1;
+				else
+					div_ant_conf->alt_lna_conf =
+							ATH_ANT_DIV_COMB_LNA2;
+			else
+				/* Set alt to A+B or A-B */
+				div_ant_conf->alt_lna_conf = antcomb->main_conf;
+		}
+		break;
+	default:
+		break;
+	}
+}
+
+static void
+ath_ant_div_conf_fast_divbias(struct ar9285_antcomb_conf *ant_conf)
+{
+	/* Adjust the fast_div_bias based on main and alt lna conf */
+	switch ((ant_conf->main_lna_conf << 4) | ant_conf->alt_lna_conf) {
+	case (0x01): /* A-B LNA2 */
+		ant_conf->fast_div_bias = 0x3b;
+		break;
+	case (0x02): /* A-B LNA1 */
+		ant_conf->fast_div_bias = 0x3d;
+		break;
+	case (0x03): /* A-B A+B */
+		ant_conf->fast_div_bias = 0x1;
+		break;
+	case (0x10): /* LNA2 A-B */
+		ant_conf->fast_div_bias = 0x7;
+		break;
+	case (0x12): /* LNA2 LNA1 */
+		ant_conf->fast_div_bias = 0x2;
+		break;
+	case (0x13): /* LNA2 A+B */
+		ant_conf->fast_div_bias = 0x7;
+		break;
+	case (0x20): /* LNA1 A-B */
+		ant_conf->fast_div_bias = 0x6;
+		break;
+	case (0x21): /* LNA1 LNA2 */
+		ant_conf->fast_div_bias = 0x0;
+		break;
+	case (0x23): /* LNA1 A+B */
+		ant_conf->fast_div_bias = 0x6;
+		break;
+	case (0x30): /* A+B A-B */
+		ant_conf->fast_div_bias = 0x1;
+		break;
+	case (0x31): /* A+B LNA2 */
+		ant_conf->fast_div_bias = 0x3b;
+		break;
+	case (0x32): /* A+B LNA1 */
+		ant_conf->fast_div_bias = 0x3d;
+		break;
+	default:
+		break;
+	}
+}
+
+/* Antenna diversity and combining */
+void
+ar9285_ant_comb_scan(struct ath_hal *ah, struct ath_rx_status *rs,
+    unsigned long ticks, int hz)
+{
+	struct ar9285_antcomb_conf div_ant_conf;
+	struct ar9285_ant_comb *antcomb = &AH9285(ah)->ant_comb;
+	int alt_ratio = 0, alt_rssi_avg = 0, main_rssi_avg = 0, curr_alt_set;
+	int curr_main_set, curr_bias;
+	int main_rssi = rs->rs_rssi_ctl[0];
+	int alt_rssi = rs->rs_rssi_ctl[1];
+	int rx_ant_conf, main_ant_conf;
+	HAL_BOOL short_scan = AH_FALSE;
+
+	rx_ant_conf = (rs->rs_rssi_ctl[2] >> ATH_ANT_RX_CURRENT_SHIFT) &
+		       ATH_ANT_RX_MASK;
+	main_ant_conf = (rs->rs_rssi_ctl[2] >> ATH_ANT_RX_MAIN_SHIFT) &
+			 ATH_ANT_RX_MASK;
+
+	/* Record packet only when alt_rssi is positive */
+	if (alt_rssi > 0) {
+		antcomb->total_pkt_count++;
+		antcomb->main_total_rssi += main_rssi;
+		antcomb->alt_total_rssi  += alt_rssi;
+		if (main_ant_conf == rx_ant_conf)
+			antcomb->main_recv_cnt++;
+		else
+			antcomb->alt_recv_cnt++;
+	}
+
+	/* Short scan check */
+	if (antcomb->scan && antcomb->alt_good) {
+		if (time_after(ticks, antcomb->scan_start_time +
+		    msecs_to_jiffies(ATH_ANT_DIV_COMB_SHORT_SCAN_INTR)))
+			short_scan = AH_TRUE;
+		else
+			if (antcomb->total_pkt_count ==
+			    ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT) {
+				alt_ratio = ((antcomb->alt_recv_cnt * 100) /
+					    antcomb->total_pkt_count);
+				if (alt_ratio < ATH_ANT_DIV_COMB_ALT_ANT_RATIO)
+					short_scan = AH_TRUE;
+			}
+	}
+
+	if (((antcomb->total_pkt_count < ATH_ANT_DIV_COMB_MAX_PKTCOUNT) ||
+	    rs->rs_moreaggr) && !short_scan)
+		return;
+
+	if (antcomb->total_pkt_count) {
+		alt_ratio = ((antcomb->alt_recv_cnt * 100) /
+			     antcomb->total_pkt_count);
+		main_rssi_avg = (antcomb->main_total_rssi /
+				 antcomb->total_pkt_count);
+		alt_rssi_avg = (antcomb->alt_total_rssi /
+				 antcomb->total_pkt_count);
+	}
+
+
+	ar9285_antdiv_comb_conf_get(ah, &div_ant_conf);
+	curr_alt_set = div_ant_conf.alt_lna_conf;
+	curr_main_set = div_ant_conf.main_lna_conf;
+	curr_bias = div_ant_conf.fast_div_bias;
+
+	antcomb->count++;
+
+	if (antcomb->count == ATH_ANT_DIV_COMB_MAX_COUNT) {
+		if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO) {
+			ath_lnaconf_alt_good_scan(antcomb, div_ant_conf,
+						  main_rssi_avg);
+			antcomb->alt_good = AH_TRUE;
+		} else {
+			antcomb->alt_good = AH_FALSE;
+		}
+
+		antcomb->count = 0;
+		antcomb->scan = AH_TRUE;
+		antcomb->scan_not_start = AH_TRUE;
+	}
+
+	if (!antcomb->scan) {
+		if (alt_ratio > ATH_ANT_DIV_COMB_ALT_ANT_RATIO) {
+			if (curr_alt_set == ATH_ANT_DIV_COMB_LNA2) {
+				/* Switch main and alt LNA */
+				div_ant_conf.main_lna_conf =
+						ATH_ANT_DIV_COMB_LNA2;
+				div_ant_conf.alt_lna_conf  =
+						ATH_ANT_DIV_COMB_LNA1;
+			} else if (curr_alt_set == ATH_ANT_DIV_COMB_LNA1) {
+				div_ant_conf.main_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1;
+				div_ant_conf.alt_lna_conf  =
+						ATH_ANT_DIV_COMB_LNA2;
+			}
+
+			goto div_comb_done;
+		} else if ((curr_alt_set != ATH_ANT_DIV_COMB_LNA1) &&
+			   (curr_alt_set != ATH_ANT_DIV_COMB_LNA2)) {
+			/* Set alt to another LNA */
+			if (curr_main_set == ATH_ANT_DIV_COMB_LNA2)
+				div_ant_conf.alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1;
+			else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1)
+				div_ant_conf.alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA2;
+
+			goto div_comb_done;
+		}
+
+		if ((alt_rssi_avg < (main_rssi_avg +
+		    ATH_ANT_DIV_COMB_LNA1_LNA2_DELTA)))
+			goto div_comb_done;
+	}
+
+	if (!antcomb->scan_not_start) {
+		switch (curr_alt_set) {
+		case ATH_ANT_DIV_COMB_LNA2:
+			antcomb->rssi_lna2 = alt_rssi_avg;
+			antcomb->rssi_lna1 = main_rssi_avg;
+			antcomb->scan = AH_TRUE;
+			/* set to A+B */
+			div_ant_conf.main_lna_conf =
+				ATH_ANT_DIV_COMB_LNA1;
+			div_ant_conf.alt_lna_conf  =
+				ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
+			break;
+		case ATH_ANT_DIV_COMB_LNA1:
+			antcomb->rssi_lna1 = alt_rssi_avg;
+			antcomb->rssi_lna2 = main_rssi_avg;
+			antcomb->scan = AH_TRUE;
+			/* set to A+B */
+			div_ant_conf.main_lna_conf = ATH_ANT_DIV_COMB_LNA2;
+			div_ant_conf.alt_lna_conf  =
+				ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
+			break;
+		case ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2:
+			antcomb->rssi_add = alt_rssi_avg;
+			antcomb->scan = AH_TRUE;
+			/* set to A-B */
+			div_ant_conf.alt_lna_conf =
+				ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
+			break;
+		case ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2:
+			antcomb->rssi_sub = alt_rssi_avg;
+			antcomb->scan = AH_FALSE;
+			if (antcomb->rssi_lna2 >
+			    (antcomb->rssi_lna1 +
+			    ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA)) {
+				/* use LNA2 as main LNA */
+				if ((antcomb->rssi_add > antcomb->rssi_lna1) &&
+				    (antcomb->rssi_add > antcomb->rssi_sub)) {
+					/* set to A+B */
+					div_ant_conf.main_lna_conf =
+						ATH_ANT_DIV_COMB_LNA2;
+					div_ant_conf.alt_lna_conf  =
+						ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
+				} else if (antcomb->rssi_sub >
+					   antcomb->rssi_lna1) {
+					/* set to A-B */
+					div_ant_conf.main_lna_conf =
+						ATH_ANT_DIV_COMB_LNA2;
+					div_ant_conf.alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
+				} else {
+					/* set to LNA1 */
+					div_ant_conf.main_lna_conf =
+						ATH_ANT_DIV_COMB_LNA2;
+					div_ant_conf.alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1;
+				}
+			} else {
+				/* use LNA1 as main LNA */
+				if ((antcomb->rssi_add > antcomb->rssi_lna2) &&
+				    (antcomb->rssi_add > antcomb->rssi_sub)) {
+					/* set to A+B */
+					div_ant_conf.main_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1;
+					div_ant_conf.alt_lna_conf  =
+						ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2;
+				} else if (antcomb->rssi_sub >
+					   antcomb->rssi_lna1) {
+					/* set to A-B */
+					div_ant_conf.main_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1;
+					div_ant_conf.alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2;
+				} else {
+					/* set to LNA2 */
+					div_ant_conf.main_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1;
+					div_ant_conf.alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA2;
+				}
+			}
+			break;
+		default:
+			break;
+		}
+	} else {
+		if (!antcomb->alt_good) {
+			antcomb->scan_not_start = AH_FALSE;
+			/* Set alt to another LNA */
+			if (curr_main_set == ATH_ANT_DIV_COMB_LNA2) {
+				div_ant_conf.main_lna_conf =
+						ATH_ANT_DIV_COMB_LNA2;
+				div_ant_conf.alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1;
+			} else if (curr_main_set == ATH_ANT_DIV_COMB_LNA1) {
+				div_ant_conf.main_lna_conf =
+						ATH_ANT_DIV_COMB_LNA1;
+				div_ant_conf.alt_lna_conf =
+						ATH_ANT_DIV_COMB_LNA2;
+			}
+			goto div_comb_done;
+		}
+	}
+
+	ath_select_ant_div_from_quick_scan(antcomb, &div_ant_conf,
+					   main_rssi_avg, alt_rssi_avg,
+					   alt_ratio);
+
+	antcomb->quick_scan_cnt++;
+
+div_comb_done:
+	ath_ant_div_conf_fast_divbias(&div_ant_conf);
+
+	ar9285_antdiv_comb_conf_set(ah, &div_ant_conf);
+
+	antcomb->scan_start_time = ticks;
+	antcomb->total_pkt_count = 0;
+	antcomb->main_total_rssi = 0;
+	antcomb->alt_total_rssi = 0;
+	antcomb->main_recv_cnt = 0;
+	antcomb->alt_recv_cnt = 0;
+}

Added: head/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.h	Wed Apr 13 11:32:15 2011	(r220593)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2008-2010 Atheros Communications Inc.
+ * Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (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$
+ */
+#ifndef	__AR9285_DIVERSITY_H__
+#define	__AR9285_DIVERSITY_H__
+
+/* Antenna diversity/combining */
+#define	ATH_ANT_RX_CURRENT_SHIFT	4
+#define	ATH_ANT_RX_MAIN_SHIFT		2
+#define	ATH_ANT_RX_MASK			0x3
+
+#define	ATH_ANT_DIV_COMB_SHORT_SCAN_INTR	50
+#define	ATH_ANT_DIV_COMB_SHORT_SCAN_PKTCOUNT	0x100
+#define	ATH_ANT_DIV_COMB_MAX_PKTCOUNT		0x200
+#define	ATH_ANT_DIV_COMB_INIT_COUNT		95
+#define	ATH_ANT_DIV_COMB_MAX_COUNT		100
+#define	ATH_ANT_DIV_COMB_ALT_ANT_RATIO		30
+#define	ATH_ANT_DIV_COMB_ALT_ANT_RATIO2		20
+
+#define	ATH_ANT_DIV_COMB_LNA1_LNA2_DELTA	-3
+#define	ATH_ANT_DIV_COMB_LNA1_LNA2_SWITCH_DELTA	-1
+#define	ATH_ANT_DIV_COMB_LNA1_DELTA_HI		-4
+#define	ATH_ANT_DIV_COMB_LNA1_DELTA_MID		-2
+#define	ATH_ANT_DIV_COMB_LNA1_DELTA_LOW		2
+
+extern	void ar9285_ant_comb_scan(struct ath_hal *ah, struct ath_rx_status *rs,
+		unsigned long ticks, int hz);
+
+#endif

Modified: head/sys/modules/ath/Makefile
==============================================================================
--- head/sys/modules/ath/Makefile	Wed Apr 13 11:28:46 2011	(r220592)
+++ head/sys/modules/ath/Makefile	Wed Apr 13 11:32:15 2011	(r220593)
@@ -99,6 +99,7 @@ SRCS+=	ar9160_attach.c
 .PATH:	${.CURDIR}/../../dev/ath/ath_hal/ar9002
 SRCS+=	ar9280.c ar9280_attach.c ar9280_olc.c
 SRCS+=	ar9285.c ar9285_reset.c ar9285_attach.c ar9285_cal.c ar9285_phy.c
+SRCS+=	ar9285_diversity.c
 
 # NB: rate control is bound to the driver by symbol names so only pick one
 .if ${ATH_RATE} == "sample"

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 12:19:03 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 95CB2106564A;
	Wed, 13 Apr 2011 12:19:03 +0000 (UTC)
	(envelope-from pluknet@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 84B648FC0A;
	Wed, 13 Apr 2011 12:19:03 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DCJ3bE082888;
	Wed, 13 Apr 2011 12:19:03 GMT (envelope-from pluknet@svn.freebsd.org)
Received: (from pluknet@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DCJ3mF082886;
	Wed, 13 Apr 2011 12:19:03 GMT (envelope-from pluknet@svn.freebsd.org)
Message-Id: <201104131219.p3DCJ3mF082886@svn.freebsd.org>
From: Sergey Kandaurov 
Date: Wed, 13 Apr 2011 12:19:03 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220594 - head/sys/boot/forth
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 12:19:03 -0000

Author: pluknet
Date: Wed Apr 13 12:19:03 2011
New Revision: 220594
URL: http://svn.freebsd.org/changeset/base/220594

Log:
  Remove the now defunct kern.ipc.nmbufs tunable.
  
  PR:		kern/132497 (part)
  MFC after:	1 week

Modified:
  head/sys/boot/forth/loader.conf

Modified: head/sys/boot/forth/loader.conf
==============================================================================
--- head/sys/boot/forth/loader.conf	Wed Apr 13 11:32:15 2011	(r220593)
+++ head/sys/boot/forth/loader.conf	Wed Apr 13 12:19:03 2011	(r220594)
@@ -107,7 +107,6 @@ module_path="/boot/modules"	# Set the mo
 #kern.cam.scsi_delay="2000"	# Delay (in ms) before probing SCSI
 #kern.ipc.maxsockets=""		# Set the maximum number of sockets avaliable
 #kern.ipc.nmbclusters=""	# Set the number of mbuf clusters
-#kern.ipc.nmbufs=""		# Set the maximum number of mbufs
 #kern.ipc.nsfbufs=""		# Set the number of sendfile(2) bufs
 #net.inet.tcp.tcbhashsize=""	# Set the value of TCBHASHSIZE
 #vfs.root.mountfrom=""		# Specify root partition in a way the

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 12:46:25 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CB336106566C;
	Wed, 13 Apr 2011 12:46:25 +0000 (UTC) (envelope-from ru@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BA5878FC0A;
	Wed, 13 Apr 2011 12:46:25 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DCkPM1085011;
	Wed, 13 Apr 2011 12:46:25 GMT (envelope-from ru@svn.freebsd.org)
Received: (from ru@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DCkPDU085009;
	Wed, 13 Apr 2011 12:46:25 GMT (envelope-from ru@svn.freebsd.org)
Message-Id: <201104131246.p3DCkPDU085009@svn.freebsd.org>
From: Ruslan Ermilov 
Date: Wed, 13 Apr 2011 12:46:25 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220595 - head/sys/nfsclient
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 12:46:25 -0000

Author: ru
Date: Wed Apr 13 12:46:25 2011
New Revision: 220595
URL: http://svn.freebsd.org/changeset/base/220595

Log:
  - Fixed nfs_printf() to use vprintf().
  - Fixed vfs.nfs.acdebug sysctl's description.
  - Fixed panic when compiled with NFS_ACDEBUG.
  
  MFC after:	3 days

Modified:
  head/sys/nfsclient/nfs_subs.c

Modified: head/sys/nfsclient/nfs_subs.c
==============================================================================
--- head/sys/nfsclient/nfs_subs.c	Wed Apr 13 12:19:03 2011	(r220594)
+++ head/sys/nfsclient/nfs_subs.c	Wed Apr 13 12:46:25 2011	(r220595)
@@ -442,7 +442,7 @@ nfs_printf(const char *fmt, ...)
 
 	mtx_lock(&Giant);
 	va_start(ap, fmt);
-	printf(fmt, ap);
+	vprintf(fmt, ap);
 	va_end(ap);
 	mtx_unlock(&Giant);
 }
@@ -656,7 +656,7 @@ out:
 SYSCTL_DECL(_vfs_nfs);
 static int nfs_acdebug;
 SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0,
-    "Toggle acdebug (access cache debug) flag");
+    "Toggle acdebug (attribute cache debug) flag");
 #endif
 
 /*
@@ -713,6 +713,9 @@ nfs_getattrcache(struct vnode *vp, struc
 	if ((time_second - np->n_attrstamp) >= timeo) {
 		nfsstats.attrcache_misses++;
 		mtx_unlock(&np->n_mtx);
+#ifdef NFS_ACDEBUG
+		mtx_unlock(&Giant);	/* nfs_printf() */
+#endif
 		KDTRACE_NFS_ATTRCACHE_GET_MISS(vp);
 		return (ENOENT);
 	}

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 13:05:49 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5221E1065674;
	Wed, 13 Apr 2011 13:05:49 +0000 (UTC) (envelope-from ru@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 40F6E8FC21;
	Wed, 13 Apr 2011 13:05:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DD5nQn086543;
	Wed, 13 Apr 2011 13:05:49 GMT (envelope-from ru@svn.freebsd.org)
Received: (from ru@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DD5nbI086541;
	Wed, 13 Apr 2011 13:05:49 GMT (envelope-from ru@svn.freebsd.org)
Message-Id: <201104131305.p3DD5nbI086541@svn.freebsd.org>
From: Ruslan Ermilov 
Date: Wed, 13 Apr 2011 13:05:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220596 - head/usr.bin/nfsstat
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 13:05:49 -0000

Author: ru
Date: Wed Apr 13 13:05:48 2011
New Revision: 220596
URL: http://svn.freebsd.org/changeset/base/220596

Log:
  Show client's access cache statistics.

Modified:
  head/usr.bin/nfsstat/nfsstat.c

Modified: head/usr.bin/nfsstat/nfsstat.c
==============================================================================
--- head/usr.bin/nfsstat/nfsstat.c	Wed Apr 13 12:46:25 2011	(r220595)
+++ head/usr.bin/nfsstat/nfsstat.c	Wed Apr 13 13:05:48 2011	(r220596)
@@ -321,14 +321,15 @@ intpr(int clientOnly, int serverOnly)
 			nfsstats.write_bios);
 		printf("%9.9s %9.9s %9.9s %9.9s",
 			"BioRLHits", "Misses", "BioD Hits", "Misses");
-		printf(" %9.9s %9.9s\n", "DirE Hits", "Misses");
+		printf(" %9.9s %9.9s %9.9s %9.9s\n", "DirE Hits", "Misses", "Accs Hits", "Misses");
 		printf("%9d %9d %9d %9d",
 			nfsstats.biocache_readlinks-nfsstats.readlink_bios,
 			nfsstats.readlink_bios,
 			nfsstats.biocache_readdirs-nfsstats.readdir_bios,
 			nfsstats.readdir_bios);
-		printf(" %9d %9d\n",
-			nfsstats.direofcache_hits, nfsstats.direofcache_misses);
+		printf(" %9d %9d %9d %9d\n",
+			nfsstats.direofcache_hits, nfsstats.direofcache_misses,
+			nfsstats.accesscache_hits, nfsstats.accesscache_misses);
 	}
 	if (serverOnly && !nfsrvstatsp) {
 		printf("Server not present!\n");

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 13:24:27 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8A8B9106564A;
	Wed, 13 Apr 2011 13:24:27 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 789BB8FC08;
	Wed, 13 Apr 2011 13:24:27 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DDORud088038;
	Wed, 13 Apr 2011 13:24:27 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DDORFj088036;
	Wed, 13 Apr 2011 13:24:27 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <201104131324.p3DDORFj088036@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Wed, 13 Apr 2011 13:24:27 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220597 - head/sys/powerpc/powerpc
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 13:24:27 -0000

Author: nwhitehorn
Date: Wed Apr 13 13:24:27 2011
New Revision: 220597
URL: http://svn.freebsd.org/changeset/base/220597

Log:
  Make sure that extra threads in 32-bit processes stay in 32-bit mode. This
  fixes operation of threaded 32-bit binaries on 64-bit kernels.

Modified:
  head/sys/powerpc/powerpc/exec_machdep.c

Modified: head/sys/powerpc/powerpc/exec_machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/exec_machdep.c	Wed Apr 13 13:05:48 2011	(r220596)
+++ head/sys/powerpc/powerpc/exec_machdep.c	Wed Apr 13 13:24:27 2011	(r220597)
@@ -1015,6 +1015,9 @@ cpu_set_upcall_kse(struct thread *td, vo
 		tf->srr0 = (register_t)entry;
 	    #ifdef AIM
 		tf->srr1 = PSL_MBO | PSL_USERSET | PSL_FE_DFLT;
+		#ifdef __powerpc64__
+		tf->srr1 &= ~PSL_SF;
+		#endif
 	    #else
 		tf->srr1 = PSL_USERSET;
 	    #endif

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 14:33:52 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2D870106564A;
	Wed, 13 Apr 2011 14:33:52 +0000 (UTC) (envelope-from jh@FreeBSD.org)
Received: from gw01.mail.saunalahti.fi (gw01.mail.saunalahti.fi
	[195.197.172.115])
	by mx1.freebsd.org (Postfix) with ESMTP id 4967A8FC19;
	Wed, 13 Apr 2011 14:33:51 +0000 (UTC)
Received: from a91-153-123-205.elisa-laajakaista.fi
	(a91-153-123-205.elisa-laajakaista.fi [91.153.123.205])
	by gw01.mail.saunalahti.fi (Postfix) with SMTP id D650D1515F1;
	Wed, 13 Apr 2011 17:33:45 +0300 (EEST)
Date: Wed, 13 Apr 2011 17:33:45 +0300
From: Jaakko Heinonen 
To: Alexander Motin 
Message-ID: <20110413143345.GA1553@a91-153-123-205.elisa-laajakaista.fi>
References: <201104081442.p38EgUhl083322@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201104081442.p38EgUhl083322@svn.freebsd.org>
User-Agent: Mutt/1.5.21 (2010-09-15)
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220454 - in head: share/man/man4 sys/cam/ata
 sys/conf
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 14:33:52 -0000

On 2011-04-08, Alexander Motin wrote:
>   - Add kern.cam.ada.X.write_cache tunables/sysctls to control write caching
>   on per-device basis.

> --- head/sys/cam/ata/ata_da.c	Fri Apr  8 14:39:41 2011	(r220453)
> +++ head/sys/cam/ata/ata_da.c	Fri Apr  8 14:42:29 2011	(r220454)
> @@ -738,6 +773,10 @@ adaregister(struct cam_periph *periph, v
>  		softc->quirks = ((struct ada_quirk_entry *)match)->quirks;
>  	else
>  		softc->quirks = ADA_Q_NONE;
> +	softc->write_cache = -1;
> +	snprintf(announce_buf, sizeof(announce_buf),
> +	    "kern.cam.ada.%d.writa_cache", periph->unit_number);
                                ^^^
Typo.

> +	TUNABLE_INT_FETCH(announce_buf, &softc->write_cache);

TUNABLE_INT_FETCH() uses getenv() which may sleep (due to M_WAITOK
allocation). You will get a witness warning (see below) on a WITNESS
enabled kernel because the sim mutex is held in adaregister(). The
tunable must exist, otherwise getenv() doesn't allocate memory.

cd(4) has the same problem for kern.cam.cd.%d.minimum_cmd_size tunable
and da(4) for kern.cam.da.%d.minimum_cmd_size tunable.

I am considering adding WITNESS_WARN() to getenv() to expose these bugs
early.

uma_zalloc_arg: zone "16" with the following non-sleepable locks held:
exclusive sleep mutex ATA state lock (ATA state lock) r = 0 (0xc42e0174) locked @ /home/jaakko/src/head/sys/cam/cam_xpt.c:1991
KDB: stack backtrace:
db_trace_self_wrapper(c0cccf87,c0cca676,192,0,0,...) at db_trace_self_wrapper+0x26
kdb_backtrace(7c7,0,ffffffff,c0f8d60c,d8cc8cfc,...) at kdb_backtrace+0x2a
_witness_debugger(c0ccfeaa,d8cc8d10,4,1,0,...) at _witness_debugger+0x25
witness_warn(5,0,c0d0361e,c0c81bfe,c0cbef65,...) at witness_warn+0x1fe
uma_zalloc_arg(c15b99c0,0,2,2,0,...) at uma_zalloc_arg+0x34
malloc(2,c0dd29f0,2,156,310000,...) at malloc+0x113
getenv(d8cc90b8,d8cc8ec4,a,d8cc8efc,d8cc90b8,...) at getenv+0xea
getenv_quad(d8cc90b8,d8cc8ee0,d8cc8efc,d8cc8efc,d8cc9118,...) at getenv_quad+0x1a
getenv_int(d8cc90b8,c456b044,c0c2a8fe,0,c048d560,...) at getenv_int+0x18
adaregister(c4219080,d8cc9694,d8cc9170,0,0,...) at adaregister+0x1ef

-- 
Jaakko

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 14:51:07 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 951ED106566B;
	Wed, 13 Apr 2011 14:51:07 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 821D58FC0C;
	Wed, 13 Apr 2011 14:51:07 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DEp7IY094782;
	Wed, 13 Apr 2011 14:51:07 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DEp7Ha094780;
	Wed, 13 Apr 2011 14:51:07 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104131451.p3DEp7Ha094780@svn.freebsd.org>
From: Adrian Chadd 
Date: Wed, 13 Apr 2011 14:51:07 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220598 - head/sys/dev/ath/ath_hal/ar5416
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 14:51:07 -0000

Author: adrian
Date: Wed Apr 13 14:51:07 2011
New Revision: 220598
URL: http://svn.freebsd.org/changeset/base/220598

Log:
  Change this to be less noisy.

Modified:
  head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Wed Apr 13 13:24:27 2011	(r220597)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Wed Apr 13 14:51:07 2011	(r220598)
@@ -1228,7 +1228,7 @@ ar5416UpdateChainMasks(struct ath_hal *a
 		AH5416(ah)->ah_tx_chainmask = 1;
 	}
 	AH5416(ah)->ah_rx_chainmask = pCap->halRxChainMask;
-	HALDEBUG(ah, HAL_DEBUG_ANY, "TX chainmask: 0x%x; RX chainmask: 0x%x\n",
+	HALDEBUG(ah, HAL_DEBUG_RESET, "TX chainmask: 0x%x; RX chainmask: 0x%x\n",
 	    AH5416(ah)->ah_tx_chainmask,
 	    AH5416(ah)->ah_rx_chainmask);
 }

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 15:08:51 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CEFAC1065670;
	Wed, 13 Apr 2011 15:08:51 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A11D78FC19;
	Wed, 13 Apr 2011 15:08:51 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DF8pPS096165;
	Wed, 13 Apr 2011 15:08:51 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DF8pFw096162;
	Wed, 13 Apr 2011 15:08:51 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104131508.p3DF8pFw096162@svn.freebsd.org>
From: Adrian Chadd 
Date: Wed, 13 Apr 2011 15:08:51 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220599 - in head/sys/dev/ath/ath_hal: . ar9002
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 15:08:51 -0000

Author: adrian
Date: Wed Apr 13 15:08:51 2011
New Revision: 220599
URL: http://svn.freebsd.org/changeset/base/220599

Log:
  More kite diversity related changes.
  
  * add a diversity flag to the HAL debugging section
  * add a check to make sure the kite diversity code doesn't run
    on boards that don't require it, as not all Kite chips will
    implement it.
  * add some debug statements when the diversity code makes
    changes to the antenna diversity/combining setup.

Modified:
  head/sys/dev/ath/ath_hal/ah_debug.h
  head/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c

Modified: head/sys/dev/ath/ath_hal/ah_debug.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_debug.h	Wed Apr 13 14:51:07 2011	(r220598)
+++ head/sys/dev/ath/ath_hal/ah_debug.h	Wed Apr 13 15:08:51 2011	(r220599)
@@ -44,6 +44,7 @@ enum {
 	HAL_DEBUG_POWER		= 0x00020000,	/* power management */
 	HAL_DEBUG_GPIO		= 0x00040000,	/* GPIO debugging */
 	HAL_DEBUG_INTERRUPT	= 0x00080000,	/* interrupt handling */
+	HAL_DEBUG_DIVERSITY	= 0x00100000,	/* diversity debugging */
 
 	HAL_DEBUG_ANY		= 0xffffffff
 };

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c	Wed Apr 13 14:51:07 2011	(r220598)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c	Wed Apr 13 15:08:51 2011	(r220599)
@@ -371,6 +371,9 @@ ar9285_ant_comb_scan(struct ath_hal *ah,
 	int rx_ant_conf, main_ant_conf;
 	HAL_BOOL short_scan = AH_FALSE;
 
+	if (! ar9285_check_div_comb(ah))
+		return;
+
 	rx_ant_conf = (rs->rs_rssi_ctl[2] >> ATH_ANT_RX_CURRENT_SHIFT) &
 		       ATH_ANT_RX_MASK;
 	main_ant_conf = (rs->rs_rssi_ctl[2] >> ATH_ANT_RX_MAIN_SHIFT) &
@@ -415,7 +418,6 @@ ar9285_ant_comb_scan(struct ath_hal *ah,
 				 antcomb->total_pkt_count);
 	}
 
-
 	ar9285_antdiv_comb_conf_get(ah, &div_ant_conf);
 	curr_alt_set = div_ant_conf.alt_lna_conf;
 	curr_main_set = div_ant_conf.main_lna_conf;
@@ -585,6 +587,16 @@ div_comb_done:
 
 	ar9285_antdiv_comb_conf_set(ah, &div_ant_conf);
 
+	if (curr_alt_set != div_ant_conf.alt_lna_conf)
+		HALDEBUG(ah, HAL_DEBUG_DIVERSITY, "%s: lna_conf: %x -> %x\n",
+		    __func__, curr_alt_set, div_ant_conf.alt_lna_conf);
+	if (curr_main_set != div_ant_conf.main_lna_conf)
+		HALDEBUG(ah, HAL_DEBUG_DIVERSITY, "%s: main_lna_conf: %x -> %x\n",
+		    __func__, curr_main_set, div_ant_conf.main_lna_conf);
+	if (curr_bias != div_ant_conf.fast_div_bias)
+		HALDEBUG(ah, HAL_DEBUG_DIVERSITY, "%s: fast_div_bias: %x -> %x\n",
+		    __func__, curr_bias, div_ant_conf.fast_div_bias);
+
 	antcomb->scan_start_time = ticks;
 	antcomb->total_pkt_count = 0;
 	antcomb->main_total_rssi = 0;

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 15:12:49 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F3B9F1065689;
	Wed, 13 Apr 2011 15:12:48 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C60A78FC16;
	Wed, 13 Apr 2011 15:12:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DFCmeX096516;
	Wed, 13 Apr 2011 15:12:48 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DFCmuL096513;
	Wed, 13 Apr 2011 15:12:48 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104131512.p3DFCmuL096513@svn.freebsd.org>
From: Adrian Chadd 
Date: Wed, 13 Apr 2011 15:12:48 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220600 - in head/sys/dev/ath/ath_hal: . ar9002
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 15:12:49 -0000

Author: adrian
Date: Wed Apr 13 15:12:48 2011
New Revision: 220600
URL: http://svn.freebsd.org/changeset/base/220600

Log:
  Add in the last bit of the HAL support for Kite diversity.
  
  * add a new method, specifically for doing per-RX packet
    antenna diversity
  * set that HAL method only if it's Kite and a Kite chip that
    does diversity.

Modified:
  head/sys/dev/ath/ath_hal/ah.h
  head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c

Modified: head/sys/dev/ath/ath_hal/ah.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.h	Wed Apr 13 15:08:51 2011	(r220599)
+++ head/sys/dev/ath/ath_hal/ah.h	Wed Apr 13 15:12:48 2011	(r220600)
@@ -767,6 +767,9 @@ struct ath_hal {
 				const struct ieee80211_channel *);
 	void	  __ahdecl(*ah_procMibEvent)(struct ath_hal *,
 				const HAL_NODE_STATS *);
+	void	  __ahdecl(*ah_rxAntCombDiversity)(struct ath_hal *,
+				struct ath_rx_status *,
+				unsigned long, int);
 
 	/* Misc Functions */
 	HAL_STATUS __ahdecl(*ah_getCapability)(struct ath_hal *,

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c	Wed Apr 13 15:08:51 2011	(r220599)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c	Wed Apr 13 15:12:48 2011	(r220600)
@@ -34,6 +34,8 @@
 #include "ar9002/ar9280v2.ini"		/* XXX ini for tx/rx gain */
 
 #include "ar9002/ar9285_cal.h"
+#include "ar9002/ar9285_phy.h"
+#include "ar9002/ar9285_diversity.h"
 
 static const HAL_PERCAL_DATA ar9280_iq_cal = {		/* single sample */
 	.calName = "IQ", .calType = IQ_MISMATCH_CAL,
@@ -262,6 +264,12 @@ ar9285Attach(uint16_t devid, HAL_SOFTC s
 		goto bad;
 	}
 
+	/* Print out whether the EEPROM settings enable AR9285 diversity */
+	if (ar9285_check_div_comb(ah)) {
+		ath_hal_printf(ah, "[ath] Enabling diversity for Kite\n");
+		ah->ah_rxAntCombDiversity = ar9285_ant_comb_scan;
+	}
+
 	/* Disable 11n for the AR2427 */
 	if (devid == AR2427_DEVID_PCIE)
 		AH_PRIVATE(ah)->ah_caps.halHTSupport = AH_FALSE;

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 15:17:23 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 61A42106564A;
	Wed, 13 Apr 2011 15:17:23 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4E5A48FC13;
	Wed, 13 Apr 2011 15:17:23 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DFHNSk096906;
	Wed, 13 Apr 2011 15:17:23 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DFHNZ0096904;
	Wed, 13 Apr 2011 15:17:23 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104131517.p3DFHNZ0096904@svn.freebsd.org>
From: Adrian Chadd 
Date: Wed, 13 Apr 2011 15:17:23 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220601 - head/sys/dev/ath
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 15:17:23 -0000

Author: adrian
Date: Wed Apr 13 15:17:23 2011
New Revision: 220601
URL: http://svn.freebsd.org/changeset/base/220601

Log:
  Add in the AR9285 (Kite) diversity to if_ath, enabling TX/RX antenna
  diversity.
  
  This is bit dirty and likely should be revised at a later date,
  with an eye to unifying/tidying up the whole diversity setup
  and allowing developers to do "tricky stuff" as they desire.
  For now, this works.

Modified:
  head/sys/dev/ath/if_ath.c

Modified: head/sys/dev/ath/if_ath.c
==============================================================================
--- head/sys/dev/ath/if_ath.c	Wed Apr 13 15:12:48 2011	(r220600)
+++ head/sys/dev/ath/if_ath.c	Wed Apr 13 15:17:23 2011	(r220601)
@@ -3615,6 +3615,12 @@ rx_accept:
 			} else
 				sc->sc_rxotherant = 0;
 		}
+
+		/* Newer school diversity - kite specific for now */
+		/* XXX perhaps migrate the normal diversity code to this? */
+		if ((ah)->ah_rxAntCombDiversity)
+			(*(ah)->ah_rxAntCombDiversity)(ah, rs, ticks, hz);
+
 		if (sc->sc_softled) {
 			/*
 			 * Blink for any data frame.  Otherwise do a

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 15:51:41 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E3AB1106566B;
	Wed, 13 Apr 2011 15:51:41 +0000 (UTC)
	(envelope-from pawel@dawidek.net)
Received: from mail.garage.freebsd.pl (60.wheelsystems.com [83.12.187.60])
	by mx1.freebsd.org (Postfix) with ESMTP id 1E9448FC0C;
	Wed, 13 Apr 2011 15:51:40 +0000 (UTC)
Received: by mail.garage.freebsd.pl (Postfix, from userid 65534)
	id 33DBE45F20; Wed, 13 Apr 2011 17:51:38 +0200 (CEST)
Received: from localhost (host-80-54-90-198.eimg.pl [80.54.90.198])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mail.garage.freebsd.pl (Postfix) with ESMTP id B73C445C8A;
	Wed, 13 Apr 2011 17:51:31 +0200 (CEST)
Date: Wed, 13 Apr 2011 17:51:21 +0200
From: Pawel Jakub Dawidek 
To: Adrian Chadd 
Message-ID: <20110413155121.GU40382@garage.freebsd.pl>
References: <201104120810.p3C8AQs0014704@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="gSSGYPGSs0dvYOj7"
Content-Disposition: inline
In-Reply-To: <201104120810.p3C8AQs0014704@svn.freebsd.org>
X-OS: FreeBSD 9.0-CURRENT amd64
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on 
	mail.garage.freebsd.pl
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=4.5 tests=BAYES_00 autolearn=ham 
	version=3.0.4
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220559 - in head/sys: conf geom
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 15:51:42 -0000


--gSSGYPGSs0dvYOj7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Apr 12, 2011 at 08:10:26AM +0000, Adrian Chadd wrote:
> Author: adrian
> Date: Tue Apr 12 08:10:25 2011
> New Revision: 220559
> URL: http://svn.freebsd.org/changeset/base/220559
>=20
> Log:
>   Introduce geom_map, a GEOM provider designed for use by
>   embedded flash stores.
>  =20
>   Some devices - notably those with uboot - don't have an
>   explicit partition table (eg like Redboot's FIS.)
>   geom_map thus provides an easy way to export the hard-coded
>   flash layout as geom providers for use by filesystems and
>   other tools.
>  =20
>   It also includes a "search" function which allows for
>   dynamic creation of partition layouts where the device only
>   has a single hard-coded partition. For example, if
>   there is a "kernel+rootfs" partition, a single image can
>   be created which appends the rootfs after the kernel with
>   an appropriate search string. geom_map can be told to
>   search for said search string and create a partition
>   beginning after it.
>  =20
>   Submitted by:	Aleksandr Rybalko 

I'm sorry for not finding time to review this change before your commit,
but I do have some comments.

Before I get to the code, I'd like to state that I fully agree with
Andrew Thompson that having 4GB limit is really wrong. We had this
bigdisk project for a long time trying to remove all such old
assumptions about disk sizes and committing a GEOM class that have a
limit of 4GB for media size is really wrong direction. We should really
treat this as a policy for new GEOM classes. Changing GEOM_MAP to work
with 64bit offsets is not a big change and I'd really like to see it
being committed. Maybe Aleksandr (CCed) would like to work on this?

> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 

I'd move empty line from above sys/sbuf.h to below it.

> +#define MAP_CLASS_NAME "MAP"

Spaces here should be replaced with tabs.

> +struct map_desc {
> +	uint8_t		name   [16];	/* null-terminated name */

I'd remove white-spaces between array name and size. Also in other
places.

> +static int
> +g_map_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, st=
ruct thread *td)
> +{
> +	return (ENOIOCTL);
> +}

This can be removed. If the ioctl method is not specified, GEOM will
return ENOIOCTL for you.

> +static int
> +g_map_access(struct g_provider *pp, int dread, int dwrite, int dexcl)
> +{
> +	struct g_geom  *gp =3D pp->geom;

Two spaces instead of one. You can also think about moving
initializations below declarations.

> +	struct g_slicer *gsp =3D gp->softc;
> +	struct g_map_softc *sc =3D gsp->softc;

> +static int
> +g_map_start(struct bio *bp)
> +{
> +	struct g_provider *pp;
> +	struct g_geom  *gp;

Two spaces instead of one.

> +	struct g_map_softc *sc;
> +	struct g_slicer *gsp;
> +	int		idx;

Tabs instead of single space.

> +	pp =3D bp->bio_to;
> +	idx =3D pp->index;
> +	gp =3D pp->geom;
> +	gsp =3D gp->softc;
> +	sc =3D gsp->softc;
> +	if (bp->bio_cmd =3D=3D BIO_GETATTR) {
> +		if (g_handleattr_int(bp, MAP_CLASS_NAME "::entry",
> +				     sc->entry[idx]))
> +			return (1);
> +		if (g_handleattr_int(bp, MAP_CLASS_NAME "::dsize",
> +				     sc->dsize[idx]))
> +			return (1);

This should look like this:

		if (g_handleattr_int(bp, MAP_CLASS_NAME "::entry",
		    sc->entry[idx])) {
			return (1);
		}
		if (g_handleattr_int(bp, MAP_CLASS_NAME "::dsize",
		    sc->dsize[idx])) {
			return (1);
		}

> +static void
> +g_map_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
> +	       struct g_consumer *cp __unused, struct g_provider *pp)

The line should be started with four spaces.

> +		if (indent =3D=3D NULL) {
> +			sbuf_printf(sb, " entry %d", sc->entry[pp->index]);
> +			sbuf_printf(sb, " dsize %d", sc->dsize[pp->index]);
> +		} else {
> +			sbuf_printf(sb, "%s%d\n", indent,
> +				    sc->entry[pp->index]);
> +			sbuf_printf(sb, "%s%d\n", indent,
> +				    sc->dsize[pp->index]);
> +		}

Line should be continued using four spaces.

> +#include 

This shouldn't be here.

> +static struct g_geom *
> +g_map_taste(struct g_class *mp, struct g_provider *pp, int insist)
> +{
> +	struct g_geom  *gp;
> +	struct g_consumer *cp;
> +	struct g_map_softc *sc;
> +	int		error     , sectorsize, i, ret;
> +	struct map_desc *head;
> +	u_int32_t	start =3D 0, end =3D 0, size =3D 0, off, readonly;
> +	const char     *name;
> +	const char     *at;
> +	const char     *search;
> +	int		search_start =3D 0, search_end =3D 0;
> +	u_char         *buf;
> +	uint32_t	offmask;
> +	u_int		blksize;/* NB: flash block size stored as stripesize */
> +	off_t		offset;

White-spaces need cleanups.

Three 'const char *' should use single line.

uint32_t is preferred over u_int32_t and only one of them should be used
for consistency.

> +	g_trace(G_T_TOPOLOGY, "map_taste(%s,%s)", mp->name, pp->name);
> +	g_topology_assert();
> +	if (!strcmp(pp->geom->class->name, MAP_CLASS_NAME))

strcmp() doesn't return bool, it returns int so should be compared to 0.

> +	gp =3D g_slice_new(mp, MAP_MAXSLICE, pp, &cp, &sc, sizeof(*sc),
> +			 g_map_start);

Four spaces.

> +	if (powerof2(cp->provider->mediasize))
> +		offmask =3D cp->provider->mediasize - 1;
> +	else
> +		offmask =3D 0xffffffff;	/* XXX */
> +
> +	g_topology_unlock();
> +	head =3D NULL;
> +	offset =3D cp->provider->mediasize - blksize;
> +	g_topology_lock();

Why do you drop the topology lock here? Seems wrong.

> +	for (i =3D 0; i < MAP_MAXSLICE; i++) {
> +		search_start =3D search_end =3D start =3D end =3D off =3D readonly =3D=
 0;
> +
> +		ret =3D resource_string_value("map", i, "at", &at);
> +		if (ret)
> +			continue;

'ret' is not bool.

> +
> +		/* Check if my provider */
> +		if (strncmp(pp->name, at, strlen(at)))
> +			continue;

strncmp() is not bool.

> +		ret =3D resource_string_value("map", i, "start", &search);
> +
> +		if (!ret && strncmp(search, "search", 6) =3D=3D 0) {
> +			uint32_t search_offset, search_start =3D 0;
> +			uint32_t search_step =3D 0;
> +			const char *search_key;
> +			char key[255];
> +			int c;
> +
> +			ret =3D resource_int_value("map", i, "searchstart",
> +						 &search_start);
> +			ret =3D resource_int_value("map", i, "searchstep",
> +						 &search_step);

Four spaces.

> +			printf("GEOM_MAP: searchkey=3D\"%s\"\n", search_key);

Is this a leftover debug printf?

> +			for (search_offset =3D search_start;
> +			     search_offset < cp->provider->mediasize && start =3D=3D 0;
> +			     search_offset +=3D search_step) {
> +				buf =3D g_read_data(cp,=20
> +					rounddown(search_offset, sectorsize),=20
> +					roundup(strlen(search_key), sectorsize),=20
> +					NULL);

Four spaces.

It is better to drop the topology lock when doing g_read_data().

> +				if (buf !=3D NULL && strncmp(
> +					buf + search_offset % sectorsize,=20
> +					key, strlen(search_key)) =3D=3D 0)
> +					start =3D search_offset;

This is good example why do we use four spaces to continue previous
line. In the above code it is hard to see where the diff ends and where
the code begins.

> +			ret =3D resource_int_value("map", i, "searchstart", &search_start);
> +			ret =3D resource_int_value("map", i, "searchstep", &search_step);
> +			if (ret)
> +				search_step =3D 0x10000U;

First 'ret' is not checked.

> +				buf =3D g_read_data(cp,=20
> +					rounddown(search_offset, sectorsize),=20
> +					roundup(strlen(search_key), sectorsize),=20
> +					NULL);

Again, it is better to drop the topology lock.

> +		ret =3D resource_int_value("map", i, "offset", &off);
> +		ret =3D resource_int_value("map", i, "readonly", &readonly);
> +		ret =3D resource_string_value("map", i, "name", &name);
> +		/* No name or error read name */
> +		if (ret)
> +			continue;

First and second 'ret' is not checked.

> +		if (off > size)
> +			printf("%s: off(%d) > size(%d) for \"%s\"\n",=20
> +				__func__, off, size, name);

Is this a leftover debug printf?

> +		error =3D g_slice_config(gp, i, G_SLICE_CONFIG_SET, start + off,=20
> +			size - off, sectorsize, "map/%s", name);

Four spaces.

> +		printf("MAP: %08x-%08x, offset=3D%08x \"map/%s\"\n",
> +			       (uint32_t) start,
> +			       (uint32_t) size,
> +			       (uint32_t) off,
> +			       name
> +			       );

Four spaces.

Not need to separate cast and variable with space.

> +		if (error)
> +			printf("%s g_slice_config returns %d for \"%s\"\n",=20
> +				__func__, error, name);

Leftover debug printf?

> +		sc->entry[i] =3D off;
> +		sc->dsize[i] =3D size - off;
> +		sc->readonly[i] =3D readonly ? 1 : 0;
> +	}
> +=09
> +
> +	if (i =3D=3D 0)
> +		return (NULL);

Redundant empty line before 'if'.

> +static void
> +g_map_config(struct gctl_req *req, struct g_class *mp, const char *verb)
> +{
> +	struct g_geom  *gp;
> +
> +	g_topology_assert();
> +	gp =3D gctl_get_geom(req, mp, "geom");
> +	if (gp =3D=3D NULL)
> +		return;
> +	gctl_error(req, "Unknown verb");
> +}

Seems to be a no-op. GEOM can cope if this method is not specified.

--=20
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

--gSSGYPGSs0dvYOj7
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAk2lxngACgkQForvXbEpPzSgKACeM/fQzuiH5yafKOuMMqOEojqP
rqsAoNGr3V9zQLddb7/U2UIcjlqqHsxz
=ZpLd
-----END PGP SIGNATURE-----

--gSSGYPGSs0dvYOj7--

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 16:20:54 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C6B1A106566C;
	Wed, 13 Apr 2011 16:20:54 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A75588FC18;
	Wed, 13 Apr 2011 16:20:54 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DGKsi9001986;
	Wed, 13 Apr 2011 16:20:54 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DGKsZX001977;
	Wed, 13 Apr 2011 16:20:54 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104131620.p3DGKsZX001977@svn.freebsd.org>
From: Alexander Motin 
Date: Wed, 13 Apr 2011 16:20:54 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220602 - in head/sys: cam cam/ata dev/ahci dev/mvs
	dev/siis sys
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 16:20:55 -0000

Author: mav
Date: Wed Apr 13 16:20:54 2011
New Revision: 220602
URL: http://svn.freebsd.org/changeset/base/220602

Log:
  Improve SATA Asynchronous Notification feature support in CAM:
   - make SATA SIMs announce capabilities to handle SDB with Notification bit;
   - make PMP driver honor this SIMs capability;
   - make SATA XPT to negotiate and enable this feature for ATAPI devices.
  
  This feature allows supporting SATA ATAPI devices to inform system about
  some events happened, that may require attention. In my case this allows
  LG GH22LS50 SATA DVR-RW drive to report tray open/close events. Events
  reported to CAM in form of AC_SCSI_AEN async. Further they could be used
  as a hints for checking device status and reporting media change to upper
  layers, for example, via spoiling mechanism of GEOM.

Modified:
  head/sys/cam/ata/ata_pmp.c
  head/sys/cam/ata/ata_xpt.c
  head/sys/cam/cam_ccb.h
  head/sys/dev/ahci/ahci.c
  head/sys/dev/mvs/mvs.c
  head/sys/dev/siis/siis.c
  head/sys/sys/ata.h

Modified: head/sys/cam/ata/ata_pmp.c
==============================================================================
--- head/sys/cam/ata/ata_pmp.c	Wed Apr 13 15:17:23 2011	(r220601)
+++ head/sys/cam/ata/ata_pmp.c	Wed Apr 13 16:20:54 2011	(r220602)
@@ -533,7 +533,8 @@ pmpstart(struct cam_periph *periph, unio
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
 		      pmp_default_timeout * 1000);
-		ata_pm_write_cmd(ataio, 0x60, 15, 0xf);
+		ata_pm_write_cmd(ataio, 0x60, 15, 0x07 |
+		    ((softc->caps & CTS_SATA_CAPS_H_AN) ? 0x08 : 0));
 		break;
 	default:
 		break;
@@ -672,7 +673,9 @@ pmpdone(struct cam_periph *periph, union
 				cts.xport_specific.sata.revision = (res & 0x0f0) >> 4;
 				cts.xport_specific.sata.valid = CTS_SATA_VALID_REVISION;
 				cts.xport_specific.sata.caps = softc->caps &
-				    (CTS_SATA_CAPS_H_PMREQ | CTS_SATA_CAPS_H_DMAAA);
+				    (CTS_SATA_CAPS_H_PMREQ |
+				     CTS_SATA_CAPS_H_DMAAA |
+				     CTS_SATA_CAPS_H_AN);
 				cts.xport_specific.sata.valid |= CTS_SATA_VALID_CAPS;
 				xpt_action((union ccb *)&cts);
 				xpt_free_path(dpath);

Modified: head/sys/cam/ata/ata_xpt.c
==============================================================================
--- head/sys/cam/ata/ata_xpt.c	Wed Apr 13 15:17:23 2011	(r220601)
+++ head/sys/cam/ata/ata_xpt.c	Wed Apr 13 16:20:54 2011	(r220602)
@@ -87,6 +87,7 @@ typedef enum {
 	PROBE_SETPM,
 	PROBE_SETAPST,
 	PROBE_SETDMAAA,
+	PROBE_SETAN,
 	PROBE_SET_MULTI,
 	PROBE_INQUIRY,
 	PROBE_FULL_INQUIRY,
@@ -103,6 +104,7 @@ static char *probe_action_text[] = {
 	"PROBE_SETPM",
 	"PROBE_SETAPST",
 	"PROBE_SETDMAAA",
+	"PROBE_SETAN",
 	"PROBE_SET_MULTI",
 	"PROBE_INQUIRY",
 	"PROBE_FULL_INQUIRY",
@@ -436,6 +438,19 @@ negotiate:
 		    (softc->caps & CTS_SATA_CAPS_H_DMAAA) ? 0x10 : 0x90,
 		    0, 0x02);
 		break;
+	case PROBE_SETAN:
+		cam_fill_ataio(ataio,
+		    1,
+		    probedone,
+		    CAM_DIR_NONE,
+		    0,
+		    NULL,
+		    0,
+		    30*1000);
+		ata_28bit_cmd(ataio, ATA_SETFEATURES,
+		    (softc->caps & CTS_SATA_CAPS_H_AN) ? 0x10 : 0x90,
+		    0, 0x05);
+		break;
 	case PROBE_SET_MULTI:
 	{
 		u_int sectors, bytecount;
@@ -1027,6 +1042,16 @@ noerror:
 		}
 		/* FALLTHROUGH */
 	case PROBE_SETDMAAA:
+		if ((ident_buf->satasupport & ATA_SUPPORT_ASYNCNOTIF) &&
+		    (!(softc->caps & CTS_SATA_CAPS_H_AN)) !=
+		    (!(ident_buf->sataenabled & ATA_SUPPORT_ASYNCNOTIF))) {
+			PROBE_SET_ACTION(softc, PROBE_SETAN);
+			xpt_release_ccb(done_ccb);
+			xpt_schedule(periph, priority);
+			return;
+		}
+		/* FALLTHROUGH */
+	case PROBE_SETAN:
 notsata:
 		if (path->device->protocol == PROTO_ATA) {
 			PROBE_SET_ACTION(softc, PROBE_SET_MULTI);

Modified: head/sys/cam/cam_ccb.h
==============================================================================
--- head/sys/cam/cam_ccb.h	Wed Apr 13 15:17:23 2011	(r220601)
+++ head/sys/cam/cam_ccb.h	Wed Apr 13 16:20:54 2011	(r220602)
@@ -889,6 +889,7 @@ struct ccb_trans_settings_sata {
 #define	CTS_SATA_CAPS_H_PMREQ		0x00000001
 #define	CTS_SATA_CAPS_H_APST		0x00000002
 #define	CTS_SATA_CAPS_H_DMAAA		0x00000010 /* Auto-activation */
+#define	CTS_SATA_CAPS_H_AN		0x00000020 /* Async. notification */
 #define	CTS_SATA_CAPS_D			0xffff0000
 #define	CTS_SATA_CAPS_D_PMREQ		0x00010000
 #define	CTS_SATA_CAPS_D_APST		0x00020000

Modified: head/sys/dev/ahci/ahci.c
==============================================================================
--- head/sys/dev/ahci/ahci.c	Wed Apr 13 15:17:23 2011	(r220601)
+++ head/sys/dev/ahci/ahci.c	Wed Apr 13 16:20:54 2011	(r220602)
@@ -914,7 +914,8 @@ ahci_ch_attach(device_t dev)
 			    CTS_SATA_CAPS_H_APST |
 			    CTS_SATA_CAPS_D_PMREQ | CTS_SATA_CAPS_D_APST;
 		}
-		ch->user[i].caps |= CTS_SATA_CAPS_H_DMAAA;
+		ch->user[i].caps |= CTS_SATA_CAPS_H_DMAAA |
+		    CTS_SATA_CAPS_H_AN;
 	}
 	rid = ch->unit;
 	if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
@@ -2721,6 +2722,7 @@ ahciaction(struct cam_sim *sim, union cc
 			if ((ch->caps & AHCI_CAP_SNCQ) &&
 			    (ch->quirks & AHCI_Q_NOAA) == 0)
 				cts->xport_specific.sata.caps |= CTS_SATA_CAPS_H_DMAAA;
+			cts->xport_specific.sata.caps |= CTS_SATA_CAPS_H_AN;
 			cts->xport_specific.sata.caps &=
 			    ch->user[ccb->ccb_h.target_id].caps;
 			cts->xport_specific.sata.valid |= CTS_SATA_VALID_CAPS;

Modified: head/sys/dev/mvs/mvs.c
==============================================================================
--- head/sys/dev/mvs/mvs.c	Wed Apr 13 15:17:23 2011	(r220601)
+++ head/sys/dev/mvs/mvs.c	Wed Apr 13 16:20:54 2011	(r220602)
@@ -138,6 +138,7 @@ mvs_ch_attach(device_t dev)
 			    CTS_SATA_CAPS_H_APST |
 			    CTS_SATA_CAPS_D_PMREQ | CTS_SATA_CAPS_D_APST;
 		}
+		ch->user[i].caps |= CTS_SATA_CAPS_H_AN;
 	}
 	rid = ch->unit;
 	if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
@@ -861,6 +862,8 @@ mvs_legacy_intr(device_t dev)
 			if (mvs_wait(dev, ATA_S_DRQ, ATA_S_BUSY, 1000) < 0) {
 			    device_printf(dev, "timeout waiting for read DRQ\n");
 			    et = MVS_ERR_TIMEOUT;
+			    xpt_freeze_simq(ch->sim, 1);
+			    ch->toslots |= (1 << slot->slot);
 			    goto end_finished;
 			}
 			ATA_INSW_STRM(ch->r_mem, ATA_DATA,
@@ -880,6 +883,8 @@ mvs_legacy_intr(device_t dev)
 				    device_printf(dev,
 					"timeout waiting for write DRQ\n");
 				    et = MVS_ERR_TIMEOUT;
+				    xpt_freeze_simq(ch->sim, 1);
+				    ch->toslots |= (1 << slot->slot);
 				    goto end_finished;
 				}
 				ATA_OUTSW_STRM(ch->r_mem, ATA_DATA,
@@ -1325,6 +1330,8 @@ mvs_legacy_execute_transaction(struct mv
 			if (mvs_wait(dev, ATA_S_DRQ, ATA_S_BUSY, 1000) < 0) {
 				device_printf(dev,
 				    "timeout waiting for write DRQ\n");
+				xpt_freeze_simq(ch->sim, 1);
+				ch->toslots |= (1 << slot->slot);
 				mvs_end_transaction(slot, MVS_ERR_TIMEOUT);
 				return;
 			}
@@ -1351,6 +1358,8 @@ mvs_legacy_execute_transaction(struct mv
 		/* Wait for ready to write ATAPI command block */
 		if (mvs_wait(dev, 0, ATA_S_BUSY, 1000) < 0) {
 			device_printf(dev, "timeout waiting for ATAPI !BUSY\n");
+			xpt_freeze_simq(ch->sim, 1);
+			ch->toslots |= (1 << slot->slot);
 			mvs_end_transaction(slot, MVS_ERR_TIMEOUT);
 			return;
 		}
@@ -1367,6 +1376,8 @@ mvs_legacy_execute_transaction(struct mv
 		if (timeout <= 0) {
 			device_printf(dev,
 			    "timeout waiting for ATAPI command ready\n");
+			xpt_freeze_simq(ch->sim, 1);
+			ch->toslots |= (1 << slot->slot);
 			mvs_end_transaction(slot, MVS_ERR_TIMEOUT);
 			return;
 		}
@@ -2205,6 +2216,7 @@ mvsaction(struct cam_sim *sim, union ccb
 			cts->xport_specific.sata.caps = d->caps & CTS_SATA_CAPS_D;
 //			if (ch->pm_level)
 //				cts->xport_specific.sata.caps |= CTS_SATA_CAPS_H_PMREQ;
+			cts->xport_specific.sata.caps |= CTS_SATA_CAPS_H_AN;
 			cts->xport_specific.sata.caps &=
 			    ch->user[ccb->ccb_h.target_id].caps;
 			cts->xport_specific.sata.valid |= CTS_SATA_VALID_CAPS;
@@ -2212,6 +2224,9 @@ mvsaction(struct cam_sim *sim, union ccb
 			cts->xport_specific.sata.revision = d->revision;
 			cts->xport_specific.sata.valid |= CTS_SATA_VALID_REVISION;
 			cts->xport_specific.sata.caps = d->caps;
+			if (cts->type == CTS_TYPE_CURRENT_SETTINGS/* &&
+			    (ch->quirks & MVS_Q_GENIIE) == 0*/)
+				cts->xport_specific.sata.caps &= ~CTS_SATA_CAPS_H_AN;
 			cts->xport_specific.sata.valid |= CTS_SATA_VALID_CAPS;
 		}
 		cts->xport_specific.sata.mode = d->mode;

Modified: head/sys/dev/siis/siis.c
==============================================================================
--- head/sys/dev/siis/siis.c	Wed Apr 13 15:17:23 2011	(r220601)
+++ head/sys/dev/siis/siis.c	Wed Apr 13 16:20:54 2011	(r220602)
@@ -474,6 +474,7 @@ siis_ch_attach(device_t dev)
 		ch->curr[i] = ch->user[i];
 		if (ch->pm_level)
 			ch->user[i].caps = CTS_SATA_CAPS_H_PMREQ;
+		ch->user[i].caps |= CTS_SATA_CAPS_H_AN;
 	}
 	mtx_init(&ch->mtx, "SIIS channel lock", NULL, MTX_DEF);
 	rid = ch->unit;
@@ -1869,6 +1870,7 @@ siisaction(struct cam_sim *sim, union cc
 			cts->xport_specific.sata.caps = d->caps & CTS_SATA_CAPS_D;
 			if (ch->pm_level)
 				cts->xport_specific.sata.caps |= CTS_SATA_CAPS_H_PMREQ;
+			cts->xport_specific.sata.caps |= CTS_SATA_CAPS_H_AN;
 			cts->xport_specific.sata.caps &=
 			    ch->user[ccb->ccb_h.target_id].caps;
 			cts->xport_specific.sata.valid |= CTS_SATA_VALID_CAPS;
@@ -1876,6 +1878,9 @@ siisaction(struct cam_sim *sim, union cc
 			cts->xport_specific.sata.revision = d->revision;
 			cts->xport_specific.sata.valid |= CTS_SATA_VALID_REVISION;
 			cts->xport_specific.sata.caps = d->caps;
+			if (cts->type == CTS_TYPE_CURRENT_SETTINGS &&
+			    (ch->quirks & SIIS_Q_SNTF) == 0)
+				cts->xport_specific.sata.caps &= ~CTS_SATA_CAPS_H_AN;
 			cts->xport_specific.sata.valid |= CTS_SATA_VALID_CAPS;
 		}
 		cts->xport_specific.sata.mode = d->mode;

Modified: head/sys/sys/ata.h
==============================================================================
--- head/sys/sys/ata.h	Wed Apr 13 15:17:23 2011	(r220601)
+++ head/sys/sys/ata.h	Wed Apr 13 16:20:54 2011	(r220602)
@@ -135,6 +135,7 @@ struct ata_params {
 #define ATA_SUPPORT_AUTOACTIVATE        0x0004
 #define ATA_SUPPORT_IFPWRMNGT           0x0008
 #define ATA_SUPPORT_INORDERDATA         0x0010
+#define ATA_SUPPORT_ASYNCNOTIF          0x0020
 #define ATA_SUPPORT_SOFTSETPRESERVE     0x0040
 /*79*/  u_int16_t       sataenabled;
 #define ATA_ENABLED_DAPST               0x0080

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 16:35:43 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CA9221065670;
	Wed, 13 Apr 2011 16:35:43 +0000 (UTC)
	(envelope-from yongari@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B6F108FC15;
	Wed, 13 Apr 2011 16:35:43 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DGZhM4003132;
	Wed, 13 Apr 2011 16:35:43 GMT (envelope-from yongari@svn.freebsd.org)
Received: (from yongari@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DGZhJ8003129;
	Wed, 13 Apr 2011 16:35:43 GMT (envelope-from yongari@svn.freebsd.org)
Message-Id: <201104131635.p3DGZhJ8003129@svn.freebsd.org>
From: Pyun YongHyeon 
Date: Wed, 13 Apr 2011 16:35:43 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220603 - in head/sys: dev/bxe modules/bxe
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 16:35:43 -0000

Author: yongari
Date: Wed Apr 13 16:35:43 2011
New Revision: 220603
URL: http://svn.freebsd.org/changeset/base/220603

Log:
  Remove mii(4) dependency and unneeded headers.
  
  Reviewed by:	davidch

Modified:
  head/sys/dev/bxe/if_bxe.h
  head/sys/modules/bxe/Makefile

Modified: head/sys/dev/bxe/if_bxe.h
==============================================================================
--- head/sys/dev/bxe/if_bxe.h	Wed Apr 13 16:20:54 2011	(r220602)
+++ head/sys/dev/bxe/if_bxe.h	Wed Apr 13 16:35:43 2011	(r220603)
@@ -70,19 +70,9 @@
 #include 
 #include 
 
-#include 
-#include 
-#include "miidevs.h"
-
 #include 
 #include 
 
-#include 
-#include 
-
-#include "miibus_if.h"
-
-
 /*
  * Device identification definitions.
  */

Modified: head/sys/modules/bxe/Makefile
==============================================================================
--- head/sys/modules/bxe/Makefile	Wed Apr 13 16:20:54 2011	(r220602)
+++ head/sys/modules/bxe/Makefile	Wed Apr 13 16:35:43 2011	(r220603)
@@ -3,7 +3,7 @@ BXE	= ${.CURDIR}/../../dev/bxe
 .PATH:	${BXE}
 
 KMOD=	if_bxe
-SRCS	= opt_bxe.h device_if.h bus_if.h pci_if.h miibus_if.h miidevs.h 
+SRCS	= opt_bxe.h device_if.h bus_if.h pci_if.h
 SRCS	+= if_bxe.c bxe_link.c
 
 CFLAGS += -I${BXE} -DBXE_TASK

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 19:10:56 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 85C7C106566C;
	Wed, 13 Apr 2011 19:10:56 +0000 (UTC)
	(envelope-from gavin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5AA318FC16;
	Wed, 13 Apr 2011 19:10:56 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DJAueZ008736;
	Wed, 13 Apr 2011 19:10:56 GMT (envelope-from gavin@svn.freebsd.org)
Received: (from gavin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DJAuIk008734;
	Wed, 13 Apr 2011 19:10:56 GMT (envelope-from gavin@svn.freebsd.org)
Message-Id: <201104131910.p3DJAuIk008734@svn.freebsd.org>
From: Gavin Atkinson 
Date: Wed, 13 Apr 2011 19:10:56 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220606 - head/sys/kern
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 19:10:56 -0000

Author: gavin
Date: Wed Apr 13 19:10:56 2011
New Revision: 220606
URL: http://svn.freebsd.org/changeset/base/220606

Log:
  Add a new DDB command, "show rmans", which will show the address and brief
  details of each rman header, but not the contents of all rman structures
  in the system.  This is especially useful on platforms where some rmans
  have many thousands of entries in rmans, making scrolling through the
  output of "show all rman" impractical.  Individual rmans can then be viewed
  including their contents with "show rman 0xaddr" as usual.
  
  Reviewed by:	jhb

Modified:
  head/sys/kern/subr_rman.c

Modified: head/sys/kern/subr_rman.c
==============================================================================
--- head/sys/kern/subr_rman.c	Wed Apr 13 18:19:41 2011	(r220605)
+++ head/sys/kern/subr_rman.c	Wed Apr 13 19:10:56 2011	(r220606)
@@ -927,6 +927,16 @@ SYSCTL_NODE(_hw_bus, OID_AUTO, rman, CTL
 
 #ifdef DDB
 static void
+dump_rman_header(struct rman *rm)
+{
+
+	if (db_pager_quit)
+		return;
+	db_printf("rman %p: %s (0x%lx-0x%lx full range)\n",
+	    rm, rm->rm_descr, rm->rm_start, rm->rm_end);
+}
+
+static void
 dump_rman(struct rman *rm)
 {
 	struct resource_i *r;
@@ -934,8 +944,6 @@ dump_rman(struct rman *rm)
 
 	if (db_pager_quit)
 		return;
-	db_printf("rman: %s\n", rm->rm_descr);
-	db_printf("    0x%lx-0x%lx (full range)\n", rm->rm_start, rm->rm_end);
 	TAILQ_FOREACH(r, &rm->rm_list, r_link) {
 		if (r->r_dev != NULL) {
 			devname = device_get_nameunit(r->r_dev);
@@ -956,16 +964,29 @@ dump_rman(struct rman *rm)
 DB_SHOW_COMMAND(rman, db_show_rman)
 {
 
-	if (have_addr)
+	if (have_addr) {
+		dump_rman_header((struct rman *)addr);
 		dump_rman((struct rman *)addr);
+	}
+}
+
+DB_SHOW_COMMAND(rmans, db_show_rmans)
+{
+	struct rman *rm;
+
+	TAILQ_FOREACH(rm, &rman_head, rm_link) {
+		dump_rman_header(rm);
+	}
 }
 
 DB_SHOW_ALL_COMMAND(rman, db_show_all_rman)
 {
 	struct rman *rm;
 
-	TAILQ_FOREACH(rm, &rman_head, rm_link)
+	TAILQ_FOREACH(rm, &rman_head, rm_link) {
+		dump_rman_header(rm);
 		dump_rman(rm);
+	}
 }
 DB_SHOW_ALIAS(allrman, db_show_all_rman);
 #endif

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 21:41:32 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 156151065673;
	Wed, 13 Apr 2011 21:41:32 +0000 (UTC) (envelope-from dim@FreeBSD.org)
Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net
	[IPv6:2001:7b8:2ff:146::2])
	by mx1.freebsd.org (Postfix) with ESMTP id CBDE88FC08;
	Wed, 13 Apr 2011 21:41:31 +0000 (UTC)
Received: from [IPv6:2001:7b8:3a7:0:ad8b:7db5:9520:7ed0] (unknown
	[IPv6:2001:7b8:3a7:0:ad8b:7db5:9520:7ed0])
	(using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
	(No client certificate requested)
	by tensor.andric.com (Postfix) with ESMTPSA id AB82F5C59;
	Wed, 13 Apr 2011 23:41:29 +0200 (CEST)
Message-ID: <4DA6189A.5040200@FreeBSD.org>
Date: Wed, 13 Apr 2011 23:41:46 +0200
From: Dimitry Andric 
Organization: The FreeBSD Project
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
	rv:1.9.2.16pre) Gecko/20110319 Lanikai/3.1.10pre
MIME-Version: 1.0
To: Jung-uk Kim 
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
In-Reply-To: <201104122349.p3CNn7kK039179@svn.freebsd.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 21:41:32 -0000

On 2011-04-13 01:49, Jung-uk Kim wrote:
> Author: jkim
> Date: Tue Apr 12 23:49:07 2011
> New Revision: 220584
> URL: http://svn.freebsd.org/changeset/base/220584
>
> Log:
>    Reduce errors in effective frequency calculation.
>
> Modified:
>    head/sys/amd64/amd64/machdep.c
>    head/sys/i386/i386/machdep.c
>
> Modified: head/sys/amd64/amd64/machdep.c
> ==============================================================================
> --- head/sys/amd64/amd64/machdep.c	Tue Apr 12 23:04:01 2011	(r220583)
> +++ head/sys/amd64/amd64/machdep.c	Tue Apr 12 23:49:07 2011	(r220584)
> @@ -546,7 +546,7 @@ int
>   cpu_est_clockrate(int cpu_id, uint64_t *rate)
>   {
>   	uint64_t tsc1, tsc2;
> -	uint64_t acnt, mcnt;
> +	uint64_t acnt, mcnt, perf;
>   	register_t reg;
>
>   	if (pcpu_find(cpu_id) == NULL || rate == NULL)
> @@ -579,7 +579,8 @@ cpu_est_clockrate(int cpu_id, uint64_t *
>   		acnt = rdmsr(MSR_APERF);
>   		tsc2 = rdtsc();
>   		intr_restore(reg);
> -		*rate = (tsc2 - tsc1) / 1000 * acnt / mcnt * 1000000;
> +		perf = 1000 * acnt / mcnt;
> +		*rate = (tsc2 - tsc1) * perf;
>   	} else {
>   		tsc1 = rdtsc();
>   		DELAY(1000);

Hmm...  on my VMs this now leads to:

Fatal trap 18: integer divide fault while in kernel mode
cpuid = 0; apic id = 00
instruction pointer     = 0x20:0xffffffff809c908d
stack pointer           = 0x28:0xffffff80f6a14850
frame pointer           = 0x28:0xffffff80f6a14880
code segment            = base 0x0, limit 0xfffff, type 0x1b
                         = DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags        = interrupt enabled, resume, IOPL = 0
current process         = 54 (sysctl)
[ thread pid 54 tid 100060 ]
Stopped at      cpu_est_clockrate+0x11d:        divq    %rdi,%eax
db> bt
Tracing pid 54 tid 100060 td 0xfffffe0002dbe8c0
cpu_est_clockrate() at cpu_est_clockrate+0x11d
cf_get_method() at cf_get_method+0x2d4
cpufreq_curr_sysctl() at cpufreq_curr_sysctl+0x6c
sysctl_root() at sysctl_root+0x19d
userland_sysctl() at userland_sysctl+0x1a4
__sysctl() at __sysctl+0x75
syscallenter() at syscallenter+0x201
syscall() at syscall+0x38
Xfast_syscall() at Xfast_syscall+0xe1
--- syscall (202, FreeBSD ELF64, __sysctl), rip = 0x8009472ac, rsp = 0x7fffffffca38, rbp = 0x7fffffffd310 ---

But I don't really see why, yet. :)  With r220532, it worked fine.

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 21:49:19 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 91D31106564A;
	Wed, 13 Apr 2011 21:49:19 +0000 (UTC) (envelope-from dim@FreeBSD.org)
Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net
	[IPv6:2001:7b8:2ff:146::2])
	by mx1.freebsd.org (Postfix) with ESMTP id 5478D8FC08;
	Wed, 13 Apr 2011 21:49:19 +0000 (UTC)
Received: from [IPv6:2001:7b8:3a7:0:ad8b:7db5:9520:7ed0] (unknown
	[IPv6:2001:7b8:3a7:0:ad8b:7db5:9520:7ed0])
	(using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
	(No client certificate requested)
	by tensor.andric.com (Postfix) with ESMTPSA id AA82A5C59;
	Wed, 13 Apr 2011 23:49:18 +0200 (CEST)
Message-ID: <4DA61A70.8040609@FreeBSD.org>
Date: Wed, 13 Apr 2011 23:49:36 +0200
From: Dimitry Andric 
Organization: The FreeBSD Project
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
	rv:1.9.2.16pre) Gecko/20110319 Lanikai/3.1.10pre
MIME-Version: 1.0
To: Jung-uk Kim 
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
	<4DA6189A.5040200@FreeBSD.org>
In-Reply-To: <4DA6189A.5040200@FreeBSD.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 21:49:19 -0000

On 2011-04-13 23:41, Dimitry Andric wrote:
...
> But I don't really see why, yet. :)  With r220532, it worked fine.

Ah, I failed to notice the commit that came before, r220583.
Apparently, it can happen (at least in a VM environment) that the
DELAY(1000) in this fragment from cpu_est_clockrate():

                 wrmsr(MSR_MPERF, 0);
                 wrmsr(MSR_APERF, 0);
                 tsc1 = rdtsc();
                 DELAY(1000);
                 mcnt = rdmsr(MSR_MPERF);
                 acnt = rdmsr(MSR_APERF);
                 tsc2 = rdtsc();
                 intr_restore(reg);
                 perf = 1000 * acnt / mcnt;

will still read 0 from MSR_MPERF, leading to a division by zero.  Maybe
just fallback to the second method in the 'else' branch then?

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 22:16:52 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BF90E106566B;
	Wed, 13 Apr 2011 22:16:52 +0000 (UTC)
	(envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 94CEC8FC0A;
	Wed, 13 Apr 2011 22:16:52 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DMGqND012982;
	Wed, 13 Apr 2011 22:16:52 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DMGqpi012980;
	Wed, 13 Apr 2011 22:16:52 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201104132216.p3DMGqpi012980@svn.freebsd.org>
From: Rick Macklem 
Date: Wed, 13 Apr 2011 22:16:52 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220610 - head/sys/fs/nfsclient
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 22:16:52 -0000

Author: rmacklem
Date: Wed Apr 13 22:16:52 2011
New Revision: 220610
URL: http://svn.freebsd.org/changeset/base/220610

Log:
  Fix the experimental NFSv4 client so that it recognizes server
  mount point crossings correctly. It was testing the wrong flag.
  Also, try harder to make sure that the fsid is different than
  the one assigned to the client mount point, by hashing the
  server's fsid (just to create a different value deterministically)
  when it is the same.
  
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfsclient/nfs_clport.c

Modified: head/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clport.c	Wed Apr 13 19:55:58 2011	(r220609)
+++ head/sys/fs/nfsclient/nfs_clport.c	Wed Apr 13 22:16:52 2011	(r220610)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
  * generally, I don't like #includes inside .h files, but it seems to
  * be the easiest way to handle the port.
  */
+#include 
 #include 
 #include 
 #include 
@@ -377,12 +378,23 @@ nfscl_loadattrcache(struct vnode **vpp, 
 	 * be the same as a local fs, but since this is in an NFS mount
 	 * point, I don't think that will cause any problems?
 	 */
-	if ((nmp->nm_flag & (NFSMNT_NFSV4 | NFSMNT_HASSETFSID)) ==
-	    (NFSMNT_NFSV4 | NFSMNT_HASSETFSID) &&
+	if (NFSHASNFSV4(nmp) && NFSHASHASSETFSID(nmp) &&
 	    (nmp->nm_fsid[0] != np->n_vattr.na_filesid[0] ||
-	     nmp->nm_fsid[1] != np->n_vattr.na_filesid[1]))
-		vap->va_fsid = np->n_vattr.na_filesid[0];
-	else
+	     nmp->nm_fsid[1] != np->n_vattr.na_filesid[1])) {
+		/*
+		 * va_fsid needs to be set to some value derived from
+		 * np->n_vattr.na_filesid that is not equal
+		 * vp->v_mount->mnt_stat.f_fsid[0], so that it changes
+		 * from the value used for the top level server volume
+		 * in the mounted subtree.
+		 */
+		if (vp->v_mount->mnt_stat.f_fsid.val[0] !=
+		    (uint32_t)np->n_vattr.na_filesid[0])
+			vap->va_fsid = (uint32_t)np->n_vattr.na_filesid[0];
+		else
+			vap->va_fsid = (uint32_t)hash32_buf(
+			    np->n_vattr.na_filesid, 2 * sizeof(uint64_t), 0);
+	} else
 		vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
 	np->n_attrstamp = time_second;
 	if (vap->va_size != np->n_size) {

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 22:27:47 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by hub.freebsd.org (Postfix) with ESMTP id 1E2471065673;
	Wed, 13 Apr 2011 22:27:47 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
From: Jung-uk Kim 
To: Dimitry Andric 
Date: Wed, 13 Apr 2011 18:27:36 -0400
User-Agent: KMail/1.6.2
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
	<4DA6189A.5040200@FreeBSD.org> <4DA61A70.8040609@FreeBSD.org>
In-Reply-To: <4DA61A70.8040609@FreeBSD.org>
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Message-Id: <201104131827.39373.jkim@FreeBSD.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 22:27:47 -0000

On Wednesday 13 April 2011 05:49 pm, Dimitry Andric wrote:
> On 2011-04-13 23:41, Dimitry Andric wrote:
> ...
>
> > But I don't really see why, yet. :)  With r220532, it worked
> > fine.
>
> Ah, I failed to notice the commit that came before, r220583.
> Apparently, it can happen (at least in a VM environment) that the
> DELAY(1000) in this fragment from cpu_est_clockrate():
>
>                  wrmsr(MSR_MPERF, 0);
>                  wrmsr(MSR_APERF, 0);
>                  tsc1 = rdtsc();
>                  DELAY(1000);
>                  mcnt = rdmsr(MSR_MPERF);
>                  acnt = rdmsr(MSR_APERF);
>                  tsc2 = rdtsc();
>                  intr_restore(reg);
>                  perf = 1000 * acnt / mcnt;
>
> will still read 0 from MSR_MPERF, leading to a division by zero. 
> Maybe just fallback to the second method in the 'else' branch then?

That means your VM has broken CPUID support.  To get there, it has to 
meet two conditions, i.e., TSC is invariant and it has APERF/MPERF 
MSRs.  A simple workaround is setting "machdep.disable_tsc=1" 
tuanable from loader but your VM is the real culprit here.

Jung-uk Kim

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 22:29:04 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 561BC106564A;
	Wed, 13 Apr 2011 22:29:04 +0000 (UTC)
	(envelope-from yanegomi@gmail.com)
Received: from mail-px0-f172.google.com (mail-px0-f172.google.com
	[209.85.212.172])
	by mx1.freebsd.org (Postfix) with ESMTP id 1CE4E8FC13;
	Wed, 13 Apr 2011 22:29:03 +0000 (UTC)
Received: by pxi6 with SMTP id 6so933330pxi.17
	for ; Wed, 13 Apr 2011 15:29:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=iFLJ0H//R6pe2C45KOIjUcAC7KSBLESztwI/5Ar/e98=;
	b=RmmeKxmQWuCMuxi+mvkc5aTJz7E1r79iWfpz2wRb0l8j9Tdg2HhkEFZsjYWCCKLeFl
	krsHpiV/tu6VXxta3lCOt1q78FKEy5HvEUPIyTFbEGE9hHito/H1W57UQqndnygxjYgu
	zNNM5JDIYoZTLbEDlJKyVTPTKx7YVe5liTl78=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	b=wno9B2WdDMvgWKbM22ZxjggB4aqfuqlR7T8hSsnldivVP2IZcswNsvwz0XWy7JxJ6C
	HhVYwoCfhyXhd3cmqHA/2D4SY3QkqqBG9ga1hI3EiNVywPs8MGjmtZ/FdHdbjuM+j/ot
	E0/jHbdS3v2qSjrteZYXRAyopwAdkgPhgynMQ=
MIME-Version: 1.0
Received: by 10.142.237.20 with SMTP id k20mr23713wfh.170.1302733743579; Wed,
	13 Apr 2011 15:29:03 -0700 (PDT)
Received: by 10.68.42.3 with HTTP; Wed, 13 Apr 2011 15:29:03 -0700 (PDT)
In-Reply-To: <4DA61A70.8040609@FreeBSD.org>
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
	<4DA6189A.5040200@FreeBSD.org> <4DA61A70.8040609@FreeBSD.org>
Date: Wed, 13 Apr 2011 15:29:03 -0700
Message-ID: 
From: Garrett Cooper 
To: Dimitry Andric 
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org, Jung-uk Kim 
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 22:29:04 -0000

On Wed, Apr 13, 2011 at 2:49 PM, Dimitry Andric  wrote:
> On 2011-04-13 23:41, Dimitry Andric wrote:
> ...
>>
>> But I don't really see why, yet. :) =A0With r220532, it worked fine.
>
> Ah, I failed to notice the commit that came before, r220583.
> Apparently, it can happen (at least in a VM environment) that the
> DELAY(1000) in this fragment from cpu_est_clockrate():
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0wrmsr(MSR_MPERF, 0);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0wrmsr(MSR_APERF, 0);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tsc1 =3D rdtsc();
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0DELAY(1000);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mcnt =3D rdmsr(MSR_MPERF);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0acnt =3D rdmsr(MSR_APERF);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tsc2 =3D rdtsc();
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0intr_restore(reg);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0perf =3D 1000 * acnt / mcnt;
>
> will still read 0 from MSR_MPERF, leading to a division by zero. =A0Maybe
> just fallback to the second method in the 'else' branch then?

    Yeah, it kind of peeves me that this kind of rinky dink stuff is
done with VMware ESXi, etc (fake RAM returning 0MHz in the SMBIOS
table in certain scenarios).
Thanks,
-Garrett

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 22:33:12 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8D5EB106566C;
	Wed, 13 Apr 2011 22:33:12 +0000 (UTC)
	(envelope-from yanegomi@gmail.com)
Received: from mail-pv0-f182.google.com (mail-pv0-f182.google.com
	[74.125.83.182])
	by mx1.freebsd.org (Postfix) with ESMTP id 5375F8FC1B;
	Wed, 13 Apr 2011 22:33:12 +0000 (UTC)
Received: by pvg11 with SMTP id 11so509321pvg.13
	for ; Wed, 13 Apr 2011 15:33:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=8CRJjfKZGWa38j7BDGDJA3Ngs+n3twg4GDFgUITCHms=;
	b=iRG09tqT8XlzUPoepGpi+/nx8UIw61UlxyMSEzoy+WQdZe1eJipxSVHbC/wyddP2Py
	NRta0KyWWwH9FY9lMpOwzAEsLVJVCpsPyjKqU5V2AfRmpqxxyWb3UDC2yOMSMe9QFiVp
	Mh4rZhfvHTVIss0qom/zSxA0DXJKIRU2K+a9Q=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:cc:content-type:content-transfer-encoding;
	b=xyXf7KuZryB02xBze3rk922CRbVneQGmQymgCrcJI8iFxTkZdhPzqeZIwyztevH/K/
	rabLwXxmsejchQ7L2XzHcEadehsr6/r6cPxNNkf+kwWD5a/X3OMz80sE0nGsK3RZrkWc
	MroFc7kGuhTQ0njW65w9crV68nlBTZ0FJ4Cmw=
MIME-Version: 1.0
Received: by 10.142.237.20 with SMTP id k20mr27010wfh.170.1302733991682; Wed,
	13 Apr 2011 15:33:11 -0700 (PDT)
Received: by 10.68.42.3 with HTTP; Wed, 13 Apr 2011 15:33:11 -0700 (PDT)
In-Reply-To: <201104131827.39373.jkim@FreeBSD.org>
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
	<4DA6189A.5040200@FreeBSD.org> <4DA61A70.8040609@FreeBSD.org>
	<201104131827.39373.jkim@FreeBSD.org>
Date: Wed, 13 Apr 2011 15:33:11 -0700
Message-ID: 
From: Garrett Cooper 
To: Jung-uk Kim 
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org, Dimitry Andric 
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 22:33:12 -0000

On Wed, Apr 13, 2011 at 3:27 PM, Jung-uk Kim  wrote:
> On Wednesday 13 April 2011 05:49 pm, Dimitry Andric wrote:
>> On 2011-04-13 23:41, Dimitry Andric wrote:
>> ...
>>
>> > But I don't really see why, yet. :) =A0With r220532, it worked
>> > fine.
>>
>> Ah, I failed to notice the commit that came before, r220583.
>> Apparently, it can happen (at least in a VM environment) that the
>> DELAY(1000) in this fragment from cpu_est_clockrate():
>>
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0wrmsr(MSR_MPERF, 0);
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0wrmsr(MSR_APERF, 0);
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tsc1 =3D rdtsc();
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0DELAY(1000);
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mcnt =3D rdmsr(MSR_MPERF);
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0acnt =3D rdmsr(MSR_APERF);
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tsc2 =3D rdtsc();
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0intr_restore(reg);
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0perf =3D 1000 * acnt / mcnt;
>>
>> will still read 0 from MSR_MPERF, leading to a division by zero.
>> Maybe just fallback to the second method in the 'else' branch then?
>
> That means your VM has broken CPUID support. =A0To get there, it has to
> meet two conditions, i.e., TSC is invariant and it has APERF/MPERF
> MSRs. =A0A simple workaround is setting "machdep.disable_tsc=3D1"
> tuanable from loader but your VM is the real culprit here.

    VMware ESXi lies on multiple fronts in this area I've discovered
lately at $WORK, in particular the SMBIOS / FreeBSD are calling CPUID
which is returning info based on the host processor instead of the
emulated guest processor, which in turn is causes minor problems in
our software. Example being that the host processor is a Intel
Woodcrest CPU (this is what an in-house tool and FreeBSD reports)
instead of a Pentium Pro emulated CPU (that's what dmidecode reports
and that's what ESXi emulates).
    Wasn't happy about this breakage and someone should probably talk
to VMware about fixing their emulation software so that it tells a
consistent story across the board.
Thanks,
-Garrett

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 22:37:29 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DCBCC1065678;
	Wed, 13 Apr 2011 22:37:28 +0000 (UTC)
	(envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CC21B8FC1B;
	Wed, 13 Apr 2011 22:37:28 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3DMbSW5013396;
	Wed, 13 Apr 2011 22:37:28 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3DMbS6q013394;
	Wed, 13 Apr 2011 22:37:28 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201104132237.p3DMbS6q013394@svn.freebsd.org>
From: Rick Macklem 
Date: Wed, 13 Apr 2011 22:37:28 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220611 - head/sys/fs/nfsclient
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 22:37:29 -0000

Author: rmacklem
Date: Wed Apr 13 22:37:28 2011
New Revision: 220611
URL: http://svn.freebsd.org/changeset/base/220611

Log:
  Add VOP_PATHCONF() support to the experimental NFS client
  so that it can, along with other things, report whether or
  not NFS4 ACLs are supported.
  
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfsclient/nfs_clvnops.c

Modified: head/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clvnops.c	Wed Apr 13 22:16:52 2011	(r220610)
+++ head/sys/fs/nfsclient/nfs_clvnops.c	Wed Apr 13 22:37:28 2011	(r220611)
@@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$");
 #define	FALSE	0
 
 extern struct nfsstats newnfsstats;
+extern int nfsrv_useacl;
 MALLOC_DECLARE(M_NEWNFSREQ);
 
 /*
@@ -103,6 +104,7 @@ static vop_lookup_t	nfs_lookup;
 static vop_create_t	nfs_create;
 static vop_mknod_t	nfs_mknod;
 static vop_open_t	nfs_open;
+static vop_pathconf_t	nfs_pathconf;
 static vop_close_t	nfs_close;
 static vop_access_t	nfs_access;
 static vop_getattr_t	nfs_getattr;
@@ -151,6 +153,7 @@ struct vop_vector newnfs_vnodeops = {
 	.vop_mkdir =		nfs_mkdir,
 	.vop_mknod =		nfs_mknod,
 	.vop_open =		nfs_open,
+	.vop_pathconf =		nfs_pathconf,
 	.vop_print =		nfs_print,
 	.vop_read =		nfs_read,
 	.vop_readdir =		nfs_readdir,
@@ -3244,3 +3247,115 @@ nfs_setacl(struct vop_setacl_args *ap)
 	}
 	return (error);
 }
+
+/*
+ * Return POSIX pathconf information applicable to nfs filesystems.
+ */
+static int
+nfs_pathconf(struct vop_pathconf_args *ap)
+{
+	struct nfsv3_pathconf pc;
+	struct nfsvattr nfsva;
+	struct vnode *vp = ap->a_vp;
+	struct thread *td = curthread;
+	int attrflag, error;
+
+	if (NFS_ISV34(vp)) {
+		error = nfsrpc_pathconf(vp, &pc, td->td_ucred, td, &nfsva,
+		    &attrflag, NULL);
+		if (attrflag != 0)
+			(void) nfscl_loadattrcache(&vp, &nfsva, NULL, NULL, 0,
+			    1);
+		if (error != 0)
+			return (error);
+	} else {
+		/* For NFSv2, just fake them. */
+		pc.pc_linkmax = LINK_MAX;
+		pc.pc_namemax = NFS_MAXNAMLEN;
+		pc.pc_notrunc = 1;
+		pc.pc_chownrestricted = 1;
+		pc.pc_caseinsensitive = 0;
+		pc.pc_casepreserving = 1;
+		error = 0;
+	}
+	switch (ap->a_name) {
+	case _PC_LINK_MAX:
+		*ap->a_retval = pc.pc_linkmax;
+		break;
+	case _PC_NAME_MAX:
+		*ap->a_retval = pc.pc_namemax;
+		break;
+	case _PC_PATH_MAX:
+		*ap->a_retval = PATH_MAX;
+		break;
+	case _PC_PIPE_BUF:
+		*ap->a_retval = PIPE_BUF;
+		break;
+	case _PC_CHOWN_RESTRICTED:
+		*ap->a_retval = pc.pc_chownrestricted;
+		break;
+	case _PC_NO_TRUNC:
+		*ap->a_retval = pc.pc_notrunc;
+		break;
+	case _PC_ACL_EXTENDED:
+		*ap->a_retval = 0;
+		break;
+	case _PC_ACL_NFS4:
+		if (NFS_ISV4(vp) && nfsrv_useacl != 0 && attrflag != 0 &&
+		    NFSISSET_ATTRBIT(&nfsva.na_suppattr, NFSATTRBIT_ACL))
+			*ap->a_retval = 1;
+		else
+			*ap->a_retval = 0;
+		break;
+	case _PC_ACL_PATH_MAX:
+		if (NFS_ISV4(vp))
+			*ap->a_retval = ACL_MAX_ENTRIES;
+		else
+			*ap->a_retval = 3;
+		break;
+	case _PC_MAC_PRESENT:
+		*ap->a_retval = 0;
+		break;
+	case _PC_ASYNC_IO:
+		/* _PC_ASYNC_IO should have been handled by upper layers. */
+		KASSERT(0, ("_PC_ASYNC_IO should not get here"));
+		error = EINVAL;
+		break;
+	case _PC_PRIO_IO:
+		*ap->a_retval = 0;
+		break;
+	case _PC_SYNC_IO:
+		*ap->a_retval = 0;
+		break;
+	case _PC_ALLOC_SIZE_MIN:
+		*ap->a_retval = vp->v_mount->mnt_stat.f_bsize;
+		break;
+	case _PC_FILESIZEBITS:
+		if (NFS_ISV34(vp))
+			*ap->a_retval = 64;
+		else
+			*ap->a_retval = 32;
+		break;
+	case _PC_REC_INCR_XFER_SIZE:
+		*ap->a_retval = vp->v_mount->mnt_stat.f_iosize;
+		break;
+	case _PC_REC_MAX_XFER_SIZE:
+		*ap->a_retval = -1; /* means ``unlimited'' */
+		break;
+	case _PC_REC_MIN_XFER_SIZE:
+		*ap->a_retval = vp->v_mount->mnt_stat.f_iosize;
+		break;
+	case _PC_REC_XFER_ALIGN:
+		*ap->a_retval = PAGE_SIZE;
+		break;
+	case _PC_SYMLINK_MAX:
+		*ap->a_retval = NFS_MAXPATHLEN;
+		break;
+
+	default:
+		error = EINVAL;
+		break;
+	}
+	return (error);
+}
+

From owner-svn-src-head@FreeBSD.ORG  Wed Apr 13 23:07:43 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by hub.freebsd.org (Postfix) with ESMTP id 32D211065674;
	Wed, 13 Apr 2011 23:07:43 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
From: Jung-uk Kim 
To: Garrett Cooper 
Date: Wed, 13 Apr 2011 19:07:33 -0400
User-Agent: KMail/1.6.2
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
	<201104131827.39373.jkim@FreeBSD.org>
	
In-Reply-To: 
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: text/plain;
  charset="utf-8"
Content-Transfer-Encoding: 8bit
Message-Id: <201104131907.35216.jkim@FreeBSD.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org, Dimitry Andric 
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Wed, 13 Apr 2011 23:07:43 -0000

On Wednesday 13 April 2011 06:33 pm, Garrett Cooper wrote:
> On Wed, Apr 13, 2011 at 3:27 PM, Jung-uk Kim  
wrote:
> > On Wednesday 13 April 2011 05:49 pm, Dimitry Andric wrote:
> >> On 2011-04-13 23:41, Dimitry Andric wrote:
> >> ...
> >>
> >> > But I don't really see why, yet. :)  With r220532, it worked
> >> > fine.
> >>
> >> Ah, I failed to notice the commit that came before, r220583.
> >> Apparently, it can happen (at least in a VM environment) that
> >> the DELAY(1000) in this fragment from cpu_est_clockrate():
> >>
> >>                  wrmsr(MSR_MPERF, 0);
> >>                  wrmsr(MSR_APERF, 0);
> >>                  tsc1 = rdtsc();
> >>                  DELAY(1000);
> >>                  mcnt = rdmsr(MSR_MPERF);
> >>                  acnt = rdmsr(MSR_APERF);
> >>                  tsc2 = rdtsc();
> >>                  intr_restore(reg);
> >>                  perf = 1000 * acnt / mcnt;
> >>
> >> will still read 0 from MSR_MPERF, leading to a division by zero.
> >> Maybe just fallback to the second method in the 'else' branch
> >> then?
> >
> > That means your VM has broken CPUID support.  To get there, it
> > has to meet two conditions, i.e., TSC is invariant and it has
> > APERF/MPERF MSRs.  A simple workaround is setting
> > "machdep.disable_tsc=1" tuanable from loader but your VM is the
> > real culprit here.
>
>     VMware ESXi lies on multiple fronts in this area I've
> discovered lately at $WORK, in particular the SMBIOS / FreeBSD are
> calling CPUID which is returning info based on the host processor
> instead of the emulated guest processor, which in turn is causes
> minor problems in our software. Example being that the host
> processor is a Intel Woodcrest CPU (this is what an in-house tool
> and FreeBSD reports) instead of a Pentium Pro emulated CPU (that's
> what dmidecode reports and that's what ESXi emulates).
>     Wasn't happy about this breakage and someone should probably
> talk to VMware about fixing their emulation software so that it
> tells a consistent story across the board.

Yeah, it is really shame that VMware (and others) suck in this area.  
VMware just exposes nominal frequency of the host CPU (or user can 
configure it) and advertises it is constant.  Then, RDTSC instruction 
is trapped and scaled at the fixed frequency.  On the other hand, 
VirtualBox has a different problem, e.g., TSC does not scale 
properly.  I think it just detects the *current* frequency of the 
host CPU and never changes even if host clock frequency changes.  I 
believe you can just disable TSC in VM guest and use other clock 
sources until they fix the problems.  AFAIK, virtualized TSC has no 
benefit over other clock sources, unlike real hardware anyway.

Jung-uk Kim

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 00:07:09 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 81AD9106566C;
	Thu, 14 Apr 2011 00:07:09 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1DD3B8FC0C;
	Thu, 14 Apr 2011 00:07:09 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3E07918015369;
	Thu, 14 Apr 2011 00:07:09 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3E078cV015365;
	Thu, 14 Apr 2011 00:07:08 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104140007.p3E078cV015365@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 14 Apr 2011 00:07:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220613 - in head/sys: dev/acpica x86/isa x86/x86
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 00:07:09 -0000

Author: jkim
Date: Thu Apr 14 00:07:08 2011
New Revision: 220613
URL: http://svn.freebsd.org/changeset/base/220613

Log:
  Add some tunable descriptions about x86 timers.
  
  Requested by:	arundel

Modified:
  head/sys/dev/acpica/acpi_timer.c
  head/sys/x86/isa/clock.c
  head/sys/x86/x86/tsc.c

Modified: head/sys/dev/acpica/acpi_timer.c
==============================================================================
--- head/sys/dev/acpica/acpi_timer.c	Wed Apr 13 23:09:36 2011	(r220612)
+++ head/sys/dev/acpica/acpi_timer.c	Thu Apr 14 00:07:08 2011	(r220613)
@@ -276,7 +276,7 @@ acpi_timer_sysctl_freq(SYSCTL_HANDLER_AR
 }
  
 SYSCTL_PROC(_machdep, OID_AUTO, acpi_timer_freq, CTLTYPE_INT | CTLFLAG_RW,
-	    0, sizeof(u_int), acpi_timer_sysctl_freq, "I", "");
+    0, sizeof(u_int), acpi_timer_sysctl_freq, "I", "ACPI timer frequency");
 
 /*
  * Some ACPI timers are known or believed to suffer from implementation

Modified: head/sys/x86/isa/clock.c
==============================================================================
--- head/sys/x86/isa/clock.c	Wed Apr 13 23:09:36 2011	(r220612)
+++ head/sys/x86/isa/clock.c	Thu Apr 14 00:07:08 2011	(r220613)
@@ -527,7 +527,8 @@ sysctl_machdep_i8254_freq(SYSCTL_HANDLER
 }
 
 SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW,
-    0, sizeof(u_int), sysctl_machdep_i8254_freq, "IU", "");
+    0, sizeof(u_int), sysctl_machdep_i8254_freq, "IU",
+    "i8254 timer frequency");
 
 static unsigned
 i8254_get_timecount(struct timecounter *tc)

Modified: head/sys/x86/x86/tsc.c
==============================================================================
--- head/sys/x86/x86/tsc.c	Wed Apr 13 23:09:36 2011	(r220612)
+++ head/sys/x86/x86/tsc.c	Thu Apr 14 00:07:08 2011	(r220613)
@@ -361,7 +361,7 @@ sysctl_machdep_tsc_freq(SYSCTL_HANDLER_A
 }
 
 SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_U64 | CTLFLAG_RW,
-    0, 0, sysctl_machdep_tsc_freq, "QU", "");
+    0, 0, sysctl_machdep_tsc_freq, "QU", "Time Stamp Counter frequency");
 
 static unsigned
 tsc_get_timecount(struct timecounter *tc)

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 07:14:22 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 69179106566C;
	Thu, 14 Apr 2011 07:14:22 +0000 (UTC) (envelope-from ru@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 598928FC1A;
	Thu, 14 Apr 2011 07:14:22 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3E7EM7q024430;
	Thu, 14 Apr 2011 07:14:22 GMT (envelope-from ru@svn.freebsd.org)
Received: (from ru@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3E7EM31024428;
	Thu, 14 Apr 2011 07:14:22 GMT (envelope-from ru@svn.freebsd.org)
Message-Id: <201104140714.p3E7EM31024428@svn.freebsd.org>
From: Ruslan Ermilov 
Date: Thu, 14 Apr 2011 07:14:22 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220614 - head/sys/dev/ipmi
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 07:14:22 -0000

Author: ru
Date: Thu Apr 14 07:14:22 2011
New Revision: 220614
URL: http://svn.freebsd.org/changeset/base/220614

Log:
  Fixed firmware revision decoding:
  - the major is 7-bit binary encoded
  - the minor is BCD encoded
  
  PR:		kern/151586
  MFC after:	3 days

Modified:
  head/sys/dev/ipmi/ipmi.c

Modified: head/sys/dev/ipmi/ipmi.c
==============================================================================
--- head/sys/dev/ipmi/ipmi.c	Thu Apr 14 00:07:08 2011	(r220613)
+++ head/sys/dev/ipmi/ipmi.c	Thu Apr 14 07:14:22 2011	(r220614)
@@ -713,10 +713,10 @@ ipmi_startup(void *arg)
 		return;
 	}
 
-	device_printf(dev, "IPMI device rev. %d, firmware rev. %d.%d, "
+	device_printf(dev, "IPMI device rev. %d, firmware rev. %d.%d%d, "
 	    "version %d.%d\n",
 	     req->ir_reply[1] & 0x0f,
-	     req->ir_reply[2] & 0x0f, req->ir_reply[4],
+	     req->ir_reply[2] & 0x7f, req->ir_reply[3] >> 4, req->ir_reply[3] & 0x0f,
 	     req->ir_reply[4] & 0x0f, req->ir_reply[4] >> 4);
 
 	ipmi_free_request(req);

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 07:49:46 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4B2B9106564A;
	Thu, 14 Apr 2011 07:49:46 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 391608FC16;
	Thu, 14 Apr 2011 07:49:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3E7nkAH025139;
	Thu, 14 Apr 2011 07:49:46 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3E7nk2u025136;
	Thu, 14 Apr 2011 07:49:46 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104140749.p3E7nk2u025136@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 14 Apr 2011 07:49:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220615 - head/sys/dev/mvs
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 07:49:46 -0000

Author: mav
Date: Thu Apr 14 07:49:45 2011
New Revision: 220615
URL: http://svn.freebsd.org/changeset/base/220615

Log:
  Refactor hard-reset implementation in mvs(4).
  
  Instead of spinning in a tight loop for up to 15 seconds, polling for device
  readiness while it spins up, return reset completion just after PHY reports
  "connect well" or 100ms connection timeout. If device was found, use callout
  for checking device readiness with 100ms period up to full 31 second timeout.
  
  This fixes system freeze for 5-10 seconds on drives hot plug-in.

Modified:
  head/sys/dev/mvs/mvs.c
  head/sys/dev/mvs/mvs.h

Modified: head/sys/dev/mvs/mvs.c
==============================================================================
--- head/sys/dev/mvs/mvs.c	Thu Apr 14 07:14:22 2011	(r220614)
+++ head/sys/dev/mvs/mvs.c	Thu Apr 14 07:49:45 2011	(r220615)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -75,7 +76,7 @@ static int mvs_sata_phy_reset(device_t d
 static int mvs_wait(device_t dev, u_int s, u_int c, int t);
 static void mvs_tfd_read(device_t dev, union ccb *ccb);
 static void mvs_tfd_write(device_t dev, union ccb *ccb);
-static void mvs_legacy_intr(device_t dev);
+static void mvs_legacy_intr(device_t dev, int poll);
 static void mvs_crbq_intr(device_t dev);
 static void mvs_begin_transaction(device_t dev, union ccb *ccb);
 static void mvs_legacy_execute_transaction(struct mvs_slot *slot);
@@ -125,6 +126,7 @@ mvs_ch_attach(device_t dev)
 	    device_get_unit(dev), "pm_level", &ch->pm_level);
 	if (ch->pm_level > 3)
 		callout_init_mtx(&ch->pm_timer, &ch->mtx, 0);
+	callout_init_mtx(&ch->reset_timer, &ch->mtx, 0);
 	resource_int_value(device_get_name(dev),
 	    device_get_unit(dev), "sata_rev", &sata_rev);
 	for (i = 0; i < 16; i++) {
@@ -218,6 +220,11 @@ mvs_ch_detach(device_t dev)
 
 	mtx_lock(&ch->mtx);
 	xpt_async(AC_LOST_DEVICE, ch->path, NULL);
+	/* Forget about reset. */
+	if (ch->resetting) {
+		ch->resetting = 0;
+		xpt_release_simq(ch->sim, TRUE);
+	}
 	xpt_free_path(ch->path);
 	xpt_bus_deregister(cam_sim_path(ch->sim));
 	cam_sim_free(ch->sim, /*free_devq*/TRUE);
@@ -225,6 +232,7 @@ mvs_ch_detach(device_t dev)
 
 	if (ch->pm_level > 3)
 		callout_drain(&ch->pm_timer);
+	callout_drain(&ch->reset_timer);
 	bus_teardown_intr(dev, ch->r_irq, ch->ih);
 	bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq);
 
@@ -286,6 +294,12 @@ mvs_ch_suspend(device_t dev)
 	xpt_freeze_simq(ch->sim, 1);
 	while (ch->oslots)
 		msleep(ch, &ch->mtx, PRIBIO, "mvssusp", hz/100);
+	/* Forget about reset. */
+	if (ch->resetting) {
+		ch->resetting = 0;
+		callout_stop(&ch->reset_timer);
+		xpt_release_simq(ch->sim, TRUE);
+	}
 	mvs_ch_deinit(dev);
 	mtx_unlock(&ch->mtx);
 	return (0);
@@ -804,7 +818,7 @@ mvs_ch_intr(void *data)
 	}
 	/* Legacy mode device interrupt. */
 	if ((arg->cause & 2) && !edma)
-		mvs_legacy_intr(dev);
+		mvs_legacy_intr(dev, arg->cause & 4);
 }
 
 static uint8_t
@@ -823,7 +837,7 @@ mvs_getstatus(device_t dev, int clear)
 }
 
 static void
-mvs_legacy_intr(device_t dev)
+mvs_legacy_intr(device_t dev, int poll)
 {
 	struct mvs_channel *ch = device_get_softc(dev);
 	struct mvs_slot *slot = &ch->slot[0]; /* PIO is always in slot 0. */
@@ -841,6 +855,8 @@ mvs_legacy_intr(device_t dev)
 	port = ccb->ccb_h.target_id & 0x0f;
 	/* Wait a bit for late !BUSY status update. */
 	if (status & ATA_S_BUSY) {
+		if (poll)
+			return;
 		DELAY(100);
 		if ((status = mvs_getstatus(dev, 1)) & ATA_S_BUSY) {
 			DELAY(1000);
@@ -1317,7 +1333,7 @@ mvs_legacy_execute_transaction(struct mv
 			    DELAY(10);
 			    ccb->ataio.res.status = ATA_INB(ch->r_mem, ATA_STATUS);
 			} while (ccb->ataio.res.status & ATA_S_BUSY && timeout--);
-			mvs_legacy_intr(dev);
+			mvs_legacy_intr(dev, 1);
 			return;
 		}
 		ch->donecount = 0;
@@ -1910,11 +1926,13 @@ mvs_wait(device_t dev, u_int s, u_int c,
 	uint8_t st;
 
 	while (((st =  mvs_getstatus(dev, 0)) & (s | c)) != s) {
-		DELAY(1000);
-		if (timeout++ > t) {
-			device_printf(dev, "Wait status %02x\n", st);
+		if (timeout >= t) {
+			if (t != 0)
+				device_printf(dev, "Wait status %02x\n", st);
 			return (-1);
 		}
+		DELAY(1000);
+		timeout++;
 	} 
 	return (timeout);
 }
@@ -1937,6 +1955,35 @@ mvs_requeue_frozen(device_t dev)
 }
 
 static void
+mvs_reset_to(void *arg)
+{
+	device_t dev = arg;
+	struct mvs_channel *ch = device_get_softc(dev);
+	int t;
+
+	if (ch->resetting == 0)
+		return;
+	ch->resetting--;
+	if ((t = mvs_wait(dev, 0, ATA_S_BUSY | ATA_S_DRQ, 0)) >= 0) {
+		if (bootverbose) {
+			device_printf(dev,
+			    "MVS reset: device ready after %dms\n",
+			    (310 - ch->resetting) * 100);
+		}
+		ch->resetting = 0;
+		xpt_release_simq(ch->sim, TRUE);
+		return;
+	}
+	if (ch->resetting == 0) {
+		device_printf(dev,
+		    "MVS reset: device not ready after 31000ms\n");
+		xpt_release_simq(ch->sim, TRUE);
+		return;
+	}
+	callout_schedule(&ch->reset_timer, hz / 10);
+}
+
+static void
 mvs_reset(device_t dev)
 {
 	struct mvs_channel *ch = device_get_softc(dev);
@@ -1945,6 +1992,12 @@ mvs_reset(device_t dev)
 	xpt_freeze_simq(ch->sim, 1);
 	if (bootverbose)
 		device_printf(dev, "MVS reset...\n");
+	/* Forget about previous reset. */
+	if (ch->resetting) {
+		ch->resetting = 0;
+		callout_stop(&ch->reset_timer);
+		xpt_release_simq(ch->sim, TRUE);
+	}
 	/* Requeue freezed command. */
 	mvs_requeue_frozen(dev);
 	/* Kill the engine and requeue all running commands. */
@@ -1969,6 +2022,7 @@ mvs_reset(device_t dev)
 	ch->eslots = 0;
 	ch->toslots = 0;
 	ch->fatalerr = 0;
+	ch->fake_busy = 0;
 	/* Tell the XPT about the event */
 	xpt_async(AC_BUS_RESET, ch->path, NULL);
 	ATA_OUTL(ch->r_mem, EDMA_IEM, 0);
@@ -1978,8 +2032,7 @@ mvs_reset(device_t dev)
 	/* Reset and reconnect PHY, */
 	if (!mvs_sata_phy_reset(dev)) {
 		if (bootverbose)
-			device_printf(dev,
-			    "MVS reset done: phy reset found no device\n");
+			device_printf(dev, "MVS reset: device not found\n");
 		ch->devices = 0;
 		ATA_OUTL(ch->r_mem, SATA_SE, 0xffffffff);
 		ATA_OUTL(ch->r_mem, EDMA_IEC, 0);
@@ -1987,18 +2040,26 @@ mvs_reset(device_t dev)
 		xpt_release_simq(ch->sim, TRUE);
 		return;
 	}
+	if (bootverbose)
+		device_printf(dev, "MVS reset: device found\n");
 	/* Wait for clearing busy status. */
-	if ((i = mvs_wait(dev, 0, ATA_S_BUSY | ATA_S_DRQ, 15000)) < 0)
-		device_printf(dev, "device is not ready\n");
-	else if (bootverbose)                                                        
-		device_printf(dev, "ready wait time=%dms\n", i);
+	if ((i = mvs_wait(dev, 0, ATA_S_BUSY | ATA_S_DRQ,
+	    dumping ? 31000 : 0)) < 0) {
+		if (dumping) {
+			device_printf(dev,
+			    "MVS reset: device not ready after 31000ms\n");
+		} else
+			ch->resetting = 310;
+	} else if (bootverbose)
+		device_printf(dev, "MVS reset: device ready after %dms\n", i);
 	ch->devices = 1;
 	ATA_OUTL(ch->r_mem, SATA_SE, 0xffffffff);
 	ATA_OUTL(ch->r_mem, EDMA_IEC, 0);
 	ATA_OUTL(ch->r_mem, EDMA_IEM, ~EDMA_IE_TRANSIENT);
-	if (bootverbose)
-		device_printf(dev, "MVS reset done: device found\n");
-	xpt_release_simq(ch->sim, TRUE);
+	if (ch->resetting)
+		callout_reset(&ch->reset_timer, hz / 10, mvs_reset_to, dev);
+	else
+		xpt_release_simq(ch->sim, TRUE);
 }
 
 static void
@@ -2307,7 +2368,12 @@ mvspoll(struct cam_sim *sim)
 	struct mvs_intr_arg arg;
 
 	arg.arg = ch->dev;
-	arg.cause = 2; /* XXX */
+	arg.cause = 2 | 4; /* XXX */
 	mvs_ch_intr(&arg);
+	if (ch->resetting != 0 &&
+	    (--ch->resetpolldiv <= 0 || !callout_pending(&ch->reset_timer))) {
+		ch->resetpolldiv = 1000;
+		mvs_reset_to(ch->dev);
+	}
 }
 

Modified: head/sys/dev/mvs/mvs.h
==============================================================================
--- head/sys/dev/mvs/mvs.h	Thu Apr 14 07:14:22 2011	(r220614)
+++ head/sys/dev/mvs/mvs.h	Thu Apr 14 07:49:45 2011	(r220615)
@@ -561,6 +561,8 @@ struct mvs_channel {
 	int			fatalerr;	/* Fatal error happend */
 	int			lastslot;	/* Last used slot */
 	int			taggedtarget;	/* Last tagged target */
+	int			resetting;	/* Hard-reset in progress. */
+	int			resetpolldiv;	/* Hard-reset poll divider. */
 	int			out_idx;	/* Next written CRQB */
 	int			in_idx;		/* Next read CRPB */
 	u_int			transfersize;	/* PIO transfer size */
@@ -569,6 +571,7 @@ struct mvs_channel {
 	u_int			fake_busy;	/* Fake busy bit after command submission */
 	union ccb		*frozen;	/* Frozen command */
 	struct callout		pm_timer;	/* Power management events */
+	struct callout		reset_timer;	/* Hard-reset timeout */
 
 	struct mvs_device	user[16];	/* User-specified settings */
 	struct mvs_device	curr[16];	/* Current settings */

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 08:17:45 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A1C48106566C;
	Thu, 14 Apr 2011 08:17:45 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 90A6E8FC08;
	Thu, 14 Apr 2011 08:17:45 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3E8Hj65025717;
	Thu, 14 Apr 2011 08:17:45 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3E8HjGx025715;
	Thu, 14 Apr 2011 08:17:45 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104140817.p3E8HjGx025715@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 14 Apr 2011 08:17:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220616 - head/sys/cam/ata
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 08:17:45 -0000

Author: mav
Date: Thu Apr 14 08:17:45 2011
New Revision: 220616
URL: http://svn.freebsd.org/changeset/base/220616

Log:
  Properly log few more ATA commands used by the kernel.

Modified:
  head/sys/cam/ata/ata_all.c

Modified: head/sys/cam/ata/ata_all.c
==============================================================================
--- head/sys/cam/ata/ata_all.c	Thu Apr 14 07:49:45 2011	(r220615)
+++ head/sys/cam/ata/ata_all.c	Thu Apr 14 08:17:45 2011	(r220616)
@@ -72,6 +72,8 @@ char *
 ata_op_string(struct ata_cmd *cmd)
 {
 
+	if (cmd->control & 0x04)
+		return ("SOFT_RESET");
 	switch (cmd->command) {
 	case 0x00: return ("NOP");
 	case 0x03: return ("CFA_REQUEST_EXTENDED_ERROR");
@@ -149,6 +151,8 @@ ata_op_string(struct ata_cmd *cmd)
 	        case 0x06: return ("SETFEATURES ENABLE PUIS");
 	        case 0x86: return ("SETFEATURES DISABLE PUIS");
 	        case 0x07: return ("SETFEATURES SPIN-UP");
+	        case 0x10: return ("SETFEATURES ENABLE SATA FEATURE");
+	        case 0x90: return ("SETFEATURES DISABLE SATA FEATURE");
 	        case 0xaa: return ("SETFEATURES ENABLE RCACHE");
 	        case 0x55: return ("SETFEATURES DISABLE RCACHE");
 	        }

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 08:53:04 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BD9C9106566B;
	Thu, 14 Apr 2011 08:53:04 +0000 (UTC)
	(envelope-from pluknet@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id AA18A8FC0A;
	Thu, 14 Apr 2011 08:53:04 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3E8r4H2026635;
	Thu, 14 Apr 2011 08:53:04 GMT (envelope-from pluknet@svn.freebsd.org)
Received: (from pluknet@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3E8r4Rj026628;
	Thu, 14 Apr 2011 08:53:04 GMT (envelope-from pluknet@svn.freebsd.org)
Message-Id: <201104140853.p3E8r4Rj026628@svn.freebsd.org>
From: Sergey Kandaurov 
Date: Thu, 14 Apr 2011 08:53:04 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220617 - in head: lib/libc/gen sbin/reboot
	share/man/man4 share/man/man5
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 08:53:04 -0000

Author: pluknet
Date: Thu Apr 14 08:53:04 2011
New Revision: 220617
URL: http://svn.freebsd.org/changeset/base/220617

Log:
  Remove vestiges of disklabel(5).
  
  Reviewed by:	uqs
  MFC after:	5 days

Modified:
  head/lib/libc/gen/getdiskbyname.3
  head/sbin/reboot/boot_i386.8
  head/share/man/man4/cd.4
  head/share/man/man4/md.4
  head/share/man/man4/vinum.4
  head/share/man/man5/disktab.5

Modified: head/lib/libc/gen/getdiskbyname.3
==============================================================================
--- head/lib/libc/gen/getdiskbyname.3	Thu Apr 14 08:17:45 2011	(r220616)
+++ head/lib/libc/gen/getdiskbyname.3	Thu Apr 14 08:53:04 2011	(r220617)
@@ -54,7 +54,6 @@ the
 .Xr disktab 5
 file.
 .Sh SEE ALSO
-.Xr disklabel 5 ,
 .Xr disktab 5 ,
 .Xr disklabel 8
 .Sh HISTORY

Modified: head/sbin/reboot/boot_i386.8
==============================================================================
--- head/sbin/reboot/boot_i386.8	Thu Apr 14 08:17:45 2011	(r220616)
+++ head/sbin/reboot/boot_i386.8	Thu Apr 14 08:53:04 2011	(r220617)
@@ -358,9 +358,7 @@ requirement has not been adhered to.
 .Xr reboot 8 ,
 .Xr shutdown 8
 .Sh BUGS
-The
-.Xr bsdlabel 5
-format used by this version of
+The bsdlabel format used by this version of
 .Bx
 is quite
 different from that of other architectures.

Modified: head/share/man/man4/cd.4
==============================================================================
--- head/share/man/man4/cd.4	Thu Apr 14 08:17:45 2011	(r220616)
+++ head/share/man/man4/cd.4	Thu Apr 14 08:53:04 2011	(r220617)
@@ -111,8 +111,8 @@ drive.
 The disklabel is initialized with information
 read from the scsi inquiry commands, and should be the same as
 the information printed at boot.
-This structure is defined in
-.Xr disklabel 5 .
+This structure is defined in the header file
+.In sys/disklabel.h .
 .It Dv CDIOCCAPABILITY
 .Pq Li "struct ioc_capability"
 Retrieve information from the drive on what features it supports.
@@ -497,7 +497,6 @@ None.
 .Sh SEE ALSO
 .Xr cam 4 ,
 .Xr da 4 ,
-.Xr disklabel 5 ,
 .Xr disklabel 8 ,
 .Xr cd 9
 .Sh HISTORY

Modified: head/share/man/man4/md.4
==============================================================================
--- head/share/man/man4/md.4	Thu Apr 14 08:17:45 2011	(r220616)
+++ head/share/man/man4/md.4	Thu Apr 14 08:53:04 2011	(r220617)
@@ -81,7 +81,6 @@ disk found in the 
 man page.
 Other tools will also create these images, such as NanoBSD.
 .Sh SEE ALSO
-.Xr disklabel 5 ,
 .Xr disklabel 8 ,
 .Xr fdisk 8 ,
 .Xr loader 8 ,

Modified: head/share/man/man4/vinum.4
==============================================================================
--- head/share/man/man4/vinum.4	Thu Apr 14 08:17:45 2011	(r220616)
+++ head/share/man/man4/vinum.4	Thu Apr 14 08:53:04 2011	(r220617)
@@ -359,9 +359,6 @@ They are described in the header file
 Conventional disk special devices have a
 .Em "disk label"
 in the second sector of the device.
-See
-.Xr disklabel 5
-for more details.
 This disk label describes the layout of the partitions within
 the device.
 .Nm
@@ -842,7 +839,6 @@ The drive is not accessible.
 The drive is up and running.
 .El
 .Sh SEE ALSO
-.Xr disklabel 5 ,
 .Xr loader.conf 5 ,
 .Xr disklabel 8 ,
 .Xr gvinum 8 ,

Modified: head/share/man/man5/disktab.5
==============================================================================
--- head/share/man/man5/disktab.5	Thu Apr 14 08:17:45 2011	(r220616)
+++ head/share/man/man5/disktab.5	Thu Apr 14 08:53:04 2011	(r220617)
@@ -134,7 +134,6 @@ file system, swap, etc)
 .El
 .Sh SEE ALSO
 .Xr getdiskbyname 3 ,
-.\" .Xr bsdlabel 5 ,
 .Xr bsdlabel 8 ,
 .Xr newfs 8
 .Sh HISTORY

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 09:11:50 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EA9A41065674;
	Thu, 14 Apr 2011 09:11:50 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D85788FC18;
	Thu, 14 Apr 2011 09:11:50 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3E9Bolq027076;
	Thu, 14 Apr 2011 09:11:50 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3E9BooX027074;
	Thu, 14 Apr 2011 09:11:50 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104140911.p3E9BooX027074@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 14 Apr 2011 09:11:50 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220618 - head/sys/cam/ata
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 09:11:51 -0000

Author: mav
Date: Thu Apr 14 09:11:50 2011
New Revision: 220618
URL: http://svn.freebsd.org/changeset/base/220618

Log:
  Fix typo in write_cache tunable name and move TUNABLE_INT_FETCH() out of
  the SIM lock to fix WITNESS warning.
  
  Reported by:	jh

Modified:
  head/sys/cam/ata/ata_da.c

Modified: head/sys/cam/ata/ata_da.c
==============================================================================
--- head/sys/cam/ata/ata_da.c	Thu Apr 14 08:53:04 2011	(r220617)
+++ head/sys/cam/ata/ata_da.c	Thu Apr 14 09:11:50 2011	(r220618)
@@ -773,10 +773,6 @@ adaregister(struct cam_periph *periph, v
 		softc->quirks = ((struct ada_quirk_entry *)match)->quirks;
 	else
 		softc->quirks = ADA_Q_NONE;
-	softc->write_cache = -1;
-	snprintf(announce_buf, sizeof(announce_buf),
-	    "kern.cam.ada.%d.writa_cache", periph->unit_number);
-	TUNABLE_INT_FETCH(announce_buf, &softc->write_cache);
 
 	bzero(&cpi, sizeof(cpi));
 	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NONE);
@@ -788,7 +784,12 @@ adaregister(struct cam_periph *periph, v
 	/*
 	 * Register this media as a disk
 	 */
+	(void)cam_periph_hold(periph, PRIBIO);
 	mtx_unlock(periph->sim->mtx);
+	softc->write_cache = -1;
+	snprintf(announce_buf, sizeof(announce_buf),
+	    "kern.cam.ada.%d.write_cache", periph->unit_number);
+	TUNABLE_INT_FETCH(announce_buf, &softc->write_cache);
 	adagetparams(periph, cgd);
 	softc->disk = disk_alloc();
 	softc->disk->d_open = adaopen;
@@ -841,6 +842,7 @@ adaregister(struct cam_periph *periph, v
 
 	disk_create(softc->disk, DISK_VERSION);
 	mtx_lock(periph->sim->mtx);
+	cam_periph_unhold(periph);
 
 	dp = &softc->params;
 	snprintf(announce_buf, sizeof(announce_buf),

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 09:47:10 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 34E15106564A;
	Thu, 14 Apr 2011 09:47:10 +0000 (UTC) (envelope-from bz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2217F8FC0A;
	Thu, 14 Apr 2011 09:47:10 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3E9lAVW027865;
	Thu, 14 Apr 2011 09:47:10 GMT (envelope-from bz@svn.freebsd.org)
Received: (from bz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3E9lA3t027863;
	Thu, 14 Apr 2011 09:47:10 GMT (envelope-from bz@svn.freebsd.org)
Message-Id: <201104140947.p3E9lA3t027863@svn.freebsd.org>
From: "Bjoern A. Zeeb" 
Date: Thu, 14 Apr 2011 09:47:10 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220619 - head/sys/netinet
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 09:47:10 -0000

Author: bz
Date: Thu Apr 14 09:47:09 2011
New Revision: 220619
URL: http://svn.freebsd.org/changeset/base/220619

Log:
  The mbuf_frag_size always was and is file local and not queried from base
  user space tools via kvm.  Mark it static.
  
  MFC after:	3 days

Modified:
  head/sys/netinet/ip_output.c

Modified: head/sys/netinet/ip_output.c
==============================================================================
--- head/sys/netinet/ip_output.c	Thu Apr 14 09:11:50 2011	(r220618)
+++ head/sys/netinet/ip_output.c	Thu Apr 14 09:47:09 2011	(r220619)
@@ -87,7 +87,7 @@ __FBSDID("$FreeBSD$");
 VNET_DEFINE(u_short, ip_id);
 
 #ifdef MBUF_STRESS_TEST
-int mbuf_frag_size = 0;
+static int mbuf_frag_size = 0;
 SYSCTL_INT(_net_inet_ip, OID_AUTO, mbuf_frag_size, CTLFLAG_RW,
 	&mbuf_frag_size, 0, "Fragment outgoing mbufs to this size");
 #endif

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 10:27:11 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8D4F5106564A;
	Thu, 14 Apr 2011 10:27:11 +0000 (UTC)
	(envelope-from ivoras@gmail.com)
Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com
	[209.85.216.54])
	by mx1.freebsd.org (Postfix) with ESMTP id 0B1A68FC18;
	Thu, 14 Apr 2011 10:27:10 +0000 (UTC)
Received: by qwc9 with SMTP id 9so950336qwc.13
	for ; Thu, 14 Apr 2011 03:27:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:sender:in-reply-to:references:from
	:date:x-google-sender-auth:message-id:subject:to:cc:content-type
	:content-transfer-encoding;
	bh=Aa+EhYooXFIyKphRHjZlBf4c8T3LlPIG3ZIQsfB5h/w=;
	b=SNqeB5mVV+j8F53LlgzXNz4Q+B9axi4mb7u+nOxJU+SfStiU34S9fO6M3rCMnbvcSc
	p8mwqseBiJKEtVND8yWVjSKx8XlYGquqHLaXTLDErZ4k5adoK4duuoWvoNTySOh+PWE/
	SjzKkEHsMydIK6/tpWouYNhvmh+n41+2IlARc=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:sender:in-reply-to:references:from:date
	:x-google-sender-auth:message-id:subject:to:cc:content-type
	:content-transfer-encoding;
	b=P7ueNRP0AoLjUBD7Kf8A92na0ln9ycGTHcbaLwdbktk0SodyFplcaXS4NVmTsNmH5l
	uaqeQdWAltYmtXTCcAj8KrQ+pxsVoi6OBruh8ahBy4Y31Ri9VA1U/ITzK53OCLDHe7fw
	jGqIvdTIfIyPK+uN808EkxB0OPsp8KQOVg2Kw=
Received: by 10.229.128.211 with SMTP id l19mr385983qcs.31.1302776830215; Thu,
	14 Apr 2011 03:27:10 -0700 (PDT)
MIME-Version: 1.0
Sender: ivoras@gmail.com
Received: by 10.229.213.79 with HTTP; Thu, 14 Apr 2011 03:26:30 -0700 (PDT)
In-Reply-To: <201104131827.39373.jkim@FreeBSD.org>
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
	<4DA6189A.5040200@FreeBSD.org>
	<4DA61A70.8040609@FreeBSD.org> <201104131827.39373.jkim@FreeBSD.org>
From: Ivan Voras 
Date: Thu, 14 Apr 2011 12:26:30 +0200
X-Google-Sender-Auth: lVphHZPWPoCWMWKuryaGUXNsDKM
Message-ID: 
To: Jung-uk Kim 
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 10:27:11 -0000

On 14 April 2011 00:27, Jung-uk Kim  wrote:

>
> That means your VM has broken CPUID support. =C2=A0To get there, it has t=
o
> meet two conditions, i.e., TSC is invariant and it has APERF/MPERF
> MSRs. =C2=A0A simple workaround is setting "machdep.disable_tsc=3D1"
> tuanable from loader but your VM is the real culprit here.

You are probably right but fixing VMs is not going to happen (or not
soon enough) so workarounds must be implemented.

I don't know if it is called early enough for this purpose, but
detect_virtual() in kern/subr_param.c initializes the vm_guest
variable which could be useful for such workarounds (also see how
vm_guest is used in init_param1() in the same file to scale down HZ).

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 10:40:58 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 427651065670;
	Thu, 14 Apr 2011 10:40:58 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 13B508FC21;
	Thu, 14 Apr 2011 10:40:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EAevC7031510;
	Thu, 14 Apr 2011 10:40:57 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EAevn9031508;
	Thu, 14 Apr 2011 10:40:57 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104141040.p3EAevn9031508@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Thu, 14 Apr 2011 10:40:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220620 - head/sys/netinet
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 10:40:58 -0000

Author: trasz
Date: Thu Apr 14 10:40:57 2011
New Revision: 220620
URL: http://svn.freebsd.org/changeset/base/220620

Log:
  Refactor udp_input(), moving calls to u_tun_func() into udp_append().
  
  Obtained from: Wheel Systems Sp. z o.o.
  Reviewed by:	bz@

Modified:
  head/sys/netinet/udp_usrreq.c

Modified: head/sys/netinet/udp_usrreq.c
==============================================================================
--- head/sys/netinet/udp_usrreq.c	Thu Apr 14 09:47:09 2011	(r220619)
+++ head/sys/netinet/udp_usrreq.c	Thu Apr 14 10:40:57 2011	(r220620)
@@ -246,16 +246,24 @@ udp_append(struct inpcb *inp, struct ip 
 #ifdef INET6
 	struct sockaddr_in6 udp_in6;
 #endif
-#ifdef IPSEC
-#ifdef IPSEC_NAT_T
-#ifdef INET
 	struct udpcb *up;
-#endif
-#endif
-#endif
 
 	INP_RLOCK_ASSERT(inp);
 
+	/*
+	 * Engage the tunneling protocol.
+	 */
+	up = intoudpcb(inp);
+	if (up->u_tun_func != NULL) {
+		(*up->u_tun_func)(n, off, inp);
+		return;
+	}
+
+	if (n == NULL)
+		return;
+
+	off += sizeof(struct udphdr);
+
 #ifdef IPSEC
 	/* Check AH/ESP integrity. */
 	if (ipsec4_in_reject(n, inp)) {
@@ -322,7 +330,6 @@ udp_input(struct mbuf *m, int off)
 	struct udphdr *uh;
 	struct ifnet *ifp;
 	struct inpcb *inp;
-	struct udpcb *up;
 	int len;
 	struct ip save_ip;
 	struct sockaddr_in udp_in;
@@ -508,24 +515,7 @@ udp_input(struct mbuf *m, int off)
 				struct mbuf *n;
 
 				n = m_copy(m, 0, M_COPYALL);
-				up = intoudpcb(last);
-				if (up->u_tun_func == NULL) {
-					if (n != NULL)
-						udp_append(last, 
-						    ip, n, 
-						    iphlen +
-						    sizeof(struct udphdr),
-						    &udp_in);
-				} else {
-					/*
-					 * Engage the tunneling protocol we
-					 * will have to leave the info_lock
-					 * up, since we are hunting through
-					 * multiple UDP's.
-					 */
-
-					(*up->u_tun_func)(n, iphlen, last);
-				}
+				udp_append(last, ip, n, iphlen, &udp_in);
 				INP_RUNLOCK(last);
 			}
 			last = inp;
@@ -551,16 +541,7 @@ udp_input(struct mbuf *m, int off)
 			UDPSTAT_INC(udps_noportbcast);
 			goto badheadlocked;
 		}
-		up = intoudpcb(last);
-		if (up->u_tun_func == NULL) {
-			udp_append(last, ip, m, iphlen + sizeof(struct udphdr),
-			    &udp_in);
-		} else {
-			/*
-			 * Engage the tunneling protocol.
-			 */
-			(*up->u_tun_func)(m, iphlen, last);
-		}
+		udp_append(last, ip, m, iphlen, &udp_in);
 		INP_RUNLOCK(last);
 		INP_INFO_RUNLOCK(&V_udbinfo);
 		return;
@@ -606,16 +587,7 @@ udp_input(struct mbuf *m, int off)
 		INP_RUNLOCK(inp);
 		goto badunlocked;
 	}
-	up = intoudpcb(inp);
-	if (up->u_tun_func == NULL) {
-		udp_append(inp, ip, m, iphlen + sizeof(struct udphdr), &udp_in);
-	} else {
-		/*
-		 * Engage the tunneling protocol.
-		 */
-
-		(*up->u_tun_func)(m, iphlen, inp);
-	}
+	udp_append(inp, ip, m, iphlen, &udp_in);
 	INP_RUNLOCK(inp);
 	return;
 

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 10:49:22 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A4754106566B;
	Thu, 14 Apr 2011 10:49:22 +0000 (UTC) (envelope-from dim@FreeBSD.org)
Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net
	[IPv6:2001:7b8:2ff:146::2])
	by mx1.freebsd.org (Postfix) with ESMTP id 5D2588FC16;
	Thu, 14 Apr 2011 10:49:22 +0000 (UTC)
Received: from [IPv6:2001:7b8:3a7:0:dd48:486e:166b:644] (unknown
	[IPv6:2001:7b8:3a7:0:dd48:486e:166b:644])
	(using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
	(No client certificate requested)
	by tensor.andric.com (Postfix) with ESMTPSA id 629125C59;
	Thu, 14 Apr 2011 12:49:21 +0200 (CEST)
Message-ID: <4DA6D145.8070804@FreeBSD.org>
Date: Thu, 14 Apr 2011 12:49:41 +0200
From: Dimitry Andric 
Organization: The FreeBSD Project
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
	rv:1.9.2.16pre) Gecko/20110319 Lanikai/3.1.10pre
MIME-Version: 1.0
To: Jung-uk Kim 
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
	<4DA6189A.5040200@FreeBSD.org> <4DA61A70.8040609@FreeBSD.org>
	<201104131827.39373.jkim@FreeBSD.org>
In-Reply-To: <201104131827.39373.jkim@FreeBSD.org>
Content-Type: multipart/mixed; boundary="------------090705030302090306020404"
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 10:49:22 -0000

This is a multi-part message in MIME format.
--------------090705030302090306020404
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

On 2011-04-14 00:27, Jung-uk Kim wrote:
...
>> will still read 0 from MSR_MPERF, leading to a division by zero.
>> Maybe just fallback to the second method in the 'else' branch then?
>
> That means your VM has broken CPUID support.  To get there, it has to
> meet two conditions, i.e., TSC is invariant and it has APERF/MPERF
> MSRs.

Well, VM hosts like VMware and VirtualBox usually just return the
'native' CPUID values to guests, but can't really support stuff like
those MSRs, for all kinds of reasons.

I was just looking at this from a viewpoint of "it worked for years, and
now it broke". :)

In any case, I don't see why a bit of defensive programming would be bad
here, so I propose the following patch to revert to the 'old' way of
estimating the rate, in case reading the MPERF MSR returns zero.

--------------090705030302090306020404
Content-Type: text/plain;
 name="est-zero-mcnt-workaround-1.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="est-zero-mcnt-workaround-1.diff"

Index: sys/i386/i386/machdep.c
===================================================================
--- sys/i386/i386/machdep.c	(revision 220620)
+++ sys/i386/i386/machdep.c	(working copy)
@@ -1172,7 +1172,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate)
 		acnt = rdmsr(MSR_APERF);
 		tsc2 = rdtsc();
 		intr_restore(reg);
-		perf = 1000 * acnt / mcnt;
+		perf = (mcnt != 0) ? 1000 * acnt / mcnt : 1000;
 		*rate = (tsc2 - tsc1) * perf;
 	} else {
 		tsc1 = rdtsc();
Index: sys/amd64/amd64/machdep.c
===================================================================
--- sys/amd64/amd64/machdep.c	(revision 220620)
+++ sys/amd64/amd64/machdep.c	(working copy)
@@ -579,7 +579,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate)
 		acnt = rdmsr(MSR_APERF);
 		tsc2 = rdtsc();
 		intr_restore(reg);
-		perf = 1000 * acnt / mcnt;
+		perf = (mcnt != 0) ? 1000 * acnt / mcnt : 1000;
 		*rate = (tsc2 - tsc1) * perf;
 	} else {
 		tsc1 = rdtsc();

--------------090705030302090306020404--

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 14:25:48 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3DBCF106566B;
	Thu, 14 Apr 2011 14:25:48 +0000 (UTC)
	(envelope-from pluknet@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2934B8FC17;
	Thu, 14 Apr 2011 14:25:48 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EEPmpl036777;
	Thu, 14 Apr 2011 14:25:48 GMT (envelope-from pluknet@svn.freebsd.org)
Received: (from pluknet@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EEPm1h036774;
	Thu, 14 Apr 2011 14:25:48 GMT (envelope-from pluknet@svn.freebsd.org)
Message-Id: <201104141425.p3EEPm1h036774@svn.freebsd.org>
From: Sergey Kandaurov 
Date: Thu, 14 Apr 2011 14:25:48 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220621 - in head/sys: kern sys
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 14:25:48 -0000

Author: pluknet
Date: Thu Apr 14 14:25:47 2011
New Revision: 220621
URL: http://svn.freebsd.org/changeset/base/220621

Log:
  Remove stale M_ZOMBIE malloc type.
  This type is unused since embedding p_ru into struct proc.
  
  MFC after:	1 week

Modified:
  head/sys/kern/kern_exit.c
  head/sys/sys/proc.h

Modified: head/sys/kern/kern_exit.c
==============================================================================
--- head/sys/kern/kern_exit.c	Thu Apr 14 10:40:57 2011	(r220620)
+++ head/sys/kern/kern_exit.c	Thu Apr 14 14:25:47 2011	(r220621)
@@ -94,9 +94,6 @@ SDT_PROVIDER_DECLARE(proc);
 SDT_PROBE_DEFINE(proc, kernel, , exit, exit);
 SDT_PROBE_ARGTYPE(proc, kernel, , exit, 0, "int");
 
-/* Required to be non-static for SysVR4 emulator */
-MALLOC_DEFINE(M_ZOMBIE, "zombie", "zombie proc status");
-
 /* Hook for NFS teardown procedure. */
 void (*nlminfo_release_p)(struct proc *p);
 

Modified: head/sys/sys/proc.h
==============================================================================
--- head/sys/sys/proc.h	Thu Apr 14 10:40:57 2011	(r220620)
+++ head/sys/sys/proc.h	Thu Apr 14 14:25:47 2011	(r220621)
@@ -664,7 +664,6 @@ MALLOC_DECLARE(M_PARGS);
 MALLOC_DECLARE(M_PGRP);
 MALLOC_DECLARE(M_SESSION);
 MALLOC_DECLARE(M_SUBPROC);
-MALLOC_DECLARE(M_ZOMBIE);
 #endif
 
 #define	FOREACH_PROC_IN_SYSTEM(p)					\

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 14:45:10 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by hub.freebsd.org (Postfix) with ESMTP id 810C2106564A;
	Thu, 14 Apr 2011 14:45:09 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
From: Jung-uk Kim 
To: Dimitry Andric 
Date: Thu, 14 Apr 2011 10:44:48 -0400
User-Agent: KMail/1.6.2
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
	<201104131827.39373.jkim@FreeBSD.org>
	<4DA6D145.8070804@FreeBSD.org>
In-Reply-To: <4DA6D145.8070804@FreeBSD.org>
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Message-Id: <201104141044.55789.jkim@FreeBSD.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 14:45:10 -0000

On Thursday 14 April 2011 06:49 am, Dimitry Andric wrote:
> On 2011-04-14 00:27, Jung-uk Kim wrote:
> ...
>
> >> will still read 0 from MSR_MPERF, leading to a division by zero.
> >> Maybe just fallback to the second method in the 'else' branch
> >> then?
> >
> > That means your VM has broken CPUID support.  To get there, it
> > has to meet two conditions, i.e., TSC is invariant and it has
> > APERF/MPERF MSRs.
>
> Well, VM hosts like VMware and VirtualBox usually just return the
> 'native' CPUID values to guests, but can't really support stuff
> like those MSRs, for all kinds of reasons.
>
> I was just looking at this from a viewpoint of "it worked for
> years, and now it broke". :)
>
> In any case, I don't see why a bit of defensive programming would
> be bad here, so I propose the following patch to revert to the
> 'old' way of estimating the rate, in case reading the MPERF MSR
> returns zero.

I am going to test APERF & MPERF so that you don't need to do that 
from there.  Please stay tuned.

Jung-uk Kim

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 14:54:22 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E5E0B106564A;
	Thu, 14 Apr 2011 14:54:22 +0000 (UTC)
	(envelope-from glebius@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D3BA68FC08;
	Thu, 14 Apr 2011 14:54:22 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EEsMas037438;
	Thu, 14 Apr 2011 14:54:22 GMT (envelope-from glebius@svn.freebsd.org)
Received: (from glebius@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EEsMAJ037436;
	Thu, 14 Apr 2011 14:54:22 GMT (envelope-from glebius@svn.freebsd.org)
Message-Id: <201104141454.p3EEsMAJ037436@svn.freebsd.org>
From: Gleb Smirnoff 
Date: Thu, 14 Apr 2011 14:54:22 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220622 - head/sys/kern
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 14:54:23 -0000

Author: glebius
Date: Thu Apr 14 14:54:22 2011
New Revision: 220622
URL: http://svn.freebsd.org/changeset/base/220622

Log:
  Revert r194662, since it breaks ng_ksocket(4) and may break
  other socket consumers with alternate sb_upcall.
  
  PR:		kern/154676
  Submitted by:	Arnaud Lacombe 
  MFC after:	7 days

Modified:
  head/sys/kern/uipc_sockbuf.c

Modified: head/sys/kern/uipc_sockbuf.c
==============================================================================
--- head/sys/kern/uipc_sockbuf.c	Thu Apr 14 14:25:47 2011	(r220621)
+++ head/sys/kern/uipc_sockbuf.c	Thu Apr 14 14:54:22 2011	(r220622)
@@ -528,9 +528,6 @@ sbappendstream_locked(struct sockbuf *sb
 
 	SBLASTMBUFCHK(sb);
 
-	/* Remove all packet headers and mbuf tags to get a pure data chain. */
-	m_demote(m, 1);
-	
 	sbcompress(sb, m, sb->sb_mbtail);
 
 	sb->sb_lastrecord = sb->sb_mb;

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 15:06:47 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by hub.freebsd.org (Postfix) with ESMTP id 67DFB106566B;
	Thu, 14 Apr 2011 15:06:47 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
From: Jung-uk Kim 
To: Dimitry Andric 
Date: Thu, 14 Apr 2011 11:06:37 -0400
User-Agent: KMail/1.6.2
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
	<4DA6D145.8070804@FreeBSD.org>
	<201104141044.55789.jkim@FreeBSD.org>
In-Reply-To: <201104141044.55789.jkim@FreeBSD.org>
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: Multipart/Mixed;
  boundary="Boundary-00=_A2wpNeamMJ/Vg7B"
Message-Id: <201104141106.40303.jkim@FreeBSD.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 15:06:47 -0000


--Boundary-00=_A2wpNeamMJ/Vg7B
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Thursday 14 April 2011 10:44 am, Jung-uk Kim wrote:
> On Thursday 14 April 2011 06:49 am, Dimitry Andric wrote:
> > On 2011-04-14 00:27, Jung-uk Kim wrote:
> > ...
> >
> > >> will still read 0 from MSR_MPERF, leading to a division by
> > >> zero. Maybe just fallback to the second method in the 'else'
> > >> branch then?
> > >
> > > That means your VM has broken CPUID support.  To get there, it
> > > has to meet two conditions, i.e., TSC is invariant and it has
> > > APERF/MPERF MSRs.
> >
> > Well, VM hosts like VMware and VirtualBox usually just return the
> > 'native' CPUID values to guests, but can't really support stuff
> > like those MSRs, for all kinds of reasons.
> >
> > I was just looking at this from a viewpoint of "it worked for
> > years, and now it broke". :)
> >
> > In any case, I don't see why a bit of defensive programming would
> > be bad here, so I propose the following patch to revert to the
> > 'old' way of estimating the rate, in case reading the MPERF MSR
> > returns zero.
>
> I am going to test APERF & MPERF so that you don't need to do that
> from there.  Please stay tuned.

Can you please test the attached patch?

Thanks,

Jung-uk Kim

--Boundary-00=_A2wpNeamMJ/Vg7B
Content-Type: text/plain;
  charset="iso-8859-1";
  name="tsc.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="tsc.diff"

Index: sys/x86/x86/tsc.c
===================================================================
--- sys/x86/x86/tsc.c	(revision 220613)
+++ sys/x86/x86/tsc.c	(working copy)
@@ -183,8 +183,18 @@ probe_tsc_freq(void)
 
 	if (cpu_high >= 6) {
 		do_cpuid(6, regs);
-		if ((regs[2] & CPUID_PERF_STAT) != 0)
-			tsc_perf_stat = 1;
+		if ((regs[2] & CPUID_PERF_STAT) != 0) {
+			/*
+			 * XXX Some emulators expose host CPUID without actual
+			 * support for these MSRs.  We must test whether they
+			 * really work.
+			 */
+			wrmsr(MSR_MPERF, 0);
+			wrmsr(MSR_APERF, 0);
+			DELAY(10);
+			if (rdmsr(MSR_MPERF) > 0 && rdmsr(MSR_APERF) > 0)
+				tsc_perf_stat = 1;
+		}
 	}
 
 	if (tsc_skip_calibration) {

--Boundary-00=_A2wpNeamMJ/Vg7B--

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 15:42:16 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 31DA3106566C;
	Thu, 14 Apr 2011 15:42:16 +0000 (UTC)
	(envelope-from obrien@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 20A308FC1F;
	Thu, 14 Apr 2011 15:42:16 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EFgGIa038771;
	Thu, 14 Apr 2011 15:42:16 GMT (envelope-from obrien@svn.freebsd.org)
Received: (from obrien@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EFgGiK038768;
	Thu, 14 Apr 2011 15:42:16 GMT (envelope-from obrien@svn.freebsd.org)
Message-Id: <201104141542.p3EFgGiK038768@svn.freebsd.org>
From: "David E. O'Brien" 
Date: Thu, 14 Apr 2011 15:42:16 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220624 - in head/lib/libedit: . edit/readline
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 15:42:16 -0000

Author: obrien
Date: Thu Apr 14 15:42:15 2011
New Revision: 220624
URL: http://svn.freebsd.org/changeset/base/220624

Log:
  Add $FreeBSD$'s.

Modified:
  head/lib/libedit/chartype.h
  head/lib/libedit/edit/readline/readline.h

Modified: head/lib/libedit/chartype.h
==============================================================================
--- head/lib/libedit/chartype.h	Thu Apr 14 15:25:27 2011	(r220623)
+++ head/lib/libedit/chartype.h	Thu Apr 14 15:42:15 2011	(r220624)
@@ -31,6 +31,8 @@
  * CONTRACT, STRICT LIABILITY, OR TORT (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$
  */
 
 #ifndef _h_chartype_f

Modified: head/lib/libedit/edit/readline/readline.h
==============================================================================
--- head/lib/libedit/edit/readline/readline.h	Thu Apr 14 15:25:27 2011	(r220623)
+++ head/lib/libedit/edit/readline/readline.h	Thu Apr 14 15:42:15 2011	(r220624)
@@ -27,6 +27,8 @@
  * CONTRACT, STRICT LIABILITY, OR TORT (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$
  */
 #ifndef _READLINE_H_
 #define _READLINE_H_

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 15:44:44 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EDF9F106566C;
	Thu, 14 Apr 2011 15:44:44 +0000 (UTC)
	(envelope-from nwhitehorn@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DDA348FC1F;
	Thu, 14 Apr 2011 15:44:44 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EFiicY038965;
	Thu, 14 Apr 2011 15:44:44 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Received: (from nwhitehorn@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EFiiNP038963;
	Thu, 14 Apr 2011 15:44:44 GMT
	(envelope-from nwhitehorn@svn.freebsd.org)
Message-Id: <201104141544.p3EFiiNP038963@svn.freebsd.org>
From: Nathan Whitehorn 
Date: Thu, 14 Apr 2011 15:44:44 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220626 - head
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 15:44:45 -0000

Author: nwhitehorn
Date: Thu Apr 14 15:44:44 2011
New Revision: 220626
URL: http://svn.freebsd.org/changeset/base/220626

Log:
  Provide a (belated) UPDATING note related to the new release-building
  process so that fewer people will be caught unaware.
  
  Requested by:	emaste

Modified:
  head/UPDATING

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Thu Apr 14 15:43:21 2011	(r220625)
+++ head/UPDATING	Thu Apr 14 15:44:44 2011	(r220626)
@@ -32,6 +32,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.
 	TO REPEAT: if_ath_ahb is not needed for normal users. Normal users only
 	need to load if_ath and if_ath_pci for ath(4) operation.
 
+20110314:
+	As part of the replacement of sysinstall, the process of building
+	release media has changed significantly. For details, please re-read
+	release(7), which has been updated to reflect the new build process.
+
 20110218:
 	GNU binutils 2.17.50 (as of 2007-07-03) has been merged to -HEAD.  This
 	is the last available version under GPLv2.  It brings a number of new

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 16:01:06 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5553A1065673;
	Thu, 14 Apr 2011 16:01:06 +0000 (UTC) (envelope-from jh@FreeBSD.org)
Received: from gw02.mail.saunalahti.fi (gw02.mail.saunalahti.fi
	[195.197.172.116])
	by mx1.freebsd.org (Postfix) with ESMTP id 98A9B8FC17;
	Thu, 14 Apr 2011 16:01:05 +0000 (UTC)
Received: from a91-153-123-205.elisa-laajakaista.fi
	(a91-153-123-205.elisa-laajakaista.fi [91.153.123.205])
	by gw02.mail.saunalahti.fi (Postfix) with SMTP id EE01E1397B6;
	Thu, 14 Apr 2011 19:00:59 +0300 (EEST)
Date: Thu, 14 Apr 2011 19:00:59 +0300
From: Jaakko Heinonen 
To: Alexander Motin 
Message-ID: <20110414160059.GA1644@a91-153-123-205.elisa-laajakaista.fi>
References: <201104140911.p3E9BooX027074@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201104140911.p3E9BooX027074@svn.freebsd.org>
User-Agent: Mutt/1.5.21 (2010-09-15)
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220618 - head/sys/cam/ata
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 16:01:06 -0000

On 2011-04-14, Alexander Motin wrote:
>   Fix typo in write_cache tunable name and move TUNABLE_INT_FETCH() out of
>   the SIM lock to fix WITNESS warning.

Thanks!

Does this analogous patch for cd(4) and da(4) look good? I am not
completely sure if it's safe to move setting of minimum_cmd_size in
daregister().

---

Move TUNABLE_INT_FETCH() out of the SIM lock to avoid sleeping while
holding the lock. The fix is analogous to r220618 for ada(4).

%%%
Index: sys/cam/scsi/scsi_cd.c
===================================================================
--- sys/cam/scsi/scsi_cd.c	(revision 220619)
+++ sys/cam/scsi/scsi_cd.c	(working copy)
@@ -687,6 +687,8 @@ cdregister(struct cam_periph *periph, vo
 	else
 		softc->minimum_command_size = 6;
 
+	(void)cam_periph_hold(periph, PRIBIO);
+	cam_periph_unlock(periph);
 	/*
 	 * Load the user's default, if any.
 	 */
@@ -712,7 +714,6 @@ cdregister(struct cam_periph *periph, vo
 	 * WORM peripheral driver.  WORM drives will also have the WORM
 	 * driver attached to them.
 	 */
-	cam_periph_unlock(periph);
 	softc->disk = disk_alloc();
 	softc->disk->d_devstat = devstat_new_entry("cd", 
 			  periph->unit_number, 0,
@@ -745,6 +746,7 @@ cdregister(struct cam_periph *periph, vo
 	softc->disk->d_hba_subdevice = cpi.hba_subdevice;
 	disk_create(softc->disk, DISK_VERSION);
 	cam_periph_lock(periph);
+	cam_periph_unhold(periph);
 
 	/*
 	 * Add an async callback so that we get
Index: sys/cam/scsi/scsi_da.c
===================================================================
--- sys/cam/scsi/scsi_da.c	(revision 220619)
+++ sys/cam/scsi/scsi_da.c	(working copy)
@@ -1231,35 +1231,6 @@ daregister(struct cam_periph *periph, vo
 	TASK_INIT(&softc->sysctl_task, 0, dasysctlinit, periph);
 
 	/*
-	 * RBC devices don't have to support READ(6), only READ(10).
-	 */
-	if (softc->quirks & DA_Q_NO_6_BYTE || SID_TYPE(&cgd->inq_data) == T_RBC)
-		softc->minimum_cmd_size = 10;
-	else
-		softc->minimum_cmd_size = 6;
-
-	/*
-	 * Load the user's default, if any.
-	 */
-	snprintf(tmpstr, sizeof(tmpstr), "kern.cam.da.%d.minimum_cmd_size",
-		 periph->unit_number);
-	TUNABLE_INT_FETCH(tmpstr, &softc->minimum_cmd_size);
-
-	/*
-	 * 6, 10, 12 and 16 are the currently permissible values.
-	 */
-	if (softc->minimum_cmd_size < 6)
-		softc->minimum_cmd_size = 6;
-	else if ((softc->minimum_cmd_size > 6)
-	      && (softc->minimum_cmd_size <= 10))
-		softc->minimum_cmd_size = 10;
-	else if ((softc->minimum_cmd_size > 10)
-	      && (softc->minimum_cmd_size <= 12))
-		softc->minimum_cmd_size = 12;
-	else if (softc->minimum_cmd_size > 12)
-		softc->minimum_cmd_size = 16;
-
-	/*
 	 * Register this media as a disk
 	 */
 
@@ -1291,6 +1262,35 @@ daregister(struct cam_periph *periph, vo
 	    dasendorderedtag, softc);
 
 	mtx_unlock(periph->sim->mtx);
+	/*
+	 * RBC devices don't have to support READ(6), only READ(10).
+	 */
+	if (softc->quirks & DA_Q_NO_6_BYTE || SID_TYPE(&cgd->inq_data) == T_RBC)
+		softc->minimum_cmd_size = 10;
+	else
+		softc->minimum_cmd_size = 6;
+
+	/*
+	 * Load the user's default, if any.
+	 */
+	snprintf(tmpstr, sizeof(tmpstr), "kern.cam.da.%d.minimum_cmd_size",
+		 periph->unit_number);
+	TUNABLE_INT_FETCH(tmpstr, &softc->minimum_cmd_size);
+
+	/*
+	 * 6, 10, 12 and 16 are the currently permissible values.
+	 */
+	if (softc->minimum_cmd_size < 6)
+		softc->minimum_cmd_size = 6;
+	else if ((softc->minimum_cmd_size > 6)
+	      && (softc->minimum_cmd_size <= 10))
+		softc->minimum_cmd_size = 10;
+	else if ((softc->minimum_cmd_size > 10)
+	      && (softc->minimum_cmd_size <= 12))
+		softc->minimum_cmd_size = 12;
+	else if (softc->minimum_cmd_size > 12)
+		softc->minimum_cmd_size = 16;
+
 	softc->disk = disk_alloc();
 	softc->disk->d_open = daopen;
 	softc->disk->d_close = daclose;
%%%

-- 
Jaakko

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 16:02:52 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 74431106566B;
	Thu, 14 Apr 2011 16:02:52 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6396D8FC16;
	Thu, 14 Apr 2011 16:02:52 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EG2qTv039435;
	Thu, 14 Apr 2011 16:02:52 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EG2q9e039433;
	Thu, 14 Apr 2011 16:02:52 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104141602.p3EG2q9e039433@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 14 Apr 2011 16:02:52 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220627 - head/sys/i386/include
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 16:02:52 -0000

Author: jkim
Date: Thu Apr 14 16:02:52 2011
New Revision: 220627
URL: http://svn.freebsd.org/changeset/base/220627

Log:
  Consistently use C99 standard integers as the rest of this file.

Modified:
  head/sys/i386/include/cpufunc.h

Modified: head/sys/i386/include/cpufunc.h
==============================================================================
--- head/sys/i386/include/cpufunc.h	Thu Apr 14 15:44:44 2011	(r220626)
+++ head/sys/i386/include/cpufunc.h	Thu Apr 14 16:02:52 2011	(r220627)
@@ -55,13 +55,13 @@ extern u_int read_eflags(void);
 
 struct region_descriptor;
 
-#define readb(va)	(*(volatile u_int8_t *) (va))
-#define readw(va)	(*(volatile u_int16_t *) (va))
-#define readl(va)	(*(volatile u_int32_t *) (va))
-
-#define writeb(va, d)	(*(volatile u_int8_t *) (va) = (d))
-#define writew(va, d)	(*(volatile u_int16_t *) (va) = (d))
-#define writel(va, d)	(*(volatile u_int32_t *) (va) = (d))
+#define readb(va)	(*(volatile uint8_t *) (va))
+#define readw(va)	(*(volatile uint16_t *) (va))
+#define readl(va)	(*(volatile uint32_t *) (va))
+
+#define writeb(va, d)	(*(volatile uint8_t *) (va) = (d))
+#define writew(va, d)	(*(volatile uint16_t *) (va) = (d))
+#define writel(va, d)	(*(volatile uint32_t *) (va) = (d))
 
 #if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
 

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 16:14:35 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9ACA21065673;
	Thu, 14 Apr 2011 16:14:35 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 89A728FC1C;
	Thu, 14 Apr 2011 16:14:35 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EGEZxx039810;
	Thu, 14 Apr 2011 16:14:35 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EGEZI9039808;
	Thu, 14 Apr 2011 16:14:35 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104141614.p3EGEZI9039808@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 14 Apr 2011 16:14:35 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220628 - head/sys/amd64/include
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 16:14:35 -0000

Author: jkim
Date: Thu Apr 14 16:14:35 2011
New Revision: 220628
URL: http://svn.freebsd.org/changeset/base/220628

Log:
  Prefer C99 standard integers to reduce diff from i386 version.

Modified:
  head/sys/amd64/include/cpufunc.h

Modified: head/sys/amd64/include/cpufunc.h
==============================================================================
--- head/sys/amd64/include/cpufunc.h	Thu Apr 14 16:02:52 2011	(r220627)
+++ head/sys/amd64/include/cpufunc.h	Thu Apr 14 16:14:35 2011	(r220628)
@@ -45,15 +45,15 @@
 
 struct region_descriptor;
 
-#define readb(va)	(*(volatile u_int8_t *) (va))
-#define readw(va)	(*(volatile u_int16_t *) (va))
-#define readl(va)	(*(volatile u_int32_t *) (va))
-#define readq(va)	(*(volatile u_int64_t *) (va))
-
-#define writeb(va, d)	(*(volatile u_int8_t *) (va) = (d))
-#define writew(va, d)	(*(volatile u_int16_t *) (va) = (d))
-#define writel(va, d)	(*(volatile u_int32_t *) (va) = (d))
-#define writeq(va, d)	(*(volatile u_int64_t *) (va) = (d))
+#define readb(va)	(*(volatile uint8_t *) (va))
+#define readw(va)	(*(volatile uint16_t *) (va))
+#define readl(va)	(*(volatile uint32_t *) (va))
+#define readq(va)	(*(volatile uint64_t *) (va))
+
+#define writeb(va, d)	(*(volatile uint8_t *) (va) = (d))
+#define writew(va, d)	(*(volatile uint16_t *) (va) = (d))
+#define writel(va, d)	(*(volatile uint32_t *) (va) = (d))
+#define writeq(va, d)	(*(volatile uint64_t *) (va) = (d))
 
 #if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
 
@@ -295,31 +295,31 @@ read_rflags(void)
 	return (rf);
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdmsr(u_int msr)
 {
-	u_int32_t low, high;
+	uint32_t low, high;
 
 	__asm __volatile("rdmsr" : "=a" (low), "=d" (high) : "c" (msr));
-	return (low | ((u_int64_t)high << 32));
+	return (low | ((uint64_t)high << 32));
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdpmc(u_int pmc)
 {
-	u_int32_t low, high;
+	uint32_t low, high;
 
 	__asm __volatile("rdpmc" : "=a" (low), "=d" (high) : "c" (pmc));
-	return (low | ((u_int64_t)high << 32));
+	return (low | ((uint64_t)high << 32));
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdtsc(void)
 {
-	u_int32_t low, high;
+	uint32_t low, high;
 
 	__asm __volatile("rdtsc" : "=a" (low), "=d" (high));
-	return (low | ((u_int64_t)high << 32));
+	return (low | ((uint64_t)high << 32));
 }
 
 static __inline void
@@ -335,9 +335,9 @@ write_rflags(u_long rf)
 }
 
 static __inline void
-wrmsr(u_int msr, u_int64_t newval)
+wrmsr(u_int msr, uint64_t newval)
 {
-	u_int32_t low, high;
+	uint32_t low, high;
 
 	low = newval;
 	high = newval >> 32;
@@ -530,114 +530,114 @@ ltr(u_short sel)
 	__asm __volatile("ltr %0" : : "r" (sel));
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdr0(void)
 {
-	u_int64_t data;
+	uint64_t data;
 	__asm __volatile("movq %%dr0,%0" : "=r" (data));
 	return (data);
 }
 
 static __inline void
-load_dr0(u_int64_t dr0)
+load_dr0(uint64_t dr0)
 {
 	__asm __volatile("movq %0,%%dr0" : : "r" (dr0));
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdr1(void)
 {
-	u_int64_t data;
+	uint64_t data;
 	__asm __volatile("movq %%dr1,%0" : "=r" (data));
 	return (data);
 }
 
 static __inline void
-load_dr1(u_int64_t dr1)
+load_dr1(uint64_t dr1)
 {
 	__asm __volatile("movq %0,%%dr1" : : "r" (dr1));
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdr2(void)
 {
-	u_int64_t data;
+	uint64_t data;
 	__asm __volatile("movq %%dr2,%0" : "=r" (data));
 	return (data);
 }
 
 static __inline void
-load_dr2(u_int64_t dr2)
+load_dr2(uint64_t dr2)
 {
 	__asm __volatile("movq %0,%%dr2" : : "r" (dr2));
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdr3(void)
 {
-	u_int64_t data;
+	uint64_t data;
 	__asm __volatile("movq %%dr3,%0" : "=r" (data));
 	return (data);
 }
 
 static __inline void
-load_dr3(u_int64_t dr3)
+load_dr3(uint64_t dr3)
 {
 	__asm __volatile("movq %0,%%dr3" : : "r" (dr3));
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdr4(void)
 {
-	u_int64_t data;
+	uint64_t data;
 	__asm __volatile("movq %%dr4,%0" : "=r" (data));
 	return (data);
 }
 
 static __inline void
-load_dr4(u_int64_t dr4)
+load_dr4(uint64_t dr4)
 {
 	__asm __volatile("movq %0,%%dr4" : : "r" (dr4));
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdr5(void)
 {
-	u_int64_t data;
+	uint64_t data;
 	__asm __volatile("movq %%dr5,%0" : "=r" (data));
 	return (data);
 }
 
 static __inline void
-load_dr5(u_int64_t dr5)
+load_dr5(uint64_t dr5)
 {
 	__asm __volatile("movq %0,%%dr5" : : "r" (dr5));
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdr6(void)
 {
-	u_int64_t data;
+	uint64_t data;
 	__asm __volatile("movq %%dr6,%0" : "=r" (data));
 	return (data);
 }
 
 static __inline void
-load_dr6(u_int64_t dr6)
+load_dr6(uint64_t dr6)
 {
 	__asm __volatile("movq %0,%%dr6" : : "r" (dr6));
 }
 
-static __inline u_int64_t
+static __inline uint64_t
 rdr7(void)
 {
-	u_int64_t data;
+	uint64_t data;
 	__asm __volatile("movq %%dr7,%0" : "=r" (data));
 	return (data);
 }
 
 static __inline void
-load_dr7(u_int64_t dr7)
+load_dr7(uint64_t dr7)
 {
 	__asm __volatile("movq %0,%%dr7" : : "r" (dr7));
 }
@@ -684,14 +684,14 @@ void	lldt(u_short sel);
 void	load_cr0(u_long cr0);
 void	load_cr3(u_long cr3);
 void	load_cr4(u_long cr4);
-void	load_dr0(u_int64_t dr0);
-void	load_dr1(u_int64_t dr1);
-void	load_dr2(u_int64_t dr2);
-void	load_dr3(u_int64_t dr3);
-void	load_dr4(u_int64_t dr4);
-void	load_dr5(u_int64_t dr5);
-void	load_dr6(u_int64_t dr6);
-void	load_dr7(u_int64_t dr7);
+void	load_dr0(uint64_t dr0);
+void	load_dr1(uint64_t dr1);
+void	load_dr2(uint64_t dr2);
+void	load_dr3(uint64_t dr3);
+void	load_dr4(uint64_t dr4);
+void	load_dr5(uint64_t dr5);
+void	load_dr6(uint64_t dr6);
+void	load_dr7(uint64_t dr7);
 void	load_fs(u_short sel);
 void	load_gs(u_short sel);
 void	ltr(u_short sel);
@@ -705,23 +705,23 @@ u_long	rcr0(void);
 u_long	rcr2(void);
 u_long	rcr3(void);
 u_long	rcr4(void);
-u_int64_t rdmsr(u_int msr);
-u_int64_t rdpmc(u_int pmc);
-u_int64_t rdr0(void);
-u_int64_t rdr1(void);
-u_int64_t rdr2(void);
-u_int64_t rdr3(void);
-u_int64_t rdr4(void);
-u_int64_t rdr5(void);
-u_int64_t rdr6(void);
-u_int64_t rdr7(void);
-u_int64_t rdtsc(void);
+uint64_t rdmsr(u_int msr);
+uint64_t rdpmc(u_int pmc);
+uint64_t rdr0(void);
+uint64_t rdr1(void);
+uint64_t rdr2(void);
+uint64_t rdr3(void);
+uint64_t rdr4(void);
+uint64_t rdr5(void);
+uint64_t rdr6(void);
+uint64_t rdr7(void);
+uint64_t rdtsc(void);
 u_int	read_rflags(void);
 u_int	rfs(void);
 u_int	rgs(void);
 void	wbinvd(void);
 void	write_rflags(u_int rf);
-void	wrmsr(u_int msr, u_int64_t newval);
+void	wrmsr(u_int msr, uint64_t newval);
 
 #endif	/* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */
 

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 16:19:41 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 85B2E1065677;
	Thu, 14 Apr 2011 16:19:41 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6A72B8FC27;
	Thu, 14 Apr 2011 16:19:41 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EGJf7K040030;
	Thu, 14 Apr 2011 16:19:41 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EGJfUh040027;
	Thu, 14 Apr 2011 16:19:41 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104141619.p3EGJfUh040027@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 14 Apr 2011 16:19:41 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220629 - in head/sys: amd64/include i386/include
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 16:19:41 -0000

Author: jkim
Date: Thu Apr 14 16:19:41 2011
New Revision: 220629
URL: http://svn.freebsd.org/changeset/base/220629

Log:
  Consistently use __volatile as the rest of this file.

Modified:
  head/sys/amd64/include/cpufunc.h
  head/sys/i386/include/cpufunc.h

Modified: head/sys/amd64/include/cpufunc.h
==============================================================================
--- head/sys/amd64/include/cpufunc.h	Thu Apr 14 16:14:35 2011	(r220628)
+++ head/sys/amd64/include/cpufunc.h	Thu Apr 14 16:19:41 2011	(r220629)
@@ -176,7 +176,7 @@ inb(u_int port)
 {
 	u_char	data;
 
-	__asm volatile("inb %w1, %0" : "=a" (data) : "Nd" (port));
+	__asm __volatile("inb %w1, %0" : "=a" (data) : "Nd" (port));
 	return (data);
 }
 
@@ -185,7 +185,7 @@ inl(u_int port)
 {
 	u_int	data;
 
-	__asm volatile("inl %w1, %0" : "=a" (data) : "Nd" (port));
+	__asm __volatile("inl %w1, %0" : "=a" (data) : "Nd" (port));
 	return (data);
 }
 
@@ -227,20 +227,20 @@ inw(u_int port)
 {
 	u_short	data;
 
-	__asm volatile("inw %w1, %0" : "=a" (data) : "Nd" (port));
+	__asm __volatile("inw %w1, %0" : "=a" (data) : "Nd" (port));
 	return (data);
 }
 
 static __inline void
 outb(u_int port, u_char data)
 {
-	__asm volatile("outb %0, %w1" : : "a" (data), "Nd" (port));
+	__asm __volatile("outb %0, %w1" : : "a" (data), "Nd" (port));
 }
 
 static __inline void
 outl(u_int port, u_int data)
 {
-	__asm volatile("outl %0, %w1" : : "a" (data), "Nd" (port));
+	__asm __volatile("outl %0, %w1" : : "a" (data), "Nd" (port));
 }
 
 static __inline void
@@ -270,7 +270,7 @@ outsl(u_int port, const void *addr, size
 static __inline void
 outw(u_int port, u_short data)
 {
-	__asm volatile("outw %0, %w1" : : "a" (data), "Nd" (port));
+	__asm __volatile("outw %0, %w1" : : "a" (data), "Nd" (port));
 }
 
 static __inline void

Modified: head/sys/i386/include/cpufunc.h
==============================================================================
--- head/sys/i386/include/cpufunc.h	Thu Apr 14 16:14:35 2011	(r220628)
+++ head/sys/i386/include/cpufunc.h	Thu Apr 14 16:19:41 2011	(r220629)
@@ -189,7 +189,7 @@ inb(u_int port)
 {
 	u_char	data;
 
-	__asm volatile("inb %w1, %0" : "=a" (data) : "Nd" (port));
+	__asm __volatile("inb %w1, %0" : "=a" (data) : "Nd" (port));
 	return (data);
 }
 
@@ -198,7 +198,7 @@ inl(u_int port)
 {
 	u_int	data;
 
-	__asm volatile("inl %w1, %0" : "=a" (data) : "Nd" (port));
+	__asm __volatile("inl %w1, %0" : "=a" (data) : "Nd" (port));
 	return (data);
 }
 
@@ -240,7 +240,7 @@ inw(u_int port)
 {
 	u_short	data;
 
-	__asm volatile("inw %w1, %0" : "=a" (data) : "Nd" (port));
+	__asm __volatile("inw %w1, %0" : "=a" (data) : "Nd" (port));
 	return (data);
 }
 
@@ -253,7 +253,7 @@ outb(u_int port, u_char data)
 static __inline void
 outl(u_int port, u_int data)
 {
-	__asm volatile("outl %0, %w1" : : "a" (data), "Nd" (port));
+	__asm __volatile("outl %0, %w1" : : "a" (data), "Nd" (port));
 }
 
 static __inline void
@@ -283,7 +283,7 @@ outsl(u_int port, const void *addr, size
 static __inline void
 outw(u_int port, u_short data)
 {
-	__asm volatile("outw %0, %w1" : : "a" (data), "Nd" (port));
+	__asm __volatile("outw %0, %w1" : : "a" (data), "Nd" (port));
 }
 
 static __inline void

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 16:45:16 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C4180106564A;
	Thu, 14 Apr 2011 16:45:16 +0000 (UTC) (envelope-from dim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B26878FC19;
	Thu, 14 Apr 2011 16:45:16 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EGjGE6040852;
	Thu, 14 Apr 2011 16:45:16 GMT (envelope-from dim@svn.freebsd.org)
Received: (from dim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EGjGrX040850;
	Thu, 14 Apr 2011 16:45:16 GMT (envelope-from dim@svn.freebsd.org)
Message-Id: <201104141645.p3EGjGrX040850@svn.freebsd.org>
From: Dimitry Andric 
Date: Thu, 14 Apr 2011 16:45:16 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220630 - head/gnu/usr.bin/cc/include
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 16:45:16 -0000

Author: dim
Date: Thu Apr 14 16:45:16 2011
New Revision: 220630
URL: http://svn.freebsd.org/changeset/base/220630

Log:
  In r219639, SSSE3 instruction set support was backported to our gcc.
  
  Therefore, we also need to install the new tmmintrin.h header containing
  the related intrinsic functions, similar to xmmintrin.h, emmintrin.h,
  etc.
  
  Reported by:	George Liaskos 

Modified:
  head/gnu/usr.bin/cc/include/Makefile

Modified: head/gnu/usr.bin/cc/include/Makefile
==============================================================================
--- head/gnu/usr.bin/cc/include/Makefile	Thu Apr 14 16:19:41 2011	(r220629)
+++ head/gnu/usr.bin/cc/include/Makefile	Thu Apr 14 16:45:16 2011	(r220630)
@@ -7,7 +7,7 @@ INCSDIR=${INCLUDEDIR}/gcc/${GCCVER}
 .PATH: ${GCCDIR}/config/${GCC_CPU}
 
 .if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64"
-INCS=	emmintrin.h mmintrin.h pmmintrin.h xmmintrin.h mm_malloc.h
+INCS=	emmintrin.h mmintrin.h pmmintrin.h tmmintrin.h xmmintrin.h mm_malloc.h
 .elif ${TARGET_ARCH} == "ia64"
 INCS=	ia64intrin.h
 .elif ${TARGET_ARCH} == "arm"

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 16:53:32 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6E992106566B;
	Thu, 14 Apr 2011 16:53:32 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5CF278FC13;
	Thu, 14 Apr 2011 16:53:32 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EGrWM3041067;
	Thu, 14 Apr 2011 16:53:32 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EGrWmv041064;
	Thu, 14 Apr 2011 16:53:32 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104141653.p3EGrWmv041064@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 14 Apr 2011 16:53:32 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220631 - in head/sys: amd64/include i386/include
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 16:53:32 -0000

Author: jkim
Date: Thu Apr 14 16:53:32 2011
New Revision: 220631
URL: http://svn.freebsd.org/changeset/base/220631

Log:
  Add a function rdtsc32() to read lower 32 bits from TSC and discard upper
  32 bits.  Some times compiler inserts unnecessary instructions to preserve
  unused upper 32 bits even when it is casted to a 32-bit value.  It reduces
  such compiler mistakes where every cycle counts.

Modified:
  head/sys/amd64/include/cpufunc.h
  head/sys/i386/include/cpufunc.h

Modified: head/sys/amd64/include/cpufunc.h
==============================================================================
--- head/sys/amd64/include/cpufunc.h	Thu Apr 14 16:45:16 2011	(r220630)
+++ head/sys/amd64/include/cpufunc.h	Thu Apr 14 16:53:32 2011	(r220631)
@@ -322,6 +322,15 @@ rdtsc(void)
 	return (low | ((uint64_t)high << 32));
 }
 
+static __inline uint32_t
+rdtsc32(void)
+{
+	uint32_t rv;
+
+	__asm __volatile("rdtsc" : "=a" (rv) : : "edx");
+	return (rv);
+}
+
 static __inline void
 wbinvd(void)
 {

Modified: head/sys/i386/include/cpufunc.h
==============================================================================
--- head/sys/i386/include/cpufunc.h	Thu Apr 14 16:45:16 2011	(r220630)
+++ head/sys/i386/include/cpufunc.h	Thu Apr 14 16:53:32 2011	(r220631)
@@ -332,6 +332,15 @@ rdtsc(void)
 	return (rv);
 }
 
+static __inline uint32_t
+rdtsc32(void)
+{
+	uint32_t rv;
+
+	__asm __volatile("rdtsc" : "=a" (rv) : : "edx");
+	return (rv);
+}
+
 static __inline void
 wbinvd(void)
 {

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 17:08:24 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2526B106564A;
	Thu, 14 Apr 2011 17:08:24 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1446E8FC0A;
	Thu, 14 Apr 2011 17:08:24 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EH8NiG041474;
	Thu, 14 Apr 2011 17:08:23 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EH8Nbt041472;
	Thu, 14 Apr 2011 17:08:23 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104141708.p3EH8Nbt041472@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 14 Apr 2011 17:08:23 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220632 - head/sys/x86/x86
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 17:08:24 -0000

Author: jkim
Date: Thu Apr 14 17:08:23 2011
New Revision: 220632
URL: http://svn.freebsd.org/changeset/base/220632

Log:
  Use newly added rdtsc32() for the timecounter_get_t method.

Modified:
  head/sys/x86/x86/tsc.c

Modified: head/sys/x86/x86/tsc.c
==============================================================================
--- head/sys/x86/x86/tsc.c	Thu Apr 14 16:53:32 2011	(r220631)
+++ head/sys/x86/x86/tsc.c	Thu Apr 14 17:08:23 2011	(r220632)
@@ -363,8 +363,9 @@ sysctl_machdep_tsc_freq(SYSCTL_HANDLER_A
 SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_U64 | CTLFLAG_RW,
     0, 0, sysctl_machdep_tsc_freq, "QU", "Time Stamp Counter frequency");
 
-static unsigned
+static u_int
 tsc_get_timecount(struct timecounter *tc)
 {
-	return (rdtsc());
+
+	return (rdtsc32());
 }

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 17:19:34 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3FEC3106564A;
	Thu, 14 Apr 2011 17:19:34 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2EE4E8FC08;
	Thu, 14 Apr 2011 17:19:34 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EHJYxE041754;
	Thu, 14 Apr 2011 17:19:34 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EHJYBr041750;
	Thu, 14 Apr 2011 17:19:34 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104141719.p3EHJYBr041750@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Thu, 14 Apr 2011 17:19:34 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220633 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 17:19:34 -0000

Author: bschmidt
Date: Thu Apr 14 17:19:33 2011
New Revision: 220633
URL: http://svn.freebsd.org/changeset/base/220633

Log:
  Remove IWN_FLAG_HAS_5GHZ and IWN_PCI_BAR0, both unused.

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnreg.h
  head/sys/dev/iwn/if_iwnvar.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Thu Apr 14 17:08:23 2011	(r220632)
+++ head/sys/dev/iwn/if_iwn.c	Thu Apr 14 17:19:33 2011	(r220633)
@@ -1792,7 +1792,6 @@ iwn_read_eeprom_band(struct iwn_softc *s
 			c->ic_freq = ieee80211_ieee2mhz(chan,
 			    IEEE80211_CHAN_A);
 			c->ic_flags = IEEE80211_CHAN_A | nflags;
-			sc->sc_flags |= IWN_FLAG_HAS_5GHZ;
 		}
 #if 0	/* HT */
 		/* XXX no constraints on using HT20 */

Modified: head/sys/dev/iwn/if_iwnreg.h
==============================================================================
--- head/sys/dev/iwn/if_iwnreg.h	Thu Apr 14 17:08:23 2011	(r220632)
+++ head/sys/dev/iwn/if_iwnreg.h	Thu Apr 14 17:19:33 2011	(r220633)
@@ -50,9 +50,6 @@
 #define IWN_HIADDR(paddr)	(0)
 #endif
 
-/* Base Address Register. */
-#define IWN_PCI_BAR0	PCI_MAPREG_START
-
 /*
  * Control and status registers.
  */

Modified: head/sys/dev/iwn/if_iwnvar.h
==============================================================================
--- head/sys/dev/iwn/if_iwnvar.h	Thu Apr 14 17:08:23 2011	(r220632)
+++ head/sys/dev/iwn/if_iwnvar.h	Thu Apr 14 17:19:33 2011	(r220633)
@@ -215,7 +215,6 @@ struct iwn_softc {
 	struct resource		*irq;
 
 	u_int			sc_flags;
-#define IWN_FLAG_HAS_5GHZ	(1 << 0)
 #define IWN_FLAG_HAS_OTPROM	(1 << 1)
 #define IWN_FLAG_CALIB_DONE	(1 << 2)
 #define IWN_FLAG_USE_ICT	(1 << 3)

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 17:20:54 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5BFDD106566B;
	Thu, 14 Apr 2011 17:20:54 +0000 (UTC) (envelope-from dim@FreeBSD.org)
Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net
	[IPv6:2001:7b8:2ff:146::2])
	by mx1.freebsd.org (Postfix) with ESMTP id 1C1DF8FC14;
	Thu, 14 Apr 2011 17:20:54 +0000 (UTC)
Received: from [IPv6:2001:7b8:3a7:0:dd48:486e:166b:644] (unknown
	[IPv6:2001:7b8:3a7:0:dd48:486e:166b:644])
	(using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
	(No client certificate requested)
	by tensor.andric.com (Postfix) with ESMTPSA id EE9995C59;
	Thu, 14 Apr 2011 19:20:52 +0200 (CEST)
Message-ID: <4DA72D08.3030805@FreeBSD.org>
Date: Thu, 14 Apr 2011 19:21:12 +0200
From: Dimitry Andric 
Organization: The FreeBSD Project
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;
	rv:1.9.2.16pre) Gecko/20110319 Lanikai/3.1.10pre
MIME-Version: 1.0
To: Jung-uk Kim 
References: <201104122349.p3CNn7kK039179@svn.freebsd.org>
	<4DA6D145.8070804@FreeBSD.org>
	<201104141044.55789.jkim@FreeBSD.org>
	<201104141106.40303.jkim@FreeBSD.org>
In-Reply-To: <201104141106.40303.jkim@FreeBSD.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220584 - in head/sys: amd64/amd64 i386/i386
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 17:20:54 -0000

On 2011-04-14 17:06, Jung-uk Kim wrote:
...
>> I am going to test APERF&  MPERF so that you don't need to do that
>> from there.  Please stay tuned.
>
> Can you please test the attached patch?

Yes, this works fine.  Please commit.

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 17:26:13 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 996791065677;
	Thu, 14 Apr 2011 17:26:13 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 885E18FC08;
	Thu, 14 Apr 2011 17:26:13 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EHQDmV041990;
	Thu, 14 Apr 2011 17:26:13 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EHQDwZ041988;
	Thu, 14 Apr 2011 17:26:13 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104141726.p3EHQDwZ041988@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Thu, 14 Apr 2011 17:26:13 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220634 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 17:26:13 -0000

Author: bschmidt
Date: Thu Apr 14 17:26:13 2011
New Revision: 220634
URL: http://svn.freebsd.org/changeset/base/220634

Log:
  Reuse net80211 code:
  - IWN_TXOP_TO_US is equal to IEEE80211_TXOP_TO_US
  - use IEEE80211_DUR_TU
  - ieee80211_add_rates/ieee80211_add_xrates are public, use em
  - copied ieee80211_add_ssid it is not public

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Thu Apr 14 17:19:33 2011	(r220633)
+++ head/sys/dev/iwn/if_iwn.c	Thu Apr 14 17:26:13 2011	(r220634)
@@ -198,6 +198,7 @@ static void	iwn_tune_sensitivity(struct 
 static int	iwn_send_sensitivity(struct iwn_softc *);
 static int	iwn_set_pslevel(struct iwn_softc *, int, int, int);
 static int	iwn_config(struct iwn_softc *);
+static uint8_t	*ieee80211_add_ssid(uint8_t *, const uint8_t *, u_int);
 static int	iwn_scan(struct iwn_softc *);
 static int	iwn_auth(struct iwn_softc *, struct ieee80211vap *vap);
 static int	iwn_run(struct iwn_softc *, struct ieee80211vap *vap);
@@ -3636,7 +3637,6 @@ static int
 iwn_wme_update(struct ieee80211com *ic)
 {
 #define IWN_EXP2(x)	((1 << (x)) - 1)	/* CWmin = 2^ECWmin - 1 */
-#define	IWN_TXOP_TO_US(v)		(v<<5)
 	struct iwn_softc *sc = ic->ic_ifp->if_softc;
 	struct iwn_edca_params cmd;
 	int i;
@@ -3650,7 +3650,7 @@ iwn_wme_update(struct ieee80211com *ic)
 		cmd.ac[i].cwmin = htole16(IWN_EXP2(wmep->wmep_logcwmin));
 		cmd.ac[i].cwmax = htole16(IWN_EXP2(wmep->wmep_logcwmax));
 		cmd.ac[i].txoplimit =
-		    htole16(IWN_TXOP_TO_US(wmep->wmep_txopLimit));
+		    htole16(IEEE80211_TXOP_TO_US(wmep->wmep_txopLimit));
 	}
 	IEEE80211_UNLOCK(ic);
 	IWN_LOCK(sc);
@@ -3658,7 +3658,6 @@ iwn_wme_update(struct ieee80211com *ic)
 	IWN_UNLOCK(sc);
 	IEEE80211_LOCK(ic);
 	return 0;
-#undef IWN_TXOP_TO_US
 #undef IWN_EXP2
 }
 
@@ -3720,7 +3719,7 @@ iwn_set_timing(struct iwn_softc *sc, str
 	cmd.lintval = htole16(10);
 
 	/* Compute remaining time until next beacon. */
-	val = (uint64_t)ni->ni_intval * 1024;	/* msecs -> usecs */
+	val = (uint64_t)ni->ni_intval * IEEE80211_DUR_TU;
 	mod = le64toh(cmd.tstamp) % val;
 	cmd.binitval = htole32((uint32_t)(val - mod));
 
@@ -4270,7 +4269,7 @@ iwn_tune_sensitivity(struct iwn_softc *s
 	/* Compute number of false alarms since last call for OFDM. */
 	fa  = le32toh(stats->ofdm.bad_plcp) - calib->bad_plcp_ofdm;
 	fa += le32toh(stats->ofdm.fa) - calib->fa_ofdm;
-	fa *= 200 * 1024;	/* 200TU */
+	fa *= 200 * IEEE80211_DUR_TU;	/* 200TU */
 
 	/* Save counters values for next call. */
 	calib->bad_plcp_ofdm = le32toh(stats->ofdm.bad_plcp);
@@ -4327,7 +4326,7 @@ iwn_tune_sensitivity(struct iwn_softc *s
 	/* Compute number of false alarms since last call for CCK. */
 	fa  = le32toh(stats->cck.bad_plcp) - calib->bad_plcp_cck;
 	fa += le32toh(stats->cck.fa) - calib->fa_cck;
-	fa *= 200 * 1024;	/* 200TU */
+	fa *= 200 * IEEE80211_DUR_TU;	/* 200TU */
 
 	/* Save counters values for next call. */
 	calib->bad_plcp_cck = le32toh(stats->cck.bad_plcp);
@@ -4586,6 +4585,18 @@ iwn_config(struct iwn_softc *sc)
 	return 0;
 }
 
+/*
+ * Add an ssid element to a frame.
+ */
+static uint8_t *
+ieee80211_add_ssid(uint8_t *frm, const uint8_t *ssid, u_int len)
+{
+	*frm++ = IEEE80211_ELEMID_SSID;
+	*frm++ = len;
+	memcpy(frm, ssid, len);
+	return frm + len;
+}
+
 static int
 iwn_scan(struct iwn_softc *sc)
 {
@@ -4599,7 +4610,7 @@ iwn_scan(struct iwn_softc *sc)
 	struct ieee80211_frame *wh;
 	struct ieee80211_rateset *rs;
 	struct ieee80211_channel *c;
-	int buflen, error, nrates;
+	int buflen, error;
 	uint16_t rxchain;
 	uint8_t *buf, *frm, txant;
 
@@ -4675,30 +4686,14 @@ iwn_scan(struct iwn_softc *sc)
 	*(uint16_t *)&wh->i_seq[0] = 0;	/* filled by HW */
 
 	frm = (uint8_t *)(wh + 1);
-
-	/* Add SSID IE. */
-	*frm++ = IEEE80211_ELEMID_SSID;
-	*frm++ = ss->ss_ssid[0].len;
-	memcpy(frm, ss->ss_ssid[0].ssid, ss->ss_ssid[0].len);
-	frm += ss->ss_ssid[0].len;
-
-	/* Add supported rates IE. */
-	*frm++ = IEEE80211_ELEMID_RATES;
-	nrates = rs->rs_nrates;
-	if (nrates > IEEE80211_RATE_SIZE)
-		nrates = IEEE80211_RATE_SIZE;
-	*frm++ = nrates;
-	memcpy(frm, rs->rs_rates, nrates);
-	frm += nrates;
-
-	/* Add supported xrates IE. */
-	if (rs->rs_nrates > IEEE80211_RATE_SIZE) {
-		nrates = rs->rs_nrates - IEEE80211_RATE_SIZE;
-		*frm++ = IEEE80211_ELEMID_XRATES;
-		*frm++ = (uint8_t)nrates;
-		memcpy(frm, rs->rs_rates + IEEE80211_RATE_SIZE, nrates);
-		frm += nrates;
-	}
+	frm = ieee80211_add_ssid(frm, NULL, 0);
+	frm = ieee80211_add_rates(frm, rs);
+	if (rs->rs_nrates > IEEE80211_RATE_SIZE)
+		frm = ieee80211_add_xrates(frm, rs);
+#if 0	/* HT */
+	if (ic->ic_flags & IEEE80211_F_HTON)
+		frm = ieee80211_add_htcaps(frm, ic);
+#endif
 
 	/* Set length of probe request. */
 	tx->len = htole16(frm - (uint8_t *)wh);

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 17:31:35 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1B334106566C;
	Thu, 14 Apr 2011 17:31:35 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0ACB18FC13;
	Thu, 14 Apr 2011 17:31:35 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EHVY4l042131;
	Thu, 14 Apr 2011 17:31:34 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EHVYGP042129;
	Thu, 14 Apr 2011 17:31:34 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104141731.p3EHVYGP042129@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Thu, 14 Apr 2011 17:31:34 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220635 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 17:31:35 -0000

Author: bschmidt
Date: Thu Apr 14 17:31:34 2011
New Revision: 220635
URL: http://svn.freebsd.org/changeset/base/220635

Log:
  iwn_cleanup() is just a wrapper around iwn_detach(), call it directly
  instead.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Thu Apr 14 17:26:13 2011	(r220634)
+++ head/sys/dev/iwn/if_iwn.c	Thu Apr 14 17:31:34 2011	(r220635)
@@ -81,7 +81,6 @@ static struct ieee80211vap *iwn_vap_crea
 		    int flags, const uint8_t bssid[IEEE80211_ADDR_LEN],
 		    const uint8_t mac[IEEE80211_ADDR_LEN]);
 static void	iwn_vap_delete(struct ieee80211vap *);
-static int	iwn_cleanup(device_t);
 static int	iwn_detach(device_t);
 static int	iwn_nic_lock(struct iwn_softc *);
 static int	iwn_eeprom_lock(struct iwn_softc *);
@@ -684,7 +683,7 @@ iwn_attach(device_t dev)
 	ieee80211_announce(ic);
 	return 0;
 fail:
-	iwn_cleanup(dev);
+	iwn_detach(dev);
 	return error;
 }
 
@@ -845,7 +844,7 @@ iwn_vap_delete(struct ieee80211vap *vap)
 }
 
 static int
-iwn_cleanup(device_t dev)
+iwn_detach(device_t dev)
 {
 	struct iwn_softc *sc = device_get_softc(dev);
 	struct ifnet *ifp = sc->sc_ifp;
@@ -895,13 +894,6 @@ iwn_cleanup(device_t dev)
 }
 
 static int
-iwn_detach(device_t dev)
-{
-	iwn_cleanup(dev);
-	return 0;
-}
-
-static int
 iwn_nic_lock(struct iwn_softc *sc)
 {
 	int ntries;

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 17:42:22 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2E2BB106564A;
	Thu, 14 Apr 2011 17:42:22 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1DC908FC08;
	Thu, 14 Apr 2011 17:42:22 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EHgM1G042405;
	Thu, 14 Apr 2011 17:42:22 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EHgL1h042403;
	Thu, 14 Apr 2011 17:42:21 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104141742.p3EHgL1h042403@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Thu, 14 Apr 2011 17:42:21 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220636 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 17:42:22 -0000

Author: bschmidt
Date: Thu Apr 14 17:42:21 2011
New Revision: 220636
URL: http://svn.freebsd.org/changeset/base/220636

Log:
  Instead of trying to figure out which rxon.flags to clear, restart
  from scratch. Remove htole16() calls, rxon.chan is an uint8_t,
  ieee80211_chan2ieee() does return an ic_ieee as an int, but I heavily
  doubt a htole16() will buy us anything here.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Thu Apr 14 17:31:34 2011	(r220635)
+++ head/sys/dev/iwn/if_iwn.c	Thu Apr 14 17:42:21 2011	(r220636)
@@ -4757,7 +4757,7 @@ iwn_auth(struct iwn_softc *sc, struct ie
 
 	/* Update adapter configuration. */
 	IEEE80211_ADDR_COPY(sc->rxon.bssid, ni->ni_bssid);
-	sc->rxon.chan = htole16(ieee80211_chan2ieee(ic, ni->ni_chan));
+	sc->rxon.chan = ieee80211_chan2ieee(ic, ni->ni_chan);
 	sc->rxon.flags = htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF);
 	if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan))
 		sc->rxon.flags |= htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ);
@@ -4843,15 +4843,11 @@ iwn_run(struct iwn_softc *sc, struct iee
 
 	/* Update adapter configuration. */
 	IEEE80211_ADDR_COPY(sc->rxon.bssid, ni->ni_bssid);
-	sc->rxon.chan = htole16(ieee80211_chan2ieee(ic, ni->ni_chan));
 	sc->rxon.associd = htole16(IEEE80211_AID(ni->ni_associd));
-	/* Short preamble and slot time are negotiated when associating. */
-	sc->rxon.flags &= ~htole32(IWN_RXON_SHPREAMBLE | IWN_RXON_SHSLOT);
-	sc->rxon.flags |= htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF);
+	sc->rxon.chan = ieee80211_chan2ieee(ic, ni->ni_chan);
+	sc->rxon.flags = htole32(IWN_RXON_TSF | IWN_RXON_CTS_TO_SELF);
 	if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan))
 		sc->rxon.flags |= htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ);
-	else
-		sc->rxon.flags &= ~htole32(IWN_RXON_AUTO | IWN_RXON_24GHZ);
 	if (ic->ic_flags & IEEE80211_F_SHSLOT)
 		sc->rxon.flags |= htole32(IWN_RXON_SHSLOT);
 	if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 17:50:26 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6F80F106566C;
	Thu, 14 Apr 2011 17:50:26 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 5FCF58FC17;
	Thu, 14 Apr 2011 17:50:26 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EHoQ7x042619;
	Thu, 14 Apr 2011 17:50:26 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EHoQbC042617;
	Thu, 14 Apr 2011 17:50:26 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104141750.p3EHoQbC042617@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 14 Apr 2011 17:50:26 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220637 - head/sys/x86/x86
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 17:50:26 -0000

Author: jkim
Date: Thu Apr 14 17:50:26 2011
New Revision: 220637
URL: http://svn.freebsd.org/changeset/base/220637

Log:
  Work around an emulator problem where virtual CPU advertises TSC is P-state
  invariant and APERF/MPERF MSRs exist but these MSRs never tick.  When we
  calculate effective frequency from cpu_est_clockrate(), it caused panic of
  division-by-zero.  Now we test whether these MSRs actually increase to avoid
  such foot-shooting.
  
  Reported by:	dim
  Tested by:	dim

Modified:
  head/sys/x86/x86/tsc.c

Modified: head/sys/x86/x86/tsc.c
==============================================================================
--- head/sys/x86/x86/tsc.c	Thu Apr 14 17:42:21 2011	(r220636)
+++ head/sys/x86/x86/tsc.c	Thu Apr 14 17:50:26 2011	(r220637)
@@ -183,8 +183,18 @@ probe_tsc_freq(void)
 
 	if (cpu_high >= 6) {
 		do_cpuid(6, regs);
-		if ((regs[2] & CPUID_PERF_STAT) != 0)
-			tsc_perf_stat = 1;
+		if ((regs[2] & CPUID_PERF_STAT) != 0) {
+			/*
+			 * XXX Some emulators expose host CPUID without actual
+			 * support for these MSRs.  We must test whether they
+			 * really work.
+			 */
+			wrmsr(MSR_MPERF, 0);
+			wrmsr(MSR_APERF, 0);
+			DELAY(10);
+			if (rdmsr(MSR_MPERF) > 0 && rdmsr(MSR_APERF) > 0)
+				tsc_perf_stat = 1;
+		}
 	}
 
 	if (tsc_skip_calibration) {

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 18:06:19 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by hub.freebsd.org (Postfix) with ESMTP id 4A3121065673;
	Thu, 14 Apr 2011 18:06:19 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
From: Jung-uk Kim 
To: src-committers@FreeBSD.org
Date: Thu, 14 Apr 2011 14:06:09 -0400
User-Agent: KMail/1.6.2
References: <201104141708.p3EH8Nbt041472@svn.freebsd.org>
In-Reply-To: <201104141708.p3EH8Nbt041472@svn.freebsd.org>
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Message-Id: <201104141406.12183.jkim@FreeBSD.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org
Subject: Re: svn commit: r220632 - head/sys/x86/x86
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 18:06:19 -0000

On Thursday 14 April 2011 01:08 pm, Jung-uk Kim wrote:
> Author: jkim
> Date: Thu Apr 14 17:08:23 2011
> New Revision: 220632
> URL: http://svn.freebsd.org/changeset/base/220632
>
> Log:
>   Use newly added rdtsc32() for the timecounter_get_t method.

It only seems to make big difference in amd64, probably because 
rdtsc() is implemented differently in inline asm.

tsc_get_timecount (before):
        pushq   %rbp
        movq    %rsp, %rbp
        rdtsc
        mov     %eax, %eax
        salq    $32, %rdx
        leave
        orq     %rax, %rdx
        movl    %edx, %eax
        ret

tsc_get_timecount (after):
        pushq   %rbp
        movq    %rsp, %rbp
        rdtsc
        leave
        ret

Similar problem was also observed when it is inlined.

BTW, clang does not have this issue. :-)

Jung-uk Kim

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 18:14:43 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EAEE41065676;
	Thu, 14 Apr 2011 18:14:43 +0000 (UTC)
	(envelope-from andreast@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DAF568FC14;
	Thu, 14 Apr 2011 18:14:43 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EIEhS0043231;
	Thu, 14 Apr 2011 18:14:43 GMT
	(envelope-from andreast@svn.freebsd.org)
Received: (from andreast@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EIEh6O043229;
	Thu, 14 Apr 2011 18:14:43 GMT
	(envelope-from andreast@svn.freebsd.org)
Message-Id: <201104141814.p3EIEh6O043229@svn.freebsd.org>
From: Andreas Tobler 
Date: Thu, 14 Apr 2011 18:14:43 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220638 - head/sys/powerpc/powerpc
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 18:14:44 -0000

Author: andreast
Date: Thu Apr 14 18:14:43 2011
New Revision: 220638
URL: http://svn.freebsd.org/changeset/base/220638

Log:
  Add stoppcbs[] arrays on powerpc(64) and have each CPU save its
  current context in the IPI_STOP handler. Similar as done on other
  architectures.
  
  Approved by: nwhitehorn (mentor)

Modified:
  head/sys/powerpc/powerpc/mp_machdep.c

Modified: head/sys/powerpc/powerpc/mp_machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/mp_machdep.c	Thu Apr 14 17:50:26 2011	(r220637)
+++ head/sys/powerpc/powerpc/mp_machdep.c	Thu Apr 14 18:14:43 2011	(r220638)
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -62,6 +63,7 @@ volatile static u_int ap_letgo;
 volatile static u_quad_t ap_timebase;
 static u_int ipi_msg_cnt[32];
 static struct mtx ap_boot_mtx;
+struct pcb stoppcbs[MAXCPU];
 
 void
 machdep_ap_bootstrap(void)
@@ -306,6 +308,7 @@ powerpc_ipi_handler(void *arg)
 			 */
 			CTR1(KTR_SMP, "%s: IPI_STOP or IPI_STOP_HARD (stop)",
 			    __func__);
+			savectx(&stoppcbs[PCPU_GET(cpuid)]);
 			self = PCPU_GET(cpumask);
 			savectx(PCPU_GET(curpcb));
 			atomic_set_int(&stopped_cpus, self);

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 18:26:51 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1A6DB106566B;
	Thu, 14 Apr 2011 18:26:51 +0000 (UTC)
	(envelope-from andreast@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 097318FC0C;
	Thu, 14 Apr 2011 18:26:51 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EIQoXL043552;
	Thu, 14 Apr 2011 18:26:50 GMT
	(envelope-from andreast@svn.freebsd.org)
Received: (from andreast@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EIQoHO043549;
	Thu, 14 Apr 2011 18:26:50 GMT
	(envelope-from andreast@svn.freebsd.org)
Message-Id: <201104141826.p3EIQoHO043549@svn.freebsd.org>
From: Andreas Tobler 
Date: Thu, 14 Apr 2011 18:26:50 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220639 - head/sys/powerpc/aim
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 18:26:51 -0000

Author: andreast
Date: Thu Apr 14 18:26:50 2011
New Revision: 220639
URL: http://svn.freebsd.org/changeset/base/220639

Log:
  The macro MOEA_PVO_CHECK is empty and not used. It is a left over from the
  NetBSD import. Remove the definition and all its occurrences.
  
  Approved by: nwhitehorn (mentor)

Modified:
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea.c	Thu Apr 14 18:14:43 2011	(r220638)
+++ head/sys/powerpc/aim/mmu_oea.c	Thu Apr 14 18:26:50 2011	(r220639)
@@ -161,8 +161,6 @@ __FBSDID("$FreeBSD$");
 #define	VSID_TO_SR(vsid)	((vsid) & 0xf)
 #define	VSID_TO_HASH(vsid)	(((vsid) >> 4) & 0xfffff)
 
-#define	MOEA_PVO_CHECK(pvo)
-
 struct ofw_map {
 	vm_offset_t	om_va;
 	vm_size_t	om_len;
@@ -1809,7 +1807,6 @@ moea_remove_all(mmu_t mmu, vm_page_t m)
 	for (pvo = LIST_FIRST(pvo_head); pvo != NULL; pvo = next_pvo) {
 		next_pvo = LIST_NEXT(pvo, pvo_vlink);
 
-		MOEA_PVO_CHECK(pvo);	/* sanity check */
 		pmap = pvo->pvo_pmap;
 		PMAP_LOCK(pmap);
 		moea_pvo_remove(pvo, -1);
@@ -2163,7 +2160,6 @@ moea_pte_spill(vm_offset_t addr)
 		/*
 		 * We need to find a pvo entry for this address.
 		 */
-		MOEA_PVO_CHECK(pvo);
 		if (source_pvo == NULL &&
 		    moea_pte_match(&pvo->pvo_pte.pte, sr, addr,
 		    pvo->pvo_pte.pte.pte_hi & PTE_HID)) {
@@ -2176,7 +2172,6 @@ moea_pte_spill(vm_offset_t addr)
 			if (j >= 0) {
 				PVO_PTEGIDX_SET(pvo, j);
 				moea_pte_overflow--;
-				MOEA_PVO_CHECK(pvo);
 				mtx_unlock(&moea_table_mutex);
 				return (1);
 			}
@@ -2215,7 +2210,6 @@ moea_pte_spill(vm_offset_t addr)
 		 */
 		LIST_FOREACH(pvo, &moea_pvo_table[ptegidx ^ moea_pteg_mask],
 		    pvo_olink) {
-			MOEA_PVO_CHECK(pvo);
 			/*
 			 * We also need the pvo entry of the victim we are
 			 * replacing so save the R & C bits of the PTE.
@@ -2245,9 +2239,6 @@ moea_pte_spill(vm_offset_t addr)
 	PVO_PTEGIDX_SET(source_pvo, i);
 	moea_pte_replacements++;
 
-	MOEA_PVO_CHECK(victim_pvo);
-	MOEA_PVO_CHECK(source_pvo);
-
 	mtx_unlock(&moea_table_mutex);
 	return (1);
 }
@@ -2299,7 +2290,6 @@ moea_query_bit(vm_page_t m, int ptebit)
 
 	vm_page_lock_queues();
 	LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) {
-		MOEA_PVO_CHECK(pvo);	/* sanity check */
 
 		/*
 		 * See if we saved the bit off.  If so, cache it and return
@@ -2307,7 +2297,6 @@ moea_query_bit(vm_page_t m, int ptebit)
 		 */
 		if (pvo->pvo_pte.pte.pte_lo & ptebit) {
 			moea_attr_save(m, ptebit);
-			MOEA_PVO_CHECK(pvo);	/* sanity check */
 			vm_page_unlock_queues();
 			return (TRUE);
 		}
@@ -2320,7 +2309,6 @@ moea_query_bit(vm_page_t m, int ptebit)
 	 */
 	powerpc_sync();
 	LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) {
-		MOEA_PVO_CHECK(pvo);	/* sanity check */
 
 		/*
 		 * See if this pvo has a valid PTE.  if so, fetch the
@@ -2333,7 +2321,6 @@ moea_query_bit(vm_page_t m, int ptebit)
 			mtx_unlock(&moea_table_mutex);
 			if (pvo->pvo_pte.pte.pte_lo & ptebit) {
 				moea_attr_save(m, ptebit);
-				MOEA_PVO_CHECK(pvo);	/* sanity check */
 				vm_page_unlock_queues();
 				return (TRUE);
 			}
@@ -2373,7 +2360,6 @@ moea_clear_bit(vm_page_t m, int ptebit)
 	 */
 	count = 0;
 	LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) {
-		MOEA_PVO_CHECK(pvo);	/* sanity check */
 		pt = moea_pvo_to_pte(pvo, -1);
 		if (pt != NULL) {
 			moea_pte_synch(pt, &pvo->pvo_pte.pte);
@@ -2384,7 +2370,6 @@ moea_clear_bit(vm_page_t m, int ptebit)
 			mtx_unlock(&moea_table_mutex);
 		}
 		pvo->pvo_pte.pte.pte_lo &= ~ptebit;
-		MOEA_PVO_CHECK(pvo);	/* sanity check */
 	}
 
 	vm_page_unlock_queues();

Modified: head/sys/powerpc/aim/mmu_oea64.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea64.c	Thu Apr 14 18:14:43 2011	(r220638)
+++ head/sys/powerpc/aim/mmu_oea64.c	Thu Apr 14 18:26:50 2011	(r220639)
@@ -169,8 +169,6 @@ uintptr_t moea64_get_unique_vsid(void); 
 #define	VSID_TO_HASH(vsid)	(((vsid) >> 4) & 0xfffff)
 #define	VSID_HASH_MASK		0x0000007fffffffffULL
 
-#define	MOEA_PVO_CHECK(pvo)
-
 #define LOCK_TABLE() mtx_lock(&moea64_table_mutex)
 #define UNLOCK_TABLE() mtx_unlock(&moea64_table_mutex);
 #define ASSERT_TABLE_LOCK() mtx_assert(&moea64_table_mutex, MA_OWNED)
@@ -2084,7 +2082,6 @@ moea64_remove_all(mmu_t mmu, vm_page_t m
 	for (pvo = LIST_FIRST(pvo_head); pvo != NULL; pvo = next_pvo) {
 		next_pvo = LIST_NEXT(pvo, pvo_vlink);
 
-		MOEA_PVO_CHECK(pvo);	/* sanity check */
 		pmap = pvo->pvo_pmap;
 		PMAP_LOCK(pmap);
 		moea64_pvo_remove(mmu, pvo);
@@ -2413,7 +2410,6 @@ moea64_query_bit(mmu_t mmu, vm_page_t m,
 	vm_page_lock_queues();
 
 	LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) {
-		MOEA_PVO_CHECK(pvo);	/* sanity check */
 
 		/*
 		 * See if we saved the bit off.  If so, cache it and return
@@ -2421,7 +2417,6 @@ moea64_query_bit(mmu_t mmu, vm_page_t m,
 		 */
 		if (pvo->pvo_pte.lpte.pte_lo & ptebit) {
 			moea64_attr_save(m, ptebit);
-			MOEA_PVO_CHECK(pvo);	/* sanity check */
 			vm_page_unlock_queues();
 			return (TRUE);
 		}
@@ -2434,7 +2429,6 @@ moea64_query_bit(mmu_t mmu, vm_page_t m,
 	 */
 	powerpc_sync();
 	LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) {
-		MOEA_PVO_CHECK(pvo);	/* sanity check */
 
 		/*
 		 * See if this pvo has a valid PTE.  if so, fetch the
@@ -2449,7 +2443,6 @@ moea64_query_bit(mmu_t mmu, vm_page_t m,
 				UNLOCK_TABLE();
 
 				moea64_attr_save(m, ptebit);
-				MOEA_PVO_CHECK(pvo);	/* sanity check */
 				vm_page_unlock_queues();
 				return (TRUE);
 			}
@@ -2490,7 +2483,6 @@ moea64_clear_bit(mmu_t mmu, vm_page_t m,
 	 */
 	count = 0;
 	LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) {
-		MOEA_PVO_CHECK(pvo);	/* sanity check */
 
 		LOCK_TABLE();
 		pt = MOEA64_PVO_TO_PTE(mmu, pvo);
@@ -2503,7 +2495,6 @@ moea64_clear_bit(mmu_t mmu, vm_page_t m,
 			}
 		}
 		pvo->pvo_pte.lpte.pte_lo &= ~ptebit;
-		MOEA_PVO_CHECK(pvo);	/* sanity check */
 		UNLOCK_TABLE();
 	}
 

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 18:37:27 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 86DB9106566C;
	Thu, 14 Apr 2011 18:37:27 +0000 (UTC)
	(envelope-from trasz@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 752188FC17;
	Thu, 14 Apr 2011 18:37:27 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EIbRLB043876;
	Thu, 14 Apr 2011 18:37:27 GMT (envelope-from trasz@svn.freebsd.org)
Received: (from trasz@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EIbRfS043872;
	Thu, 14 Apr 2011 18:37:27 GMT (envelope-from trasz@svn.freebsd.org)
Message-Id: <201104141837.p3EIbRfS043872@svn.freebsd.org>
From: Edward Tomasz Napierala 
Date: Thu, 14 Apr 2011 18:37:27 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220640 - in head: share/man/man5 usr.bin/rctl
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 18:37:27 -0000

Author: trasz
Date: Thu Apr 14 18:37:27 2011
New Revision: 220640
URL: http://svn.freebsd.org/changeset/base/220640

Log:
  Add manual page for rctl.conf(5).

Added:
  head/share/man/man5/rctl.conf.5   (contents, props changed)
Modified:
  head/share/man/man5/Makefile
  head/usr.bin/rctl/rctl.8

Modified: head/share/man/man5/Makefile
==============================================================================
--- head/share/man/man5/Makefile	Thu Apr 14 18:26:50 2011	(r220639)
+++ head/share/man/man5/Makefile	Thu Apr 14 18:37:27 2011	(r220640)
@@ -57,6 +57,7 @@ MAN=	acct.5 \
 	protocols.5 \
 	quota.user.5 \
 	rc.conf.5 \
+	rctl.conf.5 \
 	regdomain.5 \
 	reiserfs.5 \
 	remote.5 \

Added: head/share/man/man5/rctl.conf.5
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/share/man/man5/rctl.conf.5	Thu Apr 14 18:37:27 2011	(r220640)
@@ -0,0 +1,74 @@
+.\" Copyright (c) 2011 Edward Tomasz Napierala
+.\" Copyright (c) 1999 Chris Costello 
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (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$
+.\"
+.Dd April 14, 2011
+.Dt RCTL.CONF 5
+.Os
+.Sh NAME
+.Nm rctl.conf
+.Nd resource limits database defaults
+.Sh DESCRIPTION
+The
+.Pa /etc/rctl.conf
+file is read in when the system goes into multi-user mode to set default
+contents of the RCTL database.
+The
+.Pa /etc/rctl.conf
+is in the format of the
+.Xr rctl 8
+command, i.e.\&
+.Bd -literal -offset indent
+subject:subject-id:resource:action=amount/per
+.Ed
+.Pp
+Comments are denoted by a
+.Dq #
+at the beginning of a line.
+Comments can also exist at the end of a line,
+as seen in the
+.Sx EXAMPLES
+section, below.
+.Sh FILES
+.Bl -tag -width /etc/rctl.conf -compact
+.It Pa /etc/rctl.conf
+Initial settings for
+.Xr rctl 8 .
+.El
+.Sh EXAMPLES
+To limit the number of processes for users in login class "testing",
+use a rule like
+.Bd -literal -offset indent
+# Resource limits for the "testing" class.
+loginclass:testing:nproc:deny=100/user # At most 100 processes per user
+.Ed
+.Sh SEE ALSO
+.Xr rctl 8
+.Sh HISTORY
+The
+.Nm
+file appeared in
+.Fx 9.0 .

Modified: head/usr.bin/rctl/rctl.8
==============================================================================
--- head/usr.bin/rctl/rctl.8	Thu Apr 14 18:26:50 2011	(r220639)
+++ head/usr.bin/rctl/rctl.8	Thu Apr 14 18:37:27 2011	(r220640)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 30, 2011
+.Dd April 14, 2011
 .Dt RCTL 8
 .Os
 .Sh NAME
@@ -185,6 +185,7 @@ Display resource usage information for j
 .Pp
 Display all the rules applicable to process with PID 512.
 .Sh SEE ALSO
+.Xr rctl.conf 5 ,
 .Xr jailstat 8 ,
 .Xr userstat 8
 .Sh HISTORY

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 19:11:46 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0B0A0106566B;
	Thu, 14 Apr 2011 19:11:46 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D39CD8FC14;
	Thu, 14 Apr 2011 19:11:45 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EJBjT8044697;
	Thu, 14 Apr 2011 19:11:45 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EJBjPo044695;
	Thu, 14 Apr 2011 19:11:45 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104141911.p3EJBjPo044695@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 14 Apr 2011 19:11:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220641 - head/sys/x86/isa
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 19:11:46 -0000

Author: jkim
Date: Thu Apr 14 19:11:45 2011
New Revision: 220641
URL: http://svn.freebsd.org/changeset/base/220641

Log:
  Use newly added rdtsc32() for DELAY(9) as well.

Modified:
  head/sys/x86/isa/clock.c

Modified: head/sys/x86/isa/clock.c
==============================================================================
--- head/sys/x86/isa/clock.c	Thu Apr 14 18:37:27 2011	(r220640)
+++ head/sys/x86/isa/clock.c	Thu Apr 14 19:11:45 2011	(r220641)
@@ -250,7 +250,7 @@ static u_int
 get_tsc(__unused struct timecounter *tc)
 {
 
-	return (rdtsc());
+	return (rdtsc32());
 }
 
 static __inline int

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 19:37:31 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D6EBB106566C;
	Thu, 14 Apr 2011 19:37:31 +0000 (UTC)
	(envelope-from andreast@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C50768FC1B;
	Thu, 14 Apr 2011 19:37:31 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EJbVRi045327;
	Thu, 14 Apr 2011 19:37:31 GMT
	(envelope-from andreast@svn.freebsd.org)
Received: (from andreast@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EJbVu9045325;
	Thu, 14 Apr 2011 19:37:31 GMT
	(envelope-from andreast@svn.freebsd.org)
Message-Id: <201104141937.p3EJbVu9045325@svn.freebsd.org>
From: Andreas Tobler 
Date: Thu, 14 Apr 2011 19:37:31 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220642 - head/sys/powerpc/aim
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 19:37:31 -0000

Author: andreast
Date: Thu Apr 14 19:37:31 2011
New Revision: 220642
URL: http://svn.freebsd.org/changeset/base/220642

Log:
  Adjust debugging string to match the actual function.
  
  Approved by: nwhitehorn (mentor)

Modified:
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea64.c	Thu Apr 14 19:11:45 2011	(r220641)
+++ head/sys/powerpc/aim/mmu_oea64.c	Thu Apr 14 19:37:31 2011	(r220642)
@@ -936,7 +936,7 @@ moea64_late_bootstrap(mmu_t mmup, vm_off
 	pa = moea64_bootstrap_alloc(KSTACK_PAGES * PAGE_SIZE, PAGE_SIZE);
 	va = virtual_avail + KSTACK_GUARD_PAGES * PAGE_SIZE;
 	virtual_avail = va + KSTACK_PAGES * PAGE_SIZE;
-	CTR2(KTR_PMAP, "moea_bootstrap: kstack0 at %#x (%#x)", pa, va);
+	CTR2(KTR_PMAP, "moea64_bootstrap: kstack0 at %#x (%#x)", pa, va);
 	thread0.td_kstack = va;
 	thread0.td_kstack_pages = KSTACK_PAGES;
 	for (i = 0; i < KSTACK_PAGES; i++) {

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 20:06:23 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BD8A6106566C;
	Thu, 14 Apr 2011 20:06:23 +0000 (UTC) (envelope-from np@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id ABC528FC16;
	Thu, 14 Apr 2011 20:06:23 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EK6NwI046001;
	Thu, 14 Apr 2011 20:06:23 GMT (envelope-from np@svn.freebsd.org)
Received: (from np@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EK6NXe045997;
	Thu, 14 Apr 2011 20:06:23 GMT (envelope-from np@svn.freebsd.org)
Message-Id: <201104142006.p3EK6NXe045997@svn.freebsd.org>
From: Navdeep Parhar 
Date: Thu, 14 Apr 2011 20:06:23 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220643 - head/sys/dev/cxgbe
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 20:06:23 -0000

Author: np
Date: Thu Apr 14 20:06:23 2011
New Revision: 220643
URL: http://svn.freebsd.org/changeset/base/220643

Log:
  There is no need to request a tx credit flush if such a request is already
  pending.
  
  MFC after:	3 days

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/adapter.h
==============================================================================
--- head/sys/dev/cxgbe/adapter.h	Thu Apr 14 19:37:31 2011	(r220642)
+++ head/sys/dev/cxgbe/adapter.h	Thu Apr 14 20:06:23 2011	(r220643)
@@ -260,7 +260,7 @@ enum {
 	/* eq flags */
 	EQ_ALLOCATED	= (1 << 1),	/* firmware resources allocated */
 	EQ_STARTED	= (1 << 2),	/* started */
-	EQ_STALLED	= (1 << 3),	/* currently stalled */
+	EQ_CRFLUSHED	= (1 << 3),	/* expecting an update from SGE */
 };
 
 /*

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c	Thu Apr 14 19:37:31 2011	(r220642)
+++ head/sys/dev/cxgbe/t4_main.c	Thu Apr 14 20:06:23 2011	(r220643)
@@ -2673,6 +2673,7 @@ cxgbe_txq_start(void *arg, int count)
 	struct sge_txq *txq = arg;
 
 	TXQ_LOCK(txq);
+	txq->eq.flags &= ~EQ_CRFLUSHED;
 	txq_start(txq->ifp, txq);
 	TXQ_UNLOCK(txq);
 }

Modified: head/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- head/sys/dev/cxgbe/t4_sge.c	Thu Apr 14 19:37:31 2011	(r220642)
+++ head/sys/dev/cxgbe/t4_sge.c	Thu Apr 14 20:06:23 2011	(r220643)
@@ -876,7 +876,7 @@ doorbell:
 	 * WR that reduced it to 0 so we don't need another flush (we don't have
 	 * any descriptor for a flush WR anyway, duh).
 	 */
-	if (m && eq->avail > 0)
+	if (m && eq->avail > 0 && !(eq->flags & EQ_CRFLUSHED))
 		write_eqflush_wr(eq);
 	txq->m = m;
 
@@ -1882,8 +1882,11 @@ write_txpkt_wr(struct port_info *pi, str
 	wr->op_immdlen = htobe32(V_FW_WR_OP(FW_ETH_TX_PKT_WR) |
 	    V_FW_WR_IMMDLEN(ctrl));
 	ctrl = V_FW_WR_LEN16(howmany(nflits, 2));
-	if (eq->avail == ndesc)
+	if (eq->avail == ndesc && !(eq->flags & EQ_CRFLUSHED)) {
 		ctrl |= F_FW_WR_EQUEQ | F_FW_WR_EQUIQ;
+		eq->flags |= EQ_CRFLUSHED;
+	}
+
 	wr->equiq_to_len16 = htobe32(ctrl);
 	wr->r3 = 0;
 
@@ -2071,8 +2074,10 @@ write_txpkts_wr(struct sge_txq *txq, str
 	wr->op_immdlen = htobe32(V_FW_WR_OP(FW_ETH_TX_PKTS_WR) |
 	    V_FW_WR_IMMDLEN(0)); /* immdlen does not matter in this WR */
 	ctrl = V_FW_WR_LEN16(howmany(txpkts->nflits, 2));
-	if (eq->avail == ndesc)
+	if (eq->avail == ndesc && !(eq->flags & EQ_CRFLUSHED)) {
 		ctrl |= F_FW_WR_EQUEQ | F_FW_WR_EQUIQ;
+		eq->flags |= EQ_CRFLUSHED;
+	}
 	wr->equiq_to_len16 = htobe32(ctrl);
 	wr->plen = htobe16(txpkts->plen);
 	wr->npkt = txpkts->npkt;
@@ -2083,7 +2088,7 @@ write_txpkts_wr(struct sge_txq *txq, str
 	txsd = &eq->sdesc[eq->pidx];
 	txsd->desc_used = ndesc;
 
-	KASSERT(eq->avail >= ndesc, ("%s: out ouf descriptors", __func__));
+	KASSERT(eq->avail >= ndesc, ("%s: out of descriptors", __func__));
 
 	eq->pending += ndesc;
 	eq->avail -= ndesc;
@@ -2384,6 +2389,7 @@ write_eqflush_wr(struct sge_eq *eq)
 	txsd->desc_used = 1;
 	txsd->map_used = 0;
 
+	eq->flags |= EQ_CRFLUSHED;
 	eq->pending++;
 	eq->avail--;
 	if (++eq->pidx == eq->cap)
@@ -2438,6 +2444,10 @@ handle_sge_egr_update(struct adapter *sc
 	struct port_info *pi;
 
 	txq = (void *)s->eqmap[qid - s->eq_start];
+
+	KASSERT(txq->eq.flags & EQ_CRFLUSHED,
+	    ("%s: tx queue %p not expecting an update.", __func__, txq));
+
 	pi = txq->ifp->if_softc;
 	taskqueue_enqueue(pi->tq, &txq->resume_tx);
 	txq->egr_update++;

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 20:10:32 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 653F91065674;
	Thu, 14 Apr 2011 20:10:32 +0000 (UTC)
	(envelope-from mavbsd@gmail.com)
Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com
	[209.85.161.54])
	by mx1.freebsd.org (Postfix) with ESMTP id 24AFC8FC21;
	Thu, 14 Apr 2011 20:10:30 +0000 (UTC)
Received: by fxm11 with SMTP id 11so1945710fxm.13
	for ; Thu, 14 Apr 2011 13:10:30 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:sender:message-id:date:from:user-agent
	:mime-version:to:cc:subject:references:in-reply-to:content-type
	:content-transfer-encoding;
	bh=y1bSUjHm0AC4clPcEOSmIp2RqmSdUjuHCBtlEzgqGLc=;
	b=szR3v/0/FRru4j9pavDNjeJrfreNZraCSJDq390dmOrZwodRj4tG46YF86RAhhzvD4
	vCmuebbY/bI+d1BuJQbN/zZtOHg2U34QPbnvLdMzT3urPN5ANk3LX0AURmhDLqvyzfML
	Agfls1PMUCWRXyCpFQ7fest7N7/t904PquQcU=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject
	:references:in-reply-to:content-type:content-transfer-encoding;
	b=AaAbnYuSin+llMHePh9SD398zV+z0BRjuBAyLnErK11xyu1IIao86NMYgF3xrVwtJu
	8uYnvdC4OtHNVAiKLwVlygUgbvHBwW6u+OtihD4j3xnA9YBNd159+i+4TAakRfQBdHTI
	wi95EDescezM0hQtN4PNmlpzcnUdbpwEwWepQ=
Received: by 10.223.35.147 with SMTP id p19mr1297424fad.13.1302811830033;
	Thu, 14 Apr 2011 13:10:30 -0700 (PDT)
Received: from mavbook.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226])
	by mx.google.com with ESMTPS id o17sm599988fal.25.2011.04.14.13.10.28
	(version=SSLv3 cipher=OTHER); Thu, 14 Apr 2011 13:10:29 -0700 (PDT)
Sender: Alexander Motin 
Message-ID: <4DA754B2.6070802@FreeBSD.org>
Date: Thu, 14 Apr 2011 23:10:26 +0300
From: Alexander Motin 
User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US;
	rv:1.9.2.15) Gecko/20110310 Thunderbird/3.1.9
MIME-Version: 1.0
To: Jaakko Heinonen 
References: <201104140911.p3E9BooX027074@svn.freebsd.org>
	<20110414160059.GA1644@a91-153-123-205.elisa-laajakaista.fi>
In-Reply-To: <20110414160059.GA1644@a91-153-123-205.elisa-laajakaista.fi>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220618 - head/sys/cam/ata
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 20:10:32 -0000

On 14.04.2011 19:00, Jaakko Heinonen wrote:
> On 2011-04-14, Alexander Motin wrote:
>>    Fix typo in write_cache tunable name and move TUNABLE_INT_FETCH() out of
>>    the SIM lock to fix WITNESS warning.
>
> Thanks!
>
> Does this analogous patch for cd(4) and da(4) look good?

Looks fine.

> I am not
> completely sure if it's safe to move setting of minimum_cmd_size in
> daregister().

I see no problem. dastart() in NORMAL state, that using it, won't be 
called until device created (to be opened) and hold will not be dropped.

> ---
>
> Move TUNABLE_INT_FETCH() out of the SIM lock to avoid sleeping while
> holding the lock. The fix is analogous to r220618 for ada(4).
>
> %%%
> Index: sys/cam/scsi/scsi_cd.c
> ===================================================================
> --- sys/cam/scsi/scsi_cd.c	(revision 220619)
> +++ sys/cam/scsi/scsi_cd.c	(working copy)
> @@ -687,6 +687,8 @@ cdregister(struct cam_periph *periph, vo
>   	else
>   		softc->minimum_command_size = 6;
>
> +	(void)cam_periph_hold(periph, PRIBIO);
> +	cam_periph_unlock(periph);
>   	/*
>   	 * Load the user's default, if any.
>   	 */
> @@ -712,7 +714,6 @@ cdregister(struct cam_periph *periph, vo
>   	 * WORM peripheral driver.  WORM drives will also have the WORM
>   	 * driver attached to them.
>   	 */
> -	cam_periph_unlock(periph);
>   	softc->disk = disk_alloc();
>   	softc->disk->d_devstat = devstat_new_entry("cd",
>   			  periph->unit_number, 0,
> @@ -745,6 +746,7 @@ cdregister(struct cam_periph *periph, vo
>   	softc->disk->d_hba_subdevice = cpi.hba_subdevice;
>   	disk_create(softc->disk, DISK_VERSION);
>   	cam_periph_lock(periph);
> +	cam_periph_unhold(periph);
>
>   	/*
>   	 * Add an async callback so that we get
> Index: sys/cam/scsi/scsi_da.c
> ===================================================================
> --- sys/cam/scsi/scsi_da.c	(revision 220619)
> +++ sys/cam/scsi/scsi_da.c	(working copy)
> @@ -1231,35 +1231,6 @@ daregister(struct cam_periph *periph, vo
>   	TASK_INIT(&softc->sysctl_task, 0, dasysctlinit, periph);
>
>   	/*
> -	 * RBC devices don't have to support READ(6), only READ(10).
> -	 */
> -	if (softc->quirks&  DA_Q_NO_6_BYTE || SID_TYPE(&cgd->inq_data) == T_RBC)
> -		softc->minimum_cmd_size = 10;
> -	else
> -		softc->minimum_cmd_size = 6;
> -
> -	/*
> -	 * Load the user's default, if any.
> -	 */
> -	snprintf(tmpstr, sizeof(tmpstr), "kern.cam.da.%d.minimum_cmd_size",
> -		 periph->unit_number);
> -	TUNABLE_INT_FETCH(tmpstr,&softc->minimum_cmd_size);
> -
> -	/*
> -	 * 6, 10, 12 and 16 are the currently permissible values.
> -	 */
> -	if (softc->minimum_cmd_size<  6)
> -		softc->minimum_cmd_size = 6;
> -	else if ((softc->minimum_cmd_size>  6)
> -	&&  (softc->minimum_cmd_size<= 10))
> -		softc->minimum_cmd_size = 10;
> -	else if ((softc->minimum_cmd_size>  10)
> -	&&  (softc->minimum_cmd_size<= 12))
> -		softc->minimum_cmd_size = 12;
> -	else if (softc->minimum_cmd_size>  12)
> -		softc->minimum_cmd_size = 16;
> -
> -	/*
>   	 * Register this media as a disk
>   	 */
>
> @@ -1291,6 +1262,35 @@ daregister(struct cam_periph *periph, vo
>   	    dasendorderedtag, softc);
>
>   	mtx_unlock(periph->sim->mtx);
> +	/*
> +	 * RBC devices don't have to support READ(6), only READ(10).
> +	 */
> +	if (softc->quirks&  DA_Q_NO_6_BYTE || SID_TYPE(&cgd->inq_data) == T_RBC)
> +		softc->minimum_cmd_size = 10;
> +	else
> +		softc->minimum_cmd_size = 6;
> +
> +	/*
> +	 * Load the user's default, if any.
> +	 */
> +	snprintf(tmpstr, sizeof(tmpstr), "kern.cam.da.%d.minimum_cmd_size",
> +		 periph->unit_number);
> +	TUNABLE_INT_FETCH(tmpstr,&softc->minimum_cmd_size);
> +
> +	/*
> +	 * 6, 10, 12 and 16 are the currently permissible values.
> +	 */
> +	if (softc->minimum_cmd_size<  6)
> +		softc->minimum_cmd_size = 6;
> +	else if ((softc->minimum_cmd_size>  6)
> +	&&  (softc->minimum_cmd_size<= 10))
> +		softc->minimum_cmd_size = 10;
> +	else if ((softc->minimum_cmd_size>  10)
> +	&&  (softc->minimum_cmd_size<= 12))
> +		softc->minimum_cmd_size = 12;
> +	else if (softc->minimum_cmd_size>  12)
> +		softc->minimum_cmd_size = 16;
> +
>   	softc->disk = disk_alloc();
>   	softc->disk->d_open = daopen;
>   	softc->disk->d_close = daclose;
> %%%
>


-- 
Alexander Motin

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 21:25:33 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6632D106566B;
	Thu, 14 Apr 2011 21:25:33 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 49F328FC13;
	Thu, 14 Apr 2011 21:25:33 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3ELPXMr047818;
	Thu, 14 Apr 2011 21:25:33 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3ELPX8e047808;
	Thu, 14 Apr 2011 21:25:33 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104142125.p3ELPX8e047808@svn.freebsd.org>
From: Alexander Motin 
Date: Thu, 14 Apr 2011 21:25:33 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220644 - in head/sys/cam: . ata scsi
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 21:25:33 -0000

Author: mav
Date: Thu Apr 14 21:25:32 2011
New Revision: 220644
URL: http://svn.freebsd.org/changeset/base/220644

Log:
  Make CAM report devices with ATA/SATA transport to devstat(9) as IDE.

Modified:
  head/sys/cam/ata/ata_da.c
  head/sys/cam/cam_ccb.h
  head/sys/cam/scsi/scsi_cd.c
  head/sys/cam/scsi/scsi_ch.c
  head/sys/cam/scsi/scsi_da.c
  head/sys/cam/scsi/scsi_pass.c
  head/sys/cam/scsi/scsi_pt.c
  head/sys/cam/scsi/scsi_sa.c
  head/sys/cam/scsi/scsi_sg.c

Modified: head/sys/cam/ata/ata_da.c
==============================================================================
--- head/sys/cam/ata/ata_da.c	Thu Apr 14 20:06:23 2011	(r220643)
+++ head/sys/cam/ata/ata_da.c	Thu Apr 14 21:25:32 2011	(r220644)
@@ -792,6 +792,12 @@ adaregister(struct cam_periph *periph, v
 	TUNABLE_INT_FETCH(announce_buf, &softc->write_cache);
 	adagetparams(periph, cgd);
 	softc->disk = disk_alloc();
+	softc->disk->d_devstat = devstat_new_entry(periph->periph_name,
+			  periph->unit_number, softc->params.secsize,
+			  DEVSTAT_ALL_SUPPORTED,
+			  DEVSTAT_TYPE_DIRECT |
+			  XPORT_DEVSTAT_TYPE(cpi.transport),
+			  DEVSTAT_PRIORITY_DISK);
 	softc->disk->d_open = adaopen;
 	softc->disk->d_close = adaclose;
 	softc->disk->d_strategy = adastrategy;

Modified: head/sys/cam/cam_ccb.h
==============================================================================
--- head/sys/cam/cam_ccb.h	Thu Apr 14 20:06:23 2011	(r220643)
+++ head/sys/cam/cam_ccb.h	Thu Apr 14 21:25:32 2011	(r220644)
@@ -258,6 +258,14 @@ typedef enum {
 	XPORT_ISCSI,	/* iSCSI */
 } cam_xport;
 
+#define XPORT_IS_ATA(t)		((t) == XPORT_ATA || (t) == XPORT_SATA)
+#define XPORT_IS_SCSI(t)	((t) != XPORT_UNKNOWN && \
+				 (t) != XPORT_UNSPECIFIED && \
+				 !XPORT_IS_ATA(t))
+#define XPORT_DEVSTAT_TYPE(t)	(XPORT_IS_ATA(t) ? DEVSTAT_TYPE_IF_IDE : \
+				 XPORT_IS_SCSI(t) ? DEVSTAT_TYPE_IF_SCSI : \
+				 DEVSTAT_TYPE_IF_OTHER)
+
 #define PROTO_VERSION_UNKNOWN (UINT_MAX - 1)
 #define PROTO_VERSION_UNSPECIFIED UINT_MAX
 #define XPORT_VERSION_UNKNOWN (UINT_MAX - 1)

Modified: head/sys/cam/scsi/scsi_cd.c
==============================================================================
--- head/sys/cam/scsi/scsi_cd.c	Thu Apr 14 20:06:23 2011	(r220643)
+++ head/sys/cam/scsi/scsi_cd.c	Thu Apr 14 21:25:32 2011	(r220644)
@@ -714,10 +714,11 @@ cdregister(struct cam_periph *periph, vo
 	 */
 	cam_periph_unlock(periph);
 	softc->disk = disk_alloc();
-	softc->disk->d_devstat = devstat_new_entry("cd", 
+	softc->disk->d_devstat = devstat_new_entry("cd",
 			  periph->unit_number, 0,
-	  		  DEVSTAT_BS_UNAVAILABLE,
-			  DEVSTAT_TYPE_CDROM | DEVSTAT_TYPE_IF_SCSI,
+			  DEVSTAT_BS_UNAVAILABLE,
+			  DEVSTAT_TYPE_CDROM |
+			  XPORT_DEVSTAT_TYPE(cpi.transport),
 			  DEVSTAT_PRIORITY_CD);
 	softc->disk->d_open = cdopen;
 	softc->disk->d_close = cdclose;

Modified: head/sys/cam/scsi/scsi_ch.c
==============================================================================
--- head/sys/cam/scsi/scsi_ch.c	Thu Apr 14 20:06:23 2011	(r220643)
+++ head/sys/cam/scsi/scsi_ch.c	Thu Apr 14 21:25:32 2011	(r220644)
@@ -322,6 +322,7 @@ chregister(struct cam_periph *periph, vo
 {
 	struct ch_softc *softc;
 	struct ccb_getdev *cgd;
+	struct ccb_pathinq cpi;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (periph == NULL) {
@@ -347,6 +348,11 @@ chregister(struct cam_periph *periph, vo
 	periph->softc = softc;
 	softc->quirks = CH_Q_NONE;
 
+	bzero(&cpi, sizeof(cpi));
+	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+	cpi.ccb_h.func_code = XPT_PATH_INQ;
+	xpt_action((union ccb *)&cpi);
+
 	/*
 	 * Changers don't have a blocksize, and obviously don't support
 	 * tagged queueing.
@@ -355,7 +361,8 @@ chregister(struct cam_periph *periph, vo
 	softc->device_stats = devstat_new_entry("ch",
 			  periph->unit_number, 0,
 			  DEVSTAT_NO_BLOCKSIZE | DEVSTAT_NO_ORDERED_TAGS,
-			  SID_TYPE(&cgd->inq_data)| DEVSTAT_TYPE_IF_SCSI,
+			  SID_TYPE(&cgd->inq_data) |
+			  XPORT_DEVSTAT_TYPE(cpi.transport),
 			  DEVSTAT_PRIORITY_OTHER);
 
 	/* Register the device */

Modified: head/sys/cam/scsi/scsi_da.c
==============================================================================
--- head/sys/cam/scsi/scsi_da.c	Thu Apr 14 20:06:23 2011	(r220643)
+++ head/sys/cam/scsi/scsi_da.c	Thu Apr 14 21:25:32 2011	(r220644)
@@ -1292,6 +1292,12 @@ daregister(struct cam_periph *periph, vo
 
 	mtx_unlock(periph->sim->mtx);
 	softc->disk = disk_alloc();
+	softc->disk->d_devstat = devstat_new_entry(periph->periph_name,
+			  periph->unit_number, 0,
+			  DEVSTAT_BS_UNAVAILABLE,
+			  SID_TYPE(&cgd->inq_data) |
+			  XPORT_DEVSTAT_TYPE(cpi.transport),
+			  DEVSTAT_PRIORITY_DISK);
 	softc->disk->d_open = daopen;
 	softc->disk->d_close = daclose;
 	softc->disk->d_strategy = dastrategy;

Modified: head/sys/cam/scsi/scsi_pass.c
==============================================================================
--- head/sys/cam/scsi/scsi_pass.c	Thu Apr 14 20:06:23 2011	(r220643)
+++ head/sys/cam/scsi/scsi_pass.c	Thu Apr 14 21:25:32 2011	(r220644)
@@ -230,6 +230,7 @@ passregister(struct cam_periph *periph, 
 {
 	struct pass_softc *softc;
 	struct ccb_getdev *cgd;
+	struct ccb_pathinq cpi;
 	int    no_tags;
 
 	cgd = (struct ccb_getdev *)arg;
@@ -254,10 +255,20 @@ passregister(struct cam_periph *periph, 
 
 	bzero(softc, sizeof(*softc));
 	softc->state = PASS_STATE_NORMAL;
-	softc->pd_type = SID_TYPE(&cgd->inq_data);
+	if (cgd->protocol == PROTO_SCSI || cgd->protocol == PROTO_ATAPI)
+		softc->pd_type = SID_TYPE(&cgd->inq_data);
+	else if (cgd->protocol == PROTO_SATAPM)
+		softc->pd_type = T_ENCLOSURE;
+	else
+		softc->pd_type = T_DIRECT;
 
 	periph->softc = softc;
 
+	bzero(&cpi, sizeof(cpi));
+	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+	cpi.ccb_h.func_code = XPT_PATH_INQ;
+	xpt_action((union ccb *)&cpi);
+
 	/*
 	 * We pass in 0 for a blocksize, since we don't 
 	 * know what the blocksize of this device is, if 
@@ -270,7 +281,7 @@ passregister(struct cam_periph *periph, 
 			  DEVSTAT_NO_BLOCKSIZE
 			  | (no_tags ? DEVSTAT_NO_ORDERED_TAGS : 0),
 			  softc->pd_type |
-			  DEVSTAT_TYPE_IF_SCSI |
+			  XPORT_DEVSTAT_TYPE(cpi.transport) |
 			  DEVSTAT_TYPE_PASS,
 			  DEVSTAT_PRIORITY_PASS);
 

Modified: head/sys/cam/scsi/scsi_pt.c
==============================================================================
--- head/sys/cam/scsi/scsi_pt.c	Thu Apr 14 20:06:23 2011	(r220643)
+++ head/sys/cam/scsi/scsi_pt.c	Thu Apr 14 21:25:32 2011	(r220644)
@@ -252,6 +252,7 @@ ptctor(struct cam_periph *periph, void *
 {
 	struct pt_softc *softc;
 	struct ccb_getdev *cgd;
+	struct ccb_pathinq cpi;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (periph == NULL) {
@@ -280,12 +281,18 @@ ptctor(struct cam_periph *periph, void *
 	softc->io_timeout = SCSI_PT_DEFAULT_TIMEOUT * 1000;
 
 	periph->softc = softc;
-	
+
+	bzero(&cpi, sizeof(cpi));
+	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+	cpi.ccb_h.func_code = XPT_PATH_INQ;
+	xpt_action((union ccb *)&cpi);
+
 	cam_periph_unlock(periph);
 	softc->device_stats = devstat_new_entry("pt",
 			  periph->unit_number, 0,
 			  DEVSTAT_NO_BLOCKSIZE,
-			  SID_TYPE(&cgd->inq_data) | DEVSTAT_TYPE_IF_SCSI,
+			  SID_TYPE(&cgd->inq_data) |
+			  XPORT_DEVSTAT_TYPE(cpi.transport),
 			  DEVSTAT_PRIORITY_OTHER);
 
 	softc->dev = make_dev(&pt_cdevsw, periph->unit_number, UID_ROOT,

Modified: head/sys/cam/scsi/scsi_sa.c
==============================================================================
--- head/sys/cam/scsi/scsi_sa.c	Thu Apr 14 20:06:23 2011	(r220643)
+++ head/sys/cam/scsi/scsi_sa.c	Thu Apr 14 21:25:32 2011	(r220644)
@@ -1431,6 +1431,7 @@ saregister(struct cam_periph *periph, vo
 {
 	struct sa_softc *softc;
 	struct ccb_getdev *cgd;
+	struct ccb_pathinq cpi;
 	caddr_t match;
 	int i;
 	
@@ -1479,15 +1480,20 @@ saregister(struct cam_periph *periph, vo
 	} else
 		softc->quirks = SA_QUIRK_NONE;
 
+	bzero(&cpi, sizeof(cpi));
+	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+	cpi.ccb_h.func_code = XPT_PATH_INQ;
+	xpt_action((union ccb *)&cpi);
+
 	/*
- 	 * The SA driver supports a blocksize, but we don't know the
+	 * The SA driver supports a blocksize, but we don't know the
 	 * blocksize until we media is inserted.  So, set a flag to
 	 * indicate that the blocksize is unavailable right now.
 	 */
 	cam_periph_unlock(periph);
 	softc->device_stats = devstat_new_entry("sa", periph->unit_number, 0,
 	    DEVSTAT_BS_UNAVAILABLE, SID_TYPE(&cgd->inq_data) |
-	    DEVSTAT_TYPE_IF_SCSI, DEVSTAT_PRIORITY_TAPE);
+	    XPORT_DEVSTAT_TYPE(cpi.transport), DEVSTAT_PRIORITY_TAPE);
 
 	softc->devs.ctl_dev = make_dev(&sa_cdevsw, SAMINOR(SA_CTLDEV,
 	    0, SA_ATYPE_R), UID_ROOT, GID_OPERATOR,

Modified: head/sys/cam/scsi/scsi_sg.c
==============================================================================
--- head/sys/cam/scsi/scsi_sg.c	Thu Apr 14 20:06:23 2011	(r220643)
+++ head/sys/cam/scsi/scsi_sg.c	Thu Apr 14 21:25:32 2011	(r220644)
@@ -258,6 +258,7 @@ sgregister(struct cam_periph *periph, vo
 {
 	struct sg_softc *softc;
 	struct ccb_getdev *cgd;
+	struct ccb_pathinq cpi;
 	int no_tags;
 
 	cgd = (struct ccb_getdev *)arg;
@@ -284,6 +285,11 @@ sgregister(struct cam_periph *periph, vo
 	TAILQ_INIT(&softc->rdwr_done);
 	periph->softc = softc;
 
+	bzero(&cpi, sizeof(cpi));
+	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+	cpi.ccb_h.func_code = XPT_PATH_INQ;
+	xpt_action((union ccb *)&cpi);
+
 	/*
 	 * We pass in 0 for all blocksize, since we don't know what the
 	 * blocksize of the device is, if it even has a blocksize.
@@ -295,7 +301,7 @@ sgregister(struct cam_periph *periph, vo
 			DEVSTAT_NO_BLOCKSIZE
 			| (no_tags ? DEVSTAT_NO_ORDERED_TAGS : 0),
 			softc->pd_type |
-			DEVSTAT_TYPE_IF_SCSI |
+			XPORT_DEVSTAT_TYPE(cpi.transport) |
 			DEVSTAT_TYPE_PASS,
 			DEVSTAT_PRIORITY_PASS);
 

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 21:34:38 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4AEDE1065670;
	Thu, 14 Apr 2011 21:34:38 +0000 (UTC) (envelope-from jhb@freebsd.org)
Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42])
	by mx1.freebsd.org (Postfix) with ESMTP id 218948FC0C;
	Thu, 14 Apr 2011 21:34:38 +0000 (UTC)
Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net
	[66.111.2.69])
	by cyrus.watson.org (Postfix) with ESMTPSA id C6E7546B0D;
	Thu, 14 Apr 2011 17:34:37 -0400 (EDT)
Received: from jhbbsd.localnet (unknown [209.249.190.124])
	by bigwig.baldwin.cx (Postfix) with ESMTPSA id 50F868A027;
	Thu, 14 Apr 2011 17:34:37 -0400 (EDT)
From: John Baldwin 
To: Konstantin Belousov 
Date: Thu, 14 Apr 2011 17:13:28 -0400
User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110325; KDE/4.5.5; amd64; ; )
References: <201104101707.p3AH736T054347@svn.freebsd.org>
In-Reply-To: <201104101707.p3AH736T054347@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Message-Id: <201104141713.28311.jhb@freebsd.org>
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6
	(bigwig.baldwin.cx); Thu, 14 Apr 2011 17:34:37 -0400 (EDT)
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220526 - head/sys/kern
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 21:34:38 -0000

On Sunday, April 10, 2011 1:07:03 pm Konstantin Belousov wrote:
> Author: kib
> Date: Sun Apr 10 17:07:02 2011
> New Revision: 220526
> URL: http://svn.freebsd.org/changeset/base/220526
> 
> Log:
>   Some callers of proc_reparent() already have the parent process locked.
>   Detect the situation and avoid process lock recursion.
>   
>   Reported by:	Fabian Keil 
> 
> Modified:
>   head/sys/kern/kern_exit.c

Can we instead assert it is always held and fix callers that don't?  Using 
locked variables is messy and I'd rather avoid it when possible.  We already 
require the caller to hold other locks for this operation.

-- 
John Baldwin

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 21:49:52 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 75C73106564A;
	Thu, 14 Apr 2011 21:49:52 +0000 (UTC)
	(envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6310D8FC12;
	Thu, 14 Apr 2011 21:49:52 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3ELnqNr048330;
	Thu, 14 Apr 2011 21:49:52 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3ELnqh1048322;
	Thu, 14 Apr 2011 21:49:52 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201104142149.p3ELnqh1048322@svn.freebsd.org>
From: Rick Macklem 
Date: Thu, 14 Apr 2011 21:49:52 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220645 - in head/sys/fs: nfs nfsclient nfsserver
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 21:49:52 -0000

Author: rmacklem
Date: Thu Apr 14 21:49:52 2011
New Revision: 220645
URL: http://svn.freebsd.org/changeset/base/220645

Log:
  Modify the experimental NFSv4 server so that it handles
  crossing of server mount points properly. The functions
  nfsvno_fillattr() and nfsv4_fillattr() were modified to
  take the extra arguments that are the mount point, a flag
  to indicate that it is a file system root and the mounted
  on fileno. The mount point argument needs to be busy when
  nfsvno_fillattr() is called, since the vp argument is not
  locked.
  
  Reviewed by:	kib
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/fs/nfs/nfs_var.h
  head/sys/fs/nfsclient/nfs_clport.c
  head/sys/fs/nfsclient/nfs_clrpcops.c
  head/sys/fs/nfsclient/nfs_clstate.c
  head/sys/fs/nfsserver/nfs_nfsdport.c
  head/sys/fs/nfsserver/nfs_nfsdserv.c

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonsubs.c	Thu Apr 14 21:25:32 2011	(r220644)
+++ head/sys/fs/nfs/nfs_commonsubs.c	Thu Apr 14 21:49:52 2011	(r220645)
@@ -1916,9 +1916,10 @@ nfsrv_mtostr(struct nfsrv_descript *nd, 
  * Fill in the attributes as marked by the bitmap (V4).
  */
 APPLESTATIC int
-nfsv4_fillattr(struct nfsrv_descript *nd, vnode_t vp, NFSACL_T *saclp,
-    struct vattr *vap, fhandle_t *fhp, int rderror, nfsattrbit_t *attrbitp,
-    struct ucred *cred, NFSPROC_T *p, int isdgram, int reterr)
+nfsv4_fillattr(struct nfsrv_descript *nd, struct mount *mp, vnode_t vp,
+    NFSACL_T *saclp, struct vattr *vap, fhandle_t *fhp, int rderror,
+    nfsattrbit_t *attrbitp, struct ucred *cred, NFSPROC_T *p, int isdgram,
+    int reterr, int at_root, uint64_t mounted_on_fileno)
 {
 	int bitpos, retnum = 0;
 	u_int32_t *tl;
@@ -1928,7 +1929,6 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 	nfsattrbit_t *retbitp = &retbits;
 	u_int32_t freenum, *retnump;
 	u_int64_t uquad;
-	long fid;
 	struct statfs fs;
 	struct nfsfsinfo fsinf;
 	struct timespec temptime;
@@ -1958,7 +1958,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 	 * Get the VFS_STATFS(), since some attributes need them.
 	 */
 	if (NFSISSETSTATFS_ATTRBIT(retbitp)) {
-		error = VFS_STATFS(vnode_mount(vp), &fs);
+		error = VFS_STATFS(mp, &fs);
 		if (error != 0) {
 			if (reterr) {
 				nd->nd_repstat = NFSERR_ACCES;
@@ -1974,12 +1974,12 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 	 */
 	if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_ACLSUPPORT) &&
 	    (nfsrv_useacl == 0 || ((cred != NULL || p != NULL) &&
-		!NFSHASNFS4ACL(vnode_mount(vp))))) {
+		!NFSHASNFS4ACL(mp)))) {
 		NFSCLRBIT_ATTRBIT(retbitp, NFSATTRBIT_ACLSUPPORT);
 	}
 	if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_ACL)) {
 		if (nfsrv_useacl == 0 || ((cred != NULL || p != NULL) &&
-		    !NFSHASNFS4ACL(vnode_mount(vp)))) {
+		    !NFSHASNFS4ACL(mp))) {
 			NFSCLRBIT_ATTRBIT(retbitp, NFSATTRBIT_ACL);
 		} else if (naclp != NULL) {
 			if (vn_lock(vp, LK_SHARED) == 0) {
@@ -2016,7 +2016,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 		case NFSATTRBIT_SUPPORTEDATTRS:
 			NFSSETSUPP_ATTRBIT(&attrbits);
 			if (nfsrv_useacl == 0 || ((cred != NULL || p != NULL)
-			    && !NFSHASNFS4ACL(vnode_mount(vp)))) {
+			    && !NFSHASNFS4ACL(mp))) {
 			    NFSCLRBIT_ATTRBIT(&attrbits,NFSATTRBIT_ACLSUPPORT);
 			    NFSCLRBIT_ATTRBIT(&attrbits,NFSATTRBIT_ACL);
 			}
@@ -2066,9 +2066,9 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 		case NFSATTRBIT_FSID:
 			NFSM_BUILD(tl, u_int32_t *, NFSX_V4FSID);
 			*tl++ = 0;
-			*tl++=txdr_unsigned(vfs_statfs(vnode_mount(vp))->f_fsid.val[0]);
+			*tl++ = txdr_unsigned(mp->mnt_stat.f_fsid.val[0]);
 			*tl++ = 0;
-			*tl=txdr_unsigned(vfs_statfs(vnode_mount(vp))->f_fsid.val[1]);
+			*tl = txdr_unsigned(mp->mnt_stat.f_fsid.val[1]);
 			retnum += NFSX_V4FSID;
 			break;
 		case NFSATTRBIT_UNIQUEHANDLES:
@@ -2142,7 +2142,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 			 */
 			savuid = p->p_cred->p_ruid;
 			p->p_cred->p_ruid = cred->cr_uid;
-			if (!VFS_QUOTACTL(vnode_mount(vp),QCMD(Q_GETQUOTA,USRQUOTA),
+			if (!VFS_QUOTACTL(mp, QCMD(Q_GETQUOTA,USRQUOTA),
 			    cred->cr_uid, (caddr_t)&dqb))
 			    freenum = min(dqb.dqb_isoftlimit-dqb.dqb_curinodes,
 				freenum);
@@ -2249,7 +2249,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 			 */
 			savuid = p->p_cred->p_ruid;
 			p->p_cred->p_ruid = cred->cr_uid;
-			if (!VFS_QUOTACTL(vnode_mount(vp),QCMD(Q_GETQUOTA,USRQUOTA),
+			if (!VFS_QUOTACTL(mp, QCMD(Q_GETQUOTA,USRQUOTA),
 			    cred->cr_uid, (caddr_t)&dqb))
 			    freenum = min(dqb.dqb_bhardlimit, freenum);
 			p->p_cred->p_ruid = savuid;
@@ -2273,7 +2273,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 			 */
 			savuid = p->p_cred->p_ruid;
 			p->p_cred->p_ruid = cred->cr_uid;
-			if (!VFS_QUOTACTL(vnode_mount(vp),QCMD(Q_GETQUOTA,USRQUOTA),
+			if (!VFS_QUOTACTL(mp, QCMD(Q_GETQUOTA,USRQUOTA),
 			    cred->cr_uid, (caddr_t)&dqb))
 			    freenum = min(dqb.dqb_bsoftlimit, freenum);
 			p->p_cred->p_ruid = savuid;
@@ -2294,7 +2294,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 			 */
 			savuid = p->p_cred->p_ruid;
 			p->p_cred->p_ruid = cred->cr_uid;
-			if (!VFS_QUOTACTL(vnode_mount(vp),QCMD(Q_GETQUOTA,USRQUOTA),
+			if (!VFS_QUOTACTL(mp, QCMD(Q_GETQUOTA,USRQUOTA),
 			    cred->cr_uid, (caddr_t)&dqb))
 			    freenum = dqb.dqb_curblocks;
 			p->p_cred->p_ruid = savuid;
@@ -2390,11 +2390,11 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 			break;
 		case NFSATTRBIT_MOUNTEDONFILEID:
 			NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER);
-			*tl++ = 0;
-			if (nfsrv_atroot(vp, &fid))
-				*tl = txdr_unsigned(fid);
+			if (at_root != 0)
+				uquad = mounted_on_fileno;
 			else
-				*tl = txdr_unsigned(vap->va_fileid);
+				uquad = (u_int64_t)vap->va_fileid;
+			txdr_hyper(uquad, tl);
 			retnum += NFSX_HYPER;
 			break;
 		default:

Modified: head/sys/fs/nfs/nfs_var.h
==============================================================================
--- head/sys/fs/nfs/nfs_var.h	Thu Apr 14 21:25:32 2011	(r220644)
+++ head/sys/fs/nfs/nfs_var.h	Thu Apr 14 21:49:52 2011	(r220645)
@@ -288,9 +288,9 @@ int nfsrv_mtofh(struct nfsrv_descript *,
 int nfsrv_putattrbit(struct nfsrv_descript *, nfsattrbit_t *);
 void nfsrv_wcc(struct nfsrv_descript *, int, struct nfsvattr *, int,
     struct nfsvattr *);
-int nfsv4_fillattr(struct nfsrv_descript *, vnode_t, NFSACL_T *,
+int nfsv4_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, NFSACL_T *,
     struct vattr *, fhandle_t *, int, nfsattrbit_t *,
-    struct ucred *, NFSPROC_T *, int, int);
+    struct ucred *, NFSPROC_T *, int, int, int, uint64_t);
 void nfsrv_fillattr(struct nfsrv_descript *, struct nfsvattr *);
 void nfsrv_adj(mbuf_t, int, int);
 void nfsrv_postopattr(struct nfsrv_descript *, int, struct nfsvattr *);
@@ -556,9 +556,9 @@ void nfsvno_open(struct nfsrv_descript *
     struct nfsexstuff *, vnode_t *);
 void nfsvno_updfilerev(vnode_t, struct nfsvattr *, struct ucred *,
     NFSPROC_T *);
-int nfsvno_fillattr(struct nfsrv_descript *, vnode_t,
+int nfsvno_fillattr(struct nfsrv_descript *, struct mount *, vnode_t,
     struct nfsvattr *, fhandle_t *, int, nfsattrbit_t *,
-    struct ucred *, NFSPROC_T *, int, int);
+    struct ucred *, NFSPROC_T *, int, int, int, uint64_t);
 int nfsrv_sattr(struct nfsrv_descript *, struct nfsvattr *, nfsattrbit_t *,
     NFSACL_T *, NFSPROC_T *);
 int nfsv4_sattr(struct nfsrv_descript *, struct nfsvattr *, nfsattrbit_t *,

Modified: head/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clport.c	Thu Apr 14 21:25:32 2011	(r220644)
+++ head/sys/fs/nfsclient/nfs_clport.c	Thu Apr 14 21:49:52 2011	(r220645)
@@ -803,8 +803,8 @@ nfscl_fillsattr(struct nfsrv_descript *n
 			NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEACCESSSET);
 		if (vap->va_mtime.tv_sec != VNOVAL)
 			NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEMODIFYSET);
-		(void) nfsv4_fillattr(nd, vp, NULL, vap, NULL, 0, &attrbits,
-		    NULL, NULL, 0, 0);
+		(void) nfsv4_fillattr(nd, vp->v_mount, vp, NULL, vap, NULL, 0,
+		    &attrbits, NULL, NULL, 0, 0, 0, (uint64_t)0);
 		break;
 	};
 }

Modified: head/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clrpcops.c	Thu Apr 14 21:25:32 2011	(r220644)
+++ head/sys/fs/nfsclient/nfs_clrpcops.c	Thu Apr 14 21:49:52 2011	(r220645)
@@ -4176,8 +4176,8 @@ nfsrpc_setaclrpc(vnode_t vp, struct ucre
 	nfsm_stateidtom(nd, stateidp, NFSSTATEID_PUTSTATEID);
 	NFSZERO_ATTRBIT(&attrbits);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_ACL);
-	(void) nfsv4_fillattr(nd, vp, aclp, NULL, NULL, 0, &attrbits,
-	    NULL, NULL, 0, 0);
+	(void) nfsv4_fillattr(nd, vnode_mount(vp), vp, aclp, NULL, NULL, 0,
+	    &attrbits, NULL, NULL, 0, 0, 0, (uint64_t)0);
 	error = nfscl_request(nd, vp, p, cred, stuff);
 	if (error)
 		return (error);

Modified: head/sys/fs/nfsclient/nfs_clstate.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clstate.c	Thu Apr 14 21:25:32 2011	(r220644)
+++ head/sys/fs/nfsclient/nfs_clstate.c	Thu Apr 14 21:49:52 2011	(r220645)
@@ -3061,8 +3061,9 @@ nfscl_docb(struct nfsrv_descript *nd, NF
 					NFSSETBIT_ATTRBIT(&rattrbits,
 					    NFSATTRBIT_CHANGE);
 				}
-				(void) nfsv4_fillattr(nd, NULL, NULL, &va,
-				    NULL, 0, &rattrbits, NULL, NULL, 0, 0);
+				(void) nfsv4_fillattr(nd, NULL, NULL, NULL, &va,
+				    NULL, 0, &rattrbits, NULL, NULL, 0, 0, 0,
+				    (uint64_t)0);
 				if (!ret)
 					vrele(vp);
 			}

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdport.c	Thu Apr 14 21:25:32 2011	(r220644)
+++ head/sys/fs/nfsserver/nfs_nfsdport.c	Thu Apr 14 21:49:52 2011	(r220645)
@@ -70,15 +70,15 @@ static uint32_t nfsv4_sysid = 0;
 static int nfssvc_srvcall(struct thread *, struct nfssvc_args *,
     struct ucred *);
 
-static int enable_crossmntpt = 1;
+int nfsrv_enable_crossmntpt = 1;
 static int nfs_commit_blks;
 static int nfs_commit_miss;
 extern int nfsrv_issuedelegs;
 extern int nfsrv_dolocallocks;
 
 SYSCTL_DECL(_vfs_newnfs);
-SYSCTL_INT(_vfs_newnfs, OID_AUTO, mirrormnt, CTLFLAG_RW, &enable_crossmntpt,
-    0, "Enable nfsd to cross mount points");
+SYSCTL_INT(_vfs_newnfs, OID_AUTO, mirrormnt, CTLFLAG_RW,
+    &nfsrv_enable_crossmntpt, 0, "Enable nfsd to cross mount points");
 SYSCTL_INT(_vfs_newnfs, OID_AUTO, commit_blks, CTLFLAG_RW, &nfs_commit_blks,
     0, "");
 SYSCTL_INT(_vfs_newnfs, OID_AUTO, commit_miss, CTLFLAG_RW, &nfs_commit_miss,
@@ -308,12 +308,12 @@ nfsvno_namei(struct nfsrv_descript *nd, 
 			dp = rootvnode;
 			VREF(dp);
 		}
-	} else if ((enable_crossmntpt == 0 && NFSVNO_EXPORTED(exp)) ||
+	} else if ((nfsrv_enable_crossmntpt == 0 && NFSVNO_EXPORTED(exp)) ||
 	    (nd->nd_flag & ND_NFSV4) == 0) {
 		/*
 		 * Only cross mount points for NFSv4 when doing a
 		 * mount while traversing the file system above
-		 * the mount point, unless enable_crossmntpt is set.
+		 * the mount point, unless nfsrv_enable_crossmntpt is set.
 		 */
 		cnp->cn_flags |= NOCROSSMOUNT;
 		crossmnt = 0;
@@ -1394,14 +1394,15 @@ nfsvno_updfilerev(struct vnode *vp, stru
  * Glue routine to nfsv4_fillattr().
  */
 int
-nfsvno_fillattr(struct nfsrv_descript *nd, struct vnode *vp,
+nfsvno_fillattr(struct nfsrv_descript *nd, struct mount *mp, struct vnode *vp,
     struct nfsvattr *nvap, fhandle_t *fhp, int rderror, nfsattrbit_t *attrbitp,
-    struct ucred *cred, struct thread *p, int isdgram, int reterr)
+    struct ucred *cred, struct thread *p, int isdgram, int reterr, int at_root,
+    uint64_t mounted_on_fileno)
 {
 	int error;
 
-	error = nfsv4_fillattr(nd, vp, NULL, &nvap->na_vattr, fhp, rderror,
-	    attrbitp, cred, p, isdgram, reterr);
+	error = nfsv4_fillattr(nd, mp, vp, NULL, &nvap->na_vattr, fhp, rderror,
+	    attrbitp, cred, p, isdgram, reterr, at_root, mounted_on_fileno);
 	return (error);
 }
 
@@ -1691,8 +1692,9 @@ nfsrvd_readdirplus(struct nfsrv_descript
 	struct uio io;
 	struct iovec iv;
 	struct componentname cn;
-	int not_zfs;
-	struct mount *mp;
+	int at_root, needs_unbusy, not_zfs;
+	struct mount *mp, *new_mp;
+	uint64_t mounted_on_fileno;
 
 	if (nd->nd_repstat) {
 		nfsrv_postopattr(nd, getret, &at);
@@ -1932,6 +1934,10 @@ again:
 			nvp = NULL;
 			refp = NULL;
 			r = 0;
+			at_root = 0;
+			needs_unbusy = 0;
+			new_mp = mp;
+			mounted_on_fileno = (uint64_t)dp->d_fileno;
 			if ((nd->nd_flag & ND_NFSV3) ||
 			    NFSNONZERO_ATTRBIT(&savbits)) {
 				if (nd->nd_flag & ND_NFSV4)
@@ -1983,6 +1989,29 @@ again:
 								    0);
 						}
 					}
+
+					/*
+					 * For NFSv4, check to see if nvp is
+					 * a mount point and get the mount
+					 * point vnode, as required.
+					 */
+					if (r == 0 &&
+					    nfsrv_enable_crossmntpt != 0 &&
+					    (nd->nd_flag & ND_NFSV4) != 0 &&
+					    nvp->v_type == VDIR &&
+					    nvp->v_mountedhere != NULL) {
+						new_mp = nvp->v_mountedhere;
+						r = vfs_busy(new_mp, 0);
+						vput(nvp);
+						nvp = NULL;
+						if (r == 0) {
+							r = VFS_ROOT(new_mp,
+							    LK_SHARED, &nvp);
+							needs_unbusy = 1;
+							if (r == 0)
+								at_root = 1;
+						}
+					}
 				}
 				if (!r) {
 				    if (refp == NULL &&
@@ -2001,6 +2030,8 @@ again:
 					    NFSATTRBIT_RDATTRERROR)) {
 						if (nvp != NULL)
 							vput(nvp);
+						if (needs_unbusy != 0)
+							vfs_unbusy(new_mp);
 						nd->nd_repstat = r;
 						break;
 					}
@@ -2039,21 +2070,27 @@ again:
 					if (nd->nd_repstat) {
 						if (nvp != NULL)
 							vrele(nvp);
+						if (needs_unbusy != 0)
+							vfs_unbusy(new_mp);
 						break;
 					}
 				} else if (r) {
-					dirlen += nfsvno_fillattr(nd, nvp, nvap,
-					    &nfh, r, &rderrbits, nd->nd_cred,
-					    p, isdgram, 0);
+					dirlen += nfsvno_fillattr(nd, new_mp,
+					    nvp, nvap, &nfh, r, &rderrbits,
+					    nd->nd_cred, p, isdgram, 0, at_root,
+					    mounted_on_fileno);
 				} else {
-					dirlen += nfsvno_fillattr(nd, nvp, nvap,
-					    &nfh, r, &attrbits, nd->nd_cred,
-					    p, isdgram, 0);
+					dirlen += nfsvno_fillattr(nd, new_mp,
+					    nvp, nvap, &nfh, r, &attrbits,
+					    nd->nd_cred, p, isdgram, 0, at_root,
+					    mounted_on_fileno);
 				}
 				if (nvp != NULL)
 					vrele(nvp);
 				dirlen += (3 * NFSX_UNSIGNED);
 			}
+			if (needs_unbusy != 0)
+				vfs_unbusy(new_mp);
 			if (dirlen <= cnt)
 				entrycnt++;
 		}

Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdserv.c	Thu Apr 14 21:25:32 2011	(r220644)
+++ head/sys/fs/nfsserver/nfs_nfsdserv.c	Thu Apr 14 21:49:52 2011	(r220645)
@@ -52,6 +52,7 @@ extern u_int32_t newnfs_false, newnfs_tr
 extern enum vtype nv34tov_type[8];
 extern struct timeval nfsboottime;
 extern int nfs_rootfhset;
+extern int nfsrv_enable_crossmntpt;
 #endif	/* !APPLEKEXT */
 
 /*
@@ -169,9 +170,13 @@ nfsrvd_getattr(struct nfsrv_descript *nd
 {
 	struct nfsvattr nva;
 	fhandle_t fh;
-	int error = 0;
+	int at_root = 0, error = 0;
 	struct nfsreferral *refp;
 	nfsattrbit_t attrbits;
+	struct mount *mp;
+	struct vnode *tvp = NULL;
+	struct vattr va;
+	uint64_t mounted_on_fileno = 0;
 
 	if (nd->nd_repstat)
 		return (0);
@@ -207,11 +212,46 @@ nfsrvd_getattr(struct nfsrv_descript *nd
 			if (!nd->nd_repstat)
 				nd->nd_repstat = nfsrv_checkgetattr(nd, vp,
 				    &nva, &attrbits, nd->nd_cred, p);
-			NFSVOPUNLOCK(vp, 0, p);
-			if (!nd->nd_repstat)
-				(void) nfsvno_fillattr(nd, vp, &nva, &fh,
-				    0, &attrbits, nd->nd_cred, p, isdgram, 1);
-			vrele(vp);
+			if (nd->nd_repstat == 0) {
+				mp = vp->v_mount;
+				if (nfsrv_enable_crossmntpt != 0 &&
+				    vp->v_type == VDIR &&
+				    (vp->v_vflag & VV_ROOT) != 0 &&
+				    vp != rootvnode) {
+					tvp = mp->mnt_vnodecovered;
+					VREF(tvp);
+					at_root = 1;
+				} else
+					at_root = 0;
+				vfs_ref(mp);
+				VOP_UNLOCK(vp, 0);
+				if (at_root != 0) {
+					if ((nd->nd_repstat =
+					     vn_lock(tvp, LK_SHARED)) == 0) {
+						nd->nd_repstat = VOP_GETATTR(
+						    tvp, &va, nd->nd_cred);
+						vput(tvp);
+					} else
+						vrele(tvp);
+					if (nd->nd_repstat == 0)
+						mounted_on_fileno = (uint64_t)
+						    va.va_fileid;
+					else
+						at_root = 0;
+				}
+				if (nd->nd_repstat == 0)
+					nd->nd_repstat = vfs_busy(mp, 0);
+				vfs_rel(mp);
+				if (nd->nd_repstat == 0) {
+					(void)nfsvno_fillattr(nd, mp, vp, &nva,
+					    &fh, 0, &attrbits, nd->nd_cred, p,
+					    isdgram, 1, at_root,
+					    mounted_on_fileno);
+					vfs_unbusy(mp);
+				}
+				vrele(vp);
+			} else
+				vput(vp);
 		} else {
 			nfsrv_fillattr(nd, &nva);
 			vput(vp);

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 22:06:11 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 92210106564A;
	Thu, 14 Apr 2011 22:06:11 +0000 (UTC)
	(envelope-from jilles@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 81EB88FC12;
	Thu, 14 Apr 2011 22:06:11 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EM6B4O049692;
	Thu, 14 Apr 2011 22:06:11 GMT (envelope-from jilles@svn.freebsd.org)
Received: (from jilles@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EM6Bt4049690;
	Thu, 14 Apr 2011 22:06:11 GMT (envelope-from jilles@svn.freebsd.org)
Message-Id: <201104142206.p3EM6Bt4049690@svn.freebsd.org>
From: Jilles Tjoelker 
Date: Thu, 14 Apr 2011 22:06:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220646 - head/lib/libc/sys
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 22:06:11 -0000

Author: jilles
Date: Thu Apr 14 22:06:11 2011
New Revision: 220646
URL: http://svn.freebsd.org/changeset/base/220646

Log:
  getfh(2): Add xrefs for fhopen(2), open(2), stat(2).
  
  MFC after:	1 week

Modified:
  head/lib/libc/sys/getfh.2

Modified: head/lib/libc/sys/getfh.2
==============================================================================
--- head/lib/libc/sys/getfh.2	Thu Apr 14 21:49:52 2011	(r220645)
+++ head/lib/libc/sys/getfh.2	Thu Apr 14 22:06:11 2011	(r220646)
@@ -28,7 +28,7 @@
 .\"	@(#)getfh.2	8.1 (Berkeley) 6/9/93
 .\" $FreeBSD$
 .\"
-.Dd April 6, 2004
+.Dd April 14, 2011
 .Dt GETFH 2
 .Os
 .Sh NAME
@@ -104,6 +104,10 @@ An
 .Tn I/O
 error occurred while reading from or writing to the file system.
 .El
+.Sh SEE ALSO
+.Xr fhopen 2 ,
+.Xr open 2 ,
+.Xr stat 2
 .Sh HISTORY
 The
 .Fn getfh

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 22:17:39 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EFD9E1065670;
	Thu, 14 Apr 2011 22:17:39 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DFBD78FC08;
	Thu, 14 Apr 2011 22:17:39 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EMHdPl050003;
	Thu, 14 Apr 2011 22:17:39 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EMHdQ7050000;
	Thu, 14 Apr 2011 22:17:39 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104142217.p3EMHdQ7050000@svn.freebsd.org>
From: Jung-uk Kim 
Date: Thu, 14 Apr 2011 22:17:39 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220647 - in head/sys: dev/acpica sys
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 22:17:40 -0000

Author: jkim
Date: Thu Apr 14 22:17:39 2011
New Revision: 220647
URL: http://svn.freebsd.org/changeset/base/220647

Log:
  Add event handlers for (ACPI) suspend/resume events.  Suspend event handlers
  are invoked right before device drivers go into sleep state and resume event
  handlers are invoked right after all device drivers are waken up.

Modified:
  head/sys/dev/acpica/acpi.c
  head/sys/sys/eventhandler.h

Modified: head/sys/dev/acpica/acpi.c
==============================================================================
--- head/sys/dev/acpica/acpi.c	Thu Apr 14 22:06:11 2011	(r220646)
+++ head/sys/dev/acpica/acpi.c	Thu Apr 14 22:17:39 2011	(r220647)
@@ -2594,6 +2594,8 @@ acpi_EnterSleepState(struct acpi_softc *
 	return_ACPI_STATUS (AE_OK);
     }
 
+    EVENTHANDLER_INVOKE(power_suspend);
+
     if (smp_started) {
 	thread_lock(curthread);
 	sched_bind(curthread, 0);
@@ -2685,6 +2687,8 @@ backout:
 	thread_unlock(curthread);
     }
 
+    EVENTHANDLER_INVOKE(power_resume);
+
     /* Allow another sleep request after a while. */
     timeout(acpi_sleep_enable, sc, hz * ACPI_MINIMUM_AWAKETIME);
 

Modified: head/sys/sys/eventhandler.h
==============================================================================
--- head/sys/sys/eventhandler.h	Thu Apr 14 22:06:11 2011	(r220646)
+++ head/sys/sys/eventhandler.h	Thu Apr 14 22:17:39 2011	(r220647)
@@ -178,6 +178,11 @@ EVENTHANDLER_DECLARE(shutdown_pre_sync, 
 EVENTHANDLER_DECLARE(shutdown_post_sync, shutdown_fn);	/* after fs sync */
 EVENTHANDLER_DECLARE(shutdown_final, shutdown_fn);
 
+/* Power state change events */
+typedef void (*power_change_fn)(void *);
+EVENTHANDLER_DECLARE(power_resume, power_change_fn);
+EVENTHANDLER_DECLARE(power_suspend, power_change_fn);
+
 /* Low memory event */
 typedef void (*vm_lowmem_handler_t)(void *, int);
 #define	LOWMEM_PRI_DEFAULT	EVENTHANDLER_PRI_FIRST

From owner-svn-src-head@FreeBSD.ORG  Thu Apr 14 23:46:15 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E9C50106564A;
	Thu, 14 Apr 2011 23:46:15 +0000 (UTC)
	(envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D9AA18FC21;
	Thu, 14 Apr 2011 23:46:15 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3ENkFBj051786;
	Thu, 14 Apr 2011 23:46:15 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3ENkFgp051775;
	Thu, 14 Apr 2011 23:46:15 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201104142346.p3ENkFgp051775@svn.freebsd.org>
From: Rick Macklem 
Date: Thu, 14 Apr 2011 23:46:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220648 - in head/sys/fs: nfs nfsclient nfsserver
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Thu, 14 Apr 2011 23:46:16 -0000

Author: rmacklem
Date: Thu Apr 14 23:46:15 2011
New Revision: 220648
URL: http://svn.freebsd.org/changeset/base/220648

Log:
  Fix the experimental NFSv4 server so that it uses VOP_PATHCONF()
  to determine if a file system supports NFSv4 ACLs. Since
  VOP_PATHCONF() must be called with a locked vnode, the function
  is called before nfsvno_fillattr() and the result is passed in
  as an extra argument.
  
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfs/nfs_commonacl.c
  head/sys/fs/nfs/nfs_commonport.c
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/fs/nfs/nfs_var.h
  head/sys/fs/nfs/nfsport.h
  head/sys/fs/nfsclient/nfs_clport.c
  head/sys/fs/nfsclient/nfs_clrpcops.c
  head/sys/fs/nfsclient/nfs_clstate.c
  head/sys/fs/nfsserver/nfs_nfsdport.c
  head/sys/fs/nfsserver/nfs_nfsdserv.c

Modified: head/sys/fs/nfs/nfs_commonacl.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonacl.c	Thu Apr 14 22:17:39 2011	(r220647)
+++ head/sys/fs/nfs/nfs_commonacl.c	Thu Apr 14 23:46:15 2011	(r220648)
@@ -445,7 +445,7 @@ nfsrv_setacl(vnode_t vp, NFSACL_T *aclp,
 {
 	int error;
 
-	if (nfsrv_useacl == 0 || !NFSHASNFS4ACL(vnode_mount(vp)))
+	if (nfsrv_useacl == 0 || nfs_supportsnfsv4acls(vp) == 0)
 		return (NFSERR_ATTRNOTSUPP);
 	/*
 	 * With NFSv4 ACLs, chmod(2) may need to add additional entries.

Modified: head/sys/fs/nfs/nfs_commonport.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonport.c	Thu Apr 14 22:17:39 2011	(r220647)
+++ head/sys/fs/nfs/nfs_commonport.c	Thu Apr 14 23:46:15 2011	(r220648)
@@ -437,18 +437,18 @@ newnfs_portinit(void)
  * Return 1 if it does, 0 otherwise.
  */
 int
-nfs_supportsnfsv4acls(struct mount *mp)
+nfs_supportsnfsv4acls(struct vnode *vp)
 {
+	int error;
+	register_t retval;
 
-	if (mp->mnt_stat.f_fstypename == NULL)
-		return (0);
-	if (strcmp(mp->mnt_stat.f_fstypename, "ufs") == 0) {
-		/* Not yet */
+	ASSERT_VOP_LOCKED(vp, "nfs supports nfsv4acls");
+
+	if (nfsrv_useacl == 0)
 		return (0);
-	} else if (strcmp(mp->mnt_stat.f_fstypename, "zfs") == 0) {
-		/* Always supports them */
+	error = VOP_PATHCONF(vp, _PC_ACL_NFS4, &retval);
+	if (error == 0 && retval != 0)
 		return (1);
-	}
 	return (0);
 }
 

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonsubs.c	Thu Apr 14 22:17:39 2011	(r220647)
+++ head/sys/fs/nfs/nfs_commonsubs.c	Thu Apr 14 23:46:15 2011	(r220648)
@@ -1919,7 +1919,7 @@ APPLESTATIC int
 nfsv4_fillattr(struct nfsrv_descript *nd, struct mount *mp, vnode_t vp,
     NFSACL_T *saclp, struct vattr *vap, fhandle_t *fhp, int rderror,
     nfsattrbit_t *attrbitp, struct ucred *cred, NFSPROC_T *p, int isdgram,
-    int reterr, int at_root, uint64_t mounted_on_fileno)
+    int reterr, int supports_nfsv4acls, int at_root, uint64_t mounted_on_fileno)
 {
 	int bitpos, retnum = 0;
 	u_int32_t *tl;
@@ -1974,12 +1974,12 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 	 */
 	if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_ACLSUPPORT) &&
 	    (nfsrv_useacl == 0 || ((cred != NULL || p != NULL) &&
-		!NFSHASNFS4ACL(mp)))) {
+		supports_nfsv4acls == 0))) {
 		NFSCLRBIT_ATTRBIT(retbitp, NFSATTRBIT_ACLSUPPORT);
 	}
 	if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_ACL)) {
 		if (nfsrv_useacl == 0 || ((cred != NULL || p != NULL) &&
-		    !NFSHASNFS4ACL(mp))) {
+		    supports_nfsv4acls == 0)) {
 			NFSCLRBIT_ATTRBIT(retbitp, NFSATTRBIT_ACL);
 		} else if (naclp != NULL) {
 			if (vn_lock(vp, LK_SHARED) == 0) {
@@ -2016,7 +2016,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd
 		case NFSATTRBIT_SUPPORTEDATTRS:
 			NFSSETSUPP_ATTRBIT(&attrbits);
 			if (nfsrv_useacl == 0 || ((cred != NULL || p != NULL)
-			    && !NFSHASNFS4ACL(mp))) {
+			    && supports_nfsv4acls == 0)) {
 			    NFSCLRBIT_ATTRBIT(&attrbits,NFSATTRBIT_ACLSUPPORT);
 			    NFSCLRBIT_ATTRBIT(&attrbits,NFSATTRBIT_ACL);
 			}

Modified: head/sys/fs/nfs/nfs_var.h
==============================================================================
--- head/sys/fs/nfs/nfs_var.h	Thu Apr 14 22:17:39 2011	(r220647)
+++ head/sys/fs/nfs/nfs_var.h	Thu Apr 14 23:46:15 2011	(r220648)
@@ -290,7 +290,7 @@ void nfsrv_wcc(struct nfsrv_descript *, 
     struct nfsvattr *);
 int nfsv4_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, NFSACL_T *,
     struct vattr *, fhandle_t *, int, nfsattrbit_t *,
-    struct ucred *, NFSPROC_T *, int, int, int, uint64_t);
+    struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t);
 void nfsrv_fillattr(struct nfsrv_descript *, struct nfsvattr *);
 void nfsrv_adj(mbuf_t, int, int);
 void nfsrv_postopattr(struct nfsrv_descript *, int, struct nfsvattr *);
@@ -328,6 +328,7 @@ int nfs_catnap(int, int, const char *);
 struct nfsreferral *nfsv4root_getreferral(vnode_t, vnode_t, u_int32_t);
 int nfsrv_atroot(vnode_t, long *);
 void newnfs_timer(void *);
+int nfs_supportsnfsv4acls(vnode_t);
 
 /* nfs_commonacl.c */
 int nfsrv_dissectace(struct nfsrv_descript *, struct acl_entry *,
@@ -558,7 +559,7 @@ void nfsvno_updfilerev(vnode_t, struct n
     NFSPROC_T *);
 int nfsvno_fillattr(struct nfsrv_descript *, struct mount *, vnode_t,
     struct nfsvattr *, fhandle_t *, int, nfsattrbit_t *,
-    struct ucred *, NFSPROC_T *, int, int, int, uint64_t);
+    struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t);
 int nfsrv_sattr(struct nfsrv_descript *, struct nfsvattr *, nfsattrbit_t *,
     NFSACL_T *, NFSPROC_T *);
 int nfsv4_sattr(struct nfsrv_descript *, struct nfsvattr *, nfsattrbit_t *,

Modified: head/sys/fs/nfs/nfsport.h
==============================================================================
--- head/sys/fs/nfs/nfsport.h	Thu Apr 14 22:17:39 2011	(r220647)
+++ head/sys/fs/nfs/nfsport.h	Thu Apr 14 23:46:15 2011	(r220648)
@@ -778,12 +778,6 @@ void newnfs_realign(struct mbuf **);
 #define	NFSHASPRIVACY(n)	((n)->nm_flag & NFSMNT_PRIVACY)
 #define	NFSSETWRITEVERF(n)	((n)->nm_state |= NFSSTA_HASWRITEVERF)
 #define	NFSSETHASSETFSID(n)	((n)->nm_state |= NFSSTA_HASSETFSID)
-#ifdef NFS4_ACL_EXTATTR_NAME
-#define	NFSHASNFS4ACL(m)	nfs_supportsnfsv4acls(m)
-int nfs_supportsnfsv4acls(struct mount *);
-#else
-#define	NFSHASNFS4ACL(m)	0
-#endif
 
 /*
  * Gets the stats field out of the mount structure.

Modified: head/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clport.c	Thu Apr 14 22:17:39 2011	(r220647)
+++ head/sys/fs/nfsclient/nfs_clport.c	Thu Apr 14 23:46:15 2011	(r220648)
@@ -804,7 +804,7 @@ nfscl_fillsattr(struct nfsrv_descript *n
 		if (vap->va_mtime.tv_sec != VNOVAL)
 			NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEMODIFYSET);
 		(void) nfsv4_fillattr(nd, vp->v_mount, vp, NULL, vap, NULL, 0,
-		    &attrbits, NULL, NULL, 0, 0, 0, (uint64_t)0);
+		    &attrbits, NULL, NULL, 0, 0, 0, 0, (uint64_t)0);
 		break;
 	};
 }

Modified: head/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clrpcops.c	Thu Apr 14 22:17:39 2011	(r220647)
+++ head/sys/fs/nfsclient/nfs_clrpcops.c	Thu Apr 14 23:46:15 2011	(r220648)
@@ -4177,7 +4177,7 @@ nfsrpc_setaclrpc(vnode_t vp, struct ucre
 	NFSZERO_ATTRBIT(&attrbits);
 	NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_ACL);
 	(void) nfsv4_fillattr(nd, vnode_mount(vp), vp, aclp, NULL, NULL, 0,
-	    &attrbits, NULL, NULL, 0, 0, 0, (uint64_t)0);
+	    &attrbits, NULL, NULL, 0, 0, 0, 0, (uint64_t)0);
 	error = nfscl_request(nd, vp, p, cred, stuff);
 	if (error)
 		return (error);

Modified: head/sys/fs/nfsclient/nfs_clstate.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clstate.c	Thu Apr 14 22:17:39 2011	(r220647)
+++ head/sys/fs/nfsclient/nfs_clstate.c	Thu Apr 14 23:46:15 2011	(r220648)
@@ -3062,7 +3062,7 @@ nfscl_docb(struct nfsrv_descript *nd, NF
 					    NFSATTRBIT_CHANGE);
 				}
 				(void) nfsv4_fillattr(nd, NULL, NULL, NULL, &va,
-				    NULL, 0, &rattrbits, NULL, NULL, 0, 0, 0,
+				    NULL, 0, &rattrbits, NULL, NULL, 0, 0, 0, 0,
 				    (uint64_t)0);
 				if (!ret)
 					vrele(vp);

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdport.c	Thu Apr 14 22:17:39 2011	(r220647)
+++ head/sys/fs/nfsserver/nfs_nfsdport.c	Thu Apr 14 23:46:15 2011	(r220648)
@@ -1396,13 +1396,14 @@ nfsvno_updfilerev(struct vnode *vp, stru
 int
 nfsvno_fillattr(struct nfsrv_descript *nd, struct mount *mp, struct vnode *vp,
     struct nfsvattr *nvap, fhandle_t *fhp, int rderror, nfsattrbit_t *attrbitp,
-    struct ucred *cred, struct thread *p, int isdgram, int reterr, int at_root,
-    uint64_t mounted_on_fileno)
+    struct ucred *cred, struct thread *p, int isdgram, int reterr,
+    int supports_nfsv4acls, int at_root, uint64_t mounted_on_fileno)
 {
 	int error;
 
 	error = nfsv4_fillattr(nd, mp, vp, NULL, &nvap->na_vattr, fhp, rderror,
-	    attrbitp, cred, p, isdgram, reterr, at_root, mounted_on_fileno);
+	    attrbitp, cred, p, isdgram, reterr, supports_nfsv4acls, at_root,
+	    mounted_on_fileno);
 	return (error);
 }
 
@@ -1692,7 +1693,7 @@ nfsrvd_readdirplus(struct nfsrv_descript
 	struct uio io;
 	struct iovec iv;
 	struct componentname cn;
-	int at_root, needs_unbusy, not_zfs;
+	int at_root, needs_unbusy, not_zfs, supports_nfsv4acls;
 	struct mount *mp, *new_mp;
 	uint64_t mounted_on_fileno;
 
@@ -2061,8 +2062,12 @@ again:
 				*tl++ = 0;
 				*tl = txdr_unsigned(*cookiep);
 				dirlen += nfsm_strtom(nd, dp->d_name, nlen);
-				if (nvp != NULL)
+				if (nvp != NULL) {
+					supports_nfsv4acls =
+					    nfs_supportsnfsv4acls(nvp);
 					VOP_UNLOCK(nvp, 0);
+				} else
+					supports_nfsv4acls = 0;
 				if (refp != NULL) {
 					dirlen += nfsrv_putreferralattr(nd,
 					    &savbits, refp, 0,
@@ -2077,12 +2082,14 @@ again:
 				} else if (r) {
 					dirlen += nfsvno_fillattr(nd, new_mp,
 					    nvp, nvap, &nfh, r, &rderrbits,
-					    nd->nd_cred, p, isdgram, 0, at_root,
+					    nd->nd_cred, p, isdgram, 0,
+					    supports_nfsv4acls, at_root,
 					    mounted_on_fileno);
 				} else {
 					dirlen += nfsvno_fillattr(nd, new_mp,
 					    nvp, nvap, &nfh, r, &attrbits,
-					    nd->nd_cred, p, isdgram, 0, at_root,
+					    nd->nd_cred, p, isdgram, 0,
+					    supports_nfsv4acls, at_root,
 					    mounted_on_fileno);
 				}
 				if (nvp != NULL)

Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdserv.c	Thu Apr 14 22:17:39 2011	(r220647)
+++ head/sys/fs/nfsserver/nfs_nfsdserv.c	Thu Apr 14 23:46:15 2011	(r220648)
@@ -170,7 +170,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd
 {
 	struct nfsvattr nva;
 	fhandle_t fh;
-	int at_root = 0, error = 0;
+	int at_root = 0, error = 0, supports_nfsv4acls;
 	struct nfsreferral *refp;
 	nfsattrbit_t attrbits;
 	struct mount *mp;
@@ -213,6 +213,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd
 				nd->nd_repstat = nfsrv_checkgetattr(nd, vp,
 				    &nva, &attrbits, nd->nd_cred, p);
 			if (nd->nd_repstat == 0) {
+				supports_nfsv4acls = nfs_supportsnfsv4acls(vp);
 				mp = vp->v_mount;
 				if (nfsrv_enable_crossmntpt != 0 &&
 				    vp->v_type == VDIR &&
@@ -245,8 +246,8 @@ nfsrvd_getattr(struct nfsrv_descript *nd
 				if (nd->nd_repstat == 0) {
 					(void)nfsvno_fillattr(nd, mp, vp, &nva,
 					    &fh, 0, &attrbits, nd->nd_cred, p,
-					    isdgram, 1, at_root,
-					    mounted_on_fileno);
+					    isdgram, 1, supports_nfsv4acls,
+					    at_root, mounted_on_fileno);
 					vfs_unbusy(mp);
 				}
 				vrele(vp);

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 03:09:27 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C5FC8106564A;
	Fri, 15 Apr 2011 03:09:27 +0000 (UTC) (envelope-from np@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B51E98FC14;
	Fri, 15 Apr 2011 03:09:27 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3F39R9j056404;
	Fri, 15 Apr 2011 03:09:27 GMT (envelope-from np@svn.freebsd.org)
Received: (from np@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3F39R8Y056398;
	Fri, 15 Apr 2011 03:09:27 GMT (envelope-from np@svn.freebsd.org)
Message-Id: <201104150309.p3F39R8Y056398@svn.freebsd.org>
From: Navdeep Parhar 
Date: Fri, 15 Apr 2011 03:09:27 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220649 - in head/sys/dev/cxgbe: . common
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 03:09:27 -0000

Author: np
Date: Fri Apr 15 03:09:27 2011
New Revision: 220649
URL: http://svn.freebsd.org/changeset/base/220649

Log:
  Fix a couple of bad races that can occur when a cxgbe interface is taken
  down.  The ingress queue lock was unused and has been removed as part of
  these changes.
  
  - An in-flight egress update from the SGE must be handled before the
    queue that requested it is destroyed.  Wait for the update to arrive.
  
  - Interrupt handlers must stop processing rx events for a queue before
    the queue is destroyed.  Events that have not yet been processed
    should be ignored once the queue disappears.
  
  MFC after:	1 week

Modified:
  head/sys/dev/cxgbe/adapter.h
  head/sys/dev/cxgbe/common/t4_hw.c
  head/sys/dev/cxgbe/osdep.h
  head/sys/dev/cxgbe/t4_main.c
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/adapter.h
==============================================================================
--- head/sys/dev/cxgbe/adapter.h	Thu Apr 14 23:46:15 2011	(r220648)
+++ head/sys/dev/cxgbe/adapter.h	Fri Apr 15 03:09:27 2011	(r220649)
@@ -227,6 +227,11 @@ enum {
 	/* iq flags */
 	IQ_ALLOCATED	= (1 << 1),	/* firmware resources allocated */
 	IQ_STARTED	= (1 << 2),	/* started */
+
+	/* iq state */
+	IQS_DISABLED	= 0,
+	IQS_BUSY	= 1,
+	IQS_IDLE	= 2,
 };
 
 /*
@@ -244,7 +249,7 @@ struct sge_iq {
 	iq_intr_handler_t *handler;
 	__be64  *desc;		/* KVA of descriptor ring */
 
-	struct mtx iq_lock;
+	volatile uint32_t state;
 	struct adapter *adapter;
 	const __be64 *cdesc;	/* current descriptor */
 	uint8_t  gen;		/* generation bit */
@@ -445,22 +450,12 @@ struct adapter {
 #define PORT_LOCK_ASSERT_OWNED(pi)	mtx_assert(&(pi)->pi_lock, MA_OWNED)
 #define PORT_LOCK_ASSERT_NOTOWNED(pi)	mtx_assert(&(pi)->pi_lock, MA_NOTOWNED)
 
-#define IQ_LOCK(iq)			mtx_lock(&(iq)->iq_lock)
-#define IQ_UNLOCK(iq)			mtx_unlock(&(iq)->iq_lock)
-#define IQ_LOCK_ASSERT_OWNED(iq)	mtx_assert(&(iq)->iq_lock, MA_OWNED)
-#define IQ_LOCK_ASSERT_NOTOWNED(iq)	mtx_assert(&(iq)->iq_lock, MA_NOTOWNED)
-
 #define FL_LOCK(fl)			mtx_lock(&(fl)->fl_lock)
 #define FL_TRYLOCK(fl)			mtx_trylock(&(fl)->fl_lock)
 #define FL_UNLOCK(fl)			mtx_unlock(&(fl)->fl_lock)
 #define FL_LOCK_ASSERT_OWNED(fl)	mtx_assert(&(fl)->fl_lock, MA_OWNED)
 #define FL_LOCK_ASSERT_NOTOWNED(fl)	mtx_assert(&(fl)->fl_lock, MA_NOTOWNED)
 
-#define RXQ_LOCK(rxq)			IQ_LOCK(&(rxq)->iq)
-#define RXQ_UNLOCK(rxq)			IQ_UNLOCK(&(rxq)->iq)
-#define RXQ_LOCK_ASSERT_OWNED(rxq)	IQ_LOCK_ASSERT_OWNED(&(rxq)->iq)
-#define RXQ_LOCK_ASSERT_NOTOWNED(rxq)	IQ_LOCK_ASSERT_NOTOWNED(&(rxq)->iq)
-
 #define RXQ_FL_LOCK(rxq)		FL_LOCK(&(rxq)->fl)
 #define RXQ_FL_UNLOCK(rxq)		FL_UNLOCK(&(rxq)->fl)
 #define RXQ_FL_LOCK_ASSERT_OWNED(rxq)	FL_LOCK_ASSERT_OWNED(&(rxq)->fl)
@@ -586,6 +581,8 @@ void t4_intr_fwd(void *);
 void t4_intr_err(void *);
 void t4_intr_evt(void *);
 void t4_intr_data(void *);
+void t4_evt_rx(void *);
+void t4_eth_rx(void *);
 int t4_eth_tx(struct ifnet *, struct sge_txq *, struct mbuf *);
 void t4_update_fl_bufsize(struct ifnet *);
 

Modified: head/sys/dev/cxgbe/common/t4_hw.c
==============================================================================
--- head/sys/dev/cxgbe/common/t4_hw.c	Thu Apr 14 23:46:15 2011	(r220648)
+++ head/sys/dev/cxgbe/common/t4_hw.c	Fri Apr 15 03:09:27 2011	(r220649)
@@ -32,6 +32,8 @@ __FBSDID("$FreeBSD$");
 #include "t4_regs_values.h"
 #include "t4fw_interface.h"
 
+#undef msleep
+#define msleep(x) DELAY((x) * 1000)
 
 /**
  *	t4_wait_op_done_val - wait until an operation is completed

Modified: head/sys/dev/cxgbe/osdep.h
==============================================================================
--- head/sys/dev/cxgbe/osdep.h	Thu Apr 14 23:46:15 2011	(r220648)
+++ head/sys/dev/cxgbe/osdep.h	Fri Apr 15 03:09:27 2011	(r220649)
@@ -74,8 +74,6 @@ typedef boolean_t bool;
 #define false FALSE
 #define true TRUE
 
-#undef msleep
-#define msleep(x) DELAY((x) * 1000)
 #define mdelay(x) DELAY((x) * 1000)
 #define udelay(x) DELAY(x)
 

Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c	Thu Apr 14 23:46:15 2011	(r220648)
+++ head/sys/dev/cxgbe/t4_main.c	Fri Apr 15 03:09:27 2011	(r220649)
@@ -1038,8 +1038,21 @@ static void
 cxgbe_qflush(struct ifnet *ifp)
 {
 	struct port_info *pi = ifp->if_softc;
+	struct sge_txq *txq;
+	int i;
+	struct mbuf *m;
 
-	device_printf(pi->dev, "%s unimplemented.\n", __func__);
+	/* queues do not exist if !IFF_DRV_RUNNING. */
+	if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+		for_each_txq(pi, i, txq) {
+			TXQ_LOCK(txq);
+			m_freem(txq->m);
+			while ((m = buf_ring_dequeue_sc(txq->eq.br)) != NULL)
+				m_freem(m);
+			TXQ_UNLOCK(txq);
+		}
+	}
+	if_qflush(ifp);
 }
 
 static int
@@ -2673,8 +2686,11 @@ cxgbe_txq_start(void *arg, int count)
 	struct sge_txq *txq = arg;
 
 	TXQ_LOCK(txq);
-	txq->eq.flags &= ~EQ_CRFLUSHED;
-	txq_start(txq->ifp, txq);
+	if (txq->eq.flags & EQ_CRFLUSHED) {
+		txq->eq.flags &= ~EQ_CRFLUSHED;
+		txq_start(txq->ifp, txq);
+	} else
+		wakeup_one(txq);	/* txq is going away, wakeup free_txq */
 	TXQ_UNLOCK(txq);
 }
 

Modified: head/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- head/sys/dev/cxgbe/t4_sge.c	Thu Apr 14 23:46:15 2011	(r220648)
+++ head/sys/dev/cxgbe/t4_sge.c	Fri Apr 15 03:09:27 2011	(r220649)
@@ -279,7 +279,7 @@ t4_setup_adapter_iqs(struct adapter *sc)
 			}
 		}
 
-		handler = t4_intr_evt;
+		handler = t4_evt_rx;
 		i = 0;	/* forward fwq's interrupt to the first fiq */
 	} else {
 		handler = NULL;
@@ -345,7 +345,7 @@ t4_setup_eth_queues(struct port_info *pi
 		    device_get_nameunit(pi->dev), i);
 		init_iq(&rxq->iq, sc, pi->tmr_idx, pi->pktc_idx,
 		    pi->qsize_rxq, RX_IQ_ESIZE,
-		    sc->flags & INTR_FWD ? t4_intr_data: NULL, name);
+		    sc->flags & INTR_FWD ? t4_eth_rx : NULL, name);
 
 		snprintf(name, sizeof(name), "%s rxq%d-fl",
 		    device_get_nameunit(pi->dev), i);
@@ -428,6 +428,9 @@ t4_intr_fwd(void *arg)
 	int ndesc_pending = 0, ndesc_total = 0;
 	int qid;
 
+	if (!atomic_cmpset_32(&iq->state, IQS_IDLE, IQS_BUSY))
+		return;
+
 	while (is_new_response(iq, &ctrl)) {
 
 		rmb();
@@ -460,6 +463,8 @@ t4_intr_fwd(void *arg)
 		    V_CIDXINC(ndesc_pending) | V_INGRESSQID((u32)iq->cntxt_id) |
 		    V_SEINTARM(iq->intr_params));
 	}
+
+	atomic_cmpset_32(&iq->state, IQS_BUSY, IQS_IDLE);
 }
 
 /* Deals with error interrupts */
@@ -479,6 +484,32 @@ void
 t4_intr_evt(void *arg)
 {
 	struct sge_iq *iq = arg;
+
+	if (!atomic_cmpset_32(&iq->state, IQS_IDLE, IQS_BUSY))
+		return;
+
+	t4_evt_rx(arg);
+
+	atomic_cmpset_32(&iq->state, IQS_BUSY, IQS_IDLE);
+}
+
+void
+t4_intr_data(void *arg)
+{
+	struct sge_iq *iq = arg;
+
+	if (!atomic_cmpset_32(&iq->state, IQS_IDLE, IQS_BUSY))
+		return;
+
+	t4_eth_rx(arg);
+
+	atomic_cmpset_32(&iq->state, IQS_BUSY, IQS_IDLE);
+}
+
+void
+t4_evt_rx(void *arg)
+{
+	struct sge_iq *iq = arg;
 	struct adapter *sc = iq->adapter;
 	struct rsp_ctrl *ctrl;
 	const struct rss_header *rss;
@@ -537,7 +568,7 @@ t4_intr_evt(void *arg)
 }
 
 void
-t4_intr_data(void *arg)
+t4_eth_rx(void *arg)
 {
 	struct sge_rxq *rxq = arg;
 	struct sge_iq *iq = arg;
@@ -1017,8 +1048,6 @@ alloc_iq_fl(struct port_info *pi, struct
 	if (pi == NULL)
 		pi = sc->port[0];
 
-	mtx_init(&iq->iq_lock, iq->lockname, NULL, MTX_DEF);
-
 	len = iq->qsize * iq->esize;
 	rc = alloc_ring(sc, len, &iq->desc_tag, &iq->desc_map, &iq->ba,
 	    (void **)&iq->desc);
@@ -1148,6 +1177,7 @@ alloc_iq_fl(struct port_info *pi, struct
 	}
 
 	/* Enable IQ interrupts */
+	atomic_store_rel_32(&iq->state, IQS_IDLE);
 	t4_write_reg(sc, MYPF_REG(A_SGE_PF_GTS), V_SEINTARM(iq->intr_params) |
 	    V_INGRESSQID(iq->cntxt_id));
 
@@ -1179,6 +1209,10 @@ free_iq_fl(struct port_info *pi, struct 
 			return (rc);
 		}
 		iq->flags &= ~IQ_STARTED;
+
+		/* Synchronize with the interrupt handler */
+		while (!atomic_cmpset_32(&iq->state, IQS_IDLE, IQS_DISABLED))
+			pause("iqfree", hz / 1000);
 	}
 
 	if (iq->flags & IQ_ALLOCATED) {
@@ -1196,9 +1230,6 @@ free_iq_fl(struct port_info *pi, struct 
 
 	free_ring(sc, iq->desc_tag, iq->desc_map, iq->ba, iq->desc);
 
-	if (mtx_initialized(&iq->iq_lock))
-		mtx_destroy(&iq->iq_lock);
-
 	bzero(iq, sizeof(*iq));
 
 	if (fl) {
@@ -1425,6 +1456,27 @@ free_txq(struct port_info *pi, struct sg
 	struct sge_eq *eq = &txq->eq;
 
 	if (eq->flags & (EQ_ALLOCATED | EQ_STARTED)) {
+
+		/*
+		 * Wait for the response to a credit flush if there's one
+		 * pending.  Clearing the flag tells handle_sge_egr_update or
+		 * cxgbe_txq_start (depending on how far the response has made
+		 * it) that they should ignore the response and wake up free_txq
+		 * instead.
+		 *
+		 * The interface has been marked down by the time we get here
+		 * (both IFF_UP and IFF_DRV_RUNNING cleared).  qflush has
+		 * emptied the tx buf_rings and we know nothing new is being
+		 * queued for tx so we don't have to worry about a new credit
+		 * flush request.
+		 */
+		TXQ_LOCK(txq);
+		if (eq->flags & EQ_CRFLUSHED) {
+			eq->flags &= ~EQ_CRFLUSHED;
+			msleep(txq, &eq->eq_lock, 0, "crflush", 0);
+		}
+		TXQ_UNLOCK(txq);
+
 		rc = -t4_eth_eq_free(sc, sc->mbox, sc->pf, 0, eq->cntxt_id);
 		if (rc != 0) {
 			device_printf(pi->dev,
@@ -2444,13 +2496,14 @@ handle_sge_egr_update(struct adapter *sc
 	struct port_info *pi;
 
 	txq = (void *)s->eqmap[qid - s->eq_start];
-
-	KASSERT(txq->eq.flags & EQ_CRFLUSHED,
-	    ("%s: tx queue %p not expecting an update.", __func__, txq));
-
-	pi = txq->ifp->if_softc;
-	taskqueue_enqueue(pi->tq, &txq->resume_tx);
-	txq->egr_update++;
+	TXQ_LOCK(txq);
+	if (txq->eq.flags & EQ_CRFLUSHED) {
+		pi = txq->ifp->if_softc;
+		taskqueue_enqueue(pi->tq, &txq->resume_tx);
+		txq->egr_update++;
+	} else
+		wakeup_one(txq);	/* txq is going away, wakeup free_txq */
+	TXQ_UNLOCK(txq);
 
 	return (0);
 }

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 07:07:29 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 592181065769;
	Fri, 15 Apr 2011 07:07:29 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 472DD8FC0A;
	Fri, 15 Apr 2011 07:07:29 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3F77TxR061607;
	Fri, 15 Apr 2011 07:07:29 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3F77TsC061605;
	Fri, 15 Apr 2011 07:07:29 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104150707.p3F77TsC061605@svn.freebsd.org>
From: Alexander Motin 
Date: Fri, 15 Apr 2011 07:07:29 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220650 - head/sys/cam/ata
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 07:07:29 -0000

Author: mav
Date: Fri Apr 15 07:07:29 2011
New Revision: 220650
URL: http://svn.freebsd.org/changeset/base/220650

Log:
  Make ada(4) driver put ATA disks into sleep state on suspend.
  
  Submitted by:	jkim (original version)

Modified:
  head/sys/cam/ata/ata_da.c

Modified: head/sys/cam/ata/ata_da.c
==============================================================================
--- head/sys/cam/ata/ata_da.c	Fri Apr 15 03:09:27 2011	(r220649)
+++ head/sys/cam/ata/ata_da.c	Fri Apr 15 07:07:29 2011	(r220650)
@@ -180,6 +180,8 @@ static void		adagetparams(struct cam_per
 				struct ccb_getdev *cgd);
 static timeout_t	adasendorderedtag;
 static void		adashutdown(void *arg, int howto);
+static void		adasuspend(void *arg);
+static void		adaresume(void *arg);
 
 #ifndef ADA_DEFAULT_TIMEOUT
 #define ADA_DEFAULT_TIMEOUT 30	/* Timeout in seconds */
@@ -197,6 +199,10 @@ static void		adashutdown(void *arg, int 
 #define	ADA_DEFAULT_SPINDOWN_SHUTDOWN	1
 #endif
 
+#ifndef	ADA_DEFAULT_SPINDOWN_SUSPEND
+#define	ADA_DEFAULT_SPINDOWN_SUSPEND	1
+#endif
+
 #ifndef	ADA_DEFAULT_WRITE_CACHE
 #define	ADA_DEFAULT_WRITE_CACHE	1
 #endif
@@ -213,6 +219,7 @@ static int ada_retry_count = ADA_DEFAULT
 static int ada_default_timeout = ADA_DEFAULT_TIMEOUT;
 static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED;
 static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOWN_SHUTDOWN;
+static int ada_spindown_suspend = ADA_DEFAULT_SPINDOWN_SUSPEND;
 static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE;
 
 SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0,
@@ -229,6 +236,9 @@ TUNABLE_INT("kern.cam.ada.ada_send_order
 SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RW,
            &ada_spindown_shutdown, 0, "Spin down upon shutdown");
 TUNABLE_INT("kern.cam.ada.spindown_shutdown", &ada_spindown_shutdown);
+SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_suspend, CTLFLAG_RW,
+           &ada_spindown_suspend, 0, "Spin down upon suspend");
+TUNABLE_INT("kern.cam.ada.spindown_suspend", &ada_spindown_suspend);
 SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RW,
            &ada_write_cache, 0, "Enable disk write cache");
 TUNABLE_INT("kern.cam.ada.write_cache", &ada_write_cache);
@@ -525,8 +535,14 @@ adainit(void)
 		       "due to status 0x%x!\n", status);
 	} else if (ada_send_ordered) {
 
-		/* Register our shutdown event handler */
-		if ((EVENTHANDLER_REGISTER(shutdown_post_sync, adashutdown, 
+		/* Register our event handlers */
+		if ((EVENTHANDLER_REGISTER(power_suspend, adasuspend,
+					   NULL, EVENTHANDLER_PRI_LAST)) == NULL)
+		    printf("adainit: power event registration failed!\n");
+		if ((EVENTHANDLER_REGISTER(power_resume, adaresume,
+					   NULL, EVENTHANDLER_PRI_LAST)) == NULL)
+		    printf("adainit: power event registration failed!\n");
+		if ((EVENTHANDLER_REGISTER(shutdown_post_sync, adashutdown,
 					   NULL, SHUTDOWN_PRI_DEFAULT)) == NULL)
 		    printf("adainit: shutdown event registration failed!\n");
 	}
@@ -1372,7 +1388,7 @@ adasendorderedtag(void *arg)
  * sync the disk cache to physical media.
  */
 static void
-adashutdown(void * arg, int howto)
+adaflush(void)
 {
 	struct cam_periph *periph;
 	struct ada_softc *softc;
@@ -1424,10 +1440,13 @@ adashutdown(void * arg, int howto)
 					 /*getcount_only*/0);
 		cam_periph_unlock(periph);
 	}
+}
 
-	if (ada_spindown_shutdown == 0 ||
-	    (howto & (RB_HALT | RB_POWEROFF)) == 0)
-		return;
+static void
+adaspindown(uint8_t cmd, int flags)
+{
+	struct cam_periph *periph;
+	struct ada_softc *softc;
 
 	TAILQ_FOREACH(periph, &adadriver.units, unit_links) {
 		union ccb ccb;
@@ -1454,13 +1473,13 @@ adashutdown(void * arg, int howto)
 		cam_fill_ataio(&ccb.ataio,
 				    1,
 				    adadone,
-				    CAM_DIR_NONE,
+				    CAM_DIR_NONE | flags,
 				    0,
 				    NULL,
 				    0,
 				    ada_default_timeout*1000);
 
-		ata_28bit_cmd(&ccb.ataio, ATA_STANDBY_IMMEDIATE, 0, 0, 0);
+		ata_28bit_cmd(&ccb.ataio, cmd, 0, 0, 0);
 		xpt_polled_action(&ccb);
 
 		if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
@@ -1476,4 +1495,60 @@ adashutdown(void * arg, int howto)
 	}
 }
 
+static void
+adashutdown(void *arg, int howto)
+{
+
+	adaflush();
+	if (ada_spindown_shutdown != 0 &&
+	    (howto & (RB_HALT | RB_POWEROFF)) != 0)
+		adaspindown(ATA_STANDBY_IMMEDIATE, 0);
+}
+
+static void
+adasuspend(void *arg)
+{
+
+	adaflush();
+	if (ada_spindown_suspend != 0)
+		adaspindown(ATA_SLEEP, CAM_DEV_QFREEZE);
+}
+
+static void
+adaresume(void *arg)
+{
+	struct cam_periph *periph;
+	struct ada_softc *softc;
+
+	if (ada_spindown_suspend == 0)
+		return;
+
+	TAILQ_FOREACH(periph, &adadriver.units, unit_links) {
+		cam_periph_lock(periph);
+		softc = (struct ada_softc *)periph->softc;
+		/*
+		 * We only spin-down the drive if it is capable of it..
+		 */
+		if ((softc->flags & ADA_FLAG_CAN_POWERMGT) == 0) {
+			cam_periph_unlock(periph);
+			continue;
+		}
+
+		if (bootverbose)
+			xpt_print(periph->path, "resume\n");
+
+		/*
+		 * Drop freeze taken due to CAM_DEV_QFREEZE flag set on
+		 * sleep request.
+		 */
+		cam_release_devq(periph->path,
+			 /*relsim_flags*/0,
+			 /*openings*/0,
+			 /*timeout*/0,
+			 /*getcount_only*/0);
+		
+		cam_periph_unlock(periph);
+	}
+}
+
 #endif /* _KERNEL */

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 08:27:12 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 95231106566B;
	Fri, 15 Apr 2011 08:27:12 +0000 (UTC)
	(envelope-from kostikbel@gmail.com)
Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200])
	by mx1.freebsd.org (Postfix) with ESMTP id 9946E8FC0A;
	Fri, 15 Apr 2011 08:27:11 +0000 (UTC)
Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua
	[10.1.1.148])
	by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p3F8R6Mw006835
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Fri, 15 Apr 2011 11:27:06 +0300 (EEST)
	(envelope-from kostikbel@gmail.com)
Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1])
	by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id
	p3F8R6EX081608; Fri, 15 Apr 2011 11:27:06 +0300 (EEST)
	(envelope-from kostikbel@gmail.com)
Received: (from kostik@localhost)
	by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p3F8R6BR081607; 
	Fri, 15 Apr 2011 11:27:06 +0300 (EEST)
	(envelope-from kostikbel@gmail.com)
X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to
	kostikbel@gmail.com using -f
Date: Fri, 15 Apr 2011 11:27:06 +0300
From: Kostik Belousov 
To: John Baldwin 
Message-ID: <20110415082706.GI48734@deviant.kiev.zoral.com.ua>
References: <201104101707.p3AH736T054347@svn.freebsd.org>
	<201104141713.28311.jhb@freebsd.org>
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="cW+P/jduATWpL925"
Content-Disposition: inline
In-Reply-To: <201104141713.28311.jhb@freebsd.org>
User-Agent: Mutt/1.4.2.3i
X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua
X-Virus-Status: Clean
X-Spam-Status: No, score=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,
	DNS_FROM_OPENWHOIS,FUZZY_CREDIT autolearn=no version=3.2.5
X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on
	skuns.kiev.zoral.com.ua
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org, trasz@freebsd.org
Subject: Re: svn commit: r220526 - head/sys/kern
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 08:27:12 -0000


--cW+P/jduATWpL925
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Apr 14, 2011 at 05:13:28PM -0400, John Baldwin wrote:
> On Sunday, April 10, 2011 1:07:03 pm Konstantin Belousov wrote:
> > Author: kib
> > Date: Sun Apr 10 17:07:02 2011
> > New Revision: 220526
> > URL: http://svn.freebsd.org/changeset/base/220526
> >=20
> > Log:
> >   Some callers of proc_reparent() already have the parent process locke=
d.
> >   Detect the situation and avoid process lock recursion.
> >  =20
> >   Reported by:	Fabian Keil 
> >=20
> > Modified:
> >   head/sys/kern/kern_exit.c
>=20
> Can we instead assert it is always held and fix callers that don't?  Usin=
g=20
> locked variables is messy and I'd rather avoid it when possible.  We alre=
ady=20
> require the caller to hold other locks for this operation.
>=20
I agree that this is ugly, and proper fix probably would be something else.
E.g. struct proc could grow another field that holds a pointer to the ucred
it is accounted for, and locked with some global lock.

--cW+P/jduATWpL925
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEARECAAYFAk2oAVoACgkQC3+MBN1Mb4ipJwCdGBm37JsjAiBc1EToMmI+b6Dp
czgAoMIsuLe4E8WTDYf8pVNiMKUC87D5
=cQRQ
-----END PGP SIGNATURE-----

--cW+P/jduATWpL925--

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 12:32:53 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1D3981065672;
	Fri, 15 Apr 2011 12:32:53 +0000 (UTC)
	(envelope-from gavin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0BE4D8FC0A;
	Fri, 15 Apr 2011 12:32:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FCWqI3069903;
	Fri, 15 Apr 2011 12:32:52 GMT (envelope-from gavin@svn.freebsd.org)
Received: (from gavin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FCWqXQ069901;
	Fri, 15 Apr 2011 12:32:52 GMT (envelope-from gavin@svn.freebsd.org)
Message-Id: <201104151232.p3FCWqXQ069901@svn.freebsd.org>
From: Gavin Atkinson 
Date: Fri, 15 Apr 2011 12:32:52 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220652 - head/sys/geom/part
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 12:32:53 -0000

Author: gavin
Date: Fri Apr 15 12:32:52 2011
New Revision: 220652
URL: http://svn.freebsd.org/changeset/base/220652

Log:
  Remove an incorrect be16toh() that prevented geom_part_apm from working on
  little-endian machines.
  
  Reviewed by:	marcel
  MFC after:	2 weeks

Modified:
  head/sys/geom/part/g_part_apm.c

Modified: head/sys/geom/part/g_part_apm.c
==============================================================================
--- head/sys/geom/part/g_part_apm.c	Fri Apr 15 10:33:20 2011	(r220651)
+++ head/sys/geom/part/g_part_apm.c	Fri Apr 15 12:32:52 2011	(r220652)
@@ -390,7 +390,7 @@ g_part_apm_probe(struct g_part_table *ba
 	buf = g_read_data(cp, 0L, pp->sectorsize, &error);
 	if (buf == NULL)
 		return (error);
-	if (be16dec(buf) == be16toh(APM_DDR_SIG)) {
+	if (be16dec(buf) == APM_DDR_SIG) {
 		/* Normal Apple DDR */
 		table->ddr.ddr_sig = be16dec(buf);
 		table->ddr.ddr_blksize = be16dec(buf + 2);

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 13:37:44 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1DCBB1065673;
	Fri, 15 Apr 2011 13:37:44 +0000 (UTC)
	(envelope-from philip@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0B0A98FC15;
	Fri, 15 Apr 2011 13:37:44 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FDbhZt071348;
	Fri, 15 Apr 2011 13:37:43 GMT (envelope-from philip@svn.freebsd.org)
Received: (from philip@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FDbhgW071344;
	Fri, 15 Apr 2011 13:37:43 GMT (envelope-from philip@svn.freebsd.org)
Message-Id: <201104151337.p3FDbhgW071344@svn.freebsd.org>
From: Philip Paeps 
Date: Fri, 15 Apr 2011 13:37:43 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220653 - in head/sys: . arm/mv/orion boot/fdt/dts
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 13:37:44 -0000

Author: philip
Date: Fri Apr 15 13:37:43 2011
New Revision: 220653
URL: http://svn.freebsd.org/changeset/base/220653

Log:
  Add basic support for the Marvell Orion TS-7800.
  
  Submitted by:	Kristof Provost 

Added:
  head/sys/arm/mv/orion/files.ts7800   (contents, props changed)
  head/sys/arm/mv/orion/std.ts7800   (contents, props changed)
  head/sys/boot/fdt/dts/ts7800.dts   (contents, props changed)
  head/sys/files.ts7800   (contents, props changed)

Added: head/sys/arm/mv/orion/files.ts7800
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/mv/orion/files.ts7800	Fri Apr 15 13:37:43 2011	(r220653)
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+arm/mv/orion/orion.c	standard
+

Added: head/sys/arm/mv/orion/std.ts7800
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/mv/orion/std.ts7800	Fri Apr 15 13:37:43 2011	(r220653)
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+include	"../mv/std.mv"
+files	"../mv/orion/files.ts7800"
+
+makeoptions	KERNPHYSADDR=0x00900000
+makeoptions	KERNVIRTADDR=0xc0900000
+
+options		KERNPHYSADDR=0x00900000
+options 	KERNVIRTADDR=0xc0900000
+options		PHYSADDR=0x00000000
+options		STARTUP_PAGETABLE_ADDR=0x00100000
+options   LOADERRAMADDR=0x00000000
+options   FLASHADDR=0x00008000
+

Added: head/sys/boot/fdt/dts/ts7800.dts
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/fdt/dts/ts7800.dts	Fri Apr 15 13:37:43 2011	(r220653)
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2010 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Technologic Systems TS-7800 Device Tree Source.
+ *
+ * $FreeBSD$
+ */
+
+/dts-v1/;
+
+/ {
+	model = "mrvl,TS-7800";
+	compatible = "DB-88F5182-BP", "DB-88F5182-BP-A";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	aliases {
+		ethernet0 = &mge0;
+		serial0 = &serial0;
+		serial1 = &serial1;
+		mpp = &MPP;
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "ARM,88FR531";
+			reg = <0x0>;
+			d-cache-line-size = <32>;	// 32 bytes
+			i-cache-line-size = <32>;	// 32 bytes
+			d-cache-size = <0x8000>;	// L1, 32K
+			i-cache-size = <0x8000>;	// L1, 32K
+			timebase-frequency = <0>;
+			bus-frequency = <0>;
+			clock-frequency = <0>;
+		};
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x0 0x08000000>;		// 128M at 0x0
+	};
+
+	localbus@f1000000 {
+		#address-cells = <2>;
+		#size-cells = <1>;
+		compatible = "mrvl,lbc";
+
+		/* This reflects CPU decode windows setup. */
+		ranges = <0x0 0x0f 0xf9300000 0x00100000
+			  0x1 0x1e 0xfa000000 0x00100000
+			  0x2 0x1d 0xfa100000 0x02000000>;
+	};
+
+	soc88f5182@f1000000 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "simple-bus";
+		ranges = <0x0 0xf1000000 0x00100000>;
+		bus-frequency = <0>;
+
+		PIC: pic@20200 {
+			interrupt-controller;
+			#address-cells = <0>;
+			#interrupt-cells = <1>;
+			reg = <0x20200 0x3c>;
+			compatible = "mrvl,pic";
+		};
+
+		timer@20300 {
+			compatible = "mrvl,timer";
+			reg = <0x20300 0x30>;
+			interrupts = <0>;
+			interrupt-parent = <&PIC>;
+			mrvl,has-wdt;
+		};
+
+		MPP: mpp@10000 {
+			#pin-cells = <2>;
+			compatible = "mrvl,mpp";
+			reg = <0x10000 0x54>;
+			pin-count = <20>;
+			pin-map = <
+				16 0		/* MPP[16]: UA1_RXD */
+				17 0		/* MPP[17]: UA1_TXD */
+				19 0 >;		/* MPP[19]: UA1_RTS */
+		};
+
+		mge0: ethernet@72000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
+			model = "V1";
+			compatible = "mrvl,ge";
+			reg = <0x72000 0x2000>;
+			ranges = <0x0 0x72000 0x2000>;
+			local-mac-address = [ 00 00 00 00 00 00 ];
+			interrupts = <18 19 20 21 22>;
+			interrupt-parent = <&PIC>;
+
+			phy-handle = <&phy0>;
+
+			mdio@0 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "mrvl,mdio";
+
+				phy0: ethernet-phy@0 {
+					reg = <0x0>;
+				};
+			};
+		};
+
+		serial0: serial@12000 {
+			compatible = "ns16550";
+			reg = <0x12000 0x20>;
+			reg-shift = <2>;
+			clock-frequency = <0>;
+			interrupts = <3>;
+			interrupt-parent = <&PIC>;
+		};
+
+		serial1: serial@12100 {
+			compatible = "ns16550";
+			reg = <0x12100 0x20>;
+			reg-shift = <2>;
+			clock-frequency = <0>;
+			interrupts = <4>;
+			interrupt-parent = <&PIC>;
+		};
+	};
+
+	chosen {
+		stdin = "serial0";
+		stdout = "serial0";
+	};
+};

Added: head/sys/files.ts7800
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/files.ts7800	Fri Apr 15 13:37:43 2011	(r220653)
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+arm/mv/orion/orion.c	standard
+

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 15:14:58 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D25C21065675;
	Fri, 15 Apr 2011 15:14:58 +0000 (UTC)
	(envelope-from jilles@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A6A388FC18;
	Fri, 15 Apr 2011 15:14:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FFEw8K073524;
	Fri, 15 Apr 2011 15:14:58 GMT (envelope-from jilles@svn.freebsd.org)
Received: (from jilles@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FFEwkn073523;
	Fri, 15 Apr 2011 15:14:58 GMT (envelope-from jilles@svn.freebsd.org)
Message-Id: <201104151514.p3FFEwkn073523@svn.freebsd.org>
From: Jilles Tjoelker 
Date: Fri, 15 Apr 2011 15:14:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220654 - head/tools/regression/bin/sh/builtins
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 15:14:58 -0000

Author: jilles
Date: Fri Apr 15 15:14:58 2011
New Revision: 220654
URL: http://svn.freebsd.org/changeset/base/220654

Log:
  sh: Add test for bin/56147.

Added:
  head/tools/regression/bin/sh/builtins/case4.0   (contents, props changed)

Added: head/tools/regression/bin/sh/builtins/case4.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/case4.0	Fri Apr 15 15:14:58 2011	(r220654)
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+set -- "*"
+case x in
+"$1") echo failed ;;
+esac

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 15:26:06 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0D297106564A;
	Fri, 15 Apr 2011 15:26:06 +0000 (UTC)
	(envelope-from jilles@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id EFD268FC16;
	Fri, 15 Apr 2011 15:26:05 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FFQ5Xq073803;
	Fri, 15 Apr 2011 15:26:05 GMT (envelope-from jilles@svn.freebsd.org)
Received: (from jilles@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FFQ5oU073802;
	Fri, 15 Apr 2011 15:26:05 GMT (envelope-from jilles@svn.freebsd.org)
Message-Id: <201104151526.p3FFQ5oU073802@svn.freebsd.org>
From: Jilles Tjoelker 
Date: Fri, 15 Apr 2011 15:26:05 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220655 - head/tools/regression/bin/sh/expansion
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 15:26:06 -0000

Author: jilles
Date: Fri Apr 15 15:26:05 2011
New Revision: 220655
URL: http://svn.freebsd.org/changeset/base/220655

Log:
  sh: Add test for obscure and ambiguous ${#?}.

Added:
  head/tools/regression/bin/sh/expansion/length4.0   (contents, props changed)

Added: head/tools/regression/bin/sh/expansion/length4.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/expansion/length4.0	Fri Apr 15 15:26:05 2011	(r220655)
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+# The construct ${#?} is ambiguous in POSIX.1-2008: it could be the length
+# of $? or it could be $# giving an error in the (impossible) case that it
+# is not set.
+# We use the former interpretation; it seems more useful.
+
+:
+[ "${#?}" = 1 ] || echo '${#?} wrong'
+(exit 42)
+[ "${#?}" = 2 ] || echo '${#?} wrong'

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 15:33:24 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DFF8E1065672;
	Fri, 15 Apr 2011 15:33:24 +0000 (UTC)
	(envelope-from jilles@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CE63B8FC16;
	Fri, 15 Apr 2011 15:33:24 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FFXOZs074007;
	Fri, 15 Apr 2011 15:33:24 GMT (envelope-from jilles@svn.freebsd.org)
Received: (from jilles@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FFXOAp074006;
	Fri, 15 Apr 2011 15:33:24 GMT (envelope-from jilles@svn.freebsd.org)
Message-Id: <201104151533.p3FFXOAp074006@svn.freebsd.org>
From: Jilles Tjoelker 
Date: Fri, 15 Apr 2011 15:33:24 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220656 - head/tools/regression/bin/sh/expansion
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 15:33:25 -0000

Author: jilles
Date: Fri Apr 15 15:33:24 2011
New Revision: 220656
URL: http://svn.freebsd.org/changeset/base/220656

Log:
  sh: Add test for bin/12137.

Added:
  head/tools/regression/bin/sh/expansion/length5.0   (contents, props changed)

Added: head/tools/regression/bin/sh/expansion/length5.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/expansion/length5.0	Fri Apr 15 15:33:24 2011	(r220656)
@@ -0,0 +1,27 @@
+# $FreeBSD$
+
+unset LC_ALL
+LC_CTYPE=en_US.ISO8859-1
+export LC_CTYPE
+
+e=
+for i in 0 1 2 3; do
+	for j in 0 1 2 3 4 5 6 7; do
+		for k in 0 1 2 3 4 5 6 7; do
+			case $i$j$k in
+			000) continue ;;
+			esac
+			e="$e\\$i$j$k"
+		done
+	done
+done
+ee=`printf "$e"`
+[ ${#ee} = 255 ] || echo bad 1
+[ "${#ee}" = 255 ] || echo bad 2
+[ $((${#ee})) = 255 ] || echo bad 3
+[ "$((${#ee}))" = 255 ] || echo bad 4
+set -- "$ee"
+[ ${#1} = 255 ] || echo bad 5
+[ "${#1}" = 255 ] || echo bad 6
+[ $((${#1})) = 255 ] || echo bad 7
+[ "$((${#1}))" = 255 ] || echo bad 8

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 16:40:32 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 31E221065673;
	Fri, 15 Apr 2011 16:40:32 +0000 (UTC) (envelope-from mav@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 205D18FC0A;
	Fri, 15 Apr 2011 16:40:32 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FGeWFe075400;
	Fri, 15 Apr 2011 16:40:32 GMT (envelope-from mav@svn.freebsd.org)
Received: (from mav@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FGeWYh075397;
	Fri, 15 Apr 2011 16:40:32 GMT (envelope-from mav@svn.freebsd.org)
Message-Id: <201104151640.p3FGeWYh075397@svn.freebsd.org>
From: Alexander Motin 
Date: Fri, 15 Apr 2011 16:40:31 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220657 - head/sys/dev/ahci
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 16:40:32 -0000

Author: mav
Date: Fri Apr 15 16:40:31 2011
New Revision: 220657
URL: http://svn.freebsd.org/changeset/base/220657

Log:
  Some changes around hot-plug and interface power-management:
   - use ATA_SE_EXCHANGED (SError.DIAG.X) bit to detect hot-plug events when
  power-management enabled and ATA_SE_PHY_CHANGED (SError.DIAG.N) can't be
  trusted;
   - on controllers supporting staggered spin-up (SS) put unused channels
  into Listen state instead of Off. It should still save some power, but
  allow plug-in events to be detected;
   - on controllers supporting cold presence detection (CPD), when power
  management enabled, use CPD events to detect hot-plug in addition to PHY
  events.

Modified:
  head/sys/dev/ahci/ahci.c
  head/sys/dev/ahci/ahci.h

Modified: head/sys/dev/ahci/ahci.c
==============================================================================
--- head/sys/dev/ahci/ahci.c	Fri Apr 15 15:33:24 2011	(r220656)
+++ head/sys/dev/ahci/ahci.c	Fri Apr 15 16:40:31 2011	(r220657)
@@ -1272,34 +1272,66 @@ ahci_slotsfree(device_t dev)
 	}
 }
 
-static void
+static int
 ahci_phy_check_events(device_t dev, u_int32_t serr)
 {
 	struct ahci_channel *ch = device_get_softc(dev);
 
-	if ((serr & ATA_SE_PHY_CHANGED) && (ch->pm_level == 0)) {
+	if (((ch->pm_level == 0) && (serr & ATA_SE_PHY_CHANGED)) ||
+	    ((ch->pm_level != 0 || ch->listening) && (serr & ATA_SE_EXCHANGED))) {
 		u_int32_t status = ATA_INL(ch->r_mem, AHCI_P_SSTS);
 		union ccb *ccb;
 
 		if (bootverbose) {
-			if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) &&
-			    ((status & ATA_SS_SPD_MASK) != ATA_SS_SPD_NO_SPEED) &&
-			    ((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE)) {
+			if ((status & ATA_SS_DET_MASK) != ATA_SS_DET_NO_DEVICE)
 				device_printf(dev, "CONNECT requested\n");
-			} else
+			else
 				device_printf(dev, "DISCONNECT requested\n");
 		}
 		ahci_reset(dev);
 		if ((ccb = xpt_alloc_ccb_nowait()) == NULL)
-			return;
+			return (0);
 		if (xpt_create_path(&ccb->ccb_h.path, NULL,
 		    cam_sim_path(ch->sim),
 		    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
 			xpt_free_ccb(ccb);
-			return;
+			return (0);
 		}
 		xpt_rescan(ccb);
+		return (1);
 	}
+	return (0);
+}
+
+static void
+ahci_cpd_check_events(device_t dev)
+{
+	struct ahci_channel *ch = device_get_softc(dev);
+	u_int32_t status;
+	union ccb *ccb;
+
+	if (ch->pm_level == 0)
+		return;
+
+	status = ATA_INL(ch->r_mem, AHCI_P_CMD);
+	if ((status & AHCI_P_CMD_CPD) == 0)
+		return;
+
+	if (bootverbose) {
+		if (status & AHCI_P_CMD_CPS) {
+			device_printf(dev, "COLD CONNECT requested\n");
+		} else
+			device_printf(dev, "COLD DISCONNECT requested\n");
+	}
+	ahci_reset(dev);
+	if ((ccb = xpt_alloc_ccb_nowait()) == NULL)
+		return;
+	if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(ch->sim),
+	    CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
+		xpt_free_ccb(ccb);
+		return;
+	}
+	xpt_rescan(ccb);
 }
 
 static void
@@ -1359,7 +1391,7 @@ ahci_ch_intr(void *data)
 	struct ahci_channel *ch = device_get_softc(dev);
 	uint32_t istatus, sstatus, cstatus, serr = 0, sntf = 0, ok, err;
 	enum ahci_err_type et;
-	int i, ccs, port;
+	int i, ccs, port, reset = 0;
 
 	/* Read and clear interrupt statuses. */
 	istatus = ATA_INL(ch->r_mem, AHCI_P_IS);
@@ -1395,9 +1427,12 @@ ahci_ch_intr(void *data)
 		serr = ATA_INL(ch->r_mem, AHCI_P_SERR);
 		if (serr) {
 			ATA_OUTL(ch->r_mem, AHCI_P_SERR, serr);
-			ahci_phy_check_events(dev, serr);
+			reset = ahci_phy_check_events(dev, serr);
 		}
 	}
+	/* Process cold presence detection events */
+	if ((istatus & AHCI_P_IX_CPD) && !reset)
+		ahci_cpd_check_events(dev);
 	/* Process command errors */
 	if (istatus & (AHCI_P_IX_OF | AHCI_P_IX_IF |
 	    AHCI_P_IX_HBD | AHCI_P_IX_HBF | AHCI_P_IX_TFE)) {
@@ -2446,7 +2481,8 @@ ahci_reset(device_t dev)
 		ch->devices = 0;
 		/* Enable wanted port interrupts */
 		ATA_OUTL(ch->r_mem, AHCI_P_IE,
-		    (AHCI_P_IX_CPD | AHCI_P_IX_PRC | AHCI_P_IX_PC));
+		    (((ch->pm_level != 0) ? AHCI_P_IX_CPD | AHCI_P_IX_MP : 0) |
+		     AHCI_P_IX_PRC | AHCI_P_IX_PC));
 		xpt_release_simq(ch->sim, TRUE);
 		return;
 	}
@@ -2463,9 +2499,10 @@ ahci_reset(device_t dev)
 	ch->devices = 1;
 	/* Enable wanted port interrupts */
 	ATA_OUTL(ch->r_mem, AHCI_P_IE,
-	     (AHCI_P_IX_CPD | AHCI_P_IX_TFE | AHCI_P_IX_HBF |
+	     (((ch->pm_level != 0) ? AHCI_P_IX_CPD | AHCI_P_IX_MP : 0) |
+	      AHCI_P_IX_TFE | AHCI_P_IX_HBF |
 	      AHCI_P_IX_HBD | AHCI_P_IX_IF | AHCI_P_IX_OF |
-	      ((ch->pm_level == 0) ? AHCI_P_IX_PRC | AHCI_P_IX_PC : 0) |
+	      ((ch->pm_level == 0) ? AHCI_P_IX_PRC : 0) | AHCI_P_IX_PC |
 	      AHCI_P_IX_DP | AHCI_P_IX_UF | (ctlr->ccc ? 0 : AHCI_P_IX_SDB) |
 	      AHCI_P_IX_DS | AHCI_P_IX_PS | (ctlr->ccc ? 0 : AHCI_P_IX_DHR)));
 	if (ch->resetting)
@@ -2570,6 +2607,12 @@ ahci_sata_phy_reset(device_t dev)
 	int sata_rev;
 	uint32_t val;
 
+	if (ch->listening) {
+		val = ATA_INL(ch->r_mem, AHCI_P_CMD);
+		val |= AHCI_P_CMD_SUD;
+		ATA_OUTL(ch->r_mem, AHCI_P_CMD, val);
+		ch->listening = 0;
+	}
 	sata_rev = ch->user[ch->pm_present ? 15 : 0].revision;
 	if (sata_rev == 1)
 		val = ATA_SC_SPD_SPEED_GEN1;
@@ -2588,7 +2631,12 @@ ahci_sata_phy_reset(device_t dev)
 	    (ATA_SC_IPM_DIS_PARTIAL | ATA_SC_IPM_DIS_SLUMBER)));
 	DELAY(5000);
 	if (!ahci_sata_connect(ch)) {
-		if (ch->pm_level > 0)
+		if (ch->caps & AHCI_CAP_SSS) {
+			val = ATA_INL(ch->r_mem, AHCI_P_CMD);
+			val &= ~AHCI_P_CMD_SUD;
+			ATA_OUTL(ch->r_mem, AHCI_P_CMD, val);
+			ch->listening = 1;
+		} else if (ch->pm_level > 0)
 			ATA_OUTL(ch->r_mem, AHCI_P_SCTL, ATA_SC_DET_DISABLE);
 		return (0);
 	}

Modified: head/sys/dev/ahci/ahci.h
==============================================================================
--- head/sys/dev/ahci/ahci.h	Fri Apr 15 15:33:24 2011	(r220656)
+++ head/sys/dev/ahci/ahci.h	Fri Apr 15 16:40:31 2011	(r220657)
@@ -118,6 +118,7 @@
 #define         ATA_SE_LINKSEQ_ERR      0x00800000
 #define         ATA_SE_TRANSPORT_ERR    0x01000000
 #define         ATA_SE_UNKNOWN_FIS      0x02000000
+#define         ATA_SE_EXCHANGED        0x04000000
 
 #define ATA_SCONTROL                    15
 #define         ATA_SC_DET_MASK         0x0000000f
@@ -221,7 +222,7 @@
 #define         AHCI_P_IX_UF        0x00000010
 #define         AHCI_P_IX_DP        0x00000020
 #define         AHCI_P_IX_PC        0x00000040
-#define         AHCI_P_IX_DI        0x00000080
+#define         AHCI_P_IX_MP        0x00000080
 
 #define         AHCI_P_IX_PRC       0x00400000
 #define         AHCI_P_IX_IPM       0x00800000
@@ -413,6 +414,7 @@ struct ahci_channel {
 	int			lastslot;	/* Last used slot */
 	int			taggedtarget;	/* Last tagged target */
 	int			resetting;	/* Hard-reset in progress. */
+	int			listening;	/* SUD bit is cleared. */
 	union ccb		*frozen;	/* Frozen command */
 	struct callout		pm_timer;	/* Power management events */
 	struct callout		reset_timer;	/* Hard-reset timeout */

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 16:50:37 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 95FE0106564A;
	Fri, 15 Apr 2011 16:50:37 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6A8D28FC0C;
	Fri, 15 Apr 2011 16:50:37 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FGobho075696;
	Fri, 15 Apr 2011 16:50:37 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FGobQF075693;
	Fri, 15 Apr 2011 16:50:37 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104151650.p3FGobQF075693@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Fri, 15 Apr 2011 16:50:37 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220659 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 16:50:37 -0000

Author: bschmidt
Date: Fri Apr 15 16:50:37 2011
New Revision: 220659
URL: http://svn.freebsd.org/changeset/base/220659

Log:
  Don't timeout when stopping DMA channels.
  
  Obtained from:	OpenBSD

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnreg.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Fri Apr 15 16:44:04 2011	(r220658)
+++ head/sys/dev/iwn/if_iwn.c	Fri Apr 15 16:50:37 2011	(r220659)
@@ -4003,7 +4003,7 @@ iwn4965_get_temperature(struct iwn_softc
 		return 0;
 
 	/* Sign-extend 23-bit R4 value to 32-bit. */
-	r4 = (r4 << 8) >> 8;
+	r4 = ((r4 & 0xffffff) ^ 0x800000) - 0x800000;
 	/* Compute temperature in Kelvin. */
 	temp = (259 * (r4 - r2)) / (r3 - r1);
 	temp = (temp * 97) / 100 + 8;
@@ -6283,7 +6283,6 @@ static void
 iwn_hw_stop(struct iwn_softc *sc)
 {
 	const struct iwn_hal *hal = sc->sc_hal;
-	uint32_t tmp;
 	int chnl, qid, ntries;
 
 	IWN_WRITE(sc, IWN_RESET, IWN_RESET_NEVO);
@@ -6305,8 +6304,7 @@ iwn_hw_stop(struct iwn_softc *sc)
 		for (chnl = 0; chnl < hal->ndmachnls; chnl++) {
 			IWN_WRITE(sc, IWN_FH_TX_CONFIG(chnl), 0);
 			for (ntries = 0; ntries < 200; ntries++) {
-				tmp = IWN_READ(sc, IWN_FH_TX_STATUS);
-				if ((tmp & IWN_FH_TX_STATUS_IDLE(chnl)) ==
+				if (IWN_READ(sc, IWN_FH_TX_STATUS) &
 				    IWN_FH_TX_STATUS_IDLE(chnl))
 					break;
 				DELAY(10);

Modified: head/sys/dev/iwn/if_iwnreg.h
==============================================================================
--- head/sys/dev/iwn/if_iwnreg.h	Fri Apr 15 16:44:04 2011	(r220658)
+++ head/sys/dev/iwn/if_iwnreg.h	Fri Apr 15 16:50:37 2011	(r220659)
@@ -283,8 +283,7 @@
 #define IWN_FH_TX_CHICKEN_SCHED_RETRY	(1 << 1)
 
 /* Possible flags for register IWN_FH_TX_STATUS. */
-#define IWN_FH_TX_STATUS_IDLE(chnl)					\
-	(1 << ((chnl) + 24) | 1 << ((chnl) + 16))
+#define IWN_FH_TX_STATUS_IDLE(chnl)	(1 << ((chnl) + 16))
 
 /* Possible flags for register IWN_FH_RX_CONFIG. */
 #define IWN_FH_RX_CONFIG_ENA		(1 << 31)

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 16:55:45 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E3E14106566B;
	Fri, 15 Apr 2011 16:55:45 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D30408FC16;
	Fri, 15 Apr 2011 16:55:45 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FGtjjn075910;
	Fri, 15 Apr 2011 16:55:45 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FGtjAI075908;
	Fri, 15 Apr 2011 16:55:45 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104151655.p3FGtjAI075908@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Fri, 15 Apr 2011 16:55:45 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220660 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 16:55:46 -0000

Author: bschmidt
Date: Fri Apr 15 16:55:45 2011
New Revision: 220660
URL: http://svn.freebsd.org/changeset/base/220660

Log:
  Only handle beacon misses while in RUN state and not scanning.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Fri Apr 15 16:50:37 2011	(r220659)
+++ head/sys/dev/iwn/if_iwn.c	Fri Apr 15 16:55:45 2011	(r220660)
@@ -2463,23 +2463,22 @@ iwn_notif_intr(struct iwn_softc *sc)
 			    BUS_DMASYNC_POSTREAD);
 			misses = le32toh(miss->consecutive);
 
-			/* XXX not sure why we're notified w/ zero */
-			if (misses == 0)
-				break;
 			DPRINTF(sc, IWN_DEBUG_STATE,
 			    "%s: beacons missed %d/%d\n", __func__,
 			    misses, le32toh(miss->total));
-
 			/*
 			 * If more than 5 consecutive beacons are missed,
 			 * reinitialize the sensitivity state machine.
 			 */
-			if (vap->iv_state == IEEE80211_S_RUN && misses > 5)
-				(void) iwn_init_sensitivity(sc);
-			if (misses >= vap->iv_bmissthreshold) {
-				IWN_UNLOCK(sc);
-				ieee80211_beacon_miss(ic);
-				IWN_LOCK(sc);
+			if (vap->iv_state == IEEE80211_S_RUN &&
+			    (ic->ic_flags & IEEE80211_F_SCAN) != 0) {
+				if (misses > 5)
+					(void)iwn_init_sensitivity(sc);
+				if (misses >= vap->iv_bmissthreshold) {
+					IWN_UNLOCK(sc);
+					ieee80211_beacon_miss(ic);
+					IWN_LOCK(sc);
+				}
 			}
 			break;
 		}

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 16:59:57 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 503F5106564A;
	Fri, 15 Apr 2011 16:59:57 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3EFA18FC08;
	Fri, 15 Apr 2011 16:59:57 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FGxvlD076031;
	Fri, 15 Apr 2011 16:59:57 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FGxvOY076029;
	Fri, 15 Apr 2011 16:59:57 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104151659.p3FGxvOY076029@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Fri, 15 Apr 2011 16:59:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220661 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 16:59:57 -0000

Author: bschmidt
Date: Fri Apr 15 16:59:56 2011
New Revision: 220661
URL: http://svn.freebsd.org/changeset/base/220661

Log:
  Fixes for firmware handling:
  - there is a local variable for sc->fw_dma, use that instead
  - OpenBSD uses 5*hz to wait for firmware to be loaded
  - in case the firmware module contains invalid data, actually release it

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Fri Apr 15 16:55:45 2011	(r220660)
+++ head/sys/dev/iwn/if_iwn.c	Fri Apr 15 16:59:56 2011	(r220661)
@@ -5629,10 +5629,10 @@ iwn4965_load_firmware(struct iwn_softc *
 
 	/* Copy initialization sections into pre-allocated DMA-safe memory. */
 	memcpy(dma->vaddr, fw->init.data, fw->init.datasz);
-	bus_dmamap_sync(sc->fw_dma.tag, dma->map, BUS_DMASYNC_PREWRITE);
+	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
 	memcpy(dma->vaddr + IWN4965_FW_DATA_MAXSZ,
 	    fw->init.text, fw->init.textsz);
-	bus_dmamap_sync(sc->fw_dma.tag, dma->map, BUS_DMASYNC_PREWRITE);
+	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
 
 	/* Tell adapter where to find initialization sections. */
 	error = iwn_nic_lock(sc);
@@ -5670,10 +5670,10 @@ iwn4965_load_firmware(struct iwn_softc *
 
 	/* Copy runtime sections into pre-allocated DMA-safe memory. */
 	memcpy(dma->vaddr, fw->main.data, fw->main.datasz);
-	bus_dmamap_sync(sc->fw_dma.tag, dma->map, BUS_DMASYNC_PREWRITE);
+	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
 	memcpy(dma->vaddr + IWN4965_FW_DATA_MAXSZ,
 	    fw->main.text, fw->main.textsz);
-	bus_dmamap_sync(sc->fw_dma.tag, dma->map, BUS_DMASYNC_PREWRITE);
+	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
 
 	/* Tell adapter where to find runtime sections. */
 	error = iwn_nic_lock(sc);
@@ -5700,7 +5700,7 @@ iwn5000_load_firmware_section(struct iwn
 
 	/* Copy firmware section into pre-allocated DMA-safe memory. */
 	memcpy(dma->vaddr, section, size);
-	bus_dmamap_sync(sc->fw_dma.tag, dma->map, BUS_DMASYNC_PREWRITE);
+	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
 
 	error = iwn_nic_lock(sc);
 	if (error != 0)
@@ -5726,7 +5726,7 @@ iwn5000_load_firmware_section(struct iwn
 	iwn_nic_unlock(sc);
 
 	/* Wait at most five seconds for FH DMA transfer to complete. */
-	return msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", hz);
+	return msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", 5 * hz);
 }
 
 static int
@@ -5771,7 +5771,7 @@ iwn_read_firmware_leg(struct iwn_softc *
 	size_t hdrlen = 24;
 	uint32_t rev;
 
-	ptr = (const uint32_t *)sc->fw_fp->data;
+	ptr = (const uint32_t *)fw->data;
 	rev = le32toh(*ptr++);
 
 	/* Check firmware API version. */
@@ -5819,7 +5819,7 @@ iwn_read_firmware_leg(struct iwn_softc *
 /*
  * Extract text and data sections from a TLV firmware image.
  */
-int
+static int
 iwn_read_firmware_tlv(struct iwn_softc *sc, struct iwn_fw_info *fw,
     uint16_t alt)
 {
@@ -5931,6 +5931,8 @@ iwn_read_firmware(struct iwn_softc *sc)
 		device_printf(sc->sc_dev,
 		    "%s: firmware file too short: %zu bytes\n",
 		    __func__, fw->size);
+		firmware_put(sc->fw_fp, FIRMWARE_UNLOAD);
+		sc->fw_fp = NULL;
 		return EINVAL;
 	}
 
@@ -5942,6 +5944,8 @@ iwn_read_firmware(struct iwn_softc *sc)
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not read firmware sections\n", __func__);
+		firmware_put(sc->fw_fp, FIRMWARE_UNLOAD);
+		sc->fw_fp = NULL;
 		return error;
 	}
 
@@ -5954,6 +5958,8 @@ iwn_read_firmware(struct iwn_softc *sc)
 	    (fw->boot.textsz & 3) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: firmware sections too large\n", __func__);
+		firmware_put(sc->fw_fp, FIRMWARE_UNLOAD);
+		sc->fw_fp = NULL;
 		return EINVAL;
 	}
 

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 17:01:18 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4B227106564A;
	Fri, 15 Apr 2011 17:01:18 +0000 (UTC)
	(envelope-from kostikbel@gmail.com)
Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200])
	by mx1.freebsd.org (Postfix) with ESMTP id 0F3438FC16;
	Fri, 15 Apr 2011 17:01:16 +0000 (UTC)
Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua
	[10.1.1.148])
	by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p3FH10e5047717
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Fri, 15 Apr 2011 20:01:00 +0300 (EEST)
	(envelope-from kostikbel@gmail.com)
Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1])
	by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id
	p3FH10Th002829; Fri, 15 Apr 2011 20:01:00 +0300 (EEST)
	(envelope-from kostikbel@gmail.com)
Received: (from kostik@localhost)
	by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id p3FH10or002828; 
	Fri, 15 Apr 2011 20:01:00 +0300 (EEST)
	(envelope-from kostikbel@gmail.com)
X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to
	kostikbel@gmail.com using -f
Date: Fri, 15 Apr 2011 20:01:00 +0300
From: Kostik Belousov 
To: Attilio Rao 
Message-ID: <20110415170100.GM48734@deviant.kiev.zoral.com.ua>
References: <201104101707.p3AH736T054347@svn.freebsd.org>
	<201104141713.28311.jhb@freebsd.org>
	<20110415082706.GI48734@deviant.kiev.zoral.com.ua>
	
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="Rex5+51txc1ort/q"
Content-Disposition: inline
In-Reply-To: 
User-Agent: Mutt/1.4.2.3i
X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua
X-Virus-Status: Clean
X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,
	DNS_FROM_OPENWHOIS autolearn=no version=3.2.5
X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on
	skuns.kiev.zoral.com.ua
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org, trasz@freebsd.org,
	John Baldwin 
Subject: Re: svn commit: r220526 - head/sys/kern
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 17:01:18 -0000


--Rex5+51txc1ort/q
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Apr 15, 2011 at 12:46:18PM -0400, Attilio Rao wrote:
> 2011/4/15 Kostik Belousov :
> > On Thu, Apr 14, 2011 at 05:13:28PM -0400, John Baldwin wrote:
> >> On Sunday, April 10, 2011 1:07:03 pm Konstantin Belousov wrote:
> >> > Author: kib
> >> > Date: Sun Apr 10 17:07:02 2011
> >> > New Revision: 220526
> >> > URL: http://svn.freebsd.org/changeset/base/220526
> >> >
> >> > Log:
> >> > =9A Some callers of proc_reparent() already have the parent process =
locked.
> >> > =9A Detect the situation and avoid process lock recursion.
> >> >
> >> > =9A Reported by: =9A =9A =9AFabian Keil 
> >> >
> >> > Modified:
> >> > =9A head/sys/kern/kern_exit.c
> >>
> >> Can we instead assert it is always held and fix callers that don't? =
=9AUsing
> >> locked variables is messy and I'd rather avoid it when possible. =9AWe=
 already
> >> require the caller to hold other locks for this operation.
> >>
> > I agree that this is ugly, and proper fix probably would be something e=
lse.
> > E.g. struct proc could grow another field that holds a pointer to the u=
cred
> > it is accounted for, and locked with some global lock.
>=20
> As you already hold allproc_lock the process can't be distructed, then
> as I already pointed out to Tomasz, it should alright to just bump the
> refcount for cred and pass down, I guess.
I do not see how allproc_lock is useful there, unless setuid(2) and
other syscalls, which change the process credentials, are protected by
the same lock. The issue there is in accounting for wrong container.
You want to avoid a race between dereferencing stale p_ucred and the
process moving to another container.

--Rex5+51txc1ort/q
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEARECAAYFAk2oecsACgkQC3+MBN1Mb4i1XwCeIF9qTEUMAeJyleMI/x9FvmIs
QmAAn08YXHnxCUvQmb/rb/0oZn5oMZap
=omN2
-----END PGP SIGNATURE-----

--Rex5+51txc1ort/q--

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 17:04:46 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9E846106566C;
	Fri, 15 Apr 2011 17:04:46 +0000 (UTC)
	(envelope-from asmrookie@gmail.com)
Received: from mail-gy0-f182.google.com (mail-gy0-f182.google.com
	[209.85.160.182])
	by mx1.freebsd.org (Postfix) with ESMTP id 057018FC1C;
	Fri, 15 Apr 2011 17:04:45 +0000 (UTC)
Received: by gyg13 with SMTP id 13so1116784gyg.13
	for ; Fri, 15 Apr 2011 10:04:45 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:sender:in-reply-to:references:date
	:x-google-sender-auth:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=NIU3a0SKQnG49poaHTACeGRhEChv8KPa3K8K2HRUNp4=;
	b=SjhxQLlQdLdCUWSJhopSi7XdVAopFmB+zLpkTNO6w8YrivUoO5g1uMP4ZLsZnfXLdr
	Bu9iGm2H8biKYFKl1xzX3hwaq0CWys5m+hL1H2J6dqdfaIBVnHFy9z71EI1yLxMP74BO
	ZsjdAWyq2FvJluM4CgrHfH4xCF9gLaIrEgrFE=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:sender:in-reply-to:references:date
	:x-google-sender-auth:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	b=korpGo3FD/nwRxoGYc7c1TdNwdDsohqhnf271lVtwEH7Bcn/UZw572Jcibxu4Pe/+P
	fV/4Q4Jb9pL83smiSz2Xotgyrb0tbs58n3K955a2nyk38Ulgy+uN3KPIBaUKy75qXXDv
	wFtJryWiSXjZlhL89BicG2f+3lNBhUMAPmGJ8=
MIME-Version: 1.0
Received: by 10.236.190.225 with SMTP id e61mr973975yhn.208.1302887085154;
	Fri, 15 Apr 2011 10:04:45 -0700 (PDT)
Sender: asmrookie@gmail.com
Received: by 10.236.103.34 with HTTP; Fri, 15 Apr 2011 10:04:45 -0700 (PDT)
In-Reply-To: <20110415170100.GM48734@deviant.kiev.zoral.com.ua>
References: <201104101707.p3AH736T054347@svn.freebsd.org>
	<201104141713.28311.jhb@freebsd.org>
	<20110415082706.GI48734@deviant.kiev.zoral.com.ua>
	
	<20110415170100.GM48734@deviant.kiev.zoral.com.ua>
Date: Fri, 15 Apr 2011 13:04:45 -0400
X-Google-Sender-Auth: U915dx_IORwXIUTRiX-ce4TLDUM
Message-ID: 
From: Attilio Rao 
To: Kostik Belousov 
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org, trasz@freebsd.org,
	John Baldwin 
Subject: Re: svn commit: r220526 - head/sys/kern
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 17:04:46 -0000

2011/4/15 Kostik Belousov :
> On Fri, Apr 15, 2011 at 12:46:18PM -0400, Attilio Rao wrote:
>> 2011/4/15 Kostik Belousov :
>> > On Thu, Apr 14, 2011 at 05:13:28PM -0400, John Baldwin wrote:
>> >> On Sunday, April 10, 2011 1:07:03 pm Konstantin Belousov wrote:
>> >> > Author: kib
>> >> > Date: Sun Apr 10 17:07:02 2011
>> >> > New Revision: 220526
>> >> > URL: http://svn.freebsd.org/changeset/base/220526
>> >> >
>> >> > Log:
>> >> > =C2=A0 Some callers of proc_reparent() already have the parent proc=
ess locked.
>> >> > =C2=A0 Detect the situation and avoid process lock recursion.
>> >> >
>> >> > =C2=A0 Reported by: =C2=A0 =C2=A0 =C2=A0Fabian Keil 
>> >> >
>> >> > Modified:
>> >> > =C2=A0 head/sys/kern/kern_exit.c
>> >>
>> >> Can we instead assert it is always held and fix callers that don't? =
=C2=A0Using
>> >> locked variables is messy and I'd rather avoid it when possible. =C2=
=A0We already
>> >> require the caller to hold other locks for this operation.
>> >>
>> > I agree that this is ugly, and proper fix probably would be something =
else.
>> > E.g. struct proc could grow another field that holds a pointer to the =
ucred
>> > it is accounted for, and locked with some global lock.
>>
>> As you already hold allproc_lock the process can't be distructed, then
>> as I already pointed out to Tomasz, it should alright to just bump the
>> refcount for cred and pass down, I guess.
> I do not see how allproc_lock is useful there, unless setuid(2) and
> other syscalls, which change the process credentials, are protected by
> the same lock. The issue there is in accounting for wrong container.
> You want to avoid a race between dereferencing stale p_ucred and the
> process moving to another container.

I thought the issue was just prevent destroying of process/ucred I may
need to better look at callers then if you also want to avoid
credentials changes. BTW, a global lock for that is not what I really
hope to see.

Attilio


--=20
Peace can only be achieved by understanding - A. Einstein

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 17:10:52 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 76CE0106564A;
	Fri, 15 Apr 2011 17:10:52 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4B76B8FC08;
	Fri, 15 Apr 2011 17:10:52 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FHAqID076341;
	Fri, 15 Apr 2011 17:10:52 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FHAq67076339;
	Fri, 15 Apr 2011 17:10:52 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104151710.p3FHAq67076339@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Fri, 15 Apr 2011 17:10:52 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220662 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 17:10:52 -0000

Author: bschmidt
Date: Fri Apr 15 17:10:52 2011
New Revision: 220662
URL: http://svn.freebsd.org/changeset/base/220662

Log:
  Split out bluetooth coexistence setup.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Fri Apr 15 16:59:56 2011	(r220661)
+++ head/sys/dev/iwn/if_iwn.c	Fri Apr 15 17:10:52 2011	(r220662)
@@ -196,6 +196,7 @@ static void	iwn_tune_sensitivity(struct 
 		    const struct iwn_rx_stats *);
 static int	iwn_send_sensitivity(struct iwn_softc *);
 static int	iwn_set_pslevel(struct iwn_softc *, int, int, int);
+static int	iwn_send_btcoex(struct iwn_softc *);
 static int	iwn_config(struct iwn_softc *);
 static uint8_t	*ieee80211_add_ssid(uint8_t *, const uint8_t *, u_int);
 static int	iwn_scan(struct iwn_softc *);
@@ -4464,12 +4465,25 @@ iwn_set_pslevel(struct iwn_softc *sc, in
 }
 
 static int
+iwn_send_btcoex(struct iwn_softc *sc)
+{
+	struct iwn_bluetooth cmd;
+
+	memset(&cmd, 0, sizeof cmd);
+	cmd.flags = IWN_BT_COEX_CHAN_ANN | IWN_BT_COEX_BT_PRIO;
+	cmd.lead_time = IWN_BT_LEAD_TIME_DEF;
+	cmd.max_kill = IWN_BT_MAX_KILL_DEF;
+	DPRINTF(sc, IWN_DEBUG_RESET, "%s: configuring bluetooth coexistence\n",
+	    __func__);
+	return iwn_cmd(sc, IWN_CMD_BT_COEX, &cmd, sizeof(cmd), 0);
+}
+
+static int
 iwn_config(struct iwn_softc *sc)
 {
 	const struct iwn_hal *hal = sc->sc_hal;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
-	struct iwn_bluetooth bluetooth;
 	uint32_t txmask;
 	int error;
 	uint16_t rxchain;
@@ -4490,13 +4504,7 @@ iwn_config(struct iwn_softc *sc)
 	}
 
 	/* Configure bluetooth coexistence. */
-	memset(&bluetooth, 0, sizeof bluetooth);
-	bluetooth.flags = IWN_BT_COEX_CHAN_ANN | IWN_BT_COEX_BT_PRIO;
-	bluetooth.lead_time = IWN_BT_LEAD_TIME_DEF;
-	bluetooth.max_kill = IWN_BT_MAX_KILL_DEF;
-	DPRINTF(sc, IWN_DEBUG_RESET, "%s: config bluetooth coexistence\n",
-	    __func__);
-	error = iwn_cmd(sc, IWN_CMD_BT_COEX, &bluetooth, sizeof bluetooth, 0);
+	error = iwn_send_btcoex(sc);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not configure bluetooth coexistence, error %d\n",

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 17:12:47 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B1D2E106564A;
	Fri, 15 Apr 2011 17:12:47 +0000 (UTC)
	(envelope-from asmrookie@gmail.com)
Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54])
	by mx1.freebsd.org (Postfix) with ESMTP id 408E98FC0A;
	Fri, 15 Apr 2011 17:12:46 +0000 (UTC)
Received: by gwb15 with SMTP id 15so1442582gwb.13
	for ; Fri, 15 Apr 2011 10:12:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:sender:in-reply-to:references:date
	:x-google-sender-auth:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	bh=X4lRWRFBSrAZkddIyDdFWoQBgwYkjR5TwzKJkXTQiNI=;
	b=iZjD70FnQ7eN//htgBCu+BC/TWLC8f3KkD9V02KHK6obNLMYc5qOzYVqPQIhCCtT/Q
	qJ6d99/+1S32TFKFbnJOHZmf8acvGjp4PAd7huHHgyK/E1enlnqSAAa/1LMl7pnk4565
	9FLkp8rjYuptPxZcXC4bZhenki34MpQWA8sJA=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:sender:in-reply-to:references:date
	:x-google-sender-auth:message-id:subject:from:to:cc:content-type
	:content-transfer-encoding;
	b=Uy3qWrMqFr/3Su5Owb3zasV6JOr0IiKVX+wPN/pwTb+iR8S5wntmhfoRPPrHkpP/RM
	3xHT2Qd4DNQEm5zOUyK53Ql0gYP6MJPI4GWT3Ibn5M7Evex538U6Kd4dAajN/8x86G0V
	q4gR+WVXqTr8p0qVjiRhzeMbLiFwzuwb8QWmQ=
MIME-Version: 1.0
Received: by 10.236.187.97 with SMTP id x61mr918308yhm.476.1302885978243; Fri,
	15 Apr 2011 09:46:18 -0700 (PDT)
Sender: asmrookie@gmail.com
Received: by 10.236.103.34 with HTTP; Fri, 15 Apr 2011 09:46:18 -0700 (PDT)
In-Reply-To: <20110415082706.GI48734@deviant.kiev.zoral.com.ua>
References: <201104101707.p3AH736T054347@svn.freebsd.org>
	<201104141713.28311.jhb@freebsd.org>
	<20110415082706.GI48734@deviant.kiev.zoral.com.ua>
Date: Fri, 15 Apr 2011 12:46:18 -0400
X-Google-Sender-Auth: _RO_QaLt0gdzLykRvUZ7euqs2GA
Message-ID: 
From: Attilio Rao 
To: Kostik Belousov 
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org, trasz@freebsd.org,
	John Baldwin 
Subject: Re: svn commit: r220526 - head/sys/kern
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 17:12:47 -0000

2011/4/15 Kostik Belousov :
> On Thu, Apr 14, 2011 at 05:13:28PM -0400, John Baldwin wrote:
>> On Sunday, April 10, 2011 1:07:03 pm Konstantin Belousov wrote:
>> > Author: kib
>> > Date: Sun Apr 10 17:07:02 2011
>> > New Revision: 220526
>> > URL: http://svn.freebsd.org/changeset/base/220526
>> >
>> > Log:
>> > =C2=A0 Some callers of proc_reparent() already have the parent process=
 locked.
>> > =C2=A0 Detect the situation and avoid process lock recursion.
>> >
>> > =C2=A0 Reported by: =C2=A0 =C2=A0 =C2=A0Fabian Keil 
>> >
>> > Modified:
>> > =C2=A0 head/sys/kern/kern_exit.c
>>
>> Can we instead assert it is always held and fix callers that don't? =C2=
=A0Using
>> locked variables is messy and I'd rather avoid it when possible. =C2=A0W=
e already
>> require the caller to hold other locks for this operation.
>>
> I agree that this is ugly, and proper fix probably would be something els=
e.
> E.g. struct proc could grow another field that holds a pointer to the ucr=
ed
> it is accounted for, and locked with some global lock.

As you already hold allproc_lock the process can't be distructed, then
as I already pointed out to Tomasz, it should alright to just bump the
refcount for cred and pass down, I guess.

Attilio


--=20
Peace can only be achieved by understanding - A. Einstein

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 18:34:28 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 52180106566B;
	Fri, 15 Apr 2011 18:34:28 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3D4FA8FC1B;
	Fri, 15 Apr 2011 18:34:28 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FIYSoa078124;
	Fri, 15 Apr 2011 18:34:28 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FIYS1r078119;
	Fri, 15 Apr 2011 18:34:28 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104151834.p3FIYS1r078119@svn.freebsd.org>
From: Jung-uk Kim 
Date: Fri, 15 Apr 2011 18:34:28 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220663 - in head: sys/conf sys/contrib/dev/acpica
	sys/contrib/dev/acpica/common sys/contrib/dev/acpica/compiler
	sys/contrib/dev/acpica/debugger
	sys/contrib/dev/acpica/dispatcher sys/co...
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 18:34:28 -0000

Author: jkim
Date: Fri Apr 15 18:34:27 2011
New Revision: 220663
URL: http://svn.freebsd.org/changeset/base/220663

Log:
  Merge ACPICA 20110413.

Added:
  head/sys/contrib/dev/acpica/compiler/dtparser.l
     - copied, changed from r220658, vendor-sys/acpica/dist/compiler/dtparser.l
  head/sys/contrib/dev/acpica/compiler/dtparser.y
     - copied, changed from r220658, vendor-sys/acpica/dist/compiler/dtparser.y
  head/sys/contrib/dev/acpica/events/evglock.c
     - copied, changed from r220658, vendor-sys/acpica/dist/events/evglock.c
Modified:
  head/sys/conf/files
  head/sys/contrib/dev/acpica/acpica_prep.sh
  head/sys/contrib/dev/acpica/changes.txt
  head/sys/contrib/dev/acpica/common/dmtable.c
  head/sys/contrib/dev/acpica/common/dmtbdump.c
  head/sys/contrib/dev/acpica/compiler/aslanalyze.c
  head/sys/contrib/dev/acpica/compiler/aslcompiler.h
  head/sys/contrib/dev/acpica/compiler/aslcompiler.y
  head/sys/contrib/dev/acpica/compiler/asldefine.h
  head/sys/contrib/dev/acpica/compiler/aslglobal.h
  head/sys/contrib/dev/acpica/compiler/asllookup.c
  head/sys/contrib/dev/acpica/compiler/aslmain.c
  head/sys/contrib/dev/acpica/compiler/aslmap.c
  head/sys/contrib/dev/acpica/compiler/aslmessages.h
  head/sys/contrib/dev/acpica/compiler/aslpredef.c
  head/sys/contrib/dev/acpica/compiler/asltypes.h
  head/sys/contrib/dev/acpica/compiler/aslutils.c
  head/sys/contrib/dev/acpica/compiler/aslwalks.c
  head/sys/contrib/dev/acpica/compiler/dtcompile.c
  head/sys/contrib/dev/acpica/compiler/dtcompiler.h
  head/sys/contrib/dev/acpica/compiler/dtexpress.c
  head/sys/contrib/dev/acpica/compiler/dtfield.c
  head/sys/contrib/dev/acpica/compiler/dtio.c
  head/sys/contrib/dev/acpica/compiler/dtsubtable.c
  head/sys/contrib/dev/acpica/compiler/dttable.c
  head/sys/contrib/dev/acpica/compiler/dttemplate.c
  head/sys/contrib/dev/acpica/compiler/dttemplate.h
  head/sys/contrib/dev/acpica/compiler/dtutils.c
  head/sys/contrib/dev/acpica/debugger/dbdisply.c
  head/sys/contrib/dev/acpica/dispatcher/dswload.c
  head/sys/contrib/dev/acpica/dispatcher/dswload2.c
  head/sys/contrib/dev/acpica/events/evmisc.c
  head/sys/contrib/dev/acpica/events/evregion.c
  head/sys/contrib/dev/acpica/events/evrgnini.c
  head/sys/contrib/dev/acpica/events/evxfregn.c
  head/sys/contrib/dev/acpica/executer/excreate.c
  head/sys/contrib/dev/acpica/include/acconfig.h
  head/sys/contrib/dev/acpica/include/acevents.h
  head/sys/contrib/dev/acpica/include/acpixf.h
  head/sys/contrib/dev/acpica/include/actypes.h
  head/sys/contrib/dev/acpica/include/amlcode.h
  head/sys/contrib/dev/acpica/namespace/nsrepair.c
  head/sys/contrib/dev/acpica/utilities/utdecode.c
  head/sys/modules/acpi/acpi/Makefile
  head/usr.sbin/acpi/acpidb/Makefile
  head/usr.sbin/acpi/iasl/Makefile
Directory Properties:
  head/sys/contrib/dev/acpica/   (props changed)

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Fri Apr 15 17:10:52 2011	(r220662)
+++ head/sys/conf/files	Fri Apr 15 18:34:27 2011	(r220663)
@@ -190,6 +190,7 @@ contrib/dev/acpica/dispatcher/dswload2.c
 contrib/dev/acpica/dispatcher/dswscope.c	optional acpi
 contrib/dev/acpica/dispatcher/dswstate.c	optional acpi
 contrib/dev/acpica/events/evevent.c		optional acpi
+contrib/dev/acpica/events/evglock.c		optional acpi
 contrib/dev/acpica/events/evgpe.c		optional acpi
 contrib/dev/acpica/events/evgpeblk.c		optional acpi
 contrib/dev/acpica/events/evgpeinit.c		optional acpi

Modified: head/sys/contrib/dev/acpica/acpica_prep.sh
==============================================================================
--- head/sys/contrib/dev/acpica/acpica_prep.sh	Fri Apr 15 17:10:52 2011	(r220662)
+++ head/sys/contrib/dev/acpica/acpica_prep.sh	Fri Apr 15 18:34:27 2011	(r220663)
@@ -67,7 +67,7 @@ find ${wrk} -type f -print | xargs -J % 
 
 # canonify include paths
 for H in ${src_headers}; do
-	find ${dst} -name "*.[chy]" -type f -print |	\
+	find ${dst} -name "*.[chly]" -type f -print |	\
 	xargs sed -i "" -e "s|[\"<]$H[\">]|\|g"
 done
 for H in ${comp_headers}; do

Modified: head/sys/contrib/dev/acpica/changes.txt
==============================================================================
--- head/sys/contrib/dev/acpica/changes.txt	Fri Apr 15 17:10:52 2011	(r220662)
+++ head/sys/contrib/dev/acpica/changes.txt	Fri Apr 15 18:34:27 2011	(r220663)
@@ -1,7 +1,83 @@
 ----------------------------------------
+13 April 2011. Summary of changes for version 20110413:
+
+1) ACPI CA Core Subsystem:
+
+Implemented support to execute a so-called "orphan" _REG method under the EC 
+device. This change will force the execution of a _REG method underneath the EC 
+device even if there is no corresponding operation region of type 
+EmbeddedControl. Fixes a problem seen on some machines and apparently is 
+compatible with Windows behavior. ACPICA BZ 875.
+
+Added more predefined methods that are eligible for automatic NULL package 
+element removal. This change adds another group of predefined names to the list 
+of names that can be repaired by having NULL package elements dynamically 
+removed. This group are those methods that return a single variable-length 
+package containing simple data types such as integers, buffers, strings. This 
+includes: _ALx, _BCL, _CID,_ DOD, _EDL, _FIX, _PCL, _PLD, _PMD, _PRx, _PSL, _Sx, 
+and _TZD. ACPICA BZ 914.
+
+Split and segregated all internal global lock functions to a new file, evglock.c.
+
+Updated internal address SpaceID for DataTable regions. Moved this internal space 
+id in preparation for ACPI 5.0 changes that will include some new space IDs. This 
+change should not affect user/host code.
+
+Example Code and Data Size: These are the sizes for the OS-independent acpica.lib 
+produced by the Microsoft Visual C++ 9.0 32-bit compiler. The debug version of 
+the code includes the debug output trace mechanism and has a much larger code and 
+data size.
+
+  Previous Release (VC 9.0):
+    Non-Debug Version:  89.8K Code, 23.8K Data, 113.6K Total
+    Debug Version:     164.2K Code, 67.9K Data, 232.1K Total
+  Current Release (VC 9.0):
+    Non-Debug Version:  90.0K Code, 23.8K Data, 113.8K Total
+    Debug Version:     164.5K Code, 68.0K Data, 232.5K Total
+
+2) iASL Compiler/Disassembler and Tools:
+
+iASL/DTC: Major update for new grammar features. Allow generic data types in 
+custom ACPI tables. Field names are now optional. Any line can be split to 
+multiple lines using the continuation char (\). Large buffers now use line-
+continuation character(s) and no colon on the continuation lines. See the grammar 
+update in the iASL compiler reference. ACPI BZ 910,911. Lin Ming, Bob Moore.
+
+iASL: Mark ASL "Return()" and the simple "Return" as "Null" return statements. 
+Since the parser stuffs a "zero" as the return value for these statements (due to 
+the underlying AML grammar), they were seen as "return with value" by the iASL 
+semantic checking. They are now seen correctly as "null" return statements.
+
+iASL: Check if a_REG declaration has a corresponding Operation Region. Adds a 
+check for each _REG to ensure that there is in fact a corresponding operation 
+region declaration in the same scope. If not, the _REG method is not very useful 
+since it probably won't be executed. ACPICA BZ 915.
+
+iASL/DTC: Finish support for expression evaluation. Added a new expression parser 
+that implements c-style operator precedence and parenthesization. ACPICA bugzilla 
+908.
+
+Disassembler/DTC: Remove support for () and <> style comments in data tables. Now 
+that DTC has full expression support, we don't want to have comment strings that 
+start with a parentheses or a less-than symbol. Now, only the standard /* and // 
+comments are supported, as well as the bracket [] comments.
+
+AcpiXtract: Fix for RSDP and dynamic SSDT extraction. These tables have "unusual" 
+headers in the acpidump file. Update the header validation to support these 
+tables. Problem introduced in previous AcpiXtract version in the change to 
+support "wrong checksum" error messages emitted by acpidump utility.
+
+iASL: Add a * option to generate all template files (as a synonym for ALL) as in 
+"iasl -T *" or "iasl -T ALL".
+
+iASL/DTC: Do not abort compiler on fatal errors. We do not want to completely 
+abort the compiler on "fatal" errors, simply should abort the current compile. 
+This allows multiple compiles with a single (possibly wildcard) compiler 
+invocation.
+
+----------------------------------------
 16 March 2011. Summary of changes for version 20110316:
 
-x
 1) ACPI CA Core Subsystem:
 
 Fixed a problem caused by a _PRW method appearing at the namespace root scope 
@@ -126,7 +202,6 @@ no need to abort on simple errors within
 Debugger: Simplified the output of the help command. All help output now in 
 a single screen, instead of help subcommands. ACPICA Bugzilla 897.
 
-
 ----------------------------------------
 12 January 2011. Summary of changes for version 20110112:
 
@@ -134,16 +209,14 @@ a single screen, instead of help subcomm
 
 Fixed a race condition between method execution and namespace walks that can 
 possibly cause a fault. The problem was apparently introduced in version 
-20100528 as a result of a performance optimization that reduces the number 
-of 
+20100528 as a result of a performance optimization that reduces the number of 
 namespace walks upon method exit by using the delete_namespace_subtree 
 function instead of the delete_namespace_by_owner function used previously. 
 Bug is a missing namespace lock in the delete_namespace_subtree function. 
 dana.myers@oracle.com
 
 Fixed several issues and a possible fault with the automatic "serialized" 
-method support. History: This support changes a method to "serialized" on 
-the 
+method support. History: This support changes a method to "serialized" on the 
 fly if the method generates an AE_ALREADY_EXISTS error, indicating the 
 possibility that it cannot handle reentrancy. This fix repairs a couple of 
 issues seen in the field, especially on machines with many cores:
@@ -181,8 +254,7 @@ details.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release (VC 6.0):
@@ -194,13 +266,11 @@ much larger code and data size.
 
 2) iASL Compiler/Disassembler and Tools:
 
-iASL: Added generic data types to the Data Table compiler. Add "generic" 
-data 
+iASL: Added generic data types to the Data Table compiler. Add "generic" data 
 types such as UINT32, String, Unicode, etc., to simplify the generation of 
 platform-defined tables such as UEFI. Lin Ming.
 
-iASL: Added listing support for the Data Table Compiler. Adds listing 
-support 
+iASL: Added listing support for the Data Table Compiler. Adds listing support 
 (-l) to display actual binary output for each line of input code.
 
 ----------------------------------------
@@ -232,15 +302,13 @@ when a Wake GPE is received if there is 
 handler. ACPICA BZ 870.
 
 Fixed a problem with the Scope() operator during table parse and load phase. 
-During load phase (table load or method execution), the scope operator 
-should 
+During load phase (table load or method execution), the scope operator should 
 not enter the target into the namespace. Instead, it should open a new scope 
 at the target location. Linux BZ 19462, ACPICA BZ 882.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -299,8 +367,7 @@ longer needed in Execute_HID, Execute_CI
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -313,16 +380,13 @@ much larger code and data size.
 2) iASL Compiler/Disassembler and Tools:
 
 iASL: Implemented additional compile-time validation for _HID strings. The 
-non-hex prefix (such as "PNP" or "ACPI") must be uppercase, and the length 
-of 
+non-hex prefix (such as "PNP" or "ACPI") must be uppercase, and the length of 
 the string must be exactly seven or eight characters. For both _HID and _CID 
 strings, all characters must be alphanumeric. ACPICA BZ 874.
 
 iASL: Allow certain "null" resource descriptors. Some BIOS code creates 
-descriptors that are mostly or all zeros, with the expectation that they 
-will 
-be filled in at runtime. iASL now allows this as long as there is a 
-"resource 
+descriptors that are mostly or all zeros, with the expectation that they will 
+be filled in at runtime. iASL now allows this as long as there is a "resource 
 tag" (name) associated with the descriptor, which gives the ASL a handle 
 needed to modify the descriptor. ACPICA BZ 873.
 
@@ -332,8 +396,7 @@ threaded ACPICA tools/applications - inc
 _MULTI_THREADED option was replaced by the (reverse) ACPI_SINGLE_THREADED 
 option. ACPICA BZ 879.
 
-AcpiExec: several fixes for the 64-bit version. Adds XSDT support and 
-support 
+AcpiExec: several fixes for the 64-bit version. Adds XSDT support and support 
 for 64-bit DSDT/FACS addresses in the FADT. Lin Ming.
 
 iASL: Moved all compiler messages to a new file, aslmessages.h.
@@ -343,8 +406,7 @@ iASL: Moved all compiler messages to a n
 
 1) ACPI CA Core Subsystem:
 
-Removed the AcpiOsDerivePciId OSL interface. The various host 
-implementations 
+Removed the AcpiOsDerivePciId OSL interface. The various host implementations 
 of this function were not OS-dependent and are now obsolete and can be 
 removed from all host OSLs. This function has been replaced by 
 AcpiHwDerivePciId, which is now part of the ACPICA core code. 
@@ -358,8 +420,7 @@ accordance with the ACPI specification a
 ACPICA BZ 871.
 
 The ACPI_THREAD_ID type is no longer configurable, internally it is now 
-always UINT64. This simplifies the ACPICA code, especially any printf 
-output. 
+always UINT64. This simplifies the ACPICA code, especially any printf output. 
 UINT64 is the only common data type for all thread_id types across all 
 operating systems. It is now up to the host OSL to cast the native thread_id 
 type to UINT64 before returning the value to ACPICA (via AcpiOsGetThreadId). 
@@ -381,8 +442,7 @@ is used. ACPICA BZ 829. Lin Ming, Bob Mo
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -411,8 +471,7 @@ of size_t on 32-bit versus 64-bit genera
 Designed and implemented a new host interface to the _OSI support code. This 
 will allow the host to dynamically add or remove multiple _OSI strings, as 
 well as install an optional handler that is called for each _OSI invocation. 
-Also added a new AML debugger command, 'osi' to display and modify the 
-global 
+Also added a new AML debugger command, 'osi' to display and modify the global 
 _OSI string table, and test support in the AcpiExec utility. See the ACPICA 
 reference manual for full details. Lin Ming, Bob Moore. ACPICA BZ 836.
 New Functions:
@@ -441,14 +500,12 @@ It should be a (UINT64 *). This may affe
 
 Fixed a couple problems with the recently modified Linux makefiles for iASL 
 and AcpiExec. These new makefiles place the generated object files in the 
-local directory so that there can be no collisions between the files that 
-are 
+local directory so that there can be no collisions between the files that are 
 shared between them that are compiled with different options.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -489,29 +546,25 @@ interface. This interface will set or cl
 5) Remove GpeType argument from AcpiEnable and AcpiDisable. These interfaces 
 are now used for "runtime" GPEs only.
 
-Changed the behavior of the GPE install/remove handler interfaces. The GPE 
-is 
+Changed the behavior of the GPE install/remove handler interfaces. The GPE is 
 no longer disabled during this process, as it was found to cause problems on 
 some machines. Rafael J. Wysocki.
 
 Reverted a change introduced in version 20100528 to enable Embedded 
-Controller multi-byte transfers. This change was found to cause problems 
-with 
+Controller multi-byte transfers. This change was found to cause problems with 
 Index Fields and possibly Bank Fields. It will be reintroduced when these 
 problems have been resolved.
 
 Fixed a problem with references to Alias objects within Package Objects. A 
 reference to an Alias within the definition of a Package was not always 
 resolved properly. Aliases to objects like Processors, Thermal zones, etc. 
-were resolved to the actual object instead of a reference to the object as 
-it 
+were resolved to the actual object instead of a reference to the object as it 
 should be. Package objects are only allowed to contain integer, string, 
 buffer, package, and reference objects. Redhat bugzilla 608648.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -561,8 +614,7 @@ ACPI tables that have been seen in the f
 Implemented support to enable multi-byte transfers for Embedded Controller 
 (EC) operation regions. Previously, the maximum data size passed to the EC 
 operation region handler was a single byte. There are often EC Fields larger 
-than one byte that need to be transferred, and it is useful for the EC 
-driver 
+than one byte that need to be transferred, and it is useful for the EC driver 
 to lock these as a single transaction. This change enables single transfers 
 larger than 8 bits. This effectively changes the access to the EC space from 
 ByteAcc to AnyAcc, and will probably require changes to the host OS Embedded 
@@ -579,16 +631,12 @@ node and an ACPI operand object. However
 namespace in ten years. ACPICA bugzilla 817. Alexey Starikovskiy.
 
 Implemented a performance optimization that reduces the number of namespace 
-walks. On control method exit, only walk the namespace if the method is 
-known 
-to have created namespace objects outside of its local scope. Previously, 
-the 
+walks. On control method exit, only walk the namespace if the method is known 
+to have created namespace objects outside of its local scope. Previously, the 
 entire namespace was traversed on each control method exit. This change can 
-improve overall ACPI performance by up to 3X. Alexey Starikovskiy, Bob 
-Moore.
+improve overall ACPI performance by up to 3X. Alexey Starikovskiy, Bob Moore.
 
-Added support to truncate I/O addresses to 16 bits for Windows 
-compatibility. 
+Added support to truncate I/O addresses to 16 bits for Windows compatibility. 
 Some ASL code has been seen in the field that inadvertently has bits set 
 above bit 15. This feature is optional and is enabled if the BIOS requests 
 any Windows OSI strings. It can also be enabled by the host OS. Matthew 
@@ -606,18 +654,15 @@ part of the ACPI spec. ACPICA BZ 860.
 Expanded all statistic counters used during namespace and device 
 initialization from 16 to 32 bits in order to support very large namespaces.
 
-Replaced all instances of %d in printf format specifiers with %u since 
-nearly 
+Replaced all instances of %d in printf format specifiers with %u since nearly 
 all integers in ACPICA are unsigned.
 
-Fixed the exception namestring for AE_WAKE_ONLY_GPE. Was incorrectly 
-returned 
+Fixed the exception namestring for AE_WAKE_ONLY_GPE. Was incorrectly returned 
 as AE_NO_HANDLER.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -651,8 +696,7 @@ new table, and process any _Lxx/_Exx GPE
 runtime GPE that is referenced by an _Lxx/_Exx method in the new table is 
 immediately enabled. Handles the FADT-defined GPEs as well as GPE Block 
 Devices. Provides compatibility with other ACPI implementations. Two new 
-files added, evgpeinit.c and evgpeutil.c. ACPICA BZ 833. Lin Ming, Bob 
-Moore.
+files added, evgpeinit.c and evgpeutil.c. ACPICA BZ 833. Lin Ming, Bob Moore.
 
 Fixed a regression introduced in version 20100331 within the table manager 
 where initial table loading could fail. This was introduced in the fix for 
@@ -664,14 +708,12 @@ AcpiUtCopySimpleObject. The original cod
 where the object to be copied was a namespace node. Lin Ming. ACPICA BZ 847.
 
 Updated the allocation dump routine, AcpiUtDumpAllocation and fixed a 
-possible access beyond end-of-allocation. Also, now fully validate 
-descriptor 
+possible access beyond end-of-allocation. Also, now fully validate descriptor 
 (size and type) before output. Lin Ming, Bob Moore. ACPICA BZ 847
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -688,8 +730,7 @@ descriptors. This change implements vali
 are common to all address-type resource descriptors. These checks are 
 implemented: Checks for valid Min/Max, length within the Min/Max window, 
 valid granularity, Min/Max a multiple of granularity, and _MIF/_MAF as per 
-table 6-40 in the ACPI 4.0a specification. Also split the large 
-aslrestype1.c 
+table 6-40 in the ACPI 4.0a specification. Also split the large aslrestype1.c 
 and aslrestype2.c files into five new files. ACPICA BZ 840.
 
 iASL: Added support for the _Wxx predefined names. This support was missing 
@@ -733,10 +774,8 @@ New:
     AcpiSetGpe
 
 Implemented write support for DataTable operation regions. These regions are 
-defined via the DataTableRegion() operator. Previously, only read support 
-was 
-implemented. The ACPI specification allows DataTableRegions to be 
-read/write, 
+defined via the DataTableRegion() operator. Previously, only read support was 
+implemented. The ACPI specification allows DataTableRegions to be read/write, 
 however.
 
 Implemented a new subsystem option to force a copy of the DSDT to local 
@@ -746,8 +785,7 @@ the original DSDT, creating the need for
 not copy the DSDT.
 
 Implemented detection of a corrupted or replaced DSDT. This change adds 
-support to detect a DSDT that has been corrupted and/or replaced from 
-outside 
+support to detect a DSDT that has been corrupted and/or replaced from outside 
 the OS (by firmware). This is typically catastrophic for the system, but has 
 been seen on some machines. Once this problem has been detected, the DSDT 
 copy option can be enabled via system configuration. Lin Ming, Bob Moore.
@@ -760,8 +798,7 @@ was not set correctly. Alexey Starikovsk
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -777,8 +814,7 @@ iASL: Implement limited typechecking for
 control methods. The type of any returned static (unnamed) object is now 
 validated. For example, Return(1). ACPICA BZ 786.
 
-iASL: Fixed a predefined name object verification regression. Fixes a 
-problem 
+iASL: Fixed a predefined name object verification regression. Fixes a problem 
 introduced in version 20100304. An error is incorrectly generated if a 
 predefined name is declared as a static named object with a value defined 
 using the keywords "Zero", "One", or "Ones". Lin Ming.
@@ -797,25 +833,21 @@ Introduced in commit ae7d6fd: Properly h
 
 Fixed a possible problem with the AML Mutex handling function 
 AcpiExReleaseMutex where the function could fault under the very rare 
-condition when the interpreter has blocked, the interpreter lock is 
-released, 
+condition when the interpreter has blocked, the interpreter lock is released, 
 the interpreter is then reentered via the same thread, and attempts to 
-acquire an AML mutex that was previously acquired. FreeBSD report 140979. 
-Lin 
+acquire an AML mutex that was previously acquired. FreeBSD report 140979. Lin 
 Ming.
 
 Implemented additional configuration support for the AML "Debug Object". 
 Output from the debug object can now be enabled via a global variable, 
-AcpiGbl_EnableAmlDebugObject. This will assist with remote machine 
-debugging. 
+AcpiGbl_EnableAmlDebugObject. This will assist with remote machine debugging. 
 This debug output is now available in the release version of ACPICA instead 
 of just the debug version. Also, the entire debug output module can now be 
 configured out of the ACPICA build if desired. One new file added, 
 executer/exdebug.c. Lin Ming, Bob Moore.
 
 Added header support for the ACPI MCHI table (Management Controller Host 
-Interface Table). This table was added in ACPI 4.0, but the defining 
-document 
+Interface Table). This table was added in ACPI 4.0, but the defining document 
 has only recently become available.
 
 Standardized output of integer values for ACPICA warnings/errors. Always use 
@@ -826,8 +858,7 @@ ACPI_DEBUG_PRINT invocations and were no
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -842,8 +873,7 @@ much larger code and data size.
 iASL: Implemented typechecking support for static (non-control method) 
 predefined named objects that are declared with the Name() operator. For 
 example, the type of this object is now validated to be of type Integer: 
-Name(_BBN, 1). This change migrates the compiler to using the core 
-predefined 
+Name(_BBN, 1). This change migrates the compiler to using the core predefined 
 name table instead of maintaining a local version. Added a new file, 
 aslpredef.c. ACPICA BZ 832.
 
@@ -858,20 +888,15 @@ Added the 2010 copyright to all module h
 virtually every file in the ACPICA core subsystem, the iASL compiler, the 
 tools/utilities, and the test suites.
 
-Implemented a change to the AcpiGetDevices interface to eliminate 
-unnecessary 
+Implemented a change to the AcpiGetDevices interface to eliminate unnecessary 
 invocations of the _STA method. In the case where a specific _HID is 
 requested, do not run _STA until a _HID match is found. This eliminates 
-potentially dozens of _STA calls during a search for a particular 
-device/HID, 
+potentially dozens of _STA calls during a search for a particular device/HID, 
 which in turn can improve boot times. ACPICA BZ 828. Lin Ming.
 
-Implemented an additional repair for predefined method return values. 
-Attempt 
-to repair unexpected NULL elements within returned Package objects. Create 
-an 
-Integer of value zero, a NULL String, or a zero-length Buffer as 
-appropriate. 
+Implemented an additional repair for predefined method return values. Attempt 
+to repair unexpected NULL elements within returned Package objects. Create an 
+Integer of value zero, a NULL String, or a zero-length Buffer as appropriate. 
 ACPICA BZ 818. Lin Ming, Bob Moore.
 
 Removed the obsolete ACPI_INTEGER data type. This type was introduced as the 
@@ -883,16 +908,14 @@ for now for compatibility with existing 
 Removed the unused UINT32_STRUCT type, and the obsolete Integer64 field in 
 the parse tree object.
 
-Added additional warning options for the gcc-4 generation. Updated the 
-source 
+Added additional warning options for the gcc-4 generation. Updated the source 
 accordingly. This includes some code restructuring to eliminate unreachable 
 code, elimination of some gotos, elimination of unused return values, some 
 additional casting, and removal of redundant declarations.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -914,12 +937,10 @@ No functional changes for this release.
 Enhanced automatic data type conversions for predefined name repairs. This 
 change expands the automatic repairs/conversions for predefined name return 
 values to make Integers, Strings, and Buffers fully interchangeable. Also, a 
-Buffer can be converted to a Package of Integers if necessary. The 
-nsrepair.c 
+Buffer can be converted to a Package of Integers if necessary. The nsrepair.c 
 module was completely restructured. Lin Ming, Bob Moore.
 
-Implemented automatic removal of null package elements during predefined 
-name 
+Implemented automatic removal of null package elements during predefined name 
 repairs. This change will automatically remove embedded and trailing NULL 
 package elements from returned package objects that are defined to contain a 
 variable number of sub-packages. The driver is then presented with a package 
@@ -928,8 +949,7 @@ with no null elements to deal with. ACPI
 Implemented a repair for the predefined _FDE and _GTM names. The expected 
 return value for both names is a Buffer of 5 DWORDs. This repair fixes two 
 possible problems (both seen in the field), where a package of integers is 
-returned, or a buffer of BYTEs is returned. With assistance from Jung-uk 
-Kim.
+returned, or a buffer of BYTEs is returned. With assistance from Jung-uk Kim.
 
 Implemented additional module-level code support. This change will properly 
 execute module-level code that is not at the root of the namespace (under a 
@@ -944,8 +964,7 @@ not been seen before. ACPICA BZ 826. Lin
 
 Fixed a possible memory leak during module-level code execution. An object 
 could be leaked for each block of executed module-level code if the 
-interpreter slack mode is enabled This change deletes any implicitly 
-returned 
+interpreter slack mode is enabled This change deletes any implicitly returned 
 object from the module-level code block. Lin Ming.
 
 Removed messages for successful predefined repair(s). The repair mechanism 
@@ -955,8 +974,7 @@ repairs were converted to ACPI_DEBUG_PRI
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -968,8 +986,7 @@ much larger code and data size.
 
 2) iASL Compiler/Disassembler and Tools:
 
-iASL: Fixed a regression introduced in 20091112 where intermediate .SRC 
-files 
+iASL: Fixed a regression introduced in 20091112 where intermediate .SRC files 
 were no longer automatically removed at the termination of the compile.
 
 acpiexec: Implemented the -f option to specify default region fill value. 
@@ -995,23 +1012,19 @@ attributes. Such regions are probably BI
 Linux BZ 14445. Lin Ming.
 
 Implemented an automatic repair for predefined methods that must return 
-sorted lists. This change will repair (by sorting) packages returned by 
-_ALR, 
-_PSS, and _TSS. Drivers can now assume that the packages are correctly 
-sorted 
+sorted lists. This change will repair (by sorting) packages returned by _ALR, 
+_PSS, and _TSS. Drivers can now assume that the packages are correctly sorted 
 and do not contain NULL package elements. Adds one new file, 
 namespace/nsrepair2.c. ACPICA BZ 784. Lin Ming, Bob Moore.
 
 Fixed a possible fault during predefined name validation if a return Package 
 object contains NULL elements. Also adds a warning if a NULL element is 
-followed by any non-null elements. ACPICA BZ 813, 814. Future enhancement 
-may 
+followed by any non-null elements. ACPICA BZ 813, 814. Future enhancement may 
 include repair or removal of all such NULL elements where possible.
 
 Implemented additional module-level executable AML code support. This change 
 will execute module-level code that is not at the root of the namespace 
-(under a Device object, etc.) at table load time. Module-level executable 
-AML 
+(under a Device object, etc.) at table load time. Module-level executable AML 
 code has been illegal since ACPI 2.0. ACPICA BZ 762. Lin Ming.
 
 Implemented a new internal function to create Integer objects. This function 
@@ -1019,14 +1032,12 @@ simplifies miscellaneous object creation
 
 Reduced the severity of predefined repair messages, Warning to Info. Since 
 the object was successfully repaired, a warning is too severe. Reduced to an 
-info message for now. These messages may eventually be changed to debug-
-only. 
+info message for now. These messages may eventually be changed to debug-only. 
 ACPICA BZ 812.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -1048,12 +1059,10 @@ exists, but is shorter than the declared
 technically legal, this is probably a coding error and it is seen in the 
 field. ACPICA BZ 815. Lin Ming, Bob Moore.
 
-iASL: Fixed a problem where the compiler could fault after the maximum 
-number 
+iASL: Fixed a problem where the compiler could fault after the maximum number 
 of errors was reached (200).
 
-acpixtract: Fixed a possible warning for pointer cast if the compiler 
-warning 
+acpixtract: Fixed a possible warning for pointer cast if the compiler warning 
 level set very high.
 
 ----------------------------------------
@@ -1073,8 +1082,7 @@ operand object was leaked. Lin Ming.
 
 Implemented a run-time repair for the _MAT predefined method. If the _MAT 
 return value is defined as a Field object in the AML, and the field
-size is less than or equal to the default width of an integer (32 or 
-64),_MAT 
+size is less than or equal to the default width of an integer (32 or 64),_MAT 
 can incorrectly return an Integer instead of a Buffer. ACPICA now 
 automatically repairs this problem. ACPICA BZ 810.
 
@@ -1087,8 +1095,7 @@ within the returned Package. ACPICA BZ 8
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -1131,10 +1138,8 @@ Fixed a possible memory leak in the inte
 the package initializer list is longer than the defined size of the package. 
 This apparently can only happen if the BIOS changes the package size on the 
 fly (seen in a _PSS object), as ASL compilers do not allow this. The 
-interpreter will truncate the package to the defined size (and issue an 
-error 
-message), but previously could leave the extra objects undeleted if they 
-were 
+interpreter will truncate the package to the defined size (and issue an error 
+message), but previously could leave the extra objects undeleted if they were 
 pre-created during the argument processing (such is the case if the package 
 consists of a number of sub-packages as in the _PSS.) ACPICA BZ 805.
 
@@ -1154,8 +1159,7 @@ return type cannot be performed. ACPICA 
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -1205,17 +1209,13 @@ EINJ, ERST, and HEST. Other newly suppor
 have been some ACPI 4.0 changes to other existing tables. Split the large 
 actbl1.h header into the existing actbl2.h header. ACPICA BZ 774.
 
-ACPI 4.0: Implemented predefined name validation for all new names. There 
-are 
-31 new names in ACPI 4.0. The predefined validation module was split into 
-two 
+ACPI 4.0: Implemented predefined name validation for all new names. There are 
+31 new names in ACPI 4.0. The predefined validation module was split into two 
 files. The new file is namespace/nsrepair.c. ACPICA BZ 770.
 
 Implemented support for so-called "module-level executable code". This is 
-executable AML code that exists outside of any control method and is 
-intended 
-to be executed at table load time. Although illegal since ACPI 2.0, this 
-type 
+executable AML code that exists outside of any control method and is intended 
+to be executed at table load time. Although illegal since ACPI 2.0, this type 
 of code still exists and is apparently still being created. Blocks of this 
 code are now detected and executed as intended. Currently, the code blocks 
 must exist under either an If, Else, or While construct; these are the 
@@ -1231,8 +1231,7 @@ be repaired: _ALR, _CSD, _HPX, _MLS, _PR
 790.
 
 Fixed a regression introduced in 20090625 for the AcpiGetDevices interface. 
-The _HID/_CID matching was broken and no longer matched IDs correctly. 
-ACPICA 
+The _HID/_CID matching was broken and no longer matched IDs correctly. ACPICA 
 BZ 793.
 
 Fixed a problem with AcpiReset where the reset would silently fail if the 
@@ -1246,14 +1245,12 @@ does not exist during an attempt to writ
 (However, some hosts already delete the code that writes this bit, and the 
 code may in fact be obsolete at this date.) ACPICA BZ 799.
 
-Fixed a problem where AcpiTerminate could fault if inadvertently called 
-twice 
+Fixed a problem where AcpiTerminate could fault if inadvertently called twice 
 in succession. ACPICA BZ 795.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -1298,8 +1295,7 @@ been added - utilities/utids.c. ACPICA B
 
 Updated the AcpiRead and AcpiWrite external interfaces to support 64-bit 
 transfers. The Value parameter has been extended from 32 bits to 64 bits in 
-order to support new ACPI 4.0 tables. These changes will require an update 
-to 
+order to support new ACPI 4.0 tables. These changes will require an update to 
 all callers of these interfaces. See the ACPICA Programmer Reference for 
 details. ACPICA BZ 768.
 
@@ -1327,8 +1323,7 @@ tree head. ACPICA BZ 776.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -1352,8 +1347,7 @@ predefined names and control methods (31
 1) ACPI CA Core Subsystem:
 
 Disabled the preservation of the SCI enable bit in the PM1 control register. 
-The SCI enable bit (bit 0, SCI_EN) is defined by the ACPI specification to 
-be 
+The SCI enable bit (bit 0, SCI_EN) is defined by the ACPI specification to be 
 a "preserved" bit - "OSPM always preserves this bit position", section 
 4.7.3.2.1. However, some machines fail if this bit is in fact preserved 
 because the bit needs to be explicitly set by the OS as a workaround. No 
@@ -1365,8 +1359,7 @@ incorrectly formed _PRT package could ca
 ensure that each package element is actually a sub-package.
 
 Implemented a new interface to install or override a single control method, 
-AcpiInstallMethod. This interface is useful when debugging in order to 
-repair 
+AcpiInstallMethod. This interface is useful when debugging in order to repair 
 an existing method or to install a missing method without having to override 
 the entire ACPI table. See the ACPICA Programmer Reference for use and 
 examples. Lin Ming, Bob Moore.
@@ -1380,8 +1373,7 @@ caller. Lin Ming.
 
 Fixed a problem with Mutex Sync Levels. Fixed a problem where if multiple 
 mutexes of the same sync level are acquired but then not released in strict 
-opposite order, the internally maintained Current Sync Level becomes 
-confused 
+opposite order, the internally maintained Current Sync Level becomes confused 
 and can cause subsequent execution errors. ACPICA BZ 471.
 
 Changed the allowable release order for ASL mutex objects. The ACPI 4.0 
@@ -1404,8 +1396,7 @@ and reduced code for this frequently use
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -1430,12 +1421,10 @@ Fixed a compatibility issue with the rec
 mechanism. For windows compatibility, 1) On a port protection violation, 
 simply ignore the request and do not return an exception (allow the control 
 method to continue execution.) 2) If only part of the request overlaps a 
-protected port, read/write the individual ports that are not protected. 
-Linux 
+protected port, read/write the individual ports that are not protected. Linux 
 BZ 13036. Lin Ming
 
-Enhanced the execution of the ASL/AML BreakPoint operator so that it 
-actually 
+Enhanced the execution of the ASL/AML BreakPoint operator so that it actually 
 breaks into the AML debugger if the debugger is present. This matches the 
 ACPI-defined behavior.
 
@@ -1448,14 +1437,12 @@ ACPICA BZ 766, 767.
 Fixed a number of possible warnings when compiling with gcc 4+ (depending on 
 warning options.) Examples include printf formats, aliasing, unused globals, 
 missing prototypes, missing switch default statements, use of non-ANSI 
-library functions, use of non-ANSI constructs. See generate/unix/Makefile 
-for 
+library functions, use of non-ANSI constructs. See generate/unix/Makefile for 
 a list of warning options used with gcc 3 and 4. ACPICA BZ 735.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -1467,12 +1454,10 @@ much larger code and data size.
 
 2) iASL Compiler/Disassembler and Tools:
 
-iASL: Fixed a generation warning from Bison 2.3 and fixed several warnings 
-on 
+iASL: Fixed a generation warning from Bison 2.3 and fixed several warnings on 
 the 64-bit build.
 
-iASL: Fixed a problem where the Unix/Linux versions of the compiler could 
-not 
+iASL: Fixed a problem where the Unix/Linux versions of the compiler could not 
 correctly digest Windows/DOS formatted files (with CR/LF).
 
 iASL: Added a new option for "quiet mode" (-va) that produces only the 
@@ -1500,10 +1485,8 @@ execute fully on Cygwin.
 1) ACPI CA Core Subsystem:
 
 Fixed a possible race condition between AcpiWalkNamespace and dynamic table 
-unloads. Added a reader/writer locking mechanism to allow multiple 
-concurrent 
-namespace walks (readers), but block a dynamic table unload until it can 
-gain 
+unloads. Added a reader/writer locking mechanism to allow multiple concurrent 
+namespace walks (readers), but block a dynamic table unload until it can gain 
 exclusive write access to the namespace. This fixes a problem where a table 
 unload could (possibly catastrophically) delete the portion of the namespace 
 that is currently being examined by a walk. Adds a new file, utlock.c, that 
@@ -1537,8 +1520,7 @@ performed on a per-field basis instead o
 Modified the handling of the PM1 Status Register ignored bit (bit 11.) 
 Ignored bits must be "preserved" according to the ACPI spec. Usually, this 
 means a read/modify/write when writing to the register. However, for status 
-registers, writing a one means clear the event. Writing a zero means 
-preserve 
+registers, writing a one means clear the event. Writing a zero means preserve 
 the event (do not clear.) This behavior is clarified in the ACPI 4.0 spec, 
 and the ACPICA code now simply always writes a zero to the ignored bit.
 
@@ -1578,8 +1560,7 @@ AcpiGetRegisterUnlocked function is no l
 This will improve performance for reads on these registers. ACPICA BZ 760.
 
 Fixed the parameter validation for AcpiRead/Write. Now return 
-AE_BAD_PARAMETER if the input register pointer is null, and AE_BAD_ADDRESS 
-if 
+AE_BAD_PARAMETER if the input register pointer is null, and AE_BAD_ADDRESS if 
 the register has an address of zero. Previously, these cases simply returned 
 AE_OK. For optional registers such as PM1B status/enable/control, the caller 
 should check for a valid register address before calling. ACPICA BZ 748.
@@ -1592,33 +1573,27 @@ and condensing duplicate code to reduce 
 
 Added new functions to transparently handle the possibly split PM1 A/B 
 registers. AcpiHwReadMultiple and AcpiHwWriteMultiple. These two functions 
-now handle the split registers for PM1 Status, Enable, and Control. ACPICA 
-BZ 
+now handle the split registers for PM1 Status, Enable, and Control. ACPICA BZ 
 746.
 
 Added a function to handle the PM1 control registers, AcpiHwWritePm1Control. 
-This function writes both of the PM1 control registers (A/B). These 
-registers 
+This function writes both of the PM1 control registers (A/B). These registers 
 are different than the PM1 A/B status and enable registers in that different 
 values can be written to the A/B registers. Most notably, the SLP_TYP bits 
-can be different, as per the values returned from the _Sx predefined 
-methods.
+can be different, as per the values returned from the _Sx predefined methods.
 
 Removed an extra register write within AcpiHwClearAcpiStatus. This function 
 was writing an optional PM1B status register twice. The existing call to the 
 low-level AcpiHwRegisterWrite automatically handles a possibly split PM1 A/B 
 register. ACPICA BZ 751.
 
-Split out the PM1 Status registers from the FADT. Added new globals for 
-these 
+Split out the PM1 Status registers from the FADT. Added new globals for these 
 registers (A/B), similar to the way the PM1 Enable registers are handled. 
 Instead of overloading the FADT Event Register blocks. This makes the code 
 clearer and less prone to error.
 
-Fixed the warning message for when the platform contains too many ACPI 
-tables 
-for the default size of the global root table data structure. The 
-calculation 
+Fixed the warning message for when the platform contains too many ACPI tables 
+for the default size of the global root table data structure. The calculation 
 for the truncation value was incorrect.
 
 Removed the ACPI_GET_OBJECT_TYPE macro. Removed all instances of this 
@@ -1633,15 +1608,13 @@ Conditionally compile the AcpiSetFirmwar
 function is only needed on 64-bit host operating systems and is thus not 
 included for 32-bit hosts.
 
-Debug output: print the input and result for invocations of the _OSI 
-reserved 
+Debug output: print the input and result for invocations of the _OSI reserved 
 control method via the ACPI_LV_INFO debug level. Also, reduced some of the 
 verbosity of this debug level. Len Brown.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -1666,8 +1639,7 @@ virtually every file in the ACPICA core 
 the tools/utilities.
 
 Implemented a change to allow the host to override any ACPI table, including 
-dynamically loaded tables. Previously, only the DSDT could be replaced by 
-the 
+dynamically loaded tables. Previously, only the DSDT could be replaced by the 
 host. With this change, the AcpiOsTableOverride interface is called for each 
 table found in the RSDT/XSDT during ACPICA initialization, and also whenever 
 a table is dynamically loaded via the AML Load operator.
@@ -1680,8 +1652,7 @@ with the actual namespace entry which is
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -1727,8 +1698,7 @@ file, components/hardware/hwxface.c
 Enhanced the FADT parsing and low-level ACPI register access: The ACPI 
 register lengths within the FADT are now used, and the low level ACPI 
 register access no longer hardcodes the ACPI register lengths. Given that 
-there may be some risk in actually trusting the FADT register lengths, a 
-run-
+there may be some risk in actually trusting the FADT register lengths, a run-
 time option was added to fall back to the default hardcoded lengths if the 
 FADT proves to contain incorrect values - UseDefaultRegisterWidths. This 
 option is set to true for now, and a warning is issued if a suspicious FADT 
@@ -1741,14 +1711,12 @@ Packages. Lin Ming.
 Added semaphore support to the Linux/Unix application OS-services layer 
 (OSL). ACPICA BZ 448. Lin Ming.
 
-Added the ACPI_MUTEX_TYPE configuration option to select whether mutexes 
-will 
+Added the ACPI_MUTEX_TYPE configuration option to select whether mutexes will 
 be implemented in the OSL, or will binary semaphores be used instead.
 
 Example Code and Data Size: These are the sizes for the OS-independent 
 acpica.lib produced by the Microsoft Visual C++ 6.0 32-bit compiler. The 
-debug version of the code includes the debug output trace mechanism and has 
-a 
+debug version of the code includes the debug output trace mechanism and has a 
 much larger code and data size.
 
   Previous Release:
@@ -1760,8 +1728,7 @@ much larger code and data size.
 
 2) iASL Compiler/Disassembler and Tools:
 
-iASL: Completed the '-e' option to include additional ACPI tables in order 
-to 
+iASL: Completed the '-e' option to include additional ACPI tables in order to 
 aid with disassembly and External statement generation. ACPICA BZ 742. Lin 
 Ming.
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 20:17:52 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 77738106566B;
	Fri, 15 Apr 2011 20:17:52 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 641508FC1C;
	Fri, 15 Apr 2011 20:17:52 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FKHq7h080627;
	Fri, 15 Apr 2011 20:17:52 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FKHqgh080624;
	Fri, 15 Apr 2011 20:17:52 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104152017.p3FKHqgh080624@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Fri, 15 Apr 2011 20:17:52 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220667 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 20:17:52 -0000

Author: bschmidt
Date: Fri Apr 15 20:17:52 2011
New Revision: 220667
URL: http://svn.freebsd.org/changeset/base/220667

Log:
  Split up watchdog and calibration callout. This allows us to use different
  timing on both and to remove some monitor mode specific hacks (which has
  no calibration).

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnvar.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Fri Apr 15 19:50:38 2011	(r220666)
+++ head/sys/dev/iwn/if_iwn.c	Fri Apr 15 20:17:52 2011	(r220667)
@@ -123,10 +123,9 @@ static struct ieee80211_node *iwn_node_a
 		    const uint8_t mac[IEEE80211_ADDR_LEN]);
 static int	iwn_media_change(struct ifnet *);
 static int	iwn_newstate(struct ieee80211vap *, enum ieee80211_state, int);
+static void	iwn_calib_timeout(void *);
 static void	iwn_rx_phy(struct iwn_softc *, struct iwn_rx_desc *,
 		    struct iwn_rx_data *);
-static void	iwn_timer_timeout(void *);
-static void	iwn_calib_reset(struct iwn_softc *);
 static void	iwn_rx_done(struct iwn_softc *, struct iwn_rx_desc *,
 		    struct iwn_rx_data *);
 #if 0	/* HT */
@@ -161,7 +160,7 @@ static int	iwn_raw_xmit(struct ieee80211
 		    const struct ieee80211_bpf_params *);
 static void	iwn_start(struct ifnet *);
 static void	iwn_start_locked(struct ifnet *);
-static void	iwn_watchdog(struct iwn_softc *sc);
+static void	iwn_watchdog(void *);
 static int	iwn_ioctl(struct ifnet *, u_long, caddr_t);
 static int	iwn_cmd(struct iwn_softc *, int, const void *, int, int);
 static int	iwn4965_add_node(struct iwn_softc *, struct iwn_node_info *,
@@ -475,7 +474,6 @@ iwn_attach(device_t dev)
 	}
 
 	IWN_LOCK_INIT(sc);
-	callout_init_mtx(&sc->sc_timer_to, &sc->sc_mtx, 0);
 	TASK_INIT(&sc->sc_reinit_task, 0, iwn_hw_reset, sc );
 	TASK_INIT(&sc->sc_radioon_task, 0, iwn_radio_on, sc );
 	TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radio_off, sc );
@@ -668,6 +666,10 @@ iwn_attach(device_t dev)
 #endif
 
 	iwn_radiotap_attach(sc);
+
+	callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0);
+	callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0);
+
 	iwn_sysctlattach(sc);
 
 	/*
@@ -860,7 +862,8 @@ iwn_detach(device_t dev)
 		ieee80211_draintask(ic, &sc->sc_radiooff_task);
 
 		iwn_stop(sc);
-		callout_drain(&sc->sc_timer_to);
+		callout_drain(&sc->watchdog_to);
+		callout_drain(&sc->calib_to);
 		ieee80211_ifdetach(ic);
 	}
 
@@ -1942,7 +1945,7 @@ iwn_newstate(struct ieee80211vap *vap, e
 
 	IEEE80211_UNLOCK(ic);
 	IWN_LOCK(sc);
-	callout_stop(&sc->sc_timer_to);
+	callout_stop(&sc->calib_to);
 
 	switch (nstate) {
 	case IEEE80211_S_ASSOC:
@@ -1959,7 +1962,8 @@ iwn_newstate(struct ieee80211vap *vap, e
 		 */
 		sc->rxon.associd = 0;
 		sc->rxon.filter &= ~htole32(IWN_FILTER_BSS);
-		iwn_calib_reset(sc);
+		sc->calib.state = IWN_CALIB_STATE_INIT;
+
 		error = iwn_auth(sc, vap);
 		break;
 
@@ -1967,9 +1971,8 @@ iwn_newstate(struct ieee80211vap *vap, e
 		/*
 		 * RUN -> RUN transition; Just restart the timers.
 		 */
-		if (vap->iv_state == IEEE80211_S_RUN &&
-		    vap->iv_opmode != IEEE80211_M_MONITOR) {
-			iwn_calib_reset(sc);
+		if (vap->iv_state == IEEE80211_S_RUN) {
+			sc->calib_cnt = 0;
 			break;
 		}
 
@@ -1981,6 +1984,10 @@ iwn_newstate(struct ieee80211vap *vap, e
 		error = iwn_run(sc, vap);
 		break;
 
+	case IEEE80211_S_INIT:
+		sc->calib.state = IWN_CALIB_STATE_INIT;
+		break;
+
 	default:
 		break;
 	}
@@ -1989,6 +1996,27 @@ iwn_newstate(struct ieee80211vap *vap, e
 	return ivp->iv_newstate(vap, nstate, arg);
 }
 
+static void
+iwn_calib_timeout(void *arg)
+{
+	struct iwn_softc *sc = arg;
+
+	IWN_LOCK_ASSERT(sc);
+
+	/* Force automatic TX power calibration every 60 secs. */
+	if (++sc->calib_cnt >= 120) {
+		uint32_t flags = 0;
+
+		DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s\n",
+		    "sending request for statistics");
+		(void)iwn_cmd(sc, IWN_CMD_GET_STATISTICS, &flags,
+		    sizeof flags, 1);
+		sc->calib_cnt = 0;
+	}
+	callout_reset(&sc->calib_to, msecs_to_ticks(500), iwn_calib_timeout,
+	    sc);
+}
+
 /*
  * Process an RX_PHY firmware notification.  This is usually immediately
  * followed by an MPDU_RX_DONE notification.
@@ -2007,32 +2035,6 @@ iwn_rx_phy(struct iwn_softc *sc, struct 
 	sc->last_rx_valid = 1;
 }
 
-static void
-iwn_timer_timeout(void *arg)
-{
-	struct iwn_softc *sc = arg;
-	uint32_t flags = 0;
-
-	IWN_LOCK_ASSERT(sc);
-
-	if (sc->calib_cnt && --sc->calib_cnt == 0) {
-		DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s\n",
-		    "send statistics request");
-		(void) iwn_cmd(sc, IWN_CMD_GET_STATISTICS, &flags,
-		    sizeof flags, 1);
-		sc->calib_cnt = 60;	/* do calibration every 60s */
-	}
-	iwn_watchdog(sc);		/* NB: piggyback tx watchdog */
-	callout_reset(&sc->sc_timer_to, hz, iwn_timer_timeout, sc);
-}
-
-static void
-iwn_calib_reset(struct iwn_softc *sc)
-{
-	callout_reset(&sc->sc_timer_to, hz, iwn_timer_timeout, sc);
-	sc->calib_cnt = 60;		/* do calibration every 60s */
-}
-
 /*
  * Process an RX_DONE (4965AGN only) or MPDU_RX_DONE firmware notification.
  * Each MPDU_RX_DONE notification must be preceded by an RX_PHY one.
@@ -2222,7 +2224,7 @@ iwn_rx_statistics(struct iwn_softc *sc, 
 
 	bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
 	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: cmd %d\n", __func__, desc->type);
-	iwn_calib_reset(sc);	/* Reset TX power calibration timeout. */
+	sc->calib_cnt = 0;	/* Reset TX power calibration timeout. */
 
 	/* Test if temperature has changed. */
 	if (stats->general.temp != sc->rawtemp) {
@@ -3306,6 +3308,8 @@ iwn_raw_xmit(struct ieee80211_node *ni, 
 		ieee80211_free_node(ni);
 		ifp->if_oerrors++;
 	}
+	sc->sc_tx_timer = 5;
+
 	IWN_UNLOCK(sc);
 	return error;
 }
@@ -3352,15 +3356,24 @@ iwn_start_locked(struct ifnet *ifp)
 }
 
 static void
-iwn_watchdog(struct iwn_softc *sc)
+iwn_watchdog(void *arg)
 {
-	if (sc->sc_tx_timer > 0 && --sc->sc_tx_timer == 0) {
-		struct ifnet *ifp = sc->sc_ifp;
-		struct ieee80211com *ic = ifp->if_l2com;
+	struct iwn_softc *sc = arg;
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
+
+	IWN_LOCK_ASSERT(sc);
+
+	KASSERT(ifp->if_drv_flags & IFF_DRV_RUNNING, ("not running"));
 
-		if_printf(ifp, "device timeout\n");
-		ieee80211_runtask(ic, &sc->sc_reinit_task);
+	if (sc->sc_tx_timer > 0 || counter == 50) {
+		if (--sc->sc_tx_timer == 0 || counter == 50) {
+			if_printf(ifp, "device timeout\n");
+			ieee80211_runtask(ic, &sc->sc_reinit_task);
+			return;
+		}
 	}
+	callout_reset(&sc->watchdog_to, hz, iwn_watchdog, sc);
 }
 
 static int
@@ -4760,8 +4773,6 @@ iwn_auth(struct iwn_softc *sc, struct ie
 	struct ieee80211_node *ni = vap->iv_bss;
 	int error;
 
-	sc->calib.state = IWN_CALIB_STATE_INIT;
-
 	/* Update adapter configuration. */
 	IEEE80211_ADDR_COPY(sc->rxon.bssid, ni->ni_bssid);
 	sc->rxon.chan = ieee80211_chan2ieee(ic, ni->ni_chan);
@@ -4954,7 +4965,9 @@ iwn_run(struct iwn_softc *sc, struct iee
 
 	/* Start periodic calibration timer. */
 	sc->calib.state = IWN_CALIB_STATE_ASSOC;
-	iwn_calib_reset(sc);
+	sc->calib_cnt = 0;
+	callout_reset(&sc->calib_to, msecs_to_ticks(500), iwn_calib_timeout,
+	    sc);
 
 	/* Link LED always on while associated. */
 	iwn_set_led(sc, IWN_LED_LINK, 0, 1);
@@ -6406,6 +6419,7 @@ iwn_init_locked(struct iwn_softc *sc)
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 
+	callout_reset(&sc->watchdog_to, hz, iwn_watchdog, sc);
 	return;
 
 fail:
@@ -6435,7 +6449,8 @@ iwn_stop_locked(struct iwn_softc *sc)
 	IWN_LOCK_ASSERT(sc);
 
 	sc->sc_tx_timer = 0;
-	callout_stop(&sc->sc_timer_to);
+	callout_stop(&sc->watchdog_to);
+	callout_stop(&sc->calib_to);
 	ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
 
 	/* Power OFF hardware. */

Modified: head/sys/dev/iwn/if_iwnvar.h
==============================================================================
--- head/sys/dev/iwn/if_iwnvar.h	Fri Apr 15 19:50:38 2011	(r220666)
+++ head/sys/dev/iwn/if_iwnvar.h	Fri Apr 15 20:17:52 2011	(r220667)
@@ -260,8 +260,10 @@ struct iwn_softc {
 	struct task		sc_radioon_task;
 	struct task		sc_radiooff_task;
 
+	struct callout		calib_to;
 	int			calib_cnt;
 	struct iwn_calib_state	calib;
+	struct callout		watchdog_to;
 	u_int			calib_init;
 	u_int			calib_runtime;
 #define	IWN_CALIB_XTAL			(1 << IWN_CALIB_IDX_XTAL)
@@ -312,7 +314,6 @@ struct iwn_softc {
 	uint8_t			rxchainmask;
 	uint8_t			chainmask;
 
-	struct callout		sc_timer_to;
 	int			sc_tx_timer;
 
 	struct iwn_rx_radiotap_header sc_rxtap;

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 20:19:19 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2C8CF106564A;
	Fri, 15 Apr 2011 20:19:19 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1A6568FC12;
	Fri, 15 Apr 2011 20:19:19 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FKJJlN080693;
	Fri, 15 Apr 2011 20:19:19 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FKJIhX080691;
	Fri, 15 Apr 2011 20:19:18 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104152019.p3FKJIhX080691@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Fri, 15 Apr 2011 20:19:18 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220668 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 20:19:19 -0000

Author: bschmidt
Date: Fri Apr 15 20:19:18 2011
New Revision: 220668
URL: http://svn.freebsd.org/changeset/base/220668

Log:
  remove debug left-overs

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Fri Apr 15 20:17:52 2011	(r220667)
+++ head/sys/dev/iwn/if_iwn.c	Fri Apr 15 20:19:18 2011	(r220668)
@@ -3366,8 +3366,8 @@ iwn_watchdog(void *arg)
 
 	KASSERT(ifp->if_drv_flags & IFF_DRV_RUNNING, ("not running"));
 
-	if (sc->sc_tx_timer > 0 || counter == 50) {
-		if (--sc->sc_tx_timer == 0 || counter == 50) {
+	if (sc->sc_tx_timer > 0) {
+		if (--sc->sc_tx_timer == 0) {
 			if_printf(ifp, "device timeout\n");
 			ieee80211_runtask(ic, &sc->sc_reinit_task);
 			return;

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 20:31:02 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 75F32106564A;
	Fri, 15 Apr 2011 20:31:02 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6304E8FC18;
	Fri, 15 Apr 2011 20:31:02 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FKV2Ln081207;
	Fri, 15 Apr 2011 20:31:02 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FKV2Ff081204;
	Fri, 15 Apr 2011 20:31:02 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104152031.p3FKV2Ff081204@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Fri, 15 Apr 2011 20:31:02 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220674 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 20:31:02 -0000

Author: bschmidt
Date: Fri Apr 15 20:31:02 2011
New Revision: 220674
URL: http://svn.freebsd.org/changeset/base/220674

Log:
  Revert some of local calibration changes in favour of the OpenBSD
  implementation. This includes the fix required for the 6050 series
  devices.

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnvar.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Fri Apr 15 20:28:38 2011	(r220673)
+++ head/sys/dev/iwn/if_iwn.c	Fri Apr 15 20:31:02 2011	(r220674)
@@ -132,6 +132,8 @@ static void	iwn_rx_done(struct iwn_softc
 static void	iwn_rx_compressed_ba(struct iwn_softc *, struct iwn_rx_desc *,
 		    struct iwn_rx_data *);
 #endif
+static void	iwn5000_rx_calib_results(struct iwn_softc *,
+		    struct iwn_rx_desc *, struct iwn_rx_data *);
 static void	iwn_rx_statistics(struct iwn_softc *, struct iwn_rx_desc *,
 		    struct iwn_rx_data *);
 static void	iwn4965_tx_done(struct iwn_softc *, struct iwn_rx_desc *,
@@ -217,15 +219,10 @@ static void	iwn5000_ampdu_tx_start(struc
 		    struct ieee80211_node *, uint8_t, uint16_t);
 static void	iwn5000_ampdu_tx_stop(struct iwn_softc *, uint8_t, uint16_t);
 #endif
-static int	iwn5000_send_calib_results(struct iwn_softc *);
-static int	iwn5000_save_calib_result(struct iwn_softc *,
-		    struct iwn_phy_calib *, int, int);
-static void	iwn5000_free_calib_results(struct iwn_softc *);
-static int	iwn5000_chrystal_calib(struct iwn_softc *);
-static int	iwn5000_send_calib_query(struct iwn_softc *, uint32_t);
-static int	iwn5000_rx_calib_result(struct iwn_softc *,
-		    struct iwn_rx_desc *, struct iwn_rx_data *);
+static int	iwn5000_query_calibration(struct iwn_softc *);
+static int	iwn5000_send_calibration(struct iwn_softc *);
 static int	iwn5000_send_wimax_coex(struct iwn_softc *);
+static int	iwn5000_crystal_calib(struct iwn_softc *);
 static int	iwn4965_post_alive(struct iwn_softc *);
 static int	iwn5000_post_alive(struct iwn_softc *);
 static int	iwn4965_load_bootcode(struct iwn_softc *, const uint8_t *,
@@ -709,9 +706,6 @@ iwn_hal_attach(struct iwn_softc *sc)
 		sc->fwname = "iwn5000fw";
 		sc->txchainmask = IWN_ANT_B;
 		sc->rxchainmask = IWN_ANT_AB;
-		sc->calib_init = IWN_CALIB_XTAL | IWN_CALIB_LO |
-		    IWN_CALIB_TX_IQ | IWN_CALIB_TX_IQ_PERIODIC |
-		    IWN_CALIB_BASE_BAND;
 		break;
 	case IWN_HW_REV_TYPE_5150:
 		sc->sc_hal = &iwn5000_hal;
@@ -719,8 +713,6 @@ iwn_hal_attach(struct iwn_softc *sc)
 		sc->fwname = "iwn5150fw";
 		sc->txchainmask = IWN_ANT_A;
 		sc->rxchainmask = IWN_ANT_AB;
-		sc->calib_init = IWN_CALIB_DC | IWN_CALIB_LO |
-		    IWN_CALIB_TX_IQ | IWN_CALIB_BASE_BAND;
 		break;
 	case IWN_HW_REV_TYPE_5300:
 	case IWN_HW_REV_TYPE_5350:
@@ -729,9 +721,6 @@ iwn_hal_attach(struct iwn_softc *sc)
 		sc->fwname = "iwn5000fw";
 		sc->txchainmask = IWN_ANT_ABC;
 		sc->rxchainmask = IWN_ANT_ABC;
-		sc->calib_init = IWN_CALIB_XTAL | IWN_CALIB_LO |
-		    IWN_CALIB_TX_IQ | IWN_CALIB_TX_IQ_PERIODIC |
-		    IWN_CALIB_BASE_BAND;
 		break;
 	case IWN_HW_REV_TYPE_1000:
 		sc->sc_hal = &iwn5000_hal;
@@ -739,9 +728,6 @@ iwn_hal_attach(struct iwn_softc *sc)
 		sc->fwname = "iwn1000fw";
 		sc->txchainmask = IWN_ANT_A;
 		sc->rxchainmask = IWN_ANT_AB;
-		sc->calib_init = IWN_CALIB_XTAL | IWN_CALIB_LO |
-		    IWN_CALIB_TX_IQ | IWN_CALIB_TX_IQ_PERIODIC |
-		    IWN_CALIB_BASE_BAND;
 		break;
 	case IWN_HW_REV_TYPE_6000:
 		sc->sc_hal = &iwn5000_hal;
@@ -757,11 +743,8 @@ iwn_hal_attach(struct iwn_softc *sc)
 		default:
 			sc->txchainmask = IWN_ANT_ABC;
 			sc->rxchainmask = IWN_ANT_ABC;
-			sc->calib_runtime = IWN_CALIB_DC;
 			break;
 		}
-		sc->calib_init = IWN_CALIB_XTAL | IWN_CALIB_LO |
-		    IWN_CALIB_TX_IQ | IWN_CALIB_BASE_BAND;
 		break;
 	case IWN_HW_REV_TYPE_6050:
 		sc->sc_hal = &iwn5000_hal;
@@ -769,9 +752,6 @@ iwn_hal_attach(struct iwn_softc *sc)
 		sc->fwname = "iwn6050fw";
 		sc->txchainmask = IWN_ANT_AB;
 		sc->rxchainmask = IWN_ANT_AB;
-		sc->calib_init = IWN_CALIB_XTAL | IWN_CALIB_LO |
-		    IWN_CALIB_TX_IQ | IWN_CALIB_BASE_BAND;
-		sc->calib_runtime = IWN_CALIB_DC;
 		break;
 	case IWN_HW_REV_TYPE_6005:
 		sc->sc_hal = &iwn5000_hal;
@@ -779,9 +759,6 @@ iwn_hal_attach(struct iwn_softc *sc)
 		sc->fwname = "iwn6005fw";
 		sc->txchainmask = IWN_ANT_AB;
 		sc->rxchainmask = IWN_ANT_AB;
-		sc->calib_init = IWN_CALIB_XTAL | IWN_CALIB_LO |
-		    IWN_CALIB_TX_IQ | IWN_CALIB_BASE_BAND;
-		sc->calib_runtime = IWN_CALIB_DC;
 		break;
 	default:
 		device_printf(sc->sc_dev, "adapter type %d not supported\n",
@@ -867,8 +844,6 @@ iwn_detach(device_t dev)
 		ieee80211_ifdetach(ic);
 	}
 
-	iwn5000_free_calib_results(sc);
-
 	/* Free DMA resources. */
 	iwn_free_rx_ring(sc, &sc->rxq);
 	if (sc->sc_hal != NULL)
@@ -1679,7 +1654,7 @@ static void
 iwn5000_read_eeprom(struct iwn_softc *sc)
 {
 	struct iwn5000_eeprom_calib_hdr hdr;
-	int32_t temp, volt;
+	int32_t volt;
 	uint32_t addr, base;
 	int i;
 	uint16_t val;
@@ -1711,12 +1686,18 @@ iwn5000_read_eeprom(struct iwn_softc *sc
 	if (sc->hw_type == IWN_HW_REV_TYPE_5150) {
 		/* Compute temperature offset. */
 		iwn_read_prom_data(sc, base + IWN5000_EEPROM_TEMP, &val, 2);
-		temp = le16toh(val);
+		sc->eeprom_temp = le16toh(val);
 		iwn_read_prom_data(sc, base + IWN5000_EEPROM_VOLT, &val, 2);
 		volt = le16toh(val);
-		sc->temp_off = temp - (volt / -5);
+		sc->temp_off = sc->eeprom_temp - (volt / -5);
 		DPRINTF(sc, IWN_DEBUG_CALIBRATE, "temp=%d volt=%d offset=%dK\n",
-		    temp, volt, sc->temp_off);
+		    sc->eeprom_temp, volt, sc->temp_off);
+	} else {
+		/* Read crystal calibration. */
+		iwn_read_prom_data(sc, base + IWN5000_EEPROM_CRYSTAL,
+		    &sc->eeprom_crystal, sizeof (uint32_t));
+		DPRINTF(sc, IWN_DEBUG_CALIBRATE, "crystal calibration 0x%08x\n",
+		    le32toh(sc->eeprom_crystal));
 	}
 }
 
@@ -2202,6 +2183,63 @@ iwn_rx_compressed_ba(struct iwn_softc *s
 #endif
 
 /*
+ * Process a CALIBRATION_RESULT notification sent by the initialization
+ * firmware on response to a CMD_CALIB_CONFIG command (5000 only).
+ */
+static void
+iwn5000_rx_calib_results(struct iwn_softc *sc, struct iwn_rx_desc *desc,
+    struct iwn_rx_data *data)
+{
+	struct iwn_phy_calib *calib = (struct iwn_phy_calib *)(desc + 1);
+	int len, idx = -1;
+
+	/* Runtime firmware should not send such a notification. */
+	if (sc->sc_flags & IWN_FLAG_CALIB_DONE)
+		return;
+
+	len = (le32toh(desc->len) & 0x3fff) - 4;
+	bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
+
+	switch (calib->code) {
+	case IWN5000_PHY_CALIB_DC:
+		if (sc->hw_type == IWN_HW_REV_TYPE_5150)
+			idx = 0;
+		break;
+	case IWN5000_PHY_CALIB_LO:
+		idx = 1;
+		break;
+	case IWN5000_PHY_CALIB_TX_IQ:
+		idx = 2;
+		break;
+	case IWN5000_PHY_CALIB_TX_IQ_PERIODIC:
+		if (sc->hw_type < IWN_HW_REV_TYPE_6000 &&
+		    sc->hw_type != IWN_HW_REV_TYPE_5150)
+			idx = 3;
+		break;
+	case IWN5000_PHY_CALIB_BASE_BAND:
+		idx = 4;
+		break;
+	}
+	if (idx == -1)	/* Ignore other results. */
+		return;
+
+	/* Save calibration result. */
+	if (sc->calibcmd[idx].buf != NULL)
+		free(sc->calibcmd[idx].buf, M_DEVBUF);
+	sc->calibcmd[idx].buf = malloc(len, M_DEVBUF, M_NOWAIT);
+	if (sc->calibcmd[idx].buf == NULL) {
+		DPRINTF(sc, IWN_DEBUG_CALIBRATE,
+		    "not enough memory for calibration result %d\n",
+		    calib->code);
+		return;
+	}
+	DPRINTF(sc, IWN_DEBUG_CALIBRATE,
+	    "saving calibration result code=%d len=%d\n", calib->code, len);
+	sc->calibcmd[idx].len = len;
+	memcpy(sc->calibcmd[idx].buf, calib, len);
+}
+
+/*
  * Process an RX_STATISTICS or BEACON_STATISTICS firmware notification.
  * The latter is sent by the firmware after each received beacon.
  */
@@ -2555,7 +2593,7 @@ iwn_notif_intr(struct iwn_softc *sc)
 			break;
 		}
 		case IWN5000_CALIBRATION_RESULT:
-			iwn5000_rx_calib_result(sc, desc, data);
+			iwn5000_rx_calib_results(sc, desc, data);
 			break;
 
 		case IWN5000_CALIBRATION_DONE:
@@ -4849,7 +4887,7 @@ iwn_run(struct iwn_softc *sc, struct iee
 
 	if (ic->ic_opmode == IEEE80211_M_MONITOR) {
 		/* Link LED blinks while monitoring. */
-		iwn_set_led(sc, IWN_LED_LINK, 20, 20);
+		iwn_set_led(sc, IWN_LED_LINK, 5, 5);
 		return 0;
 	}
 	error = iwn_set_timing(sc, ni);
@@ -5192,200 +5230,57 @@ iwn5000_ampdu_tx_stop(struct iwn_softc *
 #endif
 
 /*
- * Send calibration results to the runtime firmware.  These results were
- * obtained on first boot from the initialization firmware, or by reading
- * the EEPROM for crystal calibration.
- */
-static int
-iwn5000_send_calib_results(struct iwn_softc *sc)
-{
-	struct iwn_calib_info *calib_result;
-	int idx, error;
-
-	for (idx = 0; idx < IWN_CALIB_NUM; idx++) {
-		calib_result = &sc->calib_results[idx];
-
-		/* No support for this type of calibration. */
-		if ((sc->calib_init & (1 << idx)) == 0)
-			continue;
-
-		/* No calibration result available. */
-		if (calib_result->buf == NULL)
-			continue;
-
-		DPRINTF(sc, IWN_DEBUG_CALIBRATE,
-		    "%s: send calibration result idx=%d, len=%d\n",
-		    __func__, idx, calib_result->len);
-
-		error = iwn_cmd(sc, IWN_CMD_PHY_CALIB, calib_result->buf,
-		    calib_result->len, 0);
-		if (error != 0) {
-			device_printf(sc->sc_dev,
-			    "%s: could not send calibration result "
-			    "idx=%d, error=%d\n",
-			    __func__, idx, error);
-			return error;
-		}
-	}
-	return 0;
-}
-
-/*
- * Save calibration result at the given index.  The index determines
- * in which order the results are sent to the runtime firmware.
- */
-static int
-iwn5000_save_calib_result(struct iwn_softc *sc, struct iwn_phy_calib *calib,
-    int len, int idx)
-{
-	struct iwn_calib_info *calib_result = &sc->calib_results[idx];
-
-	DPRINTF(sc, IWN_DEBUG_CALIBRATE,
-	    "%s: saving calibration result code=%d, idx=%d, len=%d\n",
-	    __func__, calib->code, idx, len);
-
-	if (calib_result->buf != NULL)
-		free(calib_result->buf, M_DEVBUF);
-
-	calib_result->buf = malloc(len, M_DEVBUF, M_NOWAIT);
-	if (calib_result->buf == NULL) {
-		device_printf(sc->sc_dev,
-		    "%s: not enough memory for calibration result "
-		    "code=%d, len=%d\n", __func__, calib->code, len);
-		return ENOMEM;
-	}
-
-	calib_result->len = len;
-	memcpy(calib_result->buf, calib, len);
-	return 0;
-}
-
-static void
-iwn5000_free_calib_results(struct iwn_softc *sc)
-{
-	struct iwn_calib_info *calib_result;
-	int idx;
-
-	for (idx = 0; idx < IWN_CALIB_NUM; idx++) {
-		calib_result = &sc->calib_results[idx];
-
-		if (calib_result->buf != NULL)
-			free(calib_result->buf, M_DEVBUF);
-
-		calib_result->buf = NULL;
-		calib_result->len = 0;
-	}
-}
-
-/*
- * Obtain the crystal calibration result from the EEPROM.
- */
-static int
-iwn5000_chrystal_calib(struct iwn_softc *sc)
-{
-	struct iwn5000_phy_calib_crystal cmd;
-	uint32_t base, crystal;
-	uint16_t val;
-
-	/* Read crystal calibration. */
-	iwn_read_prom_data(sc, IWN5000_EEPROM_CAL, &val, 2);
-	base = le16toh(val);
-	iwn_read_prom_data(sc, base + IWN5000_EEPROM_CRYSTAL, &crystal,
-	    sizeof(uint32_t));
-	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: crystal calibration=0x%08x\n",
-	    __func__, le32toh(crystal));
-
-	memset(&cmd, 0, sizeof cmd);
-	cmd.code = IWN5000_PHY_CALIB_CRYSTAL;
-	cmd.ngroups = 1;
-	cmd.isvalid = 1;
-	cmd.cap_pin[0] = le32toh(crystal) & 0xff;
-	cmd.cap_pin[1] = (le32toh(crystal) >> 16) & 0xff;
-
-	return iwn5000_save_calib_result(sc, (struct iwn_phy_calib *)&cmd,
-	    sizeof cmd, IWN_CALIB_IDX_XTAL);
-}
-
-/*
- * Query calibration results from the initialization firmware.  We do this
- * only once at first boot.
+ * Query calibration tables from the initialization firmware.  We do this
+ * only once at first boot.  Called from a process context.
  */
 static int
-iwn5000_send_calib_query(struct iwn_softc *sc, uint32_t cfg)
+iwn5000_query_calibration(struct iwn_softc *sc)
 {
-#define	CALIB_INIT_CFG	0xffffffff;
 	struct iwn5000_calib_config cmd;
 	int error;
 
 	memset(&cmd, 0, sizeof cmd);
-	cmd.ucode.once.enable = CALIB_INIT_CFG;
-	if (cfg == 0) {
-		cmd.ucode.once.start  = CALIB_INIT_CFG;
-		cmd.ucode.once.send   = CALIB_INIT_CFG;
-		cmd.ucode.flags       = CALIB_INIT_CFG;
-	} else
-		cmd.ucode.once.start  = cfg;
-
-	DPRINTF(sc, IWN_DEBUG_CALIBRATE,
-	    "%s: query calibration results, cfg %x\n", __func__, cfg);
-
+	cmd.ucode.once.enable = 0xffffffff;
+	cmd.ucode.once.start  = 0xffffffff;
+	cmd.ucode.once.send   = 0xffffffff;
+	cmd.ucode.flags       = 0xffffffff;
+	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: sending calibration query\n",
+	    __func__);
 	error = iwn_cmd(sc, IWN5000_CMD_CALIB_CONFIG, &cmd, sizeof cmd, 0);
 	if (error != 0)
 		return error;
 
 	/* Wait at most two seconds for calibration to complete. */
 	if (!(sc->sc_flags & IWN_FLAG_CALIB_DONE))
-		error = msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", 2 * hz);
-
+		error = msleep(sc, &sc->sc_mtx, PCATCH, "iwncal", 2 * hz);
 	return error;
-#undef	CALIB_INIT_CFG
 }
 
 /*
- * Process a CALIBRATION_RESULT notification sent by the initialization
- * firmware on response to a CMD_CALIB_CONFIG command.
+ * Send calibration results to the runtime firmware.  These results were
+ * obtained on first boot from the initialization firmware.
  */
 static int
-iwn5000_rx_calib_result(struct iwn_softc *sc, struct iwn_rx_desc *desc,
-    struct iwn_rx_data *data)
+iwn5000_send_calibration(struct iwn_softc *sc)
 {
-#define	FRAME_SIZE_MASK		0x3fff
-	struct iwn_phy_calib *calib = (struct iwn_phy_calib *)(desc + 1);
-	int len, idx;
-
-	bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
-	len = (le32toh(desc->len) & FRAME_SIZE_MASK);
-
-	/* Remove length field itself. */
-	len -= 4;
+	int idx, error;
 
-	/*
-	 * Determine the order in which the results will be send to the
-	 * runtime firmware.
-	 */
-	switch (calib->code) {
-	case IWN5000_PHY_CALIB_DC:
-		idx = IWN_CALIB_IDX_DC;
-		break;
-	case IWN5000_PHY_CALIB_LO:
-		idx = IWN_CALIB_IDX_LO;
-		break;
-	case IWN5000_PHY_CALIB_TX_IQ:
-		idx = IWN_CALIB_IDX_TX_IQ;
-		break;
-	case IWN5000_PHY_CALIB_TX_IQ_PERIODIC:
-		idx = IWN_CALIB_IDX_TX_IQ_PERIODIC;
-		break;
-	case IWN5000_PHY_CALIB_BASE_BAND:
-		idx = IWN_CALIB_IDX_BASE_BAND;
-		break;
-	default:
+	for (idx = 0; idx < 5; idx++) {
+		if (sc->calibcmd[idx].buf == NULL)
+			continue;	/* No results available. */
 		DPRINTF(sc, IWN_DEBUG_CALIBRATE,
-		   "%s: unknown calibration code=%d\n", __func__, calib->code);
-		return EINVAL;
+		    "send calibration result idx=%d len=%d\n", idx,
+		    sc->calibcmd[idx].len);
+		error = iwn_cmd(sc, IWN_CMD_PHY_CALIB, sc->calibcmd[idx].buf,
+		    sc->calibcmd[idx].len, 0);
+		if (error != 0) {
+			device_printf(sc->sc_dev,
+			    "%s: could not send calibration result, error %d\n",
+			    __func__, error);
+			return error;
+		}
 	}
-	return iwn5000_save_calib_result(sc, calib, len, idx);
-#undef	FRAME_SIZE_MASK
+	return 0;
 }
 
 static int
@@ -5415,6 +5310,22 @@ iwn5000_send_wimax_coex(struct iwn_softc
 	return iwn_cmd(sc, IWN5000_CMD_WIMAX_COEX, &wimax, sizeof wimax, 0);
 }
 
+static int
+iwn5000_crystal_calib(struct iwn_softc *sc)
+{
+	struct iwn5000_phy_calib_crystal cmd;
+
+	memset(&cmd, 0, sizeof cmd);
+	cmd.code = IWN5000_PHY_CALIB_CRYSTAL;
+	cmd.ngroups = 1;
+	cmd.isvalid = 1;
+	cmd.cap_pin[0] = le32toh(sc->eeprom_crystal) & 0xff;
+	cmd.cap_pin[1] = (le32toh(sc->eeprom_crystal) >> 16) & 0xff;
+	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "sending crystal calibration %d, %d\n",
+	    cmd.cap_pin[0], cmd.cap_pin[1]);
+	return iwn_cmd(sc, IWN_CMD_PHY_CALIB, &cmd, sizeof cmd, 0);
+}
+
 /*
  * This function is called after the runtime firmware notifies us of its
  * readiness (called in a process context.)
@@ -5531,36 +5442,21 @@ iwn5000_post_alive(struct iwn_softc *sc)
 		    __func__, error);
 		return error;
 	}
-
-	if (!(sc->sc_flags & IWN_FLAG_CALIB_DONE)) {
-		/*
-		 * Start calibration by setting and sending the chrystal
-		 * calibration first, this must be done before we are able
-		 * to query the other calibration results.
-		 */
-		error = iwn5000_chrystal_calib(sc);
-		if (error != 0) {
-			device_printf(sc->sc_dev,
-			    "%s: could not set chrystal calibration, "
-			    "error=%d\n", __func__, error);
-			return error;
-		}
-		error = iwn5000_send_calib_results(sc);
+	if (sc->hw_type != IWN_HW_REV_TYPE_5150) {
+		/* Perform crystal calibration. */
+		error = iwn5000_crystal_calib(sc);
 		if (error != 0) {
 			device_printf(sc->sc_dev,
-			    "%s: could not send chrystal calibration, "
-			    "error=%d\n", __func__, error);
+			    "%s: crystal calibration failed, error %d\n",
+			    __func__, error);
 			return error;
 		}
-
-		/*
-		 * Query other calibration results from the initialization
-		 * firmware.
-		 */
-		error = iwn5000_send_calib_query(sc, 0);
-		if (error != 0) {
+	}
+	if (!(sc->sc_flags & IWN_FLAG_CALIB_DONE)) {
+		/* Query calibration from the initialization firmware. */
+		if ((error = iwn5000_query_calibration(sc)) != 0) {
 			device_printf(sc->sc_dev,
-			    "%s: could not query calibration, error=%d\n",
+			    "%s: could not query calibration, error %d\n",
 			    __func__, error);
 			return error;
 		}
@@ -5572,24 +5468,8 @@ iwn5000_post_alive(struct iwn_softc *sc)
 		iwn_hw_stop(sc);
 		error = iwn_hw_init(sc);
 	} else {
-		/*
-		 * Send calibration results obtained from the initialization
-		 * firmware to the runtime firmware.
-		 */
-		error = iwn5000_send_calib_results(sc);
-
-		/*
-		 * Tell the runtime firmware to do certain calibration types.
-		 */
-		if (sc->calib_runtime != 0) {
-			error = iwn5000_send_calib_query(sc, sc->calib_runtime);
-			if (error != 0) {
-				device_printf(sc->sc_dev,
-				    "%s: could not send query calibration, "
-				    "error=%d, cfg=%x\n", __func__, error,
-				    sc->calib_runtime);
-			}
-		}
+		/* Send calibration results to runtime firmware. */
+		error = iwn5000_send_calibration(sc);
 	}
 	return error;
 }

Modified: head/sys/dev/iwn/if_iwnvar.h
==============================================================================
--- head/sys/dev/iwn/if_iwnvar.h	Fri Apr 15 20:28:38 2011	(r220673)
+++ head/sys/dev/iwn/if_iwnvar.h	Fri Apr 15 20:31:02 2011	(r220674)
@@ -264,24 +264,9 @@ struct iwn_softc {
 	int			calib_cnt;
 	struct iwn_calib_state	calib;
 	struct callout		watchdog_to;
-	u_int			calib_init;
-	u_int			calib_runtime;
-#define	IWN_CALIB_XTAL			(1 << IWN_CALIB_IDX_XTAL)
-#define	IWN_CALIB_DC			(1 << IWN_CALIB_IDX_DC)
-#define	IWN_CALIB_LO			(1 << IWN_CALIB_IDX_LO)
-#define	IWN_CALIB_TX_IQ			(1 << IWN_CALIB_IDX_TX_IQ)
-#define	IWN_CALIB_TX_IQ_PERIODIC	(1 << IWN_CALIB_IDX_TX_IQ_PERIODIC)
-#define	IWN_CALIB_BASE_BAND		(1 << IWN_CALIB_IDX_BASE_BAND)
-#define	IWN_CALIB_NUM			6
-	struct iwn_calib_info	calib_results[IWN_CALIB_NUM];
-#define	IWN_CALIB_IDX_XTAL		0
-#define	IWN_CALIB_IDX_DC		1
-#define	IWN_CALIB_IDX_LO		2
-#define	IWN_CALIB_IDX_TX_IQ		3
-#define	IWN_CALIB_IDX_TX_IQ_PERIODIC	4
-#define	IWN_CALIB_IDX_BASE_BAND		5
 
 	struct iwn_fw_info	fw;
+	struct iwn_calib_info	calibcmd[5];
 	uint32_t		errptr;
 
 	struct iwn_rx_stat	last_rx_stat;
@@ -300,6 +285,8 @@ struct iwn_softc {
 	uint16_t		rfcfg;
 	uint8_t			calib_ver;
 	char			eeprom_domain[4];
+	uint32_t		eeprom_crystal;
+	int16_t			eeprom_temp;
 	int16_t			eeprom_voltage;
 	int8_t			maxpwr2GHz;
 	int8_t			maxpwr5GHz;

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 20:35:15 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CA0BB106577B;
	Fri, 15 Apr 2011 20:35:15 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B82B28FC18;
	Fri, 15 Apr 2011 20:35:15 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FKZFB6081422;
	Fri, 15 Apr 2011 20:35:15 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FKZFkb081419;
	Fri, 15 Apr 2011 20:35:15 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104152035.p3FKZFkb081419@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Fri, 15 Apr 2011 20:35:15 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220676 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 20:35:16 -0000

Author: bschmidt
Date: Fri Apr 15 20:35:15 2011
New Revision: 220676
URL: http://svn.freebsd.org/changeset/base/220676

Log:
  The 6005 series devices need additional temperature offset calibration
  as well as the IWN_GP_DRIVER_CALIB_VER6 bit set.
  
  Obtained from:	OpenBSD

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnreg.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Fri Apr 15 20:32:17 2011	(r220675)
+++ head/sys/dev/iwn/if_iwn.c	Fri Apr 15 20:35:15 2011	(r220676)
@@ -222,6 +222,7 @@ static void	iwn5000_ampdu_tx_stop(struct
 static int	iwn5000_query_calibration(struct iwn_softc *);
 static int	iwn5000_send_calibration(struct iwn_softc *);
 static int	iwn5000_send_wimax_coex(struct iwn_softc *);
+static int	iwn5000_temp_offset_calib(struct iwn_softc *);
 static int	iwn5000_crystal_calib(struct iwn_softc *);
 static int	iwn4965_post_alive(struct iwn_softc *);
 static int	iwn5000_post_alive(struct iwn_softc *);
@@ -4539,6 +4540,16 @@ iwn_config(struct iwn_softc *sc)
 	int error;
 	uint16_t rxchain;
 
+	if (sc->hw_type == IWN_HW_REV_TYPE_6005) {
+		/* Set radio temperature sensor offset. */
+		error = iwn5000_temp_offset_calib(sc);
+		if (error != 0) {
+			device_printf(sc->sc_dev,
+			    "%s: could not set temperature offset\n", __func__);
+			return error;
+		}
+	}
+
 	/* Configure valid TX chains for 5000 Series. */
 	if (sc->hw_type != IWN_HW_REV_TYPE_4965) {
 		txmask = htole32(sc->txchainmask);
@@ -5326,6 +5337,24 @@ iwn5000_crystal_calib(struct iwn_softc *
 	return iwn_cmd(sc, IWN_CMD_PHY_CALIB, &cmd, sizeof cmd, 0);
 }
 
+static int
+iwn5000_temp_offset_calib(struct iwn_softc *sc)
+{
+	struct iwn5000_phy_calib_temp_offset cmd;
+
+	memset(&cmd, 0, sizeof cmd);
+	cmd.code = IWN5000_PHY_CALIB_TEMP_OFFSET;
+	cmd.ngroups = 1;
+	cmd.isvalid = 1;
+	if (sc->eeprom_temp != 0)
+		cmd.offset = htole16(sc->eeprom_temp);
+	else
+		cmd.offset = htole16(IWN_DEFAULT_TEMP_OFFSET);
+	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "setting radio sensor offset to %d\n",
+	    le16toh(cmd.offset));
+	return iwn_cmd(sc, IWN_CMD_PHY_CALIB, &cmd, sizeof cmd, 0);
+}
+
 /*
  * This function is called after the runtime firmware notifies us of its
  * readiness (called in a process context.)
@@ -6028,7 +6057,8 @@ iwn5000_nic_config(struct iwn_softc *sc)
 		/* Use internal power amplifier only. */
 		IWN_WRITE(sc, IWN_GP_DRIVER, IWN_GP_DRIVER_RADIO_2X2_IPA);
 	}
-	if (sc->hw_type == IWN_HW_REV_TYPE_6050 && sc->calib_ver >= 6) {
+	if ((sc->hw_type == IWN_HW_REV_TYPE_6050 ||
+	     sc->hw_type == IWN_HW_REV_TYPE_6005) && sc->calib_ver >= 6) {
 		/* Indicate that ROM calibration version is >=6. */
 		IWN_SETBITS(sc, IWN_GP_DRIVER, IWN_GP_DRIVER_CALIB_VER6);
 	}

Modified: head/sys/dev/iwn/if_iwnreg.h
==============================================================================
--- head/sys/dev/iwn/if_iwnreg.h	Fri Apr 15 20:32:17 2011	(r220675)
+++ head/sys/dev/iwn/if_iwnreg.h	Fri Apr 15 20:35:15 2011	(r220676)
@@ -885,6 +885,8 @@ struct iwn_phy_calib {
 #define IWN5000_PHY_CALIB_CRYSTAL		15
 #define IWN5000_PHY_CALIB_BASE_BAND		16
 #define IWN5000_PHY_CALIB_TX_IQ_PERIODIC	17
+#define IWN5000_PHY_CALIB_TEMP_OFFSET		18
+
 #define IWN5000_PHY_CALIB_RESET_NOISE_GAIN	18
 #define IWN5000_PHY_CALIB_NOISE_GAIN		19
 
@@ -903,6 +905,17 @@ struct iwn5000_phy_calib_crystal {
 	uint8_t	reserved[2];
 } __packed;
 
+struct iwn5000_phy_calib_temp_offset {
+	uint8_t		code;
+	uint8_t		group;
+	uint8_t		ngroups;
+	uint8_t		isvalid;
+	int16_t		offset;
+#define IWN_DEFAULT_TEMP_OFFSET	2700
+
+	uint16_t	reserved;
+} __packed;
+
 struct iwn_phy_calib_gain {
 	uint8_t	code;
 	uint8_t	group;

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 20:40:49 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5F986106566B;
	Fri, 15 Apr 2011 20:40:49 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4DBE48FC0C;
	Fri, 15 Apr 2011 20:40:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FKenhb081609;
	Fri, 15 Apr 2011 20:40:49 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FKenrf081607;
	Fri, 15 Apr 2011 20:40:49 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104152040.p3FKenrf081607@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Fri, 15 Apr 2011 20:40:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220677 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 20:40:49 -0000

Author: bschmidt
Date: Fri Apr 15 20:40:49 2011
New Revision: 220677
URL: http://svn.freebsd.org/changeset/base/220677

Log:
  fix the order of the prototypes from the previosu commit

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Fri Apr 15 20:35:15 2011	(r220676)
+++ head/sys/dev/iwn/if_iwn.c	Fri Apr 15 20:40:49 2011	(r220677)
@@ -222,8 +222,8 @@ static void	iwn5000_ampdu_tx_stop(struct
 static int	iwn5000_query_calibration(struct iwn_softc *);
 static int	iwn5000_send_calibration(struct iwn_softc *);
 static int	iwn5000_send_wimax_coex(struct iwn_softc *);
-static int	iwn5000_temp_offset_calib(struct iwn_softc *);
 static int	iwn5000_crystal_calib(struct iwn_softc *);
+static int	iwn5000_temp_offset_calib(struct iwn_softc *);
 static int	iwn4965_post_alive(struct iwn_softc *);
 static int	iwn5000_post_alive(struct iwn_softc *);
 static int	iwn4965_load_bootcode(struct iwn_softc *, const uint8_t *,

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 21:38:24 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8C3D6106566B;
	Fri, 15 Apr 2011 21:38:24 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 78B1F8FC12;
	Fri, 15 Apr 2011 21:38:24 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FLcOZx083033;
	Fri, 15 Apr 2011 21:38:24 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FLcOXu083028;
	Fri, 15 Apr 2011 21:38:24 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104152138.p3FLcOXu083028@svn.freebsd.org>
From: Jung-uk Kim 
Date: Fri, 15 Apr 2011 21:38:24 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220681 - head/sys/contrib/dev/acpica/compiler
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 21:38:24 -0000

Author: jkim
Date: Fri Apr 15 21:38:24 2011
New Revision: 220681
URL: http://svn.freebsd.org/changeset/base/220681

Log:
  Re-merge with ACPICA vendor source.

Modified:
  head/sys/contrib/dev/acpica/compiler/aslcompiler.y
  head/sys/contrib/dev/acpica/compiler/asldefine.h
  head/sys/contrib/dev/acpica/compiler/aslutils.c
  head/sys/contrib/dev/acpica/compiler/dtparser.y
Directory Properties:
  head/sys/contrib/dev/acpica/   (props changed)

Modified: head/sys/contrib/dev/acpica/compiler/aslcompiler.y
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslcompiler.y	Fri Apr 15 21:33:45 2011	(r220680)
+++ head/sys/contrib/dev/acpica/compiler/aslcompiler.y	Fri Apr 15 21:38:24 2011	(r220681)
@@ -43,14 +43,6 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
-#define YYDEBUG 1
-#define YYERROR_VERBOSE 1
-
-/*
- * State stack - compiler will fault if it overflows.   (Default was 200)
- */
-#define YYINITDEPTH 600
-
 #include 
 #include 
 #include 
@@ -74,45 +66,40 @@
  *      ResourceMacroList, and FieldUnitList
  */
 
+void *                      AslLocalAllocate (unsigned int Size);
+
+/* Bison/yacc configuration */
 
-/*
- * Next statement is important - this makes everything public so that
- * we can access some of the parser tables from other modules
- */
 #define static
 #undef alloca
-#define alloca      AslLocalAllocate
-#define YYERROR_VERBOSE     1
+#define alloca              AslLocalAllocate
+#define yytname             AslCompilername
 
-void *
-AslLocalAllocate (unsigned int Size);
+#define YYINITDEPTH         600             /* State stack depth */
+#define YYDEBUG             1               /* Enable debug output */
+#define YYERROR_VERBOSE     1               /* Verbose error messages */
 
 /*
  * The windows version of bison defines this incorrectly as "32768" (Not negative).
- * Using a custom (edited binary) version of bison that defines YYFLAG as YYFBAD
- * instead (#define YYFBAD      32768), so we can define it correctly here.
+ * We use a custom (edited binary) version of bison that defines YYFLAG as YYFBAD
+ * instead (#define YYFBAD 32768), so we can define it correctly here.
  *
  * The problem is that if YYFLAG is positive, the extended syntax error messages
  * are disabled.
  */
-
 #define YYFLAG              -32768
 
-
 %}
 
-
 /*
  * Declare the type of values in the grammar
  */
-
 %union {
     UINT64              i;
     char                *s;
     ACPI_PARSE_OBJECT   *n;
 }
 
-
 /*! [Begin] no source code translation */
 
 /*
@@ -121,14 +108,12 @@ AslLocalAllocate (unsigned int Size);
  */
 %expect 60
 
-
 /*
  * Token types: These are returned by the lexer
  *
  * NOTE: This list MUST match the AslKeywordMapping table found
  *       in aslmap.c EXACTLY!  Double check any changes!
  */
-
 %token  PARSEOP_ACCESSAS
 %token  PARSEOP_ACCESSATTRIB_BLOCK
 %token  PARSEOP_ACCESSATTRIB_BLOCK_CALL
@@ -3138,3 +3123,32 @@ AslDoError (void)
     return (TrCreateLeafNode (PARSEOP_ERRORNODE));
 
 }
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    UtGetOpName
+ *
+ * PARAMETERS:  ParseOpcode         - Parser keyword ID
+ *
+ * RETURN:      Pointer to the opcode name
+ *
+ * DESCRIPTION: Get the ascii name of the parse opcode
+ *
+ ******************************************************************************/
+
+char *
+UtGetOpName (
+    UINT32                  ParseOpcode)
+{
+#ifdef ASL_YYTNAME_START
+    /*
+     * First entries (ASL_YYTNAME_START) in yytname are special reserved names.
+     * Ignore first 8 characters of the name
+     */
+    return ((char *) yytname
+        [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8);
+#else
+    return ("[Unknown parser generator]");
+#endif
+}

Modified: head/sys/contrib/dev/acpica/compiler/asldefine.h
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/asldefine.h	Fri Apr 15 21:33:45 2011	(r220680)
+++ head/sys/contrib/dev/acpica/compiler/asldefine.h	Fri Apr 15 21:38:24 2011	(r220681)
@@ -66,12 +66,23 @@
 #define ASL_STRING_CACHE_SIZE       32768
 
 #define ASL_FIRST_PARSE_OPCODE      PARSEOP_ACCESSAS
-#define ASL_YYTNAME_START           3
-
 #define ASL_PARSE_OPCODE_BASE       PARSEOP_ACCESSAS        /* First Lex type */
 
 
 /*
+ * Per-parser-generator configuration. These values are used to cheat and
+ * directly access the bison/yacc token name table (yyname or yytname).
+ * Note: These values are the index in yyname for the first lex token
+ * (PARSEOP_ACCCESSAS).
+ */
+#if defined (YYBISON)
+#define ASL_YYTNAME_START           3   /* Bison */
+#elif defined (YYBYACC)
+#define ASL_YYTNAME_START           257 /* Berkeley yacc */
+#endif
+
+
+/*
  * Macros
  */
 #define ASL_RESDESC_OFFSET(m)       ACPI_OFFSET (AML_RESOURCE, m)
@@ -97,6 +108,7 @@
 
 /* filename suffixes for output files */
 
+#define FILE_SUFFIX_PREPROCESSOR    "i"
 #define FILE_SUFFIX_AML_CODE        "aml"
 #define FILE_SUFFIX_LISTING         "lst"
 #define FILE_SUFFIX_HEX_DUMP        "hex"

Modified: head/sys/contrib/dev/acpica/compiler/aslutils.c
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/aslutils.c	Fri Apr 15 21:33:45 2011	(r220680)
+++ head/sys/contrib/dev/acpica/compiler/aslutils.c	Fri Apr 15 21:38:24 2011	(r220681)
@@ -53,13 +53,6 @@
 #define _COMPONENT          ACPI_COMPILER
         ACPI_MODULE_NAME    ("aslutils")
 
-#ifdef _USE_BERKELEY_YACC
-extern const char * const       AslCompilername[];
-static const char * const       *yytname = &AslCompilername[254];
-#else
-extern const char * const       yytname[];
-#endif
-
 char                        AslHexLookup[] =
 {
     '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
@@ -444,32 +437,6 @@ UtSetParseOpName (
 
 /*******************************************************************************
  *
- * FUNCTION:    UtGetOpName
- *
- * PARAMETERS:  ParseOpcode         - Parser keyword ID
- *
- * RETURN:      Pointer to the opcode name
- *
- * DESCRIPTION: Get the ascii name of the parse opcode
- *
- ******************************************************************************/
-
-char *
-UtGetOpName (
-    UINT32                  ParseOpcode)
-{
-
-    /*
-     * First entries (ASL_YYTNAME_START) in yytname are special reserved names.
-     * Ignore first 8 characters of the name
-     */
-    return ((char *) yytname
-        [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8);
-}
-
-
-/*******************************************************************************
- *
  * FUNCTION:    UtDisplaySummary
  *
  * PARAMETERS:  FileID          - ID of outpout file

Modified: head/sys/contrib/dev/acpica/compiler/dtparser.y
==============================================================================
--- head/sys/contrib/dev/acpica/compiler/dtparser.y	Fri Apr 15 21:33:45 2011	(r220680)
+++ head/sys/contrib/dev/acpica/compiler/dtparser.y	Fri Apr 15 21:38:24 2011	(r220681)
@@ -42,22 +42,26 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
-#define YYDEBUG 1
-#define YYERROR_VERBOSE 1
-
 #include 
 #include 
 
-#define _COMPONENT          ACPI_COMPILER
+#define _COMPONENT          DT_COMPILER
         ACPI_MODULE_NAME    ("dtparser")
 
-UINT64                  DtParserResult;    /* Global for expression return value */
-
-int DtParserlex (void);
-int DtParserparse (void);
-extern char*            DtParsertext;
-extern void             DtParsererror (char const * msg);
-#define YYFLAG          -32768
+int                         DtParserlex (void);
+int                         DtParserparse (void);
+void                        DtParsererror (char const *msg);
+extern char                 *DtParsertext;
+extern DT_FIELD             *Gbl_CurrentField;
+
+UINT64                      DtParserResult; /* Expression return value */
+
+/* Bison/yacc configuration */
+
+#define yytname             DtParsername
+#define YYDEBUG             1               /* Enable debug output */
+#define YYERROR_VERBOSE     1               /* Verbose error messages */
+#define YYFLAG              -32768
 
 %}
 
@@ -67,6 +71,8 @@ extern void             DtParsererror (c
      UINT32                 op;
 }
 
+/*! [Begin] no source code translation */
+
 %type    Expression
 
 %token      EXPOP_EOF
@@ -164,17 +170,14 @@ Expression
     ;
 %%
 
+/*! [End] no source code translation !*/
+
 /*
  * Local support functions, including parser entry point
  */
-extern DT_FIELD                 *Gbl_CurrentField;
 #define PR_FIRST_PARSE_OPCODE   EXPOP_EOF
 #define PR_YYTNAME_START        3
 
-#ifdef _USE_BERKELEY_YACC
-#define yytname DtParsername
-#endif
-
 
 /******************************************************************************
  *
@@ -213,13 +216,16 @@ char *
 DtGetOpName (
     UINT32                  ParseOpcode)
 {
-
+#ifdef ASL_YYTNAME_START
     /*
      * First entries (PR_YYTNAME_START) in yytname are special reserved names.
      * Ignore first 6 characters of name (EXPOP_)
      */
     return ((char *) yytname
         [(ParseOpcode - PR_FIRST_PARSE_OPCODE) + PR_YYTNAME_START] + 6);
+#else
+    return ("[Unknown parser generator]");
+#endif
 }
 
 

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 21:47:11 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5430C1065670;
	Fri, 15 Apr 2011 21:47:11 +0000 (UTC)
	(envelope-from jkim@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4171F8FC08;
	Fri, 15 Apr 2011 21:47:11 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FLlBaS083250;
	Fri, 15 Apr 2011 21:47:11 GMT (envelope-from jkim@svn.freebsd.org)
Received: (from jkim@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FLlBSV083248;
	Fri, 15 Apr 2011 21:47:11 GMT (envelope-from jkim@svn.freebsd.org)
Message-Id: <201104152147.p3FLlBSV083248@svn.freebsd.org>
From: Jung-uk Kim 
Date: Fri, 15 Apr 2011 21:47:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220682 - head/usr.sbin/acpi/iasl
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 21:47:11 -0000

Author: jkim
Date: Fri Apr 15 21:47:10 2011
New Revision: 220682
URL: http://svn.freebsd.org/changeset/base/220682

Log:
  Purge _USE_BERKELEY_YACC definition from Makefile.  This ugly hack is no
  long necessary for us since r220680.

Modified:
  head/usr.sbin/acpi/iasl/Makefile

Modified: head/usr.sbin/acpi/iasl/Makefile
==============================================================================
--- head/usr.sbin/acpi/iasl/Makefile	Fri Apr 15 21:38:24 2011	(r220681)
+++ head/usr.sbin/acpi/iasl/Makefile	Fri Apr 15 21:47:10 2011	(r220682)
@@ -62,7 +62,6 @@ WARNS?=	2
 MAN=	iasl.8
 
 CFLAGS+= -DACPI_ASL_COMPILER -I.
-CFLAGS+= -D_USE_BERKELEY_YACC
 LFLAGS= -i -s
 YFLAGS= -d
 DPADD=	${LIBPTHREAD}

From owner-svn-src-head@FreeBSD.ORG  Fri Apr 15 23:07:49 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 85424106564A;
	Fri, 15 Apr 2011 23:07:49 +0000 (UTC)
	(envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 3934C8FC0C;
	Fri, 15 Apr 2011 23:07:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3FN7nl0084943;
	Fri, 15 Apr 2011 23:07:49 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3FN7nBe084937;
	Fri, 15 Apr 2011 23:07:49 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201104152307.p3FN7nBe084937@svn.freebsd.org>
From: Rick Macklem 
Date: Fri, 15 Apr 2011 23:07:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220683 - in head/sys/fs: nfs nfsclient
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Fri, 15 Apr 2011 23:07:49 -0000

Author: rmacklem
Date: Fri Apr 15 23:07:48 2011
New Revision: 220683
URL: http://svn.freebsd.org/changeset/base/220683

Log:
  Change the experimental NFS client so that it creates nfsiod
  threads in the same manner as the regular NFS client after
  r214026 was committed. This resolves the lors fixed by r214026
  and its predecessors for the regular client.
  
  Reviewed by:	jhb
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfs/nfs.h
  head/sys/fs/nfsclient/nfs.h
  head/sys/fs/nfsclient/nfs_clbio.c
  head/sys/fs/nfsclient/nfs_clnfsiod.c
  head/sys/fs/nfsclient/nfs_clsubs.c

Modified: head/sys/fs/nfs/nfs.h
==============================================================================
--- head/sys/fs/nfs/nfs.h	Fri Apr 15 21:47:10 2011	(r220682)
+++ head/sys/fs/nfs/nfs.h	Fri Apr 15 23:07:48 2011	(r220683)
@@ -70,8 +70,9 @@
 #define	NFS_WSIZE	8192		/* Def. write data size <= 8192 */
 #define	NFS_RSIZE	8192		/* Def. read data size <= 8192 */
 #define	NFS_READDIRSIZE	8192		/* Def. readdir size */
-#define	NFS_DEFRAHEAD	0		/* Def. read ahead # blocks */
-#define	NFS_MAXRAHEAD	32		/* Max. read ahead # blocks */
+#define	NFS_DEFRAHEAD	1		/* Def. read ahead # blocks */
+#define	NFS_MAXRAHEAD	16		/* Max. read ahead # blocks */
+#define	NFS_MAXASYNCDAEMON 	64	/* Max. number async_daemons runnable */
 #define	NFS_MAXUIDHASH	64		/* Max. # of hashed uid entries/mp */
 #ifndef	NFSRV_LEASE
 #define	NFSRV_LEASE		120	/* Lease time in seconds for V4 */

Modified: head/sys/fs/nfsclient/nfs.h
==============================================================================
--- head/sys/fs/nfsclient/nfs.h	Fri Apr 15 21:47:10 2011	(r220682)
+++ head/sys/fs/nfsclient/nfs.h	Fri Apr 15 23:07:48 2011	(r220683)
@@ -102,7 +102,8 @@ int ncl_fsinfo(struct nfsmount *, struct
 int ncl_init(struct vfsconf *);
 int ncl_uninit(struct vfsconf *);
 int ncl_mountroot(struct mount *);
-int ncl_nfsiodnew(int);
+void	ncl_nfsiodnew(void);
+void	ncl_nfsiodnew_tq(__unused void *, int);
 
 #endif	/* _KERNEL */
 

Modified: head/sys/fs/nfsclient/nfs_clbio.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clbio.c	Fri Apr 15 21:47:10 2011	(r220682)
+++ head/sys/fs/nfsclient/nfs_clbio.c	Fri Apr 15 23:07:48 2011	(r220683)
@@ -60,8 +60,8 @@ extern int newnfs_directio_allow_mmap;
 extern struct nfsstats newnfsstats;
 extern struct mtx ncl_iod_mutex;
 extern int ncl_numasync;
-extern enum nfsiod_state ncl_iodwant[NFS_MAXRAHEAD];
-extern struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
+extern enum nfsiod_state ncl_iodwant[NFS_MAXASYNCDAEMON];
+extern struct nfsmount *ncl_iodmount[NFS_MAXASYNCDAEMON];
 extern int newnfs_directio_enable;
 
 int ncl_pbuf_freecnt = -1;	/* start out unlimited */
@@ -1354,15 +1354,6 @@ ncl_asyncio(struct nfsmount *nmp, struct
 	int error, error2;
 
 	/*
-	 * Unless iothreadcnt is set > 0, don't bother with async I/O
-	 * threads. For LAN environments, they don't buy any significant
-	 * performance improvement that you can't get with large block
-	 * sizes.
-	 */
-	if (nmp->nm_readahead == 0)
-		return (EPERM);
-
-	/*
 	 * Commits are usually short and sweet so lets save some cpu and
 	 * leave the async daemons for more important rpc's (such as reads
 	 * and writes).
@@ -1390,13 +1381,9 @@ again:
 	/*
 	 * Try to create one if none are free.
 	 */
-	if (!gotiod) {
-		iod = ncl_nfsiodnew(1);
-		if (iod != -1)
-			gotiod = TRUE;
-	}
-
-	if (gotiod) {
+	if (!gotiod)
+		ncl_nfsiodnew();
+	else {
 		/*
 		 * Found one, so wake it up and tell it which
 		 * mount to process.
@@ -1453,11 +1440,7 @@ again:
 			 * We might have lost our iod while sleeping,
 			 * so check and loop if nescessary.
 			 */
-			if (nmp->nm_bufqiods == 0) {
-				NFS_DPF(ASYNCIO,
-					("ncl_asyncio: no iods after mount %p queue was drained, looping\n", nmp));
-				goto again;
-			}
+			goto again;
 		}
 
 		/* We might have lost our nfsiod */

Modified: head/sys/fs/nfsclient/nfs_clnfsiod.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clnfsiod.c	Fri Apr 15 21:47:10 2011	(r220682)
+++ head/sys/fs/nfsclient/nfs_clnfsiod.c	Fri Apr 15 23:07:48 2011	(r220683)
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -68,28 +69,32 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-extern struct mtx ncl_iod_mutex;
+extern struct mtx	ncl_iod_mutex;
+extern struct task	ncl_nfsiodnew_task;
 
 int ncl_numasync;
-enum nfsiod_state ncl_iodwant[NFS_MAXRAHEAD];
-struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
+enum nfsiod_state ncl_iodwant[NFS_MAXASYNCDAEMON];
+struct nfsmount *ncl_iodmount[NFS_MAXASYNCDAEMON];
 
 static void	nfssvc_iod(void *);
 
-static int nfs_asyncdaemon[NFS_MAXRAHEAD];
+static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
 
 SYSCTL_DECL(_vfs_newnfs);
 
 /* Maximum number of seconds a nfsiod kthread will sleep before exiting */
-static unsigned int ncl_iodmaxidle = 120;
-SYSCTL_UINT(_vfs_newnfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &ncl_iodmaxidle, 0, "");
+static unsigned int nfs_iodmaxidle = 120;
+SYSCTL_UINT(_vfs_newnfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &nfs_iodmaxidle, 0,
+    "Max number of seconds an nfsiod kthread will sleep before exiting");
 
 /* Maximum number of nfsiod kthreads */
-unsigned int ncl_iodmax = NFS_MAXRAHEAD;
+unsigned int ncl_iodmax = 20;
 
 /* Minimum number of nfsiod kthreads to keep as spares */
 static unsigned int nfs_iodmin = 0;
 
+static int nfs_nfsiodnew_sync(void);
+
 static int
 sysctl_iodmin(SYSCTL_HANDLER_ARGS)
 {
@@ -113,14 +118,14 @@ sysctl_iodmin(SYSCTL_HANDLER_ARGS)
 	 * than the new minimum, create some more.
 	 */
 	for (i = nfs_iodmin - ncl_numasync; i > 0; i--)
-		ncl_nfsiodnew(0);
+		nfs_nfsiodnew_sync();
 out:
 	mtx_unlock(&ncl_iod_mutex);	
 	return (0);
 }
 SYSCTL_PROC(_vfs_newnfs, OID_AUTO, iodmin, CTLTYPE_UINT | CTLFLAG_RW, 0,
-    sizeof (nfs_iodmin), sysctl_iodmin, "IU", "");
-
+    sizeof (nfs_iodmin), sysctl_iodmin, "IU",
+    "Min number of nfsiod kthreads to keep as spares");
 
 static int
 sysctl_iodmax(SYSCTL_HANDLER_ARGS)
@@ -132,7 +137,7 @@ sysctl_iodmax(SYSCTL_HANDLER_ARGS)
 	error = sysctl_handle_int(oidp, &newmax, 0, req);
 	if (error || (req->newptr == NULL))
 		return (error);
-	if (newmax > NFS_MAXRAHEAD)
+	if (newmax > NFS_MAXASYNCDAEMON)
 		return (EINVAL);
 	mtx_lock(&ncl_iod_mutex);
 	ncl_iodmax = newmax;
@@ -155,64 +160,79 @@ out:
 	return (0);
 }
 SYSCTL_PROC(_vfs_newnfs, OID_AUTO, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0,
-    sizeof (ncl_iodmax), sysctl_iodmax, "IU", "");
+    sizeof (ncl_iodmax), sysctl_iodmax, "IU",
+    "Max number of nfsiod kthreads");
 
-int
-ncl_nfsiodnew(int set_iodwant)
+static int
+nfs_nfsiodnew_sync(void)
 {
 	int error, i;
-	int newiod;
 
-	if (ncl_numasync >= ncl_iodmax)
-		return (-1);
-	newiod = -1;
-	for (i = 0; i < ncl_iodmax; i++)
+	mtx_assert(&ncl_iod_mutex, MA_OWNED);
+	for (i = 0; i < ncl_iodmax; i++) {
 		if (nfs_asyncdaemon[i] == 0) {
-			nfs_asyncdaemon[i]++;
-			newiod = i;
+			nfs_asyncdaemon[i] = 1;
 			break;
 		}
-	if (newiod == -1)
-		return (-1);
-	if (set_iodwant > 0)
-		ncl_iodwant[i] = NFSIOD_CREATED_FOR_NFS_ASYNCIO;
+	}
+	if (i == ncl_iodmax)
+		return (0);
 	mtx_unlock(&ncl_iod_mutex);
-	error = kproc_create(nfssvc_iod, nfs_asyncdaemon + i, NULL, RFHIGHPID,
-	    0, "nfsiod %d", newiod);
+	error = kproc_create(nfssvc_iod, nfs_asyncdaemon + i, NULL,
+	    RFHIGHPID, 0, "newnfs %d", i);
+	mtx_lock(&ncl_iod_mutex);
+	if (error == 0) {
+		ncl_numasync++;
+		ncl_iodwant[i] = NFSIOD_AVAILABLE;
+	} else
+		nfs_asyncdaemon[i] = 0;
+	return (error);
+}
+
+void
+ncl_nfsiodnew_tq(__unused void *arg, int pending)
+{
+
 	mtx_lock(&ncl_iod_mutex);
-	if (error) {
-		if (set_iodwant > 0)
-			ncl_iodwant[i] = NFSIOD_NOT_AVAILABLE;
-		return (-1);
+	while (pending > 0) {
+		pending--;
+		nfs_nfsiodnew_sync();
 	}
-	ncl_numasync++;
-	return (newiod);
+	mtx_unlock(&ncl_iod_mutex);
+}
+
+void
+ncl_nfsiodnew(void)
+{
+
+	mtx_assert(&ncl_iod_mutex, MA_OWNED);
+	taskqueue_enqueue(taskqueue_thread, &ncl_nfsiodnew_task);
 }
 
 static void
 nfsiod_setup(void *dummy)
 {
-	int i;
 	int error;
 
 	TUNABLE_INT_FETCH("vfs.newnfs.iodmin", &nfs_iodmin);
 	nfscl_init();
 	mtx_lock(&ncl_iod_mutex);
 	/* Silently limit the start number of nfsiod's */
-	if (nfs_iodmin > NFS_MAXRAHEAD)
-		nfs_iodmin = NFS_MAXRAHEAD;
+	if (nfs_iodmin > NFS_MAXASYNCDAEMON)
+		nfs_iodmin = NFS_MAXASYNCDAEMON;
 
-	for (i = 0; i < nfs_iodmin; i++) {
-		error = ncl_nfsiodnew(0);
+	while (ncl_numasync < nfs_iodmin) {
+		error = nfs_nfsiodnew_sync();
 		if (error == -1)
-			panic("newnfsiod_setup: ncl_nfsiodnew failed");
+			panic("nfsiod_setup: nfs_nfsiodnew failed");
 	}
 	mtx_unlock(&ncl_iod_mutex);
 }
 SYSINIT(newnfsiod, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, nfsiod_setup, NULL);
 
 static int nfs_defect = 0;
-SYSCTL_INT(_vfs_newnfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, "");
+SYSCTL_INT(_vfs_newnfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0,
+    "Allow nfsiods to migrate serving different mounts");
 
 /*
  * Asynchronous I/O daemons for client nfs.
@@ -245,7 +265,7 @@ nfssvc_iod(void *instance)
 		/*
 		 * Always keep at least nfs_iodmin kthreads.
 		 */
-		timo = (myiod < nfs_iodmin) ? 0 : ncl_iodmaxidle * hz;
+		timo = (myiod < nfs_iodmin) ? 0 : nfs_iodmaxidle * hz;
 		error = msleep(&ncl_iodwant[myiod], &ncl_iod_mutex, PWAIT | PCATCH,
 		    "-", timo);
 		if (error) {
@@ -263,7 +283,6 @@ nfssvc_iod(void *instance)
 	    if (error)
 		    break;
 	    while ((bp = TAILQ_FIRST(&nmp->nm_bufq)) != NULL) {
-		    
 		/* Take one off the front of the list */
 		TAILQ_REMOVE(&nmp->nm_bufq, bp, b_freelist);
 		nmp->nm_bufqlen--;

Modified: head/sys/fs/nfsclient/nfs_clsubs.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clsubs.c	Fri Apr 15 21:47:10 2011	(r220682)
+++ head/sys/fs/nfsclient/nfs_clsubs.c	Fri Apr 15 23:07:48 2011	(r220683)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -77,12 +78,14 @@ __FBSDID("$FreeBSD$");
 #include 
 
 extern struct mtx ncl_iod_mutex;
-extern enum nfsiod_state ncl_iodwant[NFS_MAXRAHEAD];
-extern struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
+extern enum nfsiod_state ncl_iodwant[NFS_MAXASYNCDAEMON];
+extern struct nfsmount *ncl_iodmount[NFS_MAXASYNCDAEMON];
 extern int ncl_numasync;
 extern unsigned int ncl_iodmax;
 extern struct nfsstats newnfsstats;
 
+struct task	ncl_nfsiodnew_task;
+
 int
 ncl_uninit(struct vfsconf *vfsp)
 {
@@ -393,10 +396,11 @@ ncl_init(struct vfsconf *vfsp)
 	int i;
 
 	/* Ensure async daemons disabled */
-	for (i = 0; i < NFS_MAXRAHEAD; i++) {
+	for (i = 0; i < NFS_MAXASYNCDAEMON; i++) {
 		ncl_iodwant[i] = NFSIOD_NOT_AVAILABLE;
 		ncl_iodmount[i] = NULL;
 	}
+	TASK_INIT(&ncl_nfsiodnew_task, 0, ncl_nfsiodnew_tq, NULL);
 	ncl_nhinit();			/* Init the nfsnode table */
 
 	return (0);

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 06:20:49 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D483D106564A;
	Sat, 16 Apr 2011 06:20:49 +0000 (UTC)
	(envelope-from nyan@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C21E98FC19;
	Sat, 16 Apr 2011 06:20:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3G6KnkL094115;
	Sat, 16 Apr 2011 06:20:49 GMT (envelope-from nyan@svn.freebsd.org)
Received: (from nyan@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3G6Kn9P094113;
	Sat, 16 Apr 2011 06:20:49 GMT (envelope-from nyan@svn.freebsd.org)
Message-Id: <201104160620.p3G6Kn9P094113@svn.freebsd.org>
From: Takahashi Yoshihiro 
Date: Sat, 16 Apr 2011 06:20:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220685 - head/sys/boot/pc98/boot2
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 06:20:49 -0000

Author: nyan
Date: Sat Apr 16 06:20:49 2011
New Revision: 220685
URL: http://svn.freebsd.org/changeset/base/220685

Log:
  MFi386: revisions 220389 and 220392
  
    - Mark getc() as inline, this has no effect on gcc but helps clang.
    - Move getc() body before xgetc() so gcc does not emit a warning about
      function having no body.

Modified:
  head/sys/boot/pc98/boot2/boot2.c

Modified: head/sys/boot/pc98/boot2/boot2.c
==============================================================================
--- head/sys/boot/pc98/boot2/boot2.c	Sat Apr 16 00:10:55 2011	(r220684)
+++ head/sys/boot/pc98/boot2/boot2.c	Sat Apr 16 06:20:49 2011	(r220685)
@@ -150,7 +150,7 @@ static int drvread(void *, unsigned);
 static int keyhit(unsigned);
 static int xputc(int);
 static int xgetc(int);
-static int getc(int);
+static inline int getc(int);
 
 static void memcpy(void *, const void *, int);
 static void
@@ -779,6 +779,18 @@ xputc(int c)
 }
 
 static int
+getc(int fn)
+{
+    v86.addr = 0x18;
+    v86.eax = fn << 8;
+    v86int();
+    if (fn)
+	return (v86.ebx >> 8) & 0x01;
+    else
+	return v86.eax & 0xff;
+}
+
+static int
 xgetc(int fn)
 {
     if (OPT_CHECK(RBX_NOINTR))
@@ -792,15 +804,3 @@ xgetc(int fn)
 	    return 0;
     }
 }
-
-static int
-getc(int fn)
-{
-    v86.addr = 0x18;
-    v86.eax = fn << 8;
-    v86int();
-    if (fn)
-	return (v86.ebx >> 8) & 0x01;
-    else
-	return v86.eax & 0xff;
-}

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 06:54:43 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 27BFD106564A;
	Sat, 16 Apr 2011 06:54:42 +0000 (UTC) (envelope-from jh@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 14F808FC15;
	Sat, 16 Apr 2011 06:54:42 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3G6sfsh094766;
	Sat, 16 Apr 2011 06:54:41 GMT (envelope-from jh@svn.freebsd.org)
Received: (from jh@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3G6sfQj094763;
	Sat, 16 Apr 2011 06:54:41 GMT (envelope-from jh@svn.freebsd.org)
Message-Id: <201104160654.p3G6sfQj094763@svn.freebsd.org>
From: Jaakko Heinonen 
Date: Sat, 16 Apr 2011 06:54:41 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220686 - head/sys/cam/scsi
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 06:54:43 -0000

Author: jh
Date: Sat Apr 16 06:54:41 2011
New Revision: 220686
URL: http://svn.freebsd.org/changeset/base/220686

Log:
  Move TUNABLE_INT_FETCH() out of the SIM lock to avoid sleeping while
  holding the lock. The fix is analogous to r220618 for ada(4).
  
  Reviewed by:	mav

Modified:
  head/sys/cam/scsi/scsi_cd.c
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_cd.c
==============================================================================
--- head/sys/cam/scsi/scsi_cd.c	Sat Apr 16 06:20:49 2011	(r220685)
+++ head/sys/cam/scsi/scsi_cd.c	Sat Apr 16 06:54:41 2011	(r220686)
@@ -687,6 +687,8 @@ cdregister(struct cam_periph *periph, vo
 	else
 		softc->minimum_command_size = 6;
 
+	(void)cam_periph_hold(periph, PRIBIO);
+	cam_periph_unlock(periph);
 	/*
 	 * Load the user's default, if any.
 	 */
@@ -712,7 +714,6 @@ cdregister(struct cam_periph *periph, vo
 	 * WORM peripheral driver.  WORM drives will also have the WORM
 	 * driver attached to them.
 	 */
-	cam_periph_unlock(periph);
 	softc->disk = disk_alloc();
 	softc->disk->d_devstat = devstat_new_entry("cd",
 			  periph->unit_number, 0,
@@ -746,6 +747,7 @@ cdregister(struct cam_periph *periph, vo
 	softc->disk->d_hba_subdevice = cpi.hba_subdevice;
 	disk_create(softc->disk, DISK_VERSION);
 	cam_periph_lock(periph);
+	cam_periph_unhold(periph);
 
 	/*
 	 * Add an async callback so that we get

Modified: head/sys/cam/scsi/scsi_da.c
==============================================================================
--- head/sys/cam/scsi/scsi_da.c	Sat Apr 16 06:20:49 2011	(r220685)
+++ head/sys/cam/scsi/scsi_da.c	Sat Apr 16 06:54:41 2011	(r220686)
@@ -1231,35 +1231,6 @@ daregister(struct cam_periph *periph, vo
 	TASK_INIT(&softc->sysctl_task, 0, dasysctlinit, periph);
 
 	/*
-	 * RBC devices don't have to support READ(6), only READ(10).
-	 */
-	if (softc->quirks & DA_Q_NO_6_BYTE || SID_TYPE(&cgd->inq_data) == T_RBC)
-		softc->minimum_cmd_size = 10;
-	else
-		softc->minimum_cmd_size = 6;
-
-	/*
-	 * Load the user's default, if any.
-	 */
-	snprintf(tmpstr, sizeof(tmpstr), "kern.cam.da.%d.minimum_cmd_size",
-		 periph->unit_number);
-	TUNABLE_INT_FETCH(tmpstr, &softc->minimum_cmd_size);
-
-	/*
-	 * 6, 10, 12 and 16 are the currently permissible values.
-	 */
-	if (softc->minimum_cmd_size < 6)
-		softc->minimum_cmd_size = 6;
-	else if ((softc->minimum_cmd_size > 6)
-	      && (softc->minimum_cmd_size <= 10))
-		softc->minimum_cmd_size = 10;
-	else if ((softc->minimum_cmd_size > 10)
-	      && (softc->minimum_cmd_size <= 12))
-		softc->minimum_cmd_size = 12;
-	else if (softc->minimum_cmd_size > 12)
-		softc->minimum_cmd_size = 16;
-
-	/*
 	 * Register this media as a disk
 	 */
 
@@ -1291,6 +1262,35 @@ daregister(struct cam_periph *periph, vo
 	    dasendorderedtag, softc);
 
 	mtx_unlock(periph->sim->mtx);
+	/*
+	 * RBC devices don't have to support READ(6), only READ(10).
+	 */
+	if (softc->quirks & DA_Q_NO_6_BYTE || SID_TYPE(&cgd->inq_data) == T_RBC)
+		softc->minimum_cmd_size = 10;
+	else
+		softc->minimum_cmd_size = 6;
+
+	/*
+	 * Load the user's default, if any.
+	 */
+	snprintf(tmpstr, sizeof(tmpstr), "kern.cam.da.%d.minimum_cmd_size",
+		 periph->unit_number);
+	TUNABLE_INT_FETCH(tmpstr, &softc->minimum_cmd_size);
+
+	/*
+	 * 6, 10, 12 and 16 are the currently permissible values.
+	 */
+	if (softc->minimum_cmd_size < 6)
+		softc->minimum_cmd_size = 6;
+	else if ((softc->minimum_cmd_size > 6)
+	      && (softc->minimum_cmd_size <= 10))
+		softc->minimum_cmd_size = 10;
+	else if ((softc->minimum_cmd_size > 10)
+	      && (softc->minimum_cmd_size <= 12))
+		softc->minimum_cmd_size = 12;
+	else if (softc->minimum_cmd_size > 12)
+		softc->minimum_cmd_size = 16;
+
 	softc->disk = disk_alloc();
 	softc->disk->d_devstat = devstat_new_entry(periph->periph_name,
 			  periph->unit_number, 0,

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 07:17:03 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 86512106564A;
	Sat, 16 Apr 2011 07:17:03 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 728FF8FC17;
	Sat, 16 Apr 2011 07:17:03 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3G7H33N095255;
	Sat, 16 Apr 2011 07:17:03 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3G7H3jb095253;
	Sat, 16 Apr 2011 07:17:03 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104160717.p3G7H3jb095253@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 07:17:03 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220687 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 07:17:03 -0000

Author: bschmidt
Date: Sat Apr 16 07:17:03 2011
New Revision: 220687
URL: http://svn.freebsd.org/changeset/base/220687

Log:
  Obtain the channel number directly from the laster RXON command, also
  chan is an uint8_t.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 06:54:41 2011	(r220686)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 07:17:03 2011	(r220687)
@@ -1732,7 +1732,8 @@ iwn_read_eeprom_band(struct iwn_softc *s
 	struct iwn_eeprom_chan *channels = sc->eeprom_channels[n];
 	const struct iwn_chan_band *band = &iwn_bands[n];
 	struct ieee80211_channel *c;
-	int i, chan, nflags;
+	uint8_t chan;
+	int i, nflags;
 
 	for (i = 0; i < band->nchan; i++) {
 		if (!(channels[i].flags & IWN_EEPROM_CHAN_VALID)) {
@@ -3806,8 +3807,6 @@ iwn4965_set_txpower(struct iwn_softc *sc
 	((y1) + fdivround(((int)(x) - (x1)) * ((y2) - (y1)), (x2) - (x1), n))
 
 	static const int tdiv[IWN_NATTEN_GROUPS] = { 9, 8, 8, 8, 6 };
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
 	struct iwn_ucode_info *uc = &sc->ucode_info;
 	struct iwn4965_cmd_txpower cmd;
 	struct iwn4965_eeprom_chan_samples *chans;
@@ -3816,8 +3815,8 @@ iwn4965_set_txpower(struct iwn_softc *sc
 	const uint8_t *rf_gain, *dsp_gain;
 	uint8_t chan;
 
-	/* Retrieve channel number. */
-	chan = ieee80211_chan2ieee(ic, ch);
+	/* Retrieve current channel from last RXON. */
+	chan = sc->rxon.chan;
 	DPRINTF(sc, IWN_DEBUG_RESET, "setting TX power for channel %d\n",
 	    chan);
 

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 07:21:00 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D82351065670;
	Sat, 16 Apr 2011 07:21:00 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C48AB8FC0C;
	Sat, 16 Apr 2011 07:21:00 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3G7L0WA095362;
	Sat, 16 Apr 2011 07:21:00 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3G7L05V095360;
	Sat, 16 Apr 2011 07:21:00 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104160721.p3G7L05V095360@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 07:21:00 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220688 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 07:21:00 -0000

Author: bschmidt
Date: Sat Apr 16 07:21:00 2011
New Revision: 220688
URL: http://svn.freebsd.org/changeset/base/220688

Log:
  Pass errors that might happen during state transitions up to net80211.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 07:17:03 2011	(r220687)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 07:21:00 2011	(r220688)
@@ -1920,7 +1920,7 @@ iwn_newstate(struct ieee80211vap *vap, e
 	struct iwn_vap *ivp = IWN_VAP(vap);
 	struct ieee80211com *ic = vap->iv_ic;
 	struct iwn_softc *sc = ic->ic_ifp->if_softc;
-	int error;
+	int error = 0;
 
 	DPRINTF(sc, IWN_DEBUG_STATE, "%s: %s -> %s\n", __func__,
 		ieee80211_state_name[vap->iv_state],
@@ -1947,7 +1947,10 @@ iwn_newstate(struct ieee80211vap *vap, e
 		sc->rxon.filter &= ~htole32(IWN_FILTER_BSS);
 		sc->calib.state = IWN_CALIB_STATE_INIT;
 
-		error = iwn_auth(sc, vap);
+		if ((error = iwn_auth(sc, vap)) != 0) {
+			device_printf(sc->sc_dev,
+			    "%s: could not move to auth state\n", __func__);
+		}
 		break;
 
 	case IEEE80211_S_RUN:
@@ -1964,7 +1967,10 @@ iwn_newstate(struct ieee80211vap *vap, e
 		 * which is done with a firmware cmd.  We also defer
 		 * starting the timers until that work is done.
 		 */
-		error = iwn_run(sc, vap);
+		if ((error = iwn_run(sc, vap)) != 0) {
+			device_printf(sc->sc_dev,
+			    "%s: could not move to run state\n", __func__);
+		}
 		break;
 
 	case IEEE80211_S_INIT:
@@ -1976,6 +1982,8 @@ iwn_newstate(struct ieee80211vap *vap, e
 	}
 	IWN_UNLOCK(sc);
 	IEEE80211_LOCK(ic);
+	if (error != 0)
+		return error;
 	return ivp->iv_newstate(vap, nstate, arg);
 }
 

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 07:32:57 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BD07C106566B;
	Sat, 16 Apr 2011 07:32:57 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8F3CF8FC1D;
	Sat, 16 Apr 2011 07:32:57 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3G7WvRn095626;
	Sat, 16 Apr 2011 07:32:57 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3G7WvkF095624;
	Sat, 16 Apr 2011 07:32:57 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104160732.p3G7WvkF095624@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 07:32:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220689 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 07:32:57 -0000

Author: bschmidt
Date: Sat Apr 16 07:32:57 2011
New Revision: 220689
URL: http://svn.freebsd.org/changeset/base/220689

Log:
  RSSI related syncs with the OpenBSD code:
  - read RSSI only for the active chains
  - cast RSSI/NF to int8_t before passing it up to radiotap
  - remove the htole64() for the timestamp
  
  Obtained from:	OpenBSD

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 07:21:00 2011	(r220688)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 07:32:57 2011	(r220689)
@@ -2128,18 +2128,18 @@ iwn_rx_done(struct iwn_softc *sc, struct
 	m->m_data = head;
 	m->m_pkthdr.len = m->m_len = len;
 
-	rssi = hal->get_rssi(sc, stat);
-
 	/* Grab a reference to the source node. */
 	wh = mtod(m, struct ieee80211_frame *);
 	ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
 	nf = (ni != NULL && ni->ni_vap->iv_state == IEEE80211_S_RUN &&
 	    (ic->ic_flags & IEEE80211_F_SCAN) == 0) ? sc->noise : -95;
 
+	rssi = hal->get_rssi(sc, stat);
+
 	if (ieee80211_radiotap_active(ic)) {
 		struct iwn_rx_radiotap_header *tap = &sc->sc_rxtap;
 
-		tap->wr_tsft = htole64(stat->tstamp);
+		tap->wr_tsft = stat->tstamp;
 		tap->wr_flags = 0;
 		if (stat->flags & htole16(IWN_STAT_FLAG_SHPREAMBLE))
 			tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
@@ -2161,8 +2161,8 @@ iwn_rx_done(struct iwn_softc *sc, struct
 		/* Unknown rate: should not happen. */
 		default:  tap->wr_rate =   0;
 		}
-		tap->wr_dbm_antsignal = rssi;
-		tap->wr_dbm_antnoise = nf;
+		tap->wr_dbm_antsignal = (int8_t)rssi;
+		tap->wr_dbm_antnoise = (int8_t)nf;
 	}
 
 	IWN_UNLOCK(sc);
@@ -3985,18 +3985,12 @@ iwn4965_get_rssi(struct iwn_softc *sc, s
 	agc  = (le16toh(phy->agc) >> 7) & 0x7f;
 
 	rssi = 0;
-#if 0
-	if (mask & IWN_ANT_A)	/* Ant A */
-		rssi = max(rssi, phy->rssi[0]);
-	if (mask & IWN_ATH_B)	/* Ant B */
-		rssi = max(rssi, phy->rssi[2]);
-	if (mask & IWN_ANT_C)	/* Ant C */
-		rssi = max(rssi, phy->rssi[4]);
-#else
-	rssi = max(rssi, phy->rssi[0]);
-	rssi = max(rssi, phy->rssi[2]);
-	rssi = max(rssi, phy->rssi[4]);
-#endif
+	if (mask & IWN_ANT_A)
+		rssi = MAX(rssi, phy->rssi[0]);
+	if (mask & IWN_ANT_B)
+		rssi = MAX(rssi, phy->rssi[2]);
+	if (mask & IWN_ANT_C)
+		rssi = MAX(rssi, phy->rssi[4]);
 
 	DPRINTF(sc, IWN_DEBUG_RECV, "%s: agc %d mask 0x%x rssi %d %d %d "
 	    "result %d\n", __func__, agc, mask,

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 08:38:11 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DC54A106566C;
	Sat, 16 Apr 2011 08:38:11 +0000 (UTC) (envelope-from jh@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CA8858FC08;
	Sat, 16 Apr 2011 08:38:11 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3G8cBLa097072;
	Sat, 16 Apr 2011 08:38:11 GMT (envelope-from jh@svn.freebsd.org)
Received: (from jh@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3G8cBjU097070;
	Sat, 16 Apr 2011 08:38:11 GMT (envelope-from jh@svn.freebsd.org)
Message-Id: <201104160838.p3G8cBjU097070@svn.freebsd.org>
From: Jaakko Heinonen 
Date: Sat, 16 Apr 2011 08:38:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220690 - head/sys/cam/scsi
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 08:38:12 -0000

Author: jh
Date: Sat Apr 16 08:38:11 2011
New Revision: 220690
URL: http://svn.freebsd.org/changeset/base/220690

Log:
  Move a comment to the right place. The rearrange done in r208928 left
  the comment to a wrong place.

Modified:
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/scsi/scsi_da.c
==============================================================================
--- head/sys/cam/scsi/scsi_da.c	Sat Apr 16 07:32:57 2011	(r220689)
+++ head/sys/cam/scsi/scsi_da.c	Sat Apr 16 08:38:11 2011	(r220690)
@@ -1231,10 +1231,6 @@ daregister(struct cam_periph *periph, vo
 	TASK_INIT(&softc->sysctl_task, 0, dasysctlinit, periph);
 
 	/*
-	 * Register this media as a disk
-	 */
-
-	/*
 	 * Add async callbacks for bus reset and
 	 * bus device reset calls.  I don't bother
 	 * checking if this fails as, in most cases,
@@ -1291,6 +1287,9 @@ daregister(struct cam_periph *periph, vo
 	else if (softc->minimum_cmd_size > 12)
 		softc->minimum_cmd_size = 16;
 
+	/*
+	 * Register this media as a disk.
+	 */
 	softc->disk = disk_alloc();
 	softc->disk->d_devstat = devstat_new_entry(periph->periph_name,
 			  periph->unit_number, 0,

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 08:57:17 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E8F20106566B;
	Sat, 16 Apr 2011 08:57:17 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D67258FC17;
	Sat, 16 Apr 2011 08:57:17 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3G8vH8c097546;
	Sat, 16 Apr 2011 08:57:17 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3G8vHG4097544;
	Sat, 16 Apr 2011 08:57:17 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104160857.p3G8vHG4097544@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 08:57:17 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220691 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 08:57:18 -0000

Author: bschmidt
Date: Sat Apr 16 08:57:17 2011
New Revision: 220691
URL: http://svn.freebsd.org/changeset/base/220691

Log:
  Remove the flags argument of iwn_dma_contig_alloc(), it is always set
  as BUS_DMA_NOWAIT. While here also set BUS_DMA_COHERENT.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 08:38:11 2011	(r220690)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 08:57:17 2011	(r220691)
@@ -88,7 +88,7 @@ static int	iwn_init_otprom(struct iwn_so
 static int	iwn_read_prom_data(struct iwn_softc *, uint32_t, void *, int);
 static void	iwn_dma_map_addr(void *, bus_dma_segment_t *, int, int);
 static int	iwn_dma_contig_alloc(struct iwn_softc *, struct iwn_dma_info *,
-		    void **, bus_size_t, bus_size_t, int);
+		    void **, bus_size_t, bus_size_t);
 static void	iwn_dma_contig_free(struct iwn_dma_info *);
 static int	iwn_alloc_sched(struct iwn_softc *);
 static void	iwn_free_sched(struct iwn_softc *);
@@ -1117,7 +1117,7 @@ iwn_dma_map_addr(void *arg, bus_dma_segm
 
 static int
 iwn_dma_contig_alloc(struct iwn_softc *sc, struct iwn_dma_info *dma,
-	void **kvap, bus_size_t size, bus_size_t alignment, int flags)
+    void **kvap, bus_size_t size, bus_size_t alignment)
 {
 	int error;
 
@@ -1126,7 +1126,7 @@ iwn_dma_contig_alloc(struct iwn_softc *s
 
 	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), alignment,
 	    0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size,
-	    1, size, flags, NULL, NULL, &dma->tag);
+	    1, size, BUS_DMA_NOWAIT, NULL, NULL, &dma->tag);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: bus_dma_tag_create failed, error %d\n",
@@ -1134,14 +1134,14 @@ iwn_dma_contig_alloc(struct iwn_softc *s
 		goto fail;
 	}
 	error = bus_dmamem_alloc(dma->tag, (void **)&dma->vaddr,
-	    flags | BUS_DMA_ZERO, &dma->map);
+	    BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &dma->map);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: bus_dmamem_alloc failed, error %d\n", __func__, error);
 		goto fail;
 	}
-	error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr,
-	    size, iwn_dma_map_addr, &dma->paddr, flags);
+	error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr, size,
+	    iwn_dma_map_addr, &dma->paddr, BUS_DMA_NOWAIT);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: bus_dmamap_load failed, error %d\n", __func__, error);
@@ -1176,8 +1176,8 @@ static int
 iwn_alloc_sched(struct iwn_softc *sc)
 {
 	/* TX scheduler rings must be aligned on a 1KB boundary. */
-	return iwn_dma_contig_alloc(sc, &sc->sched_dma,
-	    (void **)&sc->sched, sc->sc_hal->schedsz, 1024, BUS_DMA_NOWAIT);
+	return iwn_dma_contig_alloc(sc, &sc->sched_dma, (void **)&sc->sched,
+	    sc->sc_hal->schedsz, 1024);
 }
 
 static void
@@ -1190,8 +1190,7 @@ static int
 iwn_alloc_kw(struct iwn_softc *sc)
 {
 	/* "Keep Warm" page must be aligned on a 4KB boundary. */
-	return iwn_dma_contig_alloc(sc, &sc->kw_dma, NULL, 4096, 4096,
-	    BUS_DMA_NOWAIT);
+	return iwn_dma_contig_alloc(sc, &sc->kw_dma, NULL, 4096, 4096);
 }
 
 static void
@@ -1204,8 +1203,8 @@ static int
 iwn_alloc_ict(struct iwn_softc *sc)
 {
 	/* ICT table must be aligned on a 4KB boundary. */
-	return iwn_dma_contig_alloc(sc, &sc->ict_dma,
-	    (void **)&sc->ict, IWN_ICT_SIZE, 4096, BUS_DMA_NOWAIT);
+	return iwn_dma_contig_alloc(sc, &sc->ict_dma, (void **)&sc->ict,
+	    IWN_ICT_SIZE, 4096);
 }
 
 static void
@@ -1218,8 +1217,8 @@ static int
 iwn_alloc_fwmem(struct iwn_softc *sc)
 {
 	/* Must be aligned on a 16-byte boundary. */
-	return iwn_dma_contig_alloc(sc, &sc->fw_dma, NULL,
-	    sc->sc_hal->fwsz, 16, BUS_DMA_NOWAIT);
+	return iwn_dma_contig_alloc(sc, &sc->fw_dma, NULL, sc->sc_hal->fwsz,
+	    16);
 }
 
 static void
@@ -1238,8 +1237,8 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 
 	/* Allocate RX descriptors (256-byte aligned). */
 	size = IWN_RX_RING_COUNT * sizeof (uint32_t);
-	error = iwn_dma_contig_alloc(sc, &ring->desc_dma,
-	    (void **)&ring->desc, size, 256, BUS_DMA_NOWAIT);
+	error = iwn_dma_contig_alloc(sc, &ring->desc_dma, (void **)&ring->desc,
+	    size, 256);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not allocate Rx ring DMA memory, error %d\n",
@@ -1259,9 +1258,8 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 	}
 
 	/* Allocate RX status area (16-byte aligned). */
-	error = iwn_dma_contig_alloc(sc, &ring->stat_dma,
-	    (void **)&ring->stat, sizeof (struct iwn_rx_status),
-	    16, BUS_DMA_NOWAIT);
+	error = iwn_dma_contig_alloc(sc, &ring->stat_dma, (void **)&ring->stat,
+	    sizeof (struct iwn_rx_status), 16);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not allocate Rx status DMA memory, error %d\n",
@@ -1377,8 +1375,8 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 
 	/* Allocate TX descriptors (256-byte aligned.) */
 	size = IWN_TX_RING_COUNT * sizeof(struct iwn_tx_desc);
-	error = iwn_dma_contig_alloc(sc, &ring->desc_dma,
-	    (void **)&ring->desc, size, 256, BUS_DMA_NOWAIT);
+	error = iwn_dma_contig_alloc(sc, &ring->desc_dma, (void **)&ring->desc,
+	    size, 256);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not allocate TX ring DMA memory, error %d\n",
@@ -1394,8 +1392,8 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 		return 0;
 
 	size = IWN_TX_RING_COUNT * sizeof(struct iwn_tx_cmd);
-	error = iwn_dma_contig_alloc(sc, &ring->cmd_dma,
-	    (void **)&ring->cmd, size, 4, BUS_DMA_NOWAIT);
+	error = iwn_dma_contig_alloc(sc, &ring->cmd_dma, (void **)&ring->cmd,
+	    size, 4);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not allocate TX cmd DMA memory, error %d\n",

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 08:59:22 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 416A31065672;
	Sat, 16 Apr 2011 08:59:22 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 150668FC0C;
	Sat, 16 Apr 2011 08:59:22 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3G8xL2A097617;
	Sat, 16 Apr 2011 08:59:21 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3G8xLWg097615;
	Sat, 16 Apr 2011 08:59:21 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104160859.p3G8xLWg097615@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 08:59:21 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220692 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 08:59:22 -0000

Author: bschmidt
Date: Sat Apr 16 08:59:21 2011
New Revision: 220692
URL: http://svn.freebsd.org/changeset/base/220692

Log:
  OpenBSD uses IWN_RBUF_SIZE not MJUMPAGESIZE for the RX path, also replace
  caddr_t with void * to be in sync.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 08:57:17 2011	(r220691)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 08:59:21 2011	(r220692)
@@ -1247,9 +1247,9 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 	}
 
 	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
-	    BUS_SPACE_MAXADDR_32BIT,
-	    BUS_SPACE_MAXADDR, NULL, NULL, MJUMPAGESIZE, 1,
-	    MJUMPAGESIZE, BUS_DMA_NOWAIT, NULL, NULL, &ring->data_dmat);
+	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+	    IWN_RBUF_SIZE, 1, IWN_RBUF_SIZE, BUS_DMA_NOWAIT, NULL, NULL,
+	    &ring->data_dmat);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: bus_dma_tag_create_failed, error %d\n",
@@ -1282,7 +1282,8 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 			goto fail;
 		}
 
-		data->m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE);
+		data->m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR,
+		    IWN_RBUF_SIZE);
 		if (data->m == NULL) {
 			device_printf(sc->sc_dev,
 			    "%s: could not allocate rx mbuf\n", __func__);
@@ -1290,10 +1291,9 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 			goto fail;
 		}
 
-		/* Map page. */
 		error = bus_dmamap_load(ring->data_dmat, data->map,
-		    mtod(data->m, caddr_t), MJUMPAGESIZE,
-		    iwn_dma_map_addr, &paddr, BUS_DMA_NOWAIT);
+		    mtod(data->m, void *), IWN_RBUF_SIZE, iwn_dma_map_addr,
+		    &paddr, BUS_DMA_NOWAIT);
 		if (error != 0 && error != EFBIG) {
 			device_printf(sc->sc_dev,
 			    "%s: bus_dmamap_load failed, error %d\n",
@@ -2093,8 +2093,7 @@ iwn_rx_done(struct iwn_softc *sc, struct
 		return;
 	}
 
-	/* XXX don't need mbuf, just dma buffer */
-	m1 = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE);
+	m1 = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, IWN_RBUF_SIZE);
 	if (m1 == NULL) {
 		DPRINTF(sc, IWN_DEBUG_ANY, "%s: no mbuf to restock ring\n",
 		    __func__);
@@ -2103,9 +2102,8 @@ iwn_rx_done(struct iwn_softc *sc, struct
 	}
 	bus_dmamap_unload(ring->data_dmat, data->map);
 
-	error = bus_dmamap_load(ring->data_dmat, data->map,
-	    mtod(m1, caddr_t), MJUMPAGESIZE,
-	    iwn_dma_map_addr, &paddr, BUS_DMA_NOWAIT);
+	error = bus_dmamap_load(ring->data_dmat, data->map, mtod(m1, void *),
+	    IWN_RBUF_SIZE, iwn_dma_map_addr, &paddr, BUS_DMA_NOWAIT);
 	if (error != 0 && error != EFBIG) {
 		device_printf(sc->sc_dev,
 		    "%s: bus_dmamap_load failed, error %d\n", __func__, error);

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 09:34:41 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1F6BB106566C;
	Sat, 16 Apr 2011 09:34:41 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0E4678FC0C;
	Sat, 16 Apr 2011 09:34:41 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3G9Yelm098378;
	Sat, 16 Apr 2011 09:34:40 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3G9YeWJ098376;
	Sat, 16 Apr 2011 09:34:40 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104160934.p3G9YeWJ098376@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 09:34:40 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220693 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 09:34:41 -0000

Author: bschmidt
Date: Sat Apr 16 09:34:40 2011
New Revision: 220693
URL: http://svn.freebsd.org/changeset/base/220693

Log:
  In case a new mbuf can't be loaded, reuse the old one.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 08:59:21 2011	(r220692)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 09:34:40 2011	(r220693)
@@ -2108,6 +2108,18 @@ iwn_rx_done(struct iwn_softc *sc, struct
 		device_printf(sc->sc_dev,
 		    "%s: bus_dmamap_load failed, error %d\n", __func__, error);
 		m_freem(m1);
+
+		/* Try to reload the old mbuf. */
+		error = bus_dmamap_load(ring->data_dmat, data->map,
+		    mtod(data->m, void *), IWN_RBUF_SIZE, iwn_dma_map_addr,
+		    &paddr, BUS_DMA_NOWAIT);
+		if (error != 0 && error != EFBIG) {
+			panic("%s: could not load old RX mbuf", __func__);
+		}
+		/* Physical address may have changed. */
+		ring->desc[ring->cur] = htole32(paddr >> 8);
+		bus_dmamap_sync(ring->data_dmat, ring->desc_dma.map,
+		    BUS_DMASYNC_PREWRITE);
 		ifp->if_ierrors++;
 		return;
 	}

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 09:39:08 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 79F71106566C;
	Sat, 16 Apr 2011 09:39:08 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 68D408FC08;
	Sat, 16 Apr 2011 09:39:08 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3G9d8D6098490;
	Sat, 16 Apr 2011 09:39:08 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3G9d8fY098488;
	Sat, 16 Apr 2011 09:39:08 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104160939.p3G9d8fY098488@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 09:39:08 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220694 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 09:39:08 -0000

Author: bschmidt
Date: Sat Apr 16 09:39:08 2011
New Revision: 220694
URL: http://svn.freebsd.org/changeset/base/220694

Log:
  scratch_paddr has the same address pre-assigned, use that instead.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 09:34:40 2011	(r220693)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 09:39:08 2011	(r220694)
@@ -3145,7 +3145,6 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 	struct iwn_tx_desc *desc;
 	struct iwn_tx_data *data;
 	struct mbuf *mnew;
-	bus_addr_t paddr;
 	bus_dma_segment_t segs[IWN_MAX_SCATTER];
 	uint32_t flags;
 	u_int hdrlen;
@@ -3246,9 +3245,8 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 	txant = IWN_LSB(sc->txchainmask);
 	tx->rflags |= IWN_RFLAG_ANT(txant);
 	/* Set physical address of "scratch area". */
-	paddr = ring->cmd_dma.paddr + ring->cur * sizeof (struct iwn_tx_cmd);
-	tx->loaddr = htole32(IWN_LOADDR(paddr));
-	tx->hiaddr = IWN_HIADDR(paddr);
+	tx->loaddr = htole32(IWN_LOADDR(data->scratch_paddr));
+	tx->hiaddr = IWN_HIADDR(data->scratch_paddr);
 
 	/* Copy 802.11 header in TX command. */
 	memcpy((uint8_t *)(tx + 1), wh, hdrlen);

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 10:32:47 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 15ADF1065670;
	Sat, 16 Apr 2011 10:32:47 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 0467B8FC18;
	Sat, 16 Apr 2011 10:32:47 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GAWkUX001680;
	Sat, 16 Apr 2011 10:32:46 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GAWk21001678;
	Sat, 16 Apr 2011 10:32:46 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161032.p3GAWk21001678@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 10:32:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220700 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 10:32:47 -0000

Author: bschmidt
Date: Sat Apr 16 10:32:46 2011
New Revision: 220700
URL: http://svn.freebsd.org/changeset/base/220700

Log:
  Rewrite DMA segment handling to be more inline with the OpenBSD code.
  Also change the m_len == 0 hack to have less code churn.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 10:22:06 2011	(r220699)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 10:32:46 2011	(r220700)
@@ -2906,8 +2906,8 @@ iwn_tx_data(struct iwn_softc *sc, struct
 	struct iwn_cmd_data *tx;
 	struct ieee80211_frame *wh;
 	struct ieee80211_key *k = NULL;
-	struct mbuf *mnew;
-	bus_dma_segment_t segs[IWN_MAX_SCATTER];
+	struct mbuf *m1;
+	bus_dma_segment_t *seg, segs[IWN_MAX_SCATTER];
 	uint32_t flags;
 	u_int hdrlen;
 	int totlen, error, pad, nsegs = 0, i, rate;
@@ -3063,26 +3063,30 @@ iwn_tx_data(struct iwn_softc *sc, struct
 	tx->security = 0;
 	tx->flags = htole32(flags);
 
-	if (m->m_len > 0) {
-		error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map,
-		    m, segs, &nsegs, BUS_DMA_NOWAIT);
-		if (error == EFBIG) {
-			/* too many fragments, linearize */
-			mnew = m_collapse(m, M_DONTWAIT, IWN_MAX_SCATTER);
-			if (mnew == NULL) {
-				device_printf(sc->sc_dev,
-				    "%s: could not defrag mbuf\n", __func__);
-				m_freem(m);
-				return ENOBUFS;
-			}
-			m = mnew;
-			error = bus_dmamap_load_mbuf_sg(ring->data_dmat,
-			    data->map, m, segs, &nsegs, BUS_DMA_NOWAIT);
+	error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m, segs,
+	    &nsegs, BUS_DMA_NOWAIT);
+	if (error != 0) {
+		if (error != EFBIG) {
+			device_printf(sc->sc_dev,
+			    "%s: can't map mbuf (error %d)\n", __func__, error);
+			m_freem(m);
+			return error;
+		}
+		/* Too many DMA segments, linearize mbuf. */
+		m1 = m_collapse(m, M_DONTWAIT, IWN_MAX_SCATTER);
+		if (m1 == NULL) {
+			device_printf(sc->sc_dev,
+			    "%s: could not defrag mbuf\n", __func__);
+			m_freem(m);
+			return ENOBUFS;
 		}
+		m = m1;
+
+		error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m,
+		    segs, &nsegs, BUS_DMA_NOWAIT);
 		if (error != 0) {
 			device_printf(sc->sc_dev,
-			    "%s: bus_dmamap_load_mbuf_sg failed, error %d\n",
-			    __func__, error);
+			    "%s: can't map mbuf (error %d)\n", __func__, error);
 			m_freem(m);
 			return error;
 		}
@@ -3095,16 +3099,20 @@ iwn_tx_data(struct iwn_softc *sc, struct
 	    __func__, ring->qid, ring->cur, m->m_pkthdr.len, nsegs);
 
 	/* Fill TX descriptor. */
-	desc->nsegs = 1 + nsegs;
+	desc->nsegs = 1;
+	if (m->m_len != 0)
+		desc->nsegs += nsegs;
 	/* First DMA segment is used by the TX command. */
 	desc->segs[0].addr = htole32(IWN_LOADDR(data->cmd_paddr));
 	desc->segs[0].len  = htole16(IWN_HIADDR(data->cmd_paddr) |
 	    (4 + sizeof (*tx) + hdrlen + pad) << 4);
 	/* Other DMA segments are for data payload. */
+	seg = &segs[0];
 	for (i = 1; i <= nsegs; i++) {
-		desc->segs[i].addr = htole32(IWN_LOADDR(segs[i - 1].ds_addr));
-		desc->segs[i].len  = htole16(IWN_HIADDR(segs[i - 1].ds_addr) |
-		    segs[i - 1].ds_len << 4);
+		desc->segs[i].addr = htole32(IWN_LOADDR(seg->ds_addr));
+		desc->segs[i].len  = htole16(IWN_HIADDR(seg->ds_addr) |
+		    seg->ds_len << 4);
+		seg++;
 	}
 
 	bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE);
@@ -3144,8 +3152,8 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 	struct ieee80211_frame *wh;
 	struct iwn_tx_desc *desc;
 	struct iwn_tx_data *data;
-	struct mbuf *mnew;
-	bus_dma_segment_t segs[IWN_MAX_SCATTER];
+	struct mbuf *m1;
+	bus_dma_segment_t *seg, segs[IWN_MAX_SCATTER];
 	uint32_t flags;
 	u_int hdrlen;
 	int totlen, error, pad, nsegs = 0, i, rate;
@@ -3256,26 +3264,30 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 	tx->security = 0;
 	tx->flags = htole32(flags);
 
-	if (m->m_len > 0) {
-		error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map,
-		    m, segs, &nsegs, BUS_DMA_NOWAIT);
-		if (error == EFBIG) {
-			/* Too many fragments, linearize. */
-			mnew = m_collapse(m, M_DONTWAIT, IWN_MAX_SCATTER);
-			if (mnew == NULL) {
-				device_printf(sc->sc_dev,
-				    "%s: could not defrag mbuf\n", __func__);
-				m_freem(m);
-				return ENOBUFS;
-			}
-			m = mnew;
-			error = bus_dmamap_load_mbuf_sg(ring->data_dmat,
-			    data->map, m, segs, &nsegs, BUS_DMA_NOWAIT);
+	error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m, segs,
+	    &nsegs, BUS_DMA_NOWAIT);
+	if (error != 0) {
+		if (error != EFBIG) {
+			device_printf(sc->sc_dev,
+			    "%s: can't map mbuf (error %d)\n", __func__, error);
+			m_freem(m);
+			return error;
+		}
+		/* Too many DMA segments, linearize mbuf. */
+		m1 = m_collapse(m, M_DONTWAIT, IWN_MAX_SCATTER);
+		if (m1 == NULL) {
+			device_printf(sc->sc_dev,
+			    "%s: could not defrag mbuf\n", __func__);
+			m_freem(m);
+			return ENOBUFS;
 		}
+		m = m1;
+
+		error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m,
+		    segs, &nsegs, BUS_DMA_NOWAIT);
 		if (error != 0) {
 			device_printf(sc->sc_dev,
-			    "%s: bus_dmamap_load_mbuf_sg failed, error %d\n",
-			    __func__, error);
+			    "%s: can't map mbuf (error %d)\n", __func__, error);
 			m_freem(m);
 			return error;
 		}
@@ -3288,16 +3300,20 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 	    __func__, ring->qid, ring->cur, m->m_pkthdr.len, nsegs);
 
 	/* Fill TX descriptor. */
-	desc->nsegs = 1 + nsegs;
+	desc->nsegs = 1;
+	if (m->m_len != 0)
+		desc->nsegs += nsegs;
 	/* First DMA segment is used by the TX command. */
 	desc->segs[0].addr = htole32(IWN_LOADDR(data->cmd_paddr));
 	desc->segs[0].len  = htole16(IWN_HIADDR(data->cmd_paddr) |
 	    (4 + sizeof (*tx) + hdrlen + pad) << 4);
 	/* Other DMA segments are for data payload. */
+	seg = &segs[0];
 	for (i = 1; i <= nsegs; i++) {
-		desc->segs[i].addr = htole32(IWN_LOADDR(segs[i - 1].ds_addr));
-		desc->segs[i].len  = htole16(IWN_HIADDR(segs[i - 1].ds_addr) |
-		    segs[i - 1].ds_len << 4);
+		desc->segs[i].addr = htole32(IWN_LOADDR(seg->ds_addr));
+		desc->segs[i].len  = htole16(IWN_HIADDR(seg->ds_addr) |
+		    seg->ds_len << 4);
+		seg++;
 	}
 
 	bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE);

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 10:35:02 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CAE21106566B;
	Sat, 16 Apr 2011 10:35:02 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B74418FC14;
	Sat, 16 Apr 2011 10:35:02 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GAZ2EQ001782;
	Sat, 16 Apr 2011 10:35:02 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GAZ2hv001780;
	Sat, 16 Apr 2011 10:35:02 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161035.p3GAZ2hv001780@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 10:35:02 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220701 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 10:35:02 -0000

Author: bschmidt
Date: Sat Apr 16 10:35:02 2011
New Revision: 220701
URL: http://svn.freebsd.org/changeset/base/220701

Log:
  Make sure to destroy all DMA tags and maps.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 10:32:46 2011	(r220700)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 10:35:02 2011	(r220701)
@@ -1159,16 +1159,20 @@ fail:
 static void
 iwn_dma_contig_free(struct iwn_dma_info *dma)
 {
-	if (dma->tag != NULL) {
-		if (dma->map != NULL) {
-			if (dma->paddr == 0) {
-				bus_dmamap_sync(dma->tag, dma->map,
-				    BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
-				bus_dmamap_unload(dma->tag, dma->map);
-			}
+	if (dma->map != NULL) {
+		if (dma->vaddr != NULL) {
+			bus_dmamap_sync(dma->tag, dma->map,
+			    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+			bus_dmamap_unload(dma->tag, dma->map);
 			bus_dmamem_free(dma->tag, &dma->vaddr, dma->map);
+			dma->vaddr = NULL;
 		}
+		bus_dmamap_destroy(dma->tag, dma->map);
+		dma->map = NULL;
+	}
+	if (dma->tag != NULL) {
 		bus_dma_tag_destroy(dma->tag);
+		dma->tag = NULL;
 	}
 }
 
@@ -1360,6 +1364,10 @@ iwn_free_rx_ring(struct iwn_softc *sc, s
 		if (data->map != NULL)
 			bus_dmamap_destroy(ring->data_dmat, data->map);
 	}
+	if (ring->data_dmat != NULL) {
+		bus_dma_tag_destroy(ring->data_dmat);
+		ring->data_dmat = NULL;
+	}
 }
 
 static int
@@ -1479,6 +1487,10 @@ iwn_free_tx_ring(struct iwn_softc *sc, s
 		if (data->map != NULL)
 			bus_dmamap_destroy(ring->data_dmat, data->map);
 	}
+	if (ring->data_dmat != NULL) {
+		bus_dma_tag_destroy(ring->data_dmat);
+		ring->data_dmat = NULL;
+	}
 }
 
 static void

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 10:38:27 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CA07B1065672;
	Sat, 16 Apr 2011 10:38:27 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B96DA8FC18;
	Sat, 16 Apr 2011 10:38:27 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GAcR8x001870;
	Sat, 16 Apr 2011 10:38:27 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GAcRQA001868;
	Sat, 16 Apr 2011 10:38:27 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161038.p3GAcRQA001868@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 10:38:27 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220702 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 10:38:27 -0000

Author: bschmidt
Date: Sat Apr 16 10:38:27 2011
New Revision: 220702
URL: http://svn.freebsd.org/changeset/base/220702

Log:
  Unify TX/RX ring allocation, finish the descriptior DMA stuff before
  starting with data.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 10:35:02 2011	(r220701)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 10:38:27 2011	(r220702)
@@ -1250,23 +1250,24 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 		goto fail;
 	}
 
-	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
-	    IWN_RBUF_SIZE, 1, IWN_RBUF_SIZE, BUS_DMA_NOWAIT, NULL, NULL,
-	    &ring->data_dmat);
+	/* Allocate RX status area (16-byte aligned). */
+	error = iwn_dma_contig_alloc(sc, &ring->stat_dma, (void **)&ring->stat,
+	    sizeof (struct iwn_rx_status), 16);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: bus_dma_tag_create_failed, error %d\n",
+		    "%s: could not allocate Rx status DMA memory, error %d\n",
 		    __func__, error);
 		goto fail;
 	}
 
-	/* Allocate RX status area (16-byte aligned). */
-	error = iwn_dma_contig_alloc(sc, &ring->stat_dma, (void **)&ring->stat,
-	    sizeof (struct iwn_rx_status), 16);
+	/* Create RX buffer DMA tag. */
+	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
+	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+	    IWN_RBUF_SIZE, 1, IWN_RBUF_SIZE, BUS_DMA_NOWAIT, NULL, NULL,
+	    &ring->data_dmat);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not allocate Rx status DMA memory, error %d\n",
+		    "%s: bus_dma_tag_create_failed, error %d\n",
 		    __func__, error);
 		goto fail;
 	}

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 10:52:11 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D185D1065675;
	Sat, 16 Apr 2011 10:52:11 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A7F498FC08;
	Sat, 16 Apr 2011 10:52:11 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GAqBht002228;
	Sat, 16 Apr 2011 10:52:11 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GAqBrY002226;
	Sat, 16 Apr 2011 10:52:11 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161052.p3GAqBrY002226@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 10:52:11 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220704 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 10:52:11 -0000

Author: bschmidt
Date: Sat Apr 16 10:52:11 2011
New Revision: 220704
URL: http://svn.freebsd.org/changeset/base/220704

Log:
  Add missing bus_dmamap_sync calls as well as remove two duplicate ones.
  
  Obtained from:	OpenBSD

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 10:42:22 2011	(r220703)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 10:52:11 2011	(r220704)
@@ -1148,6 +1148,8 @@ iwn_dma_contig_alloc(struct iwn_softc *s
 		goto fail;
 	}
 
+	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
+
 	if (kvap != NULL)
 		*kvap = dma->vaddr;
 	return 0;
@@ -1307,8 +1309,6 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 			error = ENOMEM;	/* XXX unique code */
 			goto fail;
 		}
-		bus_dmamap_sync(ring->data_dmat, data->map,
-		    BUS_DMASYNC_PREWRITE);
 
 		/* Set physical address of RX buffer (256-byte aligned). */
 		ring->desc[i] = htole32(paddr >> 8);
@@ -1436,8 +1436,6 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 			    __func__, error);
 			goto fail;
 		}
-		bus_dmamap_sync(ring->data_dmat, data->map,
-		    BUS_DMASYNC_PREWRITE);
 	}
 	return 0;
 fail:
@@ -1454,6 +1452,8 @@ iwn_reset_tx_ring(struct iwn_softc *sc, 
 		struct iwn_tx_data *data = &ring->data[i];
 
 		if (data->m != NULL) {
+			bus_dmamap_sync(ring->data_dmat, data->map,
+			    BUS_DMASYNC_POSTWRITE);
 			bus_dmamap_unload(ring->data_dmat, data->map);
 			m_freem(data->m);
 			data->m = NULL;
@@ -2208,6 +2208,8 @@ iwn_rx_compressed_ba(struct iwn_softc *s
 	struct iwn_compressed_ba *ba = (struct iwn_compressed_ba *)(desc + 1);
 	struct iwn_tx_ring *txq;
 
+	bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
+
 	txq = &sc->txq[letoh16(ba->qid)];
 	/* XXX TBD */
 }
@@ -2458,6 +2460,8 @@ iwn_cmd_done(struct iwn_softc *sc, struc
 
 	/* If the command was mapped in an mbuf, free it. */
 	if (data->m != NULL) {
+		bus_dmamap_sync(ring->data_dmat, data->map,
+		    BUS_DMASYNC_POSTWRITE);
 		bus_dmamap_unload(ring->data_dmat, data->map);
 		m_freem(data->m);
 		data->m = NULL;

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 11:11:22 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id ED6F4106564A;
	Sat, 16 Apr 2011 11:11:22 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id DD0768FC08;
	Sat, 16 Apr 2011 11:11:22 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GBBMxq002941;
	Sat, 16 Apr 2011 11:11:22 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GBBMod002939;
	Sat, 16 Apr 2011 11:11:22 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161111.p3GBBMod002939@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 11:11:22 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220710 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 11:11:23 -0000

Author: bschmidt
Date: Sat Apr 16 11:11:22 2011
New Revision: 220710
URL: http://svn.freebsd.org/changeset/base/220710

Log:
  Prevent double-free, also use the same error codes as OpenBSD.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 11:06:09 2011	(r220709)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 11:11:22 2011	(r220710)
@@ -1294,7 +1294,7 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 		if (data->m == NULL) {
 			device_printf(sc->sc_dev,
 			    "%s: could not allocate rx mbuf\n", __func__);
-			error = ENOMEM;
+			error = ENOBUFS;
 			goto fail;
 		}
 
@@ -1305,8 +1305,6 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 			device_printf(sc->sc_dev,
 			    "%s: bus_dmamap_load failed, error %d\n",
 			    __func__, error);
-			m_freem(data->m);
-			error = ENOMEM;	/* XXX unique code */
 			goto fail;
 		}
 
@@ -1361,6 +1359,7 @@ iwn_free_rx_ring(struct iwn_softc *sc, s
 			    BUS_DMASYNC_POSTREAD);
 			bus_dmamap_unload(ring->data_dmat, data->map);
 			m_freem(data->m);
+			data->m = NULL;
 		}
 		if (data->map != NULL)
 			bus_dmamap_destroy(ring->data_dmat, data->map);

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 11:14:42 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5C2B11065673;
	Sat, 16 Apr 2011 11:14:42 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4B3498FC19;
	Sat, 16 Apr 2011 11:14:42 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GBEgGL003035;
	Sat, 16 Apr 2011 11:14:42 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GBEgLc003033;
	Sat, 16 Apr 2011 11:14:42 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161114.p3GBEgLc003033@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 11:14:42 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220711 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 11:14:42 -0000

Author: bschmidt
Date: Sat Apr 16 11:14:42 2011
New Revision: 220711
URL: http://svn.freebsd.org/changeset/base/220711

Log:
  Replace RX/TX ring allocation error messages with something more sane
  and remove those where the caller already prints one.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 11:11:22 2011	(r220710)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 11:14:42 2011	(r220711)
@@ -1127,26 +1127,18 @@ iwn_dma_contig_alloc(struct iwn_softc *s
 	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), alignment,
 	    0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size,
 	    1, size, BUS_DMA_NOWAIT, NULL, NULL, &dma->tag);
-	if (error != 0) {
-		device_printf(sc->sc_dev,
-		    "%s: bus_dma_tag_create failed, error %d\n",
-		    __func__, error);
+	if (error != 0)
 		goto fail;
-	}
+
 	error = bus_dmamem_alloc(dma->tag, (void **)&dma->vaddr,
 	    BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &dma->map);
-	if (error != 0) {
-		device_printf(sc->sc_dev,
-		    "%s: bus_dmamem_alloc failed, error %d\n", __func__, error);
+	if (error != 0)
 		goto fail;
-	}
+
 	error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr, size,
 	    iwn_dma_map_addr, &dma->paddr, BUS_DMA_NOWAIT);
-	if (error != 0) {
-		device_printf(sc->sc_dev,
-		    "%s: bus_dmamap_load failed, error %d\n", __func__, error);
+	if (error != 0)
 		goto fail;
-	}
 
 	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
 
@@ -1247,7 +1239,7 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 	    size, 256);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not allocate Rx ring DMA memory, error %d\n",
+		    "%s: could not allocate RX ring DMA memory, error %d\n",
 		    __func__, error);
 		goto fail;
 	}
@@ -1257,7 +1249,7 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 	    sizeof (struct iwn_rx_status), 16);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not allocate Rx status DMA memory, error %d\n",
+		    "%s: could not allocate RX status DMA memory, error %d\n",
 		    __func__, error);
 		goto fail;
 	}
@@ -1269,7 +1261,7 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 	    &ring->data_dmat);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: bus_dma_tag_create_failed, error %d\n",
+		    "%s: could not create RX buf DMA tag, error %d\n",
 		    __func__, error);
 		goto fail;
 	}
@@ -1284,7 +1276,7 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 		error = bus_dmamap_create(ring->data_dmat, 0, &data->map);
 		if (error != 0) {
 			device_printf(sc->sc_dev,
-			    "%s: bus_dmamap_create failed, error %d\n",
+			    "%s: could not create RX buf DMA map, error %d\n",
 			    __func__, error);
 			goto fail;
 		}
@@ -1293,7 +1285,7 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 		    IWN_RBUF_SIZE);
 		if (data->m == NULL) {
 			device_printf(sc->sc_dev,
-			    "%s: could not allocate rx mbuf\n", __func__);
+			    "%s: could not allocate RX mbuf\n", __func__);
 			error = ENOBUFS;
 			goto fail;
 		}
@@ -1303,8 +1295,8 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 		    &paddr, BUS_DMA_NOWAIT);
 		if (error != 0 && error != EFBIG) {
 			device_printf(sc->sc_dev,
-			    "%s: bus_dmamap_load failed, error %d\n",
-			    __func__, error);
+			    "%s: can't not map mbuf, error %d\n", __func__,
+			    error);
 			goto fail;
 		}
 
@@ -1415,7 +1407,7 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 	    MCLBYTES, BUS_DMA_NOWAIT, NULL, NULL, &ring->data_dmat);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: bus_dma_tag_create_failed, error %d\n",
+		    "%s: could not create TX buf DMA tag, error %d\n",
 		    __func__, error);
 		goto fail;
 	}
@@ -1431,7 +1423,7 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 		error = bus_dmamap_create(ring->data_dmat, 0, &data->map);
 		if (error != 0) {
 			device_printf(sc->sc_dev,
-			    "%s: bus_dmamap_create failed, error %d\n",
+			    "%s: could not create TX buf DMA map, error %d\n",
 			    __func__, error);
 			goto fail;
 		}

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 11:15:58 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 33BED106566B;
	Sat, 16 Apr 2011 11:15:58 +0000 (UTC)
	(envelope-from brucec@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 2332B8FC0A;
	Sat, 16 Apr 2011 11:15:58 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GBFwfN003100;
	Sat, 16 Apr 2011 11:15:58 GMT (envelope-from brucec@svn.freebsd.org)
Received: (from brucec@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GBFwJg003098;
	Sat, 16 Apr 2011 11:15:58 GMT (envelope-from brucec@svn.freebsd.org)
Message-Id: <201104161115.p3GBFwJg003098@svn.freebsd.org>
From: Bruce Cran 
Date: Sat, 16 Apr 2011 11:15:58 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220712 - head/sys/modules/netgraph/atm/ccatm
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 11:15:58 -0000

Author: brucec
Date: Sat Apr 16 11:15:57 2011
New Revision: 220712
URL: http://svn.freebsd.org/changeset/base/220712

Log:
  Remove missing include directory in preparation for adding
  -Wmissing-include-dirs to CWARNFLAGS.

Modified:
  head/sys/modules/netgraph/atm/ccatm/Makefile

Modified: head/sys/modules/netgraph/atm/ccatm/Makefile
==============================================================================
--- head/sys/modules/netgraph/atm/ccatm/Makefile	Sat Apr 16 11:14:42 2011	(r220711)
+++ head/sys/modules/netgraph/atm/ccatm/Makefile	Sat Apr 16 11:15:57 2011	(r220712)
@@ -12,6 +12,6 @@ KMOD=	ng_ccatm
 SRCS=	ng_ccatm.c cc_conn.c cc_data.c cc_dump.c cc_port.c cc_sig.c	\
 	cc_user.c unisap.c
 
-CFLAGS+= -I${LIBBASE} -I${LIBBASE}/netnatm/ccatm -DCCATM_DEBUG
+CFLAGS+= -I${LIBBASE} -DCCATM_DEBUG
 
 .include 

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 11:17:55 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E01041065670;
	Sat, 16 Apr 2011 11:17:55 +0000 (UTC)
	(envelope-from bruce@cran.org.uk)
Received: from muon.cran.org.uk (muon.cran.org.uk
	[IPv6:2a01:348:0:15:5d59:5c40:0:1])
	by mx1.freebsd.org (Postfix) with ESMTP id 740D88FC1A;
	Sat, 16 Apr 2011 11:17:55 +0000 (UTC)
Received: from muon.cran.org.uk (localhost [127.0.0.1])
	by muon.cran.org.uk (Postfix) with ESMTP id 1C74CE61C9;
	Sat, 16 Apr 2011 12:17:54 +0100 (BST)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cran.org.uk; h=subject
	:from:to:cc:in-reply-to:references:content-type:date:message-id
	:mime-version:content-transfer-encoding; s=mail; bh=ejyFEFdGeNLW
	28YsiHVTGClk0RI=; b=ryCoBDhVMqk4nXxNgNoUnlgqy8k9G0Q7GAayfCN2D4zF
	Pu5x9de2GFN8DhQGwTUm549C+jY+fZn+2ON24bnMsEm2ZhiJDH+Dj57pENa6SmnC
	FZQ+CepWgTTTbMbJRYiOEgtc+LjEBI5kt6z10Tejkenuz/X5ZYLszAAfCDrrA/c=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=cran.org.uk; h=subject:from
	:to:cc:in-reply-to:references:content-type:date:message-id
	:mime-version:content-transfer-encoding; q=dns; s=mail; b=Vap/3v
	8HAiUeSICFaT8Uvo44oBiNG7DPqxC3M88ARBDY4RqOVOvyS4+0UkH+uQarqiEcbT
	O+Xtj1YOkHD9v8mgwxJUZW8QJfmx0tm3ZnYSa/esYfG1e4P1KNzkpo7UuS4w2pEv
	oDMe4+YnCSG0mfOrHGcwcyaEVYS/FHTl/BrW8=
Received: from [192.168.1.68] (188-222-18-231.zone13.bethere.co.uk
	[188.222.18.231])
	(using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
	(No client certificate requested)
	by muon.cran.org.uk (Postfix) with ESMTPSA id C0776E61C8;
	Sat, 16 Apr 2011 12:17:53 +0100 (BST)
From: Bruce Cran 
To: Bruce Cran 
In-Reply-To: <201104161115.p3GBFwJg003098@svn.freebsd.org>
References: <201104161115.p3GBFwJg003098@svn.freebsd.org>
Content-Type: text/plain; charset="us-ascii"
Date: Sat, 16 Apr 2011 12:17:37 +0100
Message-ID: <1302952657.3027.0.camel@core.nessbank>
Mime-Version: 1.0
X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port 
Content-Transfer-Encoding: 7bit
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r220712 - head/sys/modules/netgraph/atm/ccatm
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 11:17:56 -0000

On Sat, 2011-04-16 at 11:15 +0000, Bruce Cran wrote:

> Log:
>   Remove missing include directory in preparation for adding
>   -Wmissing-include-dirs to CWARNFLAGS.

Submitted by: arundel

-- 
Bruce Cran


From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 11:59:37 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9C31E106566C;
	Sat, 16 Apr 2011 11:59:37 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 8A8398FC0C;
	Sat, 16 Apr 2011 11:59:37 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GBxbKi004051;
	Sat, 16 Apr 2011 11:59:37 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GBxbDH004047;
	Sat, 16 Apr 2011 11:59:37 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104161159.p3GBxbDH004047@svn.freebsd.org>
From: Adrian Chadd 
Date: Sat, 16 Apr 2011 11:59:37 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220713 - in head/sys/dev/ath/ath_hal: ar5416 ar9002
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 11:59:37 -0000

Author: adrian
Date: Sat Apr 16 11:59:37 2011
New Revision: 220713
URL: http://svn.freebsd.org/changeset/base/220713

Log:
  Remove some duplicate code from the AR9285 TX power configuration path.

Modified:
  head/sys/dev/ath/ath_hal/ar5416/ar5416.h
  head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
  head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416.h	Sat Apr 16 11:15:57 2011	(r220712)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416.h	Sat Apr 16 11:59:37 2011	(r220713)
@@ -246,6 +246,8 @@ extern	void ar5416InitChainMasks(struct 
 extern	void ar5416RestoreChainMask(struct ath_hal *ah);
 extern	void ar5416EepromSetAddac(struct ath_hal *ah,
 		const struct ieee80211_channel *chan);
+extern	uint16_t ar5416GetMaxEdgePower(uint16_t freq,
+		CAL_CTL_EDGES *pRdEdgesPower, HAL_BOOL is2GHz);
 
 /* TX power setup related routines in ar5416_reset.c */
 extern	void ar5416GetGainBoundariesAndPdadcs(struct ath_hal *ah,

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Sat Apr 16 11:15:57 2011	(r220712)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c	Sat Apr 16 11:59:37 2011	(r220713)
@@ -61,8 +61,6 @@ static HAL_BOOL ar5416SetPowerPerRateTab
 	uint16_t cfgCtl, uint16_t AntennaReduction,
 	uint16_t twiceMaxRegulatoryPower, 
 	uint16_t powerLimit);
-static uint16_t ar5416GetMaxEdgePower(uint16_t freq,
-	CAL_CTL_EDGES *pRdEdgesPower, HAL_BOOL is2GHz);
 static void ar5416Set11nRegs(struct ath_hal *ah, const struct ieee80211_channel *chan);
 
 /*
@@ -1779,7 +1777,7 @@ fbin2freq(uint8_t fbin, HAL_BOOL is2GHz)
  *
  * Find the maximum conformance test limit for the given channel and CTL info
  */
-static uint16_t
+uint16_t
 ar5416GetMaxEdgePower(uint16_t freq, CAL_CTL_EDGES *pRdEdgesPower, HAL_BOOL is2GHz)
 {
     uint16_t twiceMaxEdgePower = AR5416_MAX_RATE_POWER;

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c	Sat Apr 16 11:15:57 2011	(r220712)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c	Sat Apr 16 11:59:37 2011	(r220713)
@@ -65,7 +65,6 @@ static void ar9285GetGainBoundariesAndPd
 	uint16_t tPdGainOverlap, int16_t *pMinCalPower,
 	uint16_t * pPdGainBoundaries, uint8_t * pPDADCValues,
 	uint16_t numXpdGains);
-static uint16_t ar9285GetMaxEdgePower(uint16_t, CAL_CTL_EDGES *);
 
 HAL_BOOL
 ar9285SetTransmitPower(struct ath_hal *ah,
@@ -558,9 +557,9 @@ ar9285SetPowerPerRateTable(struct ath_ha
 				(((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == 
 				 ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))) {
 				rep = &(pEepData->ctlData[i]);
-				twiceMinEdgePower = ar9285GetMaxEdgePower(freq,
+				twiceMinEdgePower = ar5416GetMaxEdgePower(freq,
 							rep->ctlEdges[
-							  owl_get_ntxchains(AH5416(ah)->ah_tx_chainmask) - 1]);
+							  owl_get_ntxchains(AH5416(ah)->ah_tx_chainmask) - 1], AH_TRUE);
 				if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL) {
 					/* Find the minimum of all CTL edge powers that apply to this channel */
 					twiceMaxEdgePower = AH_MIN(twiceMaxEdgePower, twiceMinEdgePower);
@@ -643,58 +642,6 @@ ar9285SetPowerPerRateTable(struct ath_ha
 #undef N
 }
 
-/**************************************************************************
- * fbin2freq
- *
- * Get channel value from binary representation held in eeprom
- * RETURNS: the frequency in MHz
- */
-static uint16_t
-fbin2freq(uint8_t fbin)
-{
-    /*
-     * Reserved value 0xFF provides an empty definition both as
-     * an fbin and as a frequency - do not convert
-     */
-    if (fbin == AR5416_BCHAN_UNUSED) {
-        return fbin;
-    }
-
-    return (uint16_t)(2300 + fbin);
-}
-
-/*
- * XXX almost the same as ar5416GetMaxEdgePower.
- */
-static uint16_t
-ar9285GetMaxEdgePower(uint16_t freq, CAL_CTL_EDGES *pRdEdgesPower)
-{
-    uint16_t twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
-    int      i;
-
-    /* Get the edge power */
-    for (i = 0; (i < AR5416_NUM_BAND_EDGES) && (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED) ; i++) {
-        /*
-         * If there's an exact channel match or an inband flag set
-         * on the lower channel use the given rdEdgePower
-         */
-        if (freq == fbin2freq(pRdEdgesPower[i].bChannel)) {
-            twiceMaxEdgePower = MS(pRdEdgesPower[i].tPowerFlag, CAL_CTL_EDGES_POWER);
-            break;
-        } else if ((i > 0) && (freq < fbin2freq(pRdEdgesPower[i].bChannel))) {
-            if (fbin2freq(pRdEdgesPower[i - 1].bChannel) < freq && (pRdEdgesPower[i - 1].tPowerFlag & CAL_CTL_EDGES_FLAG) != 0) {
-                twiceMaxEdgePower = MS(pRdEdgesPower[i - 1].tPowerFlag, CAL_CTL_EDGES_POWER);
-            }
-            /* Leave loop - no more affecting edges possible in this monotonic increasing list */
-            break;
-        }
-    }
-    HALASSERT(twiceMaxEdgePower > 0);
-    return twiceMaxEdgePower;
-}
-
-
-
 static HAL_BOOL
 ar9285SetPowerCalTable(struct ath_hal *ah, struct ar5416eeprom_4k *pEepData,
 	const struct ieee80211_channel *chan, int16_t *pTxPowerIndexOffset)

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 12:42:54 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EBAA81065672;
	Sat, 16 Apr 2011 12:42:54 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D8D9D8FC08;
	Sat, 16 Apr 2011 12:42:54 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GCgsDa005392;
	Sat, 16 Apr 2011 12:42:54 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GCgsum005389;
	Sat, 16 Apr 2011 12:42:54 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161242.p3GCgsum005389@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 12:42:54 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220715 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 12:42:55 -0000

Author: bschmidt
Date: Sat Apr 16 12:42:54 2011
New Revision: 220715
URL: http://svn.freebsd.org/changeset/base/220715

Log:
  Instead of hardcoding TX rates and using that to fill the retry table
  use the neogotiated ni_rates instead.

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnreg.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 12:41:22 2011	(r220714)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 12:42:54 2011	(r220715)
@@ -121,6 +121,7 @@ static void	iwn_read_eeprom_channels(str
 static void	iwn_read_eeprom_enhinfo(struct iwn_softc *);
 static struct ieee80211_node *iwn_node_alloc(struct ieee80211vap *,
 		    const uint8_t mac[IEEE80211_ADDR_LEN]);
+static void	iwn_newassoc(struct ieee80211_node *, int);
 static int	iwn_media_change(struct ifnet *);
 static int	iwn_newstate(struct ieee80211vap *, enum ieee80211_state, int);
 static void	iwn_calib_timeout(void *);
@@ -169,7 +170,8 @@ static int	iwn4965_add_node(struct iwn_s
 		    int);
 static int	iwn5000_add_node(struct iwn_softc *, struct iwn_node_info *,
 		    int);
-static int	iwn_set_link_quality(struct iwn_softc *, uint8_t, int);
+static int	iwn_set_link_quality(struct iwn_softc *,
+		    struct ieee80211_node *);
 static int	iwn_add_broadcast_node(struct iwn_softc *, int);
 static int	iwn_wme_update(struct ieee80211com *);
 static void	iwn_update_mcast(struct ifnet *);
@@ -648,6 +650,7 @@ iwn_attach(device_t dev)
 	ic->ic_vap_delete = iwn_vap_delete;
 	ic->ic_raw_xmit = iwn_raw_xmit;
 	ic->ic_node_alloc = iwn_node_alloc;
+	ic->ic_newassoc = iwn_newassoc;
 	ic->ic_wme.wme_update = iwn_wme_update;
 	ic->ic_update_mcast = iwn_update_mcast;
 	ic->ic_scan_start = iwn_scan_start;
@@ -1908,6 +1911,18 @@ iwn_node_alloc(struct ieee80211vap *vap,
 	return malloc(sizeof (struct iwn_node), M_80211_NODE,M_NOWAIT | M_ZERO);
 }
 
+static void
+iwn_newassoc(struct ieee80211_node *ni, int isnew)
+{
+	struct iwn_node *wn = (void *)ni;
+	int ridx, i;
+
+	for (i = 0; i < ni->ni_rates.rs_nrates; i++) {
+		ridx = iwn_plcp_signal(ni->ni_rates.rs_rates[i]);
+		wn->ridx[i] = ridx;
+	}
+}
+
 static int
 iwn_media_change(struct ifnet *ifp)
 {
@@ -2891,7 +2906,7 @@ iwn_plcp_signal(int rate) {
 	int i;
 
 	for (i = 0; i < IWN_RIDX_MAX + 1; i++) {
-		if (rate == iwn_rates[i].rate)
+		if ((rate & IEEE80211_RATE_VAL) == iwn_rates[i].rate)
 			return i;
 	}
 
@@ -3055,7 +3070,7 @@ iwn_tx_data(struct iwn_softc *sc, struct
 		txant = IWN_LSB(sc->txchainmask);
 		tx->rflags |= IWN_RFLAG_ANT(txant);
 	} else {
-		tx->linkq = IWN_RIDX_OFDM54 - ridx;
+		tx->linkq = ni->ni_rates.rs_nrates - ridx - 1;
 		flags |= IWN_TX_LINKQ;	/* enable MRR */
 	}
 
@@ -3599,98 +3614,39 @@ iwn5000_add_node(struct iwn_softc *sc, s
 	return iwn_cmd(sc, IWN_CMD_ADD_NODE, node, sizeof (*node), async);
 }
 
-#if 0	/* HT */
-static const uint8_t iwn_ridx_to_plcp[] = {
-	10, 20, 55, 110, /* CCK */
-	0xd, 0xf, 0x5, 0x7, 0x9, 0xb, 0x1, 0x3, 0x3 /* OFDM R1-R4 */
-};
-static const uint8_t iwn_siso_mcs_to_plcp[] = {
-	0, 0, 0, 0, 			/* CCK */
-	0, 0, 1, 2, 3, 4, 5, 6, 7	/* HT */
-};
-static const uint8_t iwn_mimo_mcs_to_plcp[] = {
-	0, 0, 0, 0, 			/* CCK */
-	8, 8, 9, 10, 11, 12, 13, 14, 15	/* HT */
-};
-#endif
-static const uint8_t iwn_prev_ridx[] = {
-	/* NB: allow fallback from CCK11 to OFDM9 and from OFDM6 to CCK5 */
-	0, 0, 1, 5,			/* CCK */
-	2, 4, 3, 6, 7, 8, 9, 10, 10	/* OFDM */
-};
-
-/*
- * Configure hardware link parameters for the specified
- * node operating on the specified channel.
- */
 static int
-iwn_set_link_quality(struct iwn_softc *sc, uint8_t id, int async)
+iwn_set_link_quality(struct iwn_softc *sc, struct ieee80211_node *ni)
 {
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
+	struct iwn_node *wn = (void *)ni;
+	struct ieee80211_rateset *rs = &ni->ni_rates;
 	struct iwn_cmd_link_quality linkq;
 	const struct iwn_rate *rinfo;
-	int i;
-	uint8_t txant, ridx;
+	uint8_t txant;
+	int i, txrate;
 
 	/* Use the first valid TX antenna. */
 	txant = IWN_LSB(sc->txchainmask);
 
 	memset(&linkq, 0, sizeof linkq);
-	linkq.id = id;
+	linkq.id = wn->id;
 	linkq.antmsk_1stream = txant;
 	linkq.antmsk_2stream = IWN_ANT_AB;
 	linkq.ampdu_max = 31;
 	linkq.ampdu_threshold = 3;
 	linkq.ampdu_limit = htole16(4000);	/* 4ms */
 
-#if 0	/* HT */
-	if (IEEE80211_IS_CHAN_HT(c))
-		linkq.mimo = 1;
-#endif
-
-	if (id == IWN_ID_BSS)
-		ridx = IWN_RIDX_OFDM54;
-	else if (IEEE80211_IS_CHAN_A(ic->ic_curchan))
-		ridx = IWN_RIDX_OFDM6;
-	else
-		ridx = IWN_RIDX_CCK1;
-
+	/* Start at highest available bit-rate. */
+	txrate = rs->rs_nrates - 1;
 	for (i = 0; i < IWN_MAX_TX_RETRIES; i++) {
-		rinfo = &iwn_rates[ridx];
-#if 0	/* HT */
-		if (IEEE80211_IS_CHAN_HT40(c)) {
-			linkq.retry[i].plcp = iwn_mimo_mcs_to_plcp[ridx]
-					 | IWN_RIDX_MCS;
-			linkq.retry[i].rflags = IWN_RFLAG_HT
-					 | IWN_RFLAG_HT40;
-			/* XXX shortGI */
-		} else if (IEEE80211_IS_CHAN_HT(c)) {
-			linkq.retry[i].plcp = iwn_siso_mcs_to_plcp[ridx]
-					 | IWN_RIDX_MCS;
-			linkq.retry[i].rflags = IWN_RFLAG_HT;
-			/* XXX shortGI */
-		} else
-#endif
-		{
-			linkq.retry[i].plcp = rinfo->plcp;
-			linkq.retry[i].rflags = rinfo->flags;
-		}
+		rinfo = &iwn_rates[wn->ridx[txrate]];
+		linkq.retry[i].plcp = rinfo->plcp;
+		linkq.retry[i].rflags = rinfo->flags;
 		linkq.retry[i].rflags |= IWN_RFLAG_ANT(txant);
-		ridx = iwn_prev_ridx[ridx];
+		/* Next retry at immediate lower bit-rate. */
+		if (txrate > 0)
+			txrate--;
 	}
-#ifdef IWN_DEBUG
-	if (sc->sc_debug & IWN_DEBUG_STATE) {
-		printf("%s: set link quality for node %d, mimo %d ssmask %d\n",
-		    __func__, id, linkq.mimo, linkq.antmsk_1stream);
-		printf("%s:", __func__);
-		for (i = 0; i < IWN_MAX_TX_RETRIES; i++)
-			printf(" %d:%x", linkq.retry[i].plcp,
-			    linkq.retry[i].rflags);
-		printf("\n");
-	}
-#endif
-	return iwn_cmd(sc, IWN_CMD_LINK_QUALITY, &linkq, sizeof linkq, async);
+	return iwn_cmd(sc, IWN_CMD_LINK_QUALITY, &linkq, sizeof linkq, 1);
 }
 
 /*
@@ -3701,8 +3657,12 @@ iwn_add_broadcast_node(struct iwn_softc 
 {
 	const struct iwn_hal *hal = sc->sc_hal;
 	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
 	struct iwn_node_info node;
-	int error;
+	struct iwn_cmd_link_quality linkq;
+	const struct iwn_rate *rinfo;
+	uint8_t txant;
+	int i, error;
 
 	memset(&node, 0, sizeof node);
 	IEEE80211_ADDR_COPY(node.macaddr, ifp->if_broadcastaddr);
@@ -3712,8 +3672,31 @@ iwn_add_broadcast_node(struct iwn_softc 
 	if (error != 0)
 		return error;
 
-	error = iwn_set_link_quality(sc, hal->broadcast_id, async);
-	return error;
+	/* Use the first valid TX antenna. */
+	txant = IWN_LSB(sc->txchainmask);
+
+	memset(&linkq, 0, sizeof linkq);
+	linkq.id = sc->sc_hal->broadcast_id;
+	linkq.antmsk_1stream = txant;
+	linkq.antmsk_2stream = IWN_ANT_AB;
+	linkq.ampdu_max = 64;
+	linkq.ampdu_threshold = 3;
+	linkq.ampdu_limit = htole16(4000);	/* 4ms */
+
+	/* Use lowest mandatory bit-rate. */
+	if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan))
+		rinfo = &iwn_rates[IWN_RIDX_OFDM6];
+	else
+		rinfo = &iwn_rates[IWN_RIDX_CCK1];
+	linkq.retry[0].plcp = rinfo->plcp;
+	linkq.retry[0].rflags = rinfo->flags;
+	linkq.retry[0].rflags |= IWN_RFLAG_ANT(txant);
+	/* Use same bit-rate for all TX retries. */
+	for (i = 1; i < IWN_MAX_TX_RETRIES; i++) {
+		linkq.retry[i].plcp = linkq.retry[0].plcp;
+		linkq.retry[i].rflags = linkq.retry[0].rflags;
+	}
+	return iwn_cmd(sc, IWN_CMD_LINK_QUALITY, &linkq, sizeof linkq, async);
 }
 
 static int
@@ -5010,6 +4993,10 @@ iwn_run(struct iwn_softc *sc, struct iee
 		return error;
 	}
 
+	/* Fake a join to initialize the TX rate. */
+	((struct iwn_node *)ni)->id = IWN_ID_BSS;
+	iwn_newassoc(ni, 1);
+
 	/* Add BSS node. */
 	memset(&node, 0, sizeof node);
 	IEEE80211_ADDR_COPY(node.macaddr, ni->ni_macaddr);
@@ -5027,7 +5014,7 @@ iwn_run(struct iwn_softc *sc, struct iee
 	}
 	DPRINTF(sc, IWN_DEBUG_STATE, "setting link quality for node %d\n",
 	    node.id);
-	error = iwn_set_link_quality(sc, node.id, 1);
+	error = iwn_set_link_quality(sc, ni);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not setup MRR for node %d, error %d\n",

Modified: head/sys/dev/iwn/if_iwnreg.h
==============================================================================
--- head/sys/dev/iwn/if_iwnreg.h	Sat Apr 16 12:41:22 2011	(r220714)
+++ head/sys/dev/iwn/if_iwnreg.h	Sat Apr 16 12:42:54 2011	(r220715)
@@ -1433,10 +1433,8 @@ static const struct iwn_chan_band {
 #define IWN6050_OTP_NBLOCKS	7
 
 /* HW rate indices. */
-#define IWN_RIDX_CCK1	 0
-#define IWN_RIDX_CCK11	 3
-#define IWN_RIDX_OFDM6	 4
-#define IWN_RIDX_OFDM54	11
+#define IWN_RIDX_CCK1	0
+#define IWN_RIDX_OFDM6	4
 
 static const struct iwn_rate {
 	uint8_t	rate;

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 12:46:47 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4577A106566C;
	Sat, 16 Apr 2011 12:46:47 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 33CC48FC1A;
	Sat, 16 Apr 2011 12:46:47 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GCkljk005604;
	Sat, 16 Apr 2011 12:46:47 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GCklOd005602;
	Sat, 16 Apr 2011 12:46:47 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104161246.p3GCklOd005602@svn.freebsd.org>
From: Adrian Chadd 
Date: Sat, 16 Apr 2011 12:46:47 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220718 - head/sys/dev/ath/ath_hal/ar5416
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 12:46:47 -0000

Author: adrian
Date: Sat Apr 16 12:46:46 2011
New Revision: 220718
URL: http://svn.freebsd.org/changeset/base/220718

Log:
  Disable classic-style fast diversity on the AR5416 and later.
  
  Antenna diversity on the >= AR5416 is implemented differently than the
  AR5212 and previous chips. So for now, and not to confuse things, just
  disable it for now.

Modified:
  head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c

Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c	Sat Apr 16 12:45:09 2011	(r220717)
+++ head/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c	Sat Apr 16 12:46:46 2011	(r220718)
@@ -290,6 +290,8 @@ ar5416GetCapability(struct ath_hal *ah, 
 		    (ah->ah_macVersion == AR_XSREV_VERSION_OWL_PCIE) ||
 		    AR_SREV_SOWL(ah)) ?
 			HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_DIVERSITY:		/* disable classic fast diversity */
+		return HAL_ENXIO;
 	default:
 		break;
 	}

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 13:12:12 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DF73C1065673;
	Sat, 16 Apr 2011 13:12:12 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CD7608FC0A;
	Sat, 16 Apr 2011 13:12:12 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GDCCT9006149;
	Sat, 16 Apr 2011 13:12:12 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GDCCEB006147;
	Sat, 16 Apr 2011 13:12:12 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161312.p3GDCCEB006147@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 13:12:12 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220719 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 13:12:13 -0000

Author: bschmidt
Date: Sat Apr 16 13:12:12 2011
New Revision: 220719
URL: http://svn.freebsd.org/changeset/base/220719

Log:
  Remove if_ierrors which do not necessarily indicate a RX error, also
  do account send packets. While here use the IWN_TX_FAIL constant.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 12:46:46 2011	(r220718)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 13:12:12 2011	(r220719)
@@ -2069,7 +2069,6 @@ iwn_rx_done(struct iwn_softc *sc, struct
 		if (!sc->last_rx_valid) {
 			DPRINTF(sc, IWN_DEBUG_ANY,
 			    "%s: missing RX_PHY\n", __func__);
-			ifp->if_ierrors++;
 			return;
 		}
 		sc->last_rx_valid = 0;
@@ -2083,7 +2082,6 @@ iwn_rx_done(struct iwn_softc *sc, struct
 		device_printf(sc->sc_dev,
 		    "%s: invalid rx statistic header, len %d\n",
 		    __func__, stat->cfg_phy_len);
-		ifp->if_ierrors++;
 		return;
 	}
 	if (desc->type == IWN_MPDU_RX_DONE) {
@@ -2427,11 +2425,12 @@ iwn_tx_done(struct iwn_softc *sc, struct
 	/*
 	 * Update rate control statistics for the node.
 	 */
-	if (status & 0x80) {
+	if (status & IWN_TX_FAIL) {
 		ifp->if_oerrors++;
 		ieee80211_ratectl_tx_complete(vap, ni,
 		    IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL);
 	} else {
+		ifp->if_opackets++;
 		ieee80211_ratectl_tx_complete(vap, ni,
 		    IEEE80211_RATECTL_TX_SUCCESS, &ackfailcnt, NULL);
 	}

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 13:25:20 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 43E381065673;
	Sat, 16 Apr 2011 13:25:20 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 318C48FC17;
	Sat, 16 Apr 2011 13:25:20 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GDPK0r006463;
	Sat, 16 Apr 2011 13:25:20 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GDPKpu006461;
	Sat, 16 Apr 2011 13:25:20 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161325.p3GDPKpu006461@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 13:25:20 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220720 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 13:25:20 -0000

Author: bschmidt
Date: Sat Apr 16 13:25:19 2011
New Revision: 220720
URL: http://svn.freebsd.org/changeset/base/220720

Log:
  Fix WME/QoS handling:
  - move the TX queue selection into iwn_tx_data/iwn_tx_data_raw
  - extract traffic identifier and use it
  - do not expect ACKs for frames marked as such

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 13:12:12 2011	(r220719)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 13:25:19 2011	(r220720)
@@ -158,7 +158,10 @@ static void	iwn5000_reset_sched(struct i
 #endif
 static uint8_t	iwn_plcp_signal(int);
 static int	iwn_tx_data(struct iwn_softc *, struct mbuf *,
-		    struct ieee80211_node *, struct iwn_tx_ring *);
+		    struct ieee80211_node *);
+static int	iwn_tx_data_raw(struct iwn_softc *, struct mbuf *,
+		    struct ieee80211_node *,
+		    const struct ieee80211_bpf_params *params);
 static int	iwn_raw_xmit(struct ieee80211_node *, struct mbuf *,
 		    const struct ieee80211_bpf_params *);
 static void	iwn_start(struct ifnet *);
@@ -2913,8 +2916,7 @@ iwn_plcp_signal(int rate) {
 }
 
 static int
-iwn_tx_data(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni,
-    struct iwn_tx_ring *ring)
+iwn_tx_data(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
 {
 	const struct iwn_hal *hal = sc->sc_hal;
 	const struct ieee80211_txparam *tp;
@@ -2922,6 +2924,7 @@ iwn_tx_data(struct iwn_softc *sc, struct
 	struct ieee80211vap *vap = ni->ni_vap;
 	struct ieee80211com *ic = ni->ni_ic;
 	struct iwn_node *wn = (void *)ni;
+	struct iwn_tx_ring *ring;
 	struct iwn_tx_desc *desc;
 	struct iwn_tx_data *data;
 	struct iwn_tx_cmd *cmd;
@@ -2931,9 +2934,10 @@ iwn_tx_data(struct iwn_softc *sc, struct
 	struct mbuf *m1;
 	bus_dma_segment_t *seg, segs[IWN_MAX_SCATTER];
 	uint32_t flags;
+	uint16_t qos;
 	u_int hdrlen;
-	int totlen, error, pad, nsegs = 0, i, rate;
-	uint8_t ridx, type, txant;
+	uint8_t tid, ridx, type, txant;
+	int ac, i, totlen, error, pad, nsegs = 0, rate;
 
 	IWN_LOCK_ASSERT(sc);
 
@@ -2941,6 +2945,17 @@ iwn_tx_data(struct iwn_softc *sc, struct
 	hdrlen = ieee80211_anyhdrsize(wh);
 	type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
 
+	/* Select EDCA Access Category and TX ring for this frame. */
+	if (IEEE80211_QOS_HAS_SEQ(wh)) {
+		qos = ((const struct ieee80211_qosframe *)wh)->i_qos[0];
+		tid = qos & IEEE80211_QOS_TID;
+	} else {
+		qos = 0;
+		tid = 0;
+	}
+	ac = M_WME_GETAC(m);
+
+	ring = &sc->txq[ac];
 	desc = &ring->desc[ring->cur];
 	data = &ring->data[ring->cur];
 
@@ -2995,8 +3010,12 @@ iwn_tx_data(struct iwn_softc *sc, struct
 	tx->scratch = 0;	/* clear "scratch" area */
 
 	flags = 0;
-	if (!IEEE80211_IS_MULTICAST(wh->i_addr1))
-		flags |= IWN_TX_NEED_ACK;
+	if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
+		/* Unicast frame, check if an ACK is expected. */
+		if (!qos || (qos & IEEE80211_QOS_ACKPOLICY) !=
+		    IEEE80211_QOS_ACKPOLICY_NOACK)
+			flags |= IWN_TX_NEED_ACK;
+	}
 	if ((wh->i_fc[0] &
 	    (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) ==
 	    (IEEE80211_FC0_TYPE_CTL | IEEE80211_FC0_SUBTYPE_BAR))
@@ -3056,7 +3075,7 @@ iwn_tx_data(struct iwn_softc *sc, struct
 		pad = 0;
 
 	tx->len = htole16(totlen);
-	tx->tid = 0;
+	tx->tid = tid;
 	tx->rts_ntries = 60;
 	tx->data_ntries = 15;
 	tx->lifetime = htole32(IWN_LIFETIME_INFINITE);
@@ -3161,8 +3180,7 @@ iwn_tx_data(struct iwn_softc *sc, struct
 
 static int
 iwn_tx_data_raw(struct iwn_softc *sc, struct mbuf *m,
-    struct ieee80211_node *ni, struct iwn_tx_ring *ring,
-    const struct ieee80211_bpf_params *params)
+    struct ieee80211_node *ni, const struct ieee80211_bpf_params *params)
 {
 	const struct iwn_hal *hal = sc->sc_hal;
 	const struct iwn_rate *rinfo;
@@ -3172,13 +3190,14 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 	struct iwn_tx_cmd *cmd;
 	struct iwn_cmd_data *tx;
 	struct ieee80211_frame *wh;
+	struct iwn_tx_ring *ring;
 	struct iwn_tx_desc *desc;
 	struct iwn_tx_data *data;
 	struct mbuf *m1;
 	bus_dma_segment_t *seg, segs[IWN_MAX_SCATTER];
 	uint32_t flags;
 	u_int hdrlen;
-	int totlen, error, pad, nsegs = 0, i, rate;
+	int ac, totlen, error, pad, nsegs = 0, i, rate;
 	uint8_t ridx, type, txant;
 
 	IWN_LOCK_ASSERT(sc);
@@ -3187,6 +3206,9 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 	hdrlen = ieee80211_anyhdrsize(wh);
 	type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
 
+	ac = params->ibp_pri & 3;
+
+	ring = &sc->txq[ac];
 	desc = &ring->desc[ring->cur];
 	data = &ring->data[ring->cur];
 
@@ -3362,12 +3384,11 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 
 static int
 iwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
-	const struct ieee80211_bpf_params *params)
+    const struct ieee80211_bpf_params *params)
 {
 	struct ieee80211com *ic = ni->ni_ic;
 	struct ifnet *ifp = ic->ic_ifp;
 	struct iwn_softc *sc = ifp->if_softc;
-	struct iwn_tx_ring *txq;
 	int error = 0;
 
 	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
@@ -3377,23 +3398,18 @@ iwn_raw_xmit(struct ieee80211_node *ni, 
 	}
 
 	IWN_LOCK(sc);
-	if (params == NULL)
-		txq = &sc->txq[M_WME_GETAC(m)];
-	else
-		txq = &sc->txq[params->ibp_pri & 3];
-
 	if (params == NULL) {
 		/*
 		 * Legacy path; interpret frame contents to decide
 		 * precisely how to send the frame.
 		 */
-		error = iwn_tx_data(sc, m, ni, txq);
+		error = iwn_tx_data(sc, m, ni);
 	} else {
 		/*
 		 * Caller supplied explicit parameters to use in
 		 * sending the frame.
 		 */
-		error = iwn_tx_data_raw(sc, m, ni, txq, params);
+		error = iwn_tx_data_raw(sc, m, ni, params);
 	}
 	if (error != 0) {
 		/* NB: m is reclaimed on tx failure */
@@ -3421,12 +3437,14 @@ iwn_start_locked(struct ifnet *ifp)
 {
 	struct iwn_softc *sc = ifp->if_softc;
 	struct ieee80211_node *ni;
-	struct iwn_tx_ring *txq;
 	struct mbuf *m;
-	int pri;
 
 	IWN_LOCK_ASSERT(sc);
 
+	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
+	    (ifp->if_drv_flags & IFF_DRV_OACTIVE))
+		return;
+
 	for (;;) {
 		if (sc->qfullmsk != 0) {
 			ifp->if_drv_flags |= IFF_DRV_OACTIVE;
@@ -3436,12 +3454,10 @@ iwn_start_locked(struct ifnet *ifp)
 		if (m == NULL)
 			break;
 		ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
-		pri = M_WME_GETAC(m);
-		txq = &sc->txq[pri];
-		if (iwn_tx_data(sc, m, ni, txq) != 0) {
-			ifp->if_oerrors++;
+		if (iwn_tx_data(sc, m, ni) != 0) {
 			ieee80211_free_node(ni);
-			break;
+			ifp->if_oerrors++;
+			continue;
 		}
 		sc->sc_tx_timer = 5;
 	}

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 13:40:32 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5D329106564A;
	Sat, 16 Apr 2011 13:40:32 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 4A9998FC08;
	Sat, 16 Apr 2011 13:40:32 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GDeWsO006845;
	Sat, 16 Apr 2011 13:40:32 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GDeWMv006843;
	Sat, 16 Apr 2011 13:40:32 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161340.p3GDeWMv006843@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 13:40:32 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220721 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 13:40:32 -0000

Author: bschmidt
Date: Sat Apr 16 13:40:32 2011
New Revision: 220721
URL: http://svn.freebsd.org/changeset/base/220721

Log:
  Rename some stuff in favour of the OpenBSD names:
  - prefer EDCA over WME
  - qid for a TXQ ID
  - reg for register values

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 13:25:19 2011	(r220720)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 13:40:32 2011	(r220721)
@@ -176,7 +176,7 @@ static int	iwn5000_add_node(struct iwn_s
 static int	iwn_set_link_quality(struct iwn_softc *,
 		    struct ieee80211_node *);
 static int	iwn_add_broadcast_node(struct iwn_softc *, int);
-static int	iwn_wme_update(struct ieee80211com *);
+static int	iwn_updateedca(struct ieee80211com *);
 static void	iwn_update_mcast(struct ifnet *);
 static void	iwn_set_led(struct iwn_softc *, uint8_t, uint8_t, uint8_t);
 static int	iwn_set_critical_temp(struct iwn_softc *);
@@ -422,7 +422,7 @@ iwn_attach(device_t dev)
 	struct ieee80211com *ic;
 	struct ifnet *ifp;
 	const struct iwn_hal *hal;
-	uint32_t tmp;
+	uint32_t reg;
 	int i, error, result;
 	uint8_t macaddr[IEEE80211_ADDR_LEN];
 
@@ -442,12 +442,12 @@ iwn_attach(device_t dev)
 	pci_write_config(dev, 0x41, 0, 1);
 
 	/* Hardware bug workaround. */
-	tmp = pci_read_config(dev, PCIR_COMMAND, 1);
-	if (tmp & PCIM_CMD_INTxDIS) {
+	reg = pci_read_config(dev, PCIR_COMMAND, 1);
+	if (reg & PCIM_CMD_INTxDIS) {
 		DPRINTF(sc, IWN_DEBUG_RESET, "%s: PCIe INTx Disable set\n",
 		    __func__);
-		tmp &= ~PCIM_CMD_INTxDIS;
-		pci_write_config(dev, PCIR_COMMAND, tmp, 1);
+		reg &= ~PCIM_CMD_INTxDIS;
+		pci_write_config(dev, PCIR_COMMAND, reg, 1);
 	}
 
 	/* Enable bus-mastering. */
@@ -654,7 +654,7 @@ iwn_attach(device_t dev)
 	ic->ic_raw_xmit = iwn_raw_xmit;
 	ic->ic_node_alloc = iwn_node_alloc;
 	ic->ic_newassoc = iwn_newassoc;
-	ic->ic_wme.wme_update = iwn_wme_update;
+	ic->ic_wme.wme_update = iwn_updateedca;
 	ic->ic_update_mcast = iwn_update_mcast;
 	ic->ic_scan_start = iwn_scan_start;
 	ic->ic_scan_end = iwn_scan_end;
@@ -836,7 +836,7 @@ iwn_detach(device_t dev)
 	struct iwn_softc *sc = device_get_softc(dev);
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic;
-	int i;
+	int qid;
 
 	if (ifp != NULL) {
 		ic = ifp->if_l2com;
@@ -854,8 +854,8 @@ iwn_detach(device_t dev)
 	/* Free DMA resources. */
 	iwn_free_rx_ring(sc, &sc->rxq);
 	if (sc->sc_hal != NULL)
-		for (i = 0; i < sc->sc_hal->ntxqs; i++)
-			iwn_free_tx_ring(sc, &sc->txq[i]);
+		for (qid = 0; qid < sc->sc_hal->ntxqs; qid++)
+			iwn_free_tx_ring(sc, &sc->txq[qid]);
 	iwn_free_sched(sc);
 	iwn_free_kw(sc);
 	if (sc->ict != NULL)
@@ -3715,23 +3715,23 @@ iwn_add_broadcast_node(struct iwn_softc 
 }
 
 static int
-iwn_wme_update(struct ieee80211com *ic)
+iwn_updateedca(struct ieee80211com *ic)
 {
 #define IWN_EXP2(x)	((1 << (x)) - 1)	/* CWmin = 2^ECWmin - 1 */
 	struct iwn_softc *sc = ic->ic_ifp->if_softc;
 	struct iwn_edca_params cmd;
-	int i;
+	int aci;
 
 	memset(&cmd, 0, sizeof cmd);
 	cmd.flags = htole32(IWN_EDCA_UPDATE);
-	for (i = 0; i < WME_NUM_AC; i++) {
-		const struct wmeParams *wmep =
-		    &ic->ic_wme.wme_chanParams.cap_wmeParams[i];
-		cmd.ac[i].aifsn = wmep->wmep_aifsn;
-		cmd.ac[i].cwmin = htole16(IWN_EXP2(wmep->wmep_logcwmin));
-		cmd.ac[i].cwmax = htole16(IWN_EXP2(wmep->wmep_logcwmax));
-		cmd.ac[i].txoplimit =
-		    htole16(IEEE80211_TXOP_TO_US(wmep->wmep_txopLimit));
+	for (aci = 0; aci < WME_NUM_AC; aci++) {
+		const struct wmeParams *ac =
+		    &ic->ic_wme.wme_chanParams.cap_wmeParams[aci];
+		cmd.ac[aci].aifsn = ac->wmep_aifsn;
+		cmd.ac[aci].cwmin = htole16(IWN_EXP2(ac->wmep_logcwmin));
+		cmd.ac[aci].cwmax = htole16(IWN_EXP2(ac->wmep_logcwmax));
+		cmd.ac[aci].txoplimit =
+		    htole16(IEEE80211_TXOP_TO_US(ac->wmep_txopLimit));
 	}
 	IEEE80211_UNLOCK(ic);
 	IWN_LOCK(sc);
@@ -4500,7 +4500,7 @@ iwn_set_pslevel(struct iwn_softc *sc, in
 	const struct iwn_pmgt *pmgt;
 	struct iwn_pmgt_cmd cmd;
 	uint32_t max, skip_dtim;
-	uint32_t tmp;
+	uint32_t reg;
 	int i;
 
 	/* Select which PS parameters to use. */
@@ -4517,8 +4517,8 @@ iwn_set_pslevel(struct iwn_softc *sc, in
 	if (level == 5)
 		cmd.flags |= htole16(IWN_PS_FAST_PD);
 	/* Retrieve PCIe Active State Power Management (ASPM). */
-	tmp = pci_read_config(sc->sc_dev, sc->sc_cap_off + 0x10, 1);
-	if (!(tmp & 0x1))	/* L0s Entry disabled. */
+	reg = pci_read_config(sc->sc_dev, sc->sc_cap_off + 0x10, 1);
+	if (!(reg & 0x1))	/* L0s Entry disabled. */
 		cmd.flags |= htole16(IWN_PS_PCI_PMGT);
 	cmd.rxtimeout = htole32(pmgt->rxtimeout * 1024);
 	cmd.txtimeout = htole32(pmgt->txtimeout * 1024);
@@ -5952,7 +5952,7 @@ iwn_clock_wait(struct iwn_softc *sc)
 static int
 iwn_apm_init(struct iwn_softc *sc)
 {
-	uint32_t tmp;
+	uint32_t reg;
 	int error;
 
 	/* Disable L0s exit timer (NMI bug workaround.) */
@@ -5967,9 +5967,9 @@ iwn_apm_init(struct iwn_softc *sc)
 	IWN_SETBITS(sc, IWN_HW_IF_CONFIG, IWN_HW_IF_CONFIG_HAP_WAKE_L1A);
 
 	/* Retrieve PCIe Active State Power Management (ASPM). */
-	tmp = pci_read_config(sc->sc_dev, sc->sc_cap_off + 0x10, 1);
+	reg = pci_read_config(sc->sc_dev, sc->sc_cap_off + 0x10, 1);
 	/* Workaround for HW instability in PCIe L0->L0s->L1 transition. */
-	if (tmp & 0x02)	/* L1 Entry enabled. */
+	if (reg & 0x02)	/* L1 Entry enabled. */
 		IWN_SETBITS(sc, IWN_GIO, IWN_GIO_L0S_ENA);
 	else
 		IWN_CLRBITS(sc, IWN_GIO, IWN_GIO_L0S_ENA);

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 13:47:18 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 64600106566C;
	Sat, 16 Apr 2011 13:47:18 +0000 (UTC)
	(envelope-from adrian@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1A5F28FC0A;
	Sat, 16 Apr 2011 13:47:18 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GDlIHB007057;
	Sat, 16 Apr 2011 13:47:18 GMT (envelope-from adrian@svn.freebsd.org)
Received: (from adrian@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GDlIxh007055;
	Sat, 16 Apr 2011 13:47:18 GMT (envelope-from adrian@svn.freebsd.org)
Message-Id: <201104161347.p3GDlIxh007055@svn.freebsd.org>
From: Adrian Chadd 
Date: Sat, 16 Apr 2011 13:47:17 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220722 - head/sys/dev/ath/ath_hal/ar9002
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 13:47:19 -0000

Author: adrian
Date: Sat Apr 16 13:47:17 2011
New Revision: 220722
URL: http://svn.freebsd.org/changeset/base/220722

Log:
  Don't do Kite antenna switch selection this way (for now); antenna
  diversity is done elsewhere now.

Modified:
  head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c

Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c	Sat Apr 16 13:40:32 2011	(r220721)
+++ head/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c	Sat Apr 16 13:47:17 2011	(r220722)
@@ -399,36 +399,13 @@ ar9285FillCapabilityInfo(struct ath_hal 
 	return AH_TRUE;
 }
 
+/*
+ * Antenna selection is not (currently) done this way.
+ */
 HAL_BOOL
 ar9285SetAntennaSwitch(struct ath_hal *ah, HAL_ANT_SETTING settings)
 {
-#define ANTENNA0_CHAINMASK    0x1
-#define ANTENNA1_CHAINMASK    0x2
-	struct ath_hal_5416 *ahp = AH5416(ah);
-
-	/* Antenna selection is done by setting the tx/rx chainmasks approp. */
-	switch (settings) {
-	case HAL_ANT_FIXED_A:
-		/* Enable first antenna only */
-		ahp->ah_tx_chainmask = ANTENNA0_CHAINMASK;
-		ahp->ah_rx_chainmask = ANTENNA0_CHAINMASK;
-		break;
-	case HAL_ANT_FIXED_B:
-		/* Enable second antenna only, after checking capability */
-		if (AH_PRIVATE(ah)->ah_caps.halTxChainMask > ANTENNA1_CHAINMASK)
-			ahp->ah_tx_chainmask = ANTENNA1_CHAINMASK;
-		ahp->ah_rx_chainmask = ANTENNA1_CHAINMASK;
-		break;
-	case HAL_ANT_VARIABLE:
-		/* Restore original chainmask settings */
-		/* XXX */
-		ahp->ah_tx_chainmask = AR9285_DEFAULT_TXCHAINMASK;
-		ahp->ah_rx_chainmask = AR9285_DEFAULT_RXCHAINMASK;
-		break;
-	}
 	return AH_TRUE;
-#undef ANTENNA0_CHAINMASK
-#undef ANTENNA1_CHAINMASK
 }
 
 static const char*

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 14:36:44 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2A495106566C;
	Sat, 16 Apr 2011 14:36:44 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 1700B8FC14;
	Sat, 16 Apr 2011 14:36:44 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GEaiYX008142;
	Sat, 16 Apr 2011 14:36:44 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GEai1S008139;
	Sat, 16 Apr 2011 14:36:44 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161436.p3GEai1S008139@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 14:36:44 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220723 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 14:36:44 -0000

Author: bschmidt
Date: Sat Apr 16 14:36:43 2011
New Revision: 220723
URL: http://svn.freebsd.org/changeset/base/220723

Log:
  Shuffle code around a bit. Mostly to group functional connected things,
  others to get the same order as the OpenBSD code.

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnvar.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 13:47:17 2011	(r220722)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:36:43 2011	(r220723)
@@ -72,16 +72,61 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+struct iwn_ident {
+	uint16_t	vendor;
+	uint16_t	device;
+	const char	*name;
+};
+
+static const struct iwn_ident iwn_ident_table [] = {
+	{ 0x8086, 0x4229, "Intel(R) PRO/Wireless 4965BGN" },
+	{ 0x8086, 0x422D, "Intel(R) PRO/Wireless 4965BGN" },
+	{ 0x8086, 0x4230, "Intel(R) PRO/Wireless 4965BGN" },
+	{ 0x8086, 0x4233, "Intel(R) PRO/Wireless 4965BGN" },
+	{ 0x8086, 0x4232, "Intel(R) PRO/Wireless 5100" },
+	{ 0x8086, 0x4237, "Intel(R) PRO/Wireless 5100" },
+	{ 0x8086, 0x423C, "Intel(R) PRO/Wireless 5150" },
+	{ 0x8086, 0x423D, "Intel(R) PRO/Wireless 5150" },
+	{ 0x8086, 0x4235, "Intel(R) PRO/Wireless 5300" },
+	{ 0x8086, 0x4236, "Intel(R) PRO/Wireless 5300" },
+	{ 0x8086, 0x423A, "Intel(R) PRO/Wireless 5350" },
+	{ 0x8086, 0x423B, "Intel(R) PRO/Wireless 5350" },
+	{ 0x8086, 0x0083, "Intel(R) PRO/Wireless 1000" },
+	{ 0x8086, 0x0084, "Intel(R) PRO/Wireless 1000" },
+	{ 0x8086, 0x008D, "Intel(R) PRO/Wireless 6000" },
+	{ 0x8086, 0x008E, "Intel(R) PRO/Wireless 6000" },
+	{ 0x8086, 0x4238, "Intel(R) PRO/Wireless 6000" },
+	{ 0x8086, 0x4239, "Intel(R) PRO/Wireless 6000" },
+	{ 0x8086, 0x422B, "Intel(R) PRO/Wireless 6000" },
+	{ 0x8086, 0x422C, "Intel(R) PRO/Wireless 6000" },
+	{ 0x8086, 0x0087, "Intel(R) PRO/Wireless 6250" },
+	{ 0x8086, 0x0089, "Intel(R) PRO/Wireless 6250" },
+	{ 0x8086, 0x0082, "Intel(R) PRO/Wireless 6205a" },
+	{ 0x8086, 0x0085, "Intel(R) PRO/Wireless 6205a" },
+#ifdef notyet
+	{ 0x8086, 0x008a, "Intel(R) PRO/Wireless 6205b" },
+	{ 0x8086, 0x008b, "Intel(R) PRO/Wireless 6205b" },
+	{ 0x8086, 0x008f, "Intel(R) PRO/Wireless 6205b" },
+	{ 0x8086, 0x0090, "Intel(R) PRO/Wireless 6205b" },
+	{ 0x8086, 0x0091, "Intel(R) PRO/Wireless 6205b" },
+#endif
+	{ 0, 0, NULL }
+};
+
 static int	iwn_probe(device_t);
 static int	iwn_attach(device_t);
 static const struct iwn_hal *iwn_hal_attach(struct iwn_softc *);
 static void	iwn_radiotap_attach(struct iwn_softc *);
+static void	iwn_sysctlattach(struct iwn_softc *);
 static struct ieee80211vap *iwn_vap_create(struct ieee80211com *,
 		    const char name[IFNAMSIZ], int unit, int opmode,
 		    int flags, const uint8_t bssid[IEEE80211_ADDR_LEN],
 		    const uint8_t mac[IEEE80211_ADDR_LEN]);
 static void	iwn_vap_delete(struct ieee80211vap *);
 static int	iwn_detach(device_t);
+static int	iwn_shutdown(device_t);
+static int	iwn_suspend(device_t);
+static int	iwn_resume(device_t);
 static int	iwn_nic_lock(struct iwn_softc *);
 static int	iwn_eeprom_lock(struct iwn_softc *);
 static int	iwn_init_otprom(struct iwn_softc *);
@@ -118,6 +163,11 @@ static void	iwn_read_eeprom_ht40(struct 
 #endif
 static void	iwn_read_eeprom_channels(struct iwn_softc *, int,
 		    uint32_t);
+static struct iwn_eeprom_chan *iwn_find_eeprom_channel(struct iwn_softc *,
+		    struct ieee80211_channel *);
+static int	iwn_setregdomain(struct ieee80211com *,
+		    struct ieee80211_regdomain *, int,
+		    struct ieee80211_channel []);
 static void	iwn_read_eeprom_enhinfo(struct iwn_softc *);
 static struct ieee80211_node *iwn_node_alloc(struct ieee80211vap *,
 		    const uint8_t mac[IEEE80211_ADDR_LEN]);
@@ -251,6 +301,8 @@ static int	iwn5000_nic_config(struct iwn
 static int	iwn_hw_prepare(struct iwn_softc *);
 static int	iwn_hw_init(struct iwn_softc *);
 static void	iwn_hw_stop(struct iwn_softc *);
+static void	iwn_radio_on(void *, int);
+static void	iwn_radio_off(void *, int);
 static void	iwn_init_locked(struct iwn_softc *);
 static void	iwn_init(void *);
 static void	iwn_stop_locked(struct iwn_softc *);
@@ -260,18 +312,7 @@ static void 	iwn_scan_end(struct ieee802
 static void 	iwn_set_channel(struct ieee80211com *);
 static void 	iwn_scan_curchan(struct ieee80211_scan_state *, unsigned long);
 static void 	iwn_scan_mindwell(struct ieee80211_scan_state *);
-static struct iwn_eeprom_chan *iwn_find_eeprom_channel(struct iwn_softc *,
-		    struct ieee80211_channel *);
-static int	iwn_setregdomain(struct ieee80211com *,
-		    struct ieee80211_regdomain *, int,
-		    struct ieee80211_channel []);
 static void	iwn_hw_reset(void *, int);
-static void	iwn_radio_on(void *, int);
-static void	iwn_radio_off(void *, int);
-static void	iwn_sysctlattach(struct iwn_softc *);
-static int	iwn_shutdown(device_t);
-static int	iwn_suspend(device_t);
-static int	iwn_resume(device_t);
 
 #define IWN_DEBUG
 #ifdef IWN_DEBUG
@@ -298,51 +339,74 @@ enum {
 		printf(fmt, __VA_ARGS__);		\
 } while (0)
 
-static const char *iwn_intr_str(uint8_t);
+static const char *
+iwn_intr_str(uint8_t cmd)
+{
+	switch (cmd) {
+	/* Notifications */
+	case IWN_UC_READY:		return "UC_READY";
+	case IWN_ADD_NODE_DONE:		return "ADD_NODE_DONE";
+	case IWN_TX_DONE:		return "TX_DONE";
+	case IWN_START_SCAN:		return "START_SCAN";
+	case IWN_STOP_SCAN:		return "STOP_SCAN";
+	case IWN_RX_STATISTICS:		return "RX_STATS";
+	case IWN_BEACON_STATISTICS:	return "BEACON_STATS";
+	case IWN_STATE_CHANGED:		return "STATE_CHANGED";
+	case IWN_BEACON_MISSED:		return "BEACON_MISSED";
+	case IWN_RX_PHY:		return "RX_PHY";
+	case IWN_MPDU_RX_DONE:		return "MPDU_RX_DONE";
+	case IWN_RX_DONE:		return "RX_DONE";
+
+	/* Command Notifications */
+	case IWN_CMD_RXON:		return "IWN_CMD_RXON";
+	case IWN_CMD_RXON_ASSOC:	return "IWN_CMD_RXON_ASSOC";
+	case IWN_CMD_EDCA_PARAMS:	return "IWN_CMD_EDCA_PARAMS";
+	case IWN_CMD_TIMING:		return "IWN_CMD_TIMING";
+	case IWN_CMD_LINK_QUALITY:	return "IWN_CMD_LINK_QUALITY";
+	case IWN_CMD_SET_LED:		return "IWN_CMD_SET_LED";
+	case IWN5000_CMD_WIMAX_COEX:	return "IWN5000_CMD_WIMAX_COEX";
+	case IWN5000_CMD_CALIB_CONFIG:	return "IWN5000_CMD_CALIB_CONFIG";
+	case IWN5000_CMD_CALIB_RESULT:	return "IWN5000_CMD_CALIB_RESULT";
+	case IWN5000_CMD_CALIB_COMPLETE: return "IWN5000_CMD_CALIB_COMPLETE";
+	case IWN_CMD_SET_POWER_MODE:	return "IWN_CMD_SET_POWER_MODE";
+	case IWN_CMD_SCAN:		return "IWN_CMD_SCAN";
+	case IWN_CMD_SCAN_RESULTS:	return "IWN_CMD_SCAN_RESULTS";
+	case IWN_CMD_TXPOWER:		return "IWN_CMD_TXPOWER";
+	case IWN_CMD_TXPOWER_DBM:	return "IWN_CMD_TXPOWER_DBM";
+	case IWN5000_CMD_TX_ANT_CONFIG:	return "IWN5000_CMD_TX_ANT_CONFIG";
+	case IWN_CMD_BT_COEX:		return "IWN_CMD_BT_COEX";
+	case IWN_CMD_SET_CRITICAL_TEMP:	return "IWN_CMD_SET_CRITICAL_TEMP";
+	case IWN_CMD_SET_SENSITIVITY:	return "IWN_CMD_SET_SENSITIVITY";
+	case IWN_CMD_PHY_CALIB:		return "IWN_CMD_PHY_CALIB";
+	}
+	return "UNKNOWN INTR NOTIF/CMD";
+}
 #else
 #define DPRINTF(sc, m, fmt, ...) do { (void) sc; } while (0)
 #endif
 
-struct iwn_ident {
-	uint16_t	vendor;
-	uint16_t	device;
-	const char	*name;
+static device_method_t iwn_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,		iwn_probe),
+	DEVMETHOD(device_attach,	iwn_attach),
+	DEVMETHOD(device_detach,	iwn_detach),
+	DEVMETHOD(device_shutdown,	iwn_shutdown),
+	DEVMETHOD(device_suspend,	iwn_suspend),
+	DEVMETHOD(device_resume,	iwn_resume),
+	{ 0, 0 }
 };
 
-static const struct iwn_ident iwn_ident_table [] = {
-	{ 0x8086, 0x4229, "Intel(R) PRO/Wireless 4965BGN" },
-	{ 0x8086, 0x422D, "Intel(R) PRO/Wireless 4965BGN" },
-	{ 0x8086, 0x4230, "Intel(R) PRO/Wireless 4965BGN" },
-	{ 0x8086, 0x4233, "Intel(R) PRO/Wireless 4965BGN" },
-	{ 0x8086, 0x4232, "Intel(R) PRO/Wireless 5100" },
-	{ 0x8086, 0x4237, "Intel(R) PRO/Wireless 5100" },
-	{ 0x8086, 0x423C, "Intel(R) PRO/Wireless 5150" },
-	{ 0x8086, 0x423D, "Intel(R) PRO/Wireless 5150" },
-	{ 0x8086, 0x4235, "Intel(R) PRO/Wireless 5300" },
-	{ 0x8086, 0x4236, "Intel(R) PRO/Wireless 5300" },
-	{ 0x8086, 0x423A, "Intel(R) PRO/Wireless 5350" },
-	{ 0x8086, 0x423B, "Intel(R) PRO/Wireless 5350" },
-	{ 0x8086, 0x0083, "Intel(R) PRO/Wireless 1000" },
-	{ 0x8086, 0x0084, "Intel(R) PRO/Wireless 1000" },
-	{ 0x8086, 0x008D, "Intel(R) PRO/Wireless 6000" },
-	{ 0x8086, 0x008E, "Intel(R) PRO/Wireless 6000" },
-	{ 0x8086, 0x4238, "Intel(R) PRO/Wireless 6000" },
-	{ 0x8086, 0x4239, "Intel(R) PRO/Wireless 6000" },
-	{ 0x8086, 0x422B, "Intel(R) PRO/Wireless 6000" },
-	{ 0x8086, 0x422C, "Intel(R) PRO/Wireless 6000" },
-	{ 0x8086, 0x0087, "Intel(R) PRO/Wireless 6250" },
-	{ 0x8086, 0x0089, "Intel(R) PRO/Wireless 6250" },
-	{ 0x8086, 0x0082, "Intel(R) PRO/Wireless 6205a" },
-	{ 0x8086, 0x0085, "Intel(R) PRO/Wireless 6205a" },
-#ifdef notyet
-	{ 0x8086, 0x008a, "Intel(R) PRO/Wireless 6205b" },
-	{ 0x8086, 0x008b, "Intel(R) PRO/Wireless 6205b" },
-	{ 0x8086, 0x008f, "Intel(R) PRO/Wireless 6205b" },
-	{ 0x8086, 0x0090, "Intel(R) PRO/Wireless 6205b" },
-	{ 0x8086, 0x0091, "Intel(R) PRO/Wireless 6205b" },
-#endif
-	{ 0, 0, NULL }
+static driver_t iwn_driver = {
+	"iwn",
+	iwn_methods,
+	sizeof (struct iwn_softc)
 };
+static devclass_t iwn_devclass;
+
+DRIVER_MODULE(iwn, pci, iwn_driver, iwn_devclass, 0, 0);
+MODULE_DEPEND(iwn, firmware, 1, 1, 1);
+MODULE_DEPEND(iwn, pci, 1, 1, 1);
+MODULE_DEPEND(iwn, wlan, 1, 1, 1);
 
 static const struct iwn_hal iwn4965_hal = {
 	iwn4965_load_firmware,
@@ -477,9 +541,6 @@ iwn_attach(device_t dev)
 	}
 
 	IWN_LOCK_INIT(sc);
-	TASK_INIT(&sc->sc_reinit_task, 0, iwn_hw_reset, sc );
-	TASK_INIT(&sc->sc_radioon_task, 0, iwn_radio_on, sc );
-	TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radio_off, sc );
 
 	/* Attach Hardware Abstraction Layer. */
 	hal = iwn_hal_attach(sc);
@@ -560,6 +621,9 @@ iwn_attach(device_t dev)
 	    ((sc->rxchainmask >> 2) & 1) +
 	    ((sc->rxchainmask >> 1) & 1) +
 	    ((sc->rxchainmask >> 0) & 1);
+	device_printf(sc->sc_dev, "MIMO %dT%dR, %.4s, address %6D\n",
+	    sc->ntxchains, sc->nrxchains, sc->eeprom_domain,
+	    macaddr, ":");
 
 	ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
 	if (ifp == NULL) {
@@ -625,10 +689,6 @@ iwn_attach(device_t dev)
 		goto fail;
 	}
 
-	device_printf(sc->sc_dev, "MIMO %dT%dR, %.4s, address %6D\n",
-	    sc->ntxchains, sc->nrxchains, sc->eeprom_domain,
-	    macaddr, ":");
-
 #if 0	/* HT */
 	/* Set supported HT rates. */
 	ic->ic_sup_mcs[0] = 0xff;
@@ -653,6 +713,12 @@ iwn_attach(device_t dev)
 	ic->ic_vap_delete = iwn_vap_delete;
 	ic->ic_raw_xmit = iwn_raw_xmit;
 	ic->ic_node_alloc = iwn_node_alloc;
+#if 0	/* HT */
+	ic->ic_ampdu_rx_start = iwn_ampdu_rx_start;
+	ic->ic_ampdu_rx_stop = iwn_ampdu_rx_stop;
+	ic->ic_ampdu_tx_start = iwn_ampdu_tx_start;
+	ic->ic_ampdu_tx_stop = iwn_ampdu_tx_stop;
+#endif
 	ic->ic_newassoc = iwn_newassoc;
 	ic->ic_wme.wme_update = iwn_updateedca;
 	ic->ic_update_mcast = iwn_update_mcast;
@@ -662,17 +728,14 @@ iwn_attach(device_t dev)
 	ic->ic_scan_curchan = iwn_scan_curchan;
 	ic->ic_scan_mindwell = iwn_scan_mindwell;
 	ic->ic_setregdomain = iwn_setregdomain;
-#if 0	/* HT */
-	ic->ic_ampdu_rx_start = iwn_ampdu_rx_start;
-	ic->ic_ampdu_rx_stop = iwn_ampdu_rx_stop;
-	ic->ic_ampdu_tx_start = iwn_ampdu_tx_start;
-	ic->ic_ampdu_tx_stop = iwn_ampdu_tx_stop;
-#endif
 
 	iwn_radiotap_attach(sc);
 
 	callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0);
 	callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0);
+	TASK_INIT(&sc->sc_reinit_task, 0, iwn_hw_reset, sc );
+	TASK_INIT(&sc->sc_radioon_task, 0, iwn_radio_on, sc );
+	TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radio_off, sc );
 
 	iwn_sysctlattach(sc);
 
@@ -791,6 +854,19 @@ iwn_radiotap_attach(struct iwn_softc *sc
 		IWN_RX_RADIOTAP_PRESENT);
 }
 
+static void
+iwn_sysctlattach(struct iwn_softc *sc)
+{
+	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
+	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
+
+#ifdef IWN_DEBUG
+	sc->sc_debug = 0;
+	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+	    "debug", CTLFLAG_RW, &sc->sc_debug, 0, "control debugging printfs");
+#endif
+}
+
 static struct ieee80211vap *
 iwn_vap_create(struct ieee80211com *ic,
 	const char name[IFNAMSIZ], int unit, int opmode, int flags,
@@ -851,6 +927,13 @@ iwn_detach(device_t dev)
 		ieee80211_ifdetach(ic);
 	}
 
+	if (sc->irq != NULL) {
+		bus_teardown_intr(dev, sc->irq, sc->sc_ih);
+		bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq);
+		if (sc->irq_rid == 1)
+			pci_release_msi(dev);
+	}
+
 	/* Free DMA resources. */
 	iwn_free_rx_ring(sc, &sc->rxq);
 	if (sc->sc_hal != NULL)
@@ -862,13 +945,6 @@ iwn_detach(device_t dev)
 		iwn_free_ict(sc);
 	iwn_free_fwmem(sc);
 
-	if (sc->irq != NULL) {
-		bus_teardown_intr(dev, sc->irq, sc->sc_ih);
-		bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq);
-		if (sc->irq_rid == 1)
-			pci_release_msi(dev);
-	}
-
 	if (sc->mem != NULL)
 		bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem);
 
@@ -880,6 +956,50 @@ iwn_detach(device_t dev)
 }
 
 static int
+iwn_shutdown(device_t dev)
+{
+	struct iwn_softc *sc = device_get_softc(dev);
+
+	iwn_stop(sc);
+	return 0;
+}
+
+static int
+iwn_suspend(device_t dev)
+{
+	struct iwn_softc *sc = device_get_softc(dev);
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
+	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+
+	iwn_stop(sc);
+	if (vap != NULL)
+		ieee80211_stop(vap);
+	return 0;
+}
+
+static int
+iwn_resume(device_t dev)
+{
+	struct iwn_softc *sc = device_get_softc(dev);
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
+	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+
+	/* Clear device-specific "PCI retry timeout" register (41h). */
+	pci_write_config(dev, 0x41, 0, 1);
+
+	if (ifp->if_flags & IFF_UP) {
+		iwn_init(sc);
+		if (vap != NULL)
+			ieee80211_init(vap);
+		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+			iwn_start(ifp);
+	}
+	return 0;
+}
+
+static int
 iwn_nic_lock(struct iwn_softc *sc)
 {
 	int ntries;
@@ -1073,9 +1193,9 @@ iwn_init_otprom(struct iwn_softc *sc)
 static int
 iwn_read_prom_data(struct iwn_softc *sc, uint32_t addr, void *data, int count)
 {
+	uint8_t *out = data;
 	uint32_t val, tmp;
 	int ntries;
-	uint8_t *out = data;
 
 	addr += sc->prom_base;
 	for (; count > 0; count -= 2, addr++) {
@@ -1127,8 +1247,8 @@ iwn_dma_contig_alloc(struct iwn_softc *s
 {
 	int error;
 
-	dma->size = size;
 	dma->tag = NULL;
+	dma->size = size;
 
 	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), alignment,
 	    0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size,
@@ -1371,8 +1491,8 @@ iwn_free_rx_ring(struct iwn_softc *sc, s
 static int
 iwn_alloc_tx_ring(struct iwn_softc *sc, struct iwn_tx_ring *ring, int qid)
 {
-	bus_size_t size;
 	bus_addr_t paddr;
+	bus_size_t size;
 	int i, error;
 
 	ring->qid = qid;
@@ -1520,8 +1640,8 @@ static int
 iwn_read_eeprom(struct iwn_softc *sc, uint8_t macaddr[IEEE80211_ADDR_LEN])
 {
 	const struct iwn_hal *hal = sc->sc_hal;
-	int error;
 	uint16_t val;
+	int error;
 
 	/* Check whether adapter has an EEPROM or an OTPROM. */
 	if (sc->hw_type >= IWN_HW_REV_TYPE_1000 &&
@@ -1581,8 +1701,8 @@ static void
 iwn4965_read_eeprom(struct iwn_softc *sc)
 {
 	uint32_t addr;
-	int i;
 	uint16_t val;
+	int i;
 
 	/* Read regulatory domain (4 ASCII characters.) */
 	iwn_read_prom_data(sc, IWN4965_EEPROM_DOMAIN, sc->eeprom_domain, 4);
@@ -1664,9 +1784,9 @@ iwn5000_read_eeprom(struct iwn_softc *sc
 {
 	struct iwn5000_eeprom_calib_hdr hdr;
 	int32_t volt;
-	uint32_t addr, base;
-	int i;
+	uint32_t base, addr;
 	uint16_t val;
+	int i;
 
 	/* Read regulatory domain (4 ASCII characters.) */
 	iwn_read_prom_data(sc, IWN5000_EEPROM_REG, &val, 2);
@@ -1754,18 +1874,11 @@ iwn_read_eeprom_band(struct iwn_softc *s
 		chan = band->chan[i];
 		nflags = iwn_eeprom_channel_flags(&channels[i]);
 
-		DPRINTF(sc, IWN_DEBUG_RESET,
-		    "add chan %d flags 0x%x maxpwr %d\n",
-		    chan, channels[i].flags, channels[i].maxpwr);
-
 		c = &ic->ic_channels[ic->ic_nchans++];
 		c->ic_ieee = chan;
 		c->ic_maxregpower = channels[i].maxpwr;
 		c->ic_maxpower = 2*c->ic_maxregpower;
 
-		/* Save maximum allowed TX power for this channel. */
-		sc->maxpwr[chan] = channels[i].maxpwr;
-
 		if (n == 0) {	/* 2GHz band */
 			c->ic_freq = ieee80211_ieee2mhz(chan,
 			    IEEE80211_CHAN_G);
@@ -1781,6 +1894,14 @@ iwn_read_eeprom_band(struct iwn_softc *s
 			    IEEE80211_CHAN_A);
 			c->ic_flags = IEEE80211_CHAN_A | nflags;
 		}
+
+		/* Save maximum allowed TX power for this channel. */
+		sc->maxpwr[chan] = channels[i].maxpwr;
+
+		DPRINTF(sc, IWN_DEBUG_RESET,
+		    "add chan %d flags 0x%x maxpwr %d\n",
+		    chan, channels[i].flags, channels[i].maxpwr);
+
 #if 0	/* HT */
 		/* XXX no constraints on using HT20 */
 		/* add HT20, HT40 added separately */
@@ -1869,6 +1990,48 @@ iwn_read_eeprom_channels(struct iwn_soft
 	ieee80211_sort_channels(ic->ic_channels, ic->ic_nchans);
 }
 
+static struct iwn_eeprom_chan *
+iwn_find_eeprom_channel(struct iwn_softc *sc, struct ieee80211_channel *c)
+{
+	int i, j;
+
+	for (j = 0; j < 7; j++) {
+		for (i = 0; i < iwn_bands[j].nchan; i++) {
+			if (iwn_bands[j].chan[i] == c->ic_ieee)
+				return &sc->eeprom_channels[j][i];
+		}
+	}
+
+	return NULL;
+}
+
+/*
+ * Enforce flags read from EEPROM.
+ */
+static int
+iwn_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *rd,
+    int nchan, struct ieee80211_channel chans[])
+{
+	struct iwn_softc *sc = ic->ic_ifp->if_softc;
+	int i;
+
+	for (i = 0; i < nchan; i++) {
+		struct ieee80211_channel *c = &chans[i];
+		struct iwn_eeprom_chan *channel;
+
+		channel = iwn_find_eeprom_channel(sc, c);
+		if (channel == NULL) {
+			if_printf(ic->ic_ifp,
+			    "%s: invalid channel %u freq %u/0x%x\n",
+			    __func__, c->ic_ieee, c->ic_freq, c->ic_flags);
+			return EINVAL;
+		}
+		c->ic_flags |= iwn_eeprom_channel_flags(channel);
+	}
+
+	return 0;
+}
+
 #define nitems(_a)	(sizeof((_a)) / sizeof((_a)[0]))
 
 static void
@@ -2167,10 +2330,12 @@ iwn_rx_done(struct iwn_softc *sc, struct
 	if (ieee80211_radiotap_active(ic)) {
 		struct iwn_rx_radiotap_header *tap = &sc->sc_rxtap;
 
-		tap->wr_tsft = stat->tstamp;
 		tap->wr_flags = 0;
 		if (stat->flags & htole16(IWN_STAT_FLAG_SHPREAMBLE))
 			tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
+		tap->wr_dbm_antsignal = (int8_t)rssi;
+		tap->wr_dbm_antnoise = (int8_t)nf;
+		tap->wr_tsft = stat->tstamp;
 		switch (stat->rate) {
 		/* CCK rates. */
 		case  10: tap->wr_rate =   2; break;
@@ -2189,8 +2354,6 @@ iwn_rx_done(struct iwn_softc *sc, struct
 		/* Unknown rate: should not happen. */
 		default:  tap->wr_rate =   0;
 		}
-		tap->wr_dbm_antsignal = (int8_t)rssi;
-		tap->wr_dbm_antnoise = (int8_t)nf;
 	}
 
 	IWN_UNLOCK(sc);
@@ -2920,7 +3083,6 @@ iwn_tx_data(struct iwn_softc *sc, struct
 {
 	const struct iwn_hal *hal = sc->sc_hal;
 	const struct ieee80211_txparam *tp;
-	const struct iwn_rate *rinfo;
 	struct ieee80211vap *vap = ni->ni_vap;
 	struct ieee80211com *ic = ni->ni_ic;
 	struct iwn_node *wn = (void *)ni;
@@ -2929,14 +3091,15 @@ iwn_tx_data(struct iwn_softc *sc, struct
 	struct iwn_tx_data *data;
 	struct iwn_tx_cmd *cmd;
 	struct iwn_cmd_data *tx;
+	const struct iwn_rate *rinfo;
 	struct ieee80211_frame *wh;
 	struct ieee80211_key *k = NULL;
 	struct mbuf *m1;
-	bus_dma_segment_t *seg, segs[IWN_MAX_SCATTER];
 	uint32_t flags;
 	uint16_t qos;
 	u_int hdrlen;
-	uint8_t tid, ridx, type, txant;
+	bus_dma_segment_t *seg, segs[IWN_MAX_SCATTER];
+	uint8_t tid, ridx, txant, type;
 	int ac, i, totlen, error, pad, nsegs = 0, rate;
 
 	IWN_LOCK_ASSERT(sc);
@@ -3494,6 +3657,9 @@ iwn_ioctl(struct ifnet *ifp, u_long cmd,
 	int error = 0, startall = 0, stop = 0;
 
 	switch (cmd) {
+	case SIOCGIFADDR:
+		error = ether_ioctl(ifp, cmd, data);
+		break;
 	case SIOCSIFFLAGS:
 		IWN_LOCK(sc);
 		if (ifp->if_flags & IFF_UP) {
@@ -3517,9 +3683,6 @@ iwn_ioctl(struct ifnet *ifp, u_long cmd,
 	case SIOCGIFMEDIA:
 		error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
 		break;
-	case SIOCGIFADDR:
-		error = ether_ioctl(ifp, cmd, data);
-		break;
 	default:
 		error = EINVAL;
 		break;
@@ -3846,9 +4009,9 @@ iwn4965_set_txpower(struct iwn_softc *sc
 	struct iwn_ucode_info *uc = &sc->ucode_info;
 	struct iwn4965_cmd_txpower cmd;
 	struct iwn4965_eeprom_chan_samples *chans;
+	const uint8_t *rf_gain, *dsp_gain;
 	int32_t vdiff, tdiff;
 	int i, c, grp, maxpwr;
-	const uint8_t *rf_gain, *dsp_gain;
 	uint8_t chan;
 
 	/* Retrieve current channel from last RXON. */
@@ -4031,8 +4194,8 @@ static int
 iwn5000_get_rssi(struct iwn_softc *sc, struct iwn_rx_stat *stat)
 {
 	struct iwn5000_rx_phystat *phy = (void *)stat->phybuf;
-	int rssi;
 	uint8_t agc;
+	int rssi;
 
 	agc = (le32toh(phy->agc) >> 9) & 0x7f;
 
@@ -4274,7 +4437,7 @@ iwn5000_set_gains(struct iwn_softc *sc)
 {
 	struct iwn_calib_state *calib = &sc->calib;
 	struct iwn_phy_calib_gain cmd;
-	int i, ant, delta, div;
+	int i, ant, div, delta;
 
 	/* We collected 20 beacons and !=6050 need a 1.5 factor. */
 	div = (sc->hw_type == IWN_HW_REV_TYPE_6050) ? 20 : 30;
@@ -4497,8 +4660,8 @@ iwn_send_sensitivity(struct iwn_softc *s
 static int
 iwn_set_pslevel(struct iwn_softc *sc, int dtim, int level, int async)
 {
-	const struct iwn_pmgt *pmgt;
 	struct iwn_pmgt_cmd cmd;
+	const struct iwn_pmgt *pmgt;
 	uint32_t max, skip_dtim;
 	uint32_t reg;
 	int i;
@@ -4566,8 +4729,8 @@ iwn_config(struct iwn_softc *sc)
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	uint32_t txmask;
-	int error;
 	uint16_t rxchain;
+	int error;
 
 	if (sc->hw_type == IWN_HW_REV_TYPE_6005) {
 		/* Set radio temperature sensor offset. */
@@ -4700,9 +4863,9 @@ iwn_scan(struct iwn_softc *sc)
 	struct ieee80211_frame *wh;
 	struct ieee80211_rateset *rs;
 	struct ieee80211_channel *c;
-	int buflen, error;
-	uint16_t rxchain;
 	uint8_t *buf, *frm, txant;
+	uint16_t rxchain;
+	int buflen, error;
 
 	buf = malloc(IWN_SCAN_MAXSZ, M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (buf == NULL) {
@@ -6301,6 +6464,39 @@ iwn_hw_stop(struct iwn_softc *sc)
 }
 
 static void
+iwn_radio_on(void *arg0, int pending)
+{
+	struct iwn_softc *sc = arg0;
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
+	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+
+	if (vap != NULL) {
+		iwn_init(sc);
+		ieee80211_init(vap);
+	}
+}
+
+static void
+iwn_radio_off(void *arg0, int pending)
+{
+	struct iwn_softc *sc = arg0;
+	struct ifnet *ifp = sc->sc_ifp;
+	struct ieee80211com *ic = ifp->if_l2com;
+	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+
+	iwn_stop(sc);
+	if (vap != NULL)
+		ieee80211_stop(vap);
+
+	/* Enable interrupts to get RF toggle notification. */
+	IWN_LOCK(sc);
+	IWN_WRITE(sc, IWN_INT, 0xffffffff);
+	IWN_WRITE(sc, IWN_INT_MASK, sc->int_mask);
+	IWN_UNLOCK(sc);
+}
+
+static void
 iwn_init_locked(struct iwn_softc *sc)
 {
 	struct ifnet *ifp = sc->sc_ifp;
@@ -6487,48 +6683,6 @@ iwn_scan_mindwell(struct ieee80211_scan_
 	/* NB: don't try to abort scan; wait for firmware to finish */
 }
 
-static struct iwn_eeprom_chan *
-iwn_find_eeprom_channel(struct iwn_softc *sc, struct ieee80211_channel *c)
-{
-	int i, j;
-
-	for (j = 0; j < 7; j++) {
-		for (i = 0; i < iwn_bands[j].nchan; i++) {
-			if (iwn_bands[j].chan[i] == c->ic_ieee)
-				return &sc->eeprom_channels[j][i];
-		}
-	}
-
-	return NULL;
-}
-
-/*
- * Enforce flags read from EEPROM.
- */
-static int
-iwn_setregdomain(struct ieee80211com *ic, struct ieee80211_regdomain *rd,
-    int nchan, struct ieee80211_channel chans[])
-{
-	struct iwn_softc *sc = ic->ic_ifp->if_softc;
-	int i;
-
-	for (i = 0; i < nchan; i++) {
-		struct ieee80211_channel *c = &chans[i];
-		struct iwn_eeprom_chan *channel;
-
-		channel = iwn_find_eeprom_channel(sc, c);
-		if (channel == NULL) {
-			if_printf(ic->ic_ifp,
-			    "%s: invalid channel %u freq %u/0x%x\n",
-			    __func__, c->ic_ieee, c->ic_freq, c->ic_flags);
-			return EINVAL;
-		}
-		c->ic_flags |= iwn_eeprom_channel_flags(channel);
-	}
-
-	return 0;
-}
-
 static void
 iwn_hw_reset(void *arg0, int pending)
 {
@@ -6540,161 +6694,3 @@ iwn_hw_reset(void *arg0, int pending)
 	iwn_init(sc);
 	ieee80211_notify_radio(ic, 1);
 }
-
-static void
-iwn_radio_on(void *arg0, int pending)
-{
-	struct iwn_softc *sc = arg0;
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-
-	if (vap != NULL) {
-		iwn_init(sc);
-		ieee80211_init(vap);
-	}
-}
-
-static void
-iwn_radio_off(void *arg0, int pending)
-{
-	struct iwn_softc *sc = arg0;
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-
-	iwn_stop(sc);
-	if (vap != NULL)
-		ieee80211_stop(vap);
-
-	/* Enable interrupts to get RF toggle notification. */
-	IWN_LOCK(sc);
-	IWN_WRITE(sc, IWN_INT, 0xffffffff);
-	IWN_WRITE(sc, IWN_INT_MASK, sc->int_mask);
-	IWN_UNLOCK(sc);
-}
-
-static void
-iwn_sysctlattach(struct iwn_softc *sc)
-{
-	struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
-	struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
-
-#ifdef IWN_DEBUG
-	sc->sc_debug = 0;
-	SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
-	    "debug", CTLFLAG_RW, &sc->sc_debug, 0, "control debugging printfs");
-#endif
-}
-
-static int
-iwn_shutdown(device_t dev)
-{
-	struct iwn_softc *sc = device_get_softc(dev);
-
-	iwn_stop(sc);
-	return 0;
-}
-
-static int
-iwn_suspend(device_t dev)
-{
-	struct iwn_softc *sc = device_get_softc(dev);
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-
-	iwn_stop(sc);
-	if (vap != NULL)
-		ieee80211_stop(vap);
-	return 0;
-}
-
-static int
-iwn_resume(device_t dev)
-{
-	struct iwn_softc *sc = device_get_softc(dev);
-	struct ifnet *ifp = sc->sc_ifp;
-	struct ieee80211com *ic = ifp->if_l2com;
-	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
-
-	/* Clear device-specific "PCI retry timeout" register (41h). */
-	pci_write_config(dev, 0x41, 0, 1);
-
-	if (ifp->if_flags & IFF_UP) {
-		iwn_init(sc);
-		if (vap != NULL)
-			ieee80211_init(vap);
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING)
-			iwn_start(ifp);
-	}
-	return 0;
-}
-
-#ifdef IWN_DEBUG
-static const char *
-iwn_intr_str(uint8_t cmd)
-{
-	switch (cmd) {
-	/* Notifications */
-	case IWN_UC_READY:		return "UC_READY";
-	case IWN_ADD_NODE_DONE:		return "ADD_NODE_DONE";
-	case IWN_TX_DONE:		return "TX_DONE";
-	case IWN_START_SCAN:		return "START_SCAN";
-	case IWN_STOP_SCAN:		return "STOP_SCAN";
-	case IWN_RX_STATISTICS:		return "RX_STATS";
-	case IWN_BEACON_STATISTICS:	return "BEACON_STATS";
-	case IWN_STATE_CHANGED:		return "STATE_CHANGED";
-	case IWN_BEACON_MISSED:		return "BEACON_MISSED";
-	case IWN_RX_PHY:		return "RX_PHY";
-	case IWN_MPDU_RX_DONE:		return "MPDU_RX_DONE";
-	case IWN_RX_DONE:		return "RX_DONE";
-
-	/* Command Notifications */
-	case IWN_CMD_RXON:		return "IWN_CMD_RXON";
-	case IWN_CMD_RXON_ASSOC:	return "IWN_CMD_RXON_ASSOC";
-	case IWN_CMD_EDCA_PARAMS:	return "IWN_CMD_EDCA_PARAMS";
-	case IWN_CMD_TIMING:		return "IWN_CMD_TIMING";
-	case IWN_CMD_LINK_QUALITY:	return "IWN_CMD_LINK_QUALITY";
-	case IWN_CMD_SET_LED:		return "IWN_CMD_SET_LED";
-	case IWN5000_CMD_WIMAX_COEX:	return "IWN5000_CMD_WIMAX_COEX";
-	case IWN5000_CMD_CALIB_CONFIG:	return "IWN5000_CMD_CALIB_CONFIG";
-	case IWN5000_CMD_CALIB_RESULT:	return "IWN5000_CMD_CALIB_RESULT";
-	case IWN5000_CMD_CALIB_COMPLETE: return "IWN5000_CMD_CALIB_COMPLETE";
-	case IWN_CMD_SET_POWER_MODE:	return "IWN_CMD_SET_POWER_MODE";
-	case IWN_CMD_SCAN:		return "IWN_CMD_SCAN";
-	case IWN_CMD_SCAN_RESULTS:	return "IWN_CMD_SCAN_RESULTS";
-	case IWN_CMD_TXPOWER:		return "IWN_CMD_TXPOWER";
-	case IWN_CMD_TXPOWER_DBM:	return "IWN_CMD_TXPOWER_DBM";
-	case IWN5000_CMD_TX_ANT_CONFIG:	return "IWN5000_CMD_TX_ANT_CONFIG";
-	case IWN_CMD_BT_COEX:		return "IWN_CMD_BT_COEX";
-	case IWN_CMD_SET_CRITICAL_TEMP:	return "IWN_CMD_SET_CRITICAL_TEMP";
-	case IWN_CMD_SET_SENSITIVITY:	return "IWN_CMD_SET_SENSITIVITY";
-	case IWN_CMD_PHY_CALIB:		return "IWN_CMD_PHY_CALIB";
-	}
-	return "UNKNOWN INTR NOTIF/CMD";
-}
-#endif /* IWN_DEBUG */
-
-static device_method_t iwn_methods[] = {
-	/* Device interface */
-	DEVMETHOD(device_probe,		iwn_probe),
-	DEVMETHOD(device_attach,	iwn_attach),
-	DEVMETHOD(device_detach,	iwn_detach),
-	DEVMETHOD(device_shutdown,	iwn_shutdown),
-	DEVMETHOD(device_suspend,	iwn_suspend),
-	DEVMETHOD(device_resume,	iwn_resume),
-	{ 0, 0 }
-};
-
-static driver_t iwn_driver = {
-	"iwn",
-	iwn_methods,
-	sizeof (struct iwn_softc)
-};
-static devclass_t iwn_devclass;
-
-DRIVER_MODULE(iwn, pci, iwn_driver, iwn_devclass, 0, 0);
-MODULE_DEPEND(iwn, pci, 1, 1, 1);
-MODULE_DEPEND(iwn, firmware, 1, 1, 1);
-MODULE_DEPEND(iwn, wlan, 1, 1, 1);

Modified: head/sys/dev/iwn/if_iwnvar.h
==============================================================================
--- head/sys/dev/iwn/if_iwnvar.h	Sat Apr 16 13:47:17 2011	(r220722)
+++ head/sys/dev/iwn/if_iwnvar.h	Sat Apr 16 14:36:43 2011	(r220723)
@@ -201,19 +201,14 @@ struct iwn_vap {
 #define	IWN_VAP(_vap)	((struct iwn_vap *)(_vap))
 
 struct iwn_softc {
+	device_t 		sc_dev;
+
 	struct ifnet		*sc_ifp;
 	int			sc_debug;
 
 	/* Locks */
 	struct mtx		sc_mtx;
 
-	/* Bus */
-	device_t 		sc_dev;
-	int			mem_rid;
-	int			irq_rid;
-	struct resource 	*mem;
-	struct resource		*irq;
-
 	u_int			sc_flags;
 #define IWN_FLAG_HAS_OTPROM	(1 << 1)
 #define IWN_FLAG_CALIB_DONE	(1 << 2)
@@ -249,8 +244,12 @@ struct iwn_softc {
 	struct iwn_tx_ring	txq[IWN5000_NTXQUEUES];
 	struct iwn_rx_ring	rxq;
 
+	int			mem_rid;
+	struct resource 	*mem;
 	bus_space_tag_t		sc_st;
 	bus_space_handle_t	sc_sh;
+	int			irq_rid;
+	struct resource		*irq;
 	void 			*sc_ih;
 	bus_size_t		sc_sz;
 	int			sc_cap_off;	/* PCIe Capabilities. */

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 14:38:02 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2C0FE106566B;
	Sat, 16 Apr 2011 14:38:02 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 18C238FC12;
	Sat, 16 Apr 2011 14:38:02 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GEc2rM008202;
	Sat, 16 Apr 2011 14:38:02 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GEc2U0008200;
	Sat, 16 Apr 2011 14:38:02 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161438.p3GEc2U0008200@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 14:38:02 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220724 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 14:38:02 -0000

Author: bschmidt
Date: Sat Apr 16 14:38:01 2011
New Revision: 220724
URL: http://svn.freebsd.org/changeset/base/220724

Log:
  Sync debug and error messages with OpenBSD.

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:36:43 2011	(r220723)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:38:01 2011	(r220724)
@@ -521,7 +521,7 @@ iwn_attach(device_t dev)
 	sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid,
 	    RF_ACTIVE);
 	if (sc->mem == NULL ) {
-		device_printf(dev, "could not allocate memory resources\n");
+		device_printf(dev, "can't map mem space\n");
 		error = ENOMEM;
 		return error;
 	}
@@ -535,7 +535,7 @@ iwn_attach(device_t dev)
 	sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid,
 	    RF_ACTIVE | RF_SHAREABLE);
 	if (sc->irq == NULL) {
-		device_printf(dev, "could not allocate interrupt resource\n");
+		device_printf(dev, "can't map interrupt\n");
 		error = ENOMEM;
 		goto fail;
 	}
@@ -568,16 +568,15 @@ iwn_attach(device_t dev)
 	error = iwn_alloc_kw(sc);
 	if (error != 0) {
 		device_printf(dev,
-		    "could not allocate \"Keep Warm\" page, error %d\n", error);
+		    "could not allocate keep warm page, error %d\n", error);
 		goto fail;
 	}
 
 	/* Allocate ICT table for 5000 Series. */
 	if (sc->hw_type != IWN_HW_REV_TYPE_4965 &&
 	    (error = iwn_alloc_ict(sc)) != 0) {
-		device_printf(dev,
-		    "%s: could not allocate ICT table, error %d\n",
-		    __func__, error);
+		device_printf(dev, "could not allocate ICT table, error %d\n",
+		    error);
 		goto fail;
 	}
 
@@ -595,8 +594,8 @@ iwn_attach(device_t dev)
 		error = iwn_alloc_tx_ring(sc, &sc->txq[i], i);
 		if (error != 0) {
 			device_printf(dev,
-			    "could not allocate Tx ring %d, error %d\n",
-			    i, error);
+			    "could not allocate TX ring %d, error %d\n", i,
+			    error);
 			goto fail;
 		}
 	}
@@ -604,8 +603,8 @@ iwn_attach(device_t dev)
 	/* Allocate RX ring. */
 	error = iwn_alloc_rx_ring(sc, &sc->rxq);
 	if (error != 0 ){
-		device_printf(dev,
-		    "could not allocate Rx ring, error %d\n", error);
+		device_printf(dev, "could not allocate RX ring, error %d\n",
+		    error);
 		goto fail;
 	}
 
@@ -621,9 +620,11 @@ iwn_attach(device_t dev)
 	    ((sc->rxchainmask >> 2) & 1) +
 	    ((sc->rxchainmask >> 1) & 1) +
 	    ((sc->rxchainmask >> 0) & 1);
-	device_printf(sc->sc_dev, "MIMO %dT%dR, %.4s, address %6D\n",
-	    sc->ntxchains, sc->nrxchains, sc->eeprom_domain,
-	    macaddr, ":");
+	if (bootverbose) {
+		device_printf(dev, "MIMO %dT%dR, %.4s, address %6D\n",
+		    sc->ntxchains, sc->nrxchains, sc->eeprom_domain,
+		    macaddr, ":");
+	}
 
 	ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
 	if (ifp == NULL) {
@@ -745,12 +746,13 @@ iwn_attach(device_t dev)
 	error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE,
 	    NULL, iwn_intr, sc, &sc->sc_ih);
 	if (error != 0) {
-		device_printf(dev, "could not set up interrupt, error %d\n",
+		device_printf(dev, "can't establish interrupt, error %d\n",
 		    error);
 		goto fail;
 	}
 
-	ieee80211_announce(ic);
+	if (bootverbose)
+		ieee80211_announce(ic);
 	return 0;
 fail:
 	iwn_detach(dev);
@@ -1451,11 +1453,6 @@ iwn_reset_rx_ring(struct iwn_softc *sc, 
 			DELAY(10);
 		}
 		iwn_nic_unlock(sc);
-#ifdef IWN_DEBUG
-		if (ntries == 1000)
-			DPRINTF(sc, IWN_DEBUG_ANY, "%s\n",
-			    "timeout resetting Rx ring");
-#endif
 	}
 	ring->cur = 0;
 	sc->last_rx_valid = 0;
@@ -2246,8 +2243,8 @@ iwn_rx_done(struct iwn_softc *sc, struct
 
 	if (stat->cfg_phy_len > IWN_STAT_MAXLEN) {
 		device_printf(sc->sc_dev,
-		    "%s: invalid rx statistic header, len %d\n",
-		    __func__, stat->cfg_phy_len);
+		    "%s: invalid RX statistic header, len %d\n", __func__,
+		    stat->cfg_phy_len);
 		return;
 	}
 	if (desc->type == IWN_MPDU_RX_DONE) {
@@ -2263,7 +2260,7 @@ iwn_rx_done(struct iwn_softc *sc, struct
 
 	/* Discard frames with a bad FCS early. */
 	if ((flags & IWN_RX_NOERROR) != IWN_RX_NOERROR) {
-		DPRINTF(sc, IWN_DEBUG_RECV, "%s: rx flags error %x\n",
+		DPRINTF(sc, IWN_DEBUG_RECV, "%s: RX flags error %x\n",
 		    __func__, flags);
 		ifp->if_ierrors++;
 		return;
@@ -2464,7 +2461,9 @@ iwn_rx_statistics(struct iwn_softc *sc, 
 		return;
 
 	bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
-	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: cmd %d\n", __func__, desc->type);
+
+	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: received statistics, cmd %d\n",
+	    __func__, desc->type);
 	sc->calib_cnt = 0;	/* Reset TX power calibration timeout. */
 
 	/* Test if temperature has changed. */
@@ -2971,6 +2970,8 @@ iwn_intr(void *arg)
 		    __func__);
 	}
 	if (r1 & (IWN_INT_SW_ERR | IWN_INT_HW_ERR)) {
+		device_printf(sc->sc_dev, "%s: fatal firmware error\n",
+		    __func__);
 		iwn_fatal_intr(sc);
 		ifp->if_flags &= ~IFF_UP;
 		iwn_stop_locked(sc);
@@ -4183,9 +4184,9 @@ iwn4965_get_rssi(struct iwn_softc *sc, s
 	if (mask & IWN_ANT_C)
 		rssi = MAX(rssi, phy->rssi[4]);
 
-	DPRINTF(sc, IWN_DEBUG_RECV, "%s: agc %d mask 0x%x rssi %d %d %d "
-	    "result %d\n", __func__, agc, mask,
-	    phy->rssi[0], phy->rssi[2], phy->rssi[4],
+	DPRINTF(sc, IWN_DEBUG_RECV,
+	    "%s: agc %d mask 0x%x rssi %d %d %d result %d\n", __func__, agc,
+	    mask, phy->rssi[0], phy->rssi[2], phy->rssi[4],
 	    rssi - agc - IWN_RSSI_TO_DBM);
 	return rssi - agc - IWN_RSSI_TO_DBM;
 }
@@ -4203,8 +4204,8 @@ iwn5000_get_rssi(struct iwn_softc *sc, s
 		   le16toh(phy->rssi[1]) & 0xff);
 	rssi = MAX(le16toh(phy->rssi[2]) & 0xff, rssi);
 
-	DPRINTF(sc, IWN_DEBUG_RECV, "%s: agc %d rssi %d %d %d "
-	    "result %d\n", __func__, agc,
+	DPRINTF(sc, IWN_DEBUG_RECV,
+	    "%s: agc %d rssi %d %d %d result %d\n", __func__, agc,
 	    phy->rssi[0], phy->rssi[1], phy->rssi[2],
 	    rssi - agc - IWN_RSSI_TO_DBM);
 	return rssi - agc - IWN_RSSI_TO_DBM;
@@ -4311,7 +4312,8 @@ iwn_init_sensitivity(struct iwn_softc *s
 
 	/* Request statistics at each beacon interval. */
 	flags = 0;
-	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: calibrate phy\n", __func__);
+	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: sending request for statistics\n",
+	    __func__);
 	return iwn_cmd(sc, IWN_CMD_GET_STATISTICS, &flags, sizeof flags, 1);
 }
 
@@ -4824,7 +4826,7 @@ iwn_config(struct iwn_softc *sc)
 	error = iwn_set_critical_temp(sc);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: ccould not set critical temperature\n", __func__);
+		    "%s: could not set critical temperature\n", __func__);
 		return error;
 	}
 
@@ -5035,17 +5037,9 @@ iwn_auth(struct iwn_softc *sc, struct ie
 		sc->rxon.cck_mask  = 0x0f;
 		sc->rxon.ofdm_mask = 0x15;
 	}
-	DPRINTF(sc, IWN_DEBUG_STATE,
-	    "%s: config chan %d mode %d flags 0x%x cck 0x%x ofdm 0x%x "
-	    "ht_single 0x%x ht_dual 0x%x rxchain 0x%x "
-	    "myaddr %6D wlap %6D bssid %6D associd %d filter 0x%x\n",
-	    __func__,
-	    le16toh(sc->rxon.chan), sc->rxon.mode, le32toh(sc->rxon.flags),
-	    sc->rxon.cck_mask, sc->rxon.ofdm_mask,
-	    sc->rxon.ht_single_mask, sc->rxon.ht_dual_mask,
-	    le16toh(sc->rxon.rxchain),
-	    sc->rxon.myaddr, ":", sc->rxon.wlap, ":", sc->rxon.bssid, ":",
-	    le16toh(sc->rxon.associd), le32toh(sc->rxon.filter));
+	DPRINTF(sc, IWN_DEBUG_STATE, "rxon chan %d flags %x cck %x ofdm %x\n",
+	    sc->rxon.chan, sc->rxon.flags, sc->rxon.cck_mask,
+	    sc->rxon.ofdm_mask);
 	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, hal->rxonsz, 1);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
@@ -5057,7 +5051,7 @@ iwn_auth(struct iwn_softc *sc, struct ie
 	error = hal->set_txpower(sc, ni->ni_chan, 1);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not set Tx power, error %d\n", __func__, error);
+		    "%s: could not set TX power, error %d\n", __func__, error);
 		return error;
 	}
 	/*
@@ -5143,18 +5137,8 @@ iwn_run(struct iwn_softc *sc, struct iee
 		maxrxampdu = ampdudensity = 0;
 #endif
 	sc->rxon.filter |= htole32(IWN_FILTER_BSS);
-
-	DPRINTF(sc, IWN_DEBUG_STATE,
-	    "%s: config chan %d mode %d flags 0x%x cck 0x%x ofdm 0x%x "
-	    "ht_single 0x%x ht_dual 0x%x rxchain 0x%x "
-	    "myaddr %6D wlap %6D bssid %6D associd %d filter 0x%x\n",
-	    __func__,
-	    le16toh(sc->rxon.chan), sc->rxon.mode, le32toh(sc->rxon.flags),
-	    sc->rxon.cck_mask, sc->rxon.ofdm_mask,
-	    sc->rxon.ht_single_mask, sc->rxon.ht_dual_mask,
-	    le16toh(sc->rxon.rxchain),
-	    sc->rxon.myaddr, ":", sc->rxon.wlap, ":", sc->rxon.bssid, ":",
-	    le16toh(sc->rxon.associd), le32toh(sc->rxon.filter));
+	DPRINTF(sc, IWN_DEBUG_STATE, "rxon chan %d flags %x\n",
+	    sc->rxon.chan, sc->rxon.flags);
 	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, hal->rxonsz, 1);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
@@ -5167,7 +5151,7 @@ iwn_run(struct iwn_softc *sc, struct iee
 	error = hal->set_txpower(sc, ni->ni_chan, 1);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not set Tx power, error %d\n", __func__, error);
+		    "%s: could not set TX power, error %d\n", __func__, error);
 		return error;
 	}
 
@@ -5183,19 +5167,19 @@ iwn_run(struct iwn_softc *sc, struct iee
 	node.htflags = htole32(IWN_AMDPU_SIZE_FACTOR(3) |
 	    IWN_AMDPU_DENSITY(5));	/* 2us */
 #endif
-	DPRINTF(sc, IWN_DEBUG_STATE, "%s: add BSS node, id %d htflags 0x%x\n",
-	    __func__, node.id, le32toh(node.htflags));
+	DPRINTF(sc, IWN_DEBUG_STATE, "%s: adding BSS node\n", __func__);
 	error = hal->add_node(sc, &node, 1);
 	if (error != 0) {
-		device_printf(sc->sc_dev, "could not add BSS node\n");
+		device_printf(sc->sc_dev,
+		    "%s: could not add BSS node, error %d\n", __func__, error);
 		return error;
 	}
-	DPRINTF(sc, IWN_DEBUG_STATE, "setting link quality for node %d\n",
-	    node.id);
+	DPRINTF(sc, IWN_DEBUG_STATE, "%s: setting link quality for node %d\n",
+	    __func__, node.id);
 	error = iwn_set_link_quality(sc, ni);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not setup MRR for node %d, error %d\n",
+		    "%s: could not setup link quality for node %d, error %d\n",
 		    __func__, node.id, error);
 		return error;
 	}
@@ -5242,7 +5226,7 @@ iwn_ampdu_rx_start(struct ieee80211com *
 	node.addba_tid = tid;
 	node.addba_ssn = htole16(ba->ba_winstart);
 	DPRINTF(sc, IWN_DEBUG_RECV, "ADDBA RA=%d TID=%d SSN=%d\n",
-	    wn->id, tid, ba->ba_winstart));
+	    wn->id, tid, ba->ba_winstart);
 	return sc->sc_hal->add_node(sc, &node, 1);
 }
 
@@ -5912,8 +5896,7 @@ iwn_read_firmware_leg(struct iwn_softc *
 		ptr++;
 	}
 	if (fw->size < hdrlen) {
-		device_printf(sc->sc_dev,
-		    "%s: firmware file too short: %zu bytes\n",
+		device_printf(sc->sc_dev, "%s: firmware too short: %zu bytes\n",
 		    __func__, fw->size);
 		return EINVAL;
 	}
@@ -5926,8 +5909,7 @@ iwn_read_firmware_leg(struct iwn_softc *
 	/* Check that all firmware sections fit. */
 	if (fw->size < hdrlen + fw->main.textsz + fw->main.datasz +
 	    fw->init.textsz + fw->init.datasz + fw->boot.textsz) {
-		device_printf(sc->sc_dev,
-		    "%s: firmware file too short: %zu bytes\n",
+		device_printf(sc->sc_dev, "%s: firmware too short: %zu bytes\n",
 		    __func__, fw->size);
 		return EINVAL;
 	}
@@ -5956,18 +5938,18 @@ iwn_read_firmware_tlv(struct iwn_softc *
 	uint32_t len;
 
 	if (fw->size < sizeof (*hdr)) {
-		device_printf(sc->sc_dev,
-		    "%s: firmware file too short: %zu bytes\n",
+		device_printf(sc->sc_dev, "%s: firmware too short: %zu bytes\n",
 		    __func__, fw->size);
 		return EINVAL;
 	}
 	hdr = (const struct iwn_fw_tlv_hdr *)fw->data;
 	if (hdr->signature != htole32(IWN_FW_SIGNATURE)) {
-		device_printf(sc->sc_dev,
-		    "%s: bad firmware file signature 0x%08x\n",
+		device_printf(sc->sc_dev, "%s: bad firmware signature 0x%08x\n",
 		    __func__, le32toh(hdr->signature));
 		return EINVAL;
 	}
+	DPRINTF(sc, IWN_DEBUG_RESET, "FW: \"%.64s\", build 0x%x\n", hdr->descr,
+	    le32toh(hdr->build));
 
 	/*
 	 * Select the closest supported alternative that is less than
@@ -5976,6 +5958,7 @@ iwn_read_firmware_tlv(struct iwn_softc *
 	altmask = le64toh(hdr->altmask);
 	while (alt > 0 && !(altmask & (1ULL << alt)))
 		alt--;	/* Downgrade. */
+	DPRINTF(sc, IWN_DEBUG_RESET, "using alternative %d\n", alt);
 
 	ptr = (const uint8_t *)(hdr + 1);
 	end = (const uint8_t *)(fw->data + fw->size);
@@ -5988,8 +5971,8 @@ iwn_read_firmware_tlv(struct iwn_softc *
 		ptr += sizeof (*tlv);
 		if (ptr + len > end) {
 			device_printf(sc->sc_dev,
-			    "%s: firmware file too short: %zu bytes\n",
-			    __func__, fw->size);
+			    "%s: firmware too short: %zu bytes\n", __func__,
+			    fw->size);
 			return EINVAL;
 		}
 		/* Skip other alternatives. */
@@ -6019,8 +6002,7 @@ iwn_read_firmware_tlv(struct iwn_softc *
 			break;
 		default:
 			DPRINTF(sc, IWN_DEBUG_RESET,
-			    "%s: TLV type %d not handled\n",
-			    __func__, le16toh(tlv->type));
+			    "TLV type %d not handled\n", le16toh(tlv->type));
 			break;
 		}
 next:		/* TLV fields are 32-bit aligned. */
@@ -6043,9 +6025,8 @@ iwn_read_firmware(struct iwn_softc *sc)
 	/* Read firmware image from filesystem. */
 	sc->fw_fp = firmware_get(sc->fwname);
 	if (sc->fw_fp == NULL) {
-		device_printf(sc->sc_dev,
-		    "%s: could not load firmare image \"%s\"\n", __func__,
-		    sc->fwname);
+		device_printf(sc->sc_dev, "%s: could not read firmware %s\n",
+		    __func__, sc->fwname);
 		IWN_LOCK(sc);
 		return EINVAL;
 	}
@@ -6054,8 +6035,7 @@ iwn_read_firmware(struct iwn_softc *sc)
 	fw->size = sc->fw_fp->datasize;
 	fw->data = (const uint8_t *)sc->fw_fp->data;
 	if (fw->size < sizeof (uint32_t)) {
-		device_printf(sc->sc_dev,
-		    "%s: firmware file too short: %zu bytes\n",
+		device_printf(sc->sc_dev, "%s: firmware too short: %zu bytes\n",
 		    __func__, fw->size);
 		firmware_put(sc->fw_fp, FIRMWARE_UNLOAD);
 		sc->fw_fp = NULL;
@@ -6069,7 +6049,8 @@ iwn_read_firmware(struct iwn_softc *sc)
 		error = iwn_read_firmware_tlv(sc, fw, 1);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not read firmware sections\n", __func__);
+		    "%s: could not read firmware sections, error %d\n",
+		    __func__, error);
 		firmware_put(sc->fw_fp, FIRMWARE_UNLOAD);
 		sc->fw_fp = NULL;
 		return error;
@@ -6082,8 +6063,8 @@ iwn_read_firmware(struct iwn_softc *sc)
 	    fw->init.datasz > hal->fw_data_maxsz ||
 	    fw->boot.textsz > IWN_FW_BOOT_TEXT_MAXSZ ||
 	    (fw->boot.textsz & 3) != 0) {
-		device_printf(sc->sc_dev,
-		    "%s: firmware sections too large\n", __func__);
+		device_printf(sc->sc_dev, "%s: firmware sections too large\n",
+		    __func__);
 		firmware_put(sc->fw_fp, FIRMWARE_UNLOAD);
 		sc->fw_fp = NULL;
 		return EINVAL;
@@ -6506,7 +6487,7 @@ iwn_init_locked(struct iwn_softc *sc)
 
 	error = iwn_hw_prepare(sc);
 	if (error != 0) {
-		device_printf(sc->sc_dev, "%s: hardware not ready, eror %d\n",
+		device_printf(sc->sc_dev, "%s: hardware not ready, error %d\n",
 		    __func__, error);
 		goto fail;
 	}

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 14:38:57 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CF2491065674;
	Sat, 16 Apr 2011 14:38:57 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id BC4CF8FC08;
	Sat, 16 Apr 2011 14:38:57 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GEcvR5008250;
	Sat, 16 Apr 2011 14:38:57 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GEcvbE008247;
	Sat, 16 Apr 2011 14:38:57 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161438.p3GEcvbE008247@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 14:38:57 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220725 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 14:38:58 -0000

Author: bschmidt
Date: Sat Apr 16 14:38:57 2011
New Revision: 220725
URL: http://svn.freebsd.org/changeset/base/220725

Log:
  Sync comments with OpenBSD.

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnvar.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:38:01 2011	(r220724)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:38:57 2011	(r220725)
@@ -532,6 +532,7 @@ iwn_attach(device_t dev)
 	if ((result = pci_msi_count(dev)) == 1 &&
 	    pci_alloc_msi(dev, &result) == 0)
 		sc->irq_rid = 1;
+	/* Install interrupt handler. */
 	sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid,
 	    RF_ACTIVE | RF_SHAREABLE);
 	if (sc->irq == NULL) {
@@ -589,7 +590,7 @@ iwn_attach(device_t dev)
 		goto fail;
 	}
 
-	/* Allocate TX rings (16 on 4965AGN, 20 on 5000). */
+	/* Allocate TX rings (16 on 4965AGN, 20 on >=5000). */
 	for (i = 0; i < hal->ntxqs; i++) {
 		error = iwn_alloc_tx_ring(sc, &sc->txq[i], i);
 		if (error != 0) {
@@ -929,6 +930,7 @@ iwn_detach(device_t dev)
 		ieee80211_ifdetach(ic);
 	}
 
+	/* Uninstall interrupt handler. */
 	if (sc->irq != NULL) {
 		bus_teardown_intr(dev, sc->irq, sc->sc_ih);
 		bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, sc->irq);
@@ -1496,7 +1498,7 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 	ring->queued = 0;
 	ring->cur = 0;
 
-	/* Allocate TX descriptors (256-byte aligned.) */
+	/* Allocate TX descriptors (256-byte aligned). */
 	size = IWN_TX_RING_COUNT * sizeof(struct iwn_tx_desc);
 	error = iwn_dma_contig_alloc(sc, &ring->desc_dma, (void **)&ring->desc,
 	    size, 256);
@@ -1510,6 +1512,7 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 	/*
 	 * We only use rings 0 through 4 (4 EDCA + cmd) so there is no need
 	 * to allocate commands space for other rings.
+	 * XXX Do we really need to allocate descriptors for other rings?
 	 */
 	if (qid > 4)
 		return 0;
@@ -1618,7 +1621,7 @@ iwn5000_ict_reset(struct iwn_softc *sc)
 	memset(sc->ict, 0, IWN_ICT_SIZE);
 	sc->ict_cur = 0;
 
-	/* Set physical address of ICT table (4KB aligned.) */
+	/* Set physical address of ICT table (4KB aligned). */
 	DPRINTF(sc, IWN_DEBUG_RESET, "%s: enabling ICT\n", __func__);
 	IWN_WRITE(sc, IWN_DRAM_INT_TBL, IWN_DRAM_INT_TBL_ENABLE |
 	    IWN_DRAM_INT_TBL_WRAP_CHECK | sc->ict_dma.paddr >> 12);
@@ -1701,10 +1704,10 @@ iwn4965_read_eeprom(struct iwn_softc *sc
 	uint16_t val;
 	int i;
 
-	/* Read regulatory domain (4 ASCII characters.) */
+	/* Read regulatory domain (4 ASCII characters). */
 	iwn_read_prom_data(sc, IWN4965_EEPROM_DOMAIN, sc->eeprom_domain, 4);
 
-	/* Read the list of authorized channels (20MHz ones only.) */
+	/* Read the list of authorized channels (20MHz ones only). */
 	for (i = 0; i < 5; i++) {
 		addr = iwn4965_regulatory_bands[i];
 		iwn_read_eeprom_channels(sc, i, addr);
@@ -1785,13 +1788,13 @@ iwn5000_read_eeprom(struct iwn_softc *sc
 	uint16_t val;
 	int i;
 
-	/* Read regulatory domain (4 ASCII characters.) */
+	/* Read regulatory domain (4 ASCII characters). */
 	iwn_read_prom_data(sc, IWN5000_EEPROM_REG, &val, 2);
 	base = le16toh(val);
 	iwn_read_prom_data(sc, base + IWN5000_EEPROM_DOMAIN,
 	    sc->eeprom_domain, 4);
 
-	/* Read the list of authorized channels (20MHz ones only.) */
+	/* Read the list of authorized channels (20MHz ones only). */
 	for (i = 0; i < 5; i++) {
 		addr = base + iwn5000_regulatory_bands[i];
 		iwn_read_eeprom_channels(sc, i, addr);
@@ -2455,7 +2458,7 @@ iwn_rx_statistics(struct iwn_softc *sc, 
 	struct iwn_stats *stats = (struct iwn_stats *)(desc + 1);
 	int temp;
 
-	/* Beacon stats are meaningful only when associated and not scanning. */
+	/* Ignore statistics received during a scan. */
 	if (vap->iv_state != IEEE80211_S_RUN ||
 	    (ic->ic_flags & IEEE80211_F_SCAN))
 		return;
@@ -2474,7 +2477,7 @@ iwn_rx_statistics(struct iwn_softc *sc, 
 		DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: temperature %d\n",
 		    __func__, temp);
 
-		/* Update TX power if need be (4965AGN only.) */
+		/* Update TX power if need be (4965AGN only). */
 		if (sc->hw_type == IWN_HW_REV_TYPE_4965)
 			iwn4965_power_calibration(sc, temp);
 	}
@@ -2972,6 +2975,7 @@ iwn_intr(void *arg)
 	if (r1 & (IWN_INT_SW_ERR | IWN_INT_HW_ERR)) {
 		device_printf(sc->sc_dev, "%s: fatal firmware error\n",
 		    __func__);
+		/* Dump firmware error log and stop. */
 		iwn_fatal_intr(sc);
 		ifp->if_flags &= ~IFF_UP;
 		iwn_stop_locked(sc);
@@ -3015,7 +3019,7 @@ done:
 
 /*
  * Update TX scheduler ring when transmitting an 802.11 frame (4965AGN and
- * 5000 adapters use a slightly different format.)
+ * 5000 adapters use a slightly different format).
  */
 static void
 iwn4965_update_sched(struct iwn_softc *sc, int qid, int idx, uint8_t id,
@@ -3141,12 +3145,13 @@ iwn_tx_data(struct iwn_softc *sc, struct
 
 	/* Encrypt the frame if need be. */
 	if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
+		/* Retrieve key for TX. */
 		k = ieee80211_crypto_encap(ni, m);
 		if (k == NULL) {
 			m_freem(m);
 			return ENOBUFS;
 		}
-		/* Packet header may have moved, reset our local pointer. */
+		/* 802.11 header may have moved. */
 		wh = mtod(m, struct ieee80211_frame *);
 	}
 	totlen = m->m_pkthdr.len;
@@ -3421,6 +3426,7 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 	if (type == IEEE80211_FC0_TYPE_MGT) {
 		uint8_t subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
 
+		/* Tell HW to set timestamp in probe responses. */
 		if (subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP)
 			flags |= IWN_TX_INSERT_TSTAMP;
 
@@ -3899,7 +3905,7 @@ iwn_updateedca(struct ieee80211com *ic)
 	}
 	IEEE80211_UNLOCK(ic);
 	IWN_LOCK(sc);
-	(void) iwn_cmd(sc, IWN_CMD_EDCA_PARAMS, &cmd, sizeof cmd, 1 /*async*/);
+	(void)iwn_cmd(sc, IWN_CMD_EDCA_PARAMS, &cmd, sizeof cmd, 1);
 	IWN_UNLOCK(sc);
 	IEEE80211_LOCK(ic);
 	return 0;
@@ -3980,7 +3986,7 @@ iwn4965_power_calibration(struct iwn_sof
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 
-	/* Adjust TX power if need be (delta >= 3 degC.) */
+	/* Adjust TX power if need be (delta >= 3 degC). */
 	DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: temperature %d->%d\n",
 	    __func__, sc->temp, temp);
 	if (abs(temp - sc->temp) >= 3) {
@@ -4244,7 +4250,7 @@ iwn4965_get_temperature(struct iwn_softc
 	r3 = le32toh(uc->temp[2].chan20MHz);
 	r4 = le32toh(sc->rawtemp);
 
-	if (r1 == r3)	/* Prevents division by 0 (should not happen.) */
+	if (r1 == r3)	/* Prevents division by 0 (should not happen). */
 		return 0;
 
 	/* Sign-extend 23-bit R4 value to 32-bit. */
@@ -4265,8 +4271,7 @@ iwn5000_get_temperature(struct iwn_softc
 
 	/*
 	 * Temperature is not used by the driver for 5000 Series because
-	 * TX power calibration is handled by firmware.  We export it to
-	 * users through the sensor framework though.
+	 * TX power calibration is handled by firmware.
 	 */
 	temp = le32toh(sc->rawtemp);
 	if (sc->hw_type == IWN_HW_REV_TYPE_5150) {
@@ -4744,7 +4749,7 @@ iwn_config(struct iwn_softc *sc)
 		}
 	}
 
-	/* Configure valid TX chains for 5000 Series. */
+	/* Configure valid TX chains for >=5000 Series. */
 	if (sc->hw_type != IWN_HW_REV_TYPE_4965) {
 		txmask = htole32(sc->txchainmask);
 		DPRINTF(sc, IWN_DEBUG_RESET,
@@ -5033,7 +5038,7 @@ iwn_auth(struct iwn_softc *sc, struct ie
 		sc->rxon.cck_mask  = 0x03;
 		sc->rxon.ofdm_mask = 0;
 	} else {
-		/* XXX assume 802.11b/g */
+		/* Assume 802.11b/g. */
 		sc->rxon.cck_mask  = 0x0f;
 		sc->rxon.ofdm_mask = 0x15;
 	}
@@ -5068,9 +5073,6 @@ iwn_auth(struct iwn_softc *sc, struct ie
 	return 0;
 }
 
-/*
- * Configure the adapter for associated state.
- */
 static int
 iwn_run(struct iwn_softc *sc, struct ieee80211vap *vap)
 {
@@ -5112,7 +5114,7 @@ iwn_run(struct iwn_softc *sc, struct iee
 		sc->rxon.cck_mask  = 0x03;
 		sc->rxon.ofdm_mask = 0;
 	} else {
-		/* XXX assume 802.11b/g */
+		/* Assume 802.11b/g. */
 		sc->rxon.cck_mask  = 0x0f;
 		sc->rxon.ofdm_mask = 0x15;
 	}
@@ -5232,7 +5234,7 @@ iwn_ampdu_rx_start(struct ieee80211com *
 
 /*
  * This function is called by upper layer on teardown of an HT-immediate
- * Block Ack agreement (eg. uppon receipt of a DELBA frame.)
+ * Block Ack agreement (eg. uppon receipt of a DELBA frame).
  */
 static void
 iwn_ampdu_rx_stop(struct ieee80211com *ic, struct ieee80211_node *ni,
@@ -5537,7 +5539,7 @@ iwn5000_temp_offset_calib(struct iwn_sof
 
 /*
  * This function is called after the runtime firmware notifies us of its
- * readiness (called in a process context.)
+ * readiness (called in a process context).
  */
 static int
 iwn4965_post_alive(struct iwn_softc *sc)
@@ -5552,7 +5554,7 @@ iwn4965_post_alive(struct iwn_softc *sc)
 	iwn_mem_set_region_4(sc, sc->sched_base + IWN4965_SCHED_CTX_OFF, 0,
 	    IWN4965_SCHED_CTX_LEN / sizeof (uint32_t));
 
-	/* Set physical address of TX scheduler rings (1KB aligned.) */
+	/* Set physical address of TX scheduler rings (1KB aligned). */
 	iwn_prph_write(sc, IWN4965_SCHED_DRAM_ADDR, sc->sched_dma.paddr >> 10);
 
 	IWN_SETBITS(sc, IWN_FH_TX_CHICKEN, IWN_FH_TX_CHICKEN_SCHED_RETRY);
@@ -5590,7 +5592,7 @@ iwn4965_post_alive(struct iwn_softc *sc)
 
 /*
  * This function is called after the initialization or runtime firmware
- * notifies us of its readiness (called in a process context.)
+ * notifies us of its readiness (called in a process context).
  */
 static int
 iwn5000_post_alive(struct iwn_softc *sc)
@@ -5609,7 +5611,7 @@ iwn5000_post_alive(struct iwn_softc *sc)
 	iwn_mem_set_region_4(sc, sc->sched_base + IWN5000_SCHED_CTX_OFF, 0,
 	    IWN5000_SCHED_CTX_LEN / sizeof (uint32_t));
 
-	/* Set physical address of TX scheduler rings (1KB aligned.) */
+	/* Set physical address of TX scheduler rings (1KB aligned). */
 	iwn_prph_write(sc, IWN5000_SCHED_DRAM_ADDR, sc->sched_dma.paddr >> 10);
 
 	IWN_SETBITS(sc, IWN_FH_TX_CHICKEN, IWN_FH_TX_CHICKEN_SCHED_RETRY);
@@ -5685,7 +5687,7 @@ iwn5000_post_alive(struct iwn_softc *sc)
 
 /*
  * The firmware boot code is small and is intended to be copied directly into
- * the NIC internal memory (no DMA transfer.)
+ * the NIC internal memory (no DMA transfer).
  */
 static int
 iwn4965_load_bootcode(struct iwn_softc *sc, const uint8_t *ucode, int size)
@@ -6099,12 +6101,12 @@ iwn_apm_init(struct iwn_softc *sc)
 	uint32_t reg;
 	int error;
 
-	/* Disable L0s exit timer (NMI bug workaround.) */
+	/* Disable L0s exit timer (NMI bug workaround). */
 	IWN_SETBITS(sc, IWN_GIO_CHICKEN, IWN_GIO_CHICKEN_DIS_L0S_TIMER);
-	/* Don't wait for ICH L0s (ICH bug workaround.) */
+	/* Don't wait for ICH L0s (ICH bug workaround). */
 	IWN_SETBITS(sc, IWN_GIO_CHICKEN, IWN_GIO_CHICKEN_L1A_NO_L0S_RX);
 
-	/* Set FH wait threshold to max (HW bug under stress workaround.) */
+	/* Set FH wait threshold to max (HW bug under stress workaround). */
 	IWN_SETBITS(sc, IWN_DBG_HPET_MEM, 0xffff0000);
 
 	/* Enable HAP INTA to move adapter from L1a to L0s. */
@@ -6132,7 +6134,7 @@ iwn_apm_init(struct iwn_softc *sc)
 		return error;
 
 	if (sc->hw_type == IWN_HW_REV_TYPE_4965) {
-		/* Enable DMA and BSM (Bootstrap State Machine.) */
+		/* Enable DMA and BSM (Bootstrap State Machine). */
 		iwn_prph_write(sc, IWN_APMG_CLK_EN,
 		    IWN_APMG_CLK_CTRL_DMA_CLK_RQT |
 		    IWN_APMG_CLK_CTRL_BSM_CLK_RQT);
@@ -6316,9 +6318,9 @@ iwn_hw_init(struct iwn_softc *sc)
 		return error;
 	IWN_WRITE(sc, IWN_FH_RX_CONFIG, 0);
 	IWN_WRITE(sc, IWN_FH_RX_WPTR, 0);
-	/* Set physical address of RX ring (256-byte aligned.) */
+	/* Set physical address of RX ring (256-byte aligned). */
 	IWN_WRITE(sc, IWN_FH_RX_BASE, sc->rxq.desc_dma.paddr >> 8);
-	/* Set physical address of RX status (16-byte aligned.) */
+	/* Set physical address of RX status (16-byte aligned). */
 	IWN_WRITE(sc, IWN_FH_STATUS_WPTR, sc->rxq.stat_dma.paddr >> 4);
 	/* Enable RX. */
 	IWN_WRITE(sc, IWN_FH_RX_CONFIG,
@@ -6338,14 +6340,14 @@ iwn_hw_init(struct iwn_softc *sc)
 	/* Initialize TX scheduler. */
 	iwn_prph_write(sc, hal->sched_txfact_addr, 0);
 
-	/* Set physical address of "keep warm" page (16-byte aligned.) */
+	/* Set physical address of "keep warm" page (16-byte aligned). */
 	IWN_WRITE(sc, IWN_FH_KW_ADDR, sc->kw_dma.paddr >> 4);
 
 	/* Initialize TX rings. */
 	for (qid = 0; qid < hal->ntxqs; qid++) {
 		struct iwn_tx_ring *txq = &sc->txq[qid];
 
-		/* Set physical address of TX ring (256-byte aligned.) */
+		/* Set physical address of TX ring (256-byte aligned). */
 		IWN_WRITE(sc, IWN_FH_CBBC_QUEUE(qid),
 		    txq->desc_dma.paddr >> 8);
 	}

Modified: head/sys/dev/iwn/if_iwnvar.h
==============================================================================
--- head/sys/dev/iwn/if_iwnvar.h	Sat Apr 16 14:38:01 2011	(r220724)
+++ head/sys/dev/iwn/if_iwnvar.h	Sat Apr 16 14:38:57 2011	(r220725)
@@ -206,7 +206,6 @@ struct iwn_softc {
 	struct ifnet		*sc_ifp;
 	int			sc_debug;
 
-	/* Locks */
 	struct mtx		sc_mtx;
 
 	u_int			sc_flags;

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 14:40:42 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id C376E106564A;
	Sat, 16 Apr 2011 14:40:42 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id B08328FC13;
	Sat, 16 Apr 2011 14:40:42 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GEegta008328;
	Sat, 16 Apr 2011 14:40:42 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GEegmW008324;
	Sat, 16 Apr 2011 14:40:42 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161440.p3GEegmW008324@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 14:40:42 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220726 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 14:40:42 -0000

Author: bschmidt
Date: Sat Apr 16 14:40:42 2011
New Revision: 220726
URL: http://svn.freebsd.org/changeset/base/220726

Log:
  Just a whitespace sync, some more style(9) conform then others.

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnreg.h
  head/sys/dev/iwn/if_iwnvar.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:38:57 2011	(r220725)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:40:42 2011	(r220726)
@@ -161,13 +161,12 @@ static void	iwn_read_eeprom_band(struct 
 #if 0	/* HT */
 static void	iwn_read_eeprom_ht40(struct iwn_softc *, int);
 #endif
-static void	iwn_read_eeprom_channels(struct iwn_softc *, int,
-		    uint32_t);
+static void	iwn_read_eeprom_channels(struct iwn_softc *, int, uint32_t);
 static struct iwn_eeprom_chan *iwn_find_eeprom_channel(struct iwn_softc *,
 		    struct ieee80211_channel *);
 static int	iwn_setregdomain(struct ieee80211com *,
 		    struct ieee80211_regdomain *, int,
-		    struct ieee80211_channel []);
+		    struct ieee80211_channel[]);
 static void	iwn_read_eeprom_enhinfo(struct iwn_softc *);
 static struct ieee80211_node *iwn_node_alloc(struct ieee80211vap *,
 		    const uint8_t mac[IEEE80211_ADDR_LEN]);
@@ -269,10 +268,12 @@ static void	iwn_ampdu_tx_stop(struct iee
 		    struct ieee80211_node *, uint8_t);
 static void	iwn4965_ampdu_tx_start(struct iwn_softc *,
 		    struct ieee80211_node *, uint8_t, uint16_t);
-static void	iwn4965_ampdu_tx_stop(struct iwn_softc *, uint8_t, uint16_t);
+static void	iwn4965_ampdu_tx_stop(struct iwn_softc *,
+		    uint8_t, uint16_t);
 static void	iwn5000_ampdu_tx_start(struct iwn_softc *,
 		    struct ieee80211_node *, uint8_t, uint16_t);
-static void	iwn5000_ampdu_tx_stop(struct iwn_softc *, uint8_t, uint16_t);
+static void	iwn5000_ampdu_tx_stop(struct iwn_softc *,
+		    uint8_t, uint16_t);
 #endif
 static int	iwn5000_query_calibration(struct iwn_softc *);
 static int	iwn5000_send_calibration(struct iwn_softc *);
@@ -307,11 +308,11 @@ static void	iwn_init_locked(struct iwn_s
 static void	iwn_init(void *);
 static void	iwn_stop_locked(struct iwn_softc *);
 static void	iwn_stop(struct iwn_softc *);
-static void 	iwn_scan_start(struct ieee80211com *);
-static void 	iwn_scan_end(struct ieee80211com *);
-static void 	iwn_set_channel(struct ieee80211com *);
-static void 	iwn_scan_curchan(struct ieee80211_scan_state *, unsigned long);
-static void 	iwn_scan_mindwell(struct ieee80211_scan_state *);
+static void	iwn_scan_start(struct ieee80211com *);
+static void	iwn_scan_end(struct ieee80211com *);
+static void	iwn_set_channel(struct ieee80211com *);
+static void	iwn_scan_curchan(struct ieee80211_scan_state *, unsigned long);
+static void	iwn_scan_mindwell(struct ieee80211_scan_state *);
 static void	iwn_hw_reset(void *, int);
 
 #define IWN_DEBUG
@@ -399,11 +400,12 @@ static device_method_t iwn_methods[] = {
 static driver_t iwn_driver = {
 	"iwn",
 	iwn_methods,
-	sizeof (struct iwn_softc)
+	sizeof(struct iwn_softc)
 };
 static devclass_t iwn_devclass;
 
 DRIVER_MODULE(iwn, pci, iwn_driver, iwn_devclass, 0, 0);
+
 MODULE_DEPEND(iwn, firmware, 1, 1, 1);
 MODULE_DEPEND(iwn, pci, 1, 1, 1);
 MODULE_DEPEND(iwn, wlan, 1, 1, 1);
@@ -520,14 +522,14 @@ iwn_attach(device_t dev)
 	sc->mem_rid = PCIR_BAR(0);
 	sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid,
 	    RF_ACTIVE);
-	if (sc->mem == NULL ) {
+	if (sc->mem == NULL) {
 		device_printf(dev, "can't map mem space\n");
 		error = ENOMEM;
 		return error;
 	}
-
 	sc->sc_st = rman_get_bustag(sc->mem);
 	sc->sc_sh = rman_get_bushandle(sc->mem);
+
 	sc->irq_rid = 0;
 	if ((result = pci_msi_count(dev)) == 1 &&
 	    pci_alloc_msi(dev, &result) == 0)
@@ -550,15 +552,13 @@ iwn_attach(device_t dev)
 		goto fail;
 	}
 
-	error = iwn_hw_prepare(sc);
-	if (error != 0) {
+	if ((error = iwn_hw_prepare(sc)) != 0) {
 		device_printf(dev, "hardware not ready, error %d\n", error);
 		goto fail;
 	}
 
 	/* Allocate DMA memory for firmware transfers. */
-	error = iwn_alloc_fwmem(sc);
-	if (error != 0) {
+	if ((error = iwn_alloc_fwmem(sc)) != 0) {
 		device_printf(dev,
 		    "could not allocate memory for firmware, error %d\n",
 		    error);
@@ -566,8 +566,7 @@ iwn_attach(device_t dev)
 	}
 
 	/* Allocate "Keep Warm" page. */
-	error = iwn_alloc_kw(sc);
-	if (error != 0) {
+	if ((error = iwn_alloc_kw(sc)) != 0) {
 		device_printf(dev,
 		    "could not allocate keep warm page, error %d\n", error);
 		goto fail;
@@ -582,18 +581,15 @@ iwn_attach(device_t dev)
 	}
 
 	/* Allocate TX scheduler "rings". */
-	error = iwn_alloc_sched(sc);
-	if (error != 0) {
+	if ((error = iwn_alloc_sched(sc)) != 0) {
 		device_printf(dev,
-		    "could not allocate TX scheduler rings, error %d\n",
-		    error);
+		    "could not allocate TX scheduler rings, error %d\n", error);
 		goto fail;
 	}
 
 	/* Allocate TX rings (16 on 4965AGN, 20 on >=5000). */
 	for (i = 0; i < hal->ntxqs; i++) {
-		error = iwn_alloc_tx_ring(sc, &sc->txq[i], i);
-		if (error != 0) {
+		if ((error = iwn_alloc_tx_ring(sc, &sc->txq[i], i)) != 0) {
 			device_printf(dev,
 			    "could not allocate TX ring %d, error %d\n", i,
 			    error);
@@ -602,8 +598,7 @@ iwn_attach(device_t dev)
 	}
 
 	/* Allocate RX ring. */
-	error = iwn_alloc_rx_ring(sc, &sc->rxq);
-	if (error != 0 ){
+	if ((error = iwn_alloc_rx_ring(sc, &sc->rxq)) != 0) {
 		device_printf(dev, "could not allocate RX ring, error %d\n",
 		    error);
 		goto fail;
@@ -632,8 +627,8 @@ iwn_attach(device_t dev)
 		device_printf(dev, "can not allocate ifnet structure\n");
 		goto fail;
 	}
-	ic = ifp->if_l2com;
 
+	ic = ifp->if_l2com;
 	ic->ic_ifp = ifp;
 	ic->ic_phytype = IEEE80211_T_OFDM;	/* not only, but not used */
 	ic->ic_opmode = IEEE80211_M_STA;	/* default to BSS mode */
@@ -684,8 +679,7 @@ iwn_attach(device_t dev)
 #endif
 
 	/* Read MAC address, channels, etc from EEPROM. */
-	error = iwn_read_eeprom(sc, macaddr);
-	if (error != 0) {
+	if ((error = iwn_read_eeprom(sc, macaddr)) != 0) {
 		device_printf(dev, "could not read EEPROM, error %d\n",
 		    error);
 		goto fail;
@@ -735,9 +729,9 @@ iwn_attach(device_t dev)
 
 	callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0);
 	callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0);
-	TASK_INIT(&sc->sc_reinit_task, 0, iwn_hw_reset, sc );
-	TASK_INIT(&sc->sc_radioon_task, 0, iwn_radio_on, sc );
-	TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radio_off, sc );
+	TASK_INIT(&sc->sc_reinit_task, 0, iwn_hw_reset, sc);
+	TASK_INIT(&sc->sc_radioon_task, 0, iwn_radio_on, sc);
+	TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radio_off, sc);
 
 	iwn_sysctlattach(sc);
 
@@ -872,9 +866,9 @@ iwn_sysctlattach(struct iwn_softc *sc)
 
 static struct ieee80211vap *
 iwn_vap_create(struct ieee80211com *ic,
-	const char name[IFNAMSIZ], int unit, int opmode, int flags,
-	const uint8_t bssid[IEEE80211_ADDR_LEN],
-	const uint8_t mac[IEEE80211_ADDR_LEN])
+    const char name[IFNAMSIZ], int unit, int opmode, int flags,
+    const uint8_t bssid[IEEE80211_ADDR_LEN],
+    const uint8_t mac[IEEE80211_ADDR_LEN])
 {
 	struct iwn_vap *ivp;
 	struct ieee80211vap *vap;
@@ -1014,7 +1008,7 @@ iwn_nic_lock(struct iwn_softc *sc)
 	/* Spin until we actually get the lock. */
 	for (ntries = 0; ntries < 1000; ntries++) {
 		if ((IWN_READ(sc, IWN_GP_CNTRL) &
-		    (IWN_GP_CNTRL_MAC_ACCESS_ENA | IWN_GP_CNTRL_SLEEP)) ==
+		     (IWN_GP_CNTRL_MAC_ACCESS_ENA | IWN_GP_CNTRL_SLEEP)) ==
 		    IWN_GP_CNTRL_MAC_ACCESS_ENA)
 			return 0;
 		DELAY(10);
@@ -1147,12 +1141,10 @@ iwn_init_otprom(struct iwn_softc *sc)
 	int count, error;
 
 	/* Wait for clock stabilization before accessing prph. */
-	error = iwn_clock_wait(sc);
-	if (error != 0)
+	if ((error = iwn_clock_wait(sc)) != 0)
 		return error;
 
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
 	iwn_prph_setbits(sc, IWN_APMG_PS, IWN_APMG_PS_RESET_REQ);
 	DELAY(5);
@@ -1274,9 +1266,10 @@ iwn_dma_contig_alloc(struct iwn_softc *s
 
 	if (kvap != NULL)
 		*kvap = dma->vaddr;
+
 	return 0;
-fail:
-	iwn_dma_contig_free(dma);
+
+fail:	iwn_dma_contig_free(dma);
 	return error;
 }
 
@@ -1433,11 +1426,13 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, 
 		/* Set physical address of RX buffer (256-byte aligned). */
 		ring->desc[i] = htole32(paddr >> 8);
 	}
+
 	bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
 	    BUS_DMASYNC_PREWRITE);
+
 	return 0;
-fail:
-	iwn_free_rx_ring(sc, ring);
+
+fail:	iwn_free_rx_ring(sc, ring);
 	return error;
 }
 
@@ -1499,7 +1494,7 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 	ring->cur = 0;
 
 	/* Allocate TX descriptors (256-byte aligned). */
-	size = IWN_TX_RING_COUNT * sizeof(struct iwn_tx_desc);
+	size = IWN_TX_RING_COUNT * sizeof (struct iwn_tx_desc);
 	error = iwn_dma_contig_alloc(sc, &ring->desc_dma, (void **)&ring->desc,
 	    size, 256);
 	if (error != 0) {
@@ -1508,7 +1503,6 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 		    __func__, error);
 		goto fail;
 	}
-
 	/*
 	 * We only use rings 0 through 4 (4 EDCA + cmd) so there is no need
 	 * to allocate commands space for other rings.
@@ -1517,7 +1511,7 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 	if (qid > 4)
 		return 0;
 
-	size = IWN_TX_RING_COUNT * sizeof(struct iwn_tx_cmd);
+	size = IWN_TX_RING_COUNT * sizeof (struct iwn_tx_cmd);
 	error = iwn_dma_contig_alloc(sc, &ring->cmd_dma, (void **)&ring->cmd,
 	    size, 4);
 	if (error != 0) {
@@ -1528,9 +1522,9 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 	}
 
 	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
-	    BUS_SPACE_MAXADDR_32BIT,
-	    BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, IWN_MAX_SCATTER - 1,
-	    MCLBYTES, BUS_DMA_NOWAIT, NULL, NULL, &ring->data_dmat);
+	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES,
+	    IWN_MAX_SCATTER - 1, MCLBYTES, BUS_DMA_NOWAIT, NULL, NULL,
+	    &ring->data_dmat);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not create TX buf DMA tag, error %d\n",
@@ -1555,8 +1549,8 @@ iwn_alloc_tx_ring(struct iwn_softc *sc, 
 		}
 	}
 	return 0;
-fail:
-	iwn_free_tx_ring(sc, ring);
+
+fail:	iwn_free_tx_ring(sc, ring);
 	return error;
 }
 
@@ -1651,11 +1645,10 @@ iwn_read_eeprom(struct iwn_softc *sc, ui
 	    (sc->sc_flags & IWN_FLAG_HAS_OTPROM) ? "OTPROM" : "EEPROM");
 
 	/* Adapter has to be powered on for EEPROM access to work. */
-	error = iwn_apm_init(sc);
-	if (error != 0) {
+	if ((error = iwn_apm_init(sc)) != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not power ON adapter, error %d\n",
-		    __func__, error);
+		    "%s: could not power ON adapter, error %d\n", __func__,
+		    error);
 		return error;
 	}
 
@@ -1663,17 +1656,13 @@ iwn_read_eeprom(struct iwn_softc *sc, ui
 		device_printf(sc->sc_dev, "%s: bad ROM signature\n", __func__);
 		return EIO;
 	}
-	error = iwn_eeprom_lock(sc);
-	if (error != 0) {
-		device_printf(sc->sc_dev,
-		    "%s: could not lock ROM, error %d\n",
+	if ((error = iwn_eeprom_lock(sc)) != 0) {
+		device_printf(sc->sc_dev, "%s: could not lock ROM, error %d\n",
 		    __func__, error);
 		return error;
 	}
-
 	if (sc->sc_flags & IWN_FLAG_HAS_OTPROM) {
-		error = iwn_init_otprom(sc);
-		if (error != 0) {
+		if ((error = iwn_init_otprom(sc)) != 0) {
 			device_printf(sc->sc_dev,
 			    "%s: could not initialize OTPROM, error %d\n",
 			    __func__, error);
@@ -1808,8 +1797,8 @@ iwn5000_read_eeprom(struct iwn_softc *sc
 	base = le16toh(val);
 	iwn_read_prom_data(sc, base, &hdr, sizeof hdr);
 	DPRINTF(sc, IWN_DEBUG_CALIBRATE,
-	    "%s: calib version=%u pa type=%u voltage=%u\n",
-	    __func__, hdr.version, hdr.pa_type, le16toh(hdr.volt));
+	    "%s: calib version=%u pa type=%u voltage=%u\n", __func__,
+	    hdr.version, hdr.pa_type, le16toh(hdr.volt));
 	sc->calib_ver = hdr.version;
 
 	if (sc->hw_type == IWN_HW_REV_TYPE_5150) {
@@ -1880,18 +1869,14 @@ iwn_read_eeprom_band(struct iwn_softc *s
 		c->ic_maxpower = 2*c->ic_maxregpower;
 
 		if (n == 0) {	/* 2GHz band */
-			c->ic_freq = ieee80211_ieee2mhz(chan,
-			    IEEE80211_CHAN_G);
-
+			c->ic_freq = ieee80211_ieee2mhz(chan, IEEE80211_CHAN_G);
 			/* G =>'s B is supported */
 			c->ic_flags = IEEE80211_CHAN_B | nflags;
-
 			c = &ic->ic_channels[ic->ic_nchans++];
 			c[0] = c[-1];
 			c->ic_flags = IEEE80211_CHAN_G | nflags;
 		} else {	/* 5GHz band */
-			c->ic_freq = ieee80211_ieee2mhz(chan,
-			    IEEE80211_CHAN_A);
+			c->ic_freq = ieee80211_ieee2mhz(chan, IEEE80211_CHAN_A);
 			c->ic_flags = IEEE80211_CHAN_A | nflags;
 		}
 
@@ -1899,8 +1884,8 @@ iwn_read_eeprom_band(struct iwn_softc *s
 		sc->maxpwr[chan] = channels[i].maxpwr;
 
 		DPRINTF(sc, IWN_DEBUG_RESET,
-		    "add chan %d flags 0x%x maxpwr %d\n",
-		    chan, channels[i].flags, channels[i].maxpwr);
+		    "add chan %d flags 0x%x maxpwr %d\n", chan,
+		    channels[i].flags, channels[i].maxpwr);
 
 #if 0	/* HT */
 		/* XXX no constraints on using HT20 */
@@ -2092,7 +2077,9 @@ iwn_newassoc(struct ieee80211_node *ni, 
 static int
 iwn_media_change(struct ifnet *ifp)
 {
-	int error = ieee80211_media_change(ifp);
+	int error;
+
+	error = ieee80211_media_change(ifp);
 	/* NB: only the fixed rate can change and that doesn't need a reset */
 	return (error == ENETRESET ? 0 : error);
 }
@@ -2106,8 +2093,7 @@ iwn_newstate(struct ieee80211vap *vap, e
 	int error = 0;
 
 	DPRINTF(sc, IWN_DEBUG_STATE, "%s: %s -> %s\n", __func__,
-		ieee80211_state_name[vap->iv_state],
-		ieee80211_state_name[nstate]);
+	    ieee80211_state_name[vap->iv_state], ieee80211_state_name[nstate]);
 
 	IEEE80211_UNLOCK(ic);
 	IWN_LOCK(sc);
@@ -2360,11 +2346,11 @@ iwn_rx_done(struct iwn_softc *sc, struct
 
 	/* Send the frame to the 802.11 layer. */
 	if (ni != NULL) {
-		(void) ieee80211_input(ni, m, rssi - nf, nf);
+		(void)ieee80211_input(ni, m, rssi - nf, nf);
 		/* Node is no longer needed. */
 		ieee80211_free_node(ni);
 	} else
-		(void) ieee80211_input_all(ic, m, rssi - nf, nf);
+		(void)ieee80211_input_all(ic, m, rssi - nf, nf);
 
 	IWN_LOCK(sc);
 }
@@ -2876,13 +2862,12 @@ iwn_fatal_intr(struct iwn_softc *sc)
 	if (sc->errptr < IWN_FW_DATA_BASE ||
 	    sc->errptr + sizeof (dump) >
 	    IWN_FW_DATA_BASE + hal->fw_data_maxsz) {
-		printf("%s: bad firmware error log address 0x%08x\n",
-		    __func__, sc->errptr);
+		printf("%s: bad firmware error log address 0x%08x\n", __func__,
+		    sc->errptr);
 		return;
 	}
 	if (iwn_nic_lock(sc) != 0) {
-		printf("%s: could not read firmware error log\n",
-		    __func__);
+		printf("%s: could not read firmware error log\n", __func__);
 		return;
 	}
 	/* Read firmware error log from SRAM. */
@@ -2891,8 +2876,7 @@ iwn_fatal_intr(struct iwn_softc *sc)
 	iwn_nic_unlock(sc);
 
 	if (dump.valid == 0) {
-		printf("%s: firmware error log is empty\n",
-		    __func__);
+		printf("%s: firmware error log is empty\n", __func__);
 		return;
 	}
 	printf("firmware error log:\n");
@@ -3044,7 +3028,6 @@ iwn5000_update_sched(struct iwn_softc *s
 	uint16_t *w = &sc->sched[qid * IWN5000_SCHED_COUNT + idx];
 
 	*w = htole16(id << 12 | (len + 8));
-
 	bus_dmamap_sync(sc->sched_dma.tag, sc->sched_dma.map,
 	    BUS_DMASYNC_PREWRITE);
 	if (idx < IWN_SCHED_WINSZ) {
@@ -3227,7 +3210,6 @@ iwn_tx_data(struct iwn_softc *sc, struct
 		/* Tell HW to set timestamp in probe responses. */
 		if (subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP)
 			flags |= IWN_TX_INSERT_TSTAMP;
-
 		if (subtype == IEEE80211_FC0_SUBTYPE_ASSOC_REQ ||
 		    subtype == IEEE80211_FC0_SUBTYPE_REASSOC_REQ)
 			tx->timeout = htole16(3);
@@ -3260,7 +3242,6 @@ iwn_tx_data(struct iwn_softc *sc, struct
 		tx->linkq = ni->ni_rates.rs_nrates - ridx - 1;
 		flags |= IWN_TX_LINKQ;	/* enable MRR */
 	}
-
 	/* Set physical address of "scratch area". */
 	tx->loaddr = htole32(IWN_LOADDR(data->scratch_paddr));
 	tx->hiaddr = IWN_HIADDR(data->scratch_paddr);
@@ -3853,8 +3834,7 @@ iwn_add_broadcast_node(struct iwn_softc 
 	IEEE80211_ADDR_COPY(node.macaddr, ifp->if_broadcastaddr);
 	node.id = hal->broadcast_id;
 	DPRINTF(sc, IWN_DEBUG_RESET, "%s: adding broadcast node\n", __func__);
-	error = hal->add_node(sc, &node, async);
-	if (error != 0)
+	if ((error = hal->add_node(sc, &node, async)) != 0)
 		return error;
 
 	/* Use the first valid TX antenna. */
@@ -3953,8 +3933,7 @@ iwn_set_critical_temp(struct iwn_softc *
 		temp = 110;
 	memset(&crit, 0, sizeof crit);
 	crit.tempR = htole32(temp);
-	DPRINTF(sc, IWN_DEBUG_RESET, "setting critical temp to %d\n",
-	    temp);
+	DPRINTF(sc, IWN_DEBUG_RESET, "setting critical temp to %d\n", temp);
 	return iwn_cmd(sc, IWN_CMD_SET_CRITICAL_TEMP, &crit, sizeof crit, 0);
 }
 
@@ -4306,13 +4285,11 @@ iwn_init_sensitivity(struct iwn_softc *s
 	calib->energy_cck  = sc->limits->energy_cck;
 
 	/* Write initial sensitivity. */
-	error = iwn_send_sensitivity(sc);
-	if (error != 0)
+	if ((error = iwn_send_sensitivity(sc)) != 0)
 		return error;
 
 	/* Write initial gains. */
-	error = hal->init_gains(sc);
-	if (error != 0)
+	if ((error = hal->init_gains(sc)) != 0)
 		return error;
 
 	/* Request statistics at each beacon interval. */
@@ -4505,8 +4482,7 @@ iwn_tune_sensitivity(struct iwn_softc *s
 	int i, needs_update = 0;
 
 	/* Check that we've been enabled long enough. */
-	rxena = le32toh(stats->general.load);
-	if (rxena == 0)
+	if ((rxena = le32toh(stats->general.load)) == 0)
 		return;
 
 	/* Compute number of false alarms since last call for OFDM. */
@@ -4604,7 +4580,7 @@ iwn_tune_sensitivity(struct iwn_softc *s
 
 		if (calib->cck_state != IWN_CCK_STATE_INIT &&
 		    (((int32_t)calib->noise_ref - (int32_t)noise_ref) > 2 ||
-		    calib->low_fa > 100)) {
+		     calib->low_fa > 100)) {
 			inc(calib->energy_cck, 2, limits->min_energy_cck);
 			dec(calib->cck_x4,     3, limits->min_cck_x4);
 			dec(calib->cck_mrc_x4, 3, limits->min_cck_mrc_x4);
@@ -4638,19 +4614,19 @@ iwn_send_sensitivity(struct iwn_softc *s
 	memset(&cmd, 0, sizeof cmd);
 	cmd.which = IWN_SENSITIVITY_WORKTBL;
 	/* OFDM modulation. */
-	cmd.corr_ofdm_x1     = htole16(calib->ofdm_x1);
-	cmd.corr_ofdm_mrc_x1 = htole16(calib->ofdm_mrc_x1);
-	cmd.corr_ofdm_x4     = htole16(calib->ofdm_x4);
-	cmd.corr_ofdm_mrc_x4 = htole16(calib->ofdm_mrc_x4);
-	cmd.energy_ofdm      = htole16(sc->limits->energy_ofdm);
-	cmd.energy_ofdm_th   = htole16(62);
+	cmd.corr_ofdm_x1       = htole16(calib->ofdm_x1);
+	cmd.corr_ofdm_mrc_x1   = htole16(calib->ofdm_mrc_x1);
+	cmd.corr_ofdm_x4       = htole16(calib->ofdm_x4);
+	cmd.corr_ofdm_mrc_x4   = htole16(calib->ofdm_mrc_x4);
+	cmd.energy_ofdm        = htole16(sc->limits->energy_ofdm);
+	cmd.energy_ofdm_th     = htole16(62);
 	/* CCK modulation. */
-	cmd.corr_cck_x4      = htole16(calib->cck_x4);
-	cmd.corr_cck_mrc_x4  = htole16(calib->cck_mrc_x4);
-	cmd.energy_cck       = htole16(calib->energy_cck);
+	cmd.corr_cck_x4        = htole16(calib->cck_x4);
+	cmd.corr_cck_mrc_x4    = htole16(calib->cck_mrc_x4);
+	cmd.energy_cck         = htole16(calib->energy_cck);
 	/* Barker modulation: use default values. */
-	cmd.corr_barker      = htole16(190);
-	cmd.corr_barker_mrc  = htole16(390);
+	cmd.corr_barker        = htole16(190);
+	cmd.corr_barker_mrc    = htole16(390);
 
 	DPRINTF(sc, IWN_DEBUG_CALIBRATE,
 	    "%s: set sensitivity %d/%d/%d/%d/%d/%d/%d\n", __func__,
@@ -4808,36 +4784,32 @@ iwn_config(struct iwn_softc *sc)
 	DPRINTF(sc, IWN_DEBUG_RESET, "%s: setting configuration\n", __func__);
 	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, hal->rxonsz, 0);
 	if (error != 0) {
-		device_printf(sc->sc_dev,
-		    "%s: RXON command failed\n", __func__);
+		device_printf(sc->sc_dev, "%s: RXON command failed\n",
+		    __func__);
 		return error;
 	}
 
-	error = iwn_add_broadcast_node(sc, 0);
-	if (error != 0) {
-		device_printf(sc->sc_dev,
-		    "%s: could not add broadcast node\n", __func__);
+	if ((error = iwn_add_broadcast_node(sc, 0)) != 0) {
+		device_printf(sc->sc_dev, "%s: could not add broadcast node\n",
+		    __func__);
 		return error;
 	}
 
 	/* Configuration has changed, set TX power accordingly. */
-	error = hal->set_txpower(sc, ic->ic_curchan, 0);
-	if (error != 0) {
-		device_printf(sc->sc_dev,
-		    "%s: could not set TX power\n", __func__);
+	if ((error = hal->set_txpower(sc, ic->ic_curchan, 0)) != 0) {
+		device_printf(sc->sc_dev, "%s: could not set TX power\n",
+		    __func__);
 		return error;
 	}
 
-	error = iwn_set_critical_temp(sc);
-	if (error != 0) {
+	if ((error = iwn_set_critical_temp(sc)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not set critical temperature\n", __func__);
 		return error;
 	}
 
 	/* Set power saving level to CAM during initialization. */
-	error = iwn_set_pslevel(sc, 0, 0, 0);
-	if (error != 0) {
+	if ((error = iwn_set_pslevel(sc, 0, 0, 0)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not set power saving level\n", __func__);
 		return error;
@@ -4870,8 +4842,9 @@ iwn_scan(struct iwn_softc *sc)
 	struct ieee80211_frame *wh;
 	struct ieee80211_rateset *rs;
 	struct ieee80211_channel *c;
-	uint8_t *buf, *frm, txant;
+	uint8_t *buf, *frm;
 	uint16_t rxchain;
+	uint8_t txant;
 	int buflen, error;
 
 	buf = malloc(IWN_SCAN_MAXSZ, M_DEVBUF, M_NOWAIT | M_ZERO);
@@ -4882,7 +4855,6 @@ iwn_scan(struct iwn_softc *sc)
 		return ENOMEM;
 	}
 	hdr = (struct iwn_scan_hdr *)buf;
-
 	/*
 	 * Move to the next channel if no frames are received within 10ms
 	 * after sending the probe request.
@@ -4930,7 +4902,6 @@ iwn_scan(struct iwn_softc *sc)
 		essid[0].len = ss->ss_ssid[0].len;
 		memcpy(essid[0].data, ss->ss_ssid[0].ssid, ss->ss_ssid[0].len);
 	}
-
 	/*
 	 * Build a probe request frame.  Most of the following code is a
 	 * copy & paste of what is done in net80211.
@@ -5047,14 +5018,13 @@ iwn_auth(struct iwn_softc *sc, struct ie
 	    sc->rxon.ofdm_mask);
 	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, hal->rxonsz, 1);
 	if (error != 0) {
-		device_printf(sc->sc_dev,
-		    "%s: RXON command failed, error %d\n", __func__, error);
+		device_printf(sc->sc_dev, "%s: RXON command failed, error %d\n",
+		    __func__, error);
 		return error;
 	}
 
 	/* Configuration has changed, set TX power accordingly. */
-	error = hal->set_txpower(sc, ni->ni_chan, 1);
-	if (error != 0) {
+	if ((error = hal->set_txpower(sc, ni->ni_chan, 1)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not set TX power, error %d\n", __func__, error);
 		return error;
@@ -5063,11 +5033,10 @@ iwn_auth(struct iwn_softc *sc, struct ie
 	 * Reconfiguring RXON clears the firmware nodes table so we must
 	 * add the broadcast node again.
 	 */
-	error = iwn_add_broadcast_node(sc, 1);
-	if (error != 0) {
+	if ((error = iwn_add_broadcast_node(sc, 1)) != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not add broadcast node, error %d\n",
-		    __func__, error);
+		    "%s: could not add broadcast node, error %d\n", __func__,
+		    error);
 		return error;
 	}
 	return 0;
@@ -5089,8 +5058,7 @@ iwn_run(struct iwn_softc *sc, struct iee
 		iwn_set_led(sc, IWN_LED_LINK, 5, 5);
 		return 0;
 	}
-	error = iwn_set_timing(sc, ni);
-	if (error != 0) {
+	if ((error = iwn_set_timing(sc, ni)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not set timing, error %d\n", __func__, error);
 		return error;
@@ -5144,14 +5112,13 @@ iwn_run(struct iwn_softc *sc, struct iee
 	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, hal->rxonsz, 1);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not update configuration, error %d\n",
-		    __func__, error);
+		    "%s: could not update configuration, error %d\n", __func__,
+		    error);
 		return error;
 	}
 
 	/* Configuration has changed, set TX power accordingly. */
-	error = hal->set_txpower(sc, ni->ni_chan, 1);
-	if (error != 0) {
+	if ((error = hal->set_txpower(sc, ni->ni_chan, 1)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not set TX power, error %d\n", __func__, error);
 		return error;
@@ -5178,22 +5145,19 @@ iwn_run(struct iwn_softc *sc, struct iee
 	}
 	DPRINTF(sc, IWN_DEBUG_STATE, "%s: setting link quality for node %d\n",
 	    __func__, node.id);
-	error = iwn_set_link_quality(sc, ni);
-	if (error != 0) {
+	if ((error = iwn_set_link_quality(sc, ni)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not setup link quality for node %d, error %d\n",
 		    __func__, node.id, error);
 		return error;
 	}
 
-	error = iwn_init_sensitivity(sc);
-	if (error != 0) {
+	if ((error = iwn_init_sensitivity(sc)) != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not set sensitivity, error %d\n",
-		    __func__, error);
+		    "%s: could not set sensitivity, error %d\n", __func__,
+		    error);
 		return error;
 	}
-
 	/* Start periodic calibration timer. */
 	sc->calib.state = IWN_CALIB_STATE_ASSOC;
 	sc->calib_cnt = 0;
@@ -5202,7 +5166,6 @@ iwn_run(struct iwn_softc *sc, struct iee
 
 	/* Link LED always on while associated. */
 	iwn_set_led(sc, IWN_LED_LINK, 0, 1);
-
 	return 0;
 #undef MS
 }
@@ -5292,10 +5255,8 @@ iwn_ampdu_tx_stop(struct ieee80211com *i
 {
 	struct ieee80211_tx_ba *ba = &ni->ni_tx_ba[tid];
 	struct iwn_softc *sc = ic->ic_softc;
-	int error;
 
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if (iwn_nic_lock(sc) != 0)
 		return;
 	sc->sc_hal->ampdu_tx_stop(sc, tid, ba->ba_winstart);
 	iwn_nic_unlock(sc);
@@ -5602,8 +5563,7 @@ iwn5000_post_alive(struct iwn_softc *sc)
 	/* Switch to using ICT interrupt mode. */
 	iwn5000_ict_reset(sc);
 
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
 
 	/* Clear TX scheduler state in SRAM. */
@@ -5671,7 +5631,6 @@ iwn5000_post_alive(struct iwn_softc *sc)
 			    __func__, error);
 			return error;
 		}
-
 		/*
 		 * We have the calibration results now, reboot with the
 		 * runtime firmware (call ourselves recursively!)
@@ -5696,8 +5655,7 @@ iwn4965_load_bootcode(struct iwn_softc *
 
 	size /= sizeof (uint32_t);
 
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
 
 	/* Copy microcode image into NIC memory. */
@@ -5747,8 +5705,7 @@ iwn4965_load_firmware(struct iwn_softc *
 	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
 
 	/* Tell adapter where to find initialization sections. */
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
 	iwn_prph_write(sc, IWN_BSM_DRAM_DATA_ADDR, dma->paddr >> 4);
 	iwn_prph_write(sc, IWN_BSM_DRAM_DATA_SIZE, fw->init.datasz);
@@ -5768,8 +5725,7 @@ iwn4965_load_firmware(struct iwn_softc *
 	IWN_WRITE(sc, IWN_RESET, 0);
 
 	/* Wait at most one second for first alive notification. */
-	error = msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", hz);
-	if (error) {
+	if ((error = msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", hz)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: timeout waiting for adapter to initialize, error %d\n",
 		    __func__, error);
@@ -5788,10 +5744,8 @@ iwn4965_load_firmware(struct iwn_softc *
 	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
 
 	/* Tell adapter where to find runtime sections. */
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
-
 	iwn_prph_write(sc, IWN_BSM_DRAM_DATA_ADDR, dma->paddr >> 4);
 	iwn_prph_write(sc, IWN_BSM_DRAM_DATA_SIZE, fw->main.datasz);
 	iwn_prph_write(sc, IWN_BSM_DRAM_TEXT_ADDR,
@@ -5814,8 +5768,7 @@ iwn5000_load_firmware_section(struct iwn
 	memcpy(dma->vaddr, section, size);
 	bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
 
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
 
 	IWN_WRITE(sc, IWN_FH_TX_CONFIG(IWN_SRVC_DMACHNL),
@@ -5922,7 +5875,6 @@ iwn_read_firmware_leg(struct iwn_softc *
 	fw->init.text = fw->main.data + fw->main.datasz;
 	fw->init.data = fw->init.text + fw->init.textsz;
 	fw->boot.text = fw->init.data + fw->init.datasz;
-
 	return 0;
 }
 
@@ -6007,7 +5959,7 @@ iwn_read_firmware_tlv(struct iwn_softc *
 			    "TLV type %d not handled\n", le16toh(tlv->type));
 			break;
 		}
-next:		/* TLV fields are 32-bit aligned. */
+ next:		/* TLV fields are 32-bit aligned. */
 		ptr += (len + 3) & ~3;
 	}
 	return 0;
@@ -6125,14 +6077,11 @@ iwn_apm_init(struct iwn_softc *sc)
 		IWN_SETBITS(sc, IWN_ANA_PLL, IWN_ANA_PLL_INIT);
 
 	/* Wait for clock stabilization before accessing prph. */
-	error = iwn_clock_wait(sc);
-	if (error != 0)
+	if ((error = iwn_clock_wait(sc)) != 0)
 		return error;
 
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
-
 	if (sc->hw_type == IWN_HW_REV_TYPE_4965) {
 		/* Enable DMA and BSM (Bootstrap State Machine). */
 		iwn_prph_write(sc, IWN_APMG_CLK_EN,
@@ -6144,7 +6093,6 @@ iwn_apm_init(struct iwn_softc *sc)
 		    IWN_APMG_CLK_CTRL_DMA_CLK_RQT);
 	}
 	DELAY(20);
-
 	/* Disable L1-Active. */
 	iwn_prph_setbits(sc, IWN_APMG_PCI_STT, IWN_APMG_PCI_STT_L1A_DIS);
 	iwn_nic_unlock(sc);
@@ -6164,8 +6112,7 @@ iwn_apm_stop_master(struct iwn_softc *sc
 			return;
 		DELAY(10);
 	}
-	device_printf(sc->sc_dev, "%s: timeout waiting for master\n",
-	    __func__);
+	device_printf(sc->sc_dev, "%s: timeout waiting for master\n", __func__);
 }
 
 static void
@@ -6214,8 +6161,7 @@ iwn5000_nic_config(struct iwn_softc *sc)
 	IWN_SETBITS(sc, IWN_HW_IF_CONFIG,
 	    IWN_HW_IF_CONFIG_RADIO_SI | IWN_HW_IF_CONFIG_MAC_SI);
 
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
 	iwn_prph_setbits(sc, IWN_APMG_PS, IWN_APMG_PS_EARLY_PWROFF_DIS);
 
@@ -6292,29 +6238,25 @@ iwn_hw_init(struct iwn_softc *sc)
 	/* Clear pending interrupts. */
 	IWN_WRITE(sc, IWN_INT, 0xffffffff);
 
-	error = iwn_apm_init(sc);
-	if (error != 0) {
+	if ((error = iwn_apm_init(sc)) != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not power ON adapter, error %d\n",
-		    __func__, error);
+		    "%s: could not power ON adapter, error %d\n", __func__,
+		    error);
 		return error;
 	}
 
 	/* Select VMAIN power source. */
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
 	iwn_prph_clrbits(sc, IWN_APMG_PS, IWN_APMG_PS_PWR_SRC_MASK);
 	iwn_nic_unlock(sc);
 
 	/* Perform adapter-specific initialization. */
-	error = hal->nic_config(sc);
-	if (error != 0)
+	if ((error = hal->nic_config(sc)) != 0)
 		return error;
 
 	/* Initialize RX ring. */
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
 	IWN_WRITE(sc, IWN_FH_RX_CONFIG, 0);
 	IWN_WRITE(sc, IWN_FH_RX_WPTR, 0);
@@ -6333,8 +6275,7 @@ iwn_hw_init(struct iwn_softc *sc)
 	iwn_nic_unlock(sc);
 	IWN_WRITE(sc, IWN_FH_RX_WPTR, (IWN_RX_RING_COUNT - 1) & ~7);
 
-	error = iwn_nic_lock(sc);
-	if (error != 0)
+	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
 
 	/* Initialize TX scheduler. */
@@ -6375,16 +6316,14 @@ iwn_hw_init(struct iwn_softc *sc)
 	IWN_WRITE(sc, IWN_UCODE_GP1_CLR, IWN_UCODE_GP1_RFKILL);
 	IWN_WRITE(sc, IWN_UCODE_GP1_CLR, IWN_UCODE_GP1_RFKILL);
 
-	error = hal->load_firmware(sc);
-	if (error != 0) {
+	if ((error = hal->load_firmware(sc)) != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not load firmware, error %d\n",
-		    __func__, error);
+		    "%s: could not load firmware, error %d\n", __func__,
+		    error);
 		return error;
 	}
 	/* Wait at most one second for firmware alive notification. */
-	error = msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", hz);
-	if (error != 0) {
+	if ((error = msleep(sc, &sc->sc_mtx, PCATCH, "iwninit", hz)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: timeout waiting for adapter to initialize, error %d\n",
 		    __func__, error);
@@ -6441,7 +6380,6 @@ iwn_hw_stop(struct iwn_softc *sc)
 		iwn_nic_unlock(sc);
 	}
 	DELAY(5);
-
 	/* Power OFF adapter. */
 	iwn_apm_stop(sc);
 }
@@ -6487,8 +6425,7 @@ iwn_init_locked(struct iwn_softc *sc)
 
 	IWN_LOCK_ASSERT(sc);
 
-	error = iwn_hw_prepare(sc);
-	if (error != 0) {
+	if ((error = iwn_hw_prepare(sc)) != 0) {
 		device_printf(sc->sc_dev, "%s: hardware not ready, error %d\n",
 		    __func__, error);
 		goto fail;
@@ -6502,7 +6439,6 @@ iwn_init_locked(struct iwn_softc *sc)
 	if (!(IWN_READ(sc, IWN_GP_CNTRL) & IWN_GP_CNTRL_RFKILL)) {
 		device_printf(sc->sc_dev,
 		    "radio is disabled by hardware switch\n");
-
 		/* Enable interrupts to get RF toggle notifications. */
 		IWN_WRITE(sc, IWN_INT, 0xffffffff);
 		IWN_WRITE(sc, IWN_INT_MASK, sc->int_mask);
@@ -6510,11 +6446,10 @@ iwn_init_locked(struct iwn_softc *sc)
 	}
 
 	/* Read firmware images from the filesystem. */
-	error = iwn_read_firmware(sc);
-	if (error != 0) {
+	if ((error = iwn_read_firmware(sc)) != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not read firmware, error %d\n",
-		    __func__, error);
+		    "%s: could not read firmware, error %d\n", __func__,
+		    error);
 		goto fail;
 	}
 
@@ -6524,17 +6459,16 @@ iwn_init_locked(struct iwn_softc *sc)
 	sc->fw_fp = NULL;
 	if (error != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not initialize hardware, error %d\n",
-		    __func__, error);
+		    "%s: could not initialize hardware, error %d\n", __func__,
+		    error);
 		goto fail;
 	}
 
 	/* Configure adapter now that it is ready. */
-	error = iwn_config(sc);
-	if (error != 0) {
+	if ((error = iwn_config(sc)) != 0) {
 		device_printf(sc->sc_dev,
-		    "%s: could not configure device, error %d\n",
-		    __func__, error);
+		    "%s: could not configure device, error %d\n", __func__,
+		    error);
 		goto fail;
 	}
 
@@ -6544,8 +6478,7 @@ iwn_init_locked(struct iwn_softc *sc)
 	callout_reset(&sc->watchdog_to, hz, iwn_watchdog, sc);
 	return;
 
-fail:
-	iwn_stop_locked(sc);
+fail:	iwn_stop_locked(sc);
 }
 
 static void

Modified: head/sys/dev/iwn/if_iwnreg.h
==============================================================================
--- head/sys/dev/iwn/if_iwnreg.h	Sat Apr 16 14:38:57 2011	(r220725)
+++ head/sys/dev/iwn/if_iwnreg.h	Sat Apr 16 14:40:42 2011	(r220726)
@@ -79,10 +79,10 @@
 #define IWN_MEM_WADDR		0x410

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 14:49:29 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 985AA106566C;
	Sat, 16 Apr 2011 14:49:29 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 7C8F48FC17;
	Sat, 16 Apr 2011 14:49:29 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GEnTPw008533;
	Sat, 16 Apr 2011 14:49:29 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GEnT61008531;
	Sat, 16 Apr 2011 14:49:29 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161449.p3GEnT61008531@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 14:49:29 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220727 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 14:49:29 -0000

Author: bschmidt
Date: Sat Apr 16 14:49:29 2011
New Revision: 220727
URL: http://svn.freebsd.org/changeset/base/220727

Log:
  Read RX/TX chainmasks directly of the EEPROM. Some chips are known to
  have the wrong/broken information stored, keep the hardcoded values for
  those.
  
  Obtained from:	OpenBSD

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:40:42 2011	(r220726)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:49:29 2011	(r220727)
@@ -764,6 +764,7 @@ iwn_hal_attach(struct iwn_softc *sc)
 		sc->sc_hal = &iwn4965_hal;
 		sc->limits = &iwn4965_sensitivity_limits;
 		sc->fwname = "iwn4965fw";
+		/* Override chains masks, ROM is known to be broken. */
 		sc->txchainmask = IWN_ANT_AB;
 		sc->rxchainmask = IWN_ANT_ABC;
 		break;
@@ -771,6 +772,7 @@ iwn_hal_attach(struct iwn_softc *sc)
 		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn5000_sensitivity_limits;
 		sc->fwname = "iwn5000fw";
+		/* Override chains masks, ROM is known to be broken. */
 		sc->txchainmask = IWN_ANT_B;
 		sc->rxchainmask = IWN_ANT_AB;
 		break;
@@ -778,23 +780,17 @@ iwn_hal_attach(struct iwn_softc *sc)
 		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn5150_sensitivity_limits;
 		sc->fwname = "iwn5150fw";
-		sc->txchainmask = IWN_ANT_A;
-		sc->rxchainmask = IWN_ANT_AB;
 		break;
 	case IWN_HW_REV_TYPE_5300:
 	case IWN_HW_REV_TYPE_5350:
 		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn5000_sensitivity_limits;
 		sc->fwname = "iwn5000fw";
-		sc->txchainmask = IWN_ANT_ABC;
-		sc->rxchainmask = IWN_ANT_ABC;
 		break;
 	case IWN_HW_REV_TYPE_1000:
 		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn1000_sensitivity_limits;
 		sc->fwname = "iwn1000fw";
-		sc->txchainmask = IWN_ANT_A;
-		sc->rxchainmask = IWN_ANT_AB;
 		break;
 	case IWN_HW_REV_TYPE_6000:
 		sc->sc_hal = &iwn5000_hal;
@@ -804,28 +800,21 @@ iwn_hal_attach(struct iwn_softc *sc)
 		case 0x422C:
 		case 0x4239:
 			sc->sc_flags |= IWN_FLAG_INTERNAL_PA;
+			/* Override chains masks, ROM is known to be broken. */
 			sc->txchainmask = IWN_ANT_BC;
 			sc->rxchainmask = IWN_ANT_BC;
 			break;
-		default:
-			sc->txchainmask = IWN_ANT_ABC;
-			sc->rxchainmask = IWN_ANT_ABC;
-			break;
 		}
 		break;
 	case IWN_HW_REV_TYPE_6050:
 		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn6000_sensitivity_limits;
 		sc->fwname = "iwn6050fw";
-		sc->txchainmask = IWN_ANT_AB;
-		sc->rxchainmask = IWN_ANT_AB;
 		break;
 	case IWN_HW_REV_TYPE_6005:
 		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn6000_sensitivity_limits;
 		sc->fwname = "iwn6005fw";
-		sc->txchainmask = IWN_ANT_AB;
-		sc->rxchainmask = IWN_ANT_AB;
 		break;
 	default:
 		device_printf(sc->sc_dev, "adapter type %d not supported\n",
@@ -1673,6 +1662,11 @@ iwn_read_eeprom(struct iwn_softc *sc, ui
 	iwn_read_prom_data(sc, IWN_EEPROM_RFCFG, &val, 2);
 	sc->rfcfg = le16toh(val);
 	DPRINTF(sc, IWN_DEBUG_RESET, "radio config=0x%04x\n", sc->rfcfg);
+	/* Read Tx/Rx chains from ROM unless it's known to be broken. */
+	if (sc->txchainmask == 0)
+		sc->txchainmask = IWN_RFCFG_TXANTMSK(sc->rfcfg);
+	if (sc->rxchainmask == 0)
+		sc->rxchainmask = IWN_RFCFG_RXANTMSK(sc->rfcfg);
 
 	/* Read MAC address. */
 	iwn_read_prom_data(sc, IWN_EEPROM_MAC, macaddr, 6);

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 14:51:46 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E0CA7106564A;
	Sat, 16 Apr 2011 14:51:46 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id CE5A78FC17;
	Sat, 16 Apr 2011 14:51:46 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GEpkwH008620;
	Sat, 16 Apr 2011 14:51:46 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GEpknY008617;
	Sat, 16 Apr 2011 14:51:46 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161451.p3GEpknY008617@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 14:51:46 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220728 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 14:51:47 -0000

Author: bschmidt
Date: Sat Apr 16 14:51:46 2011
New Revision: 220728
URL: http://svn.freebsd.org/changeset/base/220728

Log:
  Bring over the HAL/OPS changes, instead of two const structs it is now
  slightly more dynamic.
  
  Obtained from:	OpenBSD

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnvar.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:49:29 2011	(r220727)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:51:46 2011	(r220728)
@@ -115,7 +115,8 @@ static const struct iwn_ident iwn_ident_
 
 static int	iwn_probe(device_t);
 static int	iwn_attach(device_t);
-static const struct iwn_hal *iwn_hal_attach(struct iwn_softc *);
+static int	iwn4965_attach(struct iwn_softc *, uint16_t);
+static int	iwn5000_attach(struct iwn_softc *, uint16_t);
 static void	iwn_radiotap_attach(struct iwn_softc *);
 static void	iwn_sysctlattach(struct iwn_softc *);
 static struct ieee80211vap *iwn_vap_create(struct ieee80211com *,
@@ -410,62 +411,6 @@ MODULE_DEPEND(iwn, firmware, 1, 1, 1);
 MODULE_DEPEND(iwn, pci, 1, 1, 1);
 MODULE_DEPEND(iwn, wlan, 1, 1, 1);
 
-static const struct iwn_hal iwn4965_hal = {
-	iwn4965_load_firmware,
-	iwn4965_read_eeprom,
-	iwn4965_post_alive,
-	iwn4965_nic_config,
-	iwn4965_update_sched,
-	iwn4965_get_temperature,
-	iwn4965_get_rssi,
-	iwn4965_set_txpower,
-	iwn4965_init_gains,
-	iwn4965_set_gains,
-	iwn4965_add_node,
-	iwn4965_tx_done,
-#if 0	/* HT */
-	iwn4965_ampdu_tx_start,
-	iwn4965_ampdu_tx_stop,
-#endif
-	IWN4965_NTXQUEUES,
-	IWN4965_NDMACHNLS,
-	IWN4965_ID_BROADCAST,
-	IWN4965_RXONSZ,
-	IWN4965_SCHEDSZ,
-	IWN4965_FW_TEXT_MAXSZ,
-	IWN4965_FW_DATA_MAXSZ,
-	IWN4965_FWSZ,
-	IWN4965_SCHED_TXFACT
-};
-
-static const struct iwn_hal iwn5000_hal = {
-	iwn5000_load_firmware,
-	iwn5000_read_eeprom,
-	iwn5000_post_alive,
-	iwn5000_nic_config,
-	iwn5000_update_sched,
-	iwn5000_get_temperature,
-	iwn5000_get_rssi,
-	iwn5000_set_txpower,
-	iwn5000_init_gains,
-	iwn5000_set_gains,
-	iwn5000_add_node,
-	iwn5000_tx_done,
-#if 0	/* HT */
-	iwn5000_ampdu_tx_start,
-	iwn5000_ampdu_tx_stop,
-#endif
-	IWN5000_NTXQUEUES,
-	IWN5000_NDMACHNLS,
-	IWN5000_ID_BROADCAST,
-	IWN5000_RXONSZ,
-	IWN5000_SCHEDSZ,
-	IWN5000_FW_TEXT_MAXSZ,
-	IWN5000_FW_DATA_MAXSZ,
-	IWN5000_FWSZ,
-	IWN5000_SCHED_TXFACT
-};
-
 static int
 iwn_probe(device_t dev)
 {
@@ -487,7 +432,6 @@ iwn_attach(device_t dev)
 	struct iwn_softc *sc = (struct iwn_softc *)device_get_softc(dev);
 	struct ieee80211com *ic;
 	struct ifnet *ifp;
-	const struct iwn_hal *hal;
 	uint32_t reg;
 	int i, error, result;
 	uint8_t macaddr[IEEE80211_ADDR_LEN];
@@ -545,10 +489,15 @@ iwn_attach(device_t dev)
 
 	IWN_LOCK_INIT(sc);
 
-	/* Attach Hardware Abstraction Layer. */
-	hal = iwn_hal_attach(sc);
-	if (hal == NULL) {
-		error = ENXIO;	/* XXX: Wrong error code? */
+	/* Read hardware revision and attach. */
+	sc->hw_type = (IWN_READ(sc, IWN_HW_REV) >> 4) & 0xf;
+	if (sc->hw_type == IWN_HW_REV_TYPE_4965)
+		error = iwn4965_attach(sc, pci_get_device(dev));
+	else
+		error = iwn5000_attach(sc, pci_get_device(dev));
+	if (error != 0) {
+		device_printf(dev, "could not attach device, error %d\n",
+		    error);
 		goto fail;
 	}
 
@@ -588,7 +537,7 @@ iwn_attach(device_t dev)
 	}
 
 	/* Allocate TX rings (16 on 4965AGN, 20 on >=5000). */
-	for (i = 0; i < hal->ntxqs; i++) {
+	for (i = 0; i < sc->ntxqs; i++) {
 		if ((error = iwn_alloc_tx_ring(sc, &sc->txq[i], i)) != 0) {
 			device_printf(dev,
 			    "could not allocate TX ring %d, error %d\n", i,
@@ -754,22 +703,78 @@ fail:
 	return error;
 }
 
-static const struct iwn_hal *
-iwn_hal_attach(struct iwn_softc *sc)
+static int
+iwn4965_attach(struct iwn_softc *sc, uint16_t pid)
 {
-	sc->hw_type = (IWN_READ(sc, IWN_HW_REV) >> 4) & 0xf;
+	struct iwn_ops *ops = &sc->ops;
+
+	ops->load_firmware = iwn4965_load_firmware;
+	ops->read_eeprom = iwn4965_read_eeprom;
+	ops->post_alive = iwn4965_post_alive;
+	ops->nic_config = iwn4965_nic_config;
+	ops->update_sched = iwn4965_update_sched;
+	ops->get_temperature = iwn4965_get_temperature;
+	ops->get_rssi = iwn4965_get_rssi;
+	ops->set_txpower = iwn4965_set_txpower;
+	ops->init_gains = iwn4965_init_gains;
+	ops->set_gains = iwn4965_set_gains;
+	ops->add_node = iwn4965_add_node;
+	ops->tx_done = iwn4965_tx_done;
+#if 0	/* HT */
+	ops->ampdu_tx_start = iwn4965_ampdu_tx_start;
+	ops->ampdu_tx_stop = iwn4965_ampdu_tx_stop;
+#endif
+	sc->ntxqs = IWN4965_NTXQUEUES;
+	sc->ndmachnls = IWN4965_NDMACHNLS;
+	sc->broadcast_id = IWN4965_ID_BROADCAST;
+	sc->rxonsz = IWN4965_RXONSZ;
+	sc->schedsz = IWN4965_SCHEDSZ;
+	sc->fw_text_maxsz = IWN4965_FW_TEXT_MAXSZ;
+	sc->fw_data_maxsz = IWN4965_FW_DATA_MAXSZ;
+	sc->fwsz = IWN4965_FWSZ;
+	sc->sched_txfact_addr = IWN4965_SCHED_TXFACT;
+	sc->limits = &iwn4965_sensitivity_limits;
+	sc->fwname = "iwn4965fw";
+	/* Override chains masks, ROM is known to be broken. */
+	sc->txchainmask = IWN_ANT_AB;
+	sc->rxchainmask = IWN_ANT_ABC;
+
+	return 0;
+}
+
+static int
+iwn5000_attach(struct iwn_softc *sc, uint16_t pid)
+{
+	struct iwn_ops *ops = &sc->ops;
+
+	ops->load_firmware = iwn5000_load_firmware;
+	ops->read_eeprom = iwn5000_read_eeprom;
+	ops->post_alive = iwn5000_post_alive;
+	ops->nic_config = iwn5000_nic_config;
+	ops->update_sched = iwn5000_update_sched;
+	ops->get_temperature = iwn5000_get_temperature;
+	ops->get_rssi = iwn5000_get_rssi;
+	ops->set_txpower = iwn5000_set_txpower;
+	ops->init_gains = iwn5000_init_gains;
+	ops->set_gains = iwn5000_set_gains;
+	ops->add_node = iwn5000_add_node;
+	ops->tx_done = iwn5000_tx_done;
+#if 0	/* HT */
+	ops->ampdu_tx_start = iwn5000_ampdu_tx_start;
+	ops->ampdu_tx_stop = iwn5000_ampdu_tx_stop;
+#endif
+	sc->ntxqs = IWN5000_NTXQUEUES;
+	sc->ndmachnls = IWN5000_NDMACHNLS;
+	sc->broadcast_id = IWN5000_ID_BROADCAST;
+	sc->rxonsz = IWN5000_RXONSZ;
+	sc->schedsz = IWN5000_SCHEDSZ;
+	sc->fw_text_maxsz = IWN5000_FW_TEXT_MAXSZ;
+	sc->fw_data_maxsz = IWN5000_FW_DATA_MAXSZ;
+	sc->fwsz = IWN5000_FWSZ;
+	sc->sched_txfact_addr = IWN5000_SCHED_TXFACT;
 
 	switch (sc->hw_type) {
-	case IWN_HW_REV_TYPE_4965:
-		sc->sc_hal = &iwn4965_hal;
-		sc->limits = &iwn4965_sensitivity_limits;
-		sc->fwname = "iwn4965fw";
-		/* Override chains masks, ROM is known to be broken. */
-		sc->txchainmask = IWN_ANT_AB;
-		sc->rxchainmask = IWN_ANT_ABC;
-		break;
 	case IWN_HW_REV_TYPE_5100:
-		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn5000_sensitivity_limits;
 		sc->fwname = "iwn5000fw";
 		/* Override chains masks, ROM is known to be broken. */
@@ -777,51 +782,42 @@ iwn_hal_attach(struct iwn_softc *sc)
 		sc->rxchainmask = IWN_ANT_AB;
 		break;
 	case IWN_HW_REV_TYPE_5150:
-		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn5150_sensitivity_limits;
 		sc->fwname = "iwn5150fw";
 		break;
 	case IWN_HW_REV_TYPE_5300:
 	case IWN_HW_REV_TYPE_5350:
-		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn5000_sensitivity_limits;
 		sc->fwname = "iwn5000fw";
 		break;
 	case IWN_HW_REV_TYPE_1000:
-		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn1000_sensitivity_limits;
 		sc->fwname = "iwn1000fw";
 		break;
 	case IWN_HW_REV_TYPE_6000:
-		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn6000_sensitivity_limits;
 		sc->fwname = "iwn6000fw";
-		switch (pci_get_device(sc->sc_dev)) {
-		case 0x422C:
-		case 0x4239:
+		if (pid == 0x422c || pid == 0x4239) {
 			sc->sc_flags |= IWN_FLAG_INTERNAL_PA;
 			/* Override chains masks, ROM is known to be broken. */
 			sc->txchainmask = IWN_ANT_BC;
 			sc->rxchainmask = IWN_ANT_BC;
-			break;
 		}
 		break;
 	case IWN_HW_REV_TYPE_6050:
-		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn6000_sensitivity_limits;
 		sc->fwname = "iwn6050fw";
 		break;
 	case IWN_HW_REV_TYPE_6005:
-		sc->sc_hal = &iwn5000_hal;
 		sc->limits = &iwn6000_sensitivity_limits;
 		sc->fwname = "iwn6005fw";
 		break;
 	default:
 		device_printf(sc->sc_dev, "adapter type %d not supported\n",
 		    sc->hw_type);
-		return NULL;
+		return ENOTSUP;
 	}
-	return sc->sc_hal;
+	return 0;
 }
 
 /*
@@ -923,9 +919,8 @@ iwn_detach(device_t dev)
 
 	/* Free DMA resources. */
 	iwn_free_rx_ring(sc, &sc->rxq);
-	if (sc->sc_hal != NULL)
-		for (qid = 0; qid < sc->sc_hal->ntxqs; qid++)
-			iwn_free_tx_ring(sc, &sc->txq[qid]);
+	for (qid = 0; qid < sc->ntxqs; qid++)
+		iwn_free_tx_ring(sc, &sc->txq[qid]);
 	iwn_free_sched(sc);
 	iwn_free_kw(sc);
 	if (sc->ict != NULL)
@@ -1287,7 +1282,7 @@ iwn_alloc_sched(struct iwn_softc *sc)
 {
 	/* TX scheduler rings must be aligned on a 1KB boundary. */
 	return iwn_dma_contig_alloc(sc, &sc->sched_dma, (void **)&sc->sched,
-	    sc->sc_hal->schedsz, 1024);
+	    sc->schedsz, 1024);
 }
 
 static void
@@ -1327,8 +1322,7 @@ static int
 iwn_alloc_fwmem(struct iwn_softc *sc)
 {
 	/* Must be aligned on a 16-byte boundary. */
-	return iwn_dma_contig_alloc(sc, &sc->fw_dma, NULL, sc->sc_hal->fwsz,
-	    16);
+	return iwn_dma_contig_alloc(sc, &sc->fw_dma, NULL, sc->fwsz, 16);
 }
 
 static void
@@ -1622,7 +1616,7 @@ iwn5000_ict_reset(struct iwn_softc *sc)
 static int
 iwn_read_eeprom(struct iwn_softc *sc, uint8_t macaddr[IEEE80211_ADDR_LEN])
 {
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	uint16_t val;
 	int error;
 
@@ -1672,7 +1666,7 @@ iwn_read_eeprom(struct iwn_softc *sc, ui
 	iwn_read_prom_data(sc, IWN_EEPROM_MAC, macaddr, 6);
 
 	/* Read adapter-specific information from EEPROM. */
-	hal->read_eeprom(sc);
+	ops->read_eeprom(sc);
 
 	iwn_apm_stop(sc);	/* Power OFF adapter. */
 
@@ -2197,7 +2191,7 @@ static void
 iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
     struct iwn_rx_data *data)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct iwn_rx_ring *ring = &sc->rxq;
@@ -2305,7 +2299,7 @@ iwn_rx_done(struct iwn_softc *sc, struct
 	nf = (ni != NULL && ni->ni_vap->iv_state == IEEE80211_S_RUN &&
 	    (ic->ic_flags & IEEE80211_F_SCAN) == 0) ? sc->noise : -95;
 
-	rssi = hal->get_rssi(sc, stat);
+	rssi = ops->get_rssi(sc, stat);
 
 	if (ieee80211_radiotap_active(ic)) {
 		struct iwn_rx_radiotap_header *tap = &sc->sc_rxtap;
@@ -2430,7 +2424,7 @@ static void
 iwn_rx_statistics(struct iwn_softc *sc, struct iwn_rx_desc *desc,
     struct iwn_rx_data *data)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
@@ -2453,7 +2447,7 @@ iwn_rx_statistics(struct iwn_softc *sc, 
 	if (stats->general.temp != sc->rawtemp) {
 		/* Convert "raw" temperature to degC. */
 		sc->rawtemp = stats->general.temp;
-		temp = hal->get_temperature(sc);
+		temp = ops->get_temperature(sc);
 		DPRINTF(sc, IWN_DEBUG_CALIBRATE, "%s: temperature %d\n",
 		    __func__, temp);
 
@@ -2628,6 +2622,7 @@ iwn_cmd_done(struct iwn_softc *sc, struc
 static void
 iwn_notif_intr(struct iwn_softc *sc)
 {
+	struct iwn_ops *ops = &sc->ops;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
@@ -2674,7 +2669,7 @@ iwn_notif_intr(struct iwn_softc *sc)
 
 		case IWN_TX_DONE:
 			/* An 802.11 frame has been transmitted. */
-			sc->sc_hal->tx_done(sc, desc, data);
+			ops->tx_done(sc, desc, data);
 			break;
 
 		case IWN_RX_STATISTICS:
@@ -2812,7 +2807,7 @@ iwn_wakeup_intr(struct iwn_softc *sc)
 
 	/* Wakeup RX and TX rings. */
 	IWN_WRITE(sc, IWN_FH_RX_WPTR, sc->rxq.cur & ~7);
-	for (qid = 0; qid < sc->sc_hal->ntxqs; qid++) {
+	for (qid = 0; qid < sc->ntxqs; qid++) {
 		struct iwn_tx_ring *ring = &sc->txq[qid];
 		IWN_WRITE(sc, IWN_HBUS_TARG_WRPTR, qid << 8 | ring->cur);
 	}
@@ -2843,7 +2838,6 @@ iwn_rftoggle_intr(struct iwn_softc *sc)
 static void
 iwn_fatal_intr(struct iwn_softc *sc)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
 	struct iwn_fw_dump dump;
 	int i;
 
@@ -2855,7 +2849,7 @@ iwn_fatal_intr(struct iwn_softc *sc)
 	/* Check that the error log address is valid. */
 	if (sc->errptr < IWN_FW_DATA_BASE ||
 	    sc->errptr + sizeof (dump) >
-	    IWN_FW_DATA_BASE + hal->fw_data_maxsz) {
+	    IWN_FW_DATA_BASE + sc->fw_data_maxsz) {
 		printf("%s: bad firmware error log address 0x%08x\n", __func__,
 		    sc->errptr);
 		return;
@@ -2890,7 +2884,7 @@ iwn_fatal_intr(struct iwn_softc *sc)
 
 	/* Dump driver status (TX and RX rings) while we're here. */
 	printf("driver status:\n");
-	for (i = 0; i < hal->ntxqs; i++) {
+	for (i = 0; i < sc->ntxqs; i++) {
 		struct iwn_tx_ring *ring = &sc->txq[i];
 		printf("  tx ring %2d: qid=%-2d cur=%-3d queued=%-3d\n",
 		    i, ring->qid, ring->cur, ring->queued);
@@ -3063,7 +3057,6 @@ iwn_plcp_signal(int rate) {
 static int
 iwn_tx_data(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
 	const struct ieee80211_txparam *tp;
 	struct ieee80211vap *vap = ni->ni_vap;
 	struct ieee80211com *ic = ni->ni_ic;
@@ -3194,7 +3187,7 @@ iwn_tx_data(struct iwn_softc *sc, struct
 
 	if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
 	    type != IEEE80211_FC0_TYPE_DATA)
-		tx->id = hal->broadcast_id;
+		tx->id = sc->broadcast_id;
 	else
 		tx->id = wn->id;
 
@@ -3226,7 +3219,7 @@ iwn_tx_data(struct iwn_softc *sc, struct
 	tx->lifetime = htole32(IWN_LIFETIME_INFINITE);
 	tx->plcp = rinfo->plcp;
 	tx->rflags = rinfo->flags;
-	if (tx->id == hal->broadcast_id) {
+	if (tx->id == sc->broadcast_id) {
 		/* Group or management frame. */
 		tx->linkq = 0;
 		/* XXX Alternate between antenna A and B? */
@@ -3308,7 +3301,7 @@ iwn_tx_data(struct iwn_softc *sc, struct
 
 #ifdef notyet
 	/* Update TX scheduler. */
-	hal->update_sched(sc, ring->qid, ring->cur, tx->id, totlen);
+	ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen);
 #endif
 
 	/* Kick TX ring. */
@@ -3326,7 +3319,6 @@ static int
 iwn_tx_data_raw(struct iwn_softc *sc, struct mbuf *m,
     struct ieee80211_node *ni, const struct ieee80211_bpf_params *params)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
 	const struct iwn_rate *rinfo;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211vap *vap = ni->ni_vap;
@@ -3431,7 +3423,7 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 
 	tx->len = htole16(totlen);
 	tx->tid = 0;
-	tx->id = hal->broadcast_id;
+	tx->id = sc->broadcast_id;
 	tx->rts_ntries = params->ibp_try1;
 	tx->data_ntries = params->ibp_try0;
 	tx->lifetime = htole32(IWN_LIFETIME_INFINITE);
@@ -3513,7 +3505,7 @@ iwn_tx_data_raw(struct iwn_softc *sc, st
 
 #ifdef notyet
 	/* Update TX scheduler. */
-	hal->update_sched(sc, ring->qid, ring->cur, tx->id, totlen);
+	ops->update_sched(sc, ring->qid, ring->cur, tx->id, totlen);
 #endif
 
 	/* Kick TX ring. */
@@ -3738,7 +3730,7 @@ iwn_cmd(struct iwn_softc *sc, int code, 
 
 #ifdef notyet
 	/* Update TX scheduler. */
-	sc->sc_hal->update_sched(sc, ring->qid, ring->cur, 0, 0);
+	ops->update_sched(sc, ring->qid, ring->cur, 0, 0);
 #endif
 
 	/* Kick command ring. */
@@ -3815,7 +3807,7 @@ iwn_set_link_quality(struct iwn_softc *s
 static int
 iwn_add_broadcast_node(struct iwn_softc *sc, int async)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct iwn_node_info node;
@@ -3826,16 +3818,16 @@ iwn_add_broadcast_node(struct iwn_softc 
 
 	memset(&node, 0, sizeof node);
 	IEEE80211_ADDR_COPY(node.macaddr, ifp->if_broadcastaddr);
-	node.id = hal->broadcast_id;
+	node.id = sc->broadcast_id;
 	DPRINTF(sc, IWN_DEBUG_RESET, "%s: adding broadcast node\n", __func__);
-	if ((error = hal->add_node(sc, &node, async)) != 0)
+	if ((error = ops->add_node(sc, &node, async)) != 0)
 		return error;
 
 	/* Use the first valid TX antenna. */
 	txant = IWN_LSB(sc->txchainmask);
 
 	memset(&linkq, 0, sizeof linkq);
-	linkq.id = sc->sc_hal->broadcast_id;
+	linkq.id = sc->broadcast_id;
 	linkq.antmsk_1stream = txant;
 	linkq.antmsk_2stream = IWN_ANT_AB;
 	linkq.ampdu_max = 64;
@@ -4260,7 +4252,7 @@ iwn5000_get_temperature(struct iwn_softc
 static int
 iwn_init_sensitivity(struct iwn_softc *sc)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	struct iwn_calib_state *calib = &sc->calib;
 	uint32_t flags;
 	int error;
@@ -4283,7 +4275,7 @@ iwn_init_sensitivity(struct iwn_softc *s
 		return error;
 
 	/* Write initial gains. */
-	if ((error = hal->init_gains(sc)) != 0)
+	if ((error = ops->init_gains(sc)) != 0)
 		return error;
 
 	/* Request statistics at each beacon interval. */
@@ -4302,7 +4294,7 @@ static void
 iwn_collect_noise(struct iwn_softc *sc,
     const struct iwn_rx_general_stats *stats)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	struct iwn_calib_state *calib = &sc->calib;
 	uint32_t val;
 	int i;
@@ -4333,13 +4325,13 @@ iwn_collect_noise(struct iwn_softc *sc,
 	if ((sc->chainmask & sc->txchainmask) == 0)
 		sc->chainmask |= IWN_LSB(sc->txchainmask);
 
-	(void)hal->set_gains(sc);
+	(void)ops->set_gains(sc);
 	calib->state = IWN_CALIB_STATE_RUN;
 
 #ifdef notyet
 	/* XXX Disable RX chains with no antennas connected. */
 	sc->rxon.rxchain = htole16(IWN_RXCHAIN_SEL(sc->chainmask));
-	(void)iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, hal->rxonsz, 1);
+	(void)iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, sc->rxonsz, 1);
 #endif
 
 #if 0
@@ -4702,7 +4694,7 @@ iwn_send_btcoex(struct iwn_softc *sc)
 static int
 iwn_config(struct iwn_softc *sc)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	uint32_t txmask;
@@ -4776,7 +4768,7 @@ iwn_config(struct iwn_softc *sc)
 	    IWN_RXCHAIN_IDLE_COUNT(2);
 	sc->rxon.rxchain = htole16(rxchain);
 	DPRINTF(sc, IWN_DEBUG_RESET, "%s: setting configuration\n", __func__);
-	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, hal->rxonsz, 0);
+	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, sc->rxonsz, 0);
 	if (error != 0) {
 		device_printf(sc->sc_dev, "%s: RXON command failed\n",
 		    __func__);
@@ -4790,7 +4782,7 @@ iwn_config(struct iwn_softc *sc)
 	}
 
 	/* Configuration has changed, set TX power accordingly. */
-	if ((error = hal->set_txpower(sc, ic->ic_curchan, 0)) != 0) {
+	if ((error = ops->set_txpower(sc, ic->ic_curchan, 0)) != 0) {
 		device_printf(sc->sc_dev, "%s: could not set TX power\n",
 		    __func__);
 		return error;
@@ -4872,7 +4864,7 @@ iwn_scan(struct iwn_softc *sc)
 
 	tx = (struct iwn_cmd_data *)(hdr + 1);
 	tx->flags = htole32(IWN_TX_AUTO_SEQ);
-	tx->id = sc->sc_hal->broadcast_id;
+	tx->id = sc->broadcast_id;
 	tx->lifetime = htole32(IWN_LIFETIME_INFINITE);
 
 	if (IEEE80211_IS_CHAN_A(ic->ic_curchan)) {
@@ -4980,7 +4972,7 @@ iwn_scan(struct iwn_softc *sc)
 static int
 iwn_auth(struct iwn_softc *sc, struct ieee80211vap *vap)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ieee80211_node *ni = vap->iv_bss;
@@ -5010,7 +5002,7 @@ iwn_auth(struct iwn_softc *sc, struct ie
 	DPRINTF(sc, IWN_DEBUG_STATE, "rxon chan %d flags %x cck %x ofdm %x\n",
 	    sc->rxon.chan, sc->rxon.flags, sc->rxon.cck_mask,
 	    sc->rxon.ofdm_mask);
-	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, hal->rxonsz, 1);
+	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, sc->rxonsz, 1);
 	if (error != 0) {
 		device_printf(sc->sc_dev, "%s: RXON command failed, error %d\n",
 		    __func__, error);
@@ -5018,7 +5010,7 @@ iwn_auth(struct iwn_softc *sc, struct ie
 	}
 
 	/* Configuration has changed, set TX power accordingly. */
-	if ((error = hal->set_txpower(sc, ni->ni_chan, 1)) != 0) {
+	if ((error = ops->set_txpower(sc, ni->ni_chan, 1)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not set TX power, error %d\n", __func__, error);
 		return error;
@@ -5040,7 +5032,7 @@ static int
 iwn_run(struct iwn_softc *sc, struct ieee80211vap *vap)
 {
 #define	MS(v,x)	(((v) & x) >> x##_S)
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	struct ifnet *ifp = sc->sc_ifp;
 	struct ieee80211com *ic = ifp->if_l2com;
 	struct ieee80211_node *ni = vap->iv_bss;
@@ -5103,7 +5095,7 @@ iwn_run(struct iwn_softc *sc, struct iee
 	sc->rxon.filter |= htole32(IWN_FILTER_BSS);
 	DPRINTF(sc, IWN_DEBUG_STATE, "rxon chan %d flags %x\n",
 	    sc->rxon.chan, sc->rxon.flags);
-	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, hal->rxonsz, 1);
+	error = iwn_cmd(sc, IWN_CMD_RXON, &sc->rxon, sc->rxonsz, 1);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not update configuration, error %d\n", __func__,
@@ -5112,7 +5104,7 @@ iwn_run(struct iwn_softc *sc, struct iee
 	}
 
 	/* Configuration has changed, set TX power accordingly. */
-	if ((error = hal->set_txpower(sc, ni->ni_chan, 1)) != 0) {
+	if ((error = ops->set_txpower(sc, ni->ni_chan, 1)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not set TX power, error %d\n", __func__, error);
 		return error;
@@ -5131,7 +5123,7 @@ iwn_run(struct iwn_softc *sc, struct iee
 	    IWN_AMDPU_DENSITY(5));	/* 2us */
 #endif
 	DPRINTF(sc, IWN_DEBUG_STATE, "%s: adding BSS node\n", __func__);
-	error = hal->add_node(sc, &node, 1);
+	error = ops->add_node(sc, &node, 1);
 	if (error != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not add BSS node, error %d\n", __func__, error);
@@ -5175,6 +5167,7 @@ iwn_ampdu_rx_start(struct ieee80211com *
 {
 	struct ieee80211_rx_ba *ba = &ni->ni_rx_ba[tid];
 	struct iwn_softc *sc = ic->ic_softc;
+	struct iwn_ops *ops = &sc->ops;
 	struct iwn_node *wn = (void *)ni;
 	struct iwn_node_info node;
 
@@ -5186,7 +5179,7 @@ iwn_ampdu_rx_start(struct ieee80211com *
 	node.addba_ssn = htole16(ba->ba_winstart);
 	DPRINTF(sc, IWN_DEBUG_RECV, "ADDBA RA=%d TID=%d SSN=%d\n",
 	    wn->id, tid, ba->ba_winstart);
-	return sc->sc_hal->add_node(sc, &node, 1);
+	return ops->add_node(sc, &node, 1);
 }
 
 /*
@@ -5198,6 +5191,7 @@ iwn_ampdu_rx_stop(struct ieee80211com *i
     uint8_t tid)
 {
 	struct iwn_softc *sc = ic->ic_softc;
+	struct iwn_ops *ops = &sc->ops;
 	struct iwn_node *wn = (void *)ni;
 	struct iwn_node_info node;
 
@@ -5207,7 +5201,7 @@ iwn_ampdu_rx_stop(struct ieee80211com *i
 	node.flags = IWN_FLAG_SET_DELBA;
 	node.delba_tid = tid;
 	DPRINTF(sc, IWN_DEBUG_RECV, "DELBA RA=%d TID=%d\n", wn->id, tid);
-	(void)sc->sc_hal->add_node(sc, &node, 1);
+	(void)ops->add_node(sc, &node, 1);
 }
 
 /*
@@ -5220,7 +5214,7 @@ iwn_ampdu_tx_start(struct ieee80211com *
 {
 	struct ieee80211_tx_ba *ba = &ni->ni_tx_ba[tid];
 	struct iwn_softc *sc = ic->ic_softc;
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	struct iwn_node *wn = (void *)ni;
 	struct iwn_node_info node;
 	int error;
@@ -5232,13 +5226,13 @@ iwn_ampdu_tx_start(struct ieee80211com *
 	node.control = IWN_NODE_UPDATE;
 	node.flags = IWN_FLAG_SET_DISABLE_TID;
 	node.disable_tid = htole16(wn->disable_tid);
-	error = hal->add_node(sc, &node, 1);
+	error = ops->add_node(sc, &node, 1);
 	if (error != 0)
 		return error;
 
 	if ((error = iwn_nic_lock(sc)) != 0)
 		return error;
-	hal->ampdu_tx_start(sc, ni, tid, ba->ba_winstart);
+	ops->ampdu_tx_start(sc, ni, tid, ba->ba_winstart);
 	iwn_nic_unlock(sc);
 	return 0;
 }
@@ -5249,10 +5243,11 @@ iwn_ampdu_tx_stop(struct ieee80211com *i
 {
 	struct ieee80211_tx_ba *ba = &ni->ni_tx_ba[tid];
 	struct iwn_softc *sc = ic->ic_softc;
+	struct iwn_ops *ops = &sc->ops;
 
 	if (iwn_nic_lock(sc) != 0)
 		return;
-	sc->sc_hal->ampdu_tx_stop(sc, tid, ba->ba_winstart);
+	ops->ampdu_tx_stop(sc, tid, ba->ba_winstart);
 	iwn_nic_unlock(sc);
 }
 
@@ -5962,7 +5957,6 @@ iwn_read_firmware_tlv(struct iwn_softc *
 static int
 iwn_read_firmware(struct iwn_softc *sc)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
 	struct iwn_fw_info *fw = &sc->fw;
 	int error;
 
@@ -6005,10 +5999,10 @@ iwn_read_firmware(struct iwn_softc *sc)
 	}
 
 	/* Make sure text and data sections fit in hardware memory. */
-	if (fw->main.textsz > hal->fw_text_maxsz ||
-	    fw->main.datasz > hal->fw_data_maxsz ||
-	    fw->init.textsz > hal->fw_text_maxsz ||
-	    fw->init.datasz > hal->fw_data_maxsz ||
+	if (fw->main.textsz > sc->fw_text_maxsz ||
+	    fw->main.datasz > sc->fw_data_maxsz ||
+	    fw->init.textsz > sc->fw_text_maxsz ||
+	    fw->init.datasz > sc->fw_data_maxsz ||
 	    fw->boot.textsz > IWN_FW_BOOT_TEXT_MAXSZ ||
 	    (fw->boot.textsz & 3) != 0) {
 		device_printf(sc->sc_dev, "%s: firmware sections too large\n",
@@ -6226,7 +6220,7 @@ iwn_hw_prepare(struct iwn_softc *sc)
 static int
 iwn_hw_init(struct iwn_softc *sc)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
+	struct iwn_ops *ops = &sc->ops;
 	int error, chnl, qid;
 
 	/* Clear pending interrupts. */
@@ -6246,7 +6240,7 @@ iwn_hw_init(struct iwn_softc *sc)
 	iwn_nic_unlock(sc);
 
 	/* Perform adapter-specific initialization. */
-	if ((error = hal->nic_config(sc)) != 0)
+	if ((error = ops->nic_config(sc)) != 0)
 		return error;
 
 	/* Initialize RX ring. */
@@ -6273,13 +6267,13 @@ iwn_hw_init(struct iwn_softc *sc)
 		return error;
 
 	/* Initialize TX scheduler. */
-	iwn_prph_write(sc, hal->sched_txfact_addr, 0);
+	iwn_prph_write(sc, sc->sched_txfact_addr, 0);
 
 	/* Set physical address of "keep warm" page (16-byte aligned). */
 	IWN_WRITE(sc, IWN_FH_KW_ADDR, sc->kw_dma.paddr >> 4);
 
 	/* Initialize TX rings. */
-	for (qid = 0; qid < hal->ntxqs; qid++) {
+	for (qid = 0; qid < sc->ntxqs; qid++) {
 		struct iwn_tx_ring *txq = &sc->txq[qid];
 
 		/* Set physical address of TX ring (256-byte aligned). */
@@ -6289,7 +6283,7 @@ iwn_hw_init(struct iwn_softc *sc)
 	iwn_nic_unlock(sc);
 
 	/* Enable DMA channels. */
-	for (chnl = 0; chnl < hal->ndmachnls; chnl++) {
+	for (chnl = 0; chnl < sc->ndmachnls; chnl++) {
 		IWN_WRITE(sc, IWN_FH_TX_CONFIG(chnl),
 		    IWN_FH_TX_CONFIG_DMA_ENA |
 		    IWN_FH_TX_CONFIG_DMA_CREDIT_ENA);
@@ -6310,7 +6304,7 @@ iwn_hw_init(struct iwn_softc *sc)
 	IWN_WRITE(sc, IWN_UCODE_GP1_CLR, IWN_UCODE_GP1_RFKILL);
 	IWN_WRITE(sc, IWN_UCODE_GP1_CLR, IWN_UCODE_GP1_RFKILL);
 
-	if ((error = hal->load_firmware(sc)) != 0) {
+	if ((error = ops->load_firmware(sc)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not load firmware, error %d\n", __func__,
 		    error);
@@ -6324,13 +6318,12 @@ iwn_hw_init(struct iwn_softc *sc)
 		return error;
 	}
 	/* Do post-firmware initialization. */
-	return hal->post_alive(sc);
+	return ops->post_alive(sc);
 }
 
 static void
 iwn_hw_stop(struct iwn_softc *sc)
 {
-	const struct iwn_hal *hal = sc->sc_hal;
 	int chnl, qid, ntries;
 
 	IWN_WRITE(sc, IWN_RESET, IWN_RESET_NEVO);
@@ -6345,11 +6338,11 @@ iwn_hw_stop(struct iwn_softc *sc)
 	iwn_nic_unlock(sc);
 
 	/* Stop TX scheduler. */
-	iwn_prph_write(sc, hal->sched_txfact_addr, 0);
+	iwn_prph_write(sc, sc->sched_txfact_addr, 0);
 
 	/* Stop all DMA channels. */
 	if (iwn_nic_lock(sc) == 0) {
-		for (chnl = 0; chnl < hal->ndmachnls; chnl++) {
+		for (chnl = 0; chnl < sc->ndmachnls; chnl++) {
 			IWN_WRITE(sc, IWN_FH_TX_CONFIG(chnl), 0);
 			for (ntries = 0; ntries < 200; ntries++) {
 				if (IWN_READ(sc, IWN_FH_TX_STATUS) &
@@ -6365,7 +6358,7 @@ iwn_hw_stop(struct iwn_softc *sc)
 	iwn_reset_rx_ring(sc, &sc->rxq);
 
 	/* Reset all TX rings. */
-	for (qid = 0; qid < hal->ntxqs; qid++)
+	for (qid = 0; qid < sc->ntxqs; qid++)
 		iwn_reset_tx_ring(sc, &sc->txq[qid]);
 
 	if (iwn_nic_lock(sc) == 0) {

Modified: head/sys/dev/iwn/if_iwnvar.h
==============================================================================
--- head/sys/dev/iwn/if_iwnvar.h	Sat Apr 16 14:49:29 2011	(r220727)
+++ head/sys/dev/iwn/if_iwnvar.h	Sat Apr 16 14:51:46 2011	(r220728)
@@ -157,7 +157,7 @@ struct iwn_fw_info {
 	struct iwn_fw_part	boot;
 };
 
-struct iwn_hal {
+struct iwn_ops {
 	int		(*load_firmware)(struct iwn_softc *);
 	void		(*read_eeprom)(struct iwn_softc *);
 	int		(*post_alive)(struct iwn_softc *);
@@ -180,15 +180,6 @@ struct iwn_hal {
 	void		(*ampdu_tx_stop)(struct iwn_softc *, uint8_t,
 			    uint16_t);
 #endif
-	int		ntxqs;
-	int		ndmachnls;
-	uint8_t		broadcast_id;
-	int		rxonsz;
-	int		schedsz;
-	uint32_t	fw_text_maxsz;
-	uint32_t	fw_data_maxsz;
-	uint32_t	fwsz;
-	bus_size_t	sched_txfact_addr;
 };
 
 struct iwn_vap {
@@ -215,10 +206,20 @@ struct iwn_softc {
 #define IWN_FLAG_INTERNAL_PA	(1 << 4)
 
 	uint8_t 		hw_type;
-	const struct iwn_hal	*sc_hal;
+
+	struct iwn_ops		ops;
 	const char		*fwname;
 	const struct iwn_sensitivity_limits
 				*limits;
+	int			ntxqs;
+	int			ndmachnls;
+	uint8_t			broadcast_id;
+	int			rxonsz;
+	int			schedsz;
+	uint32_t		fw_text_maxsz;
+	uint32_t		fw_data_maxsz;
+	uint32_t		fwsz;
+	bus_size_t		sched_txfact_addr;
 
 	/* TX scheduler rings. */
 	struct iwn_dma_info	sched_dma;

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 14:56:13 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DC21C106564A;
	Sat, 16 Apr 2011 14:56:13 +0000 (UTC)
	(envelope-from bschmidt@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id C9FD68FC08;
	Sat, 16 Apr 2011 14:56:13 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GEuDY5008759;
	Sat, 16 Apr 2011 14:56:13 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Received: (from bschmidt@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GEuDrW008755;
	Sat, 16 Apr 2011 14:56:13 GMT
	(envelope-from bschmidt@svn.freebsd.org)
Message-Id: <201104161456.p3GEuDrW008755@svn.freebsd.org>
From: Bernhard Schmidt 
Date: Sat, 16 Apr 2011 14:56:13 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220729 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 14:56:14 -0000

Author: bschmidt
Date: Sat Apr 16 14:56:13 2011
New Revision: 220729
URL: http://svn.freebsd.org/changeset/base/220729

Log:
  Add some new features:
  - 6000 series devices need enhanced sensitivity calibration.
  - 6000 series devices need a different setting for the shadow reg.
  - set the IWN_FLAG_HAS_11N bit if the EEPROM says the device has 11n
    support.
  
  Obtained from:	OpenBSD

Modified:
  head/sys/dev/iwn/if_iwn.c
  head/sys/dev/iwn/if_iwnreg.h
  head/sys/dev/iwn/if_iwnvar.h

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:51:46 2011	(r220728)
+++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:56:13 2011	(r220729)
@@ -1653,6 +1653,12 @@ iwn_read_eeprom(struct iwn_softc *sc, ui
 		}
 	}
 
+	iwn_read_prom_data(sc, IWN_EEPROM_SKU_CAP, &val, 2);
+	DPRINTF(sc, IWN_DEBUG_RESET, "SKU capabilities=0x%04x\n", le16toh(val));
+	/* Check if HT support is bonded out. */
+	if (val & htole16(IWN_EEPROM_SKU_CAP_11N))
+		sc->sc_flags |= IWN_FLAG_HAS_11N;
+
 	iwn_read_prom_data(sc, IWN_EEPROM_RFCFG, &val, 2);
 	sc->rfcfg = le16toh(val);
 	DPRINTF(sc, IWN_DEBUG_RESET, "radio config=0x%04x\n", sc->rfcfg);
@@ -4595,9 +4601,11 @@ static int
 iwn_send_sensitivity(struct iwn_softc *sc)
 {
 	struct iwn_calib_state *calib = &sc->calib;
-	struct iwn_sensitivity_cmd cmd;
+	struct iwn_enhanced_sensitivity_cmd cmd;
+	int len;
 
 	memset(&cmd, 0, sizeof cmd);
+	len = sizeof (struct iwn_sensitivity_cmd);
 	cmd.which = IWN_SENSITIVITY_WORKTBL;
 	/* OFDM modulation. */
 	cmd.corr_ofdm_x1       = htole16(calib->ofdm_x1);
@@ -4619,7 +4627,21 @@ iwn_send_sensitivity(struct iwn_softc *s
 	    calib->ofdm_x1, calib->ofdm_mrc_x1, calib->ofdm_x4,
 	    calib->ofdm_mrc_x4, calib->cck_x4,
 	    calib->cck_mrc_x4, calib->energy_cck);
-	return iwn_cmd(sc, IWN_CMD_SET_SENSITIVITY, &cmd, sizeof cmd, 1);
+
+	if (!(sc->sc_flags & IWN_FLAG_ENH_SENS))
+		goto send;
+	/* Enhanced sensitivity settings. */
+	len = sizeof (struct iwn_enhanced_sensitivity_cmd);
+	cmd.ofdm_det_slope_mrc = htole16(668);
+	cmd.ofdm_det_icept_mrc = htole16(4);
+	cmd.ofdm_det_slope     = htole16(486);
+	cmd.ofdm_det_icept     = htole16(37);
+	cmd.cck_det_slope_mrc  = htole16(853);
+	cmd.cck_det_icept_mrc  = htole16(4);
+	cmd.cck_det_slope      = htole16(476);
+	cmd.cck_det_icept      = htole16(99);
+send:
+	return iwn_cmd(sc, IWN_CMD_SET_SENSITIVITY, &cmd, len, 1);
 }
 
 /*
@@ -6175,6 +6197,8 @@ iwn5000_nic_config(struct iwn_softc *sc)
 		/* Indicate that ROM calibration version is >=6. */
 		IWN_SETBITS(sc, IWN_GP_DRIVER, IWN_GP_DRIVER_CALIB_VER6);
 	}
+	if (sc->hw_type == IWN_HW_REV_TYPE_6005)
+		IWN_SETBITS(sc, IWN_GP_DRIVER, IWN_GP_DRIVER_6050_1X2);
 	return 0;
 }
 
@@ -6304,6 +6328,10 @@ iwn_hw_init(struct iwn_softc *sc)
 	IWN_WRITE(sc, IWN_UCODE_GP1_CLR, IWN_UCODE_GP1_RFKILL);
 	IWN_WRITE(sc, IWN_UCODE_GP1_CLR, IWN_UCODE_GP1_RFKILL);
 
+	/* Enable shadow registers. */
+	if (sc->hw_type >= IWN_HW_REV_TYPE_6000)
+		IWN_SETBITS(sc, IWN_SHADOW_REG_CTRL, 0x800fffff);
+
 	if ((error = ops->load_firmware(sc)) != 0) {
 		device_printf(sc->sc_dev,
 		    "%s: could not load firmware, error %d\n", __func__,

Modified: head/sys/dev/iwn/if_iwnreg.h
==============================================================================
--- head/sys/dev/iwn/if_iwnreg.h	Sat Apr 16 14:51:46 2011	(r220728)
+++ head/sys/dev/iwn/if_iwnreg.h	Sat Apr 16 14:56:13 2011	(r220729)
@@ -70,6 +70,7 @@
 #define IWN_UCODE_GP1_CLR	0x05c
 #define IWN_LED			0x094
 #define IWN_DRAM_INT_TBL	0x0a0
+#define IWN_SHADOW_REG_CTRL	0x0a8
 #define IWN_GIO_CHICKEN		0x100
 #define IWN_ANA_PLL		0x20c
 #define IWN_HW_REV_WA		0x22c
@@ -215,6 +216,7 @@
 #define IWN_GP_DRIVER_RADIO_2X2_HYB	(1 << 0)
 #define IWN_GP_DRIVER_RADIO_2X2_IPA	(2 << 0)
 #define IWN_GP_DRIVER_CALIB_VER6	(1 << 2)
+#define IWN_GP_DRIVER_6050_1X2		(1 << 3)
 
 /* Possible flags for register IWN_UCODE_GP1_CLR. */
 #define IWN_UCODE_GP1_RFKILL		(1 << 1)
@@ -856,7 +858,7 @@ struct iwn_critical_temp {
 #define IWN_CTOMUK(c)	(((c) * 1000000) + 273150000)
 } __packed;
 
-/* Structure for command IWN_CMD_SET_SENSITIVITY. */
+/* Structures for command IWN_CMD_SET_SENSITIVITY. */
 struct iwn_sensitivity_cmd {
 	uint16_t	which;
 #define IWN_SENSITIVITY_DEFAULTTBL	0
@@ -875,6 +877,34 @@ struct iwn_sensitivity_cmd {
 	uint16_t	energy_ofdm_th;
 } __packed;
 
+struct iwn_enhanced_sensitivity_cmd {
+	uint16_t	which;
+	uint16_t	energy_cck;
+	uint16_t	energy_ofdm;
+	uint16_t	corr_ofdm_x1;
+	uint16_t	corr_ofdm_mrc_x1;
+	uint16_t	corr_cck_mrc_x4;
+	uint16_t	corr_ofdm_x4;
+	uint16_t	corr_ofdm_mrc_x4;
+	uint16_t	corr_barker;
+	uint16_t	corr_barker_mrc;
+	uint16_t	corr_cck_x4;
+	uint16_t	energy_ofdm_th;
+	/* "Enhanced" part. */
+	uint16_t	ina_det_ofdm;
+	uint16_t	ina_det_cck;
+	uint16_t	corr_11_9_en;
+	uint16_t	ofdm_det_slope_mrc;
+	uint16_t	ofdm_det_icept_mrc;
+	uint16_t	ofdm_det_slope;
+	uint16_t	ofdm_det_icept;
+	uint16_t	cck_det_slope_mrc;
+	uint16_t	cck_det_icept_mrc;
+	uint16_t	cck_det_slope;
+	uint16_t	cck_det_icept;
+	uint16_t	reserved;
+} __packed;
+
 /* Structures for command IWN_CMD_PHY_CALIB. */
 struct iwn_phy_calib {
 	uint8_t	code;
@@ -1309,6 +1339,7 @@ struct iwn_fw_tlv {
  * Offsets into EEPROM.
  */
 #define IWN_EEPROM_MAC		0x015
+#define IWN_EEPROM_SKU_CAP	0x045
 #define IWN_EEPROM_RFCFG	0x048
 #define IWN4965_EEPROM_DOMAIN	0x060
 #define IWN4965_EEPROM_BAND1	0x063
@@ -1337,6 +1368,11 @@ struct iwn_fw_tlv {
 #define IWN5000_EEPROM_TEMP	0x12a
 #define IWN5000_EEPROM_VOLT	0x12b
 
+/* Possible flags for IWN_EEPROM_SKU_CAP. */
+#define IWN_EEPROM_SKU_CAP_11N	(1 << 6)
+#define IWN_EEPROM_SKU_CAP_AMT	(1 << 7)
+#define IWN_EEPROM_SKU_CAP_IPAN	(1 << 8)
+
 /* Possible flags for IWN_EEPROM_RFCFG. */
 #define IWN_RFCFG_TYPE(x)	(((x) >>  0) & 0x3)
 #define IWN_RFCFG_STEP(x)	(((x) >>  2) & 0x3)

Modified: head/sys/dev/iwn/if_iwnvar.h
==============================================================================
--- head/sys/dev/iwn/if_iwnvar.h	Sat Apr 16 14:51:46 2011	(r220728)
+++ head/sys/dev/iwn/if_iwnvar.h	Sat Apr 16 14:56:13 2011	(r220729)
@@ -204,6 +204,8 @@ struct iwn_softc {
 #define IWN_FLAG_CALIB_DONE	(1 << 2)
 #define IWN_FLAG_USE_ICT	(1 << 3)
 #define IWN_FLAG_INTERNAL_PA	(1 << 4)
+#define IWN_FLAG_HAS_11N	(1 << 6)
+#define IWN_FLAG_ENH_SENS	(1 << 7)
 
 	uint8_t 		hw_type;
 

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 15:12:39 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5663A106564A;
	Sat, 16 Apr 2011 15:12:39 +0000 (UTC)
	(envelope-from bschmidt@techwires.net)
Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com
	[209.85.214.54])
	by mx1.freebsd.org (Postfix) with ESMTP id 8BBDE8FC08;
	Sat, 16 Apr 2011 15:12:38 +0000 (UTC)
Received: by bwz12 with SMTP id 12so3876125bwz.13
	for ; Sat, 16 Apr 2011 08:12:37 -0700 (PDT)
Received: by 10.204.3.146 with SMTP id 18mr2596845bkn.1.1302965068146;
	Sat, 16 Apr 2011 07:44:28 -0700 (PDT)
Received: from amy.lab.techwires.net (dslb-088-065-048-047.pools.arcor-ip.net
	[88.65.48.47])
	by mx.google.com with ESMTPS id l1sm2149372bkl.1.2011.04.16.07.44.26
	(version=SSLv3 cipher=OTHER); Sat, 16 Apr 2011 07:44:26 -0700 (PDT)
Sender: Bernhard Schmidt 
From: Bernhard Schmidt 
To: src-committers@freebsd.org
Date: Sat, 16 Apr 2011 16:44:29 +0200
User-Agent: KMail/1.13.6 (FreeBSD/8.2-STABLE; KDE/4.6.2; amd64; ; )
References: <201104161438.p3GEc2U0008200@svn.freebsd.org>
In-Reply-To: <201104161438.p3GEc2U0008200@svn.freebsd.org>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Message-Id: <201104161644.30206.bschmidt@freebsd.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org
Subject: Re: svn commit: r220724 - head/sys/dev/iwn
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 15:12:39 -0000

Bernhard
On Saturday 16 April 2011 16:38:02  Schmidt wrote:
> Author: bschmidt
> Date: Sat Apr 16 14:38:01 2011
> New Revision: 220724
> URL: http://svn.freebsd.org/changeset/base/220724
> 
> Log:
>   Sync debug and error messages with OpenBSD.

Forgot to mention this:
The device capability announcements are now hidden behind bootverbose.
Once the 11n bits are in this is gonna be quite spammy otherwise.

> 
> Modified: head/sys/dev/iwn/if_iwn.c
> ==============================================================================
> --- head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:36:43 2011	(r220723)
> +++ head/sys/dev/iwn/if_iwn.c	Sat Apr 16 14:38:01 2011	(r220724)
> @@ -621,9 +620,11 @@ iwn_attach(device_t dev)
>  	    ((sc->rxchainmask >> 2) & 1) +
>  	    ((sc->rxchainmask >> 1) & 1) +
>  	    ((sc->rxchainmask >> 0) & 1);
> -	device_printf(sc->sc_dev, "MIMO %dT%dR, %.4s, address %6D\n",
> -	    sc->ntxchains, sc->nrxchains, sc->eeprom_domain,
> -	    macaddr, ":");
> +	if (bootverbose) {
> +		device_printf(dev, "MIMO %dT%dR, %.4s, address %6D\n",
> +		    sc->ntxchains, sc->nrxchains, sc->eeprom_domain,
> +		    macaddr, ":");
> +	}
>  
>  	ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
>  	if (ifp == NULL) {
> @@ -745,12 +746,13 @@ iwn_attach(device_t dev)
>  		goto fail;
>  	}
>  
> -	ieee80211_announce(ic);
> +	if (bootverbose)
> +		ieee80211_announce(ic);
>  	return 0;
>  fail:
>  	iwn_detach(dev);

-- 
Bernhard

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 16:20:52 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 44933106564A;
	Sat, 16 Apr 2011 16:20:52 +0000 (UTC)
	(envelope-from dchagin@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 324D78FC0A;
	Sat, 16 Apr 2011 16:20:52 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GGKqQl010594;
	Sat, 16 Apr 2011 16:20:52 GMT (envelope-from dchagin@svn.freebsd.org)
Received: (from dchagin@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GGKqc2010591;
	Sat, 16 Apr 2011 16:20:52 GMT (envelope-from dchagin@svn.freebsd.org)
Message-Id: <201104161620.p3GGKqc2010591@svn.freebsd.org>
From: Dmitry Chagin 
Date: Sat, 16 Apr 2011 16:20:52 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220730 - head/sys/kern
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 16:20:52 -0000

Author: dchagin
Date: Sat Apr 16 16:20:51 2011
New Revision: 220730
URL: http://svn.freebsd.org/changeset/base/220730

Log:
  Remove malloc(9) return value checks when M_WAITOK is used.
  
  MFC after:	2 Week

Modified:
  head/sys/kern/link_elf.c
  head/sys/kern/link_elf_obj.c

Modified: head/sys/kern/link_elf.c
==============================================================================
--- head/sys/kern/link_elf.c	Sat Apr 16 14:56:13 2011	(r220729)
+++ head/sys/kern/link_elf.c	Sat Apr 16 16:20:51 2011	(r220730)
@@ -692,10 +692,6 @@ link_elf_load_file(linker_class_t cls, c
 	 * Read the elf header from the file.
 	 */
 	firstpage = malloc(PAGE_SIZE, M_LINKER, M_WAITOK);
-	if (firstpage == NULL) {
-		error = ENOMEM;
-		goto out;
-	}
 	hdr = (Elf_Ehdr *)firstpage;
 	error = vn_rdwr(UIO_READ, nd.ni_vp, firstpage, PAGE_SIZE, 0,
 	    UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
@@ -829,10 +825,6 @@ link_elf_load_file(linker_class_t cls, c
 	}
 #else
 	ef->address = malloc(mapsize, M_LINKER, M_WAITOK);
-	if (ef->address == NULL) {
-		error = ENOMEM;
-		goto out;
-	}
 #endif
 	mapbase = ef->address;
 
@@ -918,10 +910,6 @@ link_elf_load_file(linker_class_t cls, c
 	if (nbytes == 0 || hdr->e_shoff == 0)
 		goto nosyms;
 	shdr = malloc(nbytes, M_LINKER, M_WAITOK | M_ZERO);
-	if (shdr == NULL) {
-		error = ENOMEM;
-		goto out;
-	}
 	error = vn_rdwr(UIO_READ, nd.ni_vp,
 	    (caddr_t)shdr, nbytes, hdr->e_shoff,
 	    UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
@@ -944,10 +932,6 @@ link_elf_load_file(linker_class_t cls, c
 	strcnt = shdr[symstrindex].sh_size;
 	ef->strbase = malloc(strcnt, M_LINKER, M_WAITOK);
 
-	if (ef->symbase == NULL || ef->strbase == NULL) {
-		error = ENOMEM;
-		goto out;
-	}
 	error = vn_rdwr(UIO_READ, nd.ni_vp,
 	    ef->symbase, symcnt, shdr[symtabindex].sh_offset,
 	    UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
@@ -1318,8 +1302,6 @@ link_elf_lookup_set(linker_file_t lf, co
 
 	len = strlen(name) + sizeof("__start_set_"); /* sizeof includes \0 */
 	setsym = malloc(len, M_LINKER, M_WAITOK);
-	if (setsym == NULL)
-		return (ENOMEM);
 
 	/* get address of first entry */
 	snprintf(setsym, len, "%s%s", "__start_set_", name);

Modified: head/sys/kern/link_elf_obj.c
==============================================================================
--- head/sys/kern/link_elf_obj.c	Sat Apr 16 14:56:13 2011	(r220729)
+++ head/sys/kern/link_elf_obj.c	Sat Apr 16 16:20:51 2011	(r220730)
@@ -476,10 +476,6 @@ link_elf_load_file(linker_class_t cls, c
 
 	/* Read the elf header from the file. */
 	hdr = malloc(sizeof(*hdr), M_LINKER, M_WAITOK);
-	if (hdr == NULL) {
-		error = ENOMEM;
-		goto out;
-	}
 	error = vn_rdwr(UIO_READ, nd.ni_vp, (void *)hdr, sizeof(*hdr), 0,
 	    UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
 	    &resid, td);
@@ -536,10 +532,6 @@ link_elf_load_file(linker_class_t cls, c
 		goto out;
 	}
 	shdr = malloc(nbytes, M_LINKER, M_WAITOK);
-	if (shdr == NULL) {
-		error = ENOMEM;
-		goto out;
-	}
 	ef->e_shdr = shdr;
 	error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)shdr, nbytes, hdr->e_shoff,
 	    UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED, &resid, td);
@@ -605,22 +597,12 @@ link_elf_load_file(linker_class_t cls, c
 	if (ef->nrelatab != 0)
 		ef->relatab = malloc(ef->nrelatab * sizeof(*ef->relatab),
 		    M_LINKER, M_WAITOK | M_ZERO);
-	if ((ef->nprogtab != 0 && ef->progtab == NULL) ||
-	    (ef->nreltab != 0 && ef->reltab == NULL) ||
-	    (ef->nrelatab != 0 && ef->relatab == NULL)) {
-		error = ENOMEM;
-		goto out;
-	}
 
 	if (symtabindex == -1)
 		panic("lost symbol table index");
 	/* Allocate space for and load the symbol table */
 	ef->ddbsymcnt = shdr[symtabindex].sh_size / sizeof(Elf_Sym);
 	ef->ddbsymtab = malloc(shdr[symtabindex].sh_size, M_LINKER, M_WAITOK);
-	if (ef->ddbsymtab == NULL) {
-		error = ENOMEM;
-		goto out;
-	}
 	error = vn_rdwr(UIO_READ, nd.ni_vp, (void *)ef->ddbsymtab,
 	    shdr[symtabindex].sh_size, shdr[symtabindex].sh_offset,
 	    UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
@@ -637,10 +619,6 @@ link_elf_load_file(linker_class_t cls, c
 	/* Allocate space for and load the symbol strings */
 	ef->ddbstrcnt = shdr[symstrindex].sh_size;
 	ef->ddbstrtab = malloc(shdr[symstrindex].sh_size, M_LINKER, M_WAITOK);
-	if (ef->ddbstrtab == NULL) {
-		error = ENOMEM;
-		goto out;
-	}
 	error = vn_rdwr(UIO_READ, nd.ni_vp, ef->ddbstrtab,
 	    shdr[symstrindex].sh_size, shdr[symstrindex].sh_offset,
 	    UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,
@@ -660,10 +638,6 @@ link_elf_load_file(linker_class_t cls, c
 		ef->shstrcnt = shdr[shstrindex].sh_size;
 		ef->shstrtab = malloc(shdr[shstrindex].sh_size, M_LINKER,
 		    M_WAITOK);
-		if (ef->shstrtab == NULL) {
-			error = ENOMEM;
-			goto out;
-		}
 		error = vn_rdwr(UIO_READ, nd.ni_vp, ef->shstrtab,
 		    shdr[shstrindex].sh_size, shdr[shstrindex].sh_offset,
 		    UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, NOCRED,

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 22:15:59 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7EAE61065670;
	Sat, 16 Apr 2011 22:15:59 +0000 (UTC)
	(envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 6D3B18FC13;
	Sat, 16 Apr 2011 22:15:59 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GMFxEg017802;
	Sat, 16 Apr 2011 22:15:59 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GMFxs0017800;
	Sat, 16 Apr 2011 22:15:59 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201104162215.p3GMFxs0017800@svn.freebsd.org>
From: Rick Macklem 
Date: Sat, 16 Apr 2011 22:15:59 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220731 - head/sys/fs/nfsclient
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 22:15:59 -0000

Author: rmacklem
Date: Sat Apr 16 22:15:59 2011
New Revision: 220731
URL: http://svn.freebsd.org/changeset/base/220731

Log:
  Add mutex locking on the nfs node in ncl_inactive() for the
  experimental NFS client.
  
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfsclient/nfs_clnode.c

Modified: head/sys/fs/nfsclient/nfs_clnode.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clnode.c	Sat Apr 16 16:20:51 2011	(r220730)
+++ head/sys/fs/nfsclient/nfs_clnode.c	Sat Apr 16 22:15:59 2011	(r220731)
@@ -202,12 +202,14 @@ ncl_inactive(struct vop_inactive_args *a
 		(void) nfsrpc_close(vp, 1, ap->a_td);
 	}
 
+	mtx_lock(&np->n_mtx);
 	if (vp->v_type != VDIR) {
 		sp = np->n_sillyrename;
 		np->n_sillyrename = NULL;
 	} else
 		sp = NULL;
 	if (sp) {
+		mtx_unlock(&np->n_mtx);
 		(void) ncl_vinvalbuf(vp, 0, ap->a_td, 1);
 		/*
 		 * Remove the silly file that was rename'd earlier
@@ -216,8 +218,10 @@ ncl_inactive(struct vop_inactive_args *a
 		crfree(sp->s_cred);
 		vrele(sp->s_dvp);
 		FREE((caddr_t)sp, M_NEWNFSREQ);
+		mtx_lock(&np->n_mtx);
 	}
 	np->n_flag &= NMODIFIED;
+	mtx_unlock(&np->n_mtx);
 	return (0);
 }
 

From owner-svn-src-head@FreeBSD.ORG  Sat Apr 16 23:20:22 2011
Return-Path: 
Delivered-To: svn-src-head@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5AD7F1065670;
	Sat, 16 Apr 2011 23:20:22 +0000 (UTC)
	(envelope-from rmacklem@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 489368FC0A;
	Sat, 16 Apr 2011 23:20:22 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GNKMmV019248;
	Sat, 16 Apr 2011 23:20:22 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Received: (from rmacklem@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GNKM9x019240;
	Sat, 16 Apr 2011 23:20:22 GMT
	(envelope-from rmacklem@svn.freebsd.org)
Message-Id: <201104162320.p3GNKM9x019240@svn.freebsd.org>
From: Rick Macklem 
Date: Sat, 16 Apr 2011 23:20:22 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r220732 - in head/sys/fs: nfs nfsclient
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
	
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
X-List-Received-Date: Sat, 16 Apr 2011 23:20:22 -0000

Author: rmacklem
Date: Sat Apr 16 23:20:21 2011
New Revision: 220732
URL: http://svn.freebsd.org/changeset/base/220732

Log:
  Add a lktype flags argument to nfscl_nget() and ncl_nget() in the
  experimental NFS client so that its nfs_lookup() function can use
  cn_lkflags in a manner analagous to the regular NFS client.
  
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfs/nfs_var.h
  head/sys/fs/nfsclient/nfs_clnode.c
  head/sys/fs/nfsclient/nfs_clport.c
  head/sys/fs/nfsclient/nfs_clrpcops.c
  head/sys/fs/nfsclient/nfs_clvfsops.c
  head/sys/fs/nfsclient/nfs_clvnops.c
  head/sys/fs/nfsclient/nfsnode.h

Modified: head/sys/fs/nfs/nfs_var.h
==============================================================================
--- head/sys/fs/nfs/nfs_var.h	Sat Apr 16 22:15:59 2011	(r220731)
+++ head/sys/fs/nfs/nfs_var.h	Sat Apr 16 23:20:21 2011	(r220732)
@@ -487,7 +487,7 @@ void nfscl_cleanup(NFSPROC_T *);
 
 /* nfs_clport.c */
 int nfscl_nget(mount_t, vnode_t, struct nfsfh *,
-    struct componentname *, NFSPROC_T *, struct nfsnode **, void *);
+    struct componentname *, NFSPROC_T *, struct nfsnode **, void *, int);
 NFSPROC_T *nfscl_getparent(NFSPROC_T *);
 void nfscl_start_renewthread(struct nfsclclient *);
 void nfscl_loadsbinfo(struct nfsmount *, struct nfsstatfs *, void *);

Modified: head/sys/fs/nfsclient/nfs_clnode.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clnode.c	Sat Apr 16 22:15:59 2011	(r220731)
+++ head/sys/fs/nfsclient/nfs_clnode.c	Sat Apr 16 23:20:21 2011	(r220732)
@@ -86,7 +86,8 @@ ncl_nhuninit(void)
  * nfsnode structure is returned.
  */
 int
-ncl_nget(struct mount *mntp, u_int8_t *fhp, int fhsize, struct nfsnode **npp)
+ncl_nget(struct mount *mntp, u_int8_t *fhp, int fhsize, struct nfsnode **npp,
+    int lkflags)
 {
 	struct thread *td = curthread;	/* XXX */
 	struct nfsnode *np;
@@ -106,7 +107,7 @@ ncl_nget(struct mount *mntp, u_int8_t *f
 	    M_NFSFH, M_WAITOK);
 	bcopy(fhp, &nfhp->nfh_fh[0], fhsize);
 	nfhp->nfh_len = fhsize;
-	error = vfs_hash_get(mntp, hash, LK_EXCLUSIVE,
+	error = vfs_hash_get(mntp, hash, lkflags,
 	    td, &nvp, newnfs_vncmpf, nfhp);
 	FREE(nfhp, M_NFSFH);
 	if (error)
@@ -168,7 +169,7 @@ ncl_nget(struct mount *mntp, u_int8_t *f
 		uma_zfree(newnfsnode_zone, np);
 		return (error);
 	}
-	error = vfs_hash_insert(vp, hash, LK_EXCLUSIVE, 
+	error = vfs_hash_insert(vp, hash, lkflags, 
 	    td, &nvp, newnfs_vncmpf, np->n_fhp);
 	if (error)
 		return (error);

Modified: head/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clport.c	Sat Apr 16 22:15:59 2011	(r220731)
+++ head/sys/fs/nfsclient/nfs_clport.c	Sat Apr 16 23:20:21 2011	(r220732)
@@ -85,7 +85,7 @@ newnfs_vncmpf(struct vnode *vp, void *ar
 int
 nfscl_nget(struct mount *mntp, struct vnode *dvp, struct nfsfh *nfhp,
     struct componentname *cnp, struct thread *td, struct nfsnode **npp,
-    void *stuff)
+    void *stuff, int lkflags)
 {
 	struct nfsnode *np, *dnp;
 	struct vnode *vp, *nvp;
@@ -100,7 +100,7 @@ nfscl_nget(struct mount *mntp, struct vn
 
 	hash = fnv_32_buf(nfhp->nfh_fh, nfhp->nfh_len, FNV1_32_INIT);
 
-	error = vfs_hash_get(mntp, hash, LK_EXCLUSIVE,
+	error = vfs_hash_get(mntp, hash, lkflags,
 	    td, &nvp, newnfs_vncmpf, nfhp);
 	if (error == 0 && nvp != NULL) {
 		/*
@@ -244,7 +244,7 @@ nfscl_nget(struct mount *mntp, struct vn
 		uma_zfree(newnfsnode_zone, np);
 		return (error);
 	}
-	error = vfs_hash_insert(vp, hash, LK_EXCLUSIVE, 
+	error = vfs_hash_insert(vp, hash, lkflags, 
 	    td, &nvp, newnfs_vncmpf, nfhp);
 	if (error)
 		return (error);

Modified: head/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clrpcops.c	Sat Apr 16 22:15:59 2011	(r220731)
+++ head/sys/fs/nfsclient/nfs_clrpcops.c	Sat Apr 16 23:20:21 2011	(r220732)
@@ -3271,7 +3271,7 @@ nfsrpc_readdirplus(vnode_t vp, struct ui
 				    np = dnp;
 				} else {
 				    error = nfscl_nget(vnode_mount(vp), vp,
-				      nfhp, cnp, p, &np, NULL);
+				      nfhp, cnp, p, &np, NULL, LK_EXCLUSIVE);
 				    if (!error) {
 					newvp = NFSTOV(np);
 					unlocknewvp = 1;

Modified: head/sys/fs/nfsclient/nfs_clvfsops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clvfsops.c	Sat Apr 16 22:15:59 2011	(r220731)
+++ head/sys/fs/nfsclient/nfs_clvfsops.c	Sat Apr 16 23:20:21 2011	(r220732)
@@ -273,7 +273,7 @@ nfs_statfs(struct mount *mp, struct stat
 	error = vfs_busy(mp, MBF_NOWAIT);
 	if (error)
 		return (error);
-	error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np);
+	error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np, LK_EXCLUSIVE);
 	if (error) {
 		vfs_unbusy(mp);
 		return (error);
@@ -1221,7 +1221,8 @@ mountnfs(struct nfs_args *argp, struct m
 		 * by nfs_statfs() before any I/O occurs.
 		 */
 		mp->mnt_stat.f_iosize = NFS_DIRBLKSIZ;
-		error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np);
+		error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np,
+		    LK_EXCLUSIVE);
 		if (error)
 			goto bad;
 		*vpp = NFSTOV(np);
@@ -1336,7 +1337,7 @@ nfs_root(struct mount *mp, int flags, st
 	int error;
 
 	nmp = VFSTONFS(mp);
-	error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np);
+	error = ncl_nget(mp, nmp->nm_fh, nmp->nm_fhsize, &np, flags);
 	if (error)
 		return error;
 	vp = NFSTOV(np);

Modified: head/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clvnops.c	Sat Apr 16 22:15:59 2011	(r220731)
+++ head/sys/fs/nfsclient/nfs_clvnops.c	Sat Apr 16 23:20:21 2011	(r220732)
@@ -1156,7 +1156,8 @@ nfs_lookup(struct vop_lookup_args *ap)
 			FREE((caddr_t)nfhp, M_NFSFH);
 			return (EISDIR);
 		}
-		error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL);
+		error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL,
+		    LK_EXCLUSIVE);
 		if (error)
 			return (error);
 		newvp = NFSTOV(np);
@@ -1185,7 +1186,8 @@ nfs_lookup(struct vop_lookup_args *ap)
 				return (error);
 		}
 		VOP_UNLOCK(dvp, 0);
-		error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL);
+		error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL,
+		    cnp->cn_lkflags);
 		if (error == 0)
 			newvp = NFSTOV(np);
 		vfs_unbusy(mp);
@@ -1213,7 +1215,8 @@ nfs_lookup(struct vop_lookup_args *ap)
 			(void) nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL,
 			    0, 1);
 	} else {
-		error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL);
+		error = nfscl_nget(mp, dvp, nfhp, cnp, td, &np, NULL,
+		    cnp->cn_lkflags);
 		if (error)
 			return (error);
 		newvp = NFSTOV(np);
@@ -1395,7 +1398,7 @@ nfs_mknodrpc(struct vnode *dvp, struct v
 			    NULL);
 		if (nfhp)
 			error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp,
-			    cnp->cn_thread, &np, NULL);
+			    cnp->cn_thread, &np, NULL, LK_EXCLUSIVE);
 	}
 	if (dattrflag)
 		(void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1);
@@ -1508,7 +1511,7 @@ again:
 			    NULL);
 		if (nfhp != NULL)
 			error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp,
-			    cnp->cn_thread, &np, NULL);
+			    cnp->cn_thread, &np, NULL, LK_EXCLUSIVE);
 	}
 	if (dattrflag)
 		(void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1);
@@ -1931,7 +1934,7 @@ nfs_symlink(struct vop_symlink_args *ap)
 	    &nfsva, &nfhp, &attrflag, &dattrflag, NULL);
 	if (nfhp) {
 		ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, cnp->cn_thread,
-		    &np, NULL);
+		    &np, NULL, LK_EXCLUSIVE);
 		if (!ret)
 			newvp = NFSTOV(np);
 		else if (!error)
@@ -2014,7 +2017,7 @@ nfs_mkdir(struct vop_mkdir_args *ap)
 		dnp->n_attrstamp = 0;
 	if (nfhp) {
 		ret = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp, cnp->cn_thread,
-		    &np, NULL);
+		    &np, NULL, LK_EXCLUSIVE);
 		if (!ret) {
 			newvp = NFSTOV(np);
 			if (attrflag)
@@ -2389,7 +2392,7 @@ printf("replace=%s\n",nnn);
 		    cn.cn_nameptr = name;
 		    cn.cn_namelen = len;
 		    error = nfscl_nget(dvp->v_mount, dvp, nfhp, &cn, td,
-			&np, NULL);
+			&np, NULL, LK_EXCLUSIVE);
 		    if (error)
 			return (error);
 		    newvp = NFSTOV(np);

Modified: head/sys/fs/nfsclient/nfsnode.h
==============================================================================
--- head/sys/fs/nfsclient/nfsnode.h	Sat Apr 16 22:15:59 2011	(r220731)
+++ head/sys/fs/nfsclient/nfsnode.h	Sat Apr 16 23:20:21 2011	(r220732)
@@ -176,7 +176,7 @@ int	ncl_reclaim(struct vop_reclaim_args 
 
 /* other stuff */
 int	ncl_removeit(struct sillyrename *, struct vnode *);
-int	ncl_nget(struct mount *, u_int8_t *, int, struct nfsnode **);
+int	ncl_nget(struct mount *, u_int8_t *, int, struct nfsnode **, int);
 nfsuint64 *ncl_getcookie(struct nfsnode *, off_t, int);
 void	ncl_invaldir(struct vnode *);
 int	ncl_upgrade_vnlock(struct vnode *);