From trasz at FreeBSD.org Sun Mar 1 02:51:35 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Sun Mar 1 02:51:42 2009 Subject: svn commit: r189224 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern Message-ID: <200903011051.n21ApYYP041203@svn.freebsd.org> Author: trasz Date: Sun Mar 1 10:51:34 2009 New Revision: 189224 URL: http://svn.freebsd.org/changeset/base/189224 Log: MFC r174937 by imp. Reviewed by: imp Approved by: rwatson (mentor) Original commit log: A partial solution to some of the 'pull the umass device with a mounted FS' problems. These are more along the lines of 'avoiding an avoidable panic' than a complete solution to removable devices. We now close the barn door after the horse has gotten lose and has been hit by a truck, as it were. The barn no longer catches fire in this case, but the horse is still dead :-). The vfs_bio.c fix causes us not to put a failed write back into the dirty pool if the error returned was ENXIO. In that case, the buffer is treated like any other clean buffer that's being retured. ENXIO means the device isn't there anymore and will never be there again in the future, so retrying is futile. The vfs_mount.c fix treats 'ENXIO' as success for unmounting a file system. If the device is gone, retrying later won't help and we'll never be able to unmount the device. These two are part of a larger patch set submitted by the author. The other patches will be forth coming. I added comments to these two patches. Submitted by: Henrik Gulbrandsen Reviewed by: phk@ PR: usb/46176 (partial) Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/vfs_bio.c stable/7/sys/kern/vfs_mount.c Modified: stable/7/sys/kern/vfs_bio.c ============================================================================== --- stable/7/sys/kern/vfs_bio.c Sun Mar 1 09:51:50 2009 (r189223) +++ stable/7/sys/kern/vfs_bio.c Sun Mar 1 10:51:34 2009 (r189224) @@ -1170,6 +1170,7 @@ brelse(struct buf *bp) if (bp->b_iocmd == BIO_WRITE && (bp->b_ioflags & BIO_ERROR) && + bp->b_error != ENXIO && !(bp->b_flags & B_INVAL)) { /* * Failed write, redirty. Must clear BIO_ERROR to prevent @@ -1177,6 +1178,9 @@ brelse(struct buf *bp) * this case is not run and the next case is run to * destroy the buffer. B_INVAL can occur if the buffer * is outside the range supported by the underlying device. + * If the error is that the device went away (ENXIO), we + * shouldn't redirty the buffer either, but discard the + * data too. */ bp->b_ioflags &= ~BIO_ERROR; bdirty(bp); Modified: stable/7/sys/kern/vfs_mount.c ============================================================================== --- stable/7/sys/kern/vfs_mount.c Sun Mar 1 09:51:50 2009 (r189223) +++ stable/7/sys/kern/vfs_mount.c Sun Mar 1 10:51:34 2009 (r189224) @@ -1293,8 +1293,13 @@ dounmount(mp, flags, td) error = VFS_UNMOUNT(mp, flags, td); } vn_finished_write(mp); - if (error) { - /* Undo cdir/rdir and rootvnode changes made above. */ + /* + * If we failed to flush the dirty blocks for this mount point, + * undo all the cdir/rdir and rootvnode changes we made above. + * Unless we failed to do so because the device is reporting that + * it doesn't exist anymore. + */ + if (error && error != ENXIO) { if ((flags & MNT_FORCE) && VFS_ROOT(mp, LK_EXCLUSIVE, &fsrootvp, td) == 0) { if (mp->mnt_vnodecovered != NULL) From trasz at FreeBSD.org Sun Mar 1 03:02:39 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Sun Mar 1 03:02:56 2009 Subject: svn commit: r189226 - in stable/7: share/man/man9 sys sys/contrib/pf sys/dev/cxgb sys/fs/hpfs sys/fs/msdosfs sys/fs/ntfs sys/fs/nwfs sys/fs/smbfs sys/gnu/fs/ext2fs sys/gnu/fs/reiserfs sys/gnu/fs/xf... Message-ID: <200903011102.n21B2b6G041531@svn.freebsd.org> Author: trasz Date: Sun Mar 1 11:02:37 2009 New Revision: 189226 URL: http://svn.freebsd.org/changeset/base/189226 Log: MFC r186194: According to phk@, VOP_STRATEGY should never, _ever_, return anything other than 0. Make it so. This fixes "panic: VOP_STRATEGY failed bp=0xc320dd90 vp=0xc3b9f648", encountered when writing to an orphaned filesystem. Reason for the panic was the following assert: KASSERT(i == 0, ("VOP_STRATEGY failed bp=%p vp=%p", bp, bp->b_vp)); at vfs_bio:bufstrategy(). Reviewed by: scottl, phk Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation Modified: stable/7/share/man/man9/ (props changed) stable/7/share/man/man9/VOP_STRATEGY.9 stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/hpfs/hpfs_vnops.c stable/7/sys/fs/msdosfs/msdosfs_vnops.c stable/7/sys/fs/ntfs/ntfs_vnops.c stable/7/sys/fs/nwfs/nwfs_vnops.c stable/7/sys/fs/smbfs/smbfs_vnops.c stable/7/sys/gnu/fs/ext2fs/ext2_vnops.c stable/7/sys/gnu/fs/reiserfs/reiserfs_vnops.c stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c stable/7/sys/ufs/ufs/ufs_vnops.c Modified: stable/7/share/man/man9/VOP_STRATEGY.9 ============================================================================== --- stable/7/share/man/man9/VOP_STRATEGY.9 Sun Mar 1 11:01:00 2009 (r189225) +++ stable/7/share/man/man9/VOP_STRATEGY.9 Sun Mar 1 11:02:37 2009 (r189226) @@ -53,7 +53,9 @@ This call either reads or writes data fr .Pp The call may block. .Sh RETURN VALUES -Zero is returned on success, otherwise an error is returned. +Always zero. +Errors should be signalled by setting BIO_ERROR on b_ioflags field in struct buf, +and setting b_error to the appropriate errno value. .Sh SEE ALSO .\" .Xr buf 9 , .Xr vnode 9 Modified: stable/7/sys/fs/hpfs/hpfs_vnops.c ============================================================================== --- stable/7/sys/fs/hpfs/hpfs_vnops.c Sun Mar 1 11:01:00 2009 (r189225) +++ stable/7/sys/fs/hpfs/hpfs_vnops.c Sun Mar 1 11:02:37 2009 (r189226) @@ -663,7 +663,7 @@ hpfs_strategy(ap) bp->b_error = error; bp->b_ioflags |= BIO_ERROR; bufdone(bp); - return (error); + return (0); } if ((long)bp->b_blkno == -1) vfs_bio_clrbuf(bp); Modified: stable/7/sys/fs/msdosfs/msdosfs_vnops.c ============================================================================== --- stable/7/sys/fs/msdosfs/msdosfs_vnops.c Sun Mar 1 11:01:00 2009 (r189225) +++ stable/7/sys/fs/msdosfs/msdosfs_vnops.c Sun Mar 1 11:02:37 2009 (r189226) @@ -1880,7 +1880,7 @@ msdosfs_strategy(ap) bp->b_error = error; bp->b_ioflags |= BIO_ERROR; bufdone(bp); - return (error); + return (0); } if ((long)bp->b_blkno == -1) vfs_bio_clrbuf(bp); Modified: stable/7/sys/fs/ntfs/ntfs_vnops.c ============================================================================== --- stable/7/sys/fs/ntfs/ntfs_vnops.c Sun Mar 1 11:01:00 2009 (r189225) +++ stable/7/sys/fs/ntfs/ntfs_vnops.c Sun Mar 1 11:02:37 2009 (r189226) @@ -339,7 +339,7 @@ ntfs_strategy(ap) } } bufdone(bp); - return (error); + return (0); } static int Modified: stable/7/sys/fs/nwfs/nwfs_vnops.c ============================================================================== --- stable/7/sys/fs/nwfs/nwfs_vnops.c Sun Mar 1 11:01:00 2009 (r189225) +++ stable/7/sys/fs/nwfs/nwfs_vnops.c Sun Mar 1 11:02:37 2009 (r189226) @@ -807,7 +807,7 @@ static int nwfs_strategy (ap) */ if ((bp->b_flags & B_ASYNC) == 0 ) error = nwfs_doio(ap->a_vp, bp, cr, td); - return (error); + return (0); } Modified: stable/7/sys/fs/smbfs/smbfs_vnops.c ============================================================================== --- stable/7/sys/fs/smbfs/smbfs_vnops.c Sun Mar 1 11:01:00 2009 (r189225) +++ stable/7/sys/fs/smbfs/smbfs_vnops.c Sun Mar 1 11:02:37 2009 (r189226) @@ -864,7 +864,7 @@ smbfs_strategy (ap) if ((bp->b_flags & B_ASYNC) == 0 ) error = smbfs_doio(ap->a_vp, bp, cr, td); - return error; + return (0); } int Modified: stable/7/sys/gnu/fs/ext2fs/ext2_vnops.c ============================================================================== --- stable/7/sys/gnu/fs/ext2fs/ext2_vnops.c Sun Mar 1 11:01:00 2009 (r189225) +++ stable/7/sys/gnu/fs/ext2fs/ext2_vnops.c Sun Mar 1 11:02:37 2009 (r189226) @@ -1408,7 +1408,7 @@ ext2_strategy(ap) bp->b_error = error; bp->b_ioflags |= BIO_ERROR; bufdone(bp); - return (error); + return (0); } if ((long)bp->b_blkno == -1) vfs_bio_clrbuf(bp); Modified: stable/7/sys/gnu/fs/reiserfs/reiserfs_vnops.c ============================================================================== --- stable/7/sys/gnu/fs/reiserfs/reiserfs_vnops.c Sun Mar 1 11:01:00 2009 (r189225) +++ stable/7/sys/gnu/fs/reiserfs/reiserfs_vnops.c Sun Mar 1 11:02:37 2009 (r189226) @@ -350,8 +350,13 @@ reiserfs_strategy(struct vop_strategy_ar bp->b_ioflags |= BIO_ERROR; } + if (error) { + bp->b_ioflags |= BIO_ERROR; + bp->b_error = error; + } + bufdone(bp); - return (error); + return (0); } /* Modified: stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c ============================================================================== --- stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c Sun Mar 1 11:01:00 2009 (r189225) +++ stable/7/sys/gnu/fs/xfs/FreeBSD/xfs_vnops.c Sun Mar 1 11:02:37 2009 (r189226) @@ -1138,7 +1138,7 @@ _xfs_strategy( bp->b_error = error; bp->b_ioflags |= BIO_ERROR; bufdone(bp); - return (error); + return (0); } if ((long)bp->b_blkno == -1) vfs_bio_clrbuf(bp); Modified: stable/7/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/7/sys/ufs/ufs/ufs_vnops.c Sun Mar 1 11:01:00 2009 (r189225) +++ stable/7/sys/ufs/ufs/ufs_vnops.c Sun Mar 1 11:02:37 2009 (r189226) @@ -2015,7 +2015,7 @@ ufs_strategy(ap) bp->b_error = error; bp->b_ioflags |= BIO_ERROR; bufdone(bp); - return (error); + return (0); } if ((long)bp->b_blkno == -1) vfs_bio_clrbuf(bp); From trasz at FreeBSD.org Sun Mar 1 03:11:16 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Sun Mar 1 03:11:32 2009 Subject: svn commit: r189227 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/devfs Message-ID: <200903011111.n21BBFCD041749@svn.freebsd.org> Author: trasz Date: Sun Mar 1 11:11:14 2009 New Revision: 189227 URL: http://svn.freebsd.org/changeset/base/189227 Log: MFC r186911: Don't panic with "vinvalbuf: dirty bufs" when the mounted device that was being written to goes away. Reviewed by: kib, scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/devfs/devfs_vnops.c Modified: stable/7/sys/fs/devfs/devfs_vnops.c ============================================================================== --- stable/7/sys/fs/devfs/devfs_vnops.c Sun Mar 1 11:02:37 2009 (r189226) +++ stable/7/sys/fs/devfs/devfs_vnops.c Sun Mar 1 11:11:14 2009 (r189227) @@ -481,12 +481,28 @@ devfs_close_f(struct file *fp, struct th return (error); } -/* ARGSUSED */ static int devfs_fsync(struct vop_fsync_args *ap) { - if (!vn_isdisk(ap->a_vp, NULL)) + int error; + struct bufobj *bo; + struct devfs_dirent *de; + + if (!vn_isdisk(ap->a_vp, &error)) { + bo = &ap->a_vp->v_bufobj; + de = ap->a_vp->v_data; + if (error == ENXIO && bo->bo_dirty.bv_cnt > 0) { + printf("Device %s went missing before all of the data " + "could be written to it; expect data loss.\n", + de->de_dirent->d_name); + + error = vop_stdfsync(ap); + if (bo->bo_dirty.bv_cnt != 0 || error != 0) + panic("devfs_fsync: vop_stdfsync failed."); + } + return (0); + } return (vop_stdfsync(ap)); } From trasz at FreeBSD.org Sun Mar 1 03:17:39 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Sun Mar 1 03:17:46 2009 Subject: svn commit: r189228 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/msdosfs Message-ID: <200903011117.n21BHdnY041897@svn.freebsd.org> Author: trasz Date: Sun Mar 1 11:17:38 2009 New Revision: 189228 URL: http://svn.freebsd.org/changeset/base/189228 Log: MFC r187199: Turn a "panic: non-decreasing id" into an error printf. This seems to be caused by a metadata corruption that occurs quite often after unplugging a pendrive during write activity. Reviewed by: scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/msdosfs/msdosfs_conv.c Modified: stable/7/sys/fs/msdosfs/msdosfs_conv.c ============================================================================== --- stable/7/sys/fs/msdosfs/msdosfs_conv.c Sun Mar 1 11:11:14 2009 (r189227) +++ stable/7/sys/fs/msdosfs/msdosfs_conv.c Sun Mar 1 11:17:38 2009 (r189228) @@ -1060,8 +1060,11 @@ mbnambuf_write(struct mbnambuf *nbp, cha char *slot; size_t count, newlen; - KASSERT(nbp->nb_len == 0 || id == nbp->nb_last_id - 1, - ("non-decreasing id: id %d, last id %d", id, nbp->nb_last_id)); + if (nbp->nb_len != 0 && id != nbp->nb_last_id - 1) { + printf("msdosfs: non-decreasing id: id %d, last id %d\n", + id, nbp->nb_last_id); + return; + } /* Will store this substring in a WIN_CHARS-aligned slot. */ slot = &nbp->nb_buf[id * WIN_CHARS]; From trasz at FreeBSD.org Sun Mar 1 03:20:37 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Sun Mar 1 03:20:48 2009 Subject: svn commit: r189229 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb ufs/ffs Message-ID: <200903011120.n21BKZOQ041999@svn.freebsd.org> Author: trasz Date: Sun Mar 1 11:20:35 2009 New Revision: 189229 URL: http://svn.freebsd.org/changeset/base/189229 Log: MFC r188240: When a device containing mounted UFS filesystem disappears, the type of devvp becomes VBAD, which UFS incorrectly interprets as snapshot vnode, which in turns causes panic. Fix it by replacing '!= VCHR' with '== VREG'. With this fix in place, you should no longer be able to panic the system by removing a device with an UFS filesystem mounted from it - assuming you don't use softupdates. Reviewed by: kib Tested by: pho Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_alloc.c Modified: stable/7/sys/ufs/ffs/ffs_alloc.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_alloc.c Sun Mar 1 11:17:38 2009 (r189228) +++ stable/7/sys/ufs/ffs/ffs_alloc.c Sun Mar 1 11:20:35 2009 (r189229) @@ -1858,7 +1858,7 @@ ffs_blkfree(ump, fs, devvp, bno, size, i struct cdev *dev; cg = dtog(fs, bno); - if (devvp->v_type != VCHR) { + if (devvp->v_type == VREG) { /* devvp is a snapshot */ dev = VTOI(devvp)->i_devvp->v_rdev; cgblkno = fragstoblks(fs, cgtod(fs, cg)); @@ -1903,7 +1903,7 @@ ffs_blkfree(ump, fs, devvp, bno, size, i if (size == fs->fs_bsize) { fragno = fragstoblks(fs, cgbno); if (!ffs_isfreeblock(fs, blksfree, fragno)) { - if (devvp->v_type != VCHR) { + if (devvp->v_type == VREG) { UFS_UNLOCK(ump); /* devvp is a snapshot */ brelse(bp); @@ -2056,7 +2056,7 @@ ffs_freefile(ump, fs, devvp, ino, mode) struct cdev *dev; cg = ino_to_cg(fs, ino); - if (devvp->v_type != VCHR) { + if (devvp->v_type == VREG) { /* devvp is a snapshot */ dev = VTOI(devvp)->i_devvp->v_rdev; cgbno = fragstoblks(fs, cgtod(fs, cg)); @@ -2122,7 +2122,7 @@ ffs_checkfreefile(fs, devvp, ino) u_int8_t *inosused; cg = ino_to_cg(fs, ino); - if (devvp->v_type != VCHR) { + if (devvp->v_type == VREG) { /* devvp is a snapshot */ cgbno = fragstoblks(fs, cgtod(fs, cg)); } else { From luigi at FreeBSD.org Sun Mar 1 06:57:34 2009 From: luigi at FreeBSD.org (Luigi Rizzo) Date: Sun Mar 1 06:57:41 2009 Subject: svn commit: r189235 - stable/7/release/picobsd/bridge Message-ID: <200903011457.n21EvXB8046412@svn.freebsd.org> Author: luigi Date: Sun Mar 1 14:57:33 2009 New Revision: 189235 URL: http://svn.freebsd.org/changeset/base/189235 Log: document the possibility of hardwiring kenv/getenv values; remove duplicate isa and npx entries; remove DEVICE_POLLING add tap, bpf devices; add re and nfe drivers Modified: stable/7/release/picobsd/bridge/PICOBSD Modified: stable/7/release/picobsd/bridge/PICOBSD ============================================================================== --- stable/7/release/picobsd/bridge/PICOBSD Sun Mar 1 14:51:07 2009 (r189234) +++ stable/7/release/picobsd/bridge/PICOBSD Sun Mar 1 14:57:33 2009 (r189235) @@ -7,6 +7,10 @@ options MD_ROOT_SIZE=3200 # same as def_sz hints "PICOBSD.hints" + +# values accessible through getenv() +# env "PICOBSD.env" + cpu I486_CPU cpu I586_CPU cpu I686_CPU @@ -41,7 +45,6 @@ options DUMMYNET device if_bridge options HZ=1000 -device isa device pci # Floppy drives @@ -64,9 +67,6 @@ device vga # VGA screen device sc -# Floating point support - do not disable. -device npx - # Serial (COM) ports device sio @@ -91,8 +91,10 @@ device miibus #device de # DEC/Intel DC21x4x (``Tulip'') #device lnc device fxp # Intel EtherExpress PRO/100B (82557, 82558) +device nfe # nVidia nForce MCP on-board Ethernet #device xl # 3Com device rl # RealTek 8129/8139 +device re # RealTek 8139C+/8169/8169S/8110S device sis # National/SiS #device vx # 3Com 3c590, 3c595 (``Vortex'') #device wx # Intel Gigabit Ethernet Card (``Wiseman'') @@ -107,10 +109,10 @@ device pty # Pseudo-ttys (telnet etc) device md # Memory "disks" #device gif 4 # IPv6 and IPv4 tunneling #device faith 1 # IPv6-to-IPv4 relaying (translation) -#device tap +device tap -options DEVICE_POLLING +#options DEVICE_POLLING # The `bpf' device enables the Berkeley Packet Filter. # Be aware of the administrative consequences of enabling this! -#device bpf # Berkeley packet filter +device bpf # Berkeley packet filter From trasz at FreeBSD.org Sun Mar 1 07:01:02 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Sun Mar 1 07:01:14 2009 Subject: svn commit: r189236 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb ufs/ffs Message-ID: <200903011501.n21F10gv046543@svn.freebsd.org> Author: trasz Date: Sun Mar 1 15:01:00 2009 New Revision: 189236 URL: http://svn.freebsd.org/changeset/base/189236 Log: MFC r187894. Note that r188501 should be merged too. Make sure the cdev doesn't go away while the filesystem is still mounted. Otherwise dev2udev() could return garbage. Reviewed by: kib Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_vfsops.c Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vfsops.c Sun Mar 1 14:57:33 2009 (r189235) +++ stable/7/sys/ufs/ffs/ffs_vfsops.c Sun Mar 1 15:01:00 2009 (r189236) @@ -641,6 +641,7 @@ ffs_mountfs(devvp, mp, td) VOP_UNLOCK(devvp, 0, td); if (error) return (error); + dev_ref(dev); if (devvp->v_rdev->si_iosize_max != 0) mp->mnt_iosize_max = devvp->v_rdev->si_iosize_max; if (mp->mnt_iosize_max > MAXPHYS) @@ -921,6 +922,7 @@ out: free(ump, M_UFSMNT); mp->mnt_data = (qaddr_t)0; } + dev_rel(dev); return (error); } @@ -1107,6 +1109,7 @@ ffs_unmount(mp, mntflags, td) g_topology_unlock(); PICKUP_GIANT(); vrele(ump->um_devvp); + dev_rel(ump->um_dev); mtx_destroy(UFS_MTX(ump)); if (mp->mnt_gjprovider != NULL) { free(mp->mnt_gjprovider, M_UFSMNT); From luigi at FreeBSD.org Sun Mar 1 07:03:21 2009 From: luigi at FreeBSD.org (Luigi Rizzo) Date: Sun Mar 1 07:04:32 2009 Subject: svn commit: r189237 - stable/7/release/picobsd/build Message-ID: <200903011503.n21F38RH046613@svn.freebsd.org> Author: luigi Date: Sun Mar 1 15:03:08 2009 New Revision: 189237 URL: http://svn.freebsd.org/changeset/base/189237 Log: sync the build script with the version in -current. The most relevant changes are the building of libraries in the --init call, and the ability to use /boot/loader (on by default) which seems to be necessary for large kernels. Modified: stable/7/release/picobsd/build/picobsd Modified: stable/7/release/picobsd/build/picobsd ============================================================================== --- stable/7/release/picobsd/build/picobsd Sun Mar 1 15:01:00 2009 (r189236) +++ stable/7/release/picobsd/build/picobsd Sun Mar 1 15:03:08 2009 (r189237) @@ -21,7 +21,6 @@ # Makefile.conf Makefile used to build the kernel # config shell variables, sourced here. # mfs.mtree mtree config file -# # floppy.tree/ files which go on the floppy # mfs_tree/ files which go onto the mfs # @@ -29,10 +28,13 @@ # PICOBSD kernel config file # config shell variables, sourced here. # crunch.conf crunchgen configuration +# mfs.mtree overrides ${PICO_TREE}/mfs.mtree # floppy.tree.exclude files from floppy.tree/ which we do not need here. -# floppy.tree/ local additions to the floppy.tree +# floppy.tree/ local additions to ${PICO_TREE}/mfs_free # floppy.tree.${site}/ same as above, site specific. # mfs_tree/ local additions to the mfs_free +# buildtree.mk optional makefile to build an extension for floppy tree +# (generated in buildtree/ ) # #--- The main entry point is at the end. @@ -98,6 +100,7 @@ set_defaults() { EDITOR=${EDITOR:-vi} fd_size=${fd_size:-1440} + o_use_loader="yes" # use /boot/loader o_all_in_mfs="yes" # put all files in mfs so you can boot and run # the image via diskless boot. o_clean="" # do not clean @@ -127,6 +130,7 @@ set_defaults() { # mountpoint used to build memory filesystems c_fs=fs.PICOBSD # filename used for the memory filesystem c_img=picobsd.bin # filename used for the picobsd image + generate_iso="NO" # don't generate the iso image # select the right memory disk name case `uname -r` in @@ -146,6 +150,7 @@ set_defaults() { trap fail 15 } +# use the new build infrastructure create_includes_and_libraries2() { local no log "create_includes_and_libraries2() for ${SRC}" @@ -158,7 +163,7 @@ create_includes_and_libraries2() { export MAKEOBJDIRPREFIX ( cd ${SRC}; # make -DNOCLEAN -DNOPROFILE -DNOGAMES -DNOLIBC_R -DPICOBSD buildworld - make _+_= $no toolchain + make _+_= $no toolchain _includes _libraries ) } @@ -207,7 +212,7 @@ create_includes_and_libraries() { # set_type looks in user or system directories for the floppy type # specified as first argument, and sets variables according to the config. -# file. Sets THETYPE, SITE, name, MY_TREE and BUILDDIR +# file. Also sets MY_TREE and BUILDDIR and SITE set_type() { local a i @@ -220,17 +225,17 @@ set_type() { for i in ${c_startdir}/${a} ${PICO_TREE}/${a} ; do log "set_type: checking $i" [ -d $i -a -f $i/PICOBSD -a -f $i/crunch.conf ] || continue - set -- `cat $i/PICOBSD | \ + set -- `cat $i/PICOBSD | \ awk '/^#PicoBSD/ {print $2, $3, $4, $5, $6}'` [ x"$1" != "x" ] || continue - MFS_SIZE=$1 ; init_name=$2 - mfs_inodes=$3 ; fd_inodes=$4 - name=`(cd $i ; pwd) ` - name=`basename $name` - MY_TREE=$i - BUILDDIR=${c_startdir}/build_dir-${name} - log "Matching file $name in $i" - return ; + MFS_SIZE=$1 ; init_name=$2 + mfs_inodes=$3 ; fd_inodes=$4 + name=`(cd $i ; pwd) ` + name=`basename $name` + MY_TREE=$i + BUILDDIR=${c_startdir}/build_dir-${name} + log "Matching file $name in $i" + return ; done logverbose "Type $a NOT FOUND" } @@ -255,6 +260,13 @@ set_msgs() { # OK \t3. Site-info: ${SITE}\n\t4. Full-path: ${MY_TREE}\n" } +# build the iso image +build_iso_image() { + log "build_iso_image()" + clear + set_msgs + printf "${MSG}---> Build the iso image not ready yet\n\n" +} # Main build procedure. build_image() { @@ -307,10 +319,6 @@ build_package() { echo "##############################################" >>build.status for z in bridge dial router net isp ; do set_type ${z} - if [ "${name}" = "" ] ; then - echo "*** TYPE=${z} not found" >>build.status - continue - fi echo "---------------------------------------------">>build.status echo "Building TYPE=${z}, SIZE=${MFS_SIZE}" >>build.status msg="(ok)" # error message @@ -484,10 +492,10 @@ populate_floppy_fs() { # OK dst=${BUILDDIR}/floppy.tree log "pwd=`pwd` Populating floppy filesystem..." - # clean relics from old compilations. - rm -rf ${dst} || true - mkdir ${dst} + rm -rf ${dst} || true # clean relics from old compilations. + mkdir ${dst} # create a clean tree + # compute exclude list for generic tree excl=${MY_TREE}/floppy.tree.exclude if [ -f ${excl} ] ; then log "Files excluded from generic tree: `echo;cat ${excl}`" @@ -495,29 +503,26 @@ populate_floppy_fs() { # OK else excl="" fi - (cd ${PICO_TREE}/floppy.tree ; tar -cf - --exclude CVS --exclude .svn \ - ${excl} . ) | \ + # copy from the floppy trees into the destination + for FLOPPY_TREE in ${PICO_TREE}/floppy.tree ${MY_TREE}/floppy.tree \ + ${MY_TREE}/floppy.tree.${SITE} ; do + if [ -d ${FLOPPY_TREE} ] ; then + (cd ${FLOPPY_TREE} ; tar -cf - --exclude CVS \ + --exclude .svn ${excl} . ) | \ (cd ${dst} ; tar x${o_tarv}f - ) - log "Copied from generic floppy-tree `echo; ls -laR ${dst}`" - - srcdir=${MY_TREE}/floppy.tree - if [ -d ${srcdir} ] ; then - log "update with type-specific files:" - (cd ${srcdir} ; tar -cf - --exclude CVS --exclude .svn . ) | \ - (cd ${dst} ; tar x${o_tarv}f - ) - log "Copied from type floppy-tree `echo; ls -laR ${dst}`" - else - log "No type-specific floppy-tree" - fi - if [ -d ${srcdir}.${SITE} ] ; then - log "Update with site-specific (${SITE}) files:" - (cd ${srcdir}.${SITE} ; tar -cf - --exclude CVS --exclude .svn . ) | \ - (cd ${dst} ; tar x${o_tarv}f - ) - log "Copied from site floppy-tree `echo; ls -laR ${dst}`" - else - log "No site-specific floppy-tree" - fi + log "Copied from ${FLOPPY_TREE}" + fi + excl="" # reset the exclude list. + done + # add local manipulation + if [ -f ${MY_TREE}/buildtree.mk ] ; then + log "building local floppy tree" + ${BINMAKE} -C ${dst} -f ${MY_TREE}/buildtree.mk floppy.tree + fi + + # compress the files in etc/, just in case + # XXX this should be done in the makefile. # gzip returns an error if it fails to compress some file (cd $dst ; gzip -9 etc/* log "Compressed files in etc/ `echo; ls -l etc`" @@ -532,13 +537,12 @@ populate_floppy_fs() { # OK # Finally, if required, make a copy of the floppy.tree onto /fd populate_mfs_tree() { - local a dst + local a dst MFS_TREE log "populate_mfs_tree()" dst=${BUILDDIR}/mfs.tree - # clean relics from old compilations. - rm -rf ${dst} || true - mkdir ${dst} + rm -rf ${dst} || true # clean relics from old compilations. + mkdir ${dst} # create a fresh tree log "pwd=`pwd`, Populating MFS tree..." @@ -555,7 +559,7 @@ populate_mfs_tree() { ln -s /dev/null ${dst}/var/run/log ln -s /etc/termcap ${dst}/usr/share/misc/termcap - + ### now build the crunched binaries ### ( cd ${BUILDDIR}/crunch log "Making and installing crunch1 from `pwd` src ${SRC}..." @@ -599,12 +603,18 @@ populate_mfs_tree() { fi done + if [ -f ${MY_TREE}/buildtree.mk ] ; then + log "building local floppy tree" + ${BINMAKE} -C ${dst} -f ${MY_TREE}/buildtree.mk mfs.tree + fi + if [ "${o_all_in_mfs}" = "yes" ]; then log "Copy generic floppy_tree into MFS..." - # this may fail in case the floppy is empty + # ignore failure in case the floppy is empty cp -Rp ${BUILDDIR}/floppy.tree/* ${dst}/fd || true fi + # 4.x compatibility - create device nodes if [ "${o_no_devfs}" != "" ] ; then # create device entries using MAKEDEV (cd ${dst}/dev @@ -623,19 +633,21 @@ populate_mfs_tree() { log "importing ${import_files} into mfs" # We do it in a chroot environment on the target so # symlinks are followed correctly. - cp `which tar` ${dst}/my_copy_of_tar + # Make sure we have a statically linked tar there. + mkdir -p ${dst}/rescue + cp /rescue/tar ${dst}/rescue (cd ${l_usrtree}/.. ; tar cf - ${import_files} ) | \ - (chroot ${dst} /my_copy_of_tar xf - ) - rm ${dst}/my_copy_of_tar + (chroot ${dst} /rescue/tar xPf - ) + rm -rf ${dst}/rescue fi (cd ${BUILDDIR} # override the owner echo "/set uid=0 gid=0" > mtree.out - mtree -c -p ${dst} -k "" >> mtree.out + mtree -ic -p ${dst} -k "" >> mtree.out log "mtre.out at ${BUILDDIR}/mtree.out" makefs -t ffs -o bsize=4096 -o fsize=512 \ - -s ${MFS_SIZE}k -f 100 -F mtree.out ${c_fs} ${dst} + -s ${MFS_SIZE}k -f 1000 -F mtree.out ${c_fs} ${dst} ls -l ${c_fs} ) log "done mfs image" } @@ -712,14 +724,16 @@ fill_floppy_image() { fi log "Labeling floppy image" - log "patch ${c_boot2} to boot /kernel right away" b2=${BUILDDIR}/boot2 # modified boot2 cp -f ${c_boot2} ${b2} chmod 0644 ${b2} - set `strings -at d ${b2} | grep "/boot/loader"` - echo -e "/kernel\0\0\0\0\0" | \ - dd of=${b2} obs=$1 oseek=1 conv=notrunc 2>/dev/null + if [ ${o_use_loader} = "no" ] ; then + log "patch ${c_boot2} to boot /kernel right away" + set `strings -at d ${b2} | grep "/boot/loader"` + echo -e "/kernel\0\0\0\0\0" | \ + dd of=${b2} obs=$1 oseek=1 conv=notrunc 2>/dev/null + fi chmod 0444 ${b2} dst=${BUILDDIR}/image.tree @@ -739,22 +753,39 @@ fill_floppy_image() { if [ ${mfs_start} -gt 0 -a ${mfs_size} -ge ${imgsize} ] ; then mfs_ofs=$((${mfs_start} + 8192)) log "Preload kernel with file ${c_fs} at ${mfs_ofs}" + logverbose "`ls -l ${c_fs}` to fit in ${mfs_size}" dd if=${c_fs} ibs=8192 iseek=1 of=kernel obs=${mfs_ofs} \ - oseek=1 conv=notrunc 2> /dev/null + oseek=1 conv=notrunc # 2> /dev/null else log "not loading mfs, size ${mfs_size} img ${imgsize}" fi log "Compress with kgzip and copy to floppy image" - kgzip -o kernel.gz kernel - cp -p kernel.gz ${dst}/kernel || fail $? no_space "copying kernel" + if [ ${o_use_loader} = "no" ] ; then + kgzip -o kernel.gz kernel + cp -p kernel.gz ${dst}/kernel || fail $? no_space "copying kernel" + else + gzip kernel + mkdir -p ${dst}/boot/kernel + echo "hint.acpi.0.disabled=\"1\"" > ${dst}/boot/loader.conf + echo "console=\"comconsole\"" >> ${dst}/boot/loader.conf + cp -p /boot/loader ${dst}/boot/loader || fail $? no_space "copying bootloader" + cp -p kernel.gz ${dst}/boot/kernel/kernel.gz || fail $? no_space "copying kernel" + fi - log "Now transfer floppy tree if not already in MFS image" # now transfer the floppy tree. If it is already in mfs, dont bother. if [ "${o_all_in_mfs}" != "yes" ] ; then + log "Now transfer floppy tree if not already in MFS image" cp -Rp floppy.tree/* ${dst} || \ fail $? no_space "copying floppy tree" fi ) + + # add local manipulation to the image + if [ -f ${MY_TREE}/buildtree.mk ] ; then + ${BINMAKE} -C ${dst} -f ${MY_TREE}/buildtree.mk image.tree + fi + + log "image used `du -s ${dst}` of ${blocks}k" (cd ${BUILDDIR} makefs -t ffs -o bsize=4096 -o fsize=512 \ -s ${blocks}k -f 50 ${c_img} ${dst} @@ -764,9 +795,19 @@ fill_floppy_image() { ${l_label} -f `pwd`/${c_img} | sed -e '/ c:/{p;s/c:/a:/;}' | \ ${l_label} -R -f `pwd`/${c_img} /dev/stdin ${l_label} -f `pwd`/${c_img} + ls -l ${c_img} - logverbose "after disklabel" - ) + ${l_label} -f `pwd`/${c_img} + logverbose "after disklabel" + ) + + echo "BUILDDIR ${BUILDDIR}" + if [ "${generate_iso}" = "YES" ]; then + echo "generate_iso ${generate_iso}" + #build_iso_image() + exit 1 + fi + # dump the primary and secondary boot # XXX primary is 512 bytes dd if=${c_boot1} of=${BUILDDIR}/${c_img} conv=notrunc 2>/dev/null @@ -781,7 +822,8 @@ fill_floppy_image() { rm -rf ${BUILDDIR}/floppy.tree || true # cleanup # df -ik ${dst} | colrm 70 > .build.reply rm -rf ${dst} - rm ${BUILDDIR}/kernel.gz ${BUILDDIR}/${c_fs} + rm ${BUILDDIR}/${c_fs} + # rm ${BUILDDIR}/kernel.gz } # This function creates variables which depend on the source tree in use: @@ -824,8 +866,7 @@ set_build_parameters() { # arguments. set_defaults -args="" -while [ x"$1" != x ]; do +while [ true ]; do case $1 in --src) # set the source path instead of /usr/src SRC=`(cd $2; pwd)` @@ -840,12 +881,17 @@ while [ x"$1" != x ]; do shift ;; + --no_loader) # omit /boot/loader, just rely on boot2 + # (it may have problems with kernels > 4MB) + o_use_loader="no" + ;; + --all_in_mfs) o_all_in_mfs="yes" ;; --no_all_in_mfs) - o_all_in_mfs="" + o_all_in_mfs="no" ;; --modules) # also build kernel modules @@ -865,21 +911,24 @@ while [ x"$1" != x ]; do o_tarv="v" # tar verbose flag o_makeopts="-d l" # be verbose ;; + + --iso) # generate iso image + generate_iso="YES" + ;; + *) - args="$args $1" # accumulate args + break ;; esac shift done set_build_parameters # things that depend on ${SRC} +set_type $1 $2 # type and site, respectively # If $1="package", it creates a neat set of floppies -set -- ${args} [ "$1" = "package" ] && build_package -set_type $args # type and site, respectively - [ "${o_interactive}" != "NO" ] && main_dialog if [ "${o_clean}" = "YES" ] ; then From scottl at FreeBSD.org Sun Mar 1 08:24:58 2009 From: scottl at FreeBSD.org (Scott Long) Date: Sun Mar 1 08:25:19 2009 Subject: svn commit: r189239 - in stable/7/sys: . cam/scsi contrib/pf dev/ath/ath_hal dev/cxgb Message-ID: <200903011624.n21GOvOi048222@svn.freebsd.org> Author: scottl Date: Sun Mar 1 16:24:57 2009 New Revision: 189239 URL: http://svn.freebsd.org/changeset/base/189239 Log: Merge 181381: Update SCSI opcodes and ASCs from t10.org. Modified: stable/7/sys/ (props changed) stable/7/sys/cam/scsi/scsi_all.c stable/7/sys/cam/scsi/scsi_all.h stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_all.c Sun Mar 1 15:08:33 2009 (r189238) +++ stable/7/sys/cam/scsi/scsi_all.c Sun Mar 1 16:24:57 2009 (r189239) @@ -103,23 +103,27 @@ static int set_scsi_delay(int delay); #if !defined(SCSI_NO_OP_STRINGS) -#define D 0x001 -#define T 0x002 -#define L 0x004 -#define P 0x008 -#define W 0x010 -#define R 0x020 -#define S 0x040 -#define O 0x080 -#define M 0x100 -#define C 0x200 -#define A 0x400 -#define E 0x800 +#define D (1 << T_DIRECT) +#define T (1 << T_SEQUENTIAL) +#define L (1 << T_PRINTER) +#define P (1 << T_PROCESSOR) +#define W (1 << T_WORM) +#define R (1 << T_CDROM) +#define O (1 << T_OPTICAL) +#define M (1 << T_CHANGER) +#define A (1 << T_STORARRAY) +#define E (1 << T_ENCLOSURE) +#define B (1 << T_RBC) +#define K (1 << T_OCRW) +#define V (1 << T_ADC) +#define F (1 << T_OSD) +#define S (1 << T_SCANNER) +#define C (1 << T_COMM) -#define ALL 0xFFF +#define ALL (D | T | L | P | W | R | O | M | A | E | B | K | V | F | S | C) static struct op_table_entry plextor_cd_ops[] = { - {0xD8, R, "CD-DA READ"} + { 0xD8, R, "CD-DA READ" } }; static struct scsi_op_quirk_entry scsi_op_quirk_table[] = { @@ -140,519 +144,456 @@ static struct scsi_op_quirk_entry scsi_o }; static struct op_table_entry scsi_op_codes[] = { -/* - * From: ftp://ftp.symbios.com/pub/standards/io/t10/drafts/spc/op-num.txt - * Modifications by Kenneth Merry (ken@FreeBSD.ORG) - * - * Note: order is important in this table, scsi_op_desc() currently - * depends on the opcodes in the table being in order to save search time. - */ -/* - * File: OP-NUM.TXT - * - * SCSI Operation Codes - * Numeric Sorted Listing - * as of 11/13/96 - * - * D - DIRECT ACCESS DEVICE (SBC) device column key - * .T - SEQUENTIAL ACCESS DEVICE (SSC) ------------------- - * . L - PRINTER DEVICE (SSC) M = Mandatory - * . P - PROCESSOR DEVICE (SPC) O = Optional - * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC) V = Vendor specific - * . . R - CD DEVICE (MMC) R = Reserved - * . . S - SCANNER DEVICE (SGC) Z = Obsolete - * . . .O - OPTICAL MEMORY DEVICE (SBC) - * . . . M - MEDIA CHANGER DEVICE (SMC) - * . . . C - COMMUNICATION DEVICE (SSC) - * . . . .A - STORAGE ARRAY DEVICE (SCC) - * . . . . E - ENCLOSURE SERVICES DEVICE (SES) - * OP DTLPWRSOMCAE Description - * -- ------------ ---------------------------------------------------- */ -/* 00 MMMMMMMMMMMM TEST UNIT READY */ -{0x00, ALL, "TEST UNIT READY"}, - -/* 01 M REWIND */ -{0x01, T, "REWIND"}, -/* 01 Z V ZO ZO REZERO UNIT */ -{0x01, D|L|W|O|M, "REZERO UNIT"}, - -/* 02 VVVVVV V */ - -/* 03 MMMMMMMMMMMM REQUEST SENSE */ -{0x03, ALL, "REQUEST SENSE"}, - -/* 04 M O O FORMAT UNIT */ -{0x04, D|R|O, "FORMAT UNIT"}, -/* 04 O FORMAT MEDIUM */ -{0x04, T, "FORMAT MEDIUM"}, -/* 04 O FORMAT */ -{0x04, L, "FORMAT"}, - -/* 05 VMVVVV V READ BLOCK LIMITS */ -{0x05, T, "READ BLOCK LIMITS"}, - -/* 06 VVVVVV V */ - -/* 07 OVV O OV REASSIGN BLOCKS */ -{0x07, D|W|O, "REASSIGN BLOCKS"}, -/* 07 O INITIALIZE ELEMENT STATUS */ -{0x07, M, "INITIALIZE ELEMENT STATUS"}, - -/* 08 OMV OO OV READ(06) */ -{0x08, D|T|W|R|O, "READ(06)"}, -/* 08 O RECEIVE */ -{0x08, P, "RECEIVE"}, -/* 08 M GET MESSAGE(06) */ -{0x08, C, "GET MESSAGE(06)"}, - -/* 09 VVVVVV V */ - -/* 0A OM O OV WRITE(06) */ -{0x0A, D|T|W|O, "WRITE(06)"}, -/* 0A M SEND(06) */ -{0x0A, P, "SEND(06)"}, -/* 0A M SEND MESSAGE(06) */ -{0x0A, C, "SEND MESSAGE(06)"}, -/* 0A M PRINT */ -{0x0A, L, "PRINT"}, - -/* 0B Z ZO ZV SEEK(06) */ -{0x0B, D|W|R|O, "SEEK(06)"}, -/* 0B O SLEW AND PRINT */ -{0x0B, L, "SLEW AND PRINT"}, - -/* 0C VVVVVV V */ -/* 0D VVVVVV V */ -/* 0E VVVVVV V */ -/* 0F VOVVVV V READ REVERSE */ -{0x0F, T, "READ REVERSE"}, - -/* 10 VM VVV WRITE FILEMARKS */ -{0x10, T, "WRITE FILEMARKS"}, -/* 10 O O SYNCHRONIZE BUFFER */ -{0x10, L|W, "SYNCHRONIZE BUFFER"}, - -/* 11 VMVVVV SPACE */ -{0x11, T, "SPACE"}, - -/* 12 MMMMMMMMMMMM INQUIRY */ -{0x12, ALL, "INQUIRY"}, - -/* 13 VOVVVV VERIFY(06) */ -{0x13, T, "VERIFY(06)"}, - -/* 14 VOOVVV RECOVER BUFFERED DATA */ -{0x14, T|L, "RECOVER BUFFERED DATA"}, - -/* 15 OMO OOOOOOOO MODE SELECT(06) */ -{0x15, ALL & ~(P), "MODE SELECT(06)"}, - -/* 16 MMMOMMMM O RESERVE(06) */ -{0x16, D|T|L|P|W|R|S|O|E, "RESERVE(06)"}, -/* 16 M RESERVE ELEMENT(06) */ -{0x16, M, "RESERVE ELEMENT(06)"}, - -/* 17 MMMOMMMM O RELEASE(06) */ -{0x17, ALL & ~(M|C|A), "RELEASE(06)"}, -/* 17 M RELEASE ELEMENT(06) */ -{0x17, M, "RELEASE ELEMENT(06)"}, - -/* 18 OOOOOOOO COPY */ -{0x18, ALL & ~(M|C|A|E), "COPY"}, - -/* 19 VMVVVV ERASE */ -{0x19, T, "ERASE"}, - -/* 1A OMO OOOOOOOO MODE SENSE(06) */ -{0x1A, ALL & ~(P), "MODE SENSE(06)"}, - -/* 1B O OM O STOP START UNIT */ -{0x1B, D|W|R|O, "STOP START UNIT"}, -/* 1B O LOAD UNLOAD */ -{0x1B, T, "LOAD UNLOAD"}, -/* 1B O SCAN */ -{0x1B, S, "SCAN"}, -/* 1B O STOP PRINT */ -{0x1B, L, "STOP PRINT"}, - -/* 1C OOOOOOOOOO M RECEIVE DIAGNOSTIC RESULTS */ -{0x1C, ALL & ~(A), "RECEIVE DIAGNOSTIC RESULTS"}, - -/* 1D MMMMMMMMMMMM SEND DIAGNOSTIC */ -{0x1D, ALL, "SEND DIAGNOSTIC"}, - -/* 1E OO OM OO PREVENT ALLOW MEDIUM REMOVAL */ -{0x1E, D|T|W|R|O|M, "PREVENT ALLOW MEDIUM REMOVAL"}, - -/* 1F */ -/* 20 V VV V */ -/* 21 V VV V */ -/* 22 V VV V */ -/* 23 V VV V */ - -/* 24 V VVM SET WINDOW */ -{0x24, S, "SET WINDOW"}, - -/* 25 M M M READ CAPACITY */ -{0x25, D|W|O, "READ CAPACITY"}, -/* 25 M READ CD RECORDED CAPACITY */ -{0x25, R, "READ CD RECORDED CAPACITY"}, -/* 25 O GET WINDOW */ -{0x25, S, "GET WINDOW"}, - -/* 26 V VV */ -/* 27 V VV */ - -/* 28 M MMMM READ(10) */ -{0x28, D|W|R|S|O, "READ(10)"}, -/* 28 O GET MESSAGE(10) */ -{0x28, C, "GET MESSAGE(10)"}, - -/* 29 V VV O READ GENERATION */ -{0x29, O, "READ GENERATION"}, - -/* 2A M MM M WRITE(10) */ -{0x2A, D|W|R|O, "WRITE(10)"}, -/* 2A O SEND(10) */ -{0x2A, S, "SEND(10)"}, -/* 2A O SEND MESSAGE(10) */ -{0x2A, C, "SEND MESSAGE(10)"}, - -/* 2B O OM O SEEK(10) */ -{0x2B, D|W|R|O, "SEEK(10)"}, -/* 2B O LOCATE */ -{0x2B, T, "LOCATE"}, -/* 2B O POSITION TO ELEMENT */ -{0x2B, M, "POSITION TO ELEMENT"}, - -/* 2C V O ERASE(10) */ -{0x2C, O, "ERASE(10)"}, - -/* 2D V O O READ UPDATED BLOCK */ -{0x2D, W|O, "READ UPDATED BLOCK"}, - -/* 2E O O O WRITE AND VERIFY(10) */ -{0x2E, D|W|O, "WRITE AND VERIFY(10)"}, - -/* 2F O OO O VERIFY(10) */ -{0x2F, D|W|R|O, "VERIFY(10)"}, - -/* 30 Z ZO Z SEARCH DATA HIGH(10) */ -{0x30, D|W|R|O, "SEARCH DATA HIGH(10)"}, - -/* 31 Z ZO Z SEARCH DATA EQUAL(10) */ -{0x31, D|W|R|O, "SEARCH DATA EQUAL(10)"}, -/* 31 O OBJECT POSITION */ -{0x31, S, "OBJECT POSITION"}, - -/* 32 Z ZO Z SEARCH DATA LOW(10) */ -{0x32, D|W|R|O, "SEARCH DATA LOW(10"}, - -/* 33 O OO O SET LIMITS(10) */ -{0x33, D|W|R|O, "SET LIMITS(10)"}, - -/* 34 O OO O PRE-FETCH */ -{0x34, D|W|R|O, "PRE-FETCH"}, -/* 34 O READ POSITION */ -{0x34, T, "READ POSITION"}, -/* 34 O GET DATA BUFFER STATUS */ -{0x34, S, "GET DATA BUFFER STATUS"}, - -/* 35 O OM O SYNCHRONIZE CACHE */ -{0x35, D|W|R|O, "SYNCHRONIZE CACHE"}, - -/* 36 O OO O LOCK UNLOCK CACHE */ -{0x36, D|W|R|O, "LOCK UNLOCK CACHE"}, - -/* 37 O O READ DEFECT DATA(10) */ -{0x37, D|O, "READ DEFECT DATA(10)"}, - -/* 38 O O MEDIUM SCAN */ -{0x38, W|O, "MEDIUM SCAN"}, - -/* 39 OOOOOOOO COMPARE */ -{0x39, ALL & ~(M|C|A|E), "COMPARE"}, - -/* 3A OOOOOOOO COPY AND VERIFY */ -{0x3A, ALL & ~(M|C|A|E), "COPY AND VERIFY"}, - -/* 3B OOOOOOOOOO O WRITE BUFFER */ -{0x3B, ALL & ~(A), "WRITE BUFFER"}, - -/* 3C OOOOOOOOOO READ BUFFER */ -{0x3C, ALL & ~(A|E),"READ BUFFER"}, - -/* 3D O O UPDATE BLOCK */ -{0x3D, W|O, "UPDATE BLOCK"}, - -/* 3E O OO O READ LONG */ -{0x3E, D|W|R|O, "READ LONG"}, - -/* 3F O O O WRITE LONG */ -{0x3F, D|W|O, "WRITE LONG"}, - -/* 40 OOOOOOOOOO CHANGE DEFINITION */ -{0x40, ALL & ~(A|E),"CHANGE DEFINITION"}, - -/* 41 O WRITE SAME */ -{0x41, D, "WRITE SAME"}, - -/* 42 M READ SUB-CHANNEL */ -{0x42, R, "READ SUB-CHANNEL"}, - -/* 43 M READ TOC/PMA/ATIP {MMC Proposed} */ -{0x43, R, "READ TOC/PMA/ATIP {MMC Proposed}"}, - -/* 44 M REPORT DENSITY SUPPORT */ -{0x44, T, "REPORT DENSITY SUPPORT"}, -/* 44 M READ HEADER */ -{0x44, R, "READ HEADER"}, - -/* 45 O PLAY AUDIO(10) */ -{0x45, R, "PLAY AUDIO(10)"}, - -/* 46 */ - -/* 47 O PLAY AUDIO MSF */ -{0x47, R, "PLAY AUDIO MSF"}, - -/* 48 O PLAY AUDIO TRACK INDEX */ -{0x48, R, "PLAY AUDIO TRACK INDEX"}, - -/* 49 O PLAY TRACK RELATIVE(10) */ -{0x49, R, "PLAY TRACK RELATIVE(10)"}, - -/* 4A */ - -/* 4B O PAUSE/RESUME */ -{0x4B, R, "PAUSE/RESUME"}, - -/* 4C OOOOOOOOOOO LOG SELECT */ -{0x4C, ALL & ~(E), "LOG SELECT"}, - -/* 4D OOOOOOOOOOO LOG SENSE */ -{0x4D, ALL & ~(E), "LOG SENSE"}, - -/* 4E O STOP PLAY/SCAN {MMC Proposed} */ -{0x4E, R, "STOP PLAY/SCAN {MMC Proposed}"}, - -/* 4F */ - -/* 50 O XDWRITE(10) */ -{0x50, D, "XDWRITE(10)"}, - -/* 51 O XPWRITE(10) */ -{0x51, D, "XPWRITE(10)"}, -/* 51 M READ DISC INFORMATION {MMC Proposed} */ -{0x51, R, "READ DISC INFORMATION {MMC Proposed}"}, - -/* 52 O XDREAD(10) */ -{0x52, D, "XDREAD(10)"}, -/* 52 M READ TRACK INFORMATION {MMC Proposed} */ -{0x52, R, "READ TRACK INFORMATION {MMC Proposed}"}, - -/* 53 M RESERVE TRACK {MMC Proposed} */ -{0x53, R, "RESERVE TRACK {MMC Proposed}"}, - -/* 54 O SEND OPC INFORMATION {MMC Proposed} */ -{0x54, R, "SEND OPC INFORMATION {MMC Proposed}"}, - -/* 55 OOO OOOOOOOO MODE SELECT(10) */ -{0x55, ALL & ~(P), "MODE SELECT(10)"}, - -/* 56 MMMOMMMM O RESERVE(10) */ -{0x56, ALL & ~(M|C|A), "RESERVE(10)"}, -/* 56 M RESERVE ELEMENT(10) */ -{0x56, M, "RESERVE ELEMENT(10)"}, - -/* 57 MMMOMMMM O RELEASE(10) */ -{0x57, ALL & ~(M|C|A), "RELEASE(10"}, -/* 57 M RELEASE ELEMENT(10) */ -{0x57, M, "RELEASE ELEMENT(10)"}, - -/* 58 O REPAIR TRACK {MMC Proposed} */ -{0x58, R, "REPAIR TRACK {MMC Proposed}"}, - -/* 59 O READ MASTER CUE {MMC Proposed} */ -{0x59, R, "READ MASTER CUE {MMC Proposed}"}, - -/* 5A OOO OOOOOOOO MODE SENSE(10) */ -{0x5A, ALL & ~(P), "MODE SENSE(10)"}, - -/* 5B M CLOSE TRACK/SESSION {MMC Proposed} */ -{0x5B, R, "CLOSE TRACK/SESSION {MMC Proposed}"}, - -/* 5C O READ BUFFER CAPACITY {MMC Proposed} */ -{0x5C, R, "READ BUFFER CAPACITY {MMC Proposed}"}, - -/* 5D O SEND CUE SHEET {MMC Proposed} */ -{0x5D, R, "SEND CUE SHEET {MMC Proposed}"}, - -/* 5E OOOOOOOOO O PERSISTENT RESERVE IN */ -{0x5E, ALL & ~(C|A),"PERSISTENT RESERVE IN"}, - -/* 5F OOOOOOOOO O PERSISTENT RESERVE OUT */ -{0x5F, ALL & ~(C|A),"PERSISTENT RESERVE OUT"}, - -/* 80 O XDWRITE EXTENDED(16) */ -{0x80, D, "XDWRITE EXTENDED(16)"}, - -/* 81 O REBUILD(16) */ -{0x81, D, "REBUILD(16)"}, - -/* 82 O REGENERATE(16) */ -{0x82, D, "REGENERATE(16)"}, - -/* 83 */ -/* 84 */ -/* 85 */ -/* 86 */ -/* 87 */ -/* 88 MM OO O O READ(16) */ -{0x88, D|T|W|R|O, "READ(16)"}, -/* 89 */ -/* 8A OM O O O WRITE(16) */ -{0x8A, D|T|W|R|O, "WRITE(16)"}, -/* 8B */ -/* 8C */ -/* 8D */ -/* 8E */ -/* 8F */ -/* 90 */ -/* 91 */ -/* 92 */ -/* 93 */ -/* 94 */ -/* 95 */ -/* 96 */ -/* 97 */ -/* 98 */ -/* 99 */ -/* 9A */ -/* 9B */ -/* 9C */ -/* 9D */ -/* XXX KDM ALL for these? op-num.txt defines them for none.. */ -/* 9E SERVICE ACTION IN(16) */ -{0x9E, ALL, "SERVICE ACTION IN(16)"}, -/* 9F SERVICE ACTION OUT(16) */ -{0x9F, ALL, "SERVICE ACTION OUT(16)"}, - -/* A0 OOOOOOOOOOO REPORT LUNS */ -{0xA0, ALL & ~(E), "REPORT LUNS"}, - -/* A1 O BLANK {MMC Proposed} */ -{0xA1, R, "BLANK {MMC Proposed}"}, - -/* A2 O WRITE CD MSF {MMC Proposed} */ -{0xA2, R, "WRITE CD MSF {MMC Proposed}"}, - -/* A3 M MAINTENANCE (IN) */ -{0xA3, A, "MAINTENANCE (IN)"}, - -/* A4 O MAINTENANCE (OUT) */ -{0xA4, A, "MAINTENANCE (OUT)"}, - -/* A5 O M MOVE MEDIUM */ -{0xA5, T|M, "MOVE MEDIUM"}, -/* A5 O PLAY AUDIO(12) */ -{0xA5, R, "PLAY AUDIO(12)"}, - -/* A6 O EXCHANGE MEDIUM */ -{0xA6, M, "EXCHANGE MEDIUM"}, -/* A6 O LOAD/UNLOAD CD {MMC Proposed} */ -{0xA6, R, "LOAD/UNLOAD CD {MMC Proposed}"}, - -/* A7 OO OO OO MOVE MEDIUM ATTACHED */ -{0xA7, D|T|W|R|O|M, "MOVE MEDIUM ATTACHED"}, - -/* A8 O OM O READ(12) */ -{0xA8,D|W|R|O, "READ(12)"}, -/* A8 O GET MESSAGE(12) */ -{0xA8, C, "GET MESSAGE(12)"}, - -/* A9 O PLAY TRACK RELATIVE(12) */ -{0xA9, R, "PLAY TRACK RELATIVE(12)"}, - -/* AA O O O WRITE(12) */ -{0xAA,D|W|O, "WRITE(12)"}, -/* AA O WRITE CD(12) {MMC Proposed} */ -{0xAA, R, "WRITE CD(12) {MMC Proposed}"}, -/* AA O SEND MESSAGE(12) */ -{0xAA, C, "SEND MESSAGE(12)"}, - -/* AB */ - -/* AC O ERASE(12) */ -{0xAC, O, "ERASE(12)"}, - -/* AD */ - -/* AE O O WRITE AND VERIFY(12) */ -{0xAE, W|O, "WRITE AND VERIFY(12)"}, - -/* AF OO O VERIFY(12) */ -{0xAF, W|R|O, "VERIFY(12)"}, - -/* B0 ZO Z SEARCH DATA HIGH(12) */ -{0xB0, W|R|O, "SEARCH DATA HIGH(12)"}, - -/* B1 ZO Z SEARCH DATA EQUAL(12) */ -{0xB1, W|R|O, "SEARCH DATA EQUAL(12)"}, - -/* B2 ZO Z SEARCH DATA LOW(12) */ -{0xB2, W|R|O, "SEARCH DATA LOW(12)"}, - -/* B3 OO O SET LIMITS(12) */ -{0xB3, W|R|O, "SET LIMITS(12)"}, - -/* B4 OO OO OO READ ELEMENT STATUS ATTACHED */ -{0xB4, D|T|W|R|O|M, "READ ELEMENT STATUS ATTACHED"}, - -/* B5 O REQUEST VOLUME ELEMENT ADDRESS */ -{0xB5, M, "REQUEST VOLUME ELEMENT ADDRESS"}, - -/* B6 O SEND VOLUME TAG */ -{0xB6, M, "SEND VOLUME TAG"}, - -/* B7 O READ DEFECT DATA(12) */ -{0xB7, O, "READ DEFECT DATA(12)"}, - -/* B8 O M READ ELEMENT STATUS */ -{0xB8, T|M, "READ ELEMENT STATUS"}, -/* B8 O SET CD SPEED {MMC Proposed} */ -{0xB8, R, "SET CD SPEED {MMC Proposed}"}, - -/* B9 M READ CD MSF {MMC Proposed} */ -{0xB9, R, "READ CD MSF {MMC Proposed}"}, - -/* BA O SCAN {MMC Proposed} */ -{0xBA, R, "SCAN {MMC Proposed}"}, -/* BA M REDUNDANCY GROUP (IN) */ -{0xBA, A, "REDUNDANCY GROUP (IN)"}, - -/* BB O SET CD-ROM SPEED {proposed} */ -{0xBB, R, "SET CD-ROM SPEED {proposed}"}, -/* BB O REDUNDANCY GROUP (OUT) */ -{0xBB, A, "REDUNDANCY GROUP (OUT)"}, - -/* BC O PLAY CD {MMC Proposed} */ -{0xBC, R, "PLAY CD {MMC Proposed}"}, -/* BC M SPARE (IN) */ -{0xBC, A, "SPARE (IN)"}, - -/* BD M MECHANISM STATUS {MMC Proposed} */ -{0xBD, R, "MECHANISM STATUS {MMC Proposed}"}, -/* BD O SPARE (OUT) */ -{0xBD, A, "SPARE (OUT)"}, - -/* BE O READ CD {MMC Proposed} */ -{0xBE, R, "READ CD {MMC Proposed}"}, -/* BE M VOLUME SET (IN) */ -{0xBE, A, "VOLUME SET (IN)"}, - -/* BF O VOLUME SET (OUT) */ -{0xBF, A, "VOLUME SET (OUT)"} + /* + * From: http://www.t10.org/lists/op-num.txt + * Modifications by Kenneth Merry (ken@FreeBSD.ORG) + * and Jung-uk Kim (jkim@FreeBSD.org) + * + * Note: order is important in this table, scsi_op_desc() currently + * depends on the opcodes in the table being in order to save + * search time. + * Note: scanner and comm. devices are carried over from the previous + * version because they were removed in the latest spec. + */ + /* File: OP-NUM.TXT + * + * SCSI Operation Codes + * Numeric Sorted Listing + * as of 3/11/08 + * + * D - DIRECT ACCESS DEVICE (SBC-2) device column key + * .T - SEQUENTIAL ACCESS DEVICE (SSC-2) ----------------- + * . L - PRINTER DEVICE (SSC) M = Mandatory + * . P - PROCESSOR DEVICE (SPC) O = Optional + * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC-2) V = Vendor spec. + * . . R - CD/DVE DEVICE (MMC-3) Z = Obsolete + * . . O - OPTICAL MEMORY DEVICE (SBC-2) + * . . .M - MEDIA CHANGER DEVICE (SMC-2) + * . . . A - STORAGE ARRAY DEVICE (SCC-2) + * . . . .E - ENCLOSURE SERVICES DEVICE (SES) + * . . . .B - SIMPLIFIED DIRECT-ACCESS DEVICE (RBC) + * . . . . K - OPTICAL CARD READER/WRITER DEVICE (OCRW) + * . . . . V - AUTOMATION/DRIVE INTERFACE (ADC) + * . . . . .F - OBJECT-BASED STORAGE (OSD) + * OP DTLPWROMAEBKVF Description + * -- -------------- ---------------------------------------------- */ + /* 00 MMMMMMMMMMMMMM TEST UNIT READY */ + { 0x00, ALL, "TEST UNIT READY" }, + /* 01 M REWIND */ + { 0x01, T, "REWIND" }, + /* 01 Z V ZZZZ REZERO UNIT */ + { 0x01, D | W | R | O | M, "REZERO UNIT" }, + /* 02 VVVVVV V */ + /* 03 MMMMMMMMMMOMMM REQUEST SENSE */ + { 0x03, ALL, "REQUEST SENSE" }, + /* 04 M OO FORMAT UNIT */ + { 0x04, D | R | O, "FORMAT UNIT" }, + /* 04 O FORMAT MEDIUM */ + { 0x04, T, "FORMAT MEDIUM" }, + /* 04 O FORMAT */ + { 0x04, L, "FORMAT" }, + /* 05 VMVVVV V READ BLOCK LIMITS */ + { 0x05, T, "READ BLOCK LIMITS" }, + /* 06 VVVVVV V */ + /* 07 OVV O OV REASSIGN BLOCKS */ + { 0x07, D | W | O, "REASSIGN BLOCKS" }, + /* 07 O INITIALIZE ELEMENT STATUS */ + { 0x07, M, "INITIALIZE ELEMENT STATUS" }, + /* 08 MOV O OV READ(6) */ + { 0x08, D | T | W | O, "READ(6)" }, + /* 08 O RECEIVE */ + { 0x08, P, "RECEIVE" }, + /* 08 GET MESSAGE(6) */ + { 0x08, C, "GET MESSAGE(6)" }, + /* 09 VVVVVV V */ + /* 0A OO O OV WRITE(6) */ + { 0x0A, D | T | W | O, "WRITE(6)" }, + /* 0A M SEND(6) */ + { 0x0A, P, "SEND(6)" }, + /* 0A SEND MESSAGE(6) */ + { 0x0A, C, "SEND MESSAGE(6)" }, + /* 0A M PRINT */ + { 0x0A, L, "PRINT" }, + /* 0B Z ZOZV SEEK(6) */ + { 0x0B, D | W | R | O, "SEEK(6)" }, + /* 0B O SET CAPACITY */ + { 0x0B, T, "SET CAPACITY" }, + /* 0B O SLEW AND PRINT */ + { 0x0B, L, "SLEW AND PRINT" }, + /* 0C VVVVVV V */ + /* 0D VVVVVV V */ + /* 0E VVVVVV V */ + /* 0F VOVVVV V READ REVERSE(6) */ + { 0x0F, T, "READ REVERSE(6)" }, + /* 10 VM VVV WRITE FILEMARKS(6) */ + { 0x10, T, "WRITE FILEMARKS(6)" }, + /* 10 O SYNCHRONIZE BUFFER */ + { 0x10, L, "SYNCHRONIZE BUFFER" }, + /* 11 VMVVVV SPACE(6) */ + { 0x11, T, "SPACE(6)" }, + /* 12 MMMMMMMMMMMMMM INQUIRY */ + { 0x12, ALL, "INQUIRY" }, + /* 13 V VVVV */ + /* 13 O VERIFY(6) */ + { 0x13, T, "VERIFY(6)" }, + /* 14 VOOVVV RECOVER BUFFERED DATA */ + { 0x14, T | L, "RECOVER BUFFERED DATA" }, + /* 15 OMO O OOOO OO MODE SELECT(6) */ + { 0x15, ALL & ~(P | R | B | F), "MODE SELECT(6)" }, + /* 16 ZZMZO OOOZ O RESERVE(6) */ + { 0x16, ALL & ~(R | B | V | F | C), "RESERVE(6)" }, + /* 16 Z RESERVE ELEMENT(6) */ + { 0x16, M, "RESERVE ELEMENT(6)" }, + /* 17 ZZMZO OOOZ O RELEASE(6) */ + { 0x17, ALL & ~(R | B | V | F | C), "RELEASE(6)" }, + /* 17 Z RELEASE ELEMENT(6) */ + { 0x17, M, "RELEASE ELEMENT(6)" }, + /* 18 ZZZZOZO Z COPY */ + { 0x18, D | T | L | P | W | R | O | K | S, "COPY" }, + /* 19 VMVVVV ERASE(6) */ + { 0x19, T, "ERASE(6)" }, + /* 1A OMO O OOOO OO MODE SENSE(6) */ + { 0x1A, ALL & ~(P | R | B | F), "MODE SENSE(6)" }, + /* 1B O OOO O MO O START STOP UNIT */ + { 0x1B, D | W | R | O | A | B | K | F, "START STOP UNIT" }, + /* 1B O M LOAD UNLOAD */ + { 0x1B, T | V, "LOAD UNLOAD" }, + /* 1B SCAN */ + { 0x1B, S, "SCAN" }, + /* 1B O STOP PRINT */ + { 0x1B, L, "STOP PRINT" }, + /* 1B O OPEN/CLOSE IMPORT/EXPORT ELEMENT */ + { 0x1B, M, "OPEN/CLOSE IMPORT/EXPORT ELEMENT" }, + /* 1C OOOOO OOOM OOO RECEIVE DIAGNOSTIC RESULTS */ + { 0x1C, ALL & ~(R | B), "RECEIVE DIAGNOSTIC RESULTS" }, + /* 1D MMMMM MMOM MMM SEND DIAGNOSTIC */ + { 0x1D, ALL & ~(R | B), "SEND DIAGNOSTIC" }, + /* 1E OO OOOO O O PREVENT ALLOW MEDIUM REMOVAL */ + { 0x1E, D | T | W | R | O | M | K | F, "PREVENT ALLOW MEDIUM REMOVAL" }, + /* 1F */ + /* 20 V VVV V */ + /* 21 V VVV V */ + /* 22 V VVV V */ + /* 23 V V V V */ + /* 23 O READ FORMAT CAPACITIES */ + { 0x23, R, "READ FORMAT CAPACITIES" }, + /* 24 V VV SET WINDOW */ + { 0x24, S, "SET WINDOW" }, + /* 25 M M M M READ CAPACITY(10) */ + { 0x25, D | W | O | B, "READ CAPACITY(10)" }, + /* 25 O READ CAPACITY */ + { 0x25, R, "READ CAPACITY" }, + /* 25 M READ CARD CAPACITY */ + { 0x25, K, "READ CARD CAPACITY" }, + /* 25 GET WINDOW */ + { 0x25, S, "GET WINDOW" }, + /* 26 V VV */ + /* 27 V VV */ + /* 28 M MOM MM READ(10) */ + { 0x28, D | W | R | O | B | K | S, "READ(10)" }, + /* 28 GET MESSAGE(10) */ + { 0x28, C, "GET MESSAGE(10)" }, + /* 29 V VVO READ GENERATION */ + { 0x29, O, "READ GENERATION" }, + /* 2A O MOM MO WRITE(10) */ + { 0x2A, D | W | R | O | B | K, "WRITE(10)" }, + /* 2A SEND(10) */ + { 0x2A, S, "SEND(10)" }, + /* 2A SEND MESSAGE(10) */ + { 0x2A, C, "SEND MESSAGE(10)" }, + /* 2B Z OOO O SEEK(10) */ + { 0x2B, D | W | R | O | K, "SEEK(10)" }, + /* 2B O LOCATE(10) */ + { 0x2B, T, "LOCATE(10)" }, + /* 2B O POSITION TO ELEMENT */ + { 0x2B, M, "POSITION TO ELEMENT" }, + /* 2C V OO ERASE(10) */ + { 0x2C, R | O, "ERASE(10)" }, + /* 2D O READ UPDATED BLOCK */ + { 0x2D, O, "READ UPDATED BLOCK" }, + /* 2D V */ + /* 2E O OOO MO WRITE AND VERIFY(10) */ + { 0x2E, D | W | R | O | B | K, "WRITE AND VERIFY(10)" }, + /* 2F O OOO VERIFY(10) */ + { 0x2F, D | W | R | O, "VERIFY(10)" }, + /* 30 Z ZZZ SEARCH DATA HIGH(10) */ + { 0x30, D | W | R | O, "SEARCH DATA HIGH(10)" }, + /* 31 Z ZZZ SEARCH DATA EQUAL(10) */ + { 0x31, D | W | R | O, "SEARCH DATA EQUAL(10)" }, + /* 31 OBJECT POSITION */ + { 0x31, S, "OBJECT POSITION" }, + /* 32 Z ZZZ SEARCH DATA LOW(10) */ + { 0x32, D | W | R | O, "SEARCH DATA LOW(10)" }, + /* 33 Z OZO SET LIMITS(10) */ + { 0x33, D | W | R | O, "SET LIMITS(10)" }, + /* 34 O O O O PRE-FETCH(10) */ + { 0x34, D | W | O | K, "PRE-FETCH(10)" }, + /* 34 M READ POSITION */ + { 0x34, T, "READ POSITION" }, + /* 34 GET DATA BUFFER STATUS */ + { 0x34, S, "GET DATA BUFFER STATUS" }, + /* 35 O OOO MO SYNCHRONIZE CACHE(10) */ + { 0x35, D | W | R | O | B | K, "SYNCHRONIZE CACHE(10)" }, + /* 36 Z O O O LOCK UNLOCK CACHE(10) */ + { 0x36, D | W | O | K, "LOCK UNLOCK CACHE(10)" }, + /* 37 O O READ DEFECT DATA(10) */ + { 0x37, D | O, "READ DEFECT DATA(10)" }, + /* 37 O INITIALIZE ELEMENT STATUS WITH RANGE */ + { 0x37, M, "INITIALIZE ELEMENT STATUS WITH RANGE" }, + /* 38 O O O MEDIUM SCAN */ + { 0x38, W | O | K, "MEDIUM SCAN" }, + /* 39 ZZZZOZO Z COMPARE */ + { 0x39, D | T | L | P | W | R | O | K | S, "COMPARE" }, + /* 3A ZZZZOZO Z COPY AND VERIFY */ + { 0x3A, D | T | L | P | W | R | O | K | S, "COPY AND VERIFY" }, + /* 3B OOOOOOOOOOMOOO WRITE BUFFER */ + { 0x3B, ALL, "WRITE BUFFER" }, + /* 3C OOOOOOOOOO OOO READ BUFFER */ + { 0x3C, ALL & ~(B), "READ BUFFER" }, + /* 3D O UPDATE BLOCK */ + { 0x3D, O, "UPDATE BLOCK" }, + /* 3E O O O READ LONG(10) */ + { 0x3E, D | W | O, "READ LONG(10)" }, + /* 3F O O O WRITE LONG(10) */ + { 0x3F, D | W | O, "WRITE LONG(10)" }, + /* 40 ZZZZOZOZ CHANGE DEFINITION */ + { 0x40, D | T | L | P | W | R | O | M | S | C, "CHANGE DEFINITION" }, + /* 41 O WRITE SAME(10) */ + { 0x41, D, "WRITE SAME(10)" }, + /* 42 O READ SUB-CHANNEL */ + { 0x42, R, "READ SUB-CHANNEL" }, + /* 43 O READ TOC/PMA/ATIP */ + { 0x43, R, "READ TOC/PMA/ATIP" }, + /* 44 M M REPORT DENSITY SUPPORT */ + { 0x44, T | V, "REPORT DENSITY SUPPORT" }, + /* 44 READ HEADER */ + /* 45 O PLAY AUDIO(10) */ + { 0x45, R, "PLAY AUDIO(10)" }, + /* 46 M GET CONFIGURATION */ + { 0x46, R, "GET CONFIGURATION" }, + /* 47 O PLAY AUDIO MSF */ + { 0x47, R, "PLAY AUDIO MSF" }, + /* 48 */ + /* 49 */ + /* 4A M GET EVENT STATUS NOTIFICATION */ + { 0x4A, R, "GET EVENT STATUS NOTIFICATION" }, + /* 4B O PAUSE/RESUME */ + { 0x4B, R, "PAUSE/RESUME" }, + /* 4C OOOOO OOOO OOO LOG SELECT */ + { 0x4C, ALL & ~(R | B), "LOG SELECT" }, + /* 4D OOOOO OOOO OMO LOG SENSE */ + { 0x4D, ALL & ~(R | B), "LOG SENSE" }, + /* 4E O STOP PLAY/SCAN */ + { 0x4E, R, "STOP PLAY/SCAN" }, + /* 4F */ + /* 50 O XDWRITE(10) */ + { 0x50, D, "XDWRITE(10)" }, + /* 51 O XPWRITE(10) */ + { 0x51, D, "XPWRITE(10)" }, + /* 51 O READ DISC INFORMATION */ + { 0x51, R, "READ DISC INFORMATION" }, + /* 52 O XDREAD(10) */ + { 0x52, D, "XDREAD(10)" }, + /* 52 O READ TRACK INFORMATION */ + { 0x52, R, "READ TRACK INFORMATION" }, + /* 53 O RESERVE TRACK */ + { 0x53, R, "RESERVE TRACK" }, + /* 54 O SEND OPC INFORMATION */ + { 0x54, R, "SEND OPC INFORMATION" }, + /* 55 OOO OMOOOOMOMO MODE SELECT(10) */ + { 0x55, ALL & ~(P), "MODE SELECT(10)" }, + /* 56 ZZMZO OOOZ RESERVE(10) */ + { 0x56, ALL & ~(R | B | K | V | F | C), "RESERVE(10)" }, + /* 56 Z RESERVE ELEMENT(10) */ + { 0x56, M, "RESERVE ELEMENT(10)" }, + /* 57 ZZMZO OOOZ RELEASE(10) */ + { 0x57, ALL & ~(R | B | K | V | F | C), "RELEASE(10)" }, + /* 57 Z RELEASE ELEMENT(10) */ + { 0x57, M, "RELEASE ELEMENT(10)" }, + /* 58 O REPAIR TRACK */ + { 0x58, R, "REPAIR TRACK" }, + /* 59 */ + /* 5A OOO OMOOOOMOMO MODE SENSE(10) */ + { 0x5A, ALL & ~(P), "MODE SENSE(10)" }, + /* 5B O CLOSE TRACK/SESSION */ + { 0x5B, R, "CLOSE TRACK/SESSION" }, + /* 5C O READ BUFFER CAPACITY */ + { 0x5C, R, "READ BUFFER CAPACITY" }, + /* 5D O SEND CUE SHEET */ + { 0x5D, R, "SEND CUE SHEET" }, + /* 5E OOOOO OOOO M PERSISTENT RESERVE IN */ + { 0x5E, ALL & ~(R | B | K | V | C), "PERSISTENT RESERVE IN" }, + /* 5F OOOOO OOOO M PERSISTENT RESERVE OUT */ + { 0x5F, ALL & ~(R | B | K | V | C), "PERSISTENT RESERVE OUT" }, + /* 7E OO O OOOO O extended CDB */ + { 0x7E, D | T | R | M | A | E | B | V, "extended CDB" }, + /* 7F O M variable length CDB (more than 16 bytes) */ + { 0x7F, D | F, "variable length CDB (more than 16 bytes)" }, + /* 80 Z XDWRITE EXTENDED(16) */ + { 0x80, D, "XDWRITE EXTENDED(16)" }, + /* 80 M WRITE FILEMARKS(16) */ + { 0x80, T, "WRITE FILEMARKS(16)" }, + /* 81 Z REBUILD(16) */ + { 0x81, D, "REBUILD(16)" }, + /* 81 O READ REVERSE(16) */ + { 0x81, T, "READ REVERSE(16)" }, + /* 82 Z REGENERATE(16) */ + { 0x82, D, "REGENERATE(16)" }, + /* 83 OOOOO O OO EXTENDED COPY */ + { 0x83, D | T | L | P | W | O | K | V, "EXTENDED COPY" }, + /* 84 OOOOO O OO RECEIVE COPY RESULTS */ + { 0x84, D | T | L | P | W | O | K | V, "RECEIVE COPY RESULTS" }, + /* 85 O O O ATA COMMAND PASS THROUGH(16) */ + { 0x85, D | R | B, "ATA COMMAND PASS THROUGH(16)" }, + /* 86 OO OO OOOOOOO ACCESS CONTROL IN */ + { 0x86, ALL & ~(L | R | F), "ACCESS CONTROL IN" }, + /* 87 OO OO OOOOOOO ACCESS CONTROL OUT */ + { 0x87, ALL & ~(L | R | F), "ACCESS CONTROL OUT" }, + /* + * XXX READ(16)/WRITE(16) were not listed for CD/DVE in op-num.txt + * but we had it since r1.40. Do we really want them? + */ + /* 88 MM O O O READ(16) */ + { 0x88, D | T | W | O | B, "READ(16)" }, + /* 89 */ + /* 8A OM O O O WRITE(16) */ + { 0x8A, D | T | W | O | B, "WRITE(16)" }, + /* 8B O ORWRITE */ + { 0x8B, D, "ORWRITE" }, + /* 8C OO O OO O M READ ATTRIBUTE */ + { 0x8C, D | T | W | O | M | B | V, "READ ATTRIBUTE" }, + /* 8D OO O OO O O WRITE ATTRIBUTE */ + { 0x8D, D | T | W | O | M | B | V, "WRITE ATTRIBUTE" }, + /* 8E O O O O WRITE AND VERIFY(16) */ + { 0x8E, D | W | O | B, "WRITE AND VERIFY(16)" }, + /* 8F OO O O O VERIFY(16) */ + { 0x8F, D | T | W | O | B, "VERIFY(16)" }, + /* 90 O O O O PRE-FETCH(16) */ + { 0x90, D | W | O | B, "PRE-FETCH(16)" }, + /* 91 O O O O SYNCHRONIZE CACHE(16) */ + { 0x91, D | W | O | B, "SYNCHRONIZE CACHE(16)" }, + /* 91 O SPACE(16) */ + { 0x91, T, "SPACE(16)" }, + /* 92 Z O O LOCK UNLOCK CACHE(16) */ + { 0x92, D | W | O, "LOCK UNLOCK CACHE(16)" }, + /* 92 O LOCATE(16) */ + { 0x92, T, "LOCATE(16)" }, + /* 93 O WRITE SAME(16) */ + { 0x93, D, "WRITE SAME(16)" }, + /* 93 M ERASE(16) */ + { 0x93, T, "ERASE(16)" }, + /* 94 [usage proposed by SCSI Socket Services project] */ + /* 95 [usage proposed by SCSI Socket Services project] */ + /* 96 [usage proposed by SCSI Socket Services project] */ + /* 97 [usage proposed by SCSI Socket Services project] */ + /* 98 */ + /* 99 */ + /* 9A */ + /* 9B */ + /* 9C */ + /* 9D */ + /* XXX KDM ALL for this? op-num.txt defines it for none.. */ + /* 9E SERVICE ACTION IN(16) */ + { 0x9E, ALL, "SERVICE ACTION IN(16)" }, + /* XXX KDM ALL for this? op-num.txt defines it for ADC.. */ + /* 9F M SERVICE ACTION OUT(16) */ + { 0x9F, ALL, "SERVICE ACTION OUT(16)" }, + /* A0 MMOOO OMMM OMO REPORT LUNS */ + { 0xA0, ALL & ~(R | B), "REPORT LUNS" }, + /* A1 O BLANK */ + { 0xA1, R, "BLANK" }, + /* A1 O O ATA COMMAND PASS THROUGH(12) */ + { 0xA1, D | B, "ATA COMMAND PASS THROUGH(12)" }, + /* A2 OO O O SECURITY PROTOCOL IN */ + { 0xA2, D | T | R | V, "SECURITY PROTOCOL IN" }, + /* A3 OOO O OOMOOOM MAINTENANCE (IN) */ + { 0xA3, ALL & ~(P | R | F), "MAINTENANCE (IN)" }, + /* A3 O SEND KEY */ + { 0xA3, R, "SEND KEY" }, + /* A4 OOO O OOOOOOO MAINTENANCE (OUT) */ + { 0xA4, ALL & ~(P | R | F), "MAINTENANCE (OUT)" }, + /* A4 O REPORT KEY */ + { 0xA4, R, "REPORT KEY" }, + /* A5 O O OM MOVE MEDIUM */ + { 0xA5, T | W | O | M, "MOVE MEDIUM" }, + /* A5 O PLAY AUDIO(12) */ + { 0xA5, R, "PLAY AUDIO(12)" }, + /* A6 O EXCHANGE MEDIUM */ + { 0xA6, M, "EXCHANGE MEDIUM" }, + /* A6 O LOAD/UNLOAD C/DVD */ + { 0xA6, R, "LOAD/UNLOAD C/DVD" }, + /* A7 ZZ O O MOVE MEDIUM ATTACHED */ + { 0xA7, D | T | W | O, "MOVE MEDIUM ATTACHED" }, + /* A7 O SET READ AHEAD */ + { 0xA7, R, "SET READ AHEAD" }, + /* A8 O OOO READ(12) */ + { 0xA8, D | W | R | O, "READ(12)" }, + /* A8 GET MESSAGE(12) */ + { 0xA8, C, "GET MESSAGE(12)" }, + /* A9 O SERVICE ACTION OUT(12) */ + { 0xA9, V, "SERVICE ACTION OUT(12)" }, + /* AA O OOO WRITE(12) */ + { 0xAA, D | W | R | O, "WRITE(12)" }, + /* AA SEND MESSAGE(12) */ + { 0xAA, C, "SEND MESSAGE(12)" }, + /* AB O O SERVICE ACTION IN(12) */ + { 0xAB, R | V, "SERVICE ACTION IN(12)" }, + /* AC O ERASE(12) */ + { 0xAC, O, "ERASE(12)" }, + /* AC O GET PERFORMANCE */ + { 0xAC, R, "GET PERFORMANCE" }, + /* AD O READ DVD STRUCTURE */ + { 0xAD, R, "READ DVD STRUCTURE" }, + /* AE O O O WRITE AND VERIFY(12) */ + { 0xAE, D | W | O, "WRITE AND VERIFY(12)" }, + /* AF O OZO VERIFY(12) */ + { 0xAF, D | W | R | O, "VERIFY(12)" }, + /* B0 ZZZ SEARCH DATA HIGH(12) */ + { 0xB0, W | R | O, "SEARCH DATA HIGH(12)" }, + /* B1 ZZZ SEARCH DATA EQUAL(12) */ + { 0xB1, W | R | O, "SEARCH DATA EQUAL(12)" }, + /* B2 ZZZ SEARCH DATA LOW(12) */ + { 0xB2, W | R | O, "SEARCH DATA LOW(12)" }, + /* B3 Z OZO SET LIMITS(12) */ + { 0xB3, D | W | R | O, "SET LIMITS(12)" }, + /* B4 ZZ OZO READ ELEMENT STATUS ATTACHED */ + { 0xB4, D | T | W | R | O, "READ ELEMENT STATUS ATTACHED" }, + /* B5 OO O O SECURITY PROTOCOL OUT */ + { 0xB5, D | T | R | V, "SECURITY PROTOCOL OUT" }, + /* B5 O REQUEST VOLUME ELEMENT ADDRESS */ + { 0xB5, M, "REQUEST VOLUME ELEMENT ADDRESS" }, + /* B6 O SEND VOLUME TAG */ + { 0xB6, M, "SEND VOLUME TAG" }, + /* B6 O SET STREAMING */ + { 0xB6, R, "SET STREAMING" }, + /* B7 O O READ DEFECT DATA(12) */ + { 0xB7, D | O, "READ DEFECT DATA(12)" }, + /* B8 O OZOM READ ELEMENT STATUS */ + { 0xB8, T | W | R | O | M, "READ ELEMENT STATUS" }, + /* B9 O READ CD MSF */ + { 0xB9, R, "READ CD MSF" }, + /* BA O O OOMO REDUNDANCY GROUP (IN) */ + { 0xBA, D | W | O | M | A | E, "REDUNDANCY GROUP (IN)" }, + /* BA O SCAN */ + { 0xBA, R, "SCAN" }, + /* BB O O OOOO REDUNDANCY GROUP (OUT) */ + { 0xBB, D | W | O | M | A | E, "REDUNDANCY GROUP (OUT)" }, + /* BB O SET CD SPEED */ + { 0xBB, R, "SET CD SPEED" }, + /* BC O O OOMO SPARE (IN) */ + { 0xBC, D | W | O | M | A | E, "SPARE (IN)" }, + /* BD O O OOOO SPARE (OUT) */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From scottl at FreeBSD.org Sun Mar 1 08:26:40 2009 From: scottl at FreeBSD.org (Scott Long) Date: Sun Mar 1 08:26:45 2009 Subject: svn commit: r189240 - in stable/7/sys: . cam/scsi contrib/pf dev/ath/ath_hal dev/cxgb Message-ID: <200903011626.n21GQdw2048329@svn.freebsd.org> Author: scottl Date: Sun Mar 1 16:26:38 2009 New Revision: 189240 URL: http://svn.freebsd.org/changeset/base/189240 Log: Merge 181791: SCSI_DELAY is specified in milliseconds. Modified: stable/7/sys/ (props changed) stable/7/sys/cam/scsi/scsi_all.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_all.c Sun Mar 1 16:24:57 2009 (r189239) +++ stable/7/sys/cam/scsi/scsi_all.c Sun Mar 1 16:26:38 2009 (r189240) @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); #endif /* !_KERNEL */ /* - * This is the default number of seconds we wait for devices to settle + * This is the default number of milliseconds we wait for devices to settle * after a SCSI bus reset. */ #ifndef SCSI_DELAY From scottl at FreeBSD.org Sun Mar 1 08:28:18 2009 From: scottl at FreeBSD.org (Scott Long) Date: Sun Mar 1 08:28:24 2009 Subject: svn commit: r189241 - in stable/7/sys: . cam/scsi contrib/pf dev/cxgb Message-ID: <200903011628.n21GSH8g048420@svn.freebsd.org> Author: scottl Date: Sun Mar 1 16:28:17 2009 New Revision: 189241 URL: http://svn.freebsd.org/changeset/base/189241 Log: Merge 186371: Fix refcount locking in cd, pass, and sg periphs. Modified: stable/7/sys/ (props changed) stable/7/sys/cam/scsi/scsi_cd.c stable/7/sys/cam/scsi/scsi_pass.c stable/7/sys/cam/scsi/scsi_sg.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/cam/scsi/scsi_cd.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_cd.c Sun Mar 1 16:26:38 2009 (r189240) +++ stable/7/sys/cam/scsi/scsi_cd.c Sun Mar 1 16:28:17 2009 (r189241) @@ -996,12 +996,6 @@ cdopen(struct disk *dp) return (error); } - /* Closes aren't symmetrical with opens, so fix up the refcounting. */ - if (softc->flags & CD_FLAG_OPEN) - cam_periph_release(periph); - else - softc->flags |= CD_FLAG_OPEN; - /* * Check for media, and set the appropriate flags. We don't bail * if we don't have media, but then we don't allow anything but the @@ -1011,7 +1005,15 @@ cdopen(struct disk *dp) CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("leaving cdopen\n")); cam_periph_unhold(periph); - cam_periph_unlock(periph); + + /* Closes aren't symmetrical with opens, so fix up the refcounting. */ + if ((softc->flags & CD_FLAG_OPEN) == 0) { + softc->flags |= CD_FLAG_OPEN; + cam_periph_unlock(periph); + } else { + cam_periph_unlock(periph); + cam_periph_release(periph); + } return (0); } Modified: stable/7/sys/cam/scsi/scsi_pass.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_pass.c Sun Mar 1 16:26:38 2009 (r189240) +++ stable/7/sys/cam/scsi/scsi_pass.c Sun Mar 1 16:28:17 2009 (r189241) @@ -345,13 +345,13 @@ passopen(struct cdev *dev, int flags, in if ((softc->flags & PASS_FLAG_OPEN) == 0) { softc->flags |= PASS_FLAG_OPEN; + cam_periph_unlock(periph); } else { /* Device closes aren't symmertical, so fix up the refcount */ + cam_periph_unlock(periph); cam_periph_release(periph); } - cam_periph_unlock(periph); - return (error); } Modified: stable/7/sys/cam/scsi/scsi_sg.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_sg.c Sun Mar 1 16:26:38 2009 (r189240) +++ stable/7/sys/cam/scsi/scsi_sg.c Sun Mar 1 16:28:17 2009 (r189241) @@ -400,13 +400,13 @@ sgopen(struct cdev *dev, int flags, int if ((softc->flags & SG_FLAG_OPEN) == 0) { softc->flags |= SG_FLAG_OPEN; + cam_periph_unlock(periph); } else { /* Device closes aren't symmetrical, fix up the refcount. */ + cam_periph_unlock(periph); cam_periph_release(periph); } - cam_periph_unlock(periph); - return (error); } From scottl at FreeBSD.org Sun Mar 1 08:31:36 2009 From: scottl at FreeBSD.org (Scott Long) Date: Sun Mar 1 08:31:43 2009 Subject: svn commit: r189242 - in stable/7/sys: . cam/scsi contrib/pf dev/ath/ath_hal dev/cxgb Message-ID: <200903011631.n21GVZho048598@svn.freebsd.org> Author: scottl Date: Sun Mar 1 16:31:35 2009 New Revision: 189242 URL: http://svn.freebsd.org/changeset/base/189242 Log: Merge 182433: Fix locking mistake in the da driver. Modified: stable/7/sys/ (props changed) stable/7/sys/cam/scsi/scsi_da.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_da.c Sun Mar 1 16:28:17 2009 (r189241) +++ stable/7/sys/cam/scsi/scsi_da.c Sun Mar 1 16:31:35 2009 (r189242) @@ -674,18 +674,19 @@ daopen(struct disk *dp) softc->disk->d_fwheads = softc->params.heads; softc->disk->d_devstat->block_size = softc->params.secsize; softc->disk->d_devstat->flags &= ~DEVSTAT_BS_UNAVAILABLE; - } - - if (error == 0) { + if ((softc->flags & DA_FLAG_PACK_REMOVABLE) != 0 && (softc->quirks & DA_Q_NO_PREVENT) == 0) daprevent(periph, PR_PREVENT); - } else { + } else softc->flags &= ~DA_FLAG_OPEN; - cam_periph_release(periph); - } + cam_periph_unhold(periph); cam_periph_unlock(periph); + + if (error != 0) { + cam_periph_release(periph); + } return (error); } From scottl at FreeBSD.org Sun Mar 1 08:41:49 2009 From: scottl at FreeBSD.org (Scott Long) Date: Sun Mar 1 08:41:56 2009 Subject: svn commit: r189243 - in stable/7/sys: . contrib/pf dev/arcmsr dev/ath/ath_hal dev/cxgb Message-ID: <200903011641.n21Gfmqc048858@svn.freebsd.org> Author: scottl Date: Sun Mar 1 16:41:48 2009 New Revision: 189243 URL: http://svn.freebsd.org/changeset/base/189243 Log: Merge 188844: Fix pseudo-scsi parameters so that more than one i/o can be queued at a time. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/arcmsr/arcmsr.c stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/arcmsr/arcmsr.c ============================================================================== --- stable/7/sys/dev/arcmsr/arcmsr.c Sun Mar 1 16:31:35 2009 (r189242) +++ stable/7/sys/dev/arcmsr/arcmsr.c Sun Mar 1 16:41:48 2009 (r189243) @@ -2150,7 +2150,8 @@ static void arcmsr_action(struct cam_sim spi->sync_offset=32; spi->bus_width=MSG_EXT_WDTR_BUS_16_BIT; scsi->flags = CTS_SCSI_FLAGS_TAG_ENB; - spi->valid = CTS_SPI_VALID_SYNC_RATE + spi->valid = CTS_SPI_VALID_DISC + | CTS_SPI_VALID_SYNC_RATE | CTS_SPI_VALID_SYNC_OFFSET | CTS_SPI_VALID_BUS_WIDTH; scsi->valid = CTS_SCSI_VALID_TQ; From scottl at FreeBSD.org Sun Mar 1 08:43:47 2009 From: scottl at FreeBSD.org (Scott Long) Date: Sun Mar 1 08:43:54 2009 Subject: svn commit: r189244 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/ciss dev/cxgb Message-ID: <200903011643.n21GhkPu048955@svn.freebsd.org> Author: scottl Date: Sun Mar 1 16:43:45 2009 New Revision: 189244 URL: http://svn.freebsd.org/changeset/base/189244 Log: Merge 188845: Fix pseudo-scsi parameters so that more than 2 commands will be queued to the device at once. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/ciss/ciss.c stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/ciss/ciss.c ============================================================================== --- stable/7/sys/dev/ciss/ciss.c Sun Mar 1 16:41:48 2009 (r189243) +++ stable/7/sys/dev/ciss/ciss.c Sun Mar 1 16:43:45 2009 (r189244) @@ -2696,8 +2696,8 @@ ciss_cam_action(struct cam_sim *sim, uni { struct ccb_trans_settings *cts = &ccb->cts; int bus, target; - struct ccb_trans_settings_spi *spi = - &cts->xport_specific.spi; + struct ccb_trans_settings_spi *spi = &cts->xport_specific.spi; + struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi; bus = cam_sim_bus(sim); target = cts->ccb_h.target_id; @@ -2712,6 +2712,9 @@ ciss_cam_action(struct cam_sim *sim, uni spi->valid = CTS_SPI_VALID_DISC; spi->flags = CTS_SPI_FLAGS_DISC_ENB; + scsi->valid = CTS_SCSI_VALID_TQ; + scsi->flags = CTS_SCSI_FLAGS_TAG_ENB; + cts->ccb_h.status = CAM_REQ_CMP; break; } From scottl at FreeBSD.org Sun Mar 1 08:50:51 2009 From: scottl at FreeBSD.org (Scott Long) Date: Sun Mar 1 08:51:10 2009 Subject: svn commit: r189246 - in stable/7/sys: . contrib/pf dev/ata dev/ath/ath_hal dev/cxgb Message-ID: <200903011650.n21GokYf049195@svn.freebsd.org> Author: scottl Date: Sun Mar 1 16:50:46 2009 New Revision: 189246 URL: http://svn.freebsd.org/changeset/base/189246 Log: Merge 188840: Add DDF metadata support, found commonly on motherboards with Adaptec branding. For Entertainment Purposes Only! Added: stable/7/sys/dev/ata/ata-raid-ddf.h - copied unchanged from r188840, head/sys/dev/ata/ata-raid-ddf.h Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ata/ata-raid.c stable/7/sys/dev/ata/ata-raid.h stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Copied: stable/7/sys/dev/ata/ata-raid-ddf.h (from r188840, head/sys/dev/ata/ata-raid-ddf.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/dev/ata/ata-raid-ddf.h Sun Mar 1 16:50:46 2009 (r189246, copy of r188840, head/sys/dev/ata/ata-raid-ddf.h) @@ -0,0 +1,333 @@ +/*- + * Copyright (c) 2008 Scott Long + * 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, immediately at the beginning of the file. + * 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 ``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 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 ATA_RAID_DDF_H +#define ATA_RAID_DDF_H + +/* Definitions from the SNIA DDF spec, rev 1.2 */ + +#define DDF_HEADER_LENGTH 512 +struct ddf_header { + uint32_t Signature; +#define DDF_HEADER_SIGNATURE 0xde11de11 + uint32_t CRC; + uint8_t DDF_Header_GUID[24]; + uint8_t DDF_rev[8]; + uint32_t Sequence_Number; + uint32_t TimeStamp; + uint8_t Open_Flag; +#define DDF_HEADER_CLOSED 0x00 +#define DDF_HEADER_OPENED_MASK 0x0f +#define DDF_HEADER_OPEN_ANCHOR 0xff + uint8_t Foreign_Flag; + uint8_t Diskgrouping; + uint8_t pad1[13]; + uint8_t Header_ext[32]; + uint64_t Primary_Header_LBA; + uint64_t Secondary_Header_LBA; + uint8_t Header_Type; +#define DDF_HEADER_ANCHOR 0x00 +#define DDF_HEADER_PRIMARY 0x01 +#define DDF_HEADER_SECONDARY 0x02 + uint8_t pad2[3]; + uint32_t WorkSpace_Length; + uint64_t WorkSpace_LBA; + uint16_t Max_PD_Entries; + uint16_t Max_VD_Entries; + uint16_t Max_Partitions; + uint16_t Configuration_Record_Length; + uint16_t Max_Primary_Element_Entries; + uint8_t pad3[54]; + uint32_t cd_section; /* Controller_Data_Section */ + uint32_t cd_length; /* Controller_Data_Section_Length */ + uint32_t pdr_section; /* Physical_Drive_Records_Section */ + uint32_t pdr_length; /* Physical_Drive_Records_Length */ + uint32_t vdr_section; /* Virtual_Drive_Records_Section */ + uint32_t vdr_length; /* Virtual_Drive_Records_Length */ + uint32_t cr_section; /* Configuration_Records_Section */ + uint32_t cr_length; /* Configuration_Records_Length */ + uint32_t pdd_section; /* Physical_Drive_Data_Section */ + uint32_t pdd_length; /* Physical_Drive_Data_Length */ + uint32_t bbmlog_section; /* BBM_Log_Section */ + uint32_t bbmlog_length; /* BBM_Log_Section_Length */ + uint32_t Diagnostic_Space; + uint32_t Diagnostic_Space_Length; + uint32_t Vendor_Specific_Logs; + uint32_t Vendor_Specific_Logs_Length; + uint8_t pad4[256]; +} __packed; + +struct ddf_cd_record { + uint32_t Signature; +#define DDF_CONTROLLER_DATA_SIGNATURE 0xad111111 + uint32_t CRC; + uint8_t Controller_GUID[24]; + struct { + uint16_t Vendor_ID; + uint16_t Device_ID; + uint16_t SubVendor_ID; + uint16_t SubDevice_ID; + } Controller_Type __packed; + uint8_t Product_ID[16]; + uint8_t pad1[8]; + uint8_t Controller_Data[448]; +} __packed; + +struct ddf_device_scsi { + uint8_t Lun; + uint8_t Id; + uint8_t Channel; + uint8_t Path_Flags; +#define DDF_DEVICE_SCSI_FLAG_BROKEN (1 << 7) +} __packed; + +struct ddf_device_sas { + uint64_t Initiator_Path; +} __packed; + +union ddf_pathinfo { + struct { + struct ddf_device_scsi Path0; + struct ddf_device_scsi Path1; + uint8_t pad[10]; + } __packed scsi; + struct { + struct ddf_device_sas Path0; + struct ddf_device_sas Path1; + uint8_t Path0_Flags; + uint8_t Path1_Flags; +#define DDF_DEVICE_SAS_FLAG_BROKEN (1 << 7) + } __packed sas; +} __packed; + +struct ddf_pd_entry { + uint8_t PD_GUID[24]; + uint32_t PD_Reference; + uint16_t PD_Type; +#define DDF_PDE_GUID_FORCE (1 << 0) +#define DDF_PDE_PARTICIPATING (1 << 1) +#define DDF_PDE_GLOBAL_SPARE (1 << 2) +#define DDF_PDE_CONFIG_SPARE (1 << 3) +#define DDF_PDE_FOREIGN (1 << 4) +#define DDF_PDE_LEGACY (1 << 5) +#define DDF_PDE_TYPE_MASK (0x0f << 12) +#define DDF_PDE_UNKNOWN (0x00 << 12) +#define DDF_PDE_SCSI (0x01 << 12) +#define DDF_PDE_SAS (0x02 << 12) +#define DDF_PDE_SATA (0x03 << 12) +#define DDF_PDE_FC (0x04 << 12) + uint16_t PD_State; +#define DDF_PDE_ONLINE (1 << 0) +#define DDF_PDE_FAILED (1 << 1) +#define DDF_PDE_REBUILD (1 << 2) +#define DDF_PDE_TRANSITION (1 << 3) +#define DDF_PDE_PFA (1 << 4) +#define DDF_PDE_UNRECOVERED (1 << 5) +#define DDF_PDE_MISSING (1 << 6) + uint64_t Configured_Size; + union ddf_pathinfo Path_Information; + uint8_t pad1[6]; +} __packed; + +struct ddf_pd_record { + uint32_t Signature; +#define DDF_PDR_SIGNATURE 0x22222222 + uint32_t CRC; + uint16_t Populated_PDEs; + uint16_t Max_PDE_Supported; + uint8_t pad1[52]; + struct ddf_pd_entry entry[0]; +} __packed; + +struct ddf_vd_entry { + uint8_t VD_GUID[24]; + uint16_t VD_Number; + uint8_t pad1[2]; + uint16_t VD_Type; +#define DDF_VDE_SHARED (1 << 0) +#define DDF_VDE_ENFORCE_GROUP (1 << 1) +#define DDF_VDE_UNICODE_NAME (1 << 2) +#define DDF_VDE_OWNER_ID_VALID (1 << 3) + uint16_t Controller_GUID_CRC; + uint8_t VD_State; +#define DDF_VDE_OPTIMAL 0x00 +#define DDF_VDE_DEGRADED 0x01 +#define DDF_VDE_DELETED 0x02 +#define DDF_VDE_MISSING 0x03 +#define DDF_VDE_FAILED 0x04 +#define DDF_VDE_PARTIAL 0x05 +#define DDF_VDE_STATE_MASK 0x07 +#define DDF_VDE_MORPH (1 << 3) +#define DDF_VDE_DIRTY (1 << 4) + uint8_t Init_State; +#define DDF_VDE_UNINTIALIZED 0x00 +#define DDF_VDE_INIT_QUICK 0x01 +#define DDF_VDE_INIT_FULL 0x02 +#define DDF_VDE_INIT_MASK 0x03 +#define DDF_VDE_UACCESS_RW 0x00 +#define DDF_VDE_UACCESS_RO 0x80 +#define DDF_VDE_UACCESS_BLOCKED 0xc0 +#define DDF_VDE_UACCESS_MASK 0xc0 + uint8_t pad2[14]; + uint8_t VD_Name[16]; +} __packed; + +struct ddf_vd_record { + uint32_t Signature; +#define DDF_VD_RECORD_SIGNATURE 0xdddddddd + uint32_t CRC; + uint16_t Populated_VDEs; + uint16_t Max_VDE_Supported; + uint8_t pad1[52]; + struct ddf_vd_entry entry[0]; +} __packed; + +#define DDF_CR_INVALID 0xffffffff + +struct ddf_vdc_record { + uint32_t Signature; +#define DDF_VDCR_SIGNATURE 0xeeeeeeee + uint32_t CRC; + uint8_t VD_GUID[24]; + uint32_t Timestamp; + uint32_t Sequence_Number; + uint8_t pad1[24]; + uint16_t Primary_Element_Count; + uint8_t Stripe_Size; + uint8_t Primary_RAID_Level; +#define DDF_VDCR_RAID0 0x00 +#define DDF_VDCR_RAID1 0x01 +#define DDF_VDCR_RAID3 0x03 +#define DDF_VDCR_RAID4 0x04 +#define DDF_VDCR_RAID5 0x05 +#define DDF_VDCR_RAID6 0x06 +#define DDF_VDCR_RAID1E 0x11 +#define DDF_VDCR_SINGLE 0x0f +#define DDF_VDCR_CONCAT 0x1f +#define DDF_VDCR_RAID5E 0x15 +#define DDF_VDCR_RAID5EE 0x25 + uint8_t RLQ; + uint8_t Secondary_Element_Count; + uint8_t Secondary_Element_Seq; + uint8_t Secondary_RAID_Level; + uint64_t Block_Count; + uint64_t VD_Size; + uint8_t pad2[8]; + uint32_t Associated_Spares[8]; + uint64_t Cache_Flags; +#define DDF_VDCR_CACHE_WB (1 << 0) +#define DDF_VDCR_CACHE_WB_ADAPTIVE (1 << 1) +#define DDF_VDCR_CACHE_RA (1 << 2) +#define DDF_VDCR_CACHE_RA_ADAPTIVE (1 << 3) +#define DDF_VDCR_CACHE_WCACHE_NOBATTERY (1 << 4) +#define DDF_VDCR_CACHE_WCACHE_ALLOW (1 << 5) +#define DDF_VDCR_CACHE_RCACHE_ALLOW (1 << 6) +#define DDF_VDCR_CACHE_VENDOR (1 << 7) + uint8_t BG_Rate; + uint8_t pad3[3]; + uint8_t pad4[52]; + uint8_t pad5[192]; + uint8_t V0[32]; + uint8_t V1[32]; + uint8_t V2[16]; + uint8_t V3[16]; + uint8_t Vendor_Scratch[32]; + uint32_t Physical_Disk_Sequence[0]; +} __packed; + +struct ddf_vuc_record { + uint32_t Signature; +#define DDF_VUCR_SIGNATURE 0x88888888 + uint32_t CRC; + uint8_t VD_GUID[24]; +} __packed; + +struct ddf_sa_entry { + uint8_t VD_GUID[24]; + uint16_t Secondary_Element; + uint8_t rsrvd2[6]; +} __packed; + +struct ddf_sa_record { + uint32_t Signature; +#define DDF_SA_SIGNATURE 0x55555555 + uint32_t CRC; + uint32_t Timestamp; + uint8_t pad1[7]; + uint8_t Spare_Type; +#define DDF_SAR_TYPE_DEDICATED (1 << 0) +#define DDF_SAR_TYPE_REVERTIBLE (1 << 1) +#define DDF_SAR_TYPE_ACTIVE (1 << 2) +#define DDF_SAR_TYPE_ENCL_AFFINITY (1 << 3) + uint16_t Populated_SAEs; + uint16_t MAX_SAE_Supported; + uint8_t pad2[8]; + struct ddf_sa_entry entry[0]; +} __packed; + +struct ddf_pdd_record { + uint32_t Signature; +#define DDF_PDD_SIGNATURE 0x33333333 + uint32_t CRC; + uint8_t PD_GUID[24]; + uint32_t PD_Reference; + uint8_t Forced_Ref_Flag; +#define DDF_PDD_FORCED_REF 0x01 + uint8_t Forced_PD_GUID_Flag; +#define DDF_PDD_FORCED_GUID 0x01 + uint8_t Vendor_Scratch[32]; + uint8_t pad2[442]; +} __packed; + +struct ddf_bbm_entry { + uint64_t Defective_Block_Start; + uint32_t Spare_Block_Offset; + uint16_t Remapped_Count; + uint8_t pad[2]; +}; + +struct ddf_bbm_log { + uint32_t Signature; +#define DDF_BBML_SIGNATURE 0xabadb10c + uint32_t CRC; + uint16_t Entry_Count; + uint32_t Spare_Block_Count; + uint8_t pad1[10]; + uint64_t First_Spare_LBA; + uint64_t Mapped_Block_Entry[0]; +} __packed; + +struct ddf_vendor_log { + uint32_t Signature; +#define DDF_VENDOR_LOG_SIGNATURE 0x01dbeef0 + uint32_t CRC; + uint64_t Log_Owner; + uint8_t pad1[16]; +} __packed; + +#endif Modified: stable/7/sys/dev/ata/ata-raid.c ============================================================================== --- stable/7/sys/dev/ata/ata-raid.c Sun Mar 1 16:47:49 2009 (r189245) +++ stable/7/sys/dev/ata/ata-raid.c Sun Mar 1 16:50:46 2009 (r189246) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -65,6 +66,7 @@ static int ata_raid_read_metadata(device static int ata_raid_write_metadata(struct ar_softc *rdp); static int ata_raid_wipe_metadata(struct ar_softc *rdp); static int ata_raid_adaptec_read_meta(device_t dev, struct ar_softc **raidp); +static int ata_raid_ddf_read_meta(device_t dev, struct ar_softc **raidp); static int ata_raid_hptv2_read_meta(device_t dev, struct ar_softc **raidp); static int ata_raid_hptv2_write_meta(struct ar_softc *rdp); static int ata_raid_hptv3_read_meta(device_t dev, struct ar_softc **raidp); @@ -93,6 +95,7 @@ static char * ata_raid_flags(struct ar_s /* debugging only */ static void ata_raid_print_meta(struct ar_softc *meta); static void ata_raid_adaptec_print_meta(struct adaptec_raid_conf *meta); +static void ata_raid_ddf_print_meta(uint8_t *meta); static void ata_raid_hptv2_print_meta(struct hptv2_raid_conf *meta); static void ata_raid_hptv3_print_meta(struct hptv3_raid_conf *meta); static void ata_raid_intel_print_meta(struct intel_raid_conf *meta); @@ -1407,6 +1410,10 @@ ata_raid_read_metadata(device_t subdisk) if (ata_raid_lsiv2_read_meta(subdisk, ata_raid_arrays)) return 0; + /* DDF (used by Adaptec, maybe others) */ + if (ata_raid_ddf_read_meta(subdisk, ata_raid_arrays)) + return 0; + /* if none of the above matched, try FreeBSD native format */ return ata_raid_promise_read_meta(subdisk, ata_raid_arrays, 1); } @@ -1679,6 +1686,338 @@ adaptec_out: return retval; } +static uint64_t +ddfbe64toh(uint64_t val) +{ + return (be64toh(val)); +} + +static uint32_t +ddfbe32toh(uint32_t val) +{ + return (be32toh(val)); +} + +static uint16_t +ddfbe16toh(uint16_t val) +{ + return (be16toh(val)); +} + +static uint64_t +ddfle64toh(uint64_t val) +{ + return (le64toh(val)); +} + +static uint32_t +ddfle32toh(uint32_t val) +{ + return (le32toh(val)); +} + +static uint16_t +ddfle16toh(uint16_t val) +{ + return (le16toh(val)); +} + +static int +ata_raid_ddf_read_meta(device_t dev, struct ar_softc **raidp) +{ + struct ata_raid_subdisk *ars; + device_t parent = device_get_parent(dev); + struct ddf_header *hdr; + struct ddf_pd_record *pdr; + struct ddf_pd_entry *pde = NULL; + struct ddf_vd_record *vdr; + struct ddf_pdd_record *pdd; + struct ddf_sa_record *sa = NULL; + struct ddf_vdc_record *vdcr = NULL; + struct ddf_vd_entry *vde = NULL; + struct ar_softc *raid; + uint64_t pri_lba; + uint32_t pd_ref, pd_pos; + uint8_t *meta, *cr; + int hdr_len, vd_state = 0, pd_state = 0; + int i, disk, array, retval = 0; + uintptr_t max_cr_addr; + uint64_t (*ddf64toh)(uint64_t) = NULL; + uint32_t (*ddf32toh)(uint32_t) = NULL; + uint16_t (*ddf16toh)(uint16_t) = NULL; + + ars = device_get_softc(dev); + raid = NULL; + + /* Read in the anchor header */ + if (!(meta = malloc(DDF_HEADER_LENGTH, M_AR, M_NOWAIT | M_ZERO))) + return ENOMEM; + + if (ata_raid_rw(parent, DDF_LBA(parent), + meta, DDF_HEADER_LENGTH, ATA_R_READ)) { + if (testing || bootverbose) + device_printf(parent, "DDF read metadata failed\n"); + goto ddf_out; + } + + /* + * Check if this is a DDF RAID struct. Note the apparent "flexibility" + * regarding endianness. + */ + hdr = (struct ddf_header *)meta; + if (be32toh(hdr->Signature) == DDF_HEADER_SIGNATURE) { + ddf64toh = ddfbe64toh; + ddf32toh = ddfbe32toh; + ddf16toh = ddfbe16toh; + } else if (le32toh(hdr->Signature) == DDF_HEADER_SIGNATURE) { + ddf64toh = ddfle64toh; + ddf32toh = ddfle32toh; + ddf16toh = ddfle16toh; + } else + goto ddf_out; + + if (hdr->Header_Type != DDF_HEADER_ANCHOR) { + if (testing || bootverbose) + device_printf(parent, "DDF check1 failed\n"); + goto ddf_out; + } + + pri_lba = ddf64toh(hdr->Primary_Header_LBA); + hdr_len = ddf32toh(hdr->cd_section) + ddf32toh(hdr->cd_length); + hdr_len = max(hdr_len,ddf32toh(hdr->pdr_section)+ddf32toh(hdr->pdr_length)); + hdr_len = max(hdr_len,ddf32toh(hdr->vdr_section)+ddf32toh(hdr->vdr_length)); + hdr_len = max(hdr_len,ddf32toh(hdr->cr_section) +ddf32toh(hdr->cr_length)); + hdr_len = max(hdr_len,ddf32toh(hdr->pdd_section)+ddf32toh(hdr->pdd_length)); + if (testing || bootverbose) + device_printf(parent, "DDF pri_lba= %llu length= %d blocks\n", + (unsigned long long)pri_lba, hdr_len); + if ((pri_lba + hdr_len) > DDF_LBA(parent)) { + device_printf(parent, "DDF exceeds length of disk\n"); + goto ddf_out; + } + + /* Don't need the anchor anymore, read the rest of the metadata */ + free(meta, M_AR); + if (!(meta = malloc(hdr_len * DEV_BSIZE, M_AR, M_NOWAIT | M_ZERO))) + return ENOMEM; + + if (ata_raid_rw(parent, pri_lba, meta, hdr_len * DEV_BSIZE, ATA_R_READ)) { + if (testing || bootverbose) + device_printf(parent, "DDF read full metadata failed\n"); + goto ddf_out; + } + + /* Check that we got a Primary Header */ + hdr = (struct ddf_header *)meta; + if ((ddf32toh(hdr->Signature) != DDF_HEADER_SIGNATURE) || + (hdr->Header_Type != DDF_HEADER_PRIMARY)) { + if (testing || bootverbose) + device_printf(parent, "DDF check2 failed\n"); + goto ddf_out; + } + + if (testing || bootverbose) + ata_raid_ddf_print_meta(meta); + + if ((hdr->Open_Flag >= 0x01) && (hdr->Open_Flag <= 0x0f)) { + device_printf(parent, "DDF Header open, possibly corrupt metadata\n"); + goto ddf_out; + } + + pdr = (struct ddf_pd_record*)(meta + ddf32toh(hdr->pdr_section)*DEV_BSIZE); + vdr = (struct ddf_vd_record*)(meta + ddf32toh(hdr->vdr_section)*DEV_BSIZE); + cr = (uint8_t *)(meta + ddf32toh(hdr->cr_section)*DEV_BSIZE); + pdd = (struct ddf_pdd_record*)(meta + ddf32toh(hdr->pdd_section)*DEV_BSIZE); + + /* Verify the Physical Disk Device Record */ + if (ddf32toh(pdd->Signature) != DDF_PDD_SIGNATURE) { + device_printf(parent, "Invalid PD Signature\n"); + goto ddf_out; + } + pd_ref = ddf32toh(pdd->PD_Reference); + pd_pos = -1; + + /* Verify the Physical Disk Record and make sure the disk is usable */ + if (ddf32toh(pdr->Signature) != DDF_PDR_SIGNATURE) { + device_printf(parent, "Invalid PDR Signature\n"); + goto ddf_out; + } + for (i = 0; i < ddf16toh(pdr->Populated_PDEs); i++) { + if (ddf32toh(pdr->entry[i].PD_Reference) != pd_ref) + continue; + pde = &pdr->entry[i]; + pd_state = ddf16toh(pde->PD_State); + } + if ((pde == NULL) || + ((pd_state & DDF_PDE_ONLINE) == 0) || + (pd_state & (DDF_PDE_FAILED|DDF_PDE_MISSING|DDF_PDE_UNRECOVERED))) { + device_printf(parent, "Physical disk not usable\n"); + goto ddf_out; + } + + /* Parse out the configuration record, look for spare and VD records. + * While DDF supports a disk being part of more than one array, and + * thus having more than one VDCR record, that feature is not supported + * by ATA-RAID. Therefore, the first record found takes precedence. + */ + max_cr_addr = (uintptr_t)cr + ddf32toh(hdr->cr_length) * DEV_BSIZE - 1; + for ( ; (uintptr_t)cr < max_cr_addr; + cr += ddf16toh(hdr->Configuration_Record_Length) * DEV_BSIZE) { + switch (ddf32toh(((uint32_t *)cr)[0])) { + case DDF_VDCR_SIGNATURE: + vdcr = (struct ddf_vdc_record *)cr; + goto cr_found; + break; + case DDF_VUCR_SIGNATURE: + /* Don't care about this record */ + break; + case DDF_SA_SIGNATURE: + sa = (struct ddf_sa_record *)cr; + goto cr_found; + break; + case DDF_CR_INVALID: + /* A record was deliberately invalidated */ + break; + default: + device_printf(parent, "Invalid CR signature found\n"); + } + } +cr_found: + if ((vdcr == NULL) /* && (sa == NULL) * Spares not supported yet */) { + device_printf(parent, "No usable configuration record found\n"); + goto ddf_out; + } + + if (vdcr != NULL) { + if (vdcr->Secondary_Element_Count != 1) { + device_printf(parent, "Unsupported multi-level Virtual Disk\n"); + goto ddf_out; + } + + /* Find the Virtual Disk Entry for this array */ + if (ddf32toh(vdr->Signature) != DDF_VD_RECORD_SIGNATURE) { + device_printf(parent, "Invalid VDR Signature\n"); + goto ddf_out; + } + for (i = 0; i < ddf16toh(vdr->Populated_VDEs); i++) { + if (bcmp(vdr->entry[i].VD_GUID, vdcr->VD_GUID, 24)) + continue; + vde = &vdr->entry[i]; + vd_state = vde->VD_State & DDF_VDE_STATE_MASK; + } + if ((vde == NULL) || + ((vd_state != DDF_VDE_OPTIMAL) && (vd_state != DDF_VDE_DEGRADED))) { + device_printf(parent, "Unusable Virtual Disk\n"); + goto ddf_out; + } + for (i = 0; i < ddf16toh(hdr->Max_Primary_Element_Entries); i++) { + uint32_t pd_tmp; + + pd_tmp = ddf32toh(vdcr->Physical_Disk_Sequence[i]); + if ((pd_tmp == 0x00000000) || (pd_tmp == 0xffffffff)) + continue; + if (pd_tmp == pd_ref) { + pd_pos = i; + break; + } + } + if (pd_pos == -1) { + device_printf(parent, "Physical device not part of array\n"); + goto ddf_out; + } + } + + /* now convert DDF metadata into our generic form */ + for (array = 0; array < MAX_ARRAYS; array++) { + if (!raidp[array]) { + raid = (struct ar_softc *)malloc(sizeof(struct ar_softc), M_AR, + M_NOWAIT | M_ZERO); + if (!raid) { + device_printf(parent, "failed to allocate metadata storage\n"); + goto ddf_out; + } + } else + raid = raidp[array]; + + if (raid->format && (raid->format != AR_F_DDF_RAID)) + continue; + + if (raid->magic_0 && (raid->magic_0 != crc32(vde->VD_GUID, 24))) + continue; + + if (!raidp[array]) { + raidp[array] = raid; + + switch (vdcr->Primary_RAID_Level) { + case DDF_VDCR_RAID0: + raid->magic_0 = crc32(vde->VD_GUID, 24); + raid->magic_1 = ddf16toh(vde->VD_Number); + raid->type = AR_T_RAID0; + raid->interleave = 1 << vdcr->Stripe_Size; + raid->width = ddf16toh(vdcr->Primary_Element_Count); + break; + + case DDF_VDCR_RAID1: + raid->magic_0 = crc32(vde->VD_GUID, 24); + raid->magic_1 = ddf16toh(vde->VD_Number); + raid->type = AR_T_RAID1; + raid->width = 1; + break; + + default: + device_printf(parent, "DDF unsupported RAID type 0x%02x\n", + vdcr->Primary_RAID_Level); + free(raidp[array], M_AR); + raidp[array] = NULL; + goto ddf_out; + } + + raid->format = AR_F_DDF_RAID; + raid->generation = ddf32toh(vdcr->Sequence_Number); + raid->total_disks = ddf16toh(vdcr->Primary_Element_Count); + raid->total_sectors = ddf64toh(vdcr->VD_Size); + raid->heads = 255; + raid->sectors = 63; + raid->cylinders = raid->total_sectors / (63 * 255); + raid->offset_sectors = 0; + raid->rebuild_lba = 0; + raid->lun = array; + strncpy(raid->name, vde->VD_Name, + min(sizeof(raid->name), sizeof(vde->VD_Name))); + + /* clear out any old info */ + if (raid->generation) { + for (disk = 0; disk < raid->total_disks; disk++) { + raid->disks[disk].dev = NULL; + raid->disks[disk].flags = 0; + } + } + } + if (ddf32toh(vdcr->Sequence_Number) >= raid->generation) { + int disk_number = pd_pos; + + raid->disks[disk_number].dev = parent; + + /* Adaptec appears to not set vdcr->Block_Count, yet again in + * gross violation of the spec. + */ + raid->disks[disk_number].sectors = ddf64toh(vdcr->Block_Count); + if (raid->disks[disk_number].sectors == 0) + raid->disks[disk_number].sectors=ddf64toh(pde->Configured_Size); + raid->disks[disk_number].flags = + (AR_DF_ONLINE | AR_DF_PRESENT | AR_DF_ASSIGNED); + ars->raid[raid->volume] = raid; + ars->disk_number[raid->volume] = disk_number; + retval = 1; + } + break; + } + +ddf_out: + free(meta, M_AR); + return retval; +} + /* Highpoint V2 RocketRAID Metadata */ static int ata_raid_hptv2_read_meta(device_t dev, struct ar_softc **raidp) @@ -4258,6 +4597,7 @@ ata_raid_format(struct ar_softc *rdp) switch (rdp->format) { case AR_F_FREEBSD_RAID: return "FreeBSD PseudoRAID"; case AR_F_ADAPTEC_RAID: return "Adaptec HostRAID"; + case AR_F_DDF_RAID: return "DDF"; case AR_F_HPTV2_RAID: return "HighPoint v2 RocketRAID"; case AR_F_HPTV3_RAID: return "HighPoint v3 RocketRAID"; case AR_F_INTEL_RAID: return "Intel MatrixRAID"; @@ -4414,6 +4754,71 @@ ata_raid_adaptec_print_meta(struct adapt printf("=================================================\n"); } +static void +ata_raid_ddf_print_meta(uint8_t *meta) +{ + struct ddf_header *hdr; + struct ddf_cd_record *cd; + struct ddf_pd_record *pdr; + struct ddf_pd_entry *pde; + struct ddf_vd_record *vdr; + struct ddf_vd_entry *vde; + struct ddf_pdd_record *pdd; + uint64_t (*ddf64toh)(uint64_t) = NULL; + uint32_t (*ddf32toh)(uint32_t) = NULL; + uint16_t (*ddf16toh)(uint16_t) = NULL; + uint8_t *cr; + char *r; + + /* Check if this is a DDF RAID struct */ + hdr = (struct ddf_header *)meta; + if (be32toh(hdr->Signature) == DDF_HEADER_SIGNATURE) { + ddf64toh = ddfbe64toh; + ddf32toh = ddfbe32toh; + ddf16toh = ddfbe16toh; + } else { + ddf64toh = ddfle64toh; + ddf32toh = ddfle32toh; + ddf16toh = ddfle16toh; + } + + hdr = (struct ddf_header*)meta; + cd = (struct ddf_cd_record*)(meta + ddf32toh(hdr->cd_section) *DEV_BSIZE); + pdr = (struct ddf_pd_record*)(meta + ddf32toh(hdr->pdr_section)*DEV_BSIZE); + vdr = (struct ddf_vd_record*)(meta + ddf32toh(hdr->vdr_section)*DEV_BSIZE); + cr = (uint8_t *)(meta + ddf32toh(hdr->cr_section) * DEV_BSIZE); + pdd = (struct ddf_pdd_record*)(meta + ddf32toh(hdr->pdd_section)*DEV_BSIZE); + pde = NULL; + vde = NULL; + + printf("********* ATA DDF Metadata *********\n"); + printf("**** Header ****\n"); + r = (char *)&hdr->DDF_rev[0]; + printf("DDF_rev= %8.8s Sequence_Number= 0x%x Open_Flag= 0x%x\n", r, + ddf32toh(hdr->Sequence_Number), hdr->Open_Flag); + printf("Primary Header LBA= %llu Header_Type = 0x%x\n", + (unsigned long long)ddf64toh(hdr->Primary_Header_LBA), + hdr->Header_Type); + printf("Max_PD_Entries= %d Max_VD_Entries= %d Max_Partitions= %d " + "CR_Length= %d\n", ddf16toh(hdr->Max_PD_Entries), + ddf16toh(hdr->Max_VD_Entries), ddf16toh(hdr->Max_Partitions), + ddf16toh(hdr->Configuration_Record_Length)); + printf("CD= %d:%d PDR= %d:%d VDR= %d:%d CR= %d:%d PDD= %d%d\n", + ddf32toh(hdr->cd_section), ddf32toh(hdr->cd_length), + ddf32toh(hdr->pdr_section), ddf32toh(hdr->pdr_length), + ddf32toh(hdr->vdr_section), ddf32toh(hdr->vdr_length), + ddf32toh(hdr->cr_section), ddf32toh(hdr->cr_length), + ddf32toh(hdr->pdd_section), ddf32toh(hdr->pdd_length)); + printf("**** Controler Data ****\n"); + r = (char *)&cd->Product_ID[0]; + printf("Product_ID: %16.16s\n", r); + printf("Vendor 0x%x, Device 0x%x, SubVendor 0x%x, Sub_Device 0x%x\n", + ddf16toh(cd->Controller_Type.Vendor_ID), + ddf16toh(cd->Controller_Type.Device_ID), + ddf16toh(cd->Controller_Type.SubVendor_ID), + ddf16toh(cd->Controller_Type.SubDevice_ID)); +} + static char * ata_raid_hptv2_type(int type) { Modified: stable/7/sys/dev/ata/ata-raid.h ============================================================================== --- stable/7/sys/dev/ata/ata-raid.h Sun Mar 1 16:47:49 2009 (r189245) +++ stable/7/sys/dev/ata/ata-raid.h Sun Mar 1 16:50:46 2009 (r189246) @@ -76,7 +76,8 @@ struct ar_softc { #define AR_F_SII_RAID 0x0800 #define AR_F_SIS_RAID 0x1000 #define AR_F_VIA_RAID 0x2000 -#define AR_F_FORMAT_MASK 0x3fff +#define AR_F_DDF_RAID 0x4000 +#define AR_F_FORMAT_MASK 0x7fff u_int generation; u_int64_t total_sectors; @@ -164,6 +165,9 @@ struct adaptec_raid_conf { u_int32_t dummy_9[62]; } __packed; +/* DDF Information. Metadata definitions are in another file */ +#define DDF_LBA(dev) \ + (((struct ad_softc *)device_get_ivars(dev))->total_secs - 1) /* Highpoint V2 RocketRAID Metadata */ #define HPTV2_LBA(dev) 9 From scottl at FreeBSD.org Sun Mar 1 14:37:35 2009 From: scottl at FreeBSD.org (Scott Long) Date: Sun Mar 1 14:37:48 2009 Subject: svn commit: r189253 - in stable/7/sys: . cam/scsi contrib/pf dev/cxgb Message-ID: <200903012237.n21MbYkf056028@svn.freebsd.org> Author: scottl Date: Sun Mar 1 22:37:34 2009 New Revision: 189253 URL: http://svn.freebsd.org/changeset/base/189253 Log: Merge 186882: Implement kern.cam.cd.retry_count to aid with disk- recovery tools. Modified: stable/7/sys/ (props changed) stable/7/sys/cam/scsi/scsi_cd.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/cam/scsi/scsi_cd.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_cd.c Sun Mar 1 22:10:51 2009 (r189252) +++ stable/7/sys/cam/scsi/scsi_cd.c Sun Mar 1 22:37:34 2009 (r189253) @@ -292,6 +292,9 @@ static struct periph_driver cddriver = PERIPHDRIVER_DECLARE(cd, cddriver); +#ifndef CD_DEFAULT_RETRY +#define CD_DEFAULT_RETRY 4 +#endif #ifndef CHANGER_MIN_BUSY_SECONDS #define CHANGER_MIN_BUSY_SECONDS 5 #endif @@ -299,11 +302,15 @@ PERIPHDRIVER_DECLARE(cd, cddriver); #define CHANGER_MAX_BUSY_SECONDS 15 #endif +static int cd_retry_count = CD_DEFAULT_RETRY; static int changer_min_busy_seconds = CHANGER_MIN_BUSY_SECONDS; static int changer_max_busy_seconds = CHANGER_MAX_BUSY_SECONDS; SYSCTL_NODE(_kern_cam, OID_AUTO, cd, CTLFLAG_RD, 0, "CAM CDROM driver"); SYSCTL_NODE(_kern_cam_cd, OID_AUTO, changer, CTLFLAG_RD, 0, "CD Changer"); +SYSCTL_INT(_kern_cam_cd, OID_AUTO, retry_count, CTLFLAG_RW, + &cd_retry_count, 0, "Normal I/O retry count"); +TUNABLE_INT("kern.cam.cd.retry_count", &cd_retry_count); SYSCTL_INT(_kern_cam_cd_changer, OID_AUTO, min_busy_seconds, CTLFLAG_RW, &changer_min_busy_seconds, 0, "Minimum changer scheduling quantum"); TUNABLE_INT("kern.cam.cd.changer.min_busy_seconds", &changer_min_busy_seconds); @@ -1454,7 +1461,7 @@ cdstart(struct cam_periph *periph, union devstat_start_transaction_bio(softc->disk->d_devstat, bp); scsi_read_write(&start_ccb->csio, - /*retries*/4, + /*retries*/cd_retry_count, /* cbfcnp */ cddone, MSG_SIMPLE_Q_TAG, /* read */bp->bio_cmd == BIO_READ, From rwatson at FreeBSD.org Sun Mar 1 14:48:19 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Mar 1 14:48:36 2009 Subject: svn commit: r189255 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern Message-ID: <200903012248.n21MmIgg056435@svn.freebsd.org> Author: rwatson Date: Sun Mar 1 22:48:18 2009 New Revision: 189255 URL: http://svn.freebsd.org/changeset/base/189255 Log: Merge r187686 from head to stable/7: When a statically linked binary is executed (or at least, one without an interpreter definition in its program header), set the auxiliary ELF argument AT_BASE to 0 rather than to the address that we would have mapped the interpreter at if there had been one. The ELF ABI specifications appear to be ambiguous as to the desired behavior in this situation, as they define AT_BASE as the base address of the interpreter, but do not mention what to do if there is none. On Solaris, AT_BASE will be set to the base address of the static binary if there is no interpreter, and on Linux, AT_BASE is set to 0. We go with the Linux semantics as they are of more immediate utility and allow the early runtime environment to know that the kernel has not mapped an interpreter, but because AT_PHDR points at the ELF header for the running binary, it is still possible to retrieve all required mapping information when the process starts should it be required. Either approach would be preferable to our current behavior of passing a pointer to an unmapped region of user memory as AT_BASE. Sponsored by: Google Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/imgact_elf.c Modified: stable/7/sys/kern/imgact_elf.c ============================================================================== --- stable/7/sys/kern/imgact_elf.c Sun Mar 1 22:40:15 2009 (r189254) +++ stable/7/sys/kern/imgact_elf.c Sun Mar 1 22:48:18 2009 (r189255) @@ -830,7 +830,8 @@ __CONCAT(exec_, __elfN(imgact))(struct i uprintf("ELF interpreter %s not found\n", interp); return (error); } - } + } else + addr = 0; /* * Construct auxargs table (used by the fixup routine) From rwatson at FreeBSD.org Sun Mar 1 15:17:52 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Mar 1 15:18:10 2009 Subject: svn commit: r189258 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb security/audit Message-ID: <200903012317.n21NHpuB058160@svn.freebsd.org> Author: rwatson Date: Sun Mar 1 23:17:51 2009 New Revision: 189258 URL: http://svn.freebsd.org/changeset/base/189258 Log: Merge r188313 from head to stable/7: Change various routines that are responsible for transforming audit event IDs based on arguments to return au_event_t rather than int. Obtained from: TrustedBSD Project Sponsored by: Apple, Inc. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/security/audit/audit_bsm_klib.c stable/7/sys/security/audit/audit_private.h Modified: stable/7/sys/security/audit/audit_bsm_klib.c ============================================================================== --- stable/7/sys/security/audit/audit_bsm_klib.c Sun Mar 1 22:52:41 2009 (r189257) +++ stable/7/sys/security/audit/audit_bsm_klib.c Sun Mar 1 23:17:51 2009 (r189258) @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2008 Apple Inc. + * Copyright (c) 1999-2009 Apple Inc. * Copyright (c) 2005 Robert N. M. Watson * All rights reserved. * @@ -345,7 +345,7 @@ audit_flags_and_error_to_openevent(int o /* * Convert a MSGCTL command to a specific event. */ -int +au_event_t audit_msgctl_to_event(int cmd) { @@ -368,7 +368,7 @@ audit_msgctl_to_event(int cmd) /* * Convert a SEMCTL command to a specific event. */ -int +au_event_t audit_semctl_to_event(int cmd) { @@ -412,7 +412,7 @@ audit_semctl_to_event(int cmd) /* * Convert a command for the auditon() system call to a audit event. */ -int +au_event_t auditon_command_event(int cmd) { Modified: stable/7/sys/security/audit/audit_private.h ============================================================================== --- stable/7/sys/security/audit/audit_private.h Sun Mar 1 22:52:41 2009 (r189257) +++ stable/7/sys/security/audit/audit_private.h Sun Mar 1 23:17:51 2009 (r189258) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999-2005 Apple Inc. + * Copyright (c) 1999-2009 Apple Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -305,10 +305,10 @@ void au_evclassmap_insert(au_event_t e au_class_t au_event_class(au_event_t event); au_event_t audit_ctlname_to_sysctlevent(int name[], uint64_t valid_arg); au_event_t audit_flags_and_error_to_openevent(int oflags, int error); -int audit_msgctl_to_event(int cmd); -int audit_semctl_to_event(int cmr); +au_event_t audit_msgctl_to_event(int cmd); +au_event_t audit_semctl_to_event(int cmr); void audit_canon_path(struct thread *td, char *path, char *cpath); -int auditon_command_event(int cmd); +au_event_t auditon_command_event(int cmd); /* * Audit trigger events notify user space of kernel audit conditions From rwatson at FreeBSD.org Sun Mar 1 15:32:28 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Mar 1 15:32:46 2009 Subject: svn commit: r189259 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb security/audit Message-ID: <200903012332.n21NWRL8058474@svn.freebsd.org> Author: rwatson Date: Sun Mar 1 23:32:27 2009 New Revision: 189259 URL: http://svn.freebsd.org/changeset/base/189259 Log: Merge r188315 from head to stable/7: Set the lower bound on queue size for an audit pipe to 1 instead of 0, as an audit pipe with a queue length of 0 is less useful. Obtained from: TrustedBSD Project Sponsored by: Apple, Inc. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/security/audit/audit_pipe.c Modified: stable/7/sys/security/audit/audit_pipe.c ============================================================================== --- stable/7/sys/security/audit/audit_pipe.c Sun Mar 1 23:17:51 2009 (r189258) +++ stable/7/sys/security/audit/audit_pipe.c Sun Mar 1 23:32:27 2009 (r189259) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Robert N. M. Watson - * Copyright (c) 2008 Apple, Inc. + * Copyright (c) 2008-2009 Apple, Inc. * All rights reserved. * * This software was developed by Robert Watson for the TrustedBSD Project. @@ -76,7 +76,7 @@ static MALLOC_DEFINE(M_AUDIT_PIPE_PRESEL * Audit pipe buffer parameters. */ #define AUDIT_PIPE_QLIMIT_DEFAULT (128) -#define AUDIT_PIPE_QLIMIT_MIN (0) +#define AUDIT_PIPE_QLIMIT_MIN (1) #define AUDIT_PIPE_QLIMIT_MAX (1024) /* From vanhu at FreeBSD.org Mon Mar 2 08:55:21 2009 From: vanhu at FreeBSD.org (VANHULLEBUS Yvan) Date: Mon Mar 2 08:55:27 2009 Subject: svn commit: r189281 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netipsec Message-ID: <200903021655.n22GtKL5081077@svn.freebsd.org> Author: vanhu Date: Mon Mar 2 16:55:19 2009 New Revision: 189281 URL: http://svn.freebsd.org/changeset/base/189281 Log: MFC: Remove remain <= MHLEN restriction in m_makespace(), which caused assert with big packets PR: kern/124609 Submitted by: fabien.thomas@netasq.com Approved by: gnn(mentor) Obtained from: NetBSD Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netipsec/ipsec_mbuf.c Modified: stable/7/sys/netipsec/ipsec_mbuf.c ============================================================================== --- stable/7/sys/netipsec/ipsec_mbuf.c Mon Mar 2 15:22:01 2009 (r189280) +++ stable/7/sys/netipsec/ipsec_mbuf.c Mon Mar 2 16:55:19 2009 (r189281) @@ -73,66 +73,67 @@ m_makespace(struct mbuf *m0, int skip, i */ remain = m->m_len - skip; /* data to move */ if (hlen > M_TRAILINGSPACE(m)) { - struct mbuf *n; + struct mbuf *n0, *n, **np; + int todo, len, done, alloc; + + n0 = NULL; + np = &n0; + alloc = 0; + done = 0; + todo = remain; + while (todo > 0) { + if (todo > MHLEN) { + n = m_getcl(M_DONTWAIT, m->m_type, 0); + len = MCLBYTES; + } + else { + n = m_get(M_DONTWAIT, m->m_type); + len = MHLEN; + } + if (n == NULL) { + m_freem(n0); + return NULL; + } + *np = n; + np = &n->m_next; + alloc++; + len = min(todo, len); + memcpy(n->m_data, mtod(m, char *) + skip + done, len); + n->m_len = len; + done += len; + todo -= len; + } - /* XXX code doesn't handle clusters XXX */ - IPSEC_ASSERT(remain < MLEN, ("remainder too big: %u", remain)); - /* - * Not enough space in m, split the contents - * of m, inserting new mbufs as required. - * - * NB: this ignores mbuf types. - */ - MGET(n, M_DONTWAIT, MT_DATA); - if (n == NULL) - return (NULL); - n->m_next = m->m_next; /* splice new mbuf */ - m->m_next = n; - ipsec4stat.ips_mbinserted++; if (hlen <= M_TRAILINGSPACE(m) + remain) { - /* - * New header fits in the old mbuf if we copy - * the remainder; just do the copy to the new - * mbuf and we're good to go. - */ - memcpy(mtod(n, caddr_t), - mtod(m, caddr_t) + skip, remain); - n->m_len = remain; m->m_len = skip + hlen; *off = skip; - } else { - /* - * No space in the old mbuf for the new header. - * Make space in the new mbuf and check the - * remainder'd data fits too. If not then we - * must allocate an additional mbuf (yech). - */ - n->m_len = 0; - if (remain + hlen > M_TRAILINGSPACE(n)) { - struct mbuf *n2; - - MGET(n2, M_DONTWAIT, MT_DATA); - /* NB: new mbuf is on chain, let caller free */ - if (n2 == NULL) - return (NULL); - n2->m_len = 0; - memcpy(mtod(n2, caddr_t), - mtod(m, caddr_t) + skip, remain); - n2->m_len = remain; - /* splice in second mbuf */ - n2->m_next = n->m_next; - n->m_next = n2; - ipsec4stat.ips_mbinserted++; - } else { - memcpy(mtod(n, caddr_t) + hlen, - mtod(m, caddr_t) + skip, remain); - n->m_len += remain; + if (n0 != NULL) { + *np = m->m_next; + m->m_next = n0; } - m->m_len -= remain; - n->m_len += hlen; + } + else { + n = m_get(M_DONTWAIT, m->m_type); + if (n == NULL) { + m_freem(n0); + return NULL; + } + alloc++; + + if ((n->m_next = n0) == NULL) + np = &n->m_next; + n0 = n; + + *np = m->m_next; + m->m_next = n0; + + n->m_len = hlen; + m->m_len = skip; + m = n; /* header is at front ... */ *off = 0; /* ... of new mbuf */ } + ipsec4stat.ips_mbinserted++; } else { /* * Copy the remainder to the back of the mbuf From mav at FreeBSD.org Mon Mar 2 23:56:43 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Mon Mar 2 23:57:00 2009 Subject: svn commit: r189297 - stable/7/sbin/atacontrol Message-ID: <200903030756.n237uh0Z002124@svn.freebsd.org> Author: mav Date: Tue Mar 3 07:56:42 2009 New Revision: 189297 URL: http://svn.freebsd.org/changeset/base/189297 Log: MFC rev. 186079, 188829, 188922, 188959. Sync with HEAD. Modified: stable/7/sbin/atacontrol/ (props changed) stable/7/sbin/atacontrol/atacontrol.8 stable/7/sbin/atacontrol/atacontrol.c Modified: stable/7/sbin/atacontrol/atacontrol.8 ============================================================================== --- stable/7/sbin/atacontrol/atacontrol.8 Tue Mar 3 07:01:57 2009 (r189296) +++ stable/7/sbin/atacontrol/atacontrol.8 Tue Mar 3 07:56:42 2009 (r189297) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 25, 2008 +.Dd February 21, 2009 .Dt ATACONTROL 8 .Os .Sh NAME @@ -63,6 +63,7 @@ .Nm .Ic mode .Ar device +.Op Ar mode .Nm .Ic info .Ar channel @@ -94,7 +95,7 @@ The .Ar channel argument is the ATA channel device (e.g., ata0) on which to operate. The following commands are supported: -.Bl -tag -width "rebuild" +.Bl -tag -width ".Ic addspare" .It Ic attach Attach an ATA .Ar channel . @@ -162,9 +163,13 @@ Rebuild a RAID1 array on a RAID capable .It Ic status Get the status of an ATA RAID. .It Ic mode -Without the mode argument, the current transfer modes of the +Without the +.Ar mode +argument, the current transfer mode of the device are printed. -If the mode argument is given, the ATA driver +If the +.Ar mode +argument is given, the ATA driver is asked to change the transfer mode to the one given. The ATA driver will reject modes that are not supported by the hardware. @@ -175,9 +180,7 @@ Modes are given like case does not matter. .Pp Currently supported modes are: -.Cm PIO0 , PIO1 , PIO2 , PIO3 , PIO4 , -.Cm WDMA2 , -.Cm UDMA2 +.Cm BIOSPIO , PIO0 , PIO1 , PIO2 , PIO3 , PIO4 , WDMA2 , UDMA2 (alias .Cm UDMA33 ) , .Cm UDMA4 @@ -185,18 +188,19 @@ Currently supported modes are: .Cm UDMA66 ) , .Cm UDMA5 (alias -.Cm UDMA100 ) -and +.Cm UDMA100 ) , .Cm UDMA6 (alias -.Cm UDMA133 ) . -The device name and manufacture/version strings are shown. +.Cm UDMA133 ) , +.Cm SATA150 , SATA300 , USB , USB1 , USB2 +and +.Cm BIOSDMA . .It Ic cap Show detailed info about the device on .Ar device . .It Ic spindown Set or report timeout after which the -.Ar device +.Ar device will be spun down. To arm the timeout the device needs at least one more request after setting the timeout. @@ -205,6 +209,7 @@ No further actions are needed in this ca .It Ic info Show info about the attached devices on the .Ar channel . +The device name and manufacture/version strings are shown. .It Ic list Show info about all attached devices on all active controllers. .El @@ -312,7 +317,7 @@ If the system has a pure software array RAID controller, then shut the system down, make sure that the disk that was still working is moved to the bootable position (channel 0 or whatever the BIOS allows the system to boot from) and the blank disk -is placed in the secondary position, then boot the system into +is placed in the secondary position, then boot the system into single-user mode and issue the command: .Pp .Dl "atacontrol addspare ar0 ad6" Modified: stable/7/sbin/atacontrol/atacontrol.c ============================================================================== --- stable/7/sbin/atacontrol/atacontrol.c Tue Mar 3 07:01:57 2009 (r189296) +++ stable/7/sbin/atacontrol/atacontrol.c Tue Mar 3 07:56:42 2009 (r189297) @@ -82,6 +82,11 @@ str2mode(char *str) if (!strcasecmp(str, "UDMA100")) return ATA_UDMA5; if (!strcasecmp(str, "UDMA6")) return ATA_UDMA6; if (!strcasecmp(str, "UDMA133")) return ATA_UDMA6; + if (!strcasecmp(str, "SATA150")) return ATA_SA150; + if (!strcasecmp(str, "SATA300")) return ATA_SA300; + if (!strcasecmp(str, "USB")) return ATA_USB; + if (!strcasecmp(str, "USB1")) return ATA_USB1; + if (!strcasecmp(str, "USB2")) return ATA_USB2; if (!strcasecmp(str, "BIOSDMA")) return ATA_DMA; return -1; } @@ -127,11 +132,11 @@ param_print(struct ata_params *parm) printf("<%.40s/%.8s> ", parm->model, parm->revision); if (parm->satacapabilities && parm->satacapabilities != 0xffff) { if (parm->satacapabilities & ATA_SATA_GEN2) - printf("Serial ATA II\n"); + printf("SATA revision 2.x\n"); else if (parm->satacapabilities & ATA_SATA_GEN1) - printf("Serial ATA v1.0\n"); + printf("SATA revision 1.x\n"); else - printf("Unknown serial ATA version\n"); + printf("Unknown SATA revision\n"); } else printf("ATA/ATAPI revision %d\n", version(parm->version_major)); @@ -152,11 +157,11 @@ cap_print(struct ata_params *parm) printf("Protocol "); if (parm->satacapabilities && parm->satacapabilities != 0xffff) { if (parm->satacapabilities & ATA_SATA_GEN2) - printf("Serial ATA II\n"); + printf("SATA revision 2.x\n"); else if (parm->satacapabilities & ATA_SATA_GEN1) - printf("Serial ATA v1.0\n"); + printf("SATA revision 1.x\n"); else - printf("Unknown serial ATA version\n"); + printf("Unknown SATA revision\n"); } else printf("ATA/ATAPI revision %d\n", version(parm->version_major)); @@ -364,6 +369,8 @@ main(int argc, char **argv) fd = open_dev(argv[2], O_RDONLY); if (argc == 4) { mode = str2mode(argv[3]); + if (mode == -1) + errx(1, "unknown mode"); if (ioctl(fd, IOCATASMODE, &mode) < 0) warn("ioctl(IOCATASMODE)"); } From mav at FreeBSD.org Tue Mar 3 00:14:44 2009 From: mav at FreeBSD.org (Alexander Motin) Date: Tue Mar 3 00:14:51 2009 Subject: svn commit: r189299 - in stable/7/sys: . contrib/pf dev/ata dev/ath/ath_hal dev/cxgb Message-ID: <200903030814.n238Ehxk002622@svn.freebsd.org> Author: mav Date: Tue Mar 3 08:14:43 2009 New Revision: 189299 URL: http://svn.freebsd.org/changeset/base/189299 Log: MFC rev. 188700, 188731, 188733. Make core dumping to ad not to freeze even if interrupts, not disabled for some reason (noticed on SMP), stealing our events. ata_interrupt() does not need to return anything. It is not it's business to report request completion, expecially when it is not reliable. PR: kern/114370, kern/115801 Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ata/ata-all.c stable/7/sys/dev/ata/ata-all.h stable/7/sys/dev/ata/ata-queue.c stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/ata/ata-all.c ============================================================================== --- stable/7/sys/dev/ata/ata-all.c Tue Mar 3 07:58:01 2009 (r189298) +++ stable/7/sys/dev/ata/ata-all.c Tue Mar 3 08:14:43 2009 (r189299) @@ -140,7 +140,7 @@ ata_attach(device_t dev) return ENXIO; } if ((error = bus_setup_intr(dev, ch->r_irq, ATA_INTR_FLAGS, NULL, - (driver_intr_t *)ata_interrupt, ch, &ch->ih))) { + ata_interrupt, ch, &ch->ih))) { device_printf(dev, "unable to setup interrupt\n"); return error; } @@ -312,7 +312,7 @@ ata_resume(device_t dev) return error; } -int +void ata_interrupt(void *data) { struct ata_channel *ch = (struct ata_channel *)data; @@ -347,11 +347,10 @@ ata_interrupt(void *data) mtx_unlock(&ch->state_mtx); ATA_LOCKING(ch->dev, ATA_LF_UNLOCK); ata_finish(request); - return 1; + return; } } while (0); mtx_unlock(&ch->state_mtx); - return 0; } /* Modified: stable/7/sys/dev/ata/ata-all.h ============================================================================== --- stable/7/sys/dev/ata/ata-all.h Tue Mar 3 07:58:01 2009 (r189298) +++ stable/7/sys/dev/ata/ata-all.h Tue Mar 3 08:14:43 2009 (r189299) @@ -534,7 +534,7 @@ int ata_detach(device_t dev); int ata_reinit(device_t dev); int ata_suspend(device_t dev); int ata_resume(device_t dev); -int ata_interrupt(void *data); +void ata_interrupt(void *data); int ata_device_ioctl(device_t dev, u_long cmd, caddr_t data); int ata_identify(device_t dev); void ata_default_registers(device_t dev); Modified: stable/7/sys/dev/ata/ata-queue.c ============================================================================== --- stable/7/sys/dev/ata/ata-queue.c Tue Mar 3 07:58:01 2009 (r189298) +++ stable/7/sys/dev/ata/ata-queue.c Tue Mar 3 08:14:43 2009 (r189299) @@ -214,8 +214,10 @@ ata_start(device_t dev) if (dumping) { mtx_unlock(&ch->state_mtx); mtx_unlock(&ch->queue_mtx); - while (!ata_interrupt(ch)) + while (ch->running) { + ata_interrupt(ch); DELAY(10); + } return; } } From jhb at FreeBSD.org Tue Mar 3 08:56:17 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Tue Mar 3 08:56:29 2009 Subject: svn commit: r189307 - in stable/7/sys: . boot/i386/btx/btx contrib/pf dev/ath/ath_hal dev/cxgb Message-ID: <200903031656.n23GuFMW016007@svn.freebsd.org> Author: jhb Date: Tue Mar 3 16:56:15 2009 New Revision: 189307 URL: http://svn.freebsd.org/changeset/base/189307 Log: MFC: Use a clean slate of register state when executing hardware interrupt handlers to avoid leaking values into the upper 16-bits of general purpose registers when executing these routines. Modified: stable/7/sys/ (props changed) stable/7/sys/boot/i386/btx/btx/btx.S stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/boot/i386/btx/btx/btx.S ============================================================================== --- stable/7/sys/boot/i386/btx/btx/btx.S Tue Mar 3 16:38:59 2009 (r189306) +++ stable/7/sys/boot/i386/btx/btx/btx.S Tue Mar 3 16:56:15 2009 (r189307) @@ -36,6 +36,7 @@ /* * Fields in %eflags. */ + .set PSL_RESERVED_DEFAULT,0x00000002 .set PSL_T,0x00000100 # Trap flag .set PSL_I,0x00000200 # Interrupt enable flag .set PSL_VM,0x00020000 # Virtual 8086 mode flag @@ -455,6 +456,18 @@ intx31: pushl $-1 # Dummy int no for * -0x3c %fs * -0x40 %ds * -0x44 %es + * -0x48 zero %eax (hardware int only) + * -0x4c zero %ecx (hardware int only) + * -0x50 zero %edx (hardware int only) + * -0x54 zero %ebx (hardware int only) + * -0x58 zero %esp (hardware int only) + * -0x5c zero %ebp (hardware int only) + * -0x60 zero %esi (hardware int only) + * -0x64 zero %edi (hardware int only) + * -0x68 zero %gs (hardware int only) + * -0x6c zero %fs (hardware int only) + * -0x70 zero %ds (hardware int only) + * -0x74 zero %es (hardware int only) */ int_hw: cld # String ops inc pusha # Save gp regs @@ -467,12 +480,15 @@ int_hw: cld # String ops inc pushl %ds # address popl %es # data leal 0x44(%esp,1),%esi # Base of frame + movl %esp,MEM_ESPR-0x04 # Save kernel stack pointer movl -0x14(%esi),%eax # Get Int no cmpl $-1,%eax # Hardware interrupt? - jne intusr.2 # Yes + jne intusr.1 # Yes /* - * v86 calls save the btx_v86 pointer on the real mode stack and read the - * address and flags from the btx_v86 structure. + * v86 calls save the btx_v86 pointer on the real mode stack and read + * the address and flags from the btx_v86 structure. For interrupt + * handler invocations (VM86 INTx requests), disable interrupts, + * tracing, and alignment checking while the handler runs. */ movl $MEM_USR,%ebx # User base movl %ebx,%edx # address @@ -482,35 +498,36 @@ int_hw: cld # String ops inc movl %edx,MEM_ESPR-0x08 # Save btx_v86 ptr movl V86_ADDR(%edx),%eax # Get int no/address movl V86_CTL(%edx),%edx # Get control flags + movl -0x08(%esi),%ebx # Save user flags in %ebx + testl $V86F_ADDR,%edx # Segment:offset? + jnz intusr.4 # Yes + andl $~(PSL_I|PSL_T|PSL_AC),%ebx # Disable interrupts, tracing, + # and alignment checking for + # interrupt handler jmp intusr.3 # Skip hardware interrupt /* - * Hardware interrupts store a NULL btx_v86 pointer and use the address - * (interrupt number) from the stack with empty flags. Also, we clear - * the segment registers for the interrupt handler. + * Hardware interrupts store a NULL btx_v86 pointer and use the + * address (interrupt number) from the stack with empty flags. Also, + * push a dummy frame of zeros onto the stack for all the general + * purpose and segment registers and clear %eflags. This gives the + * hardware interrupt handler a clean slate. */ -intusr.2: xorl %edx,%edx # Control flags +intusr.1: xorl %edx,%edx # Control flags movl %edx,MEM_ESPR-0x08 # NULL btx_v86 ptr - movl %edx,-0x38(%esi) # Real mode %gs of 0 - movl %edx,-0x3c(%esi) # Real mode %fs of 0 - movl %edx,-0x40(%esi) # Real mode %ds of 0 - movl %edx,-0x44(%esi) # Real mode %es of 0 + movl $12,%ecx # Frame is 12 dwords +intusr.2: pushl $0x0 # Fill frame + loop intusr.2 # with zeros + movl $PSL_RESERVED_DEFAULT,%ebx # Set clean %eflags /* - * %eax now holds either the interrupt number or segment:offset of function. - * %edx now holds the V86F_* flags. - * - * For interrupt handler invocations (either hardware interrupts or VM86 - * INTx requests) we also disable interrupts, tracing, and alignment checking - * while the handler runs. + * Look up real mode IDT entry for hardware interrupts and VM86 INTx + * requests. */ -intusr.3: movl -0x08(%esi),%ebx # Save user flags in %ebx - testl $V86F_ADDR,%edx # Segment:offset? - jnz intusr.4 # Yes - shll $0x2,%eax # Scale +intusr.3: shll $0x2,%eax # Scale movl (%eax),%eax # Load int vector - andl $~(PSL_I|PSL_T|PSL_AC),%ebx # Disable interrupts, tracing, - # and alignment checking for - # interrupt handler jmp intusr.5 # Skip CALLF test +/* + * Panic if V86F_CALLF isn't set with V86F_ADDR. + */ intusr.4: testl $V86F_CALLF,%edx # Far call? jnz intusr.5 # Ok movl %edx,0x30(%esp,1) # Place VM86 flags in int no @@ -522,6 +539,11 @@ intusr.4: testl $V86F_CALLF,%edx # Far popl %gs popal # Restore gp regs jmp ex_noc # Panic +/* + * %eax now holds the segment:offset of the function. + * %ebx now holds the %eflags to pass to real mode. + * %edx now holds the V86F_* flags. + */ intusr.5: movw %bx,MEM_ESPR-0x12 # Pass user flags to real mode # target /* @@ -536,8 +558,7 @@ intusr.5: movw %bx,MEM_ESPR-0x12 # Pass rep # from btx_v86 movsl # to kernel stack popl %esi # Restore -intusr.6: movl %esp,MEM_ESPR-0x04 # Save kernel stack pointer - movl -0x08(%esi),%ebx # Copy user flags to real +intusr.6: movl -0x08(%esi),%ebx # Copy user flags to real movl %ebx,MEM_ESPR-0x0c # mode return trampoline movl $rret_tramp,%ebx # Set return trampoline movl %ebx,MEM_ESPR-0x10 # CS:IP @@ -611,9 +632,16 @@ rret_tramp.1: xorl %ecx,%ecx # Zero movb $SEL_TSS,%cl # Set task ltr %cx # register /* - * Now we are back in protected mode. Copy the registers off of the real - * mode stack onto the kernel stack. Also, initialize all the seg regs on - * the kernel stack. + * Now we are back in protected mode. The kernel stack frame set up + * before entering real mode is still intact. For hardware interrupts, + * leave the frame unchanged. + */ + cmpl $0,MEM_ESPR-0x08 # Leave saved regs unchanged + jz rret_tramp.3 # for hardware ints +/* + * For V86 calls, copy the registers off of the real mode stack onto + * the kernel stack as we want their updated values. Also, initialize + * the segment registers on the kernel stack. * * Note that the %esp in the kernel stack after this is garbage, but popa * ignores it, so we don't have to fix it up. @@ -624,20 +652,17 @@ rret_tramp.1: xorl %ecx,%ecx # Zero movl $8,%ecx # Copy GP regs from rep # real mode stack movsl # to kernel stack - popl %esi # Restore movl $SEL_UDATA,%eax # Selector for data seg regs movl $4,%ecx # Initialize %ds, rep # %es, %fs, and stosl # %gs /* - * If this was a V86 call, copy the saved seg regs on the real mode stack - * back over to the btx_v86 structure. Also, conditionally update the saved - * eflags on the kernel stack based on the flags from the user. + * For V86 calls, copy the saved seg regs on the real mode stack back + * over to the btx_v86 structure. Also, conditionally update the + * saved eflags on the kernel stack based on the flags from the user. */ movl MEM_ESPR-0x08,%ecx # Get btx_v86 ptr - jecxz rret_tramp.3 # Skip for hardware ints leal V86_GS(%ecx),%edi # %edi => btx_v86 seg regs - pushl %esi # Save leal MEM_ESPR-0x2c,%esi # %esi => real mode seg regs xchgl %ecx,%edx # Save btx_v86 ptr movl $4,%ecx # Copy seg regs From yongari at FreeBSD.org Tue Mar 3 17:50:02 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 3 17:50:14 2009 Subject: svn commit: r189334 - in stable/7/sys: amd64/conf i386/conf Message-ID: <200903040150.n241o0KX027491@svn.freebsd.org> Author: yongari Date: Wed Mar 4 01:50:00 2009 New Revision: 189334 URL: http://svn.freebsd.org/changeset/base/189334 Log: Enable ale(4) in GENERIC. Modified: stable/7/sys/amd64/conf/GENERIC stable/7/sys/i386/conf/GENERIC Modified: stable/7/sys/amd64/conf/GENERIC ============================================================================== --- stable/7/sys/amd64/conf/GENERIC Wed Mar 4 01:47:50 2009 (r189333) +++ stable/7/sys/amd64/conf/GENERIC Wed Mar 4 01:50:00 2009 (r189334) @@ -193,7 +193,7 @@ device vx # 3Com 3c590, 3c595 (``Vorte # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! device miibus # MII bus support device age # Attansic/Atheros L1 Gigabit Ethernet -#device ale # Atheros AR8121/AR8113/AR8114 Ethernet +device ale # Atheros AR8121/AR8113/AR8114 Ethernet device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet device bfe # Broadcom BCM440x 10/100 Ethernet device bge # Broadcom BCM570xx Gigabit Ethernet Modified: stable/7/sys/i386/conf/GENERIC ============================================================================== --- stable/7/sys/i386/conf/GENERIC Wed Mar 4 01:47:50 2009 (r189333) +++ stable/7/sys/i386/conf/GENERIC Wed Mar 4 01:50:00 2009 (r189334) @@ -204,7 +204,7 @@ device vx # 3Com 3c590, 3c595 (``Vorte # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! device miibus # MII bus support device age # Attansic/Atheros L1 Gigabit Ethernet -#device ale # Atheros AR8121/AR8113/AR8114 Ethernet +device ale # Atheros AR8121/AR8113/AR8114 Ethernet device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet device bfe # Broadcom BCM440x 10/100 Ethernet device bge # Broadcom BCM570xx Gigabit Ethernet From netchild at FreeBSD.org Wed Mar 4 12:26:40 2009 From: netchild at FreeBSD.org (Alexander Leidinger) Date: Wed Mar 4 12:26:57 2009 Subject: svn commit: r189370 - in stable/7/sys: . compat/linux contrib/pf dev/ath/ath_hal dev/cxgb Message-ID: <200903042026.n24KQdkK052139@svn.freebsd.org> Author: netchild Date: Wed Mar 4 20:26:39 2009 New Revision: 189370 URL: http://svn.freebsd.org/changeset/base/189370 Log: MFC r188572: Fix an edge-case of the linux readdir: We need the size of a linux dirent structure, not the size of a pointer to it. PR: 131099 Submitted by: Andreas Kies Modified: stable/7/sys/ (props changed) stable/7/sys/compat/linux/linux_file.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/compat/linux/linux_file.c ============================================================================== --- stable/7/sys/compat/linux/linux_file.c Wed Mar 4 18:36:48 2009 (r189369) +++ stable/7/sys/compat/linux/linux_file.c Wed Mar 4 20:26:39 2009 (r189370) @@ -438,7 +438,7 @@ getdents_common(struct thread *td, struc /* readdir(2) case. Always struct dirent. */ if (is64bit) return (EINVAL); - nbytes = sizeof(linux_dirent); + nbytes = sizeof(*linux_dirent); justone = 1; } else justone = 0; From jhb at FreeBSD.org Wed Mar 4 13:38:17 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 4 13:38:34 2009 Subject: svn commit: r189375 - stable/7/share/mk Message-ID: <200903042138.n24LcGkS053991@svn.freebsd.org> Author: jhb Date: Wed Mar 4 21:38:16 2009 New Revision: 189375 URL: http://svn.freebsd.org/changeset/base/189375 Log: MFC: Handle an additional layer of nesting for kernel modules to make it easier to compile 8.x kernels with modules on 7. Modified: stable/7/share/mk/ (props changed) stable/7/share/mk/bsd.kmod.mk Modified: stable/7/share/mk/bsd.kmod.mk ============================================================================== --- stable/7/share/mk/bsd.kmod.mk Wed Mar 4 21:22:39 2009 (r189374) +++ stable/7/share/mk/bsd.kmod.mk Wed Mar 4 21:38:16 2009 (r189375) @@ -2,7 +2,7 @@ # Search for kernel source tree in standard places. .for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. ${.CURDIR}/../../../.. \ - /sys /usr/src/sys + ${.CURDIR}/../../../../.. /sys /usr/src/sys .if !defined(SYSDIR) && exists(${_dir}/kern/) && exists(${_dir}/conf/kmod.mk) SYSDIR= ${_dir} .endif From luigi at FreeBSD.org Wed Mar 4 23:42:48 2009 From: luigi at FreeBSD.org (Luigi Rizzo) Date: Wed Mar 4 23:43:05 2009 Subject: svn commit: r189393 - stable/7/sys/netinet Message-ID: <200903050742.n257gljY066376@svn.freebsd.org> Author: luigi Date: Thu Mar 5 07:42:47 2009 New Revision: 189393 URL: http://svn.freebsd.org/changeset/base/189393 Log: Merge a couple of changes from HEAD, plus fix a potential warning. In detail: + we used SYSCTL_LONG to show a 64-bit variable. For the time being just remove the variable from the list of sysctl-exported values. Unfortunately our SYSCTL macros do not do proper type checking of the arguments so we might have some more bugs of this kind across the codebase; + fw_debug has not been used for ages, so remove it; + gcc 4.2.4 tells me that src_ip.s_addr may be not initialized, so make sure it is. I need to check what is the status of this field in head. Modified: stable/7/sys/netinet/ip_dummynet.c stable/7/sys/netinet/ip_fw2.c Modified: stable/7/sys/netinet/ip_dummynet.c ============================================================================== --- stable/7/sys/netinet/ip_dummynet.c Thu Mar 5 06:26:08 2009 (r189392) +++ stable/7/sys/netinet/ip_dummynet.c Thu Mar 5 07:42:47 2009 (r189393) @@ -160,8 +160,10 @@ SYSCTL_DECL(_net_inet_ip); SYSCTL_NODE(_net_inet_ip, OID_AUTO, dummynet, CTLFLAG_RW, 0, "Dummynet"); SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, hash_size, CTLFLAG_RW, &dn_hash_size, 0, "Default hash table size"); +#if 0 /* curr_time is 64 bit */ SYSCTL_LONG(_net_inet_ip_dummynet, OID_AUTO, curr_time, CTLFLAG_RD, &curr_time, 0, "Current tick"); +#endif SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, ready_heap, CTLFLAG_RD, &ready_heap.size, 0, "Size of ready heap"); SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, extract_heap, Modified: stable/7/sys/netinet/ip_fw2.c ============================================================================== --- stable/7/sys/netinet/ip_fw2.c Thu Mar 5 06:26:08 2009 (r189392) +++ stable/7/sys/netinet/ip_fw2.c Thu Mar 5 07:42:47 2009 (r189393) @@ -146,7 +146,6 @@ struct table_entry { u_int32_t value; }; -static int fw_debug = 1; static int autoinc_step = 100; /* bounded to 1..1000 in add_rule() */ extern int ipfw_chg_hook(SYSCTL_HANDLER_ARGS); @@ -162,8 +161,6 @@ SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, on CTLFLAG_RW | CTLFLAG_SECURE3, &fw_one_pass, 0, "Only do a single pass through ipfw when using dummynet(4)"); -SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, debug, CTLFLAG_RW, - &fw_debug, 0, "Enable printing of debug ip_fw statements"); SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, verbose, CTLFLAG_RW | CTLFLAG_SECURE3, &fw_verbose, 0, "Log matches to ipfw rules"); @@ -2208,6 +2205,7 @@ ipfw_chk(struct ip_fw_args *args) return (IP_FW_PASS); /* accept */ dst_ip.s_addr = 0; /* make sure it is initialized */ + src_ip.s_addr = 0; /* make sure it is initialized */ pktlen = m->m_pkthdr.len; args->f_id.fib = M_GETFIB(m); /* note mbuf not altered) */ proto = args->f_id.proto = 0; /* mark f_id invalid */ From jhb at FreeBSD.org Thu Mar 5 07:47:01 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Thu Mar 5 07:47:27 2009 Subject: svn commit: r189402 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/pci Message-ID: <200903051546.n25FkfBS086867@svn.freebsd.org> Author: jhb Date: Thu Mar 5 15:46:41 2009 New Revision: 189402 URL: http://svn.freebsd.org/changeset/base/189402 Log: MFC: Don't throw away the upper 32-bits of the HT MSI address window. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/pci/pci.c Modified: stable/7/sys/dev/pci/pci.c ============================================================================== --- stable/7/sys/dev/pci/pci.c Thu Mar 5 15:33:04 2009 (r189401) +++ stable/7/sys/dev/pci/pci.c Thu Mar 5 15:46:41 2009 (r189402) @@ -554,7 +554,7 @@ pci_read_extcap(device_t pcib, pcicfgreg addr = REG(ptr + PCIR_HTMSI_ADDRESS_HI, 4); addr <<= 32; - addr = REG(ptr + PCIR_HTMSI_ADDRESS_LO, + addr |= REG(ptr + PCIR_HTMSI_ADDRESS_LO, 4); if (addr != MSI_INTEL_ADDR_BASE) device_printf(pcib, From emax at FreeBSD.org Thu Mar 5 09:54:29 2009 From: emax at FreeBSD.org (Maksim Yevmenkin) Date: Thu Mar 5 09:54:46 2009 Subject: svn commit: r189413 - stable/7/include Message-ID: <200903051754.n25HsSp7095098@svn.freebsd.org> Author: emax Date: Thu Mar 5 17:54:28 2009 New Revision: 189413 URL: http://svn.freebsd.org/changeset/base/189413 Log: MFC r183057 Add missing prototypes for uuid_enc,dec_le,be() functions. Pointy hat goes to me. Modified: stable/7/include/ (props changed) stable/7/include/uuid.h Modified: stable/7/include/uuid.h ============================================================================== --- stable/7/include/uuid.h Thu Mar 5 16:56:16 2009 (r189412) +++ stable/7/include/uuid.h Thu Mar 5 17:54:28 2009 (r189413) @@ -54,6 +54,10 @@ void uuid_from_string(const char *, uuid uint16_t uuid_hash(const uuid_t *, uint32_t *); int32_t uuid_is_nil(const uuid_t *, uint32_t *); void uuid_to_string(const uuid_t *, char **, uint32_t *); +void uuid_enc_le(void *, const uuid_t *); +void uuid_dec_le(const void *, uuid_t *); +void uuid_enc_be(void *, const uuid_t *); +void uuid_dec_be(const void *, uuid_t *); __END_DECLS #endif /* _UUID_H_ */ From emax at FreeBSD.org Thu Mar 5 10:03:47 2009 From: emax at FreeBSD.org (Maksim Yevmenkin) Date: Thu Mar 5 10:04:00 2009 Subject: svn commit: r189414 - in stable/7/usr.sbin/bluetooth: . btpand sdpd Message-ID: <200903051803.n25I3kEn095351@svn.freebsd.org> Author: emax Date: Thu Mar 5 18:03:46 2009 New Revision: 189414 URL: http://svn.freebsd.org/changeset/base/189414 Log: MFC r187938 Add btpand(8) daemon from NetBSD. This daemon provides support for Bluetooth Network Access Point (NAP), Group Ad-hoc Network (GN) and Personal Area Network User (PANU) profiles. MFC r188013 Fix client mode. Pick up service availability changes. MFC r188014 Hook up btpand(8) to the build Obtained from: NetBSD Added: stable/7/usr.sbin/bluetooth/btpand/ - copied from r187938, head/usr.sbin/bluetooth/btpand/ Modified: stable/7/usr.sbin/bluetooth/ (props changed) stable/7/usr.sbin/bluetooth/Makefile stable/7/usr.sbin/bluetooth/btpand/btpand.c stable/7/usr.sbin/bluetooth/btpand/btpand.h stable/7/usr.sbin/bluetooth/btpand/server.c stable/7/usr.sbin/bluetooth/sdpd/ (props changed) Modified: stable/7/usr.sbin/bluetooth/Makefile ============================================================================== --- stable/7/usr.sbin/bluetooth/Makefile Thu Mar 5 17:54:28 2009 (r189413) +++ stable/7/usr.sbin/bluetooth/Makefile Thu Mar 5 18:03:46 2009 (r189414) @@ -6,6 +6,7 @@ SUBDIR= \ bt3cfw \ bthidcontrol \ bthidd \ + btpand \ hccontrol \ hcsecd \ hcseriald \ Modified: stable/7/usr.sbin/bluetooth/btpand/btpand.c ============================================================================== --- head/usr.sbin/bluetooth/btpand/btpand.c Fri Jan 30 22:23:21 2009 (r187938) +++ stable/7/usr.sbin/bluetooth/btpand/btpand.c Thu Mar 5 18:03:46 2009 (r189414) @@ -54,8 +54,8 @@ uint16_t service_class; bdaddr_t local_bdaddr; /* -d */ bdaddr_t remote_bdaddr; /* -a */ -uint16_t l2cap_psm = 15; /* -p */ -int l2cap_mode = 0; /* -m */ +uint16_t l2cap_psm; /* -p */ +int l2cap_mode; /* -m */ int server_limit; /* -n */ @@ -177,6 +177,9 @@ main(int argc, char *argv[]) if (interface_name == NULL) interface_name = "/dev/tap"; + if (l2cap_psm == 0) + l2cap_psm = L2CAP_PSM_BNEP; + if (bdaddr_any(&remote_bdaddr) && server_limit == 0) { if (service_class == SDP_SERVICE_CLASS_PANU) server_limit = 1; Modified: stable/7/usr.sbin/bluetooth/btpand/btpand.h ============================================================================== --- head/usr.sbin/bluetooth/btpand/btpand.h Fri Jan 30 22:23:21 2009 (r187938) +++ stable/7/usr.sbin/bluetooth/btpand/btpand.h Thu Mar 5 18:03:46 2009 (r189414) @@ -51,6 +51,10 @@ #define L2CAP_PSM_INVALID(psm) (((psm) & 0x0101) != 0x0001) #endif +#ifndef L2CAP_PSM_BNEP +#define L2CAP_PSM_BNEP 15 +#endif + typedef struct channel channel_t; typedef struct pfilter pfilter_t; typedef struct mfilter mfilter_t; Modified: stable/7/usr.sbin/bluetooth/btpand/server.c ============================================================================== --- head/usr.sbin/bluetooth/btpand/server.c Fri Jan 30 22:23:21 2009 (r187938) +++ stable/7/usr.sbin/bluetooth/btpand/server.c Thu Mar 5 18:03:46 2009 (r189414) @@ -1,4 +1,4 @@ -/* $NetBSD: server.c,v 1.1 2008/08/17 13:20:57 plunky Exp $ */ +/* $NetBSD: server.c,v 1.2 2009/01/24 17:29:28 plunky Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -28,11 +28,12 @@ /* $FreeBSD$ */ #include -__RCSID("$NetBSD: server.c,v 1.1 2008/08/17 13:20:57 plunky Exp $"); +__RCSID("$NetBSD: server.c,v 1.2 2009/01/24 17:29:28 plunky Exp $"); #include #include +#include #include #include #include @@ -42,7 +43,7 @@ __RCSID("$NetBSD: server.c,v 1.1 2008/08 static struct event server_ev; static int server_fd; -static int server_load; +static int server_avail; static void * server_ss; static uint32_t server_handle; @@ -73,13 +74,13 @@ server_update(int count) log_debug("count %d", count); - server_load = (count - 1) * 100 / server_limit; - log_info("server_load: %d%%", server_load); + server_avail = UINT8_MAX - (count - 1) * UINT8_MAX / server_limit; + log_info("Service Availability: %d/%d", server_avail, UINT8_MAX); - if (server_load > 99 && server_fd != -1) + if (server_avail == 0 && server_fd != -1) server_close(); - if (server_load < 100 && server_fd == -1) + if (server_avail > 0 && server_fd == -1) server_open(); if (service_name) @@ -257,19 +258,9 @@ server_register(void) } memset(&p, 0, sizeof(p)); - p.psm = l2cap_psm; - - if (server_load < 1) p.load_factor = 0; - else if (server_load <= 17) p.load_factor = 1; - else if (server_load <= 33) p.load_factor = 2; - else if (server_load <= 50) p.load_factor = 3; - else if (server_load <= 67) p.load_factor = 4; - else if (server_load <= 83) p.load_factor = 5; - else if (server_load <= 99) p.load_factor = 6; - else p.load_factor = 7; - - if (l2cap_mode != 0) p.security_description = 0x0001; + p.load_factor = server_avail; + p.security_description = (l2cap_mode == 0 ? 0x0000 : 0x0001); if (server_handle) rv = sdp_change_service(server_ss, server_handle, From emax at FreeBSD.org Thu Mar 5 17:27:52 2009 From: emax at FreeBSD.org (Maksim Yevmenkin) Date: Thu Mar 5 17:27:58 2009 Subject: svn commit: r189425 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netgraph/bluetooth/socket Message-ID: <200903060127.n261Rpqe004160@svn.freebsd.org> Author: emax Date: Fri Mar 6 01:27:51 2009 New Revision: 189425 URL: http://svn.freebsd.org/changeset/base/189425 Log: MFC r188132 Allow unprivileged users to run l2ping(8). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c Modified: stable/7/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c ============================================================================== --- stable/7/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c Thu Mar 5 21:18:10 2009 (r189424) +++ stable/7/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c Fri Mar 6 01:27:51 2009 (r189425) @@ -948,11 +948,6 @@ ng_btsocket_l2cap_raw_control(struct soc ng_l2cap_l2ca_ping_ip *ip = NULL; ng_l2cap_l2ca_ping_op *op = NULL; - if (!(pcb->flags & NG_BTSOCKET_L2CAP_RAW_PRIVILEGED)) { - error = EPERM; - break; - } - if ((p->echo_size != 0 && p->echo_data == NULL) || p->echo_size > NG_L2CAP_MAX_ECHO_SIZE) { error = EINVAL; From emax at FreeBSD.org Thu Mar 5 17:34:31 2009 From: emax at FreeBSD.org (Maksim Yevmenkin) Date: Thu Mar 5 17:34:38 2009 Subject: svn commit: r189426 - in stable/7: usr.bin/bluetooth/rfcomm_sppd usr.sbin/bluetooth/hcsecd usr.sbin/bluetooth/hcseriald usr.sbin/bluetooth/rfcomm_pppd Message-ID: <200903060134.n261YURs004375@svn.freebsd.org> Author: emax Date: Fri Mar 6 01:34:30 2009 New Revision: 189426 URL: http://svn.freebsd.org/changeset/base/189426 Log: MFC r188130 Clenup code a bit and do not call fork(2) before dameon(3) where not needed. Modified: stable/7/usr.bin/bluetooth/rfcomm_sppd/ (props changed) stable/7/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c stable/7/usr.sbin/bluetooth/hcsecd/ (props changed) stable/7/usr.sbin/bluetooth/hcsecd/hcsecd.c stable/7/usr.sbin/bluetooth/hcseriald/ (props changed) stable/7/usr.sbin/bluetooth/hcseriald/hcseriald.c stable/7/usr.sbin/bluetooth/rfcomm_pppd/ (props changed) stable/7/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c Modified: stable/7/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c ============================================================================== --- stable/7/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c Fri Mar 6 01:27:51 2009 (r189425) +++ stable/7/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c Fri Mar 6 01:34:30 2009 (r189426) @@ -281,22 +281,8 @@ main(int argc, char *argv[]) } /* Became daemon if required */ - if (background) { - switch (fork()) { - case -1: - err(1, "Could not fork()"); - /* NOT REACHED */ - - case 0: - exit(0); - /* NOT REACHED */ - - default: - if (daemon(0, 0) < 0) - err(1, "Could not daemon()"); - break; - } - } + if (background && daemon(0, 0) < 0) + err(1, "Could not daemon()"); openlog(SPPD_IDENT, LOG_NDELAY|LOG_PERROR|LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "Starting on %s...", (tty != NULL)? tty : "stdin/stdout"); Modified: stable/7/usr.sbin/bluetooth/hcsecd/hcsecd.c ============================================================================== --- stable/7/usr.sbin/bluetooth/hcsecd/hcsecd.c Fri Mar 6 01:27:51 2009 (r189425) +++ stable/7/usr.sbin/bluetooth/hcsecd/hcsecd.c Fri Mar 6 01:34:30 2009 (r189426) @@ -128,9 +128,8 @@ main(int argc, char *argv[]) (void * const) &filter, sizeof(filter)) < 0) err(1, "Could not set HCI socket filter"); - if (detach) - if (daemon(0, 0) < 0) - err(1, "Could not daemon()ize"); + if (detach && daemon(0, 0) < 0) + err(1, "Could not daemon()ize"); openlog(HCSECD_IDENT, LOG_NDELAY|LOG_PERROR|LOG_PID, LOG_DAEMON); Modified: stable/7/usr.sbin/bluetooth/hcseriald/hcseriald.c ============================================================================== --- stable/7/usr.sbin/bluetooth/hcseriald/hcseriald.c Fri Mar 6 01:27:51 2009 (r189425) +++ stable/7/usr.sbin/bluetooth/hcseriald/hcseriald.c Fri Mar 6 01:34:30 2009 (r189426) @@ -101,23 +101,10 @@ main(int argc, char *argv[]) /* Open device */ n = open_device(device, speed, name); - if (detach) { - pid_t pid = fork(); - - if (pid == (pid_t) -1) { - syslog(LOG_ERR, "Could not fork(). %s (%d)", - strerror(errno), errno); - exit(1); - } - - if (pid != 0) - exit(0); - - if (daemon(0, 0) < 0) { - syslog(LOG_ERR, "Could not daemon(0, 0). %s (%d)", - strerror(errno), errno); - exit(1); - } + if (detach && daemon(0, 0) < 0) { + syslog(LOG_ERR, "Could not daemon(0, 0). %s (%d)", + strerror(errno), errno); + exit(1); } /* Write PID file */ Modified: stable/7/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c ============================================================================== --- stable/7/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c Fri Mar 6 01:27:51 2009 (r189425) +++ stable/7/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c Fri Mar 6 01:34:30 2009 (r189426) @@ -166,22 +166,10 @@ main(int argc, char *argv[]) openlog(RFCOMM_PPPD, LOG_PID | LOG_PERROR | LOG_NDELAY, LOG_USER); - if (detach) { - pid = fork(); - if (pid == (pid_t) -1) { - syslog(LOG_ERR, "Could not fork(). %s (%d)", - strerror(errno), errno); - exit(1); - } - - if (pid != 0) - exit(0); - - if (daemon(0, 0) < 0) { - syslog(LOG_ERR, "Could not daemon(0, 0). %s (%d)", - strerror(errno), errno); - exit(1); - } + if (detach && daemon(0, 0) < 0) { + syslog(LOG_ERR, "Could not daemon(0, 0). %s (%d)", + strerror(errno), errno); + exit(1); } s = socket(PF_BLUETOOTH, SOCK_STREAM, BLUETOOTH_PROTO_RFCOMM); From nwhitehorn at FreeBSD.org Sat Mar 7 12:39:43 2009 From: nwhitehorn at FreeBSD.org (Nathan Whitehorn) Date: Sat Mar 7 12:39:51 2009 Subject: svn commit: r189498 - in stable/7: share/mk sys sys/conf sys/contrib/pf sys/dev/ath/ath_hal sys/dev/cxgb sys/powerpc/include sys/powerpc/powerpc Message-ID: <200903072039.n27Kdg2q062234@svn.freebsd.org> Author: nwhitehorn Date: Sat Mar 7 20:39:42 2009 New Revision: 189498 URL: http://svn.freebsd.org/changeset/base/189498 Log: MFC r188860,188879,188923,188951: Altivec support for PowerPC. Added: stable/7/sys/powerpc/include/altivec.h - copied unchanged from r188860, head/sys/powerpc/include/altivec.h stable/7/sys/powerpc/powerpc/altivec.c - copied unchanged from r188860, head/sys/powerpc/powerpc/altivec.c Modified: stable/7/share/mk/ (props changed) stable/7/share/mk/bsd.cpu.mk stable/7/sys/ (props changed) stable/7/sys/conf/files.powerpc stable/7/sys/conf/kern.mk stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/powerpc/include/pcb.h stable/7/sys/powerpc/include/pcpu.h stable/7/sys/powerpc/powerpc/genassym.c stable/7/sys/powerpc/powerpc/machdep.c stable/7/sys/powerpc/powerpc/swtch.S stable/7/sys/powerpc/powerpc/trap.c stable/7/sys/powerpc/powerpc/trap_subr.S Modified: stable/7/share/mk/bsd.cpu.mk ============================================================================== --- stable/7/share/mk/bsd.cpu.mk Sat Mar 7 19:54:30 2009 (r189497) +++ stable/7/share/mk/bsd.cpu.mk Sat Mar 7 20:39:42 2009 (r189498) @@ -109,6 +109,8 @@ _CPUCFLAGS = -march=armv5te -D__XSCALE__ . else _CPUCFLAGS = -mcpu=${CPUTYPE} . endif +. elif ${MACHINE_ARCH} == "powerpc" +_CPUCFLAGS = -mcpu=${CPUTYPE} . endif # Set up the list of CPU features based on the CPU type. This is an Modified: stable/7/sys/conf/files.powerpc ============================================================================== --- stable/7/sys/conf/files.powerpc Sat Mar 7 19:54:30 2009 (r189497) +++ stable/7/sys/conf/files.powerpc Sat Mar 7 20:39:42 2009 (r189498) @@ -34,6 +34,7 @@ dev/syscons/scterm-sc.c optional sc dev/syscons/scvtb.c optional sc dev/uart/uart_cpu_powerpc.c optional uart kern/syscalls.c optional ktr +powerpc/powerpc/altivec.c standard powerpc/powerpc/atomic.S standard powerpc/powerpc/autoconf.c standard powerpc/powerpc/bcopy.c standard Modified: stable/7/sys/conf/kern.mk ============================================================================== --- stable/7/sys/conf/kern.mk Sat Mar 7 19:54:30 2009 (r189497) +++ stable/7/sys/conf/kern.mk Sat Mar 7 20:39:42 2009 (r189498) @@ -78,9 +78,10 @@ INLINE_LIMIT?= 8000 # # For PowerPC we tell gcc to use floating point emulation. This avoids using # floating point registers for integer operations which it has a tendency to do. +# Also explicitly disable Altivec instructions inside the kernel. # .if ${MACHINE_ARCH} == "powerpc" -CFLAGS+= -msoft-float +CFLAGS+= -msoft-float -mno-altivec INLINE_LIMIT?= 15000 .endif Copied: stable/7/sys/powerpc/include/altivec.h (from r188860, head/sys/powerpc/include/altivec.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/powerpc/include/altivec.h Sat Mar 7 20:39:42 2009 (r189498, copy of r188860, head/sys/powerpc/include/altivec.h) @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2008 Nathan Whitehorn + * 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$ + */ + +#ifndef _MACHINE_ALTIVEC_H_ +#define _MACHINE_ALTIVEC_H_ + +void enable_vec(struct thread *); +void save_vec(struct thread *); + +#endif /* _MACHINE_ALTIVEC_H_ */ + Modified: stable/7/sys/powerpc/include/pcb.h ============================================================================== --- stable/7/sys/powerpc/include/pcb.h Sat Mar 7 19:54:30 2009 (r189497) +++ stable/7/sys/powerpc/include/pcb.h Sat Mar 7 20:39:42 2009 (r189498) @@ -49,12 +49,21 @@ struct pcb { copyin/copyout */ int pcb_flags; #define PCB_FPU 1 /* Process had FPU initialized */ +#define PCB_VEC 2 /* Process had Altivec initialized */ struct fpu { double fpr[32]; double fpscr; /* FPSCR stored as double for easier access */ } pcb_fpu; /* Floating point processor */ unsigned int pcb_fpcpu; /* which CPU had our FPU stuff. */ + struct vec { + uint32_t vr[32][4]; + register_t vrsave; + register_t spare[2]; + register_t vscr; + } pcb_vec __attribute__((aligned(16))); /* Vector processor */ + unsigned int pcb_veccpu; /* which CPU had our vector + stuff. */ }; #ifdef _KERNEL Modified: stable/7/sys/powerpc/include/pcpu.h ============================================================================== --- stable/7/sys/powerpc/include/pcpu.h Sat Mar 7 19:54:30 2009 (r189497) +++ stable/7/sys/powerpc/include/pcpu.h Sat Mar 7 20:39:42 2009 (r189498) @@ -39,6 +39,7 @@ struct pmap; int pc_inside_intr; \ struct pmap *pc_curpmap; /* current pmap */ \ struct thread *pc_fputhread; /* current fpu user */ \ + struct thread *pc_vecthread; /* current vec user */ \ register_t pc_tempsave[CPUSAVE_LEN]; \ register_t pc_disisave[CPUSAVE_LEN]; \ register_t pc_dbsave[CPUSAVE_LEN]; Copied: stable/7/sys/powerpc/powerpc/altivec.c (from r188860, head/sys/powerpc/powerpc/altivec.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/powerpc/powerpc/altivec.c Sat Mar 7 20:39:42 2009 (r189498, copy of r188860, head/sys/powerpc/powerpc/altivec.c) @@ -0,0 +1,152 @@ +/*- + * Copyright (C) 1996 Wolfgang Solfrank. + * Copyright (C) 1996 TooLs GmbH. + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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. + * + * $NetBSD: fpu.c,v 1.5 2001/07/22 11:29:46 wiz Exp $ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include +#include + +void +enable_vec(struct thread *td) +{ + int msr; + struct pcb *pcb; + struct trapframe *tf; + + pcb = td->td_pcb; + tf = trapframe(td); + + /* + * Save the thread's Altivec CPU number, and set the CPU's current + * vector thread + */ + td->td_pcb->pcb_veccpu = PCPU_GET(cpuid); + PCPU_SET(vecthread, td); + + /* + * Enable the vector unit for when the thread returns from the + * exception. If this is the first time the unit has been used by + * the thread, initialise the vector registers and VSCR to 0, and + * set the flag to indicate that the vector unit is in use. + */ + tf->srr1 |= PSL_VEC; + if (!(pcb->pcb_flags & PCB_VEC)) { + memset(&pcb->pcb_vec, 0, sizeof pcb->pcb_vec); + pcb->pcb_flags |= PCB_VEC; + } + + /* + * Temporarily enable the vector unit so the registers + * can be restored. + */ + msr = mfmsr(); + mtmsr(msr | PSL_VEC); + isync(); + + /* + * Restore VSCR by first loading it into a vector and then into VSCR. + * (this needs to done before loading the user's vector registers + * since we need to use a scratch vector register) + */ + __asm __volatile("vxor 0,0,0; lvewx 0,0,%0; mtvscr 0" \ + :: "b"(&pcb->pcb_vec.vscr)); + +#define LVX(n) __asm ("lvx " #n ",0,%0" \ + :: "b"(&pcb->pcb_vec.vr[n])); + LVX(0); LVX(1); LVX(2); LVX(3); + LVX(4); LVX(5); LVX(6); LVX(7); + LVX(8); LVX(9); LVX(10); LVX(11); + LVX(12); LVX(13); LVX(14); LVX(15); + LVX(16); LVX(17); LVX(18); LVX(19); + LVX(20); LVX(21); LVX(22); LVX(23); + LVX(24); LVX(25); LVX(26); LVX(27); + LVX(28); LVX(29); LVX(30); LVX(31); +#undef LVX + + isync(); + mtmsr(msr); +} + +void +save_vec(struct thread *td) +{ + int msr; + struct pcb *pcb; + + pcb = td->td_pcb; + + /* + * Temporarily re-enable the vector unit during the save + */ + msr = mfmsr(); + mtmsr(msr | PSL_VEC); + isync(); + + /* + * Save the vector registers and VSCR to the PCB + */ +#define STVX(n) __asm ("stvx %1,0,%0" \ + :: "b"(pcb->pcb_vec.vr[n]), "n"(n)); + STVX(0); STVX(1); STVX(2); STVX(3); + STVX(4); STVX(5); STVX(6); STVX(7); + STVX(8); STVX(9); STVX(10); STVX(11); + STVX(12); STVX(13); STVX(14); STVX(15); + STVX(16); STVX(17); STVX(18); STVX(19); + STVX(20); STVX(21); STVX(22); STVX(23); + STVX(24); STVX(25); STVX(26); STVX(27); + STVX(28); STVX(29); STVX(30); STVX(31); +#undef STVX + + __asm __volatile("mfvscr 0; stvewx 0,0,%0" :: "b"(&pcb->pcb_vec.vscr)); + + /* + * Disable vector unit again + */ + isync(); + mtmsr(msr); + + /* + * Clear the current vec thread and pcb's CPU id + * XXX should this be left clear to allow lazy save/restore ? + */ + pcb->pcb_veccpu = INT_MAX; + PCPU_SET(vecthread, NULL); +} + Modified: stable/7/sys/powerpc/powerpc/genassym.c ============================================================================== --- stable/7/sys/powerpc/powerpc/genassym.c Sat Mar 7 19:54:30 2009 (r189497) +++ stable/7/sys/powerpc/powerpc/genassym.c Sat Mar 7 20:39:42 2009 (r189498) @@ -136,6 +136,7 @@ ASSYM(PCB_USR, offsetof(struct pcb, pcb_ ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags)); ASSYM(PCB_FPU, PCB_FPU); +ASSYM(PCB_VEC, PCB_VEC); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); Modified: stable/7/sys/powerpc/powerpc/machdep.c ============================================================================== --- stable/7/sys/powerpc/powerpc/machdep.c Sat Mar 7 19:54:30 2009 (r189497) +++ stable/7/sys/powerpc/powerpc/machdep.c Sat Mar 7 20:39:42 2009 (r189498) @@ -103,6 +103,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -252,7 +253,6 @@ extern void *dsitrap, *dsisize; extern void *decrint, *decrsize; extern void *extint, *extsize; extern void *dblow, *dbsize; -extern void *vectrap, *vectrapsize; void powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp) @@ -343,7 +343,7 @@ powerpc_init(u_int startkernel, u_int en bcopy(&trapcode, (void *)EXC_SC, (size_t)&trapsize); bcopy(&trapcode, (void *)EXC_TRC, (size_t)&trapsize); bcopy(&trapcode, (void *)EXC_FPA, (size_t)&trapsize); - bcopy(&vectrap, (void *)EXC_VEC, (size_t)&vectrapsize); + bcopy(&trapcode, (void *)EXC_VEC, (size_t)&trapsize); bcopy(&trapcode, (void *)EXC_VECAST, (size_t)&trapsize); bcopy(&trapcode, (void *)EXC_THRM, (size_t)&trapsize); bcopy(&trapcode, (void *)EXC_BPT, (size_t)&trapsize); @@ -652,7 +652,21 @@ grab_mcontext(struct thread *td, mcontex memcpy(mcp->mc_fpreg, pcb->pcb_fpu.fpr, 32*sizeof(double)); } - /* XXX Altivec context ? */ + /* + * Repeat for Altivec context + */ + + if (pcb->pcb_flags & PCB_VEC) { + KASSERT(td == curthread, + ("get_mcontext: fp save not curthread")); + critical_enter(); + save_vec(td); + critical_exit(); + mcp->mc_flags |= _MC_AV_VALID; + mcp->mc_vscr = pcb->pcb_vec.vscr; + mcp->mc_vrsave = pcb->pcb_vec.vrsave; + memcpy(mcp->mc_avec, pcb->pcb_vec.vr, sizeof(mcp->mc_avec)); + } mcp->mc_len = sizeof(*mcp); @@ -706,7 +720,17 @@ set_mcontext(struct thread *td, const mc memcpy(pcb->pcb_fpu.fpr, mcp->mc_fpreg, 32*sizeof(double)); } - /* XXX Altivec context? */ + if (mcp->mc_flags & _MC_AV_VALID) { + if ((pcb->pcb_flags & PCB_VEC) != PCB_VEC) { + critical_enter(); + enable_vec(td); + critical_exit(); + } + pcb->pcb_vec.vscr = mcp->mc_vscr; + pcb->pcb_vec.vrsave = mcp->mc_vrsave; + memcpy(pcb->pcb_vec.vr, mcp->mc_avec, sizeof(mcp->mc_avec)); + } + return (0); } Modified: stable/7/sys/powerpc/powerpc/swtch.S ============================================================================== --- stable/7/sys/powerpc/powerpc/swtch.S Sat Mar 7 19:54:30 2009 (r189497) +++ stable/7/sys/powerpc/powerpc/swtch.S Sat Mar 7 20:39:42 2009 (r189498) @@ -94,8 +94,16 @@ ENTRY(cpu_switch) andi. %r6, %r6, PCB_FPU beq .L1 bl save_fpu - mr %r3,%r14 /* restore old thread ptr */ + .L1: + lwz %r6,PCB_FLAGS(%r5) + /* Save Altivec context if needed */ + andi. %r6, %r6, PCB_VEC + beq .L2 + bl save_vec + +.L2: + mr %r3,%r14 /* restore old thread ptr */ bl pmap_deactivate /* Deactivate the current pmap */ mr %r3,%r15 /* Get new thread ptr */ @@ -108,12 +116,20 @@ ENTRY(cpu_switch) lwz %r6, PCB_FLAGS(%r17) /* Restore FPU context if needed */ andi. %r6, %r6, PCB_FPU - beq .L2 + beq .L3 mr %r3,%r15 /* Pass curthread to enable_fpu */ bl enable_fpu +.L3: + lwz %r6, PCB_FLAGS(%r17) + /* Restore Altivec context if needed */ + andi. %r6, %r6, PCB_VEC + beq .L4 + mr %r3,%r15 /* Pass curthread to enable_vec */ + bl enable_vec + /* thread to restore is in r3 */ -.L2: +.L4: mr %r3,%r17 /* Recover PCB ptr */ lmw %r12,PCB_CONTEXT(%r3) /* Load the non-volatile GP regs */ mr %r2,%r12 Modified: stable/7/sys/powerpc/powerpc/trap.c ============================================================================== --- stable/7/sys/powerpc/powerpc/trap.c Sat Mar 7 19:54:30 2009 (r189497) +++ stable/7/sys/powerpc/powerpc/trap.c Sat Mar 7 20:39:42 2009 (r189498) @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -188,24 +189,16 @@ trap(struct trapframe *frame) enable_fpu(td); break; -#ifdef ALTIVEC case EXC_VEC: - if ((vecthread = PCPU_GET(vecthread)) != NULL) { - KASSERT(vecthread != td, - ("altivec already enabled")); - save_vec(vecthread); - } - PCPU_SET(vecthread, td); - td->td_pcb->pcb_veccpu = PCPU_GET(cpuid); + KASSERT((td->td_pcb->pcb_flags & PCB_VEC) != PCB_VEC, + ("Altivec already enabled for thread")); enable_vec(td); - frame->srr1 |= PSL_VEC; break; -#else - case EXC_VEC: + case EXC_VECAST: + printf("Vector assist exception!\n"); sig = SIGILL; break; -#endif /* ALTIVEC */ case EXC_ALI: if (fix_unaligned(td, frame) != 0) Modified: stable/7/sys/powerpc/powerpc/trap_subr.S ============================================================================== --- stable/7/sys/powerpc/powerpc/trap_subr.S Sat Mar 7 19:54:30 2009 (r189497) +++ stable/7/sys/powerpc/powerpc/trap_subr.S Sat Mar 7 20:39:42 2009 (r189498) @@ -79,13 +79,13 @@ /* * FRAME_SETUP assumes: * SPRG1 SP (1) + * SPRG3 trap type * savearea r28-r31,DAR,DSISR (DAR & DSISR only for DSI traps) * r28 LR * r29 CR * r30 scratch * r31 scratch * r1 kernel stack - * LR trap type (from calling address, mask with 0xff00) * SRR0/1 as at start of trap */ #define FRAME_SETUP(savearea) \ @@ -146,8 +146,7 @@ lwz %r31,(savearea+CPUSAVE_SRR1)(%r2); /* saved SRR1 */ \ mfxer %r3; \ mfctr %r4; \ - mflr %r5; \ - andi. %r5,%r5,0xff00; /* convert LR to exc # */ \ + mfsprg3 %r5; \ stw %r3, FRAME_XER+8(1); /* save xer/ctr/exc */ \ stw %r4, FRAME_CTR+8(1); \ stw %r5, FRAME_EXC+8(1); \ @@ -245,18 +244,10 @@ GLOBAL(dbstk) .globl CNAME(trapcode),CNAME(trapsize) CNAME(trapcode): mtsprg1 %r1 /* save SP */ - GET_CPUINFO(%r1) - stw %r28,(PC_TEMPSAVE+CPUSAVE_R28)(%r1) /* free r28-r31 */ - stw %r29,(PC_TEMPSAVE+CPUSAVE_R29)(%r1) - stw %r30,(PC_TEMPSAVE+CPUSAVE_R30)(%r1) - stw %r31,(PC_TEMPSAVE+CPUSAVE_R31)(%r1) - mfsprg1 %r1 /* restore SP, in case of branch */ - mflr %r28 /* save LR */ - mfcr %r29 /* save CR */ -/* Test whether we already had PR set */ - mfsrr1 %r31 - mtcr %r31 - bla s_trap /* LR & 0xff00 is exception # */ + mflr %r1 /* Save the old LR in r1 */ + mtsprg2 %r1 /* And then in SPRG2 */ + li %r1, 0x20 /* How to get the vector from LR */ + bla generictrap /* LR & SPRG3 is exception # */ CNAME(trapsize) = .-CNAME(trapcode) /* @@ -277,10 +268,15 @@ CNAME(alitrap): mfsprg1 %r1 /* restore SP, in case of branch */ mflr %r28 /* save LR */ mfcr %r29 /* save CR */ -/* Test whether we already had PR set */ + + /* Put our exception vector in SPRG3 */ + li %r31, EXC_ALI + mtsprg3 %r31 + + /* Test whether we already had PR set */ mfsrr1 %r31 mtcr %r31 - bla s_trap /* LR & 0xff00 is exception # */ + bla s_trap CNAME(alisize) = .-CNAME(alitrap) /* @@ -345,6 +341,11 @@ CNAME(dsisize) = .-CNAME(dsitrap) * Preamble code for DSI/ISI traps */ disitrap: + /* Write the trap vector to SPRG3 by computing LR & 0xff00 */ + mflr %r1 + andi. %r1,%r1,0xff00 + mtsprg3 %r1 + GET_CPUINFO(%r1) lwz %r30,(PC_DISISAVE+CPUSAVE_R28)(%r1) stw %r30,(PC_TEMPSAVE+CPUSAVE_R28)(%r1) @@ -397,6 +398,47 @@ realtrap: mtcr %r1 mfsprg1 %r1 /* restore SP (might have been overwritten) */ + bf 17,k_trap /* branch if PSL_PR is false */ + GET_CPUINFO(%r1) + lwz %r1,PC_CURPCB(%r1) + RESTORE_KERN_SRS(%r30,%r31) /* enable kernel mapping */ + ba s_trap + +/* + * generictrap does some standard setup for trap handling to minimize + * the code that need be installed in the actual vectors. It expects + * the following conditions. + * + * R1 - Trap vector = LR & (0xff00 | R1) + * SPRG1 - Original R1 contents + * SPRG2 - Original LR + */ + +generictrap: + /* Save R1 for computing the exception vector */ + mtsprg3 %r1 + + /* Save interesting registers */ + GET_CPUINFO(%r1) + stw %r28,(PC_TEMPSAVE+CPUSAVE_R28)(%r1) /* free r28-r31 */ + stw %r29,(PC_TEMPSAVE+CPUSAVE_R29)(%r1) + stw %r30,(PC_TEMPSAVE+CPUSAVE_R30)(%r1) + stw %r31,(PC_TEMPSAVE+CPUSAVE_R31)(%r1) + mfsprg1 %r1 /* restore SP, in case of branch */ + mfsprg2 %r28 /* save LR */ + mfcr %r29 /* save CR */ + + /* Compute the exception vector from the link register */ + mfsprg3 %r31 + ori %r31,%r31,0xff00 + mflr %r30 + and %r30,%r30,%r31 + mtsprg3 %r30 + + /* Test whether we already had PR set */ + mfsrr1 %r31 + mtcr %r31 + s_trap: bf 17,k_trap /* branch if PSL_PR is false */ GET_CPUINFO(%r1) @@ -445,14 +487,6 @@ CNAME(asttrapexit): FRAME_LEAVE(PC_TEMPSAVE) rfi -/* - * Temporary: vector-unavailable traps are directed to vector-assist traps - */ - .globl CNAME(vectrap),CNAME(vectrapsize) -CNAME(vectrap): - ba EXC_VECAST -CNAME(vectrapsize) = .-CNAME(vectrap) - #if defined(KDB) /* * Deliberate entry to dbtrap @@ -480,6 +514,14 @@ CNAME(ppc_db_trap): * Now the kdb trap catching code. */ dbtrap: + /* Write the trap vector to SPRG3 by computing LR & 0xff00 */ + mflr %r1 + andi. %r1,%r1,0xff00 + mtsprg3 %r1 + + lis %r1,(tmpstk+TMPSTKSZ-16)@ha /* get new SP */ + addi %r1,%r1,(tmpstk+TMPSTKSZ-16)@l + FRAME_SETUP(PC_DBSAVE) /* Call C trap code: */ addi %r3,%r1,8 @@ -517,16 +559,19 @@ CNAME(dblow): mfcr %r29 /* save CR in r29 */ mfsrr1 %r1 mtcr %r1 - GET_CPUINFO(%r1) bf 17,1f /* branch if privileged */ - stw %r28,(PC_TEMPSAVE+CPUSAVE_R28)(%r1) /* free r28 */ - mfsprg2 %r28 /* r29 holds cr ... */ - stw %r28,(PC_TEMPSAVE+CPUSAVE_R29)(%r1) /* free r29 */ - stw %r30,(PC_TEMPSAVE+CPUSAVE_R30)(%r1) /* free r30 */ - stw %r31,(PC_TEMPSAVE+CPUSAVE_R31)(%r1) /* free r31 */ - mflr %r28 /* save LR */ - bla u_trap + + /* Unprivileged case */ + mtcr %r29 /* put the condition register back */ + mfsprg2 %r29 /* ... and r29 */ + mflr %r1 /* save LR */ + mtsprg2 %r1 /* And then in SPRG2 */ + li %r1, 0 /* How to get the vector from LR */ + + bla generictrap /* and we look like a generic trap */ 1: + /* Privileged, so drop to KDB */ + GET_CPUINFO(%r1) stw %r28,(PC_DBSAVE+CPUSAVE_R28)(%r1) /* free r28 */ mfsprg2 %r28 /* r29 holds cr... */ stw %r28,(PC_DBSAVE+CPUSAVE_R29)(%r1) /* free r29 */ From luigi at FreeBSD.org Sat Mar 7 16:11:30 2009 From: luigi at FreeBSD.org (Luigi Rizzo) Date: Sat Mar 7 16:11:42 2009 Subject: svn commit: r189502 - stable/7/sys/kern Message-ID: <200903080011.n280BQfQ066371@svn.freebsd.org> Author: luigi Date: Sun Mar 8 00:11:26 2009 New Revision: 189502 URL: http://svn.freebsd.org/changeset/base/189502 Log: MFC rev.188571 Clarify and reimplement the bioq API so that bioq_disksort() has the correct behaviour (sorting by distance from the current head position in the scan direction) and bioq_insert_head() and bioq_insert_tail() have a well defined (and useful) behaviour, especially when intermixed with calls to bioq_disksort(). See the original commit log for more details. NO API/ABI changes (except from fixing bugs and defining unspecified behaviour that no code should rely on). Modified: stable/7/sys/kern/subr_disk.c Modified: stable/7/sys/kern/subr_disk.c ============================================================================== --- stable/7/sys/kern/subr_disk.c Sat Mar 7 22:17:44 2009 (r189501) +++ stable/7/sys/kern/subr_disk.c Sun Mar 8 00:11:26 2009 (r189502) @@ -5,6 +5,10 @@ * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- + * + * The bioq_disksort() (and the specification of the bioq API) + * have been written by Luigi Rizzo and Fabio Checconi under the same + * license as above. */ #include @@ -63,11 +67,86 @@ disk_err(struct bio *bp, const char *wha /* * BIO queue implementation + * + * Please read carefully the description below before making any change + * to the code, or you might change the behaviour of the data structure + * in undesirable ways. + * + * A bioq stores disk I/O request (bio), normally sorted according to + * the distance of the requested position (bio->bio_offset) from the + * current head position (bioq->last_offset) in the scan direction, i.e. + * + * (uoff_t)(bio_offset - last_offset) + * + * Note that the cast to unsigned (uoff_t) is fundamental to insure + * that the distance is computed in the scan direction. + * + * The main methods for manipulating the bioq are: + * + * bioq_disksort() performs an ordered insertion; + * + * bioq_first() return the head of the queue, without removing; + * + * bioq_takefirst() return and remove the head of the queue, + * updating the 'current head position' as + * bioq->last_offset = bio->bio_offset + bio->bio_length; + * + * When updating the 'current head position', we assume that the result of + * bioq_takefirst() is dispatched to the device, so bioq->last_offset + * represents the head position once the request is complete. + * + * If the bioq is manipulated using only the above calls, it starts + * with a sorted sequence of requests with bio_offset >= last_offset, + * possibly followed by another sorted sequence of requests with + * 0 <= bio_offset < bioq->last_offset + * + * NOTE: historical behaviour was to ignore bio->bio_length in the + * update, but its use tracks the head position in a better way. + * Historical behaviour was also to update the head position when + * the request under service is complete, rather than when the + * request is extracted from the queue. However, the current API + * has no method to update the head position; secondly, once + * a request has been submitted to the disk, we have no idea of + * the actual head position, so the final one is our best guess. + * + * --- Direct queue manipulation --- + * + * A bioq uses an underlying TAILQ to store requests, so we also + * export methods to manipulate the TAILQ, in particular: + * + * bioq_insert_tail() insert an entry at the end. + * It also creates a 'barrier' so all subsequent + * insertions through bioq_disksort() will end up + * after this entry; + * + * bioq_insert_head() insert an entry at the head, update + * bioq->last_offset = bio->bio_offset so that + * all subsequent insertions through bioq_disksort() + * will end up after this entry; + * + * bioq_remove() remove a generic element from the queue, act as + * bioq_takefirst() if invoked on the head of the queue. + * + * The semantic of these methods is the same of the operations + * on the underlying TAILQ, but with additional guarantees on + * subsequent bioq_disksort() calls. E.g. bioq_insert_tail() + * can be useful for making sure that all previous ops are flushed + * to disk before continuing. + * + * Updating bioq->last_offset on a bioq_insert_head() guarantees + * that the bio inserted with the last bioq_insert_head() will stay + * at the head of the queue even after subsequent bioq_disksort(). + * + * Note that when the direct queue manipulation functions are used, + * the queue may contain multiple inversion points (i.e. more than + * two sorted sequences of requests). + * */ void bioq_init(struct bio_queue_head *head) { + TAILQ_INIT(&head->queue); head->last_offset = 0; head->insert_point = NULL; @@ -76,14 +155,13 @@ bioq_init(struct bio_queue_head *head) void bioq_remove(struct bio_queue_head *head, struct bio *bp) { - if (bp == head->insert_point) { - head->last_offset = bp->bio_offset; - head->insert_point = TAILQ_NEXT(bp, bio_queue); - if (head->insert_point == NULL) { - head->last_offset = 0; - head->insert_point = TAILQ_FIRST(&head->queue); - } - } + + if (bp == TAILQ_FIRST(&head->queue)) + head->last_offset = bp->bio_offset + bp->bio_length; + + if (bp == head->insert_point) + head->insert_point = NULL; + TAILQ_REMOVE(&head->queue, bp, bio_queue); } @@ -100,8 +178,7 @@ void bioq_insert_head(struct bio_queue_head *head, struct bio *bp) { - if (TAILQ_EMPTY(&head->queue)) - head->insert_point = bp; + head->last_offset = bp->bio_offset; TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue); } @@ -109,9 +186,8 @@ void bioq_insert_tail(struct bio_queue_head *head, struct bio *bp) { - if (TAILQ_EMPTY(&head->queue)) - head->insert_point = bp; TAILQ_INSERT_TAIL(&head->queue, bp, bio_queue); + head->insert_point = bp; } struct bio * @@ -133,65 +209,42 @@ bioq_takefirst(struct bio_queue_head *he } /* + * Compute the sorting key. The cast to unsigned is + * fundamental for correctness, see the description + * near the beginning of the file. + */ +static inline uoff_t +bioq_bio_key(struct bio_queue_head *head, struct bio *bp) +{ + + return ((uoff_t)(bp->bio_offset - head->last_offset)); +} + +/* * Seek sort for disks. * - * The disksort algorithm sorts all requests in a single queue while keeping - * track of the current position of the disk with insert_point and - * last_offset. last_offset is the offset of the last block sent to disk, or - * 0 once we reach the end. insert_point points to the first buf after - * last_offset, and is used to slightly speed up insertions. Blocks are - * always sorted in ascending order and the queue always restarts at 0. - * This implements the one-way scan which optimizes disk seek times. + * Sort all requests in a single queue while keeping + * track of the current position of the disk with last_offset. + * See above for details. */ void -bioq_disksort(bioq, bp) - struct bio_queue_head *bioq; - struct bio *bp; +bioq_disksort(struct bio_queue_head *head, struct bio *bp) { - struct bio *bq; - struct bio *bn; + struct bio *cur, *prev = NULL; + uoff_t key = bioq_bio_key(head, bp); - /* - * If the queue is empty then it's easy. - */ - if (bioq_first(bioq) == NULL) { - bioq_insert_tail(bioq, bp); - return; - } - /* - * Optimize for sequential I/O by seeing if we go at the tail. - */ - bq = TAILQ_LAST(&bioq->queue, bio_queue); - if (bp->bio_offset > bq->bio_offset) { - TAILQ_INSERT_AFTER(&bioq->queue, bq, bp, bio_queue); - return; - } - /* - * Pick our scan start based on the last request. A poor man's - * binary search. - */ - if (bp->bio_offset >= bioq->last_offset) { - bq = bioq->insert_point; - /* - * If we're before the next bio and after the last offset, - * update insert_point; - */ - if (bp->bio_offset < bq->bio_offset) { - bioq->insert_point = bp; - TAILQ_INSERT_BEFORE(bq, bp, bio_queue); - return; - } - } else - bq = TAILQ_FIRST(&bioq->queue); - if (bp->bio_offset < bq->bio_offset) { - TAILQ_INSERT_BEFORE(bq, bp, bio_queue); - return; - } - /* Insertion sort */ - while ((bn = TAILQ_NEXT(bq, bio_queue)) != NULL) { - if (bp->bio_offset < bn->bio_offset) - break; - bq = bn; + cur = TAILQ_FIRST(&head->queue); + + if (head->insert_point) + cur = head->insert_point; + + while (cur != NULL && key >= bioq_bio_key(head, cur)) { + prev = cur; + cur = TAILQ_NEXT(cur, bio_queue); } - TAILQ_INSERT_AFTER(&bioq->queue, bq, bp, bio_queue); + + if (prev == NULL) + TAILQ_INSERT_HEAD(&head->queue, bp, bio_queue); + else + TAILQ_INSERT_AFTER(&head->queue, prev, bp, bio_queue); } From dchagin at FreeBSD.org Sun Mar 8 04:12:24 2009 From: dchagin at FreeBSD.org (Dmitry Chagin) Date: Sun Mar 8 04:12:36 2009 Subject: svn commit: r189530 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern Message-ID: <200903081112.n28BCNTP081886@svn.freebsd.org> Author: dchagin Date: Sun Mar 8 11:12:23 2009 New Revision: 189530 URL: http://svn.freebsd.org/changeset/base/189530 Log: MFC r189232, r189313: Fix range-check error introduced in r182292. Panic in case the ncpus == 0. it helps to catch bugs in the callers. Approved by: kib (mentor) Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/subr_smp.c Modified: stable/7/sys/kern/subr_smp.c ============================================================================== --- stable/7/sys/kern/subr_smp.c Sun Mar 8 10:58:37 2009 (r189529) +++ stable/7/sys/kern/subr_smp.c Sun Mar 8 11:12:23 2009 (r189530) @@ -358,9 +358,11 @@ smp_rendezvous_cpus(cpumask_t map, return; } - for (i = 0; i < mp_maxid; i++) + for (i = 0; i <= mp_maxid; i++) if (((1 << i) & map) != 0 && !CPU_ABSENT(i)) ncpus++; + if (ncpus == 0) + panic("ncpus is 0 with map=0x%x", map); /* obtain rendezvous lock */ mtx_lock_spin(&smp_ipi_mtx); From rwatson at FreeBSD.org Sun Mar 8 04:20:55 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Mar 8 04:21:12 2009 Subject: svn commit: r189531 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb net Message-ID: <200903081120.n28BKsjh082112@svn.freebsd.org> Author: rwatson Date: Sun Mar 8 11:20:54 2009 New Revision: 189531 URL: http://svn.freebsd.org/changeset/base/189531 Log: Merge missed routing lock fix r186061 from head to stable/7: Dont leak the rnh lock on error. Original change was from thompsa. This may correct routing-related panics seen by uses of ppp, including the following PRs: PR: 132215, 132222, 132404 Reported by: Ethan Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/net/rtsock.c Modified: stable/7/sys/net/rtsock.c ============================================================================== --- stable/7/sys/net/rtsock.c Sun Mar 8 11:12:23 2009 (r189530) +++ stable/7/sys/net/rtsock.c Sun Mar 8 11:20:54 2009 (r189531) @@ -629,10 +629,10 @@ route_output(struct mbuf *m, struct sock rt->rt_ifa->ifa_addr))) { RT_UNLOCK(rt); RADIX_NODE_HEAD_LOCK(rnh); - if ((error = rt_getifa_fib(&info, - rt->rt_fibnum)) != 0) - senderr(error); + error = rt_getifa_fib(&info, rt->rt_fibnum); RADIX_NODE_HEAD_UNLOCK(rnh); + if (error != 0) + senderr(error); RT_LOCK(rt); } if (info.rti_ifa != NULL && From nwhitehorn at FreeBSD.org Sun Mar 8 09:19:30 2009 From: nwhitehorn at FreeBSD.org (Nathan Whitehorn) Date: Sun Mar 8 09:19:42 2009 Subject: svn commit: r189536 - stable/7/sys/powerpc/powerpc Message-ID: <200903081619.n28GJTxT087550@svn.freebsd.org> Author: nwhitehorn Date: Sun Mar 8 16:19:29 2009 New Revision: 189536 URL: http://svn.freebsd.org/changeset/base/189536 Log: Fix a mismerge from head that I somehow missed last night. This caused builds with KDB enabled to fail. Pointy hat to: me Modified: stable/7/sys/powerpc/powerpc/trap_subr.S Modified: stable/7/sys/powerpc/powerpc/trap_subr.S ============================================================================== --- stable/7/sys/powerpc/powerpc/trap_subr.S Sun Mar 8 16:16:55 2009 (r189535) +++ stable/7/sys/powerpc/powerpc/trap_subr.S Sun Mar 8 16:19:29 2009 (r189536) @@ -515,12 +515,9 @@ CNAME(ppc_db_trap): */ dbtrap: /* Write the trap vector to SPRG3 by computing LR & 0xff00 */ - mflr %r1 - andi. %r1,%r1,0xff00 - mtsprg3 %r1 - - lis %r1,(tmpstk+TMPSTKSZ-16)@ha /* get new SP */ - addi %r1,%r1,(tmpstk+TMPSTKSZ-16)@l + mflr %r31 + andi. %r31,%r31,0xff00 + mtsprg3 %r31 FRAME_SETUP(PC_DBSAVE) /* Call C trap code: */ From rnoland at FreeBSD.org Mon Mar 9 01:18:41 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Mar 9 01:18:53 2009 Subject: svn commit: r189568 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/pci Message-ID: <200903090818.n298Ie9S014684@svn.freebsd.org> Author: rnoland Date: Mon Mar 9 08:18:40 2009 New Revision: 189568 URL: http://svn.freebsd.org/changeset/base/189568 Log: Merge r189285 Disable INTx when enabling MSI/MSIX This addresses interrupt storms that were noticed after enabling MSI in drm. I think this is due to a loose interpretation of the PCI 2.3 spec, which states that a function using MSI is prohibitted from using INTx. It appears that some vendors interpretted that to mean that they should handle it in hardware, while others felt it was the drivers responsibility. This fix will also likely resolve interrupt storm related issues with devices other than drm. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/pci/pci.c stable/7/sys/dev/pci/pcireg.h Modified: stable/7/sys/dev/pci/pci.c ============================================================================== --- stable/7/sys/dev/pci/pci.c Mon Mar 9 08:17:46 2009 (r189567) +++ stable/7/sys/dev/pci/pci.c Mon Mar 9 08:18:40 2009 (r189568) @@ -2845,6 +2845,8 @@ pci_setup_intr(device_t dev, device_t ch } mte->mte_handlers++; } + /* Disable INTx if we are using MSI/MSIX */ + pci_set_command_bit(dev, child, PCIM_CMD_INTxDIS); bad: if (error) { (void)bus_generic_teardown_intr(dev, child, irq, @@ -2899,6 +2901,8 @@ pci_teardown_intr(device_t dev, device_t if (mte->mte_handlers == 0) pci_mask_msix(child, rid - 1); } + /* Restore INTx capability for MSI/MSIX */ + pci_clear_command_bit(dev, child, PCIM_CMD_INTxDIS); } error = bus_generic_teardown_intr(dev, child, irq, cookie); if (device_get_parent(child) == dev && rid > 0) Modified: stable/7/sys/dev/pci/pcireg.h ============================================================================== --- stable/7/sys/dev/pci/pcireg.h Mon Mar 9 08:17:46 2009 (r189567) +++ stable/7/sys/dev/pci/pcireg.h Mon Mar 9 08:18:40 2009 (r189568) @@ -60,6 +60,7 @@ #define PCIM_CMD_PERRESPEN 0x0040 #define PCIM_CMD_SERRESPEN 0x0100 #define PCIM_CMD_BACKTOBACK 0x0200 +#define PCIM_CMD_INTxDIS 0x0400 #define PCIR_STATUS 0x06 #define PCIM_STATUS_CAPPRESENT 0x0010 #define PCIM_STATUS_66CAPABLE 0x0020 From rnoland at FreeBSD.org Mon Mar 9 01:25:06 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Mar 9 01:25:18 2009 Subject: svn commit: r189569 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/pci Message-ID: <200903090825.n298P5RU014944@svn.freebsd.org> Author: rnoland Date: Mon Mar 9 08:25:05 2009 New Revision: 189569 URL: http://svn.freebsd.org/changeset/base/189569 Log: Merge r189367,189447 Extend the management of PCIM_CMD_INTxDIS. We now explicitly enable INTx during bus_setup_intr() if it is needed. Several of the ata drivers were managing this bit internally. This is better handled in pci and it should work for all drivers now. We also mask INTx during bus_teardown_intr() by setting this bit. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/pci/pci.c Modified: stable/7/sys/dev/pci/pci.c ============================================================================== --- stable/7/sys/dev/pci/pci.c Mon Mar 9 08:18:40 2009 (r189568) +++ stable/7/sys/dev/pci/pci.c Mon Mar 9 08:25:05 2009 (r189569) @@ -2796,14 +2796,24 @@ pci_setup_intr(device_t dev, device_t ch if (error) return (error); - /* - * If this is a direct child, check to see if the interrupt is - * MSI or MSI-X. If so, ask our parent to map the MSI and give - * us the address and data register values. If we fail for some - * reason, teardown the interrupt handler. - */ + /* If this is not a direct child, just bail out. */ + if (device_get_parent(child) != dev) { + *cookiep = cookie; + return(0); + } + rid = rman_get_rid(irq); - if (device_get_parent(child) == dev && rid > 0) { + if (rid == 0) { + /* Make sure that INTx is enabled */ + pci_clear_command_bit(dev, child, PCIM_CMD_INTxDIS); + } else { + /* + * Check to see if the interrupt is MSI or MSI-X. + * Ask our parent to map the MSI and give + * us the address and data register values. + * If we fail for some reason, teardown the + * interrupt handler. + */ dinfo = device_get_ivars(child); if (dinfo->cfg.msi.msi_alloc > 0) { if (dinfo->cfg.msi.msi_addr == 0) { @@ -2845,7 +2855,8 @@ pci_setup_intr(device_t dev, device_t ch } mte->mte_handlers++; } - /* Disable INTx if we are using MSI/MSIX */ + + /* Make sure that INTx is disabled if we are using MSI/MSIX */ pci_set_command_bit(dev, child, PCIM_CMD_INTxDIS); bad: if (error) { @@ -2867,16 +2878,24 @@ pci_teardown_intr(device_t dev, device_t struct pci_devinfo *dinfo; int error, rid; - /* - * If this is a direct child, check to see if the interrupt is - * MSI or MSI-X. If so, decrement the appropriate handlers - * count and mask the MSI-X message, or disable MSI messages - * if the count drops to 0. - */ if (irq == NULL || !(rman_get_flags(irq) & RF_ACTIVE)) return (EINVAL); + + /* If this isn't a direct child, just bail out */ + if (device_get_parent(child) != dev) + return(bus_generic_teardown_intr(dev, child, irq, cookie)); + rid = rman_get_rid(irq); - if (device_get_parent(child) == dev && rid > 0) { + if (rid == 0) { + /* Mask INTx */ + pci_set_command_bit(dev, child, PCIM_CMD_INTxDIS); + } else { + /* + * Check to see if the interrupt is MSI or MSI-X. If so, + * decrement the appropriate handlers count and mask the + * MSI-X message, or disable MSI messages if the count + * drops to 0. + */ dinfo = device_get_ivars(child); rle = resource_list_find(&dinfo->resources, SYS_RES_IRQ, rid); if (rle->res != irq) @@ -2901,11 +2920,9 @@ pci_teardown_intr(device_t dev, device_t if (mte->mte_handlers == 0) pci_mask_msix(child, rid - 1); } - /* Restore INTx capability for MSI/MSIX */ - pci_clear_command_bit(dev, child, PCIM_CMD_INTxDIS); } error = bus_generic_teardown_intr(dev, child, irq, cookie); - if (device_get_parent(child) == dev && rid > 0) + if (rid > 0) KASSERT(error == 0, ("%s: generic teardown failed for MSI/MSI-X", __func__)); return (error); From brueffer at FreeBSD.org Mon Mar 9 07:04:19 2009 From: brueffer at FreeBSD.org (Christian Brueffer) Date: Mon Mar 9 07:04:30 2009 Subject: svn commit: r189582 - stable/7/share/man/man4 Message-ID: <200903091404.n29E4IVt028498@svn.freebsd.org> Author: brueffer Date: Mon Mar 9 14:04:18 2009 New Revision: 189582 URL: http://svn.freebsd.org/changeset/base/189582 Log: MFC: r189298 Xref glxsb(4). Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/crypto.4 stable/7/share/man/man4/igb.4 (props changed) Modified: stable/7/share/man/man4/crypto.4 ============================================================================== --- stable/7/share/man/man4/crypto.4 Mon Mar 9 13:32:19 2009 (r189581) +++ stable/7/share/man/man4/crypto.4 Mon Mar 9 14:04:18 2009 (r189582) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 1, 2007 +.Dd March 3, 2009 .Dt CRYPTO 4 .Os .Sh NAME @@ -105,6 +105,7 @@ asymmetric cryptographic features are po crypto access device .El .Sh SEE ALSO +.Xr glxsb 4 , .Xr hifn 4 , .Xr ipsec 4 , .Xr padlock 4 , From ru at FreeBSD.org Mon Mar 9 10:07:29 2009 From: ru at FreeBSD.org (Ruslan Ermilov) Date: Mon Mar 9 10:07:41 2009 Subject: svn commit: r189586 - stable/7/share/misc Message-ID: <200903091707.n29H7R4i032305@svn.freebsd.org> Author: ru Date: Mon Mar 9 17:07:27 2009 New Revision: 189586 URL: http://svn.freebsd.org/changeset/base/189586 Log: MFC: Spell 'Yugoslav' correctly. Modified: stable/7/share/misc/ (props changed) stable/7/share/misc/iso3166 Modified: stable/7/share/misc/iso3166 ============================================================================== --- stable/7/share/misc/iso3166 Mon Mar 9 17:05:31 2009 (r189585) +++ stable/7/share/misc/iso3166 Mon Mar 9 17:07:27 2009 (r189586) @@ -442,8 +442,8 @@ ZW ZWE 716 Zimbabwe # Previously covered by the entry ET # # Newsletter III-57, 1993-07-16 -# Macedonia, the former Yugolslav Republic of, -# Previously covered by the entry YU +# Macedonia, the former Yugoslav Republic of, +# Previously covered by the entry YU # # Newsletter III-58, 1993-07-16 # Afghanistan, changing information not included in this file From rnoland at FreeBSD.org Mon Mar 9 10:42:52 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Mar 9 10:43:22 2009 Subject: svn commit: r189591 - in stable/7/sys: . contrib/pf dev/ata dev/ath/ath_hal dev/cxgb Message-ID: <200903091742.n29HgYpS033208@svn.freebsd.org> Author: rnoland Date: Mon Mar 9 17:42:34 2009 New Revision: 189591 URL: http://svn.freebsd.org/changeset/base/189591 Log: Manual merge of r189368 due to different ata layout in stable. Remove the local management of INTx as this is now taken care of by pci. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ata/ata-chipset.c stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/ata/ata-chipset.c ============================================================================== --- stable/7/sys/dev/ata/ata-chipset.c Mon Mar 9 17:42:18 2009 (r189590) +++ stable/7/sys/dev/ata/ata-chipset.c Mon Mar 9 17:42:34 2009 (r189591) @@ -528,10 +528,6 @@ ata_ahci_chipinit(device_t dev) ctlr->allocate = ata_ahci_allocate; ctlr->setmode = ata_sata_setmode; - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); - /* announce we support the HW */ version = ATA_INL(ctlr->r_res2, ATA_AHCI_VS); device_printf(dev, @@ -1100,10 +1096,6 @@ ata_ali_chipinit(device_t dev) if ((ctlr->chip->chipid == ATA_ALI_5288) && (ata_ahci_chipinit(dev) != ENXIO)) return 0; - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); break; case ALINEW: @@ -1894,10 +1886,6 @@ ata_intel_chipinit(device_t dev) ctlr->setmode = ata_intel_sata_setmode; else ctlr->setmode = ata_sata_setmode; - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); } return 0; } @@ -2658,10 +2646,6 @@ ata_marvell_edma_chipinit(device_t dev) /* unmask host controller interrupts we want */ ATA_OUTL(ctlr->r_res1, 0x01d64, 0x000000ff/*HC0*/ | 0x0001fe00/*HC1*/ | /*(1<<19) | (1<<20) | (1<<21) |*/(1<<22) | (1<<24) | (0x7f << 25)); - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); return 0; } @@ -3201,11 +3185,6 @@ ata_nvidia_chipinit(device_t dev) /* enable device and PHY state change interrupts */ ATA_OUTB(ctlr->r_res2, offset + 1, 0xdd); } - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400,2); - } ctlr->setmode = ata_sata_setmode; } @@ -4604,10 +4583,6 @@ ata_sii_chipinit(device_t dev) ATA_OUTL(ctlr->r_res1, 0x0040, 0x80000000); DELAY(10000); ATA_OUTL(ctlr->r_res1, 0x0040, 0x0000000f); - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400, 2); break; case SIIMEMIO: @@ -5359,10 +5334,6 @@ ata_sis_chipinit(device_t dev) &ctlr->r_rid2, RF_ACTIVE))) { ctlr->allocate = ata_sis_allocate; ctlr->reset = ata_sis_reset; - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400,2); } ctlr->setmode = ata_sata_setmode; return 0; @@ -5551,10 +5522,6 @@ ata_via_chipinit(device_t dev) &ctlr->r_rid2, RF_ACTIVE))) { ctlr->allocate = ata_via_allocate; ctlr->reset = ata_via_reset; - - /* enable PCI interrupt */ - pci_write_config(dev, PCIR_COMMAND, - pci_read_config(dev, PCIR_COMMAND, 2) & ~0x0400,2); } if (ctlr->chip->cfg2 & VIABAR) { From jhb at FreeBSD.org Tue Mar 10 10:28:29 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Tue Mar 10 10:28:48 2009 Subject: svn commit: r189634 - in stable/7/sys: . compat/freebsd32 contrib/pf dev/cxgb i386/ibcs2 kern Message-ID: <200903101728.n2AHSNFH068714@svn.freebsd.org> Author: jhb Date: Tue Mar 10 17:28:23 2009 New Revision: 189634 URL: http://svn.freebsd.org/changeset/base/189634 Log: MFC: Push down Giant inside sysctl. Modified: stable/7/sys/ (props changed) stable/7/sys/compat/freebsd32/freebsd32_misc.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/i386/ibcs2/ibcs2_sysi86.c stable/7/sys/kern/kern_sysctl.c stable/7/sys/kern/kern_xxx.c Modified: stable/7/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/7/sys/compat/freebsd32/freebsd32_misc.c Tue Mar 10 17:19:45 2009 (r189633) +++ stable/7/sys/compat/freebsd32/freebsd32_misc.c Tue Mar 10 17:28:23 2009 (r189634) @@ -1966,7 +1966,6 @@ freebsd32_sysctl(struct thread *td, stru error = copyin(uap->name, name, uap->namelen * sizeof(int)); if (error) return (error); - mtx_lock(&Giant); if (uap->oldlenp) oldlen = fuword32(uap->oldlenp); else @@ -1975,12 +1974,10 @@ freebsd32_sysctl(struct thread *td, stru uap->old, &oldlen, 1, uap->new, uap->newlen, &j, SCTL_MASK32); if (error && error != ENOMEM) - goto done2; + return (error); if (uap->oldlenp) suword32(uap->oldlenp, j); -done2: - mtx_unlock(&Giant); - return (error); + return (0); } int Modified: stable/7/sys/i386/ibcs2/ibcs2_sysi86.c ============================================================================== --- stable/7/sys/i386/ibcs2/ibcs2_sysi86.c Tue Mar 10 17:19:45 2009 (r189633) +++ stable/7/sys/i386/ibcs2/ibcs2_sysi86.c Tue Mar 10 17:28:23 2009 (r189634) @@ -74,15 +74,11 @@ ibcs2_sysi86(struct thread *td, struct i case SETNAME: { /* set hostname given string w/ len <= 7 chars */ int name[2]; - int error; name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; - mtx_lock(&Giant); - error = userland_sysctl(td, name, 2, 0, 0, 0, - args->arg, 7, 0, 0); - mtx_unlock(&Giant); - return (error); + return (userland_sysctl(td, name, 2, 0, 0, 0, + args->arg, 7, 0, 0)); } case SI86_MEM: /* size of physical memory */ Modified: stable/7/sys/kern/kern_sysctl.c ============================================================================== --- stable/7/sys/kern/kern_sysctl.c Tue Mar 10 17:19:45 2009 (r189633) +++ stable/7/sys/kern/kern_sysctl.c Tue Mar 10 17:28:23 2009 (r189634) @@ -70,6 +70,7 @@ static struct sx sysctllock; #define SYSCTL_LOCK() sx_xlock(&sysctllock) #define SYSCTL_UNLOCK() sx_xunlock(&sysctllock) +#define SYSCTL_LOCK_ASSERT() sx_assert(&sysctllock, SX_XLOCKED) #define SYSCTL_INIT() sx_init(&sysctllock, "sysctl lock") static int sysctl_root(SYSCTL_HANDLER_ARGS); @@ -666,6 +667,8 @@ name2oid (char *name, int *oid, int *len struct sysctl_oid_list *lsp = &sysctl__children; char *p; + SYSCTL_LOCK_ASSERT(); + if (!*name) return (ENOENT); @@ -722,6 +725,8 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_AR int error, oid[CTL_MAXNAME], len; struct sysctl_oid *op = 0; + SYSCTL_LOCK_ASSERT(); + if (!req->newlen) return (ENOENT); if (req->newlen >= MAXPATHLEN) /* XXX arbitrary, undocumented */ @@ -1066,14 +1071,12 @@ kernel_sysctl(struct thread *td, int *na req.lock = REQ_LOCKED; SYSCTL_LOCK(); - error = sysctl_root(0, name, namelen, &req); + SYSCTL_UNLOCK(); if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); - SYSCTL_UNLOCK(); - if (error && error != ENOMEM) return (error); @@ -1098,6 +1101,11 @@ kernel_sysctlbyname(struct thread *td, c oid[1] = 3; /* name2oid */ oidlen = sizeof(oid); + /* + * XXX: Prone to a possible race condition between lookup and + * execution? Maybe put locking around it? + */ + error = kernel_sysctl(td, oid, 2, oid, &oidlen, (void *)name, strlen(name), &plen, flags); if (error) @@ -1250,6 +1258,8 @@ sysctl_root(SYSCTL_HANDLER_ARGS) struct sysctl_oid *oid; int error, indx, lvl; + SYSCTL_LOCK_ASSERT(); + error = sysctl_find_oid(arg1, arg2, &oid, &indx, req); if (error) return (error); @@ -1304,7 +1314,11 @@ sysctl_root(SYSCTL_HANDLER_ARGS) if (error != 0) return (error); #endif + + /* XXX: Handlers are not guaranteed to be Giant safe! */ + mtx_lock(&Giant); error = oid->oid_handler(oid, arg1, arg2, req); + mtx_unlock(&Giant); return (error); } @@ -1332,20 +1346,16 @@ __sysctl(struct thread *td, struct sysct if (error) return (error); - mtx_lock(&Giant); - error = userland_sysctl(td, name, uap->namelen, uap->old, uap->oldlenp, 0, uap->new, uap->newlen, &j, 0); if (error && error != ENOMEM) - goto done2; + return (error); if (uap->oldlenp) { int i = copyout(&j, uap->oldlenp, sizeof(j)); if (i) - error = i; + return (i); } -done2: - mtx_unlock(&Giant); return (error); } @@ -1405,11 +1415,11 @@ userland_sysctl(struct thread *td, int * uio_yield(); } + SYSCTL_UNLOCK(); + if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); - SYSCTL_UNLOCK(); - if (error && error != ENOMEM) return (error); @@ -1421,217 +1431,3 @@ userland_sysctl(struct thread *td, int * } return (error); } - -#ifdef COMPAT_43 -#include -#include - -#define KINFO_PROC (0<<8) -#define KINFO_RT (1<<8) -#define KINFO_VNODE (2<<8) -#define KINFO_FILE (3<<8) -#define KINFO_METER (4<<8) -#define KINFO_LOADAVG (5<<8) -#define KINFO_CLOCKRATE (6<<8) - -/* Non-standard BSDI extension - only present on their 4.3 net-2 releases */ -#define KINFO_BSDI_SYSINFO (101<<8) - -/* - * XXX this is bloat, but I hope it's better here than on the potentially - * limited kernel stack... -Peter - */ - -static struct { - int bsdi_machine; /* "i386" on BSD/386 */ -/* ^^^ this is an offset to the string, relative to the struct start */ - char *pad0; - long pad1; - long pad2; - long pad3; - u_long pad4; - u_long pad5; - u_long pad6; - - int bsdi_ostype; /* "BSD/386" on BSD/386 */ - int bsdi_osrelease; /* "1.1" on BSD/386 */ - long pad7; - long pad8; - char *pad9; - - long pad10; - long pad11; - int pad12; - long pad13; - quad_t pad14; - long pad15; - - struct timeval pad16; - /* we dont set this, because BSDI's uname used gethostname() instead */ - int bsdi_hostname; /* hostname on BSD/386 */ - - /* the actual string data is appended here */ - -} bsdi_si; - -/* - * this data is appended to the end of the bsdi_si structure during copyout. - * The "char *" offsets are relative to the base of the bsdi_si struct. - * This contains "FreeBSD\02.0-BUILT-nnnnnn\0i386\0", and these strings - * should not exceed the length of the buffer here... (or else!! :-) - */ -static char bsdi_strings[80]; /* It had better be less than this! */ - -#ifndef _SYS_SYSPROTO_H_ -struct getkerninfo_args { - int op; - char *where; - size_t *size; - int arg; -}; -#endif -int -ogetkerninfo(struct thread *td, struct getkerninfo_args *uap) -{ - int error, name[6]; - size_t size; - u_int needed = 0; - - mtx_lock(&Giant); - - switch (uap->op & 0xff00) { - - case KINFO_RT: - name[0] = CTL_NET; - name[1] = PF_ROUTE; - name[2] = 0; - name[3] = (uap->op & 0xff0000) >> 16; - name[4] = uap->op & 0xff; - name[5] = uap->arg; - error = userland_sysctl(td, name, 6, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_VNODE: - name[0] = CTL_KERN; - name[1] = KERN_VNODE; - error = userland_sysctl(td, name, 2, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_PROC: - name[0] = CTL_KERN; - name[1] = KERN_PROC; - name[2] = uap->op & 0xff; - name[3] = uap->arg; - error = userland_sysctl(td, name, 4, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_FILE: - name[0] = CTL_KERN; - name[1] = KERN_FILE; - error = userland_sysctl(td, name, 2, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_METER: - name[0] = CTL_VM; - name[1] = VM_TOTAL; - error = userland_sysctl(td, name, 2, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_LOADAVG: - name[0] = CTL_VM; - name[1] = VM_LOADAVG; - error = userland_sysctl(td, name, 2, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_CLOCKRATE: - name[0] = CTL_KERN; - name[1] = KERN_CLOCKRATE; - error = userland_sysctl(td, name, 2, uap->where, uap->size, - 0, 0, 0, &size, 0); - break; - - case KINFO_BSDI_SYSINFO: { - /* - * this is pretty crude, but it's just enough for uname() - * from BSDI's 1.x libc to work. - * - * *size gives the size of the buffer before the call, and - * the amount of data copied after a successful call. - * If successful, the return value is the amount of data - * available, which can be larger than *size. - * - * BSDI's 2.x product apparently fails with ENOMEM if *size - * is too small. - */ - - u_int left; - char *s; - - bzero((char *)&bsdi_si, sizeof(bsdi_si)); - bzero(bsdi_strings, sizeof(bsdi_strings)); - - s = bsdi_strings; - - bsdi_si.bsdi_ostype = (s - bsdi_strings) + sizeof(bsdi_si); - strcpy(s, ostype); - s += strlen(s) + 1; - - bsdi_si.bsdi_osrelease = (s - bsdi_strings) + sizeof(bsdi_si); - strcpy(s, osrelease); - s += strlen(s) + 1; - - bsdi_si.bsdi_machine = (s - bsdi_strings) + sizeof(bsdi_si); - strcpy(s, machine); - s += strlen(s) + 1; - - needed = sizeof(bsdi_si) + (s - bsdi_strings); - - if ((uap->where == NULL) || (uap->size == NULL)) { - /* process is asking how much buffer to supply.. */ - size = needed; - error = 0; - break; - } - - if ((error = copyin(uap->size, &size, sizeof(size))) != 0) - break; - - /* if too much buffer supplied, trim it down */ - if (size > needed) - size = needed; - - /* how much of the buffer is remaining */ - left = size; - - if ((error = copyout((char *)&bsdi_si, uap->where, left)) != 0) - break; - - /* is there any point in continuing? */ - if (left > sizeof(bsdi_si)) { - left -= sizeof(bsdi_si); - error = copyout(&bsdi_strings, - uap->where + sizeof(bsdi_si), left); - } - break; - } - - default: - error = EOPNOTSUPP; - break; - } - if (error == 0) { - td->td_retval[0] = needed ? needed : size; - if (uap->size) { - error = copyout(&size, uap->size, sizeof(size)); - } - } - mtx_unlock(&Giant); - return (error); -} -#endif /* COMPAT_43 */ Modified: stable/7/sys/kern/kern_xxx.c ============================================================================== --- stable/7/sys/kern/kern_xxx.c Tue Mar 10 17:19:45 2009 (r189633) +++ stable/7/sys/kern/kern_xxx.c Tue Mar 10 17:28:23 2009 (r189634) @@ -42,9 +42,11 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #if defined(COMPAT_43) @@ -61,16 +63,12 @@ ogethostname(td, uap) struct gethostname_args *uap; { int name[2]; - int error; size_t len = uap->len; name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; - mtx_lock(&Giant); - error = userland_sysctl(td, name, 2, uap->hostname, &len, - 1, 0, 0, 0, 0); - mtx_unlock(&Giant); - return(error); + return (userland_sysctl(td, name, 2, uap->hostname, &len, + 1, 0, 0, 0, 0)); } #ifndef _SYS_SYSPROTO_H_ @@ -86,15 +84,11 @@ osethostname(td, uap) register struct sethostname_args *uap; { int name[2]; - int error; name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; - mtx_lock(&Giant); - error = userland_sysctl(td, name, 2, 0, 0, 0, uap->hostname, - uap->len, 0, 0); - mtx_unlock(&Giant); - return (error); + return (userland_sysctl(td, name, 2, 0, 0, 0, uap->hostname, + uap->len, 0, 0)); } #ifndef _SYS_SYSPROTO_H_ @@ -145,6 +139,212 @@ oquota(td, uap) return (ENOSYS); } + +#define KINFO_PROC (0<<8) +#define KINFO_RT (1<<8) +#define KINFO_VNODE (2<<8) +#define KINFO_FILE (3<<8) +#define KINFO_METER (4<<8) +#define KINFO_LOADAVG (5<<8) +#define KINFO_CLOCKRATE (6<<8) + +/* Non-standard BSDI extension - only present on their 4.3 net-2 releases */ +#define KINFO_BSDI_SYSINFO (101<<8) + +/* + * XXX this is bloat, but I hope it's better here than on the potentially + * limited kernel stack... -Peter + */ + +static struct { + int bsdi_machine; /* "i386" on BSD/386 */ +/* ^^^ this is an offset to the string, relative to the struct start */ + char *pad0; + long pad1; + long pad2; + long pad3; + u_long pad4; + u_long pad5; + u_long pad6; + + int bsdi_ostype; /* "BSD/386" on BSD/386 */ + int bsdi_osrelease; /* "1.1" on BSD/386 */ + long pad7; + long pad8; + char *pad9; + + long pad10; + long pad11; + int pad12; + long pad13; + quad_t pad14; + long pad15; + + struct timeval pad16; + /* we dont set this, because BSDI's uname used gethostname() instead */ + int bsdi_hostname; /* hostname on BSD/386 */ + + /* the actual string data is appended here */ + +} bsdi_si; + +/* + * this data is appended to the end of the bsdi_si structure during copyout. + * The "char *" offsets are relative to the base of the bsdi_si struct. + * This contains "FreeBSD\02.0-BUILT-nnnnnn\0i386\0", and these strings + * should not exceed the length of the buffer here... (or else!! :-) + */ +static char bsdi_strings[80]; /* It had better be less than this! */ + +#ifndef _SYS_SYSPROTO_H_ +struct getkerninfo_args { + int op; + char *where; + size_t *size; + int arg; +}; +#endif +int +ogetkerninfo(struct thread *td, struct getkerninfo_args *uap) +{ + int error, name[6]; + size_t size; + u_int needed = 0; + + switch (uap->op & 0xff00) { + + case KINFO_RT: + name[0] = CTL_NET; + name[1] = PF_ROUTE; + name[2] = 0; + name[3] = (uap->op & 0xff0000) >> 16; + name[4] = uap->op & 0xff; + name[5] = uap->arg; + error = userland_sysctl(td, name, 6, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_VNODE: + name[0] = CTL_KERN; + name[1] = KERN_VNODE; + error = userland_sysctl(td, name, 2, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_PROC: + name[0] = CTL_KERN; + name[1] = KERN_PROC; + name[2] = uap->op & 0xff; + name[3] = uap->arg; + error = userland_sysctl(td, name, 4, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_FILE: + name[0] = CTL_KERN; + name[1] = KERN_FILE; + error = userland_sysctl(td, name, 2, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_METER: + name[0] = CTL_VM; + name[1] = VM_TOTAL; + error = userland_sysctl(td, name, 2, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_LOADAVG: + name[0] = CTL_VM; + name[1] = VM_LOADAVG; + error = userland_sysctl(td, name, 2, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_CLOCKRATE: + name[0] = CTL_KERN; + name[1] = KERN_CLOCKRATE; + error = userland_sysctl(td, name, 2, uap->where, uap->size, + 0, 0, 0, &size, 0); + break; + + case KINFO_BSDI_SYSINFO: { + /* + * this is pretty crude, but it's just enough for uname() + * from BSDI's 1.x libc to work. + * + * *size gives the size of the buffer before the call, and + * the amount of data copied after a successful call. + * If successful, the return value is the amount of data + * available, which can be larger than *size. + * + * BSDI's 2.x product apparently fails with ENOMEM if *size + * is too small. + */ + + u_int left; + char *s; + + bzero((char *)&bsdi_si, sizeof(bsdi_si)); + bzero(bsdi_strings, sizeof(bsdi_strings)); + + s = bsdi_strings; + + bsdi_si.bsdi_ostype = (s - bsdi_strings) + sizeof(bsdi_si); + strcpy(s, ostype); + s += strlen(s) + 1; + + bsdi_si.bsdi_osrelease = (s - bsdi_strings) + sizeof(bsdi_si); + strcpy(s, osrelease); + s += strlen(s) + 1; + + bsdi_si.bsdi_machine = (s - bsdi_strings) + sizeof(bsdi_si); + strcpy(s, machine); + s += strlen(s) + 1; + + needed = sizeof(bsdi_si) + (s - bsdi_strings); + + if ((uap->where == NULL) || (uap->size == NULL)) { + /* process is asking how much buffer to supply.. */ + size = needed; + error = 0; + break; + } + + if ((error = copyin(uap->size, &size, sizeof(size))) != 0) + break; + + /* if too much buffer supplied, trim it down */ + if (size > needed) + size = needed; + + /* how much of the buffer is remaining */ + left = size; + + if ((error = copyout((char *)&bsdi_si, uap->where, left)) != 0) + break; + + /* is there any point in continuing? */ + if (left > sizeof(bsdi_si)) { + left -= sizeof(bsdi_si); + error = copyout(&bsdi_strings, + uap->where + sizeof(bsdi_si), left); + } + break; + } + + default: + error = EOPNOTSUPP; + break; + } + if (error == 0) { + td->td_retval[0] = needed ? needed : size; + if (uap->size) { + error = copyout(&size, uap->size, sizeof(size)); + } + } + return (error); +} #endif /* COMPAT_43 */ /* @@ -173,11 +373,10 @@ uname(td, uap) name[0] = CTL_KERN; name[1] = KERN_OSTYPE; len = sizeof (uap->name->sysname); - mtx_lock(&Giant); error = userland_sysctl(td, name, 2, uap->name->sysname, &len, 1, 0, 0, 0, 0); if (error) - goto done2; + return (error); subyte( uap->name->sysname + sizeof(uap->name->sysname) - 1, 0); name[1] = KERN_HOSTNAME; @@ -185,7 +384,7 @@ uname(td, uap) error = userland_sysctl(td, name, 2, uap->name->nodename, &len, 1, 0, 0, 0, 0); if (error) - goto done2; + return (error); subyte( uap->name->nodename + sizeof(uap->name->nodename) - 1, 0); name[1] = KERN_OSRELEASE; @@ -193,7 +392,7 @@ uname(td, uap) error = userland_sysctl(td, name, 2, uap->name->release, &len, 1, 0, 0, 0, 0); if (error) - goto done2; + return (error); subyte( uap->name->release + sizeof(uap->name->release) - 1, 0); /* @@ -202,7 +401,7 @@ uname(td, uap) error = userland_sysctl(td, name, 2, uap->name->version, &len, 1, 0, 0, 0, 0); if (error) - goto done2; + return (error); subyte( uap->name->version + sizeof(uap->name->version) - 1, 0); */ @@ -214,11 +413,11 @@ uname(td, uap) for(us = uap->name->version; *s && *s != ':'; s++) { error = subyte( us++, *s); if (error) - goto done2; + return (error); } error = subyte( us++, 0); if (error) - goto done2; + return (error); name[0] = CTL_HW; name[1] = HW_MACHINE; @@ -226,11 +425,9 @@ uname(td, uap) error = userland_sysctl(td, name, 2, uap->name->machine, &len, 1, 0, 0, 0, 0); if (error) - goto done2; + return (error); subyte( uap->name->machine + sizeof(uap->name->machine) - 1, 0); -done2: - mtx_unlock(&Giant); - return (error); + return (0); } #ifndef _SYS_SYSPROTO_H_ From jhb at FreeBSD.org Tue Mar 10 11:16:10 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Tue Mar 10 11:16:45 2009 Subject: svn commit: r189638 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern sys Message-ID: <200903101816.n2AIG3b5069869@svn.freebsd.org> Author: jhb Date: Tue Mar 10 18:16:03 2009 New Revision: 189638 URL: http://svn.freebsd.org/changeset/base/189638 Log: MFC: Add sysctl_rename_oid() and use it in device_set_unit(). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/kern_sysctl.c stable/7/sys/kern/subr_bus.c stable/7/sys/sys/sysctl.h Modified: stable/7/sys/kern/kern_sysctl.c ============================================================================== --- stable/7/sys/kern/kern_sysctl.c Tue Mar 10 17:57:41 2009 (r189637) +++ stable/7/sys/kern/kern_sysctl.c Tue Mar 10 18:16:03 2009 (r189638) @@ -417,6 +417,25 @@ sysctl_add_oid(struct sysctl_ctx_list *c } /* + * Rename an existing oid. + */ +void +sysctl_rename_oid(struct sysctl_oid *oidp, const char *name) +{ + ssize_t len; + char *newname; + void *oldname; + + oldname = (void *)(uintptr_t)(const void *)oidp->oid_name; + len = strlen(name); + newname = malloc(len + 1, M_SYSCTLOID, M_WAITOK); + bcopy(name, newname, len + 1); + newname[len] = '\0'; + oidp->oid_name = newname; + free(oldname, M_SYSCTLOID); +} + +/* * Reparent an existing oid. */ int Modified: stable/7/sys/kern/subr_bus.c ============================================================================== --- stable/7/sys/kern/subr_bus.c Tue Mar 10 17:57:41 2009 (r189637) +++ stable/7/sys/kern/subr_bus.c Tue Mar 10 18:16:03 2009 (r189638) @@ -307,6 +307,16 @@ device_sysctl_init(device_t dev) } static void +device_sysctl_update(device_t dev) +{ + devclass_t dc = dev->devclass; + + if (dev->sysctl_tree == NULL) + return; + sysctl_rename_oid(dev->sysctl_tree, dev->nameunit + strlen(dc->name)); +} + +static void device_sysctl_fini(device_t dev) { if (dev->sysctl_tree == NULL) @@ -2396,6 +2406,7 @@ device_attach(device_t dev) dev->state = DS_NOTPRESENT; return (error); } + device_sysctl_update(dev); dev->state = DS_ATTACHED; devadded(dev); return (0); Modified: stable/7/sys/sys/sysctl.h ============================================================================== --- stable/7/sys/sys/sysctl.h Tue Mar 10 17:57:41 2009 (r189637) +++ stable/7/sys/sys/sysctl.h Tue Mar 10 18:16:03 2009 (r189638) @@ -661,6 +661,7 @@ struct sysctl_oid *sysctl_add_oid(struct int kind, void *arg1, int arg2, int (*handler) (SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr); +void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name); int sysctl_move_oid(struct sysctl_oid *oidp, struct sysctl_oid_list *parent); int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse); From jhb at FreeBSD.org Tue Mar 10 11:57:12 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Tue Mar 10 11:57:19 2009 Subject: svn commit: r189640 - in stable/7/sys: . cam/scsi contrib/pf dev/ath/ath_hal dev/cxgb ia64/ia64 ia64/include kern sys Message-ID: <200903101857.n2AIvBWr070786@svn.freebsd.org> Author: jhb Date: Tue Mar 10 18:57:10 2009 New Revision: 189640 URL: http://svn.freebsd.org/changeset/base/189640 Log: MFC: Expand the scope of the sysctllock sx lock to protect the sysctl tree itself. This also includes changes to the ia64 machine check code to defer adding machine check records to the sysctl tree, removing Giant from the CAM code that created dynamic sysctls, and tweaking the teardown of da(4) and cd(4) peripheral devices to not hold locks when freeing the sysctl tree. Modified: stable/7/sys/ (props changed) stable/7/sys/cam/scsi/scsi_cd.c stable/7/sys/cam/scsi/scsi_da.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ia64/ia64/mca.c stable/7/sys/ia64/include/mca.h stable/7/sys/kern/kern_linker.c stable/7/sys/kern/kern_sysctl.c stable/7/sys/kern/vfs_init.c stable/7/sys/sys/sysctl.h Modified: stable/7/sys/cam/scsi/scsi_cd.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_cd.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/cam/scsi/scsi_cd.c Tue Mar 10 18:57:10 2009 (r189640) @@ -401,11 +401,6 @@ cdcleanup(struct cam_periph *periph) xpt_print(periph->path, "removing device entry\n"); - if ((softc->flags & CD_FLAG_SCTX_INIT) != 0 - && sysctl_ctx_free(&softc->sysctl_ctx) != 0) { - xpt_print(periph->path, "can't remove sysctl context\n"); - } - /* * In the queued, non-active case, the device in question * has already been removed from the changer run queue. Since this @@ -474,9 +469,14 @@ cdcleanup(struct cam_periph *periph) free(softc->changer, M_DEVBUF); } cam_periph_unlock(periph); + if ((softc->flags & CD_FLAG_SCTX_INIT) != 0 + && sysctl_ctx_free(&softc->sysctl_ctx) != 0) { + xpt_print(periph->path, "can't remove sysctl context\n"); + } + disk_destroy(softc->disk); - cam_periph_lock(periph); free(softc, M_DEVBUF); + cam_periph_lock(periph); } static void @@ -555,8 +555,6 @@ cdsysctlinit(void *context, int pending) snprintf(tmpstr, sizeof(tmpstr), "CAM CD unit %d", periph->unit_number); snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number); - mtx_lock(&Giant); - sysctl_ctx_init(&softc->sysctl_ctx); softc->flags |= CD_FLAG_SCTX_INIT; softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, @@ -565,7 +563,6 @@ cdsysctlinit(void *context, int pending) if (softc->sysctl_tree == NULL) { printf("cdsysctlinit: unable to allocate sysctl tree\n"); - mtx_unlock(&Giant); cam_periph_release(periph); return; } @@ -579,7 +576,6 @@ cdsysctlinit(void *context, int pending) &softc->minimum_command_size, 0, cdcmdsizesysctl, "I", "Minimum CDB size"); - mtx_unlock(&Giant); cam_periph_release(periph); } Modified: stable/7/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_da.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/cam/scsi/scsi_da.c Tue Mar 10 18:57:10 2009 (r189640) @@ -987,6 +987,8 @@ dacleanup(struct cam_periph *periph) softc = (struct da_softc *)periph->softc; xpt_print(periph->path, "removing device entry\n"); + cam_periph_unlock(periph); + /* * If we can't free the sysctl tree, oh well... */ @@ -995,11 +997,10 @@ dacleanup(struct cam_periph *periph) xpt_print(periph->path, "can't remove sysctl context\n"); } - cam_periph_unlock(periph); disk_destroy(softc->disk); callout_drain(&softc->sendordered_c); - cam_periph_lock(periph); free(softc, M_DEVBUF); + cam_periph_lock(periph); } static void @@ -1078,7 +1079,6 @@ dasysctlinit(void *context, int pending) snprintf(tmpstr, sizeof(tmpstr), "CAM DA unit %d", periph->unit_number); snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number); - mtx_lock(&Giant); sysctl_ctx_init(&softc->sysctl_ctx); softc->flags |= DA_FLAG_SCTX_INIT; softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, @@ -1086,7 +1086,6 @@ dasysctlinit(void *context, int pending) CTLFLAG_RD, 0, tmpstr); if (softc->sysctl_tree == NULL) { printf("dasysctlinit: unable to allocate sysctl tree\n"); - mtx_unlock(&Giant); cam_periph_release(periph); return; } @@ -1100,7 +1099,6 @@ dasysctlinit(void *context, int pending) &softc->minimum_cmd_size, 0, dacmdsizesysctl, "I", "Minimum CDB size"); - mtx_unlock(&Giant); cam_periph_release(periph); } Modified: stable/7/sys/ia64/ia64/mca.c ============================================================================== --- stable/7/sys/ia64/ia64/mca.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/ia64/ia64/mca.c Tue Mar 10 18:57:10 2009 (r189640) @@ -42,6 +42,16 @@ MALLOC_DEFINE(M_MCA, "MCA", "Machine Check Architecture"); +struct mca_info { + STAILQ_ENTRY(mca_info) mi_link; + char mi_name[32]; + size_t mi_recsz; + char mi_record[0]; +}; + +static STAILQ_HEAD(, mca_info) mca_records = + STAILQ_HEAD_INITIALIZER(mca_records); + int64_t mca_info_size[SAL_INFO_TYPES]; vm_offset_t mca_info_block; struct mtx mca_info_block_lock; @@ -76,14 +86,32 @@ mca_sysctl_handler(SYSCTL_HANDLER_ARGS) } void +ia64_mca_populate(void) +{ + struct mca_info *rec; + + mtx_lock_spin(&mca_info_block_lock); + while (!STAILQ_EMPTY(&mca_records)) { + rec = STAILQ_FIRST(&mca_records); + STAILQ_REMOVE_HEAD(&mca_records, mi_link); + mtx_unlock_spin(&mca_info_block_lock); + (void)SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), + OID_AUTO, rec->mi_name, CTLTYPE_OPAQUE | CTLFLAG_RD, + rec->mi_record, rec->mi_recsz, mca_sysctl_handler, "S,MCA", + "Error record"); + mtx_lock_spin(&mca_info_block_lock); + } + mtx_unlock_spin(&mca_info_block_lock); +} + +void ia64_mca_save_state(int type) { struct ia64_sal_result result; struct mca_record_header *hdr; - struct sysctl_oid *oidp; - char *name, *state; + struct mca_info *rec; uint64_t seqnr; - size_t recsz, totsz; + size_t recsz; /* * Don't try to get the state if we couldn't get the size of @@ -95,9 +123,8 @@ ia64_mca_save_state(int type) if (mca_info_block == 0) return; + mtx_lock_spin(&mca_info_block_lock); while (1) { - mtx_lock_spin(&mca_info_block_lock); - result = ia64_sal_entry(SAL_GET_STATE_INFO, type, 0, mca_info_block, 0, 0, 0, 0); if (result.sal_status < 0) { @@ -111,11 +138,13 @@ ia64_mca_save_state(int type) mtx_unlock_spin(&mca_info_block_lock); - totsz = sizeof(struct sysctl_oid) + recsz + 32; - oidp = malloc(totsz, M_MCA, M_NOWAIT|M_ZERO); - state = (char*)(oidp + 1); - name = state + recsz; - sprintf(name, "%lld", (long long)seqnr); + rec = malloc(sizeof(struct mca_info) + recsz, M_MCA, + M_NOWAIT | M_ZERO); + if (rec == NULL) + /* XXX: Not sure what to do. */ + return; + + sprintf(rec->mi_name, "%lld", (long long)seqnr); mtx_lock_spin(&mca_info_block_lock); @@ -133,24 +162,14 @@ ia64_mca_save_state(int type) mca_info_block, 0, 0, 0, 0); if (seqnr != hdr->rh_seqnr) { mtx_unlock_spin(&mca_info_block_lock); - free(oidp, M_MCA); + free(rec, M_MCA); + mtx_lock_spin(&mca_info_block_lock); continue; } } - bcopy((char*)mca_info_block, state, recsz); - - oidp->oid_parent = &sysctl__hw_mca_children; - oidp->oid_number = OID_AUTO; - oidp->oid_kind = CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_DYN; - oidp->oid_arg1 = state; - oidp->oid_arg2 = recsz; - oidp->oid_name = name; - oidp->oid_handler = mca_sysctl_handler; - oidp->oid_fmt = "S,MCA"; - oidp->oid_descr = "Error record"; - - sysctl_register_oid(oidp); + rec->mi_recsz = recsz; + bcopy((char*)mca_info_block, rec->mi_record, recsz); if (mca_count > 0) { if (seqnr < mca_first) @@ -161,6 +180,7 @@ ia64_mca_save_state(int type) mca_first = mca_last = seqnr; mca_count++; + STAILQ_INSERT_TAIL(&mca_records, rec, mi_link); /* * Clear the state so that we get any other records when @@ -168,8 +188,6 @@ ia64_mca_save_state(int type) */ result = ia64_sal_entry(SAL_CLEAR_STATE_INFO, type, 0, 0, 0, 0, 0, 0); - - mtx_unlock_spin(&mca_info_block_lock); } } Modified: stable/7/sys/ia64/include/mca.h ============================================================================== --- stable/7/sys/ia64/include/mca.h Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/ia64/include/mca.h Tue Mar 10 18:57:10 2009 (r189640) @@ -239,6 +239,7 @@ struct mca_pcidev_reg { #ifdef _KERNEL void ia64_mca_init(void); +void ia64_mca_populate(void); void ia64_mca_save_state(int); #endif /* _KERNEL */ Modified: stable/7/sys/kern/kern_linker.c ============================================================================== --- stable/7/sys/kern/kern_linker.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/kern/kern_linker.c Tue Mar 10 18:57:10 2009 (r189640) @@ -292,10 +292,10 @@ linker_file_register_sysctls(linker_file if (linker_file_lookup_set(lf, "sysctl_set", &start, &stop, NULL) != 0) return; - mtx_lock(&Giant); + sysctl_lock(); for (oidp = start; oidp < stop; oidp++) sysctl_register_oid(*oidp); - mtx_unlock(&Giant); + sysctl_unlock(); } static void @@ -309,10 +309,10 @@ linker_file_unregister_sysctls(linker_fi if (linker_file_lookup_set(lf, "sysctl_set", &start, &stop, NULL) != 0) return; - mtx_lock(&Giant); + sysctl_lock(); for (oidp = start; oidp < stop; oidp++) sysctl_unregister_oid(*oidp); - mtx_unlock(&Giant); + sysctl_unlock(); } static int Modified: stable/7/sys/kern/kern_sysctl.c ============================================================================== --- stable/7/sys/kern/kern_sysctl.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/kern/kern_sysctl.c Tue Mar 10 18:57:10 2009 (r189640) @@ -64,24 +64,41 @@ static MALLOC_DEFINE(M_SYSCTLOID, "sysct static MALLOC_DEFINE(M_SYSCTLTMP, "sysctltmp", "sysctl temp output buffer"); /* - * Locking - this locks the sysctl tree in memory. + * The sysctllock protects the MIB tree. It also protects sysctl + * contexts used with dynamic sysctls. The sysctl_register_oid() and + * sysctl_unregister_oid() routines require the sysctllock to already + * be held, so the sysctl_lock() and sysctl_unlock() routines are + * provided for the few places in the kernel which need to use that + * API rather than using the dynamic API. Use of the dynamic API is + * strongly encouraged for most code. + * + * This lock is also used to serialize userland sysctl requests. Some + * sysctls wire user memory, and serializing the requests limits the + * amount of wired user memory in use. */ static struct sx sysctllock; -#define SYSCTL_LOCK() sx_xlock(&sysctllock) -#define SYSCTL_UNLOCK() sx_xunlock(&sysctllock) -#define SYSCTL_LOCK_ASSERT() sx_assert(&sysctllock, SX_XLOCKED) +#define SYSCTL_SLOCK() sx_slock(&sysctllock) +#define SYSCTL_SUNLOCK() sx_sunlock(&sysctllock) +#define SYSCTL_XLOCK() sx_xlock(&sysctllock) +#define SYSCTL_XUNLOCK() sx_xunlock(&sysctllock) +#define SYSCTL_ASSERT_XLOCKED() sx_assert(&sysctllock, SA_XLOCKED) +#define SYSCTL_ASSERT_LOCKED() sx_assert(&sysctllock, SA_LOCKED) #define SYSCTL_INIT() sx_init(&sysctllock, "sysctl lock") static int sysctl_root(SYSCTL_HANDLER_ARGS); struct sysctl_oid_list sysctl__children; /* root list */ +static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, + int recurse); + static struct sysctl_oid * sysctl_find_oidname(const char *name, struct sysctl_oid_list *list) { struct sysctl_oid *oidp; + SYSCTL_ASSERT_LOCKED(); SLIST_FOREACH(oidp, list, oid_link) { if (strcmp(oidp->oid_name, name) == 0) { return (oidp); @@ -95,6 +112,19 @@ sysctl_find_oidname(const char *name, st * * Order by number in each list. */ +void +sysctl_lock(void) +{ + + SYSCTL_XLOCK(); +} + +void +sysctl_unlock(void) +{ + + SYSCTL_XUNLOCK(); +} void sysctl_register_oid(struct sysctl_oid *oidp) @@ -107,6 +137,7 @@ sysctl_register_oid(struct sysctl_oid *o * First check if another oid with the same name already * exists in the parent's list. */ + SYSCTL_ASSERT_XLOCKED(); p = sysctl_find_oidname(oidp->oid_name, parent); if (p != NULL) { if ((p->oid_kind & CTLTYPE) == CTLTYPE_NODE) { @@ -159,6 +190,7 @@ sysctl_unregister_oid(struct sysctl_oid struct sysctl_oid *p; int error; + SYSCTL_ASSERT_XLOCKED(); error = ENOENT; if (oidp->oid_number == OID_AUTO) { error = EINVAL; @@ -190,6 +222,12 @@ sysctl_ctx_init(struct sysctl_ctx_list * if (c == NULL) { return (EINVAL); } + + /* + * No locking here, the caller is responsible for not adding + * new nodes to a context until after this function has + * returned. + */ TAILQ_INIT(c); return (0); } @@ -208,8 +246,9 @@ sysctl_ctx_free(struct sysctl_ctx_list * * XXX This algorithm is a hack. But I don't know any * XXX better solution for now... */ + SYSCTL_XLOCK(); TAILQ_FOREACH(e, clist, link) { - error = sysctl_remove_oid(e->entry, 0, 0); + error = sysctl_remove_oid_locked(e->entry, 0, 0); if (error) break; } @@ -226,19 +265,22 @@ sysctl_ctx_free(struct sysctl_ctx_list * sysctl_register_oid(e1->entry); e1 = TAILQ_PREV(e1, sysctl_ctx_list, link); } - if (error) + if (error) { + SYSCTL_XUNLOCK(); return(EBUSY); + } /* Now really delete the entries */ e = TAILQ_FIRST(clist); while (e != NULL) { e1 = TAILQ_NEXT(e, link); - error = sysctl_remove_oid(e->entry, 1, 0); + error = sysctl_remove_oid_locked(e->entry, 1, 0); if (error) panic("sysctl_remove_oid: corrupt tree, entry: %s", e->entry->oid_name); free(e, M_SYSCTLOID); e = e1; } + SYSCTL_XUNLOCK(); return (error); } @@ -248,6 +290,7 @@ sysctl_ctx_entry_add(struct sysctl_ctx_l { struct sysctl_ctx_entry *e; + SYSCTL_ASSERT_XLOCKED(); if (clist == NULL || oidp == NULL) return(NULL); e = malloc(sizeof(struct sysctl_ctx_entry), M_SYSCTLOID, M_WAITOK); @@ -262,6 +305,7 @@ sysctl_ctx_entry_find(struct sysctl_ctx_ { struct sysctl_ctx_entry *e; + SYSCTL_ASSERT_LOCKED(); if (clist == NULL || oidp == NULL) return(NULL); TAILQ_FOREACH(e, clist, link) { @@ -283,13 +327,17 @@ sysctl_ctx_entry_del(struct sysctl_ctx_l if (clist == NULL || oidp == NULL) return (EINVAL); + SYSCTL_XLOCK(); e = sysctl_ctx_entry_find(clist, oidp); if (e != NULL) { TAILQ_REMOVE(clist, e, link); + SYSCTL_XUNLOCK(); free(e, M_SYSCTLOID); return (0); - } else + } else { + SYSCTL_XUNLOCK(); return (ENOENT); + } } /* @@ -301,9 +349,21 @@ sysctl_ctx_entry_del(struct sysctl_ctx_l int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse) { + int error; + + SYSCTL_XLOCK(); + error = sysctl_remove_oid_locked(oidp, del, recurse); + SYSCTL_XUNLOCK(); + return (error); +} + +static int +sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse) +{ struct sysctl_oid *p; int error; + SYSCTL_ASSERT_XLOCKED(); if (oidp == NULL) return(EINVAL); if ((oidp->oid_kind & CTLFLAG_DYN) == 0) { @@ -322,7 +382,8 @@ sysctl_remove_oid(struct sysctl_oid *oid SLIST_FOREACH(p, SYSCTL_CHILDREN(oidp), oid_link) { if (!recurse) return (ENOTEMPTY); - error = sysctl_remove_oid(p, del, recurse); + error = sysctl_remove_oid_locked(p, del, + recurse); if (error) return (error); } @@ -367,6 +428,7 @@ sysctl_add_oid(struct sysctl_ctx_list *c if (parent == NULL) return(NULL); /* Check if the node already exists, otherwise create it */ + SYSCTL_XLOCK(); oidp = sysctl_find_oidname(name, parent); if (oidp != NULL) { if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) { @@ -374,8 +436,10 @@ sysctl_add_oid(struct sysctl_ctx_list *c /* Update the context */ if (clist != NULL) sysctl_ctx_entry_add(clist, oidp); + SYSCTL_XUNLOCK(); return (oidp); } else { + SYSCTL_XUNLOCK(); printf("can't re-use a leaf (%s)!\n", name); return (NULL); } @@ -413,6 +477,7 @@ sysctl_add_oid(struct sysctl_ctx_list *c sysctl_ctx_entry_add(clist, oidp); /* Register this oid */ sysctl_register_oid(oidp); + SYSCTL_XUNLOCK(); return (oidp); } @@ -426,12 +491,14 @@ sysctl_rename_oid(struct sysctl_oid *oid char *newname; void *oldname; - oldname = (void *)(uintptr_t)(const void *)oidp->oid_name; len = strlen(name); newname = malloc(len + 1, M_SYSCTLOID, M_WAITOK); bcopy(name, newname, len + 1); newname[len] = '\0'; + SYSCTL_XLOCK(); + oldname = (void *)(uintptr_t)(const void *)oidp->oid_name; oidp->oid_name = newname; + SYSCTL_XUNLOCK(); free(oldname, M_SYSCTLOID); } @@ -443,15 +510,21 @@ sysctl_move_oid(struct sysctl_oid *oid, { struct sysctl_oid *oidp; - if (oid->oid_parent == parent) + SYSCTL_XLOCK(); + if (oid->oid_parent == parent) { + SYSCTL_XUNLOCK(); return (0); + } oidp = sysctl_find_oidname(oid->oid_name, parent); - if (oidp != NULL) + if (oidp != NULL) { + SYSCTL_XUNLOCK(); return (EEXIST); + } sysctl_unregister_oid(oid); oid->oid_parent = parent; oid->oid_number = OID_AUTO; sysctl_register_oid(oid); + SYSCTL_XUNLOCK(); return (0); } @@ -466,8 +539,10 @@ sysctl_register_all(void *arg) struct sysctl_oid **oidp; SYSCTL_INIT(); + SYSCTL_XLOCK(); SET_FOREACH(oidp, sysctl_set) sysctl_register_oid(*oidp); + SYSCTL_XUNLOCK(); } SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_all, 0); @@ -497,6 +572,7 @@ sysctl_sysctl_debug_dump_node(struct sys int k; struct sysctl_oid *oidp; + SYSCTL_ASSERT_LOCKED(); SLIST_FOREACH(oidp, l, oid_link) { for (k=0; koid_number; @@ -686,7 +764,7 @@ name2oid (char *name, int *oid, int *len struct sysctl_oid_list *lsp = &sysctl__children; char *p; - SYSCTL_LOCK_ASSERT(); + SYSCTL_ASSERT_LOCKED(); if (!*name) return (ENOENT); @@ -744,7 +822,7 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_AR int error, oid[CTL_MAXNAME], len; struct sysctl_oid *op = 0; - SYSCTL_LOCK_ASSERT(); + SYSCTL_ASSERT_LOCKED(); if (!req->newlen) return (ENOENT); @@ -1089,9 +1167,9 @@ kernel_sysctl(struct thread *td, int *na req.newfunc = sysctl_new_kernel; req.lock = REQ_LOCKED; - SYSCTL_LOCK(); + SYSCTL_SLOCK(); error = sysctl_root(0, name, namelen, &req); - SYSCTL_UNLOCK(); + SYSCTL_SUNLOCK(); if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); @@ -1123,6 +1201,9 @@ kernel_sysctlbyname(struct thread *td, c /* * XXX: Prone to a possible race condition between lookup and * execution? Maybe put locking around it? + * + * Userland is just as racy, so I think the current implementation + * is fine. */ error = kernel_sysctl(td, oid, 2, oid, &oidlen, @@ -1234,6 +1315,7 @@ sysctl_find_oid(int *name, u_int namelen struct sysctl_oid *oid; int indx; + SYSCTL_ASSERT_LOCKED(); oid = SLIST_FIRST(&sysctl__children); indx = 0; while (oid && indx < CTL_MAXNAME) { @@ -1277,7 +1359,7 @@ sysctl_root(SYSCTL_HANDLER_ARGS) struct sysctl_oid *oid; int error, indx, lvl; - SYSCTL_LOCK_ASSERT(); + SYSCTL_ASSERT_LOCKED(); error = sysctl_find_oid(arg1, arg2, &oid, &indx, req); if (error) @@ -1355,7 +1437,7 @@ struct sysctl_args { int __sysctl(struct thread *td, struct sysctl_args *uap) { - int error, name[CTL_MAXNAME]; + int error, i, name[CTL_MAXNAME]; size_t j; if (uap->namelen > CTL_MAXNAME || uap->namelen < 2) @@ -1371,7 +1453,7 @@ __sysctl(struct thread *td, struct sysct if (error && error != ENOMEM) return (error); if (uap->oldlenp) { - int i = copyout(&j, uap->oldlenp, sizeof(j)); + i = copyout(&j, uap->oldlenp, sizeof(j)); if (i) return (i); } @@ -1423,7 +1505,7 @@ userland_sysctl(struct thread *td, int * req.newfunc = sysctl_new_user; req.lock = REQ_LOCKED; - SYSCTL_LOCK(); + SYSCTL_XLOCK(); for (;;) { req.oldidx = 0; @@ -1434,7 +1516,7 @@ userland_sysctl(struct thread *td, int * uio_yield(); } - SYSCTL_UNLOCK(); + SYSCTL_XUNLOCK(); if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); Modified: stable/7/sys/kern/vfs_init.c ============================================================================== --- stable/7/sys/kern/vfs_init.c Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/kern/vfs_init.c Tue Mar 10 18:57:10 2009 (r189640) @@ -165,12 +165,15 @@ vfs_register(struct vfsconf *vfc) * preserved by re-registering the oid after modifying its * number. */ + sysctl_lock(); SLIST_FOREACH(oidp, &sysctl__vfs_children, oid_link) if (strcmp(oidp->oid_name, vfc->vfc_name) == 0) { sysctl_unregister_oid(oidp); oidp->oid_number = vfc->vfc_typenum; sysctl_register_oid(oidp); + break; } + sysctl_unlock(); /* * Initialise unused ``struct vfsops'' fields, to use Modified: stable/7/sys/sys/sysctl.h ============================================================================== --- stable/7/sys/sys/sysctl.h Tue Mar 10 18:41:06 2009 (r189639) +++ stable/7/sys/sys/sysctl.h Tue Mar 10 18:57:10 2009 (r189640) @@ -685,6 +685,8 @@ int userland_sysctl(struct thread *td, i size_t *retval, int flags); int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, int *nindx, struct sysctl_req *req); +void sysctl_lock(void); +void sysctl_unlock(void); int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); #else /* !_KERNEL */ From jhb at FreeBSD.org Tue Mar 10 12:33:51 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Tue Mar 10 12:33:59 2009 Subject: svn commit: r189644 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/devfs kern sys vm Message-ID: <200903101933.n2AJXoej071656@svn.freebsd.org> Author: jhb Date: Tue Mar 10 19:33:50 2009 New Revision: 189644 URL: http://svn.freebsd.org/changeset/base/189644 Log: MFC: Add a flag to tag individual sysctl leaf nodes as MPSAFE. Tag the following nodes as MPSAFE: - All standalone INT/LONG sysctls. - kern.proc.* - All name-cache related sysctls. - vm.loadavg - vm.vmtotal - vm.stats.(sys|vm).* - sysctl.name2oid - kern.ident, kern.osrelease, kern.version, etc. - kern.arandom - security.jail.jailed - kern.devname Other changes: - Remove GIANT_REQUIRED from vmtotal(). - Add conditional Giant locking around the vrele() in sysctl_kern_proc_pathname(). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/devfs/devfs_devs.c stable/7/sys/kern/kern_jail.c stable/7/sys/kern/kern_mib.c stable/7/sys/kern/kern_proc.c stable/7/sys/kern/kern_sysctl.c stable/7/sys/kern/vfs_cache.c stable/7/sys/sys/sysctl.h stable/7/sys/vm/vm_meter.c Modified: stable/7/sys/fs/devfs/devfs_devs.c ============================================================================== --- stable/7/sys/fs/devfs/devfs_devs.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/fs/devfs/devfs_devs.c Tue Mar 10 19:33:50 2009 (r189644) @@ -103,8 +103,9 @@ sysctl_devname(SYSCTL_HANDLER_ARGS) return (error); } -SYSCTL_PROC(_kern, OID_AUTO, devname, CTLTYPE_OPAQUE|CTLFLAG_RW|CTLFLAG_ANYBODY, - NULL, 0, sysctl_devname, "", "devname(3) handler"); +SYSCTL_PROC(_kern, OID_AUTO, devname, + CTLTYPE_OPAQUE|CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE, + NULL, 0, sysctl_devname, "", "devname(3) handler"); SYSCTL_INT(_debug_sizeof, OID_AUTO, cdev, CTLFLAG_RD, 0, sizeof(struct cdev), "sizeof(struct cdev)"); Modified: stable/7/sys/kern/kern_jail.c ============================================================================== --- stable/7/sys/kern/kern_jail.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/kern/kern_jail.c Tue Mar 10 19:33:50 2009 (r189644) @@ -1791,8 +1791,9 @@ sysctl_jail_list(SYSCTL_HANDLER_ARGS) return (error); } -SYSCTL_OID(_security_jail, OID_AUTO, list, CTLTYPE_STRUCT | CTLFLAG_RD, - NULL, 0, sysctl_jail_list, "S", "List of active jails"); +SYSCTL_OID(_security_jail, OID_AUTO, list, + CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_jail_list, "S", "List of active jails"); static int sysctl_jail_jailed(SYSCTL_HANDLER_ARGS) @@ -1804,8 +1805,9 @@ sysctl_jail_jailed(SYSCTL_HANDLER_ARGS) return (error); } -SYSCTL_PROC(_security_jail, OID_AUTO, jailed, CTLTYPE_INT | CTLFLAG_RD, - NULL, 0, sysctl_jail_jailed, "I", "Process in jail?"); +SYSCTL_PROC(_security_jail, OID_AUTO, jailed, + CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_jail_jailed, "I", "Process in jail?"); #ifdef DDB DB_SHOW_COMMAND(jails, db_show_jails) Modified: stable/7/sys/kern/kern_mib.c ============================================================================== --- stable/7/sys/kern/kern_mib.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/kern/kern_mib.c Tue Mar 10 19:33:50 2009 (r189644) @@ -86,19 +86,19 @@ SYSCTL_NODE(, OID_AUTO, regression, CTLF "Regression test MIB"); #endif -SYSCTL_STRING(_kern, OID_AUTO, ident, CTLFLAG_RD, +SYSCTL_STRING(_kern, OID_AUTO, ident, CTLFLAG_RD|CTLFLAG_MPSAFE, kern_ident, 0, "Kernel identifier"); -SYSCTL_STRING(_kern, KERN_OSRELEASE, osrelease, CTLFLAG_RD, +SYSCTL_STRING(_kern, KERN_OSRELEASE, osrelease, CTLFLAG_RD|CTLFLAG_MPSAFE, osrelease, 0, "Operating system release"); SYSCTL_INT(_kern, KERN_OSREV, osrevision, CTLFLAG_RD, 0, BSD, "Operating system revision"); -SYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD, +SYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD|CTLFLAG_MPSAFE, version, 0, "Kernel version"); -SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD, +SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD|CTLFLAG_MPSAFE, ostype, 0, "Operating system type"); /* @@ -164,8 +164,9 @@ sysctl_kern_arnd(SYSCTL_HANDLER_ARGS) return (SYSCTL_OUT(req, buf, len)); } -SYSCTL_PROC(_kern, KERN_ARND, arandom, CTLTYPE_OPAQUE | CTLFLAG_RD, - NULL, 0, sysctl_kern_arnd, "", "arc4rand"); +SYSCTL_PROC(_kern, KERN_ARND, arandom, + CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_kern_arnd, "", "arc4rand"); static int sysctl_hw_physmem(SYSCTL_HANDLER_ARGS) @@ -247,7 +248,7 @@ sysctl_hostname(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_kern, KERN_HOSTNAME, hostname, - CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_PRISON, + CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_PRISON|CTLFLAG_MPSAFE, 0, 0, sysctl_hostname, "A", "Hostname"); static int regression_securelevel_nonmonotonic = 0; Modified: stable/7/sys/kern/kern_proc.c ============================================================================== --- stable/7/sys/kern/kern_proc.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/kern/kern_proc.c Tue Mar 10 19:33:50 2009 (r189644) @@ -1281,7 +1281,7 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER struct proc *p; struct vnode *vp; char *retbuf, *freebuf; - int error; + int error, vfslocked; if (arglen != 1) return (EINVAL); @@ -1307,7 +1307,9 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER if (*pidp != -1) PROC_UNLOCK(p); error = vn_fullpath(req->td, vp, &retbuf, &freebuf); + vfslocked = VFS_LOCK_GIANT(vp->v_mount); vrele(vp); + VFS_UNLOCK_GIANT(vfslocked); if (error) return (error); error = SYSCTL_OUT(req, retbuf, strlen(retbuf) + 1); @@ -1795,80 +1797,83 @@ repeat: SYSCTL_NODE(_kern, KERN_PROC, proc, CTLFLAG_RD, 0, "Process table"); -SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT, - 0, 0, sysctl_kern_proc, "S,proc", "Return entire process table"); +SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT| + CTLFLAG_MPSAFE, 0, 0, sysctl_kern_proc, "S,proc", + "Return entire process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_GID, gid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_GID, gid, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PGRP, pgrp, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_PGRP, pgrp, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_RGID, rgid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_RGID, rgid, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_SESSION, sid, CTLFLAG_RD, - sysctl_kern_proc, "Process table"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_SESSION, sid, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_TTY, tty, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_TTY, tty, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_UID, uid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_UID, uid, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_RUID, ruid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_RUID, ruid, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PID, pid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_PID, pid, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PROC, proc, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_PROC, proc, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Return process table, no threads"); static SYSCTL_NODE(_kern_proc, KERN_PROC_ARGS, args, - CTLFLAG_RW | CTLFLAG_ANYBODY, + CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE, sysctl_kern_proc_args, "Process argument list"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PATHNAME, pathname, CTLFLAG_RD, - sysctl_kern_proc_pathname, "Process executable path"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_PATHNAME, pathname, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc_pathname, "Process executable path"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_SV_NAME, sv_name, CTLFLAG_RD, - sysctl_kern_proc_sv_name, "Process syscall vector name (ABI type)"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_SV_NAME, sv_name, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc_sv_name, + "Process syscall vector name (ABI type)"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_GID | KERN_PROC_INC_THREAD), gid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_PGRP | KERN_PROC_INC_THREAD), pgrp_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_RGID | KERN_PROC_INC_THREAD), rgid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_SESSION | KERN_PROC_INC_THREAD), - sid_td, CTLFLAG_RD, sysctl_kern_proc, "Process table"); + sid_td, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_TTY | KERN_PROC_INC_THREAD), tty_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_UID | KERN_PROC_INC_THREAD), uid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_RUID | KERN_PROC_INC_THREAD), ruid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_PID | KERN_PROC_INC_THREAD), pid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_PROC | KERN_PROC_INC_THREAD), proc_td, - CTLFLAG_RD, sysctl_kern_proc, "Return process table, no threads"); + CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_kern_proc, + "Return process table, no threads"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_OVMMAP, ovmmap, CTLFLAG_RD, - sysctl_kern_proc_ovmmap, "Old Process vm map entries"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_OVMMAP, ovmmap, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc_ovmmap, "Old Process vm map entries"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_VMMAP, vmmap, CTLFLAG_RD, - sysctl_kern_proc_vmmap, "Process vm map entries"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_VMMAP, vmmap, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc_vmmap, "Process vm map entries"); #if defined(STACK) || defined(DDB) -static SYSCTL_NODE(_kern_proc, KERN_PROC_KSTACK, kstack, CTLFLAG_RD, - sysctl_kern_proc_kstack, "Process kernel stacks"); +static SYSCTL_NODE(_kern_proc, KERN_PROC_KSTACK, kstack, CTLFLAG_RD | + CTLFLAG_MPSAFE, sysctl_kern_proc_kstack, "Process kernel stacks"); #endif Modified: stable/7/sys/kern/kern_sysctl.c ============================================================================== --- stable/7/sys/kern/kern_sysctl.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/kern/kern_sysctl.c Tue Mar 10 19:33:50 2009 (r189644) @@ -850,8 +850,8 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_AR return (error); } -SYSCTL_PROC(_sysctl, 3, name2oid, CTLFLAG_RW|CTLFLAG_ANYBODY, 0, 0, - sysctl_sysctl_name2oid, "I", ""); +SYSCTL_PROC(_sysctl, 3, name2oid, CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE, + 0, 0, sysctl_sysctl_name2oid, "I", ""); static int sysctl_sysctl_oidfmt(SYSCTL_HANDLER_ARGS) @@ -873,7 +873,8 @@ sysctl_sysctl_oidfmt(SYSCTL_HANDLER_ARGS } -static SYSCTL_NODE(_sysctl, 4, oidfmt, CTLFLAG_RD, sysctl_sysctl_oidfmt, ""); +static SYSCTL_NODE(_sysctl, 4, oidfmt, CTLFLAG_RD|CTLFLAG_MPSAFE, + sysctl_sysctl_oidfmt, ""); static int sysctl_sysctl_oiddescr(SYSCTL_HANDLER_ARGS) @@ -1415,11 +1416,11 @@ sysctl_root(SYSCTL_HANDLER_ARGS) if (error != 0) return (error); #endif - - /* XXX: Handlers are not guaranteed to be Giant safe! */ - mtx_lock(&Giant); + if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + mtx_lock(&Giant); error = oid->oid_handler(oid, arg1, arg2, req); - mtx_unlock(&Giant); + if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + mtx_unlock(&Giant); return (error); } Modified: stable/7/sys/kern/vfs_cache.c ============================================================================== --- stable/7/sys/kern/vfs_cache.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/kern/vfs_cache.c Tue Mar 10 19:33:50 2009 (r189644) @@ -163,8 +163,8 @@ static u_long numposhits; STATNODE(CTLFL static u_long numnegzaps; STATNODE(CTLFLAG_RD, numnegzaps, &numnegzaps); static u_long numneghits; STATNODE(CTLFLAG_RD, numneghits, &numneghits); -SYSCTL_OPAQUE(_vfs_cache, OID_AUTO, nchstats, CTLFLAG_RD, &nchstats, - sizeof(nchstats), "LU", "VFS cache effectiveness statistics"); +SYSCTL_OPAQUE(_vfs_cache, OID_AUTO, nchstats, CTLFLAG_RD | CTLFLAG_MPSAFE, + &nchstats, sizeof(nchstats), "LU", "VFS cache effectiveness statistics"); @@ -209,8 +209,9 @@ sysctl_debug_hashstat_rawnchash(SYSCTL_H } return (0); } -SYSCTL_PROC(_debug_hashstat, OID_AUTO, rawnchash, CTLTYPE_INT|CTLFLAG_RD, - 0, 0, sysctl_debug_hashstat_rawnchash, "S,int", "nchash chain lengths"); +SYSCTL_PROC(_debug_hashstat, OID_AUTO, rawnchash, CTLTYPE_INT|CTLFLAG_RD| + CTLFLAG_MPSAFE, 0, 0, sysctl_debug_hashstat_rawnchash, "S,int", + "nchash chain lengths"); static int sysctl_debug_hashstat_nchash(SYSCTL_HANDLER_ARGS) @@ -255,8 +256,9 @@ sysctl_debug_hashstat_nchash(SYSCTL_HAND return (error); return (0); } -SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD, - 0, 0, sysctl_debug_hashstat_nchash, "I", "nchash chain lengths"); +SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD| + CTLFLAG_MPSAFE, 0, 0, sysctl_debug_hashstat_nchash, "I", + "nchash chain lengths"); /* * cache_zap(): Modified: stable/7/sys/sys/sysctl.h ============================================================================== --- stable/7/sys/sys/sysctl.h Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/sys/sysctl.h Tue Mar 10 19:33:50 2009 (r189644) @@ -84,6 +84,7 @@ struct ctlname { #define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ #define CTLMASK_SECURE 0x00F00000 /* Secure level */ #define CTLFLAG_TUN 0x00080000 /* Tunable variable */ +#define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ #define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) /* @@ -244,54 +245,54 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e /* Oid for an int. If ptr is NULL, val is returned. */ #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "I", descr) #define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "I", __DESCR(descr)) /* Oid for an unsigned int. If ptr is NULL, val is returned. */ #define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "IU", descr) #define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "IU", __DESCR(descr)) #define SYSCTL_XINT(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "IX", descr) #define SYSCTL_ADD_XINT(ctx, parent, nbr, name, access, ptr, val, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_int, "IX", __DESCR(descr)) /* Oid for a long. The pointer must be non NULL. */ #define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_LONG|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_LONG|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_long, "L", descr) #define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_LONG|CTLFLAG_MPSAFE|(access), \ ptr, 0, sysctl_handle_long, "L", __DESCR(descr)) /* Oid for an unsigned long. The pointer must be non NULL. */ #define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_long, "LU", __DESCR(descr)) #define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ ptr, 0, sysctl_handle_long, "LU", __DESCR(descr)) #define SYSCTL_XLONG(parent, nbr, name, access, ptr, val, descr) \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|(access), \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ ptr, val, sysctl_handle_long, "LX", __DESCR(descr)) #define SYSCTL_ADD_XLONG(ctx, parent, nbr, name, access, ptr, descr) \ - sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access), \ + sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|CTLFLAG_MPSAFE|(access), \ ptr, 0, sysctl_handle_long, "LX", __DESCR(descr)) /* Oid for an opaque object. Specified by a pointer and a length. */ Modified: stable/7/sys/vm/vm_meter.c ============================================================================== --- stable/7/sys/vm/vm_meter.c Tue Mar 10 19:22:45 2009 (r189643) +++ stable/7/sys/vm/vm_meter.c Tue Mar 10 19:33:50 2009 (r189644) @@ -89,8 +89,9 @@ sysctl_vm_loadavg(SYSCTL_HANDLER_ARGS) #endif return SYSCTL_OUT(req, &averunnable, sizeof(averunnable)); } -SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT|CTLFLAG_RD, - NULL, 0, sysctl_vm_loadavg, "S,loadavg", "Machine loadaverage history"); +SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT | CTLFLAG_RD | + CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_loadavg, "S,loadavg", + "Machine loadaverage history"); static int vmtotal(SYSCTL_HANDLER_ARGS) @@ -109,7 +110,6 @@ vmtotal(SYSCTL_HANDLER_ARGS) /* * Mark all objects as inactive. */ - GIANT_REQUIRED; mtx_lock(&vm_object_list_mtx); TAILQ_FOREACH(object, &vm_object_list, object_list) { if (!VM_OBJECT_TRYLOCK(object)) { @@ -275,7 +275,7 @@ vcnt(SYSCTL_HANDLER_ARGS) return (SYSCTL_OUT(req, &count, sizeof(int))); } -SYSCTL_PROC(_vm, VM_TOTAL, vmtotal, CTLTYPE_OPAQUE|CTLFLAG_RD, +SYSCTL_PROC(_vm, VM_TOTAL, vmtotal, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE, 0, sizeof(struct vmtotal), vmtotal, "S,vmtotal", "System virtual memory statistics"); SYSCTL_NODE(_vm, OID_AUTO, stats, CTLFLAG_RW, 0, "VM meter stats"); @@ -285,103 +285,103 @@ static SYSCTL_NODE(_vm_stats, OID_AUTO, "VM meter vm stats"); SYSCTL_NODE(_vm_stats, OID_AUTO, misc, CTLFLAG_RW, 0, "VM meter misc stats"); -SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_swtch, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_swtch, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_swtch, 0, vcnt, "IU", "Context switches"); -SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_trap, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_trap, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_trap, 0, vcnt, "IU", "Traps"); -SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_syscall, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_syscall, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_syscall, 0, vcnt, "IU", "Syscalls"); -SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_intr, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_intr, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_intr, 0, vcnt, "IU", "Hardware interrupts"); -SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_soft, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_sys, OID_AUTO, v_soft, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_soft, 0, vcnt, "IU", "Software interrupts"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vm_faults, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vm_faults, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vm_faults, 0, vcnt, "IU", "VM faults"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cow_faults, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cow_faults, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_cow_faults, 0, vcnt, "IU", "COW faults"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cow_optim, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cow_optim, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_cow_optim, 0, vcnt, "IU", "Optimized COW faults"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_zfod, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_zfod, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_zfod, 0, vcnt, "IU", "Zero fill"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_ozfod, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_ozfod, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_ozfod, 0, vcnt, "IU", "Optimized zero fill"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swapin, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swapin, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_swapin, 0, vcnt, "IU", "Swapin operations"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swapout, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swapout, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_swapout, 0, vcnt, "IU", "Swapout operations"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swappgsin, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swappgsin, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_swappgsin, 0, vcnt, "IU", "Swapin pages"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swappgsout, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_swappgsout, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_swappgsout, 0, vcnt, "IU", "Swapout pages"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodein, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodein, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vnodein, 0, vcnt, "IU", "Vnodein operations"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodeout, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodeout, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vnodeout, 0, vcnt, "IU", "Vnodeout operations"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodepgsin, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodepgsin, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vnodepgsin, 0, vcnt, "IU", "Vnodein pages"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodepgsout, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vnodepgsout, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vnodepgsout, 0, vcnt, "IU", "Vnodeout pages"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_intrans, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_intrans, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_intrans, 0, vcnt, "IU", "In transit page blocking"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_reactivated, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_reactivated, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_reactivated, 0, vcnt, "IU", "Reactivated pages"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdwakeups, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdwakeups, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_pdwakeups, 0, vcnt, "IU", "Pagedaemon wakeups"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdpages, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pdpages, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_pdpages, 0, vcnt, "IU", "Pagedaemon page scans"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_tcached, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_tcached, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_tcached, 0, vcnt, "IU", "Total pages cached"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_dfree, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_dfree, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_dfree, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pfree, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pfree, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_pfree, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_tfree, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_tfree, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_tfree, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_page_size, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_page_size, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_page_size, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_page_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_page_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_page_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_reserved, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_reserved, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_free_reserved, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_target, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_target, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_free_target, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_min, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_min, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_free_min, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_free_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_free_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_wire_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_wire_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_wire_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_active_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_active_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_active_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_inactive_target, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_inactive_target, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_inactive_target, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_inactive_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_inactive_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_inactive_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_count, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_count, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_cache_count, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_min, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_min, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_cache_min, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_max, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_cache_max, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_cache_max, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pageout_free_min, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_pageout_free_min, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_pageout_free_min, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_interrupt_free_min, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_interrupt_free_min, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_interrupt_free_min, 0, vcnt, "IU", ""); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_forks, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_forks, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_forks, 0, vcnt, "IU", "Number of fork() calls"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vforks, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vforks, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vforks, 0, vcnt, "IU", "Number of vfork() calls"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_rforks, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_rforks, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_rforks, 0, vcnt, "IU", "Number of rfork() calls"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_kthreads, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_kthreads, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_kthreads, 0, vcnt, "IU", "Number of fork() calls by kernel"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_forkpages, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_forkpages, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_forkpages, 0, vcnt, "IU", "VM pages affected by fork()"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vforkpages, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_vforkpages, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_vforkpages, 0, vcnt, "IU", "VM pages affected by vfork()"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_rforkpages, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_rforkpages, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_rforkpages, 0, vcnt, "IU", "VM pages affected by rfork()"); -SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_kthreadpages, CTLTYPE_UINT|CTLFLAG_RD, +SYSCTL_PROC(_vm_stats_vm, OID_AUTO, v_kthreadpages, CTLTYPE_UINT|CTLFLAG_RD|CTLFLAG_MPSAFE, &cnt.v_kthreadpages, 0, vcnt, "IU", "VM pages affected by fork() by kernel"); SYSCTL_INT(_vm_stats_misc, OID_AUTO, From thompsa at FreeBSD.org Tue Mar 10 17:58:23 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Tue Mar 10 17:58:30 2009 Subject: svn commit: r189658 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern Message-ID: <200903110058.n2B0wMNM078636@svn.freebsd.org> Author: thompsa Date: Wed Mar 11 00:58:22 2009 New Revision: 189658 URL: http://svn.freebsd.org/changeset/base/189658 Log: MFC r188548 Check the exit flag at the start of the taskqueue loop rather than the end. It is possible to tear down the taskqueue before the thread has run and the taskqueue loop would sleep forever. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/subr_taskqueue.c Modified: stable/7/sys/kern/subr_taskqueue.c ============================================================================== --- stable/7/sys/kern/subr_taskqueue.c Wed Mar 11 00:29:22 2009 (r189657) +++ stable/7/sys/kern/subr_taskqueue.c Wed Mar 11 00:58:22 2009 (r189658) @@ -397,10 +397,10 @@ taskqueue_thread_loop(void *arg) tqp = arg; tq = *tqp; TQ_LOCK(tq); - do { + while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0) { taskqueue_run(tq); TQ_SLEEP(tq, tq, &tq->tq_mutex, 0, "-", 0); - } while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0); + } /* rendezvous with thread that asked us to terminate */ tq->tq_pcount--; From thompsa at FreeBSD.org Tue Mar 10 18:03:34 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Tue Mar 10 18:03:45 2009 Subject: svn commit: r189659 - in stable/7: share/man/man4 sys/dev/usb Message-ID: <200903110103.n2B13WFM078809@svn.freebsd.org> Author: thompsa Date: Wed Mar 11 01:03:32 2009 New Revision: 189659 URL: http://svn.freebsd.org/changeset/base/189659 Log: MFC r189360 Add Mobile Action MA-620 Infrared Adapter. Manually merged due to different codebase. Modified: stable/7/share/man/man4/uplcom.4 stable/7/sys/dev/usb/uplcom.c stable/7/sys/dev/usb/usbdevs Modified: stable/7/share/man/man4/uplcom.4 ============================================================================== --- stable/7/share/man/man4/uplcom.4 Wed Mar 11 00:58:22 2009 (r189658) +++ stable/7/share/man/man4/uplcom.4 Wed Mar 11 01:03:32 2009 (r189659) @@ -96,6 +96,8 @@ I/O DATA USB-RSAQ2 .It I/O DATA USB-RSAQ3 .It +Mobile Action MA-620 Infrared Adapter +.It PLANEX USB-RS232 URS-03 .It RATOC REX-USB60 Modified: stable/7/sys/dev/usb/uplcom.c ============================================================================== --- stable/7/sys/dev/usb/uplcom.c Wed Mar 11 00:58:22 2009 (r189658) +++ stable/7/sys/dev/usb/uplcom.c Wed Mar 11 01:03:32 2009 (r189659) @@ -272,6 +272,9 @@ static const struct uplcom_product { { USB_VENDOR_SITECOM, USB_PRODUCT_SITECOM_SERIAL, -1, TYPE_PL2303 }, /* Tripp-Lite U209-000-R */ { USB_VENDOR_TRIPPLITE, USB_PRODUCT_TRIPPLITE_U209, -1, TYPE_PL2303X }, + /* Mobile Action MA-620 Infrared Adapter */ + { USB_VENDOR_MOBILEACTION, USB_PRODUCT_MOBILEACTION_MA620, -1, + TYPE_PL2303X }, { 0, 0 } }; Modified: stable/7/sys/dev/usb/usbdevs ============================================================================== --- stable/7/sys/dev/usb/usbdevs Wed Mar 11 00:58:22 2009 (r189658) +++ stable/7/sys/dev/usb/usbdevs Wed Mar 11 01:03:32 2009 (r189659) @@ -1716,6 +1716,9 @@ product MITSUMI CDRRW 0x0000 CD-R/RW Dr product MITSUMI BT_DONGLE 0x641f Bluetooth USB dongle product MITSUMI FDD 0x6901 USB FDD +/* Mobile Action products */ +product MOBILEACTION MA620 0x0620 MA-620 Infrared Adapter + /* Mobility products */ product MOBILITY EA 0x0204 Ethernet product MOBILITY EASIDOCK 0x0304 EasiDock Ethernet From rnoland at FreeBSD.org Tue Mar 10 18:47:34 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 18:47:50 2009 Subject: svn commit: r189661 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110147.n2B1lWir079753@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 01:47:32 2009 New Revision: 189661 URL: http://svn.freebsd.org/changeset/base/189661 Log: Merge r189045 Remove the PZERO priority from mtx_sleep. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:12:52 2009 (r189660) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:47:32 2009 (r189661) @@ -294,8 +294,8 @@ for ( ret = 0 ; !ret && !(condition) ; ) DRM_UNLOCK(); \ mtx_lock(&dev->irq_lock); \ if (!(condition)) \ - ret = -mtx_sleep(&(queue), &dev->irq_lock, \ - PZERO | PCATCH, "drmwtq", (timeout)); \ + ret = -mtx_sleep(&(queue), &dev->irq_lock, \ + PCATCH, "drmwtq", (timeout)); \ mtx_unlock(&dev->irq_lock); \ DRM_LOCK(); \ } From rnoland at FreeBSD.org Tue Mar 10 18:49:23 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 18:49:30 2009 Subject: svn commit: r189662 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110149.n2B1nMn8079837@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 01:49:22 2009 New Revision: 189662 URL: http://svn.freebsd.org/changeset/base/189662 Log: Merge r189046 There is no reason to hold the lock here. When I was LOCK_PROFILING this was pretty high up and there is no reason for it. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_drv.c Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:47:32 2009 (r189661) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:49:22 2009 (r189662) @@ -658,9 +658,7 @@ int drm_ioctl(struct cdev *kdev, u_long int is_driver_ioctl = 0; struct drm_file *file_priv; - DRM_LOCK(); retcode = devfs_get_cdevpriv((void **)&file_priv); - DRM_UNLOCK(); if (retcode != 0) { DRM_ERROR("can't find authenticator\n"); return EINVAL; From rnoland at FreeBSD.org Tue Mar 10 18:50:54 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 18:51:11 2009 Subject: svn commit: r189663 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110150.n2B1orkh079920@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 01:50:53 2009 New Revision: 189663 URL: http://svn.freebsd.org/changeset/base/189663 Log: Merge r189047 The vblank_swap ioctl was fundamentally race prone. Get rid of it. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/i915_dma.c stable/7/sys/dev/drm/i915_drv.h stable/7/sys/dev/drm/i915_irq.c Modified: stable/7/sys/dev/drm/i915_dma.c ============================================================================== --- stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 01:49:22 2009 (r189662) +++ stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 01:50:53 2009 (r189663) @@ -1087,7 +1087,6 @@ int i915_driver_load(struct drm_device * #ifdef I915_HAVE_GEM i915_gem_load(dev); #endif - DRM_SPININIT(&dev_priv->swaps_lock, "swap"); DRM_SPININIT(&dev_priv->user_irq_lock, "userirq"); #ifdef __linux__ @@ -1117,7 +1116,6 @@ int i915_driver_unload(struct drm_device drm_rmmap(dev, dev_priv->mmio_map); - DRM_SPINUNINIT(&dev_priv->swaps_lock); DRM_SPINUNINIT(&dev_priv->user_irq_lock); #ifdef __linux__ Modified: stable/7/sys/dev/drm/i915_drv.h ============================================================================== --- stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 01:49:22 2009 (r189662) +++ stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 01:50:53 2009 (r189663) @@ -178,9 +178,6 @@ typedef struct drm_i915_private { struct drm_i915_validate_buffer *val_bufs; #endif - DRM_SPINTYPE swaps_lock; - drm_i915_vbl_swap_t vbl_swaps; - unsigned int swaps_pending; #if defined(I915_HAVE_BUFFER) /* DRI2 sarea */ struct drm_buffer_object *sarea_bo; Modified: stable/7/sys/dev/drm/i915_irq.c ============================================================================== --- stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 01:49:22 2009 (r189662) +++ stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 01:50:53 2009 (r189663) @@ -121,277 +121,6 @@ i915_pipe_enabled(struct drm_device *dev return 0; } -/** - * Emit a synchronous flip. - * - * This function must be called with the drawable spinlock held. - */ -static void -i915_dispatch_vsync_flip(struct drm_device *dev, struct drm_drawable_info *drw, - int plane) -{ - drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; - drm_i915_sarea_t *sarea_priv = dev_priv->sarea_priv; - u16 x1, y1, x2, y2; - int pf_planes = 1 << plane; - - DRM_SPINLOCK_ASSERT(&dev->drw_lock); - - /* If the window is visible on the other plane, we have to flip on that - * plane as well. - */ - if (plane == 1) { - x1 = sarea_priv->planeA_x; - y1 = sarea_priv->planeA_y; - x2 = x1 + sarea_priv->planeA_w; - y2 = y1 + sarea_priv->planeA_h; - } else { - x1 = sarea_priv->planeB_x; - y1 = sarea_priv->planeB_y; - x2 = x1 + sarea_priv->planeB_w; - y2 = y1 + sarea_priv->planeB_h; - } - - if (x2 > 0 && y2 > 0) { - int i, num_rects = drw->num_rects; - struct drm_clip_rect *rect = drw->rects; - - for (i = 0; i < num_rects; i++) - if (!(rect[i].x1 >= x2 || rect[i].y1 >= y2 || - rect[i].x2 <= x1 || rect[i].y2 <= y1)) { - pf_planes = 0x3; - - break; - } - } - - i915_dispatch_flip(dev, pf_planes, 1); -} - -/** - * Emit blits for scheduled buffer swaps. - * - * This function will be called with the HW lock held. - */ -static void i915_vblank_tasklet(struct drm_device *dev) -{ - drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; - struct list_head *list, *tmp, hits, *hit; - int nhits, nrects, slice[2], upper[2], lower[2], i, num_pages; - unsigned counter[2]; - struct drm_drawable_info *drw; - drm_i915_sarea_t *sarea_priv = dev_priv->sarea_priv; - u32 cpp = dev_priv->cpp, offsets[3]; - u32 cmd = (cpp == 4) ? (XY_SRC_COPY_BLT_CMD | - XY_SRC_COPY_BLT_WRITE_ALPHA | - XY_SRC_COPY_BLT_WRITE_RGB) - : XY_SRC_COPY_BLT_CMD; - u32 src_pitch = sarea_priv->pitch * cpp; - u32 dst_pitch = sarea_priv->pitch * cpp; - /* COPY rop (0xcc), map cpp to magic color depth constants */ - u32 ropcpp = (0xcc << 16) | ((cpp - 1) << 24); - RING_LOCALS; - - if (IS_I965G(dev) && sarea_priv->front_tiled) { - cmd |= XY_SRC_COPY_BLT_DST_TILED; - dst_pitch >>= 2; - } - if (IS_I965G(dev) && sarea_priv->back_tiled) { - cmd |= XY_SRC_COPY_BLT_SRC_TILED; - src_pitch >>= 2; - } - - counter[0] = drm_vblank_count(dev, 0); - counter[1] = drm_vblank_count(dev, 1); - - DRM_DEBUG("\n"); - - INIT_LIST_HEAD(&hits); - - nhits = nrects = 0; - - /* No irqsave/restore necessary. This tasklet may be run in an - * interrupt context or normal context, but we don't have to worry - * about getting interrupted by something acquiring the lock, because - * we are the interrupt context thing that acquires the lock. - */ - DRM_SPINLOCK(&dev_priv->swaps_lock); - - /* Find buffer swaps scheduled for this vertical blank */ - list_for_each_safe(list, tmp, &dev_priv->vbl_swaps.head) { - drm_i915_vbl_swap_t *vbl_swap = - list_entry(list, drm_i915_vbl_swap_t, head); - int pipe = i915_get_pipe(dev, vbl_swap->plane); - - if ((counter[pipe] - vbl_swap->sequence) > (1<<23)) - continue; - - list_del(list); - dev_priv->swaps_pending--; - drm_vblank_put(dev, pipe); - - DRM_SPINUNLOCK(&dev_priv->swaps_lock); - DRM_SPINLOCK(&dev->drw_lock); - - drw = drm_get_drawable_info(dev, vbl_swap->drw_id); - - if (!drw) { - DRM_SPINUNLOCK(&dev->drw_lock); - drm_free(vbl_swap, sizeof(*vbl_swap), DRM_MEM_DRIVER); - DRM_SPINLOCK(&dev_priv->swaps_lock); - continue; - } - - list_for_each(hit, &hits) { - drm_i915_vbl_swap_t *swap_cmp = - list_entry(hit, drm_i915_vbl_swap_t, head); - struct drm_drawable_info *drw_cmp = - drm_get_drawable_info(dev, swap_cmp->drw_id); - - if (drw_cmp && - drw_cmp->rects[0].y1 > drw->rects[0].y1) { - list_add_tail(list, hit); - break; - } - } - - DRM_SPINUNLOCK(&dev->drw_lock); - - /* List of hits was empty, or we reached the end of it */ - if (hit == &hits) - list_add_tail(list, hits.prev); - - nhits++; - - DRM_SPINLOCK(&dev_priv->swaps_lock); - } - - DRM_SPINUNLOCK(&dev_priv->swaps_lock); - - if (nhits == 0) { - return; - } - - i915_kernel_lost_context(dev); - - upper[0] = upper[1] = 0; - slice[0] = max(sarea_priv->planeA_h / nhits, 1); - slice[1] = max(sarea_priv->planeB_h / nhits, 1); - lower[0] = sarea_priv->planeA_y + slice[0]; - lower[1] = sarea_priv->planeB_y + slice[0]; - - offsets[0] = sarea_priv->front_offset; - offsets[1] = sarea_priv->back_offset; - offsets[2] = sarea_priv->third_offset; - num_pages = sarea_priv->third_handle ? 3 : 2; - - DRM_SPINLOCK(&dev->drw_lock); - - /* Emit blits for buffer swaps, partitioning both outputs into as many - * slices as there are buffer swaps scheduled in order to avoid tearing - * (based on the assumption that a single buffer swap would always - * complete before scanout starts). - */ - for (i = 0; i++ < nhits; - upper[0] = lower[0], lower[0] += slice[0], - upper[1] = lower[1], lower[1] += slice[1]) { - int init_drawrect = 1; - - if (i == nhits) - lower[0] = lower[1] = sarea_priv->height; - - list_for_each(hit, &hits) { - drm_i915_vbl_swap_t *swap_hit = - list_entry(hit, drm_i915_vbl_swap_t, head); - struct drm_clip_rect *rect; - int num_rects, plane, front, back; - unsigned short top, bottom; - - drw = drm_get_drawable_info(dev, swap_hit->drw_id); - - if (!drw) - continue; - - plane = swap_hit->plane; - - if (swap_hit->flip) { - i915_dispatch_vsync_flip(dev, drw, plane); - continue; - } - - if (init_drawrect) { - int width = sarea_priv->width; - int height = sarea_priv->height; - if (IS_I965G(dev)) { - BEGIN_LP_RING(4); - - OUT_RING(GFX_OP_DRAWRECT_INFO_I965); - OUT_RING(0); - OUT_RING(((width - 1) & 0xffff) | ((height - 1) << 16)); - OUT_RING(0); - - ADVANCE_LP_RING(); - } else { - BEGIN_LP_RING(6); - - OUT_RING(GFX_OP_DRAWRECT_INFO); - OUT_RING(0); - OUT_RING(0); - OUT_RING(((width - 1) & 0xffff) | ((height - 1) << 16)); - OUT_RING(0); - OUT_RING(0); - - ADVANCE_LP_RING(); - } - - sarea_priv->ctxOwner = DRM_KERNEL_CONTEXT; - - init_drawrect = 0; - } - - rect = drw->rects; - top = upper[plane]; - bottom = lower[plane]; - - front = (dev_priv->sarea_priv->pf_current_page >> - (2 * plane)) & 0x3; - back = (front + 1) % num_pages; - - for (num_rects = drw->num_rects; num_rects--; rect++) { - int y1 = max(rect->y1, top); - int y2 = min(rect->y2, bottom); - - if (y1 >= y2) - continue; - - BEGIN_LP_RING(8); - - OUT_RING(cmd); - OUT_RING(ropcpp | dst_pitch); - OUT_RING((y1 << 16) | rect->x1); - OUT_RING((y2 << 16) | rect->x2); - OUT_RING(offsets[front]); - OUT_RING((y1 << 16) | rect->x1); - OUT_RING(src_pitch); - OUT_RING(offsets[back]); - - ADVANCE_LP_RING(); - } - } - } - - DRM_SPINUNLOCK(&dev->drw_lock); - - list_for_each_safe(hit, tmp, &hits) { - drm_i915_vbl_swap_t *swap_hit = - list_entry(hit, drm_i915_vbl_swap_t, head); - - list_del(hit); - - drm_free(swap_hit, sizeof(*swap_hit), DRM_MEM_DRIVER); - } -} - u32 i915_get_vblank_counter(struct drm_device *dev, int plane) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; @@ -526,11 +255,6 @@ irqreturn_t i915_driver_irq_handler(DRM_ #endif } - if (vblank) { - if (dev_priv->swaps_pending > 0) - drm_locked_tasklet(dev, i915_vblank_tasklet); - } - return IRQ_HANDLED; } @@ -796,157 +520,22 @@ int i915_vblank_pipe_get(struct drm_devi int i915_vblank_swap(struct drm_device *dev, void *data, struct drm_file *file_priv) { - drm_i915_private_t *dev_priv = dev->dev_private; - drm_i915_vblank_swap_t *swap = data; - drm_i915_vbl_swap_t *vbl_swap; - unsigned int pipe, seqtype, curseq, plane; - unsigned long irqflags; - struct list_head *list; - int ret; - - if (!dev_priv) { - DRM_ERROR("%s called with no initialization\n", __func__); - return -EINVAL; - } - - if (!dev_priv->sarea_priv || dev_priv->sarea_priv->rotation) { - DRM_DEBUG("Rotation not supported\n"); - return -EINVAL; - } - - if (swap->seqtype & ~(_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE | - _DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS | - _DRM_VBLANK_FLIP)) { - DRM_ERROR("Invalid sequence type 0x%x\n", swap->seqtype); - return -EINVAL; - } - - plane = (swap->seqtype & _DRM_VBLANK_SECONDARY) ? 1 : 0; - pipe = i915_get_pipe(dev, plane); - - seqtype = swap->seqtype & (_DRM_VBLANK_RELATIVE | _DRM_VBLANK_ABSOLUTE); - - if (!(dev_priv->vblank_pipe & (1 << pipe))) { - DRM_ERROR("Invalid pipe %d\n", pipe); - return -EINVAL; - } - - DRM_SPINLOCK_IRQSAVE(&dev->drw_lock, irqflags); - - /* It makes no sense to schedule a swap for a drawable that doesn't have - * valid information at this point. E.g. this could mean that the X - * server is too old to push drawable information to the DRM, in which - * case all such swaps would become ineffective. + /* The delayed swap mechanism was fundamentally racy, and has been + * removed. The model was that the client requested a delayed flip/swap + * from the kernel, then waited for vblank before continuing to perform + * rendering. The problem was that the kernel might wake the client + * up before it dispatched the vblank swap (since the lock has to be + * held while touching the ringbuffer), in which case the client would + * clear and start the next frame before the swap occurred, and + * flicker would occur in addition to likely missing the vblank. + * + * In the absence of this ioctl, userland falls back to a correct path + * of waiting for a vblank, then dispatching the swap on its own. + * Context switching to userland and back is plenty fast enough for + * meeting the requirements of vblank swapping. */ - if (!drm_get_drawable_info(dev, swap->drawable)) { - DRM_SPINUNLOCK_IRQRESTORE(&dev->drw_lock, irqflags); - DRM_DEBUG("Invalid drawable ID %d\n", swap->drawable); - return -EINVAL; - } - - DRM_SPINUNLOCK_IRQRESTORE(&dev->drw_lock, irqflags); - - /* - * We take the ref here and put it when the swap actually completes - * in the tasklet. - */ - ret = drm_vblank_get(dev, pipe); - if (ret) - return ret; - curseq = drm_vblank_count(dev, pipe); - - if (seqtype == _DRM_VBLANK_RELATIVE) - swap->sequence += curseq; - - if ((curseq - swap->sequence) <= (1<<23)) { - if (swap->seqtype & _DRM_VBLANK_NEXTONMISS) { - swap->sequence = curseq + 1; - } else { - DRM_DEBUG("Missed target sequence\n"); - drm_vblank_put(dev, pipe); - return -EINVAL; - } - } - - if (swap->seqtype & _DRM_VBLANK_FLIP) { - swap->sequence--; - - if ((curseq - swap->sequence) <= (1<<23)) { - struct drm_drawable_info *drw; - - LOCK_TEST_WITH_RETURN(dev, file_priv); - DRM_SPINLOCK_IRQSAVE(&dev->drw_lock, irqflags); - - drw = drm_get_drawable_info(dev, swap->drawable); - - if (!drw) { - DRM_SPINUNLOCK_IRQRESTORE(&dev->drw_lock, - irqflags); - DRM_DEBUG("Invalid drawable ID %d\n", - swap->drawable); - drm_vblank_put(dev, pipe); - return -EINVAL; - } - - i915_dispatch_vsync_flip(dev, drw, plane); - - DRM_SPINUNLOCK_IRQRESTORE(&dev->drw_lock, irqflags); - - drm_vblank_put(dev, pipe); - return 0; - } - } - - DRM_SPINLOCK_IRQSAVE(&dev_priv->swaps_lock, irqflags); - - list_for_each(list, &dev_priv->vbl_swaps.head) { - vbl_swap = list_entry(list, drm_i915_vbl_swap_t, head); - - if (vbl_swap->drw_id == swap->drawable && - vbl_swap->plane == plane && - vbl_swap->sequence == swap->sequence) { - vbl_swap->flip = (swap->seqtype & _DRM_VBLANK_FLIP); - DRM_SPINUNLOCK_IRQRESTORE(&dev_priv->swaps_lock, irqflags); - DRM_DEBUG("Already scheduled\n"); - return 0; - } - } - - DRM_SPINUNLOCK_IRQRESTORE(&dev_priv->swaps_lock, irqflags); - - if (dev_priv->swaps_pending >= 100) { - DRM_DEBUG("Too many swaps queued\n"); - drm_vblank_put(dev, pipe); - return -EBUSY; - } - - vbl_swap = drm_calloc(1, sizeof(*vbl_swap), DRM_MEM_DRIVER); - - if (!vbl_swap) { - DRM_ERROR("Failed to allocate memory to queue swap\n"); - drm_vblank_put(dev, pipe); - return -ENOMEM; - } - - DRM_DEBUG("\n"); - - vbl_swap->drw_id = swap->drawable; - vbl_swap->plane = plane; - vbl_swap->sequence = swap->sequence; - vbl_swap->flip = (swap->seqtype & _DRM_VBLANK_FLIP); - - if (vbl_swap->flip) - swap->sequence++; - - DRM_SPINLOCK_IRQSAVE(&dev_priv->swaps_lock, irqflags); - - list_add_tail(&vbl_swap->head, &dev_priv->vbl_swaps.head); - dev_priv->swaps_pending++; - - DRM_SPINUNLOCK_IRQRESTORE(&dev_priv->swaps_lock, irqflags); - - return 0; + return -EINVAL; } /* drm_dma.h hooks @@ -965,9 +554,6 @@ int i915_driver_irq_postinstall(struct d drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; int ret, num_pipes = 2; - INIT_LIST_HEAD(&dev_priv->vbl_swaps.head); - dev_priv->swaps_pending = 0; - dev_priv->user_irq_refcount = 0; dev_priv->irq_mask_reg = ~0; From rnoland at FreeBSD.org Tue Mar 10 18:53:23 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 18:53:34 2009 Subject: svn commit: r189664 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110153.n2B1rLjQ080030@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 01:53:21 2009 New Revision: 189664 URL: http://svn.freebsd.org/changeset/base/189664 Log: Merge 189048 The i915 driver was the only consumer of locked task support. Now that it doesn't use it anymore, get right of the taskqueue and locked task support. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/drm_drv.c stable/7/sys/dev/drm/drm_irq.c stable/7/sys/dev/drm/drm_lock.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:50:53 2009 (r189663) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:53:21 2009 (r189664) @@ -63,7 +63,6 @@ struct drm_file; #include #include #include -#include #include #include #include @@ -628,7 +627,6 @@ struct drm_device { struct mtx irq_lock; /* protects irq condition checks */ struct mtx dev_lock; /* protects everything else */ DRM_SPINTYPE drw_lock; - DRM_SPINTYPE tsk_lock; /* Usage Counters */ int open_count; /* Outstanding files open */ @@ -695,9 +693,6 @@ struct drm_device { struct unrhdr *drw_unrhdr; /* RB tree of drawable infos */ RB_HEAD(drawable_tree, bsd_drm_drawable_info) drw_head; - - struct task locked_task; - void (*locked_task_call)(struct drm_device *dev); }; static __inline__ int drm_core_check_feature(struct drm_device *dev, @@ -918,8 +913,6 @@ int drm_control(struct drm_device *dev, struct drm_file *file_priv); int drm_wait_vblank(struct drm_device *dev, void *data, struct drm_file *file_priv); -void drm_locked_tasklet(struct drm_device *dev, - void (*tasklet)(struct drm_device *dev)); /* AGP/GART support (drm_agpsupport.c) */ int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:50:53 2009 (r189663) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:53:21 2009 (r189664) @@ -193,7 +193,6 @@ int drm_attach(device_t nbdev, drm_pci_i mtx_init(&dev->irq_lock, "drmirq", NULL, MTX_DEF); mtx_init(&dev->vbl_lock, "drmvbl", NULL, MTX_DEF); mtx_init(&dev->drw_lock, "drmdrw", NULL, MTX_DEF); - mtx_init(&dev->tsk_lock, "drmtsk", NULL, MTX_DEF); id_entry = drm_find_description(pci_get_vendor(dev->device), pci_get_device(dev->device), idlist); @@ -440,7 +439,6 @@ error: DRM_UNLOCK(); destroy_dev(dev->devnode); - mtx_destroy(&dev->tsk_lock); mtx_destroy(&dev->drw_lock); mtx_destroy(&dev->vbl_lock); mtx_destroy(&dev->irq_lock); @@ -503,14 +501,12 @@ static void drm_unload(struct drm_device if (pci_disable_busmaster(dev->device)) DRM_ERROR("Request to disable bus-master failed.\n"); - mtx_destroy(&dev->tsk_lock); mtx_destroy(&dev->drw_lock); mtx_destroy(&dev->vbl_lock); mtx_destroy(&dev->irq_lock); mtx_destroy(&dev->dev_lock); } - int drm_version(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_version *version = data; Modified: stable/7/sys/dev/drm/drm_irq.c ============================================================================== --- stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:50:53 2009 (r189663) +++ stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:53:21 2009 (r189664) @@ -36,8 +36,6 @@ __FBSDID("$FreeBSD$"); #include "dev/drm/drmP.h" #include "dev/drm/drm.h" -static void drm_locked_task(void *context, int pending __unused); - int drm_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -198,7 +196,6 @@ int drm_irq_install(struct drm_device *d dev->driver->irq_postinstall(dev); DRM_UNLOCK(); - TASK_INIT(&dev->locked_task, 0, drm_locked_task, dev); return 0; err: DRM_LOCK(); @@ -507,46 +504,3 @@ void drm_handle_vblank(struct drm_device drm_vbl_send_signals(dev, crtc); } -static void drm_locked_task(void *context, int pending __unused) -{ - struct drm_device *dev = context; - - DRM_SPINLOCK(&dev->tsk_lock); - - DRM_LOCK(); /* XXX drm_lock_take() should do it's own locking */ - if (dev->locked_task_call == NULL || - drm_lock_take(&dev->lock, DRM_KERNEL_CONTEXT) == 0) { - DRM_UNLOCK(); - DRM_SPINUNLOCK(&dev->tsk_lock); - return; - } - - dev->lock.file_priv = NULL; /* kernel owned */ - dev->lock.lock_time = jiffies; - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); - - DRM_UNLOCK(); - - dev->locked_task_call(dev); - - drm_lock_free(&dev->lock, DRM_KERNEL_CONTEXT); - - dev->locked_task_call = NULL; - - DRM_SPINUNLOCK(&dev->tsk_lock); -} - -void -drm_locked_tasklet(struct drm_device *dev, - void (*tasklet)(struct drm_device *dev)) -{ - DRM_SPINLOCK(&dev->tsk_lock); - if (dev->locked_task_call != NULL) { - DRM_SPINUNLOCK(&dev->tsk_lock); - return; - } - - dev->locked_task_call = tasklet; - DRM_SPINUNLOCK(&dev->tsk_lock); - taskqueue_enqueue(taskqueue_swi, &dev->locked_task); -} Modified: stable/7/sys/dev/drm/drm_lock.c ============================================================================== --- stable/7/sys/dev/drm/drm_lock.c Wed Mar 11 01:50:53 2009 (r189663) +++ stable/7/sys/dev/drm/drm_lock.c Wed Mar 11 01:53:21 2009 (r189664) @@ -115,13 +115,6 @@ int drm_unlock(struct drm_device *dev, v return EINVAL; } - DRM_SPINLOCK(&dev->tsk_lock); - if (dev->locked_task_call != NULL) { - dev->locked_task_call(dev); - dev->locked_task_call = NULL; - } - DRM_SPINUNLOCK(&dev->tsk_lock); - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]); DRM_LOCK(); From rnoland at FreeBSD.org Tue Mar 10 18:54:42 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 18:54:55 2009 Subject: svn commit: r189665 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110154.n2B1sfod080112@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 01:54:41 2009 New Revision: 189665 URL: http://svn.freebsd.org/changeset/base/189665 Log: Merge r189049 This was part of a sync to the code that Intel is shipping in linux. - Remove the old TTM interface - Move register definitions to i915_reg.h - Overhaul the irq handler Added: stable/7/sys/dev/drm/i915_reg.h - copied unchanged from r189049, head/sys/dev/drm/i915_reg.h Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/i915_dma.c stable/7/sys/dev/drm/i915_drv.c stable/7/sys/dev/drm/i915_drv.h stable/7/sys/dev/drm/i915_irq.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:53:21 2009 (r189664) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:54:41 2009 (r189665) @@ -655,6 +655,7 @@ struct drm_device { /* Context support */ int irq; /* Interrupt used by board */ int irq_enabled; /* True if the irq handler is enabled */ + int msi_enabled; /* MSI enabled */ int irqrid; /* Interrupt used by board */ struct resource *irqr; /* Resource for interrupt used by board */ void *irqh; /* Handle from bus_setup_intr */ Modified: stable/7/sys/dev/drm/i915_dma.c ============================================================================== --- stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 01:53:21 2009 (r189664) +++ stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 01:54:41 2009 (r189665) @@ -58,6 +58,9 @@ int i915_wait_ring(struct drm_device * d if (ring->space >= n) return 0; + if (dev_priv->sarea_priv) + dev_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT; + if (ring->head != last_head) i = 0; @@ -72,77 +75,53 @@ int i915_wait_ring(struct drm_device * d return -EBUSY; } -int i915_init_hardware_status(struct drm_device *dev) +/** + * Sets up the hardware status page for devices that need a physical address + * in the register. + */ +static int i915_init_phys_hws(struct drm_device *dev) { drm_i915_private_t *dev_priv = dev->dev_private; - drm_dma_handle_t *dmah; /* Program Hardware Status Page */ -#ifdef __FreeBSD__ DRM_UNLOCK(); -#endif - dmah = drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff); -#ifdef __FreeBSD__ + dev_priv->status_page_dmah = + drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff); DRM_LOCK(); -#endif - if (!dmah) { + if (!dev_priv->status_page_dmah) { DRM_ERROR("Can not allocate hardware status page\n"); return -ENOMEM; } - - dev_priv->status_page_dmah = dmah; - dev_priv->hw_status_page = dmah->vaddr; - dev_priv->dma_status_page = dmah->busaddr; + dev_priv->hw_status_page = dev_priv->status_page_dmah->vaddr; + dev_priv->dma_status_page = dev_priv->status_page_dmah->busaddr; memset(dev_priv->hw_status_page, 0, PAGE_SIZE); - I915_WRITE(0x02080, dev_priv->dma_status_page); + I915_WRITE(HWS_PGA, dev_priv->dma_status_page); DRM_DEBUG("Enabled hardware status page\n"); return 0; } -void i915_free_hardware_status(struct drm_device *dev) +/** + * Frees the hardware status page, whether it's a physical address or a virtual + * address set up by the X Server. + */ +static void i915_free_hws(struct drm_device *dev) { drm_i915_private_t *dev_priv = dev->dev_private; if (dev_priv->status_page_dmah) { drm_pci_free(dev, dev_priv->status_page_dmah); dev_priv->status_page_dmah = NULL; - /* Need to rewrite hardware status page */ - I915_WRITE(0x02080, 0x1ffff000); } if (dev_priv->status_gfx_addr) { dev_priv->status_gfx_addr = 0; drm_core_ioremapfree(&dev_priv->hws_map, dev); - I915_WRITE(0x02080, 0x1ffff000); } -} -#if I915_RING_VALIDATE -/** - * Validate the cached ring tail value - * - * If the X server writes to the ring and DRM doesn't - * reload the head and tail pointers, it will end up writing - * data to the wrong place in the ring, causing havoc. - */ -void i915_ring_validate(struct drm_device *dev, const char *func, int line) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - drm_i915_ring_buffer_t *ring = &(dev_priv->ring); - u32 tail = I915_READ(PRB0_TAIL) & HEAD_ADDR; - u32 head = I915_READ(PRB0_HEAD) & HEAD_ADDR; - - if (tail != ring->tail) { - DRM_ERROR("%s:%d head sw %x, hw %x. tail sw %x hw %x\n", - func, line, - ring->head, head, ring->tail, tail); -#ifdef __linux__ - BUG_ON(1); -#endif - } + /* Need to rewrite hardware status page */ + I915_WRITE(HWS_PGA, 0x1ffff000); } -#endif void i915_kernel_lost_context(struct drm_device * dev) { @@ -154,6 +133,9 @@ void i915_kernel_lost_context(struct drm ring->space = ring->head - (ring->tail + 8); if (ring->space < 0) ring->space += ring->Size; + + if (ring->head == ring->tail && dev_priv->sarea_priv) + dev_priv->sarea_priv->perf_boxes |= I915_BOX_RING_EMPTY; } static int i915_dma_cleanup(struct drm_device * dev) @@ -168,86 +150,22 @@ static int i915_dma_cleanup(struct drm_d if (dev_priv->ring.virtual_start) { drm_core_ioremapfree(&dev_priv->ring.map, dev); - dev_priv->ring.virtual_start = 0; - dev_priv->ring.map.handle = 0; + dev_priv->ring.virtual_start = NULL; + dev_priv->ring.map.handle = NULL; dev_priv->ring.map.size = 0; } + /* Clear the HWS virtual address at teardown */ if (I915_NEED_GFX_HWS(dev)) - i915_free_hardware_status(dev); + i915_free_hws(dev); return 0; } -#if defined(I915_HAVE_BUFFER) -#define DRI2_SAREA_BLOCK_TYPE(b) ((b) >> 16) -#define DRI2_SAREA_BLOCK_SIZE(b) ((b) & 0xffff) -#define DRI2_SAREA_BLOCK_NEXT(p) \ - ((void *) ((unsigned char *) (p) + \ - DRI2_SAREA_BLOCK_SIZE(*(unsigned int *) p))) - -#define DRI2_SAREA_BLOCK_END 0x0000 -#define DRI2_SAREA_BLOCK_LOCK 0x0001 -#define DRI2_SAREA_BLOCK_EVENT_BUFFER 0x0002 - -static int -setup_dri2_sarea(struct drm_device * dev, - struct drm_file *file_priv, - drm_i915_init_t * init) +static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init) { drm_i915_private_t *dev_priv = dev->dev_private; - int ret; - unsigned int *p, *end, *next; - - mutex_lock(&dev->struct_mutex); - dev_priv->sarea_bo = - drm_lookup_buffer_object(file_priv, - init->sarea_handle, 1); - mutex_unlock(&dev->struct_mutex); - - if (!dev_priv->sarea_bo) { - DRM_ERROR("did not find sarea bo\n"); - return -EINVAL; - } - - ret = drm_bo_kmap(dev_priv->sarea_bo, 0, - dev_priv->sarea_bo->num_pages, - &dev_priv->sarea_kmap); - if (ret) { - DRM_ERROR("could not map sarea bo\n"); - return ret; - } - - p = dev_priv->sarea_kmap.virtual; - end = (void *) p + (dev_priv->sarea_bo->num_pages << PAGE_SHIFT); - while (p < end && DRI2_SAREA_BLOCK_TYPE(*p) != DRI2_SAREA_BLOCK_END) { - switch (DRI2_SAREA_BLOCK_TYPE(*p)) { - case DRI2_SAREA_BLOCK_LOCK: - dev->lock.hw_lock = (void *) (p + 1); - dev->sigdata.lock = dev->lock.hw_lock; - break; - } - next = DRI2_SAREA_BLOCK_NEXT(p); - if (next <= p || end < next) { - DRM_ERROR("malformed dri2 sarea: next is %p should be within %p-%p\n", - next, p, end); - return -EINVAL; - } - p = next; - } - - return 0; -} -#endif -static int i915_initialize(struct drm_device * dev, - struct drm_file *file_priv, - drm_i915_init_t * init) -{ - drm_i915_private_t *dev_priv = dev->dev_private; -#if defined(I915_HAVE_BUFFER) - int ret; -#endif dev_priv->sarea = drm_getsarea(dev); if (!dev_priv->sarea) { DRM_ERROR("can not find sarea!\n"); @@ -255,20 +173,17 @@ static int i915_initialize(struct drm_de return -EINVAL; } -#ifdef I915_HAVE_BUFFER - dev_priv->max_validate_buffers = I915_MAX_VALIDATE_BUFFERS; -#endif - - if (init->sarea_priv_offset) - dev_priv->sarea_priv = (drm_i915_sarea_t *) - ((u8 *) dev_priv->sarea->handle + - init->sarea_priv_offset); - else { - /* No sarea_priv for you! */ - dev_priv->sarea_priv = NULL; - } + dev_priv->sarea_priv = (drm_i915_sarea_t *) + ((u8 *) dev_priv->sarea->handle + init->sarea_priv_offset); if (init->ring_size != 0) { + if (dev_priv->ring.ring_obj != NULL) { + i915_dma_cleanup(dev); + DRM_ERROR("Client tried to initialize ringbuffer in " + "GEM mode\n"); + return -EINVAL; + } + dev_priv->ring.Size = init->ring_size; dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; @@ -286,41 +201,20 @@ static int i915_initialize(struct drm_de " ring buffer\n"); return -ENOMEM; } - - dev_priv->ring.virtual_start = dev_priv->ring.map.handle; } - dev_priv->cpp = init->cpp; - - if (dev_priv->sarea_priv) - dev_priv->sarea_priv->pf_current_page = 0; + dev_priv->ring.virtual_start = dev_priv->ring.map.handle; - /* We are using separate values as placeholders for mechanisms for - * private backbuffer/depthbuffer usage. - */ + dev_priv->cpp = init->cpp; + dev_priv->back_offset = init->back_offset; + dev_priv->front_offset = init->front_offset; + dev_priv->current_page = 0; + dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; /* Allow hardware batchbuffers unless told otherwise. */ dev_priv->allow_batchbuffer = 1; - /* Enable vblank on pipe A for older X servers - */ - dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A; - -#ifdef I915_HAVE_BUFFER - mutex_init(&dev_priv->cmdbuf_mutex); -#endif -#if defined(I915_HAVE_BUFFER) - if (init->func == I915_INIT_DMA2) { - ret = setup_dri2_sarea(dev, file_priv, init); - if (ret) { - i915_dma_cleanup(dev); - DRM_ERROR("could not set up dri2 sarea\n"); - return ret; - } - } -#endif - return 0; } @@ -349,9 +243,9 @@ static int i915_dma_resume(struct drm_de DRM_DEBUG("hw status page @ %p\n", dev_priv->hw_status_page); if (dev_priv->status_gfx_addr != 0) - I915_WRITE(0x02080, dev_priv->status_gfx_addr); + I915_WRITE(HWS_PGA, dev_priv->status_gfx_addr); else - I915_WRITE(0x02080, dev_priv->dma_status_page); + I915_WRITE(HWS_PGA, dev_priv->dma_status_page); DRM_DEBUG("Enabled hardware status page\n"); return 0; @@ -365,8 +259,7 @@ static int i915_dma_init(struct drm_devi switch (init->func) { case I915_INIT_DMA: - case I915_INIT_DMA2: - retcode = i915_initialize(dev, file_priv, init); + retcode = i915_initialize(dev, init); break; case I915_CLEANUP_DMA: retcode = i915_dma_cleanup(dev); @@ -541,55 +434,28 @@ int i915_emit_box(struct drm_device * de * emit. For now, do it in both places: */ -void i915_emit_breadcrumb(struct drm_device *dev) +static void i915_emit_breadcrumb(struct drm_device *dev) { drm_i915_private_t *dev_priv = dev->dev_private; RING_LOCALS; - if (++dev_priv->counter > BREADCRUMB_MASK) { - dev_priv->counter = 1; - DRM_DEBUG("Breadcrumb counter wrapped around\n"); - } - + dev_priv->counter++; + if (dev_priv->counter > 0x7FFFFFFFUL) + dev_priv->counter = 0; if (dev_priv->sarea_priv) dev_priv->sarea_priv->last_enqueue = dev_priv->counter; BEGIN_LP_RING(4); OUT_RING(MI_STORE_DWORD_INDEX); - OUT_RING(5 << MI_STORE_DWORD_INDEX_SHIFT); + OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT); OUT_RING(dev_priv->counter); OUT_RING(0); ADVANCE_LP_RING(); } - -int i915_emit_mi_flush(struct drm_device *dev, uint32_t flush) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - uint32_t flush_cmd = MI_FLUSH; - RING_LOCALS; - - flush_cmd |= flush; - - i915_kernel_lost_context(dev); - - BEGIN_LP_RING(4); - OUT_RING(flush_cmd); - OUT_RING(0); - OUT_RING(0); - OUT_RING(0); - ADVANCE_LP_RING(); - - return 0; -} - - static int i915_dispatch_cmdbuffer(struct drm_device * dev, drm_i915_cmdbuffer_t * cmd) { -#ifdef I915_HAVE_FENCE - drm_i915_private_t *dev_priv = dev->dev_private; -#endif int nbox = cmd->num_cliprects; int i = 0, count, ret; @@ -616,15 +482,11 @@ static int i915_dispatch_cmdbuffer(struc } i915_emit_breadcrumb(dev); -#ifdef I915_HAVE_FENCE - if (unlikely((dev_priv->counter & 0xFF) == 0)) - drm_fence_flush_old(dev, 0, dev_priv->counter); -#endif return 0; } -int i915_dispatch_batchbuffer(struct drm_device * dev, - drm_i915_batchbuffer_t * batch) +static int i915_dispatch_batchbuffer(struct drm_device * dev, + drm_i915_batchbuffer_t * batch) { drm_i915_private_t *dev_priv = dev->dev_private; struct drm_clip_rect __user *boxes = batch->cliprects; @@ -649,14 +511,7 @@ int i915_dispatch_batchbuffer(struct drm return ret; } - if (IS_I830(dev) || IS_845G(dev)) { - BEGIN_LP_RING(4); - OUT_RING(MI_BATCH_BUFFER); - OUT_RING(batch->start | MI_BATCH_NON_SECURE); - OUT_RING(batch->start + batch->used - 4); - OUT_RING(0); - ADVANCE_LP_RING(); - } else { + if (!IS_I830(dev) && !IS_845G(dev)) { BEGIN_LP_RING(2); if (IS_I965G(dev)) { OUT_RING(MI_BATCH_BUFFER_START | (2 << 6) | MI_BATCH_NON_SECURE_I965); @@ -666,115 +521,90 @@ int i915_dispatch_batchbuffer(struct drm OUT_RING(batch->start | MI_BATCH_NON_SECURE); } ADVANCE_LP_RING(); + } else { + BEGIN_LP_RING(4); + OUT_RING(MI_BATCH_BUFFER); + OUT_RING(batch->start | MI_BATCH_NON_SECURE); + OUT_RING(batch->start + batch->used - 4); + OUT_RING(0); + ADVANCE_LP_RING(); } } i915_emit_breadcrumb(dev); -#ifdef I915_HAVE_FENCE - if (unlikely((dev_priv->counter & 0xFF) == 0)) - drm_fence_flush_old(dev, 0, dev_priv->counter); -#endif + return 0; } -static void i915_do_dispatch_flip(struct drm_device * dev, int plane, int sync) +static int i915_dispatch_flip(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; - u32 num_pages, current_page, next_page, dspbase; - int shift = 2 * plane, x, y; RING_LOCALS; - /* Calculate display base offset */ - num_pages = dev_priv->sarea_priv->third_handle ? 3 : 2; - current_page = (dev_priv->sarea_priv->pf_current_page >> shift) & 0x3; - next_page = (current_page + 1) % num_pages; + if (!dev_priv->sarea_priv) + return -EINVAL; - switch (next_page) { - default: - case 0: - dspbase = dev_priv->sarea_priv->front_offset; - break; - case 1: - dspbase = dev_priv->sarea_priv->back_offset; - break; - case 2: - dspbase = dev_priv->sarea_priv->third_offset; - break; - } + DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n", + __func__, + dev_priv->current_page, + dev_priv->sarea_priv->pf_current_page); + + i915_kernel_lost_context(dev); - if (plane == 0) { - x = dev_priv->sarea_priv->planeA_x; - y = dev_priv->sarea_priv->planeA_y; + BEGIN_LP_RING(2); + OUT_RING(MI_FLUSH | MI_READ_FLUSH); + OUT_RING(0); + ADVANCE_LP_RING(); + + BEGIN_LP_RING(6); + OUT_RING(CMD_OP_DISPLAYBUFFER_INFO | ASYNC_FLIP); + OUT_RING(0); + if (dev_priv->current_page == 0) { + OUT_RING(dev_priv->back_offset); + dev_priv->current_page = 1; } else { - x = dev_priv->sarea_priv->planeB_x; - y = dev_priv->sarea_priv->planeB_y; + OUT_RING(dev_priv->front_offset); + dev_priv->current_page = 0; } + OUT_RING(0); + ADVANCE_LP_RING(); - dspbase += (y * dev_priv->sarea_priv->pitch + x) * dev_priv->cpp; + BEGIN_LP_RING(2); + OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_A_FLIP); + OUT_RING(0); + ADVANCE_LP_RING(); - DRM_DEBUG("plane=%d current_page=%d dspbase=0x%x\n", plane, current_page, - dspbase); + dev_priv->sarea_priv->last_enqueue = dev_priv->counter++; BEGIN_LP_RING(4); - OUT_RING(sync ? 0 : - (MI_WAIT_FOR_EVENT | (plane ? MI_WAIT_FOR_PLANE_B_FLIP : - MI_WAIT_FOR_PLANE_A_FLIP))); - OUT_RING(CMD_OP_DISPLAYBUFFER_INFO | (sync ? 0 : ASYNC_FLIP) | - (plane ? DISPLAY_PLANE_B : DISPLAY_PLANE_A)); - OUT_RING(dev_priv->sarea_priv->pitch * dev_priv->cpp); - OUT_RING(dspbase); + OUT_RING(MI_STORE_DWORD_INDEX); + OUT_RING(I915_BREADCRUMB_INDEX << MI_STORE_DWORD_INDEX_SHIFT); + OUT_RING(dev_priv->counter); + OUT_RING(0); ADVANCE_LP_RING(); - dev_priv->sarea_priv->pf_current_page &= ~(0x3 << shift); - dev_priv->sarea_priv->pf_current_page |= next_page << shift; -} - -void i915_dispatch_flip(struct drm_device * dev, int planes, int sync) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - int i; - - DRM_DEBUG("planes=0x%x pfCurrentPage=%d\n", - planes, dev_priv->sarea_priv->pf_current_page); - - i915_emit_mi_flush(dev, MI_READ_FLUSH | MI_EXE_FLUSH); - - for (i = 0; i < 2; i++) - if (planes & (1 << i)) - i915_do_dispatch_flip(dev, i, sync); - - i915_emit_breadcrumb(dev); -#ifdef I915_HAVE_FENCE - if (unlikely(!sync && ((dev_priv->counter & 0xFF) == 0))) - drm_fence_flush_old(dev, 0, dev_priv->counter); -#endif + dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; + return 0; } -int i915_quiescent(struct drm_device *dev) +static int i915_quiescent(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; - int ret; i915_kernel_lost_context(dev); - ret = i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); - if (ret) - { - i915_kernel_lost_context (dev); - DRM_ERROR ("not quiescent head %08x tail %08x space %08x\n", - dev_priv->ring.head, - dev_priv->ring.tail, - dev_priv->ring.space); - } - return ret; + return i915_wait_ring(dev, dev_priv->ring.Size - 8, __func__); } static int i915_flush_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { + int ret; - LOCK_TEST_WITH_RETURN(dev, file_priv); + RING_LOCK_TEST_WITH_RETURN(dev, file_priv); - return i915_quiescent(dev); + ret = i915_quiescent(dev); + + return ret; } static int i915_batchbuffer(struct drm_device *dev, void *data, @@ -784,6 +614,7 @@ static int i915_batchbuffer(struct drm_d drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) dev_priv->sarea_priv; drm_i915_batchbuffer_t *batch = data; + size_t cliplen; int ret; if (!dev_priv->allow_batchbuffer) { @@ -794,16 +625,35 @@ static int i915_batchbuffer(struct drm_d DRM_DEBUG("i915 batchbuffer, start %x used %d cliprects %d\n", batch->start, batch->used, batch->num_cliprects); - LOCK_TEST_WITH_RETURN(dev, file_priv); + RING_LOCK_TEST_WITH_RETURN(dev, file_priv); + DRM_UNLOCK(); + cliplen = batch->num_cliprects * sizeof(struct drm_clip_rect); if (batch->num_cliprects && DRM_VERIFYAREA_READ(batch->cliprects, - batch->num_cliprects * - sizeof(struct drm_clip_rect))) + cliplen)) { + DRM_LOCK(); return -EFAULT; + } + if (batch->num_cliprects) { + ret = vslock(batch->cliprects, cliplen); + if (ret) { + DRM_ERROR("Fault wiring cliprects\n"); + DRM_LOCK(); + return -EFAULT; + } + } + DRM_LOCK(); ret = i915_dispatch_batchbuffer(dev, batch); - sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); + if (sarea_priv) + sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); + + DRM_UNLOCK(); + if (batch->num_cliprects) + vsunlock(batch->cliprects, cliplen); + DRM_LOCK(); + return ret; } @@ -814,80 +664,70 @@ static int i915_cmdbuffer(struct drm_dev drm_i915_sarea_t *sarea_priv = (drm_i915_sarea_t *) dev_priv->sarea_priv; drm_i915_cmdbuffer_t *cmdbuf = data; + size_t cliplen; int ret; DRM_DEBUG("i915 cmdbuffer, buf %p sz %d cliprects %d\n", cmdbuf->buf, cmdbuf->sz, cmdbuf->num_cliprects); - LOCK_TEST_WITH_RETURN(dev, file_priv); + RING_LOCK_TEST_WITH_RETURN(dev, file_priv); - if (cmdbuf->num_cliprects && - DRM_VERIFYAREA_READ(cmdbuf->cliprects, - cmdbuf->num_cliprects * - sizeof(struct drm_clip_rect))) { + DRM_UNLOCK(); + cliplen = cmdbuf->num_cliprects * sizeof(struct drm_clip_rect); + if (cmdbuf->num_cliprects && DRM_VERIFYAREA_READ(cmdbuf->cliprects, + cliplen)) { DRM_ERROR("Fault accessing cliprects\n"); + DRM_LOCK(); return -EFAULT; } + if (cmdbuf->num_cliprects) { + ret = vslock(cmdbuf->cliprects, cliplen); + if (ret) { + DRM_ERROR("Fault wiring cliprects\n"); + DRM_LOCK(); + return -EFAULT; + } + ret = vslock(cmdbuf->buf, cmdbuf->sz); + if (ret) { + vsunlock(cmdbuf->cliprects, cliplen); + DRM_ERROR("Fault wiring cmds\n"); + DRM_LOCK(); + return -EFAULT; + } + } + DRM_LOCK(); ret = i915_dispatch_cmdbuffer(dev, cmdbuf); + DRM_UNLOCK(); + if (cmdbuf->num_cliprects) { + vsunlock(cmdbuf->buf, cmdbuf->sz); + vsunlock(cmdbuf->cliprects, cliplen); + } + DRM_LOCK(); if (ret) { DRM_ERROR("i915_dispatch_cmdbuffer failed\n"); return ret; } - sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); - return 0; -} - -#if defined(DRM_DEBUG_CODE) -#define DRM_DEBUG_RELOCATION (drm_debug != 0) -#else -#define DRM_DEBUG_RELOCATION 0 -#endif - -static int i915_do_cleanup_pageflip(struct drm_device * dev) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - int i, planes, num_pages = dev_priv->sarea_priv->third_handle ? 3 : 2; - - DRM_DEBUG("\n"); - - for (i = 0, planes = 0; i < 2; i++) - if (dev_priv->sarea_priv->pf_current_page & (0x3 << (2 * i))) { - dev_priv->sarea_priv->pf_current_page = - (dev_priv->sarea_priv->pf_current_page & - ~(0x3 << (2 * i))) | ((num_pages - 1) << (2 * i)); - - planes |= 1 << i; - } - - if (planes) - i915_dispatch_flip(dev, planes, 0); - + if (sarea_priv) + sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); return 0; } -static int i915_flip_bufs(struct drm_device *dev, void *data, struct drm_file *file_priv) +static int i915_flip_bufs(struct drm_device *dev, void *data, + struct drm_file *file_priv) { - drm_i915_flip_t *param = data; + int ret; - DRM_DEBUG("\n"); + DRM_DEBUG("%s\n", __func__); LOCK_TEST_WITH_RETURN(dev, file_priv); - /* This is really planes */ - if (param->pipes & ~0x3) { - DRM_ERROR("Invalid planes 0x%x, only <= 0x3 is valid\n", - param->pipes); - return -EINVAL; - } - - i915_dispatch_flip(dev, param->pipes, 0); + ret = i915_dispatch_flip(dev); - return 0; + return ret; } - static int i915_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -958,63 +798,6 @@ static int i915_setparam(struct drm_devi return 0; } -drm_i915_mmio_entry_t mmio_table[] = { - [MMIO_REGS_PS_DEPTH_COUNT] = { - I915_MMIO_MAY_READ|I915_MMIO_MAY_WRITE, - 0x2350, - 8 - } -}; - -static int mmio_table_size = sizeof(mmio_table)/sizeof(drm_i915_mmio_entry_t); - -static int i915_mmio(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - uint32_t buf[8]; - drm_i915_private_t *dev_priv = dev->dev_private; - drm_i915_mmio_entry_t *e; - drm_i915_mmio_t *mmio = data; - void __iomem *base; - int i; - - if (!dev_priv) { - DRM_ERROR("called with no initialization\n"); - return -EINVAL; - } - - if (mmio->reg >= mmio_table_size) - return -EINVAL; - - e = &mmio_table[mmio->reg]; - base = (u8 *) dev_priv->mmio_map->handle + e->offset; - - switch (mmio->read_write) { - case I915_MMIO_READ: - if (!(e->flag & I915_MMIO_MAY_READ)) - return -EINVAL; - for (i = 0; i < e->size / 4; i++) - buf[i] = I915_READ(e->offset + i * 4); - if (DRM_COPY_TO_USER(mmio->data, buf, e->size)) { - DRM_ERROR("DRM_COPY_TO_USER failed\n"); - return -EFAULT; - } - break; - - case I915_MMIO_WRITE: - if (!(e->flag & I915_MMIO_MAY_WRITE)) - return -EINVAL; - if (DRM_COPY_FROM_USER(buf, mmio->data, e->size)) { - DRM_ERROR("DRM_COPY_TO_USER failed\n"); - return -EFAULT; - } - for (i = 0; i < e->size / 4; i++) - I915_WRITE(e->offset + i * 4, buf[i]); - break; - } - return 0; -} - static int i915_set_status_page(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -1028,6 +811,7 @@ static int i915_set_status_page(struct d DRM_ERROR("called with no initialization\n"); return -EINVAL; } + DRM_DEBUG("set status page addr 0x%08x\n", (u32)hws->addr); dev_priv->status_gfx_addr = hws->addr & (0x1ffff<<12); @@ -1050,7 +834,7 @@ static int i915_set_status_page(struct d memset(dev_priv->hw_status_page, 0, PAGE_SIZE); I915_WRITE(HWS_PGA, dev_priv->status_gfx_addr); - DRM_DEBUG("load hws 0x2080 with gfx mem 0x%x\n", + DRM_DEBUG("load hws HWS_PGA with gfx mem 0x%x\n", dev_priv->status_gfx_addr); DRM_DEBUG("load hws at %p\n", dev_priv->hw_status_page); return 0; @@ -1058,7 +842,7 @@ static int i915_set_status_page(struct d int i915_driver_load(struct drm_device *dev, unsigned long flags) { - struct drm_i915_private *dev_priv; + struct drm_i915_private *dev_priv = dev->dev_private; unsigned long base, size; int ret = 0, mmio_bar = IS_I9XX(dev) ? 0 : 1; @@ -1083,27 +867,34 @@ int i915_driver_load(struct drm_device * size = drm_get_resource_len(dev, mmio_bar); ret = drm_addmap(dev, base, size, _DRM_REGISTERS, - _DRM_KERNEL | _DRM_DRIVER, &dev_priv->mmio_map); + _DRM_KERNEL | _DRM_DRIVER, &dev_priv->mmio_map); #ifdef I915_HAVE_GEM i915_gem_load(dev); #endif - DRM_SPININIT(&dev_priv->user_irq_lock, "userirq"); - -#ifdef __linux__ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) - intel_init_chipset_flush_compat(dev); -#endif -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25) - intel_opregion_init(dev); -#endif -#endif - /* Init HWS */ if (!I915_NEED_GFX_HWS(dev)) { - ret = i915_init_hardware_status(dev); - if(ret) + ret = i915_init_phys_hws(dev); + if (ret != 0) return ret; } +#ifdef __linux__ + /* On the 945G/GM, the chipset reports the MSI capability on the + * integrated graphics even though the support isn't actually there + * according to the published specs. It doesn't appear to function + * correctly in testing on 945G. + * This may be a side effect of MSI having been made available for PEG + * and the registers being closely associated. + * + * According to chipset errata, on the 965GM, MSI interrupts may + * be lost or delayed + */ + if (!IS_I945G(dev) && !IS_I945GM(dev) && !IS_I965GM(dev)) + if (pci_enable_msi(dev->pdev)) + DRM_ERROR("failed to enable MSI\n"); + + intel_opregion_init(dev); +#endif + DRM_SPININIT(&dev_priv->user_irq_lock, "userirq"); return ret; } @@ -1112,71 +903,20 @@ int i915_driver_unload(struct drm_device { struct drm_i915_private *dev_priv = dev->dev_private; - i915_free_hardware_status(dev); - - drm_rmmap(dev, dev_priv->mmio_map); - - DRM_SPINUNINIT(&dev_priv->user_irq_lock); + i915_free_hws(dev); + drm_rmmap(dev, dev_priv->mmio_map); #ifdef __linux__ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25) intel_opregion_free(dev); #endif -#endif + DRM_SPINUNINIT(&dev_priv->user_irq_lock); drm_free(dev->dev_private, sizeof(drm_i915_private_t), DRM_MEM_DRIVER); - dev->dev_private = NULL; -#ifdef __linux__ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) - intel_fini_chipset_flush_compat(dev); -#endif -#endif return 0; } -void i915_driver_lastclose(struct drm_device * dev) -{ - drm_i915_private_t *dev_priv = dev->dev_private; - - /* agp off can use this to get called before dev_priv */ - if (!dev_priv) - return; - -#ifdef I915_HAVE_BUFFER - if (dev_priv->val_bufs) { - vfree(dev_priv->val_bufs); - dev_priv->val_bufs = NULL; - } -#endif -#ifdef I915_HAVE_GEM - i915_gem_lastclose(dev); -#endif - if (drm_getsarea(dev) && dev_priv->sarea_priv) - i915_do_cleanup_pageflip(dev); - if (dev_priv->sarea_priv) - dev_priv->sarea_priv = NULL; - if (dev_priv->agp_heap) - i915_mem_takedown(&(dev_priv->agp_heap)); -#if defined(I915_HAVE_BUFFER) - if (dev_priv->sarea_kmap.virtual) { - drm_bo_kunmap(&dev_priv->sarea_kmap); - dev_priv->sarea_kmap.virtual = NULL; - dev->lock.hw_lock = NULL; - dev->sigdata.lock = NULL; - } - - if (dev_priv->sarea_bo) { - mutex_lock(&dev->struct_mutex); - drm_bo_usage_deref_locked(&dev_priv->sarea_bo); - mutex_unlock(&dev->struct_mutex); - dev_priv->sarea_bo = NULL; - } -#endif - i915_dma_cleanup(dev); -} - int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv) { struct drm_i915_file_private *i915_file_priv; @@ -1196,6 +936,21 @@ int i915_driver_open(struct drm_device * return 0; } +void i915_driver_lastclose(struct drm_device * dev) +{ + drm_i915_private_t *dev_priv = dev->dev_private; + + if (!dev_priv) + return; +#ifdef I915_HAVE_GEM + i915_gem_lastclose(dev); +#endif + if (dev_priv->agp_heap) + i915_mem_takedown(&(dev_priv->agp_heap)); + + i915_dma_cleanup(dev); +} + void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) { drm_i915_private_t *dev_priv = dev->dev_private; @@ -1226,20 +981,16 @@ struct drm_ioctl_desc i915_ioctls[] = { DRM_IOCTL_DEF(DRM_I915_SET_VBLANK_PIPE, i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY ), DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ), DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH), - DRM_IOCTL_DEF(DRM_I915_MMIO, i915_mmio, DRM_AUTH), DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), -#ifdef I915_HAVE_BUFFER - DRM_IOCTL_DEF(DRM_I915_EXECBUFFER, i915_execbuffer, DRM_AUTH), -#endif #ifdef I915_HAVE_GEM - DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH), + DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH), DRM_IOCTL_DEF(DRM_I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH), DRM_IOCTL_DEF(DRM_I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH), *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From rnoland at FreeBSD.org Tue Mar 10 18:56:18 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 18:56:30 2009 Subject: svn commit: r189666 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110156.n2B1uHQe080234@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 01:56:17 2009 New Revision: 189666 URL: http://svn.freebsd.org/changeset/base/189666 Log: Merge r189050 Add some vblank related debugging and replace the DRM_WAIT_ON macro with a localized version. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_irq.c Modified: stable/7/sys/dev/drm/drm_irq.c ============================================================================== --- stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:54:41 2009 (r189665) +++ stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:56:17 2009 (r189666) @@ -301,6 +301,7 @@ int drm_vblank_get(struct drm_device *de DRM_SPINLOCK_IRQSAVE(&dev->vbl_lock, irqflags); /* Going from 0->1 means we have to enable interrupts again */ atomic_add_acq_int(&dev->vblank[crtc].refcount, 1); + DRM_DEBUG("vblank refcount = %d\n", dev->vblank[crtc].refcount); if (dev->vblank[crtc].refcount == 1 && !dev->vblank[crtc].enabled) { ret = dev->driver->enable_vblank(dev, crtc); @@ -323,6 +324,7 @@ void drm_vblank_put(struct drm_device *d DRM_SPINLOCK_IRQSAVE(&dev->vbl_lock, irqflags); /* Last user schedules interrupt disable */ atomic_subtract_acq_int(&dev->vblank[crtc].refcount, 1); + DRM_DEBUG("vblank refcount = %d\n", dev->vblank[crtc].refcount); if (dev->vblank[crtc].refcount == 0) callout_reset(&dev->vblank_disable_timer, 5 * DRM_HZ, (timeout_t *)vblank_disable_fn, (void *)dev); @@ -385,8 +387,8 @@ out: int drm_wait_vblank(struct drm_device *dev, void *data, struct drm_file *file_priv) { union drm_wait_vblank *vblwait = data; + unsigned int flags, seq, crtc; int ret = 0; - int flags, seq, crtc; if (!dev->irq_enabled) return EINVAL; @@ -406,8 +408,10 @@ int drm_wait_vblank(struct drm_device *d return EINVAL; ret = drm_vblank_get(dev, crtc); - if (ret) + if (ret) { + DRM_ERROR("failed to acquire vblank counter, %d\n", ret); return ret; + } seq = drm_vblank_count(dev, crtc); switch (vblwait->request.type & _DRM_VBLANK_TYPES_MASK) { @@ -446,14 +450,20 @@ int drm_wait_vblank(struct drm_device *d #endif ret = EINVAL; } else { - DRM_LOCK(); - /* shared code returns -errno */ - - DRM_WAIT_ON(ret, dev->vblank[crtc].queue, 3 * DRM_HZ, - ((drm_vblank_count(dev, crtc) - - vblwait->request.sequence) <= (1 << 23))); - DRM_UNLOCK(); + DRM_DEBUG("waiting on vblank count %d, crtc %d\n", + vblwait->request.sequence, crtc); + for ( ret = 0 ; !ret && !((drm_vblank_count(dev, crtc) - + vblwait->request.sequence) <= (1 << 23)) ; ) { + mtx_lock(&dev->irq_lock); + if (!((drm_vblank_count(dev, crtc) - + vblwait->request.sequence) <= (1 << 23))) + ret = mtx_sleep(&dev->vblank[crtc].queue, + &dev->irq_lock, PCATCH, "vblwtq", + 3 * DRM_HZ); + mtx_unlock(&dev->irq_lock); + } + DRM_DEBUG("return = %d\n", ret); if (ret != EINTR) { struct timeval now; @@ -461,6 +471,10 @@ int drm_wait_vblank(struct drm_device *d vblwait->reply.tval_sec = now.tv_sec; vblwait->reply.tval_usec = now.tv_usec; vblwait->reply.sequence = drm_vblank_count(dev, crtc); + DRM_DEBUG("returning %d to client\n", + vblwait->reply.sequence); + } else { + DRM_DEBUG("vblank wait interrupted by signal\n"); } } From rnoland at FreeBSD.org Tue Mar 10 18:57:21 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 18:57:37 2009 Subject: svn commit: r189667 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110157.n2B1vKH8080303@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 01:57:20 2009 New Revision: 189667 URL: http://svn.freebsd.org/changeset/base/189667 Log: Merge r189051 Prepare the radeon driver for MSI support. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/radeon_irq.c Modified: stable/7/sys/dev/drm/radeon_irq.c ============================================================================== --- stable/7/sys/dev/drm/radeon_irq.c Wed Mar 11 01:56:17 2009 (r189666) +++ stable/7/sys/dev/drm/radeon_irq.c Wed Mar 11 01:57:20 2009 (r189667) @@ -192,6 +192,7 @@ irqreturn_t radeon_driver_irq_handler(DR (drm_radeon_private_t *) dev->dev_private; u32 stat; u32 r500_disp_int; + u32 tmp; /* Only consider the bits we're interested in - others could be used * outside the DRM @@ -218,6 +219,33 @@ irqreturn_t radeon_driver_irq_handler(DR if (stat & RADEON_CRTC2_VBLANK_STAT) drm_handle_vblank(dev, 1); } + if (dev->msi_enabled) { + switch(dev_priv->flags & RADEON_FAMILY_MASK) { + case CHIP_RS400: + case CHIP_RS480: + tmp = RADEON_READ(RADEON_AIC_CNTL) & + ~RS400_MSI_REARM; + RADEON_WRITE(RADEON_AIC_CNTL, tmp); + RADEON_WRITE(RADEON_AIC_CNTL, + tmp | RS400_MSI_REARM); + break; + case CHIP_RS690: + case CHIP_RS740: + tmp = RADEON_READ(RADEON_BUS_CNTL) & + ~RS600_MSI_REARM; + RADEON_WRITE(RADEON_BUS_CNTL, tmp); + RADEON_WRITE(RADEON_BUS_CNTL, tmp | + RS600_MSI_REARM); + break; + default: + tmp = RADEON_READ(RADEON_MSI_REARM_EN) & + ~RV370_MSI_REARM_EN; + RADEON_WRITE(RADEON_MSI_REARM_EN, tmp); + RADEON_WRITE(RADEON_MSI_REARM_EN, + tmp | RV370_MSI_REARM_EN); + break; + } + } return IRQ_HANDLED; } From rnoland at FreeBSD.org Tue Mar 10 18:58:38 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 18:58:56 2009 Subject: svn commit: r189668 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110158.n2B1wbM4080380@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 01:58:37 2009 New Revision: 189668 URL: http://svn.freebsd.org/changeset/base/189668 Log: Merge r189052 Turn on MSI if the card supports it. There is a blacklist for chips which report that they are capable of MSI, but don't work correctly. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/drm_drv.c stable/7/sys/dev/drm/drm_irq.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:57:20 2009 (r189667) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 01:58:37 2009 (r189668) @@ -319,6 +319,12 @@ typedef struct drm_pci_id_list char *name; } drm_pci_id_list_t; +struct drm_msi_blacklist_entry +{ + int vendor; + int device; +}; + #define DRM_AUTH 0x1 #define DRM_MASTER 0x2 #define DRM_ROOT_ONLY 0x4 Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:57:20 2009 (r189667) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:58:37 2009 (r189668) @@ -134,6 +134,27 @@ static struct cdevsw drm_cdevsw = { .d_flags = D_TRACKCLOSE | D_NEEDGIANT }; +static struct drm_msi_blacklist_entry drm_msi_blacklist[] = { + {0x8086, 0x2772}, /* Intel i945G */ \ + {0x8086, 0x27A2}, /* Intel i945GM */ \ + {0x8086, 0x27AE}, /* Intel i945GME */ \ + {0, 0} +}; + +static int drm_msi_is_blacklisted(int vendor, int device) +{ + int i = 0; + + for (i = 0; drm_msi_blacklist[i].vendor != 0; i++) { + if ((drm_msi_blacklist[i].vendor == vendor) && + (drm_msi_blacklist[i].device == device)) { + return 1; + } + } + + return 0; +} + int drm_probe(device_t dev, drm_pci_id_list_t *idlist) { drm_pci_id_list_t *id_entry; @@ -169,7 +190,7 @@ int drm_attach(device_t nbdev, drm_pci_i { struct drm_device *dev; drm_pci_id_list_t *id_entry; - int unit; + int unit, msicount; unit = device_get_unit(nbdev); dev = device_get_softc(nbdev); @@ -189,21 +210,66 @@ int drm_attach(device_t nbdev, drm_pci_i DRM_DEV_MODE, "dri/card%d", unit); +#if __FreeBSD_version >= 700053 + dev->pci_domain = pci_get_domain(dev->device); +#else + dev->pci_domain = 0; +#endif + dev->pci_bus = pci_get_bus(dev->device); + dev->pci_slot = pci_get_slot(dev->device); + dev->pci_func = pci_get_function(dev->device); + + dev->pci_vendor = pci_get_vendor(dev->device); + dev->pci_device = pci_get_device(dev->device); + + if (!drm_msi_is_blacklisted(dev->pci_vendor, dev->pci_device)) { + msicount = pci_msi_count(dev->device); + DRM_DEBUG("MSI count = %d\n", msicount); + if (msicount > 1) + msicount = 1; + + if (pci_alloc_msi(dev->device, &msicount) == 0) { + DRM_INFO("MSI enabled %d message(s)\n", msicount); + dev->msi_enabled = 1; + dev->irqrid = 1; + } + } + + dev->irqr = bus_alloc_resource_any(dev->device, SYS_RES_IRQ, + &dev->irqrid, RF_SHAREABLE); + if (!dev->irqr) { + return ENOENT; + } + + dev->irq = (int) rman_get_start(dev->irqr); + mtx_init(&dev->dev_lock, "drmdev", NULL, MTX_DEF); mtx_init(&dev->irq_lock, "drmirq", NULL, MTX_DEF); mtx_init(&dev->vbl_lock, "drmvbl", NULL, MTX_DEF); mtx_init(&dev->drw_lock, "drmdrw", NULL, MTX_DEF); - id_entry = drm_find_description(pci_get_vendor(dev->device), - pci_get_device(dev->device), idlist); + id_entry = drm_find_description(dev->pci_vendor, + dev->pci_device, idlist); dev->id_entry = id_entry; return drm_load(dev); } -int drm_detach(device_t dev) +int drm_detach(device_t nbdev) { - drm_unload(device_get_softc(dev)); + struct drm_device *dev; + + dev = device_get_softc(nbdev); + + drm_unload(dev); + + bus_release_resource(dev->device, SYS_RES_IRQ, dev->irqrid, dev->irqr); + + if (dev->msi_enabled) { + pci_release_msi(dev->device); + DRM_INFO("MSI released\n"); + } + return 0; } @@ -352,19 +418,6 @@ static int drm_load(struct drm_device *d DRM_DEBUG("\n"); - dev->irq = pci_get_irq(dev->device); -#if __FreeBSD_version >= 700053 - dev->pci_domain = pci_get_domain(dev->device); -#else - dev->pci_domain = 0; -#endif - dev->pci_bus = pci_get_bus(dev->device); - dev->pci_slot = pci_get_slot(dev->device); - dev->pci_func = pci_get_function(dev->device); - - dev->pci_vendor = pci_get_vendor(dev->device); - dev->pci_device = pci_get_device(dev->device); - TAILQ_INIT(&dev->maplist); drm_mem_init(); Modified: stable/7/sys/dev/drm/drm_irq.c ============================================================================== --- stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:57:20 2009 (r189667) +++ stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 01:58:37 2009 (r189668) @@ -172,13 +172,6 @@ int drm_irq_install(struct drm_device *d DRM_UNLOCK(); /* Install handler */ - dev->irqrid = 0; - dev->irqr = bus_alloc_resource_any(dev->device, SYS_RES_IRQ, - &dev->irqrid, RF_SHAREABLE); - if (!dev->irqr) { - retcode = ENOENT; - goto err; - } #if __FreeBSD_version >= 700031 retcode = bus_setup_intr(dev->device, dev->irqr, INTR_TYPE_TTY | INTR_MPSAFE, @@ -200,25 +193,17 @@ int drm_irq_install(struct drm_device *d err: DRM_LOCK(); dev->irq_enabled = 0; - if (dev->irqrid != 0) { - bus_release_resource(dev->device, SYS_RES_IRQ, dev->irqrid, - dev->irqr); - dev->irqrid = 0; - } DRM_UNLOCK(); + return retcode; } int drm_irq_uninstall(struct drm_device *dev) { - int irqrid; - if (!dev->irq_enabled) return EINVAL; dev->irq_enabled = 0; - irqrid = dev->irqrid; - dev->irqrid = 0; DRM_DEBUG("irq=%d\n", dev->irq); @@ -226,7 +211,6 @@ int drm_irq_uninstall(struct drm_device DRM_UNLOCK(); bus_teardown_intr(dev->device, dev->irqr, dev->irqh); - bus_release_resource(dev->device, SYS_RES_IRQ, irqrid, dev->irqr); DRM_LOCK(); drm_vblank_cleanup(dev); From rnoland at FreeBSD.org Tue Mar 10 19:00:14 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 19:00:50 2009 Subject: svn commit: r189669 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110200.n2B20DKq080493@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 02:00:13 2009 New Revision: 189669 URL: http://svn.freebsd.org/changeset/base/189669 Log: Merge r189053 Remove D_NEEDGIANT Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_drv.c Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 01:58:37 2009 (r189668) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:00:13 2009 (r189669) @@ -131,7 +131,7 @@ static struct cdevsw drm_cdevsw = { .d_poll = drm_poll, .d_mmap = drm_mmap, .d_name = "drm", - .d_flags = D_TRACKCLOSE | D_NEEDGIANT + .d_flags = D_TRACKCLOSE }; static struct drm_msi_blacklist_entry drm_msi_blacklist[] = { From rnoland at FreeBSD.org Tue Mar 10 19:13:48 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 19:13:55 2009 Subject: svn commit: r189670 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110213.n2B2DkSW080810@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 02:13:46 2009 New Revision: 189670 URL: http://svn.freebsd.org/changeset/base/189670 Log: Merge r189054 The GM45 handles vblank differently. Pull the changes from Intel in. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/i915_dma.c stable/7/sys/dev/drm/i915_drv.c stable/7/sys/dev/drm/i915_drv.h stable/7/sys/dev/drm/i915_irq.c stable/7/sys/dev/drm/i915_reg.h Modified: stable/7/sys/dev/drm/i915_dma.c ============================================================================== --- stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 02:00:13 2009 (r189669) +++ stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 02:13:46 2009 (r189670) @@ -868,6 +868,12 @@ int i915_driver_load(struct drm_device * ret = drm_addmap(dev, base, size, _DRM_REGISTERS, _DRM_KERNEL | _DRM_DRIVER, &dev_priv->mmio_map); + + if (IS_GM45(dev)) + dev->driver->get_vblank_counter = gm45_get_vblank_counter; + else + dev->driver->get_vblank_counter = i915_get_vblank_counter; + #ifdef I915_HAVE_GEM i915_gem_load(dev); #endif Modified: stable/7/sys/dev/drm/i915_drv.c ============================================================================== --- stable/7/sys/dev/drm/i915_drv.c Wed Mar 11 02:00:13 2009 (r189669) +++ stable/7/sys/dev/drm/i915_drv.c Wed Mar 11 02:13:46 2009 (r189670) @@ -81,7 +81,6 @@ static void i915_configure(struct drm_de dev->driver->preclose = i915_driver_preclose; dev->driver->lastclose = i915_driver_lastclose; dev->driver->device_is_agp = i915_driver_device_is_agp; - dev->driver->get_vblank_counter = i915_get_vblank_counter; dev->driver->enable_vblank = i915_enable_vblank; dev->driver->disable_vblank = i915_disable_vblank; dev->driver->irq_preinstall = i915_driver_irq_preinstall; Modified: stable/7/sys/dev/drm/i915_drv.h ============================================================================== --- stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 02:00:13 2009 (r189669) +++ stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 02:13:46 2009 (r189670) @@ -449,6 +449,7 @@ extern int i915_vblank_pipe_get(struct d extern int i915_enable_vblank(struct drm_device *dev, int crtc); extern void i915_disable_vblank(struct drm_device *dev, int crtc); extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc); +extern u32 gm45_get_vblank_counter(struct drm_device *dev, int crtc); extern int i915_vblank_swap(struct drm_device *dev, void *data, struct drm_file *file_priv); Modified: stable/7/sys/dev/drm/i915_irq.c ============================================================================== --- stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 02:00:13 2009 (r189669) +++ stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 02:13:46 2009 (r189670) @@ -170,6 +170,19 @@ u32 i915_get_vblank_counter(struct drm_d return count; } +u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe) +{ + drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; + int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45; + + if (!i915_pipe_enabled(dev, pipe)) { + DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe); + return 0; + } + + return I915_READ(reg); +} + irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) { struct drm_device *dev = (struct drm_device *) arg; Modified: stable/7/sys/dev/drm/i915_reg.h ============================================================================== --- stable/7/sys/dev/drm/i915_reg.h Wed Mar 11 02:00:13 2009 (r189669) +++ stable/7/sys/dev/drm/i915_reg.h Wed Mar 11 02:13:46 2009 (r189670) @@ -1329,6 +1329,9 @@ __FBSDID("$FreeBSD$"); #define PIPE_FRAME_LOW_SHIFT 24 #define PIPE_PIXEL_MASK 0x00ffffff #define PIPE_PIXEL_SHIFT 0 +/* GM45+ just has to be different */ +#define PIPEA_FRMCOUNT_GM45 0x70040 +#define PIPEA_FLIPCOUNT_GM45 0x70044 /* Cursor A & B regs */ #define CURACNTR 0x70080 @@ -1397,6 +1400,8 @@ __FBSDID("$FreeBSD$"); #define PIPEBSTAT 0x71024 #define PIPEBFRAMEHIGH 0x71040 #define PIPEBFRAMEPIXEL 0x71044 +#define PIPEB_FRMCOUNT_GM45 0x71040 +#define PIPEB_FLIPCOUNT_GM45 0x71044 /* Display B control */ #define DSPBCNTR 0x71180 From rnoland at FreeBSD.org Tue Mar 10 19:36:22 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 19:36:34 2009 Subject: svn commit: r189671 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110236.n2B2aKvX081293@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 02:36:20 2009 New Revision: 189671 URL: http://svn.freebsd.org/changeset/base/189671 Log: Merge r189099 Fix up some ioctl permissions issues long overlooked. Submitted by: jkim@ Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/drm_bufs.c stable/7/sys/dev/drm/drm_drv.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 02:13:46 2009 (r189670) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 02:36:20 2009 (r189671) @@ -901,8 +901,8 @@ int drm_addmap_ioctl(struct drm_device * struct drm_file *file_priv); int drm_rmmap_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); -int drm_addbufs_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv); +int drm_addbufs(struct drm_device *dev, void *data, + struct drm_file *file_priv); int drm_infobufs(struct drm_device *dev, void *data, struct drm_file *file_priv); int drm_markbufs(struct drm_device *dev, void *data, Modified: stable/7/sys/dev/drm/drm_bufs.c ============================================================================== --- stable/7/sys/dev/drm/drm_bufs.c Wed Mar 11 02:13:46 2009 (r189670) +++ stable/7/sys/dev/drm/drm_bufs.c Wed Mar 11 02:36:20 2009 (r189671) @@ -880,8 +880,7 @@ int drm_addbufs_pci(struct drm_device *d return ret; } -int drm_addbufs_ioctl(struct drm_device *dev, void *data, - struct drm_file *file_priv) +int drm_addbufs(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_buf_desc *request = data; int err; Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:13:46 2009 (r189670) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:36:20 2009 (r189671) @@ -82,7 +82,7 @@ static drm_ioctl_desc_t drm_ioctls[25 DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_getsareactx, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH), @@ -95,10 +95,11 @@ static drm_ioctl_desc_t drm_ioctls[25 DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH), DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH), + DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH), - DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER), + DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH), DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH), DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH), @@ -117,7 +118,6 @@ static drm_ioctl_desc_t drm_ioctls[25 DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, 0), DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0), DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_draw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), From rnoland at FreeBSD.org Tue Mar 10 19:37:53 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 19:37:58 2009 Subject: svn commit: r189672 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110237.n2B2bqdD081373@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 02:37:52 2009 New Revision: 189672 URL: http://svn.freebsd.org/changeset/base/189672 Log: Merge r189128 Add a tuneable to allow disabling msi on drm at runtime. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_drv.c Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:36:20 2009 (r189671) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:37:52 2009 (r189672) @@ -134,6 +134,9 @@ static struct cdevsw drm_cdevsw = { .d_flags = D_TRACKCLOSE }; +int drm_msi = 1; /* Enable by default. */ +TUNABLE_INT("hw.drm.msi", &drm_msi); + static struct drm_msi_blacklist_entry drm_msi_blacklist[] = { {0x8086, 0x2772}, /* Intel i945G */ \ {0x8086, 0x27A2}, /* Intel i945GM */ \ @@ -222,7 +225,8 @@ int drm_attach(device_t nbdev, drm_pci_i dev->pci_vendor = pci_get_vendor(dev->device); dev->pci_device = pci_get_device(dev->device); - if (!drm_msi_is_blacklisted(dev->pci_vendor, dev->pci_device)) { + if (drm_msi && + !drm_msi_is_blacklisted(dev->pci_vendor, dev->pci_device)) { msicount = pci_msi_count(dev->device); DRM_DEBUG("MSI count = %d\n", msicount); if (msicount > 1) From rnoland at FreeBSD.org Tue Mar 10 19:39:04 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Tue Mar 10 19:39:22 2009 Subject: svn commit: r189673 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903110239.n2B2d2kY081443@svn.freebsd.org> Author: rnoland Date: Wed Mar 11 02:39:02 2009 New Revision: 189673 URL: http://svn.freebsd.org/changeset/base/189673 Log: Merge 189130 Initialize the vblank structures at load time. Previously we did this at irq install/uninstall time, but when we vt switch, we uninstall the irq handler. When the irq handler is reinstalled, the modeset ioctl happens first. The modeset ioctl is supposed to tell us that we can disable vblank interrupts if there are no active consumers. This will fail after a vt switch until another modeset ioctl is called via dpms or xrandr. Leading to cases where either interrupts are on and can't be disabled, or worse, no interrupts at all. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/drm_drv.c stable/7/sys/dev/drm/drm_irq.c stable/7/sys/dev/drm/i915_dma.c stable/7/sys/dev/drm/i915_drv.h stable/7/sys/dev/drm/i915_irq.c stable/7/sys/dev/drm/mach64_drv.c stable/7/sys/dev/drm/mach64_drv.h stable/7/sys/dev/drm/mach64_irq.c stable/7/sys/dev/drm/mga_dma.c stable/7/sys/dev/drm/mga_irq.c stable/7/sys/dev/drm/r128_drv.c stable/7/sys/dev/drm/r128_drv.h stable/7/sys/dev/drm/r128_irq.c stable/7/sys/dev/drm/radeon_cp.c stable/7/sys/dev/drm/radeon_irq.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/drmP.h Wed Mar 11 02:39:02 2009 (r189673) @@ -794,6 +794,7 @@ void drm_handle_vblank(struct drm_device u32 drm_vblank_count(struct drm_device *dev, int crtc); int drm_vblank_get(struct drm_device *dev, int crtc); void drm_vblank_put(struct drm_device *dev, int crtc); +void drm_vblank_cleanup(struct drm_device *dev); int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); int drm_vblank_init(struct drm_device *dev, int num_crtcs); void drm_vbl_send_signals(struct drm_device *dev, int crtc); Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/drm_drv.c Wed Mar 11 02:39:02 2009 (r189673) @@ -523,6 +523,8 @@ static void drm_unload(struct drm_device DRM_DEBUG("mtrr_del = %d", retcode); } + drm_vblank_cleanup(dev); + DRM_LOCK(); drm_lastclose(dev); DRM_UNLOCK(); Modified: stable/7/sys/dev/drm/drm_irq.c ============================================================================== --- stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/drm_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -96,7 +96,7 @@ static void vblank_disable_fn(void *arg) } } -static void drm_vblank_cleanup(struct drm_device *dev) +void drm_vblank_cleanup(struct drm_device *dev) { unsigned long irqflags; @@ -213,8 +213,6 @@ int drm_irq_uninstall(struct drm_device bus_teardown_intr(dev->device, dev->irqr, dev->irqh); DRM_LOCK(); - drm_vblank_cleanup(dev); - return 0; } Modified: stable/7/sys/dev/drm/i915_dma.c ============================================================================== --- stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/i915_dma.c Wed Mar 11 02:39:02 2009 (r189673) @@ -902,6 +902,13 @@ int i915_driver_load(struct drm_device * #endif DRM_SPININIT(&dev_priv->user_irq_lock, "userirq"); + ret = drm_vblank_init(dev, I915_NUM_PIPE); + + if (ret) { + (void) i915_driver_unload(dev); + return ret; + } + return ret; } Modified: stable/7/sys/dev/drm/i915_drv.h ============================================================================== --- stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/i915_drv.h Wed Mar 11 02:39:02 2009 (r189673) @@ -49,6 +49,8 @@ enum pipe { PIPE_B, }; +#define I915_NUM_PIPE 2 + /* Interface history: * * 1.1: Original. Modified: stable/7/sys/dev/drm/i915_irq.c ============================================================================== --- stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/i915_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -484,11 +484,6 @@ void i915_driver_irq_preinstall(struct d int i915_driver_irq_postinstall(struct drm_device *dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; - int ret, num_pipes = 2; - - ret = drm_vblank_init(dev, num_pipes); - if (ret) - return ret; dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; Modified: stable/7/sys/dev/drm/mach64_drv.c ============================================================================== --- stable/7/sys/dev/drm/mach64_drv.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/mach64_drv.c Wed Mar 11 02:39:02 2009 (r189673) @@ -54,6 +54,7 @@ static void mach64_configure(struct drm_ DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; dev->driver->buf_priv_size = 1; /* No dev_priv */ + dev->driver->load = mach64_driver_load; dev->driver->lastclose = mach64_driver_lastclose; dev->driver->get_vblank_counter = mach64_get_vblank_counter; dev->driver->enable_vblank = mach64_enable_vblank; @@ -94,6 +95,12 @@ mach64_attach(device_t nbdev) return drm_attach(nbdev, mach64_pciidlist); } +int +mach64_driver_load(struct drm_device * dev, unsigned long flags) +{ + return drm_vblank_init(dev, 1); +} + static int mach64_detach(device_t nbdev) { Modified: stable/7/sys/dev/drm/mach64_drv.h ============================================================================== --- stable/7/sys/dev/drm/mach64_drv.h Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/mach64_drv.h Wed Mar 11 02:39:02 2009 (r189673) @@ -166,6 +166,7 @@ extern int mach64_dma_blit(struct drm_de extern int mach64_get_param(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int mach64_driver_load(struct drm_device * dev, unsigned long flags); extern u32 mach64_get_vblank_counter(struct drm_device *dev, int crtc); extern int mach64_enable_vblank(struct drm_device *dev, int crtc); extern void mach64_disable_vblank(struct drm_device *dev, int crtc); Modified: stable/7/sys/dev/drm/mach64_irq.c ============================================================================== --- stable/7/sys/dev/drm/mach64_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/mach64_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -146,7 +146,7 @@ void mach64_driver_irq_preinstall(struct int mach64_driver_irq_postinstall(struct drm_device * dev) { - return drm_vblank_init(dev, 1); + return 0; } void mach64_driver_irq_uninstall(struct drm_device * dev) Modified: stable/7/sys/dev/drm/mga_dma.c ============================================================================== --- stable/7/sys/dev/drm/mga_dma.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/mga_dma.c Wed Mar 11 02:39:02 2009 (r189673) @@ -399,6 +399,7 @@ int mga_freelist_put(struct drm_device * int mga_driver_load(struct drm_device *dev, unsigned long flags) { drm_mga_private_t *dev_priv; + int ret; dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER); if (!dev_priv) @@ -418,6 +419,13 @@ int mga_driver_load(struct drm_device *d dev->types[7] = _DRM_STAT_PRIMARY; dev->types[8] = _DRM_STAT_SECONDARY; + ret = drm_vblank_init(dev, 1); + + if (ret) { + (void) mga_driver_unload(dev); + return ret; + } + return 0; } Modified: stable/7/sys/dev/drm/mga_irq.c ============================================================================== --- stable/7/sys/dev/drm/mga_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/mga_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -157,11 +157,6 @@ void mga_driver_irq_preinstall(struct dr int mga_driver_irq_postinstall(struct drm_device * dev) { drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; - int ret; - - ret = drm_vblank_init(dev, 1); - if (ret) - return ret; DRM_INIT_WAITQUEUE(&dev_priv->fence_queue); Modified: stable/7/sys/dev/drm/r128_drv.c ============================================================================== --- stable/7/sys/dev/drm/r128_drv.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/r128_drv.c Wed Mar 11 02:39:02 2009 (r189673) @@ -52,6 +52,7 @@ static void r128_configure(struct drm_de DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; dev->driver->buf_priv_size = sizeof(drm_r128_buf_priv_t); + dev->driver->load = r128_driver_load; dev->driver->preclose = r128_driver_preclose; dev->driver->lastclose = r128_driver_lastclose; dev->driver->get_vblank_counter = r128_get_vblank_counter; @@ -93,6 +94,11 @@ r128_attach(device_t nbdev) return drm_attach(nbdev, r128_pciidlist); } +int r128_driver_load(struct drm_device * dev, unsigned long flags) +{ + return drm_vblank_init(dev, 1); +} + static int r128_detach(device_t nbdev) { Modified: stable/7/sys/dev/drm/r128_drv.h ============================================================================== --- stable/7/sys/dev/drm/r128_drv.h Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/r128_drv.h Wed Mar 11 02:39:02 2009 (r189673) @@ -162,6 +162,7 @@ extern void r128_driver_irq_preinstall(s extern int r128_driver_irq_postinstall(struct drm_device * dev); extern void r128_driver_irq_uninstall(struct drm_device * dev); extern void r128_driver_lastclose(struct drm_device * dev); +extern int r128_driver_load(struct drm_device * dev, unsigned long flags); extern void r128_driver_preclose(struct drm_device * dev, struct drm_file *file_priv); Modified: stable/7/sys/dev/drm/r128_irq.c ============================================================================== --- stable/7/sys/dev/drm/r128_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/r128_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -105,7 +105,7 @@ void r128_driver_irq_preinstall(struct d int r128_driver_irq_postinstall(struct drm_device * dev) { - return drm_vblank_init(dev, 1); + return 0; } void r128_driver_irq_uninstall(struct drm_device * dev) Modified: stable/7/sys/dev/drm/radeon_cp.c ============================================================================== --- stable/7/sys/dev/drm/radeon_cp.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/radeon_cp.c Wed Mar 11 02:39:02 2009 (r189673) @@ -1751,6 +1751,12 @@ int radeon_driver_load(struct drm_device else dev_priv->flags |= RADEON_IS_PCI; + ret = drm_vblank_init(dev, 2); + if (ret) { + radeon_driver_unload(dev); + return ret; + } + DRM_DEBUG("%s card detected\n", ((dev_priv->flags & RADEON_IS_AGP) ? "AGP" : (((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI")))); return ret; Modified: stable/7/sys/dev/drm/radeon_irq.c ============================================================================== --- stable/7/sys/dev/drm/radeon_irq.c Wed Mar 11 02:37:52 2009 (r189672) +++ stable/7/sys/dev/drm/radeon_irq.c Wed Mar 11 02:39:02 2009 (r189673) @@ -372,15 +372,10 @@ int radeon_driver_irq_postinstall(struct { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; - int ret; atomic_set(&dev_priv->swi_emitted, 0); DRM_INIT_WAITQUEUE(&dev_priv->swi_queue); - ret = drm_vblank_init(dev, 2); - if (ret) - return ret; - dev->max_vblank_count = 0x001fffff; radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1); From jhb at FreeBSD.org Wed Mar 11 15:13:13 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 11 15:13:30 2009 Subject: svn commit: r189709 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/cd9660 Message-ID: <200903112213.n2BMDCkr008048@svn.freebsd.org> Author: jhb Date: Wed Mar 11 22:13:12 2009 New Revision: 189709 URL: http://svn.freebsd.org/changeset/base/189709 Log: MFC: Make cd9660 MPSAFE and able to use shared vnode locks for pathname lookups. Also, disable operations on character device nodes. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/cd9660/cd9660_lookup.c stable/7/sys/fs/cd9660/cd9660_node.c stable/7/sys/fs/cd9660/cd9660_node.h stable/7/sys/fs/cd9660/cd9660_vfsops.c stable/7/sys/fs/cd9660/cd9660_vnops.c Modified: stable/7/sys/fs/cd9660/cd9660_lookup.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_lookup.c Wed Mar 11 22:00:03 2009 (r189708) +++ stable/7/sys/fs/cd9660/cd9660_lookup.c Wed Mar 11 22:13:12 2009 (r189709) @@ -94,29 +94,34 @@ cd9660_lookup(ap) struct iso_node *dp; /* inode for directory being searched */ struct iso_mnt *imp; /* filesystem that directory is in */ struct buf *bp; /* a buffer of directory entries */ - struct iso_directory_record *ep = 0;/* the current directory entry */ + struct iso_directory_record *ep;/* the current directory entry */ + struct iso_directory_record *ep2;/* copy of current directory entry */ int entryoffsetinblock; /* offset of ep in bp's buffer */ int saveoffset = 0; /* offset of last directory entry in dir */ + doff_t i_diroff; /* cached i_diroff value. */ + doff_t i_offset; /* cached i_offset value. */ int numdirpasses; /* strategy for directory search */ doff_t endsearch; /* offset to end directory search */ struct vnode *pdp; /* saved dp during symlink work */ struct vnode *tdp; /* returned by cd9660_vget_internal */ u_long bmask; /* block offset mask */ int error; - ino_t ino = 0, saved_ino; - int reclen; + ino_t ino, i_ino; + int ltype, reclen; u_short namelen; int isoflags; char altname[NAME_MAX]; int res; int assoc, len; char *name; + struct mount *mp; struct vnode **vpp = ap->a_vpp; struct componentname *cnp = ap->a_cnp; int flags = cnp->cn_flags; int nameiop = cnp->cn_nameiop; struct thread *td = cnp->cn_thread; + ep2 = ep = NULL; bp = NULL; *vpp = NULL; vdp = ap->a_dvp; @@ -126,9 +131,11 @@ cd9660_lookup(ap) /* * We now have a segment name to search for, and a directory to search. */ - + ino = reclen = 0; + i_diroff = dp->i_diroff; len = cnp->cn_namelen; name = cnp->cn_nameptr; + /* * A leading `=' means, we are looking for an associated file */ @@ -150,15 +157,14 @@ cd9660_lookup(ap) * of simplicity. */ bmask = imp->im_bmask; - if (nameiop != LOOKUP || dp->i_diroff == 0 || - dp->i_diroff > dp->i_size) { + if (nameiop != LOOKUP || i_diroff == 0 || i_diroff > dp->i_size) { entryoffsetinblock = 0; - dp->i_offset = 0; + i_offset = 0; numdirpasses = 1; } else { - dp->i_offset = dp->i_diroff; - if ((entryoffsetinblock = dp->i_offset & bmask) && - (error = cd9660_blkatoff(vdp, (off_t)dp->i_offset, NULL, &bp))) + i_offset = i_diroff; + if ((entryoffsetinblock = i_offset & bmask) && + (error = cd9660_blkatoff(vdp, (off_t)i_offset, NULL, &bp))) return (error); numdirpasses = 2; nchstats.ncs_2passes++; @@ -166,17 +172,17 @@ cd9660_lookup(ap) endsearch = dp->i_size; searchloop: - while (dp->i_offset < endsearch) { + while (i_offset < endsearch) { /* * If offset is on a block boundary, * read the next directory block. * Release previous if it exists. */ - if ((dp->i_offset & bmask) == 0) { + if ((i_offset & bmask) == 0) { if (bp != NULL) brelse(bp); if ((error = - cd9660_blkatoff(vdp, (off_t)dp->i_offset, NULL, &bp)) != 0) + cd9660_blkatoff(vdp, (off_t)i_offset, NULL, &bp)) != 0) return (error); entryoffsetinblock = 0; } @@ -189,8 +195,8 @@ searchloop: reclen = isonum_711(ep->length); if (reclen == 0) { /* skip to next block, if any */ - dp->i_offset = - (dp->i_offset & ~bmask) + imp->logical_block_size; + i_offset = + (i_offset & ~bmask) + imp->logical_block_size; continue; } @@ -225,7 +231,7 @@ searchloop: * Save directory entry's inode number and * release directory buffer. */ - dp->i_ino = isodirino(ep, imp); + i_ino = isodirino(ep, imp); goto found; } if (namelen != 1 @@ -242,7 +248,7 @@ searchloop: else ino = dbtob(bp->b_blkno) + entryoffsetinblock; - saveoffset = dp->i_offset; + saveoffset = i_offset; } else if (ino) goto foundino; #ifdef NOSORTBUG /* On some CDs directory entries are not sorted correctly */ @@ -258,22 +264,22 @@ searchloop: ino = isodirino(ep, imp); else ino = dbtob(bp->b_blkno) + entryoffsetinblock; - dp->i_ino = ino; - cd9660_rrip_getname(ep,altname,&namelen,&dp->i_ino,imp); + i_ino = ino; + cd9660_rrip_getname(ep, altname, &namelen, &i_ino, imp); if (namelen == cnp->cn_namelen && !bcmp(name,altname,namelen)) goto found; ino = 0; break; } - dp->i_offset += reclen; + i_offset += reclen; entryoffsetinblock += reclen; } if (ino) { foundino: - dp->i_ino = ino; - if (saveoffset != dp->i_offset) { - if (lblkno(imp, dp->i_offset) != + i_ino = ino; + if (saveoffset != i_offset) { + if (lblkno(imp, i_offset) != lblkno(imp, saveoffset)) { if (bp != NULL) brelse(bp); @@ -284,7 +290,8 @@ foundino: entryoffsetinblock = saveoffset & bmask; ep = (struct iso_directory_record *) ((char *)bp->b_data + entryoffsetinblock); - dp->i_offset = saveoffset; + reclen = isonum_711(ep->length); + i_offset = saveoffset; } goto found; } @@ -295,8 +302,8 @@ notfound: */ if (numdirpasses == 2) { numdirpasses--; - dp->i_offset = 0; - endsearch = dp->i_diroff; + i_offset = 0; + endsearch = i_diroff; goto searchloop; } if (bp != NULL) @@ -321,10 +328,10 @@ found: * in the cache as to where the entry was found. */ if ((flags & ISLASTCN) && nameiop == LOOKUP) - dp->i_diroff = dp->i_offset; + dp->i_diroff = i_offset; /* - * Step through the translation in the name. We do not `iput' the + * Step through the translation in the name. We do not `vput' the * directory because we may need it again if a symbolic link * is relative to the current directory. Instead we save it * unlocked as "pdp". We must get the target inode before unlocking @@ -334,7 +341,7 @@ found: * when following backward pointers ".." we must unlock the * parent directory before getting the requested directory. * There is a potential race condition here if both the current - * and parent directories are removed before the `iget' for the + * and parent directories are removed before the `vget' for the * inode associated with ".." returns. We hope that this occurs * infrequently since we cannot avoid this race condition without * implementing a sophisticated deadlock detection algorithm. @@ -343,30 +350,75 @@ found: * that point backwards in the directory structure. */ pdp = vdp; + /* - * If ino is different from dp->i_ino, + * Make a copy of the directory entry for non "." lookups so + * we can drop the buffer before calling vget() to avoid a + * lock order reversal between the vnode lock and the buffer + * lock. + */ + if (dp->i_number != i_ino) { + ep2 = malloc(reclen, M_TEMP, M_WAITOK); + bcopy(ep, ep2, reclen); + ep = ep2; + } + brelse(bp); + + /* + * If ino is different from i_ino, * it's a relocated directory. */ if (flags & ISDOTDOT) { - saved_ino = dp->i_ino; - VOP_UNLOCK(pdp, 0, td); /* race to get the inode */ - error = cd9660_vget_internal(vdp->v_mount, saved_ino, - LK_EXCLUSIVE, &tdp, - saved_ino != ino, ep); - brelse(bp); - vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td); + /* + * Expanded copy of vn_vget_ino() so that we can use + * cd9660_vget_internal(). + */ + mp = pdp->v_mount; + ltype = VOP_ISLOCKED(pdp, td); + for (;;) { + error = vfs_busy(mp, LK_NOWAIT, NULL, curthread); + if (error == 0) + break; + VOP_UNLOCK(pdp, 0, td); + pause("vn_vget", 1); + vn_lock(pdp, ltype | LK_RETRY, td); + if (pdp->v_iflag & VI_DOOMED) + return (ENOENT); + } + VOP_UNLOCK(pdp, 0, td); + error = cd9660_vget_internal(vdp->v_mount, i_ino, + cnp->cn_lkflags, &tdp, + i_ino != ino, ep); + free(ep2, M_TEMP); + vfs_unbusy(mp, td); + vn_lock(pdp, ltype | LK_RETRY, td); + if (pdp->v_iflag & VI_DOOMED) { + if (error == 0) + vput(tdp); + error = ENOENT; + } if (error) return (error); *vpp = tdp; - } else if (dp->i_number == dp->i_ino) { - brelse(bp); + } else if (dp->i_number == i_ino) { VREF(vdp); /* we want ourself, ie "." */ + /* + * When we lookup "." we still can be asked to lock it + * differently. + */ + ltype = cnp->cn_lkflags & LK_TYPE_MASK; + if (ltype != VOP_ISLOCKED(vdp, td)) { + if (ltype == LK_EXCLUSIVE) + vn_lock(vdp, LK_UPGRADE | LK_RETRY, td); + else /* if (ltype == LK_SHARED) */ + vn_lock(vdp, LK_DOWNGRADE | LK_RETRY, td); + } *vpp = vdp; } else { - error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, - LK_EXCLUSIVE, &tdp, - dp->i_ino != ino, ep); - brelse(bp); + error = cd9660_vget_internal(vdp->v_mount, i_ino, + cnp->cn_lkflags, &tdp, + i_ino != ino, ep); + free(ep2, M_TEMP); if (error) return (error); *vpp = tdp; Modified: stable/7/sys/fs/cd9660/cd9660_node.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_node.c Wed Mar 11 22:00:03 2009 (r189708) +++ stable/7/sys/fs/cd9660/cd9660_node.c Wed Mar 11 22:13:12 2009 (r189709) @@ -93,7 +93,6 @@ cd9660_reclaim(ap) } */ *ap; { struct vnode *vp = ap->a_vp; - struct iso_node *ip = VTOI(vp); if (prtactive && vrefcnt(vp) != 0) vprint("cd9660_reclaim: pushing active", vp); @@ -109,8 +108,6 @@ cd9660_reclaim(ap) /* * Purge old data structures associated with the inode. */ - if (ip->i_mnt->im_devvp) - vrele(ip->i_mnt->im_devvp); FREE(vp->v_data, M_ISOFSNODE); vp->v_data = NULL; return (0); Modified: stable/7/sys/fs/cd9660/cd9660_node.h ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_node.h Wed Mar 11 22:00:03 2009 (r189708) +++ stable/7/sys/fs/cd9660/cd9660_node.h Wed Mar 11 22:13:12 2009 (r189709) @@ -65,8 +65,6 @@ struct iso_node { struct lockf *i_lockf; /* head of byte-level lock list */ doff_t i_endoff; /* end of useful stuff in directory */ doff_t i_diroff; /* offset in dir, where we found last entry */ - doff_t i_offset; /* offset of free space in directory */ - ino_t i_ino; /* inode number of found directory */ long iso_extent; /* extent of file */ unsigned long i_size; Modified: stable/7/sys/fs/cd9660/cd9660_vfsops.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_vfsops.c Wed Mar 11 22:00:03 2009 (r189708) +++ stable/7/sys/fs/cd9660/cd9660_vfsops.c Wed Mar 11 22:13:12 2009 (r189709) @@ -381,6 +381,7 @@ iso_mountfs(devvp, mp, td) mp->mnt_maxsymlinklen = 0; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; + mp->mnt_kern_flag |= MNTK_MPSAFE | MNTK_LOOKUP_SHARED; MNT_IUNLOCK(mp); isomp->im_mountp = mp; isomp->im_dev = dev; @@ -556,7 +557,7 @@ cd9660_root(mp, flags, vpp, td) * With RRIP we must use the `.' entry of the root directory. * Simply tell vget, that it's a relocated directory. */ - return (cd9660_vget_internal(mp, ino, LK_EXCLUSIVE, vpp, + return (cd9660_vget_internal(mp, ino, flags, vpp, imp->iso_ftype == ISO_FTYPE_RRIP, dp)); } @@ -670,6 +671,22 @@ cd9660_vget_internal(mp, ino, flags, vpp if (error || *vpp != NULL) return (error); + /* + * We must promote to an exclusive lock for vnode creation. This + * can happen if lookup is passed LOCKSHARED. + */ + if ((flags & LK_TYPE_MASK) == LK_SHARED) { + flags &= ~LK_TYPE_MASK; + flags |= LK_EXCLUSIVE; + } + + /* + * We do not lock vnode creation as it is believed to be too + * expensive for such rare case as simultaneous creation of vnode + * for same ino by different processes. We just allow them to race + * and check later to decide who wins. Let the race begin! + */ + imp = VFSTOISOFS(mp); dev = imp->im_dev; @@ -750,7 +767,6 @@ cd9660_vget_internal(mp, ino, flags, vpp bp = 0; ip->i_mnt = imp; - VREF(imp->im_devvp); if (relocated) { /* @@ -808,6 +824,7 @@ cd9660_vget_internal(mp, ino, flags, vpp vp->v_op = &cd9660_fifoops; break; default: + vp->v_vnlock->lk_flags &= ~LK_NOSHARE; break; } Modified: stable/7/sys/fs/cd9660/cd9660_vnops.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_vnops.c Wed Mar 11 22:00:03 2009 (r189708) +++ stable/7/sys/fs/cd9660/cd9660_vnops.c Wed Mar 11 22:13:12 2009 (r189709) @@ -169,10 +169,14 @@ cd9660_open(ap) int a_fdidx; } */ *ap; { - struct iso_node *ip = VTOI(ap->a_vp); + struct vnode *vp = ap->a_vp; + struct iso_node *ip = VTOI(vp); - vnode_create_vobject(ap->a_vp, ip->i_size, ap->a_td); - return 0; + if (vp->v_type == VCHR || vp->v_type == VBLK) + return (EOPNOTSUPP); + + vnode_create_vobject(vp, ip->i_size, ap->a_td); + return (0); } From bms at FreeBSD.org Wed Mar 11 20:09:14 2009 From: bms at FreeBSD.org (Bruce M Simpson) Date: Wed Mar 11 20:09:21 2009 Subject: svn commit: r189720 - in stable/7: . sys/amd64/conf sys/arm/conf sys/conf sys/dev/ath sys/dev/ath/ath_rate/amrr sys/dev/ath/ath_rate/onoe sys/dev/ath/ath_rate/sample sys/i386/conf sys/modules sys/m... Message-ID: <200903120309.n2C39C62015056@svn.freebsd.org> Author: bms Date: Thu Mar 12 03:09:11 2009 New Revision: 189720 URL: http://svn.freebsd.org/changeset/base/189720 Log: Merge the open source Atheros HAL from HEAD to STABLE. This adds support for the AH_SUPPORT_AR5416 kernel configuration option, and removes the ath_rate* and ath_hal modules. Their kernel options are not however removed -- please see UPDATING. Tested on an IBM/Lenovo T43 and ASUS EeePC 701 in both STA and HostAP modes. Submitted by: sam Deleted: stable/7/sys/modules/ath_hal/ stable/7/sys/modules/ath_rate_amrr/ stable/7/sys/modules/ath_rate_onoe/ stable/7/sys/modules/ath_rate_sample/ Modified: stable/7/UPDATING stable/7/sys/amd64/conf/GENERIC stable/7/sys/amd64/conf/NOTES stable/7/sys/arm/conf/AVILA stable/7/sys/conf/files stable/7/sys/conf/files.amd64 stable/7/sys/conf/files.arm stable/7/sys/conf/files.i386 stable/7/sys/conf/files.pc98 stable/7/sys/conf/files.powerpc stable/7/sys/conf/files.sparc64 stable/7/sys/conf/kern.pre.mk stable/7/sys/conf/options stable/7/sys/dev/ath/ah_osdep.c stable/7/sys/dev/ath/ah_osdep.h stable/7/sys/dev/ath/ath_rate/amrr/amrr.c stable/7/sys/dev/ath/ath_rate/onoe/onoe.c stable/7/sys/dev/ath/ath_rate/sample/sample.c stable/7/sys/dev/ath/if_ath.c stable/7/sys/dev/ath/if_ath_pci.c stable/7/sys/dev/ath/if_athvar.h stable/7/sys/i386/conf/GENERIC stable/7/sys/i386/conf/NOTES stable/7/sys/modules/Makefile stable/7/sys/modules/ath/Makefile stable/7/sys/pc98/conf/GENERIC stable/7/sys/pc98/conf/NOTES stable/7/sys/sparc64/conf/GENERIC Modified: stable/7/UPDATING ============================================================================== --- stable/7/UPDATING Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/UPDATING Thu Mar 12 03:09:11 2009 (r189720) @@ -8,6 +8,16 @@ Items affecting the ports and packages s /usr/ports/UPDATING. Please read that file before running portupgrade. +20090312: + The open-source Atheros HAL has been merged from HEAD + to STABLE. + The kernel compile-time option AH_SUPPORT_AR5416 has been + added to support certain newer Atheros parts, particularly + PCI-Express chipsets. + The following modules are no longer available, and should be + removed from MODULES_OVERRIDE and/or loader.conf:- + ath_hal ath_rate_amrr ath_rate_onoe ath_rate_sample + 20090207: ZFS users on amd64 machines with 4GB or more of RAM should reevaluate their need for setting vm.kmem_size_max and Modified: stable/7/sys/amd64/conf/GENERIC ============================================================================== --- stable/7/sys/amd64/conf/GENERIC Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/amd64/conf/GENERIC Thu Mar 12 03:09:11 2009 (r189720) @@ -242,6 +242,7 @@ device wlan_scan_sta # 802.11 STA mode device an # Aironet 4500/4800 802.11 wireless NICs. device ath # Atheros pci/cardbus NIC's device ath_hal # Atheros HAL (Hardware Access Layer) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath device awi # BayStack 660 and others device ral # Ralink Technology RT2500 wireless NICs. Modified: stable/7/sys/amd64/conf/NOTES ============================================================================== --- stable/7/sys/amd64/conf/NOTES Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/amd64/conf/NOTES Thu Mar 12 03:09:11 2009 (r189720) @@ -331,6 +331,7 @@ device wpi device ath device ath_hal # Atheros HAL (includes binary component) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors #device ath_rate_amrr # AMRR rate control for ath driver #device ath_rate_onoe # Onoe rate control for ath driver device ath_rate_sample # SampleRate rate control for the ath driver Modified: stable/7/sys/arm/conf/AVILA ============================================================================== --- stable/7/sys/arm/conf/AVILA Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/arm/conf/AVILA Thu Mar 12 03:09:11 2009 (r189720) @@ -133,6 +133,7 @@ device wlan # 802.11 support #device wlan_tkip # 802.11 TKIP support device ath # Atheros pci/cardbus NIC's device ath_hal # Atheros HAL (Hardware Access Layer) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath options ATH_DEBUG Modified: stable/7/sys/conf/files ============================================================================== --- stable/7/sys/conf/files Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files Thu Mar 12 03:09:11 2009 (r189720) @@ -475,18 +475,180 @@ dev/ata/atapi-cam.c optional atapicam dev/ata/atapi-cd.c optional atapicd dev/ata/atapi-fd.c optional atapifd dev/ata/atapi-tape.c optional atapist -dev/ath/ah_osdep.c optional ath_hal \ +# +dev/ath/if_ath.c optional ath \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/if_ath_pci.c optional ath pci \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ah_osdep.c optional ath \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ah.c optional ath \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ah_eeprom_v1.c optional ath_hal | ath_ar5210 \ compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ah_eeprom_v3.c optional ath_hal | ath_ar5211 | ath_ar5212 \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ah_eeprom_v14.c optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ah_regdomain.c optional ath \ + compile-with "${NORMAL_C} -I$S/dev/ath" +dev/ath/ath_hal/ar5210/ar5210_attach.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_beacon.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_interrupts.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_keycache.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_misc.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_phy.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_power.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_recv.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_reset.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5210/ar5210_xmit.c optional ath_hal | ath_ar5210 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_attach.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_beacon.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_interrupts.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_keycache.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_misc.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_phy.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_power.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_recv.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_reset.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5211/ar5211_xmit.c optional ath_hal | ath_ar5211 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_ani.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_attach.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_beacon.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_eeprom.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_gpio.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_interrupts.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_keycache.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_misc.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_phy.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_power.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_recv.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_reset.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_rfgain.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5212_xmit.c \ + optional ath_hal | ath_ar5212 | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar2316.c optional ath_rf2316 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar2317.c optional ath_rf2317 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar2413.c optional ath_hal | ath_rf2413 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar2425.c optional ath_hal | ath_rf2425 | ath_rf2417 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5111.c optional ath_hal | ath_rf5111 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5112.c optional ath_hal | ath_rf5112 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5212/ar5413.c optional ath_hal | ath_rf5413 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar2133.c optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_ani.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_attach.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_beacon.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_cal.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_cal_iq.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_cal_adcgain.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_cal_adcdc.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_eeprom.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_gpio.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_interrupts.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_keycache.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_misc.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_phy.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_power.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_recv.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_reset.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar5416_xmit.c \ + optional ath_hal | ath_ar5416 | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar5416/ar9160_attach.c optional ath_hal | ath_ar9160 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_rate/amrr/amrr.c optional ath_rate_amrr \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ath_rate/onoe/onoe.c optional ath_rate_onoe \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ath_rate/sample/sample.c optional ath_rate_sample \ compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath.c optional ath \ - compile-with "${NORMAL_C} -I$S/dev/ath" -dev/ath/if_ath_pci.c optional ath pci \ - compile-with "${NORMAL_C} -I$S/dev/ath" dev/awi/am79c930.c optional awi dev/awi/awi.c optional awi dev/awi/if_awi_pccard.c optional awi pccard Modified: stable/7/sys/conf/files.amd64 ============================================================================== --- stable/7/sys/conf/files.amd64 Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.amd64 Thu Mar 12 03:09:11 2009 (r189720) @@ -47,16 +47,6 @@ ukbdmap.h optional ukbd_dflt_keymap \ no-obj no-implicit-rule before-depend \ clean "ukbdmap.h" # -hal.o optional ath_hal \ - dependency "$S/contrib/dev/ath/public/x86_64-elf.hal.o.uu" \ - compile-with "uudecode < $S/contrib/dev/ath/public/x86_64-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - dependency "$S/contrib/dev/ath/public/x86_64-elf.opt_ah.h" \ - compile-with "rm -f opt_ah.h; cp $S/contrib/dev/ath/public/x86_64-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" -# nvenetlib.o optional nve pci \ dependency "$S/contrib/dev/nve/amd64/nvenetlib.o.bz2.uu" \ compile-with "uudecode $S/contrib/dev/nve/amd64/nvenetlib.o.bz2.uu ; bzip2 -df nvenetlib.o.bz2" \ Modified: stable/7/sys/conf/files.arm ============================================================================== --- stable/7/sys/conf/files.arm Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.arm Thu Mar 12 03:09:11 2009 (r189720) @@ -52,13 +52,6 @@ geom/geom_bsd.c standard geom/geom_bsd_enc.c standard geom/geom_mbr.c standard geom/geom_mbr_enc.c standard -hal.o optional ath_hal \ - compile-with "ATH_HAL_CPU=`echo ${CONF_CFLAGS}|sed 's/.*-mcpu=\([a-zA-Z0-9]*\).*/\1/'`; ATH_ENDIAN=`if (echo ${CC}|grep mbig-endian>/dev/null); then echo be; else echo le; fi;`; uudecode < $S/contrib/dev/ath/public/$$ATH_HAL_CPU-$$ATH_ENDIAN-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - compile-with "ATH_HAL_CPU=`echo ${CONF_CFLAGS}|sed 's/.*-mcpu=\([a-zA-Z0-9]*\).*/\1/'`; ATH_ENDIAN=`if (echo ${CC}|grep mbig-endian>/dev/null); then echo be; else echo le; fi;`; rm -f opt_ah.h; cp $S/contrib/dev/ath/public/$$ATH_HAL_CPU-$$ATH_ENDIAN-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" libkern/arm/divsi3.S standard libkern/arm/ffs.S standard libkern/arm/muldi3.c standard Modified: stable/7/sys/conf/files.i386 ============================================================================== --- stable/7/sys/conf/files.i386 Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.i386 Thu Mar 12 03:09:11 2009 (r189720) @@ -51,16 +51,6 @@ trlld.o optional oltr \ compile-with "uudecode < $S/contrib/dev/oltr/i386-elf.trlld.o.uu" \ no-implicit-rule # -hal.o optional ath_hal \ - dependency "$S/contrib/dev/ath/public/i386-elf.hal.o.uu" \ - compile-with "uudecode < $S/contrib/dev/ath/public/i386-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - dependency "$S/contrib/dev/ath/public/i386-elf.opt_ah.h" \ - compile-with "rm -f opt_ah.h; cp $S/contrib/dev/ath/public/i386-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" -# nvenetlib.o optional nve pci \ dependency "$S/contrib/dev/nve/i386/nvenetlib.o.bz2.uu" \ compile-with "uudecode $S/contrib/dev/nve/i386/nvenetlib.o.bz2.uu ; bzip2 -df nvenetlib.o.bz2" \ Modified: stable/7/sys/conf/files.pc98 ============================================================================== --- stable/7/sys/conf/files.pc98 Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.pc98 Thu Mar 12 03:09:11 2009 (r189720) @@ -43,16 +43,6 @@ trlld.o optional oltr \ compile-with "uudecode < $S/contrib/dev/oltr/i386-elf.trlld.o.uu" \ no-implicit-rule # -hal.o optional ath_hal \ - dependency "$S/contrib/dev/ath/public/i386-elf.hal.o.uu" \ - compile-with "uudecode < $S/contrib/dev/ath/public/i386-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - dependency "$S/contrib/dev/ath/public/i386-elf.opt_ah.h" \ - compile-with "rm -f opt_ah.h; cp $S/contrib/dev/ath/public/i386-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" -# compat/linprocfs/linprocfs.c optional linprocfs compat/linsysfs/linsysfs.c optional linsysfs compat/linux/linux_emul.c optional compat_linux Modified: stable/7/sys/conf/files.powerpc ============================================================================== --- stable/7/sys/conf/files.powerpc Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.powerpc Thu Mar 12 03:09:11 2009 (r189720) @@ -14,16 +14,6 @@ font.h optional no-obj no-implicit-rule before-depend \ clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8" # -hal.o optional ath_hal \ - dependency "$S/contrib/dev/ath/public/powerpc-be-elf.hal.o.uu" \ - compile-with "uudecode < $S/contrib/dev/ath/public/powerpc-be-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - dependency "$S/contrib/dev/ath/public/powerpc-be-elf.opt_ah.h" \ - compile-with "rm -f opt_ah.h; cp $S/contrib/dev/ath/public/powerpc-be-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" -# dev/bm/if_bm.c optional bm powermac dev/fb/fb.c optional sc Modified: stable/7/sys/conf/files.sparc64 ============================================================================== --- stable/7/sys/conf/files.sparc64 Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/files.sparc64 Thu Mar 12 03:09:11 2009 (r189720) @@ -22,16 +22,6 @@ ukbdmap.h optional ukbd_dflt_keymap \ no-obj no-implicit-rule before-depend \ clean "ukbdmap.h" # -hal.o optional ath_hal \ - dependency "$S/contrib/dev/ath/public/sparc64-be-elf.hal.o.uu" \ - compile-with "uudecode < $S/contrib/dev/ath/public/sparc64-be-elf.hal.o.uu" \ - no-implicit-rule -opt_ah.h optional ath_hal \ - dependency "$S/contrib/dev/ath/public/sparc64-be-elf.opt_ah.h" \ - compile-with "rm -f opt_ah.h; cp $S/contrib/dev/ath/public/sparc64-be-elf.opt_ah.h opt_ah.h" \ - no-obj no-implicit-rule before-depend \ - clean "opt_ah.h" -# crypto/blowfish/bf_enc.c optional crypto | ipsec crypto/des/des_enc.c optional crypto | ipsec | netsmb dev/atkbdc/atkbd.c optional atkbd atkbdc Modified: stable/7/sys/conf/kern.pre.mk ============================================================================== --- stable/7/sys/conf/kern.pre.mk Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/kern.pre.mk Thu Mar 12 03:09:11 2009 (r189720) @@ -65,8 +65,8 @@ INCLUDES+= -I$S/contrib/ipfilter # ... and the same for pf INCLUDES+= -I$S/contrib/pf -# ... and the same for Atheros HAL -INCLUDES+= -I$S/dev/ath +# ... and the same for ath +INCLUDES+= -I$S/dev/ath -I$S/dev/ath/ath_hal # ... and the same for the NgATM stuff INCLUDES+= -I$S/contrib/ngatm Modified: stable/7/sys/conf/options ============================================================================== --- stable/7/sys/conf/options Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/conf/options Thu Mar 12 03:09:11 2009 (r189720) @@ -729,6 +729,21 @@ ATH_RXBUF opt_ath.h ATH_DIAGAPI opt_ath.h ATH_TX99_DIAG opt_ath.h +# options for the Atheros hal +AH_SUPPORT_AR5416 opt_ah.h + +AH_DEBUG opt_ah.h +AH_ASSERT opt_ah.h +AH_DEBUG_ALQ opt_ah.h +AH_REGOPS_FUNC opt_ah.h +AH_WRITE_REGDOMAIN opt_ah.h +AH_DEBUG_COUNTRY opt_ah.h +AH_WRITE_EEPROM opt_ah.h +AH_PRIVATE_DIAG opt_ah.h +AH_NEED_DESC_SWAP opt_ah.h +AH_USE_INIPDGAIN opt_ah.h +AH_SUPPORT_11D opt_ah.h + # dcons options DCONS_BUF_SIZE opt_dcons.h DCONS_POLL_HZ opt_dcons.h Modified: stable/7/sys/dev/ath/ah_osdep.c ============================================================================== --- stable/7/sys/dev/ath/ah_osdep.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/ah_osdep.c Thu Mar 12 03:09:11 2009 (r189720) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting + * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,7 @@ #include /* XXX for ether_sprintf */ -#include +#include /* * WiSoC boards overload the bus tag with information about the @@ -56,7 +56,7 @@ #define BUSTAG(ah) \ ((bus_space_tag_t) ((struct ar531x_config *)((ah)->ah_st))->tag) #else -#define BUSTAG(ah) ((bus_space_tag_t) (ah)->ah_st) +#define BUSTAG(ah) ((ah)->ah_st) #endif extern void ath_hal_printf(struct ath_hal *, const char*, ...) @@ -71,8 +71,12 @@ extern void ath_hal_assert_failed(const int lineno, const char* msg); #endif #ifdef AH_DEBUG +#if HAL_ABI_VERSION >= 0x08090101 +extern void HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...); +#else extern void HALDEBUG(struct ath_hal *ah, const char* fmt, ...); extern void HALDEBUGn(struct ath_hal *ah, u_int level, const char* fmt, ...); +#endif #endif /* AH_DEBUG */ /* NB: put this here instead of the driver to avoid circular references */ @@ -86,9 +90,6 @@ SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, TUNABLE_INT("hw.ath.hal.debug", &ath_hal_debug); #endif /* AH_DEBUG */ -SYSCTL_STRING(_hw_ath_hal, OID_AUTO, version, CTLFLAG_RD, ath_hal_version, 0, - "Atheros HAL version"); - /* NB: these are deprecated; they exist for now for compatibility */ int ath_hal_dma_beacon_response_time = 2; /* in TU's */ SYSCTL_INT(_hw_ath_hal, OID_AUTO, dma_brt, CTLFLAG_RW, @@ -139,6 +140,18 @@ ath_hal_ether_sprintf(const u_int8_t *ma } #ifdef AH_DEBUG +#if HAL_ABI_VERSION >= 0x08090101 +void +HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) +{ + if (ath_hal_debug & mask) { + __va_list ap; + va_start(ap, fmt); + ath_hal_vprintf(ah, fmt, ap); + va_end(ap); + } +} +#else void HALDEBUG(struct ath_hal *ah, const char* fmt, ...) { @@ -160,6 +173,7 @@ HALDEBUGn(struct ath_hal *ah, u_int leve va_end(ap); } } +#endif #endif /* AH_DEBUG */ #ifdef AH_DEBUG_ALQ @@ -178,7 +192,7 @@ HALDEBUGn(struct ath_hal *ah, u_int leve */ #include #include -#include +#include static struct alq *ath_hal_alq; static int ath_hal_alq_emitdev; /* need to emit DEVICE record */ @@ -256,7 +270,7 @@ void ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) { bus_space_tag_t tag = BUSTAG(ah); - bus_space_handle_t h = (bus_space_handle_t) ah->ah_sh; + bus_space_handle_t h = ah->ah_sh; if (ath_hal_alq) { struct ale *ale = ath_hal_alq_get(ah); @@ -280,7 +294,7 @@ u_int32_t ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg) { bus_space_tag_t tag = BUSTAG(ah); - bus_space_handle_t h = (bus_space_handle_t) ah->ah_sh; + bus_space_handle_t h = ah->ah_sh; u_int32_t val; #if _BYTE_ORDER == _BIG_ENDIAN @@ -332,7 +346,7 @@ void ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) { bus_space_tag_t tag = BUSTAG(ah); - bus_space_handle_t h = (bus_space_handle_t) ah->ah_sh; + bus_space_handle_t h = ah->ah_sh; #if _BYTE_ORDER == _BIG_ENDIAN if (reg >= 0x4000 && reg < 0x5000) @@ -346,7 +360,7 @@ u_int32_t ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg) { bus_space_tag_t tag = BUSTAG(ah); - bus_space_handle_t h = (bus_space_handle_t) ah->ah_sh; + bus_space_handle_t h = ah->ah_sh; u_int32_t val; #if _BYTE_ORDER == _BIG_ENDIAN @@ -398,37 +412,3 @@ ath_hal_memcpy(void *dst, const void *sr { return memcpy(dst, src, n); } - -/* - * Module glue. - */ - -static int -ath_hal_modevent(module_t mod, int type, void *unused) -{ - const char *sep; - int i; - - switch (type) { - case MOD_LOAD: - printf("ath_hal: %s (", ath_hal_version); - sep = ""; - for (i = 0; ath_hal_buildopts[i] != NULL; i++) { - printf("%s%s", sep, ath_hal_buildopts[i]); - sep = ", "; - } - printf(")\n"); - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t ath_hal_mod = { - "ath_hal", - ath_hal_modevent, - 0 -}; -DECLARE_MODULE(ath_hal, ath_hal_mod, SI_SUB_DRIVERS, SI_ORDER_ANY); -MODULE_VERSION(ath_hal, 1); Modified: stable/7/sys/dev/ath/ah_osdep.h ============================================================================== --- stable/7/sys/dev/ath/ah_osdep.h Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/ah_osdep.h Thu Mar 12 03:09:11 2009 (r189720) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting + * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,13 +33,29 @@ /* * Atheros Hardware Access Layer (HAL) OS Dependent Definitions. */ +#include #include #include #include +#include #include /* + * Bus i/o type definitions. + */ +typedef void *HAL_SOFTC; +typedef bus_space_tag_t HAL_BUS_TAG; +typedef bus_space_handle_t HAL_BUS_HANDLE; + +/* + * Linker set writearounds for chip and RF backend registration. + */ +#define OS_DATA_SET(set, item) DATA_SET(set, item) +#define OS_SET_DECLARE(set, ptype) SET_DECLARE(set, ptype) +#define OS_SET_FOREACH(pvar, set) SET_FOREACH(pvar, set) + +/* * Delay n microseconds. */ extern void ath_hal_delay(int); Modified: stable/7/sys/dev/ath/ath_rate/amrr/amrr.c ============================================================================== --- stable/7/sys/dev/ath/ath_rate/amrr/amrr.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/ath_rate/amrr/amrr.c Thu Mar 12 03:09:11 2009 (r189720) @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -78,7 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #define AMRR_DEBUG #ifdef AMRR_DEBUG @@ -518,29 +517,3 @@ ath_rate_detach(struct ath_ratectrl *arc callout_drain(&asc->timer); free(asc, M_DEVBUF); } - -/* - * Module glue. - */ -static int -amrr_modevent(module_t mod, int type, void *unused) -{ - switch (type) { - case MOD_LOAD: - if (bootverbose) - printf("ath_rate: version 0.1\n"); - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t amrr_mod = { - "ath_rate", - amrr_modevent, - 0 -}; -DECLARE_MODULE(ath_rate, amrr_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); -MODULE_VERSION(ath_rate, 1); -MODULE_DEPEND(ath_rate, wlan, 1, 1, 1); Modified: stable/7/sys/dev/ath/ath_rate/onoe/onoe.c ============================================================================== --- stable/7/sys/dev/ath/ath_rate/onoe/onoe.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/ath_rate/onoe/onoe.c Thu Mar 12 03:09:11 2009 (r189720) @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -66,7 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #define ONOE_DEBUG #ifdef ONOE_DEBUG @@ -492,29 +491,3 @@ ath_rate_detach(struct ath_ratectrl *arc callout_drain(&osc->timer); free(osc, M_DEVBUF); } - -/* - * Module glue. - */ -static int -onoe_modevent(module_t mod, int type, void *unused) -{ - switch (type) { - case MOD_LOAD: - if (bootverbose) - printf("ath_rate: \n"); - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t onoe_mod = { - "ath_rate", - onoe_modevent, - 0 -}; -DECLARE_MODULE(ath_rate, onoe_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); -MODULE_VERSION(ath_rate, 1); -MODULE_DEPEND(ath_rate, wlan, 1, 1, 1); Modified: stable/7/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- stable/7/sys/dev/ath/ath_rate/sample/sample.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/ath_rate/sample/sample.c Thu Mar 12 03:09:11 2009 (r189720) @@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -74,7 +73,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #define SAMPLE_DEBUG #ifdef SAMPLE_DEBUG @@ -840,30 +839,3 @@ ath_rate_detach(struct ath_ratectrl *arc free(osc, M_DEVBUF); } - -/* - * Module glue. - */ -static int -sample_modevent(module_t mod, int type, void *unused) -{ - switch (type) { - case MOD_LOAD: - if (bootverbose) - printf("ath_rate: version 1.2 \n"); - return 0; - case MOD_UNLOAD: - return 0; - } - return EINVAL; -} - -static moduledata_t sample_mod = { - "ath_rate", - sample_modevent, - 0 -}; -DECLARE_MODULE(ath_rate, sample_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); -MODULE_VERSION(ath_rate, 1); -MODULE_DEPEND(ath_rate, ath_hal, 1, 1, 1); /* Atheros HAL */ -MODULE_DEPEND(ath_rate, wlan, 1, 1, 1); Modified: stable/7/sys/dev/ath/if_ath.c ============================================================================== --- stable/7/sys/dev/ath/if_ath.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/if_ath.c Thu Mar 12 03:09:11 2009 (r189720) @@ -77,13 +77,17 @@ __FBSDID("$FreeBSD$"); #endif #include -#include -#include /* XXX for softled */ +#include /* XXX for softled */ #ifdef ATH_TX99_DIAG #include #endif +/* + * We require a HAL w/ the changes for split tx/rx MIC. + */ +CTASSERT(HAL_ABI_VERSION > 0x06052200); + /* unaligned little endian access */ #define LE_READ_2(p) \ ((u_int16_t) \ @@ -378,7 +382,6 @@ ath_attach(u_int16_t devid, struct ath_s goto bad; } callout_init(&sc->sc_cal_ch, CALLOUT_MPSAFE); - callout_init(&sc->sc_dfs_ch, CALLOUT_MPSAFE); ATH_TXBUF_LOCK_INIT(sc); @@ -2250,14 +2253,13 @@ ath_key_update_end(struct ieee80211com * static u_int32_t ath_calcrxfilter(struct ath_softc *sc) { -#define RX_FILTER_PRESERVE (HAL_RX_FILTER_PHYERR | HAL_RX_FILTER_PHYRADAR) struct ieee80211com *ic = &sc->sc_ic; - struct ath_hal *ah = sc->sc_ah; struct ifnet *ifp = sc->sc_ifp; u_int32_t rfilt; - rfilt = (ath_hal_getrxfilter(ah) & RX_FILTER_PRESERVE) - | HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; + rfilt = HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; + if (!sc->sc_needmib && !sc->sc_scanning) + rfilt |= HAL_RX_FILTER_PHYERR; if (ic->ic_opmode != IEEE80211_M_STA) rfilt |= HAL_RX_FILTER_PROBEREQ; if (ic->ic_opmode != IEEE80211_M_HOSTAP && @@ -4890,42 +4892,6 @@ ath_chan_change(struct ath_softc *sc, st } /* - * Poll for a channel clear indication; this is required - * for channels requiring DFS and not previously visited - * and/or with a recent radar detection. - */ -static void -ath_dfswait(void *arg) -{ - struct ath_softc *sc = arg; - struct ath_hal *ah = sc->sc_ah; - HAL_CHANNEL hchan; - - ath_hal_radar_wait(ah, &hchan); - DPRINTF(sc, ATH_DEBUG_DFS, "%s: radar_wait %u/%x/%x\n", - __func__, hchan.channel, hchan.channelFlags, hchan.privFlags); - - if (hchan.privFlags & CHANNEL_INTERFERENCE) { - if_printf(sc->sc_ifp, - "channel %u/0x%x/0x%x has interference\n", - hchan.channel, hchan.channelFlags, hchan.privFlags); - return; - } - if ((hchan.privFlags & CHANNEL_DFS) == 0) { - /* XXX should not happen */ - return; - } - if (hchan.privFlags & CHANNEL_DFS_CLEAR) { - sc->sc_curchan.privFlags |= CHANNEL_DFS_CLEAR; - sc->sc_ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - if_printf(sc->sc_ifp, - "channel %u/0x%x/0x%x marked clear\n", - hchan.channel, hchan.channelFlags, hchan.privFlags); - } else - callout_reset(&sc->sc_dfs_ch, 2 * hz, ath_dfswait, sc); -} - -/* * Set/change channels. If the channel is really being changed, * it's done by reseting the chip. To accomplish this we must * first cleanup any pending DMA, then restart stuff after a la @@ -4996,25 +4962,6 @@ ath_chan_set(struct ath_softc *sc, struc ath_chan_change(sc, chan); /* - * Handle DFS required waiting period to determine - * if channel is clear of radar traffic. - */ - if (ic->ic_opmode == IEEE80211_M_HOSTAP) { -#define DFS_AND_NOT_CLEAR(_c) \ - (((_c)->privFlags & (CHANNEL_DFS | CHANNEL_DFS_CLEAR)) == CHANNEL_DFS) - if (DFS_AND_NOT_CLEAR(&sc->sc_curchan)) { - if_printf(sc->sc_ifp, - "wait for DFS clear channel signal\n"); - /* XXX stop sndq */ - sc->sc_ifp->if_drv_flags |= IFF_DRV_OACTIVE; - callout_reset(&sc->sc_dfs_ch, - 2 * hz, ath_dfswait, sc); - } else - callout_stop(&sc->sc_dfs_ch); -#undef DFS_NOT_CLEAR - } - - /* * Re-enable interrupts. */ ath_hal_intrset(ah, sc->sc_imask); @@ -5163,7 +5110,6 @@ ath_newstate(struct ieee80211com *ic, en ieee80211_state_name[nstate]); callout_stop(&sc->sc_cal_ch); - callout_stop(&sc->sc_dfs_ch); ath_hal_setledstate(ah, leds[nstate]); /* set LED */ if (nstate == IEEE80211_S_INIT) { Modified: stable/7/sys/dev/ath/if_ath_pci.c ============================================================================== --- stable/7/sys/dev/ath/if_ath_pci.c Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/if_ath_pci.c Thu Mar 12 03:09:11 2009 (r189720) @@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include @@ -279,6 +278,4 @@ static devclass_t ath_devclass; DRIVER_MODULE(if_ath, pci, ath_pci_driver, ath_devclass, 0, 0); DRIVER_MODULE(if_ath, cardbus, ath_pci_driver, ath_devclass, 0, 0); MODULE_VERSION(if_ath, 1); -MODULE_DEPEND(if_ath, ath_hal, 1, 1, 1); /* Atheros HAL */ MODULE_DEPEND(if_ath, wlan, 1, 1, 1); /* 802.11 media layer */ -MODULE_DEPEND(if_ath, ath_rate, 1, 1, 1); /* rate control algorithm */ Modified: stable/7/sys/dev/ath/if_athvar.h ============================================================================== --- stable/7/sys/dev/ath/if_athvar.h Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/dev/ath/if_athvar.h Thu Mar 12 03:09:11 2009 (r189720) @@ -35,8 +35,8 @@ #ifndef _DEV_ATH_ATHVAR_H #define _DEV_ATH_ATHVAR_H -#include -#include +#include +#include #include #include #include @@ -315,7 +315,6 @@ struct ath_softc { int sc_calinterval; /* current polling interval */ int sc_caltries; /* cals at current interval */ HAL_NODE_STATS sc_halstats; /* station-mode rssi stats */ - struct callout sc_dfs_ch; /* callout handle for dfs */ }; #define sc_tx_th u_tx_rt.th #define sc_rx_th u_rx_rt.th @@ -483,7 +482,7 @@ void ath_intr(void *); #define ath_hal_getregdomain(_ah, _prd) \ (ath_hal_getcapability(_ah, HAL_CAP_REG_DMN, 0, (_prd)) == HAL_OK) #define ath_hal_setregdomain(_ah, _rd) \ - ((*(_ah)->ah_setRegulatoryDomain)((_ah), (_rd), NULL)) + ath_hal_setcapability(_ah, HAL_CAP_REG_DMN, 0, _rd, NULL) #define ath_hal_getcountrycode(_ah, _pcc) \ (*(_pcc) = (_ah)->ah_countryCode) #define ath_hal_hastkipsplit(_ah) \ @@ -618,7 +617,4 @@ void ath_intr(void *); #define ath_hal_gpiosetintr(_ah, _gpio, _b) \ ((*(_ah)->ah_gpioSetIntr)((_ah), (_gpio), (_b))) -#define ath_hal_radar_wait(_ah, _chan) \ - ((*(_ah)->ah_radarWait)((_ah), (_chan))) - #endif /* _DEV_ATH_ATHVAR_H */ Modified: stable/7/sys/i386/conf/GENERIC ============================================================================== --- stable/7/sys/i386/conf/GENERIC Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/i386/conf/GENERIC Thu Mar 12 03:09:11 2009 (r189720) @@ -255,6 +255,7 @@ device wlan_scan_sta # 802.11 STA mode device an # Aironet 4500/4800 802.11 wireless NICs. device ath # Atheros pci/cardbus NIC's device ath_hal # Atheros HAL (Hardware Access Layer) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath device awi # BayStack 660 and others device ral # Ralink Technology RT2500 wireless NICs. Modified: stable/7/sys/i386/conf/NOTES ============================================================================== --- stable/7/sys/i386/conf/NOTES Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/i386/conf/NOTES Thu Mar 12 03:09:11 2009 (r189720) @@ -680,6 +680,7 @@ device wpi device ath device ath_hal # Atheros HAL (includes binary component) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors #device ath_rate_amrr # AMRR rate control for ath driver #device ath_rate_onoe # Onoe rate control for ath driver device ath_rate_sample # SampleRate rate control for the ath driver Modified: stable/7/sys/modules/Makefile ============================================================================== --- stable/7/sys/modules/Makefile Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/modules/Makefile Thu Mar 12 03:09:11 2009 (r189720) @@ -28,11 +28,7 @@ SUBDIR= ${_3dfx} \ ${_arl} \ ${_asr} \ ata \ - ${_ath} \ - ${_ath_hal} \ - ${_ath_rate_amrr} \ - ${_ath_rate_onoe} \ - ${_ath_rate_sample} \ + ath \ aue \ ${_auxio} \ ${_awi} \ @@ -379,11 +375,6 @@ _aout= aout _apm= apm _ar= ar _arcnet= arcnet -_ath= ath -_ath_hal= ath_hal -_ath_rate_amrr= ath_rate_amrr -_ath_rate_onoe= ath_rate_onoe -_ath_rate_sample=ath_rate_sample _awi= awi _bktr= bktr _cardbus= cardbus @@ -517,11 +508,6 @@ _acpi= acpi _agp= agp _an= an _arcmsr= arcmsr -_ath= ath -_ath_hal= ath_hal -_ath_rate_amrr= ath_rate_amrr -_ath_rate_onoe= ath_rate_onoe -_ath_rate_sample=ath_rate_sample _cardbus= cardbus _cbb= cbb _cmx= cmx @@ -627,22 +613,12 @@ _xe= xe .if ${MACHINE_ARCH} == "powerpc" _an= an -_ath= ath -_ath_hal= ath_hal -_ath_rate_amrr= ath_rate_amrr -_ath_rate_onoe= ath_rate_onoe -_ath_rate_sample=ath_rate_sample _bm= bm _nvram= powermac_nvram _smbfs= smbfs .endif .if ${MACHINE_ARCH} == "sparc64" -_ath= ath -_ath_hal= ath_hal -_ath_rate_amrr= ath_rate_amrr -_ath_rate_onoe= ath_rate_onoe -_ath_rate_sample=ath_rate_sample _auxio= auxio _em= em _i2c= i2c Modified: stable/7/sys/modules/ath/Makefile ============================================================================== --- stable/7/sys/modules/ath/Makefile Thu Mar 12 02:51:55 2009 (r189719) +++ stable/7/sys/modules/ath/Makefile Thu Mar 12 03:09:11 2009 (r189720) @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting +# Copyright (c) 2002-2008 Sam Leffler, Errno Consulting *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From kib at FreeBSD.org Thu Mar 12 06:45:57 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Thu Mar 12 06:46:15 2009 Subject: svn commit: r189740 - in stable/7: . lib/libc lib/libc/string lib/libc/sys sys sys/contrib/pf sys/dev/ath/ath_hal sys/dev/cxgb sys/kern sys/sys Message-ID: <200903121345.n2CDjt4P031917@svn.freebsd.org> Author: kib Date: Thu Mar 12 13:45:55 2009 New Revision: 189740 URL: http://svn.freebsd.org/changeset/base/189740 Log: MFC r189283: Correct types of variables used to track amount of allocated SysV shared memory from int to size_t. Implement a workaround for current ABI not allowing to properly save size for and report more then 2GB sized segment of shared memory. This makes it possible to use > 2 GB shared memory segments on 64bit architectures. Please note the new BUGS section in shmctl(2) and UPDATING note for limitations of this temporal solution. MFC r189398: Systematically use vm_size_t to specify the size of the segment for VM KPI. Do not overload the local variable size in kern_shmat() due to vm_size_t change. Fix style bug by adding explicit comparision with 0. MFC r189399: Improve the grammar and wording in the changes to shmctl(2) manpage. Put an UPDATING entry and bump __FreeBSD_version for the change. Modified: stable/7/UPDATING stable/7/lib/libc/ (props changed) stable/7/lib/libc/string/ffsll.c (props changed) stable/7/lib/libc/string/flsll.c (props changed) stable/7/lib/libc/sys/shmctl.2 stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/sysv_shm.c stable/7/sys/sys/param.h stable/7/sys/sys/shm.h Modified: stable/7/UPDATING ============================================================================== --- stable/7/UPDATING Thu Mar 12 13:17:46 2009 (r189739) +++ stable/7/UPDATING Thu Mar 12 13:45:55 2009 (r189740) @@ -9,6 +9,19 @@ Items affecting the ports and packages s portupgrade. 20090312: + A workaround is committed to allow the creation of System V shared + memory segment of size > 2 GB on the 64-bit architectures. + Due to a limitation of the existing ABI, the shm_segsz member + of the struct shmid_ds, returned by shmctl(IPC_STAT) call is + wrong for large segments. Note that limits must be explicitely + raised to allow such segments to be created. + + The management interface that is used by ipcs(1) has to be changed + in incompatible way. Rebuild the ipcs(1) utility with the new + headers after the update. Buildworld/installworld takes care + of this issue automatically. + +20090312: The open-source Atheros HAL has been merged from HEAD to STABLE. The kernel compile-time option AH_SUPPORT_AR5416 has been Modified: stable/7/lib/libc/sys/shmctl.2 ============================================================================== --- stable/7/lib/libc/sys/shmctl.2 Thu Mar 12 13:17:46 2009 (r189739) +++ stable/7/lib/libc/sys/shmctl.2 Thu Mar 12 13:45:55 2009 (r189740) @@ -133,6 +133,16 @@ the shared memory segment's owner or cre Permission denied due to mismatch between operation and mode of shared memory segment. .El +.Sh "BUGS" +The segment size has size_t type. +The shm_segsz member of the +.Vt shmid_ds +structure has type int, which is too short to represent the full range +of values for a segment size. +If shared memory limits are raised to allow segments with size > 2 GB +to be created, be aware that IPC_STAT call may return a truncated value +for shm_segsz. +.El .Sh "SEE ALSO" .Xr shmat 2 , .Xr shmdt 2 , Modified: stable/7/sys/kern/sysv_shm.c ============================================================================== --- stable/7/sys/kern/sysv_shm.c Thu Mar 12 13:17:46 2009 (r189739) +++ stable/7/sys/kern/sysv_shm.c Thu Mar 12 13:45:55 2009 (r189740) @@ -121,7 +121,8 @@ static sy_call_t *shmcalls[] = { #define SHMSEG_ALLOCATED 0x0800 #define SHMSEG_WANTED 0x1000 -static int shm_last_free, shm_nused, shm_committed, shmalloced; +static int shm_last_free, shm_nused, shmalloced; +vm_size_t shm_committed; static struct shmid_kernel *shmsegs; struct shmmap_state { @@ -244,13 +245,13 @@ static void shm_deallocate_segment(shmseg) struct shmid_kernel *shmseg; { - size_t size; + vm_size_t size; GIANT_REQUIRED; vm_object_deallocate(shmseg->u.shm_internal); shmseg->u.shm_internal = NULL; - size = round_page(shmseg->u.shm_segsz); + size = round_page(shmseg->shm_bsegsz); shm_committed -= btoc(size); shm_nused--; shmseg->u.shm_perm.mode = SHMSEG_FREE; @@ -264,13 +265,13 @@ shm_delete_mapping(struct vmspace *vm, s { struct shmid_kernel *shmseg; int segnum, result; - size_t size; + vm_size_t size; GIANT_REQUIRED; segnum = IPCID_TO_IX(shmmap_s->shmid); shmseg = &shmsegs[segnum]; - size = round_page(shmseg->u.shm_segsz); + size = round_page(shmseg->shm_bsegsz); result = vm_map_remove(&vm->vm_map, shmmap_s->va, shmmap_s->va + size); if (result != KERN_SUCCESS) return (EINVAL); @@ -361,8 +362,8 @@ kern_shmat(td, shmid, shmaddr, shmflg) mtx_lock(&Giant); shmmap_s = p->p_vmspace->vm_shm; if (shmmap_s == NULL) { - size = shminfo.shmseg * sizeof(struct shmmap_state); - shmmap_s = malloc(size, M_SHM, M_WAITOK); + shmmap_s = malloc(shminfo.shmseg * sizeof(struct shmmap_state), + M_SHM, M_WAITOK); for (i = 0; i < shminfo.shmseg; i++) shmmap_s[i].shmid = -1; p->p_vmspace->vm_shm = shmmap_s; @@ -390,7 +391,7 @@ kern_shmat(td, shmid, shmaddr, shmflg) error = EMFILE; goto done2; } - size = round_page(shmseg->u.shm_segsz); + size = round_page(shmseg->shm_bsegsz); #ifdef VM_PROT_READ_IS_EXEC prot = VM_PROT_READ | VM_PROT_EXECUTE; #else @@ -422,7 +423,8 @@ kern_shmat(td, shmid, shmaddr, shmflg) vm_object_reference(shmseg->u.shm_internal); rv = vm_map_find(&p->p_vmspace->vm_map, shmseg->u.shm_internal, - 0, &attach_va, size, (flags & MAP_FIXED)?0:1, prot, prot, 0); + 0, &attach_va, size, (flags & MAP_FIXED) ? VMFS_NO_SPACE : + VMFS_ANY_SPACE, prot, prot, 0); if (rv != KERN_SUCCESS) { vm_object_deallocate(shmseg->u.shm_internal); error = ENOMEM; @@ -705,7 +707,7 @@ shmget_existing(td, uap, mode, segnum) if (error != 0) return (error); #endif - if (uap->size && uap->size > shmseg->u.shm_segsz) + if (uap->size != 0 && uap->size > shmseg->shm_bsegsz) return (EINVAL); td->td_retval[0] = IXSEQ_TO_IPCID(segnum, shmseg->u.shm_perm); return (0); @@ -717,7 +719,8 @@ shmget_allocate_segment(td, uap, mode) struct shmget_args *uap; int mode; { - int i, segnum, shmid, size; + int i, segnum, shmid; + size_t size; struct ucred *cred = td->td_ucred; struct shmid_kernel *shmseg; vm_object_t shm_object; @@ -775,6 +778,7 @@ shmget_allocate_segment(td, uap, mode) shmseg->u.shm_perm.mode = (shmseg->u.shm_perm.mode & SHMSEG_WANTED) | (mode & ACCESSPERMS) | SHMSEG_ALLOCATED; shmseg->u.shm_segsz = uap->size; + shmseg->shm_bsegsz = uap->size; shmseg->u.shm_cpid = td->td_proc->p_pid; shmseg->u.shm_lpid = shmseg->u.shm_nattch = 0; shmseg->u.shm_atime = shmseg->u.shm_dtime = 0; Modified: stable/7/sys/sys/param.h ============================================================================== --- stable/7/sys/sys/param.h Thu Mar 12 13:17:46 2009 (r189739) +++ stable/7/sys/sys/param.h Thu Mar 12 13:45:55 2009 (r189740) @@ -57,7 +57,7 @@ * is created, otherwise 1. */ #undef __FreeBSD_version -#define __FreeBSD_version 701104 /* Master, propagated to newvers */ +#define __FreeBSD_version 701105 /* Master, propagated to newvers */ #ifndef LOCORE #include Modified: stable/7/sys/sys/shm.h ============================================================================== --- stable/7/sys/sys/shm.h Thu Mar 12 13:17:46 2009 (r189739) +++ stable/7/sys/sys/shm.h Thu Mar 12 13:45:55 2009 (r189740) @@ -108,6 +108,7 @@ struct shminfo { struct shmid_kernel { struct shmid_ds u; struct label *label; /* MAC label */ + size_t shm_bsegsz; }; extern struct shminfo shminfo; From jhb at FreeBSD.org Thu Mar 12 10:32:06 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Thu Mar 12 10:32:12 2009 Subject: svn commit: r189746 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern Message-ID: <200903121732.n2CHW4tg036479@svn.freebsd.org> Author: jhb Date: Thu Mar 12 17:32:04 2009 New Revision: 189746 URL: http://svn.freebsd.org/changeset/base/189746 Log: MFC: Export hz, maxswzone, maxbcache, maxtsiz, dfldsiz, maxdsiz, dflssiz, maxssiz, and sgrowsiz via sysctl. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/subr_param.c Modified: stable/7/sys/kern/subr_param.c ============================================================================== --- stable/7/sys/kern/subr_param.c Thu Mar 12 17:23:02 2009 (r189745) +++ stable/7/sys/kern/subr_param.c Thu Mar 12 17:32:04 2009 (r189746) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -85,6 +86,24 @@ u_long dflssiz; /* initial stack size u_long maxssiz; /* max stack size */ u_long sgrowsiz; /* amount to grow stack */ +SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN, &hz, 0, "ticks/second"); +SYSCTL_INT(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN, &maxswzone, 0, + "max swmeta KVA storage"); +SYSCTL_INT(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN, &maxbcache, 0, + "max buffer cache KVA storage"); +SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RDTUN, &maxtsiz, 0, + "max text size"); +SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RDTUN, &dfldsiz, 0, + "initial data size limit"); +SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RDTUN, &maxdsiz, 0, + "max data size"); +SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RDTUN, &dflssiz, 0, + "initial stack size limit"); +SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RDTUN, &maxssiz, 0, + "max stack size"); +SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RDTUN, &sgrowsiz, 0, + "amount to grow stack"); + /* * These have to be allocated somewhere; allocating * them here forces loader errors if this file is omitted From jhb at FreeBSD.org Thu Mar 12 15:01:43 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Thu Mar 12 15:02:00 2009 Subject: svn commit: r189750 - stable/7/sys/vm Message-ID: <200903122201.n2CM1g8A041773@svn.freebsd.org> Author: jhb Date: Thu Mar 12 22:01:42 2009 New Revision: 189750 URL: http://svn.freebsd.org/changeset/base/189750 Log: Disable the vm_page_startup assertion for now. It always fails on platforms with superpages currently because the pages used by vm_reserv_startup() are incorrectly included in the 'npages' count. I haven't removed the assertion as I think this is a real bug, but the side effect is just that some memory is wasted on never-used vm_page structures. The assertion was removed from HEAD which is why the bug wasn't noticed there (and thus this is a direct commit to 7). Modified: stable/7/sys/vm/vm_page.c Modified: stable/7/sys/vm/vm_page.c ============================================================================== --- stable/7/sys/vm/vm_page.c Thu Mar 12 20:41:52 2009 (r189749) +++ stable/7/sys/vm/vm_page.c Thu Mar 12 22:01:42 2009 (r189750) @@ -363,15 +363,21 @@ vm_page_startup(vm_offset_t vaddr) vm_page_array[i].order = VM_NFREEORDER; vm_page_array_size = page_range; +#if 0 /* * This assertion tests the hypothesis that npages and total are * redundant. XXX + * + * XXX: This always fails if VM_NRESERVLEVEL > 0 because + * npages includes the memory for vm_reserv_startup() but + * page_range doesn't. */ page_range = 0; for (i = 0; phys_avail[i + 1] != 0; i += 2) page_range += atop(phys_avail[i + 1] - phys_avail[i]); KASSERT(page_range == npages, ("vm_page_startup: inconsistent page counts")); +#endif /* * Initialize the physical memory allocator. From kib at FreeBSD.org Fri Mar 13 03:52:24 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Fri Mar 13 03:52:32 2009 Subject: svn commit: r189766 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/devfs kern sys Message-ID: <200903131052.n2DAqN8n061365@svn.freebsd.org> Author: kib Date: Fri Mar 13 10:52:22 2009 New Revision: 189766 URL: http://svn.freebsd.org/changeset/base/189766 Log: MFC r189450: Extract the no_poll() and vop_nopoll() code into the common routine poll_no_poll(). Return a poll_no_poll() result from devfs_poll_f() when filedescriptor does not reference the live cdev, instead of ENXIO. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/devfs/devfs_vnops.c stable/7/sys/kern/kern_conf.c stable/7/sys/kern/sys_generic.c stable/7/sys/kern/vfs_default.c stable/7/sys/sys/systm.h Modified: stable/7/sys/fs/devfs/devfs_vnops.c ============================================================================== --- stable/7/sys/fs/devfs/devfs_vnops.c Fri Mar 13 10:40:38 2009 (r189765) +++ stable/7/sys/fs/devfs/devfs_vnops.c Fri Mar 13 10:52:22 2009 (r189766) @@ -973,7 +973,7 @@ devfs_poll_f(struct file *fp, int events fpop = td->td_fpop; error = devfs_fp_check(fp, &dev, &dsw); if (error) - return (error); + return (poll_no_poll(events)); error = dsw->d_poll(dev, events, td); td->td_fpop = fpop; dev_relthread(dev); Modified: stable/7/sys/kern/kern_conf.c ============================================================================== --- stable/7/sys/kern/kern_conf.c Fri Mar 13 10:40:38 2009 (r189765) +++ stable/7/sys/kern/kern_conf.c Fri Mar 13 10:52:22 2009 (r189766) @@ -313,18 +313,8 @@ no_strategy(struct bio *bp) static int no_poll(struct cdev *dev __unused, int events, struct thread *td __unused) { - /* - * Return true for read/write. If the user asked for something - * special, return POLLNVAL, so that clients have a way of - * determining reliably whether or not the extended - * functionality is present without hard-coding knowledge - * of specific filesystem implementations. - * Stay in sync with vop_nopoll(). - */ - if (events & ~POLLSTANDARD) - return (POLLNVAL); - return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); + return (poll_no_poll(events)); } #define no_dump (dumper_t *)enodev Modified: stable/7/sys/kern/sys_generic.c ============================================================================== --- stable/7/sys/kern/sys_generic.c Fri Mar 13 10:40:38 2009 (r189765) +++ stable/7/sys/kern/sys_generic.c Fri Mar 13 10:52:22 2009 (r189766) @@ -637,6 +637,22 @@ struct cv selwait; u_int nselcoll; /* Select collisions since boot */ SYSCTL_UINT(_kern, OID_AUTO, nselcoll, CTLFLAG_RD, &nselcoll, 0, ""); +int +poll_no_poll(int events) +{ + /* + * Return true for read/write. If the user asked for something + * special, return POLLNVAL, so that clients have a way of + * determining reliably whether or not the extended + * functionality is present without hard-coding knowledge + * of specific filesystem implementations. + */ + if (events & ~POLLSTANDARD) + return (POLLNVAL); + + return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); +} + #ifndef _SYS_SYSPROTO_H_ struct select_args { int nd; Modified: stable/7/sys/kern/vfs_default.c ============================================================================== --- stable/7/sys/kern/vfs_default.c Fri Mar 13 10:40:38 2009 (r189765) +++ stable/7/sys/kern/vfs_default.c Fri Mar 13 10:52:22 2009 (r189766) @@ -344,18 +344,8 @@ vop_nopoll(ap) struct thread *a_td; } */ *ap; { - /* - * Return true for read/write. If the user asked for something - * special, return POLLNVAL, so that clients have a way of - * determining reliably whether or not the extended - * functionality is present without hard-coding knowledge - * of specific filesystem implementations. - * Stay in sync with kern_conf.c::no_poll(). - */ - if (ap->a_events & ~POLLSTANDARD) - return (POLLNVAL); - return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); + return (poll_no_poll(ap->a_events)); } /* Modified: stable/7/sys/sys/systm.h ============================================================================== --- stable/7/sys/sys/systm.h Fri Mar 13 10:40:38 2009 (r189765) +++ stable/7/sys/sys/systm.h Fri Mar 13 10:52:22 2009 (r189766) @@ -321,6 +321,8 @@ int uminor(dev_t dev); int umajor(dev_t dev); const char *devtoname(struct cdev *cdev); +int poll_no_poll(int events); + /* XXX: Should be void nanodelay(u_int nsec); */ void DELAY(int usec); From bms at FreeBSD.org Fri Mar 13 18:12:35 2009 From: bms at FreeBSD.org (Bruce M Simpson) Date: Fri Mar 13 18:12:52 2009 Subject: svn commit: r189781 - stable/7/sys/kern Message-ID: <200903140112.n2E1CZmM077949@svn.freebsd.org> Author: bms Date: Sat Mar 14 01:12:35 2009 New Revision: 189781 URL: http://svn.freebsd.org/changeset/base/189781 Log: MFC rev: 189736 Ensure that the semaphore value is re-checked after sem_lock is re-acquired, after the condition variable is signalled. Early MFC, as the test case in the PR is fairly complete and the submitter also re-ran test case on -STABLE. It also bites Python fairly hard, which will otherwise try to use POSIX sems for its internal thread synchronization; this needs more in-depth testing. PR: http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/127545 Reviewed by: attilio Modified: stable/7/sys/kern/uipc_sem.c Modified: stable/7/sys/kern/uipc_sem.c ============================================================================== --- stable/7/sys/kern/uipc_sem.c Sat Mar 14 00:33:08 2009 (r189780) +++ stable/7/sys/kern/uipc_sem.c Sat Mar 14 01:12:35 2009 (r189781) @@ -722,7 +722,7 @@ kern_sem_wait(struct thread *td, semid_t #endif DP(("kern_sem_wait value = %d, tryflag %d\n", ks->ks_value, tryflag)); vfs_timestamp(&ks->ks_atime); - if (ks->ks_value == 0) { + while (ks->ks_value == 0) { ks->ks_waiters++; if (tryflag != 0) error = EAGAIN; From bms at incunabulum.net Fri Mar 13 18:25:02 2009 From: bms at incunabulum.net (Bruce Simpson) Date: Fri Mar 13 18:25:13 2009 Subject: svn commit: r189781 - stable/7/sys/kern In-Reply-To: <200903140112.n2E1CZmM077949@svn.freebsd.org> References: <200903140112.n2E1CZmM077949@svn.freebsd.org> Message-ID: <49BB0769.6030200@incunabulum.net> Bruce M Simpson wrote: > Early MFC, as the test case in the PR is fairly complete and the > submitter also re-ran test case on -STABLE. It also bites Python > fairly hard, which will otherwise try to use POSIX sems for its > internal thread synchronization; this needs more in-depth testing. > Note: FreeBSD's build of Python does NOT attempt to use POSIX sems by default, it will only do this if explicitly patched to do so. It defaults to using condvars + mutexes to build Python's internal thread locks. I'd encourage folk to try the patch which does this, I only posted the 'side-step' patch (i.e. use GNU Pth, needs to be explicitly enabled in OPTIONS) but the changes needed are in here too: http://people.freebsd.org/~bms/dump/python26-fbsd-pth.patch cheers BMS From bms at incunabulum.net Fri Mar 13 19:05:37 2009 From: bms at incunabulum.net (Bruce Simpson) Date: Fri Mar 13 19:05:43 2009 Subject: svn commit: r189781 - stable/7/sys/kern In-Reply-To: <200903140112.n2E1CZmM077949@svn.freebsd.org> References: <200903140112.n2E1CZmM077949@svn.freebsd.org> Message-ID: <49BB10EC.9010705@incunabulum.net> A big thanks to jhb@ for pushing much of the housekeeping around semaphores into the file descriptor layer, btw; without his major help, the fix for the logic wouldn't have been a one line diff. From bms at FreeBSD.org Sat Mar 14 01:34:46 2009 From: bms at FreeBSD.org (Bruce M Simpson) Date: Sat Mar 14 01:34:59 2009 Subject: svn commit: r189786 - stable/7/sys/sys Message-ID: <200903140834.n2E8Yjn8086457@svn.freebsd.org> Author: bms Date: Sat Mar 14 08:34:45 2009 New Revision: 189786 URL: http://svn.freebsd.org/changeset/base/189786 Log: Bump __FreeBSD_version to 701106 after the POSIX semaphore fix was committed. Modified: stable/7/sys/sys/param.h Modified: stable/7/sys/sys/param.h ============================================================================== --- stable/7/sys/sys/param.h Sat Mar 14 08:28:02 2009 (r189785) +++ stable/7/sys/sys/param.h Sat Mar 14 08:34:45 2009 (r189786) @@ -57,7 +57,7 @@ * is created, otherwise 1. */ #undef __FreeBSD_version -#define __FreeBSD_version 701105 /* Master, propagated to newvers */ +#define __FreeBSD_version 701106 /* Master, propagated to newvers */ #ifndef LOCORE #include From bms at incunabulum.net Sat Mar 14 05:33:36 2009 From: bms at incunabulum.net (Bruce Simpson) Date: Sat Mar 14 05:33:43 2009 Subject: svn commit: r189781 - stable/7/sys/kern In-Reply-To: <49BB0769.6030200@incunabulum.net> References: <200903140112.n2E1CZmM077949@svn.freebsd.org> <49BB0769.6030200@incunabulum.net> Message-ID: <49BBA41B.9010308@incunabulum.net> Bruce Simpson wrote: > > http://people.freebsd.org/~bms/dump/python26-fbsd-pth.patch This patch has been committed to the lang/python26 port with some fixups (thanks miwi). If you're a Python user, please try testing a Python port build with the SEM option selected so POSIX semaphores can receive more in-depth testing. thanks, BMS From kib at FreeBSD.org Sat Mar 14 07:02:54 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sat Mar 14 07:03:10 2009 Subject: svn commit: r189791 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb ufs/ffs Message-ID: <200903141402.n2EE2ra6095140@svn.freebsd.org> Author: kib Date: Sat Mar 14 14:02:53 2009 New Revision: 189791 URL: http://svn.freebsd.org/changeset/base/189791 Log: MFC r189706: Do not double-free the struct inode when insmntque failed. Default insmntque destructor reclaims the vnode, and ufs_reclaim frees the memory. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_vfsops.c Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Mar 14 13:42:13 2009 (r189790) +++ stable/7/sys/ufs/ffs/ffs_vfsops.c Sat Mar 14 14:02:53 2009 (r189791) @@ -1465,7 +1465,6 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags vp->v_vflag |= VV_FORCEINSMQ; error = insmntque(vp, mp); if (error != 0) { - uma_zfree(uma_inode, ip); *vpp = NULL; return (error); } From das at FreeBSD.org Sat Mar 14 11:19:51 2009 From: das at FreeBSD.org (David Schultz) Date: Sat Mar 14 11:19:57 2009 Subject: svn commit: r189802 - in stable/7/lib/libc: . stdio Message-ID: <200903141819.n2EIJouL003728@svn.freebsd.org> Author: das Date: Sat Mar 14 18:19:50 2009 New Revision: 189802 URL: http://svn.freebsd.org/changeset/base/189802 Log: Partial MFC of r189131: Make sure %zd treats negative arguments properly on 32-bit platforms. PR: 131880 Modified: stable/7/lib/libc/ (props changed) stable/7/lib/libc/stdio/vfprintf.c stable/7/lib/libc/stdio/vfwprintf.c Modified: stable/7/lib/libc/stdio/vfprintf.c ============================================================================== --- stable/7/lib/libc/stdio/vfprintf.c Sat Mar 14 17:55:16 2009 (r189801) +++ stable/7/lib/libc/stdio/vfprintf.c Sat Mar 14 18:19:50 2009 (r189802) @@ -598,7 +598,7 @@ __vfprintf(FILE *fp, const char *fmt0, v #define INTMAX_SIZE (INTMAXT|SIZET|PTRDIFFT|LLONGINT) #define SJARG() \ (flags&INTMAXT ? GETARG(intmax_t) : \ - flags&SIZET ? (intmax_t)GETARG(size_t) : \ + flags&SIZET ? (intmax_t)GETARG(ssize_t) : \ flags&PTRDIFFT ? (intmax_t)GETARG(ptrdiff_t) : \ (intmax_t)GETARG(long long)) #define UJARG() \ Modified: stable/7/lib/libc/stdio/vfwprintf.c ============================================================================== --- stable/7/lib/libc/stdio/vfwprintf.c Sat Mar 14 17:55:16 2009 (r189801) +++ stable/7/lib/libc/stdio/vfwprintf.c Sat Mar 14 18:19:50 2009 (r189802) @@ -604,7 +604,7 @@ __vfwprintf(FILE *fp, const wchar_t *fmt #define INTMAX_SIZE (INTMAXT|SIZET|PTRDIFFT|LLONGINT) #define SJARG() \ (flags&INTMAXT ? GETARG(intmax_t) : \ - flags&SIZET ? (intmax_t)GETARG(size_t) : \ + flags&SIZET ? (intmax_t)GETARG(ssize_t) : \ flags&PTRDIFFT ? (intmax_t)GETARG(ptrdiff_t) : \ (intmax_t)GETARG(long long)) #define UJARG() \ From kib at FreeBSD.org Sat Mar 14 12:03:42 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sat Mar 14 12:03:57 2009 Subject: svn commit: r189810 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern sys Message-ID: <200903141903.n2EJ3fZ6004945@svn.freebsd.org> Author: kib Date: Sat Mar 14 19:03:40 2009 New Revision: 189810 URL: http://svn.freebsd.org/changeset/base/189810 Log: MFC r178585 (by pjd): Implement 'show mount' command in DDB. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/vfs_subr.c stable/7/sys/sys/mount.h Modified: stable/7/sys/kern/vfs_subr.c ============================================================================== --- stable/7/sys/kern/vfs_subr.c Sat Mar 14 19:03:34 2009 (r189809) +++ stable/7/sys/kern/vfs_subr.c Sat Mar 14 19:03:40 2009 (r189810) @@ -2712,6 +2712,158 @@ DB_SHOW_COMMAND(vnode, db_show_vnode) vp = (struct vnode *)addr; vn_printf(vp, "vnode "); } + +/* + * Show details about the given mount point. + */ +DB_SHOW_COMMAND(mount, db_show_mount) +{ + struct mount *mp; + struct statfs *sp; + struct vnode *vp; + char buf[512]; + u_int flags; + + if (!have_addr) { + /* No address given, print short info about all mount points. */ + TAILQ_FOREACH(mp, &mountlist, mnt_list) { + db_printf("%p %s on %s (%s)\n", mp, + mp->mnt_stat.f_mntfromname, + mp->mnt_stat.f_mntonname, + mp->mnt_stat.f_fstypename); + } + db_printf("\nMore info: show mount \n"); + return; + } + + mp = (struct mount *)addr; + db_printf("%p %s on %s (%s)\n", mp, mp->mnt_stat.f_mntfromname, + mp->mnt_stat.f_mntonname, mp->mnt_stat.f_fstypename); + + buf[0] = '\0'; + flags = mp->mnt_flag; +#define MNT_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 4, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + MNT_FLAG(MNT_RDONLY); + MNT_FLAG(MNT_SYNCHRONOUS); + MNT_FLAG(MNT_NOEXEC); + MNT_FLAG(MNT_NOSUID); + MNT_FLAG(MNT_UNION); + MNT_FLAG(MNT_ASYNC); + MNT_FLAG(MNT_SUIDDIR); + MNT_FLAG(MNT_SOFTDEP); + MNT_FLAG(MNT_NOSYMFOLLOW); + MNT_FLAG(MNT_GJOURNAL); + MNT_FLAG(MNT_MULTILABEL); + MNT_FLAG(MNT_ACLS); + MNT_FLAG(MNT_NOATIME); + MNT_FLAG(MNT_NOCLUSTERR); + MNT_FLAG(MNT_NOCLUSTERW); + MNT_FLAG(MNT_EXRDONLY); + MNT_FLAG(MNT_EXPORTED); + MNT_FLAG(MNT_DEFEXPORTED); + MNT_FLAG(MNT_EXPORTANON); + MNT_FLAG(MNT_EXKERB); + MNT_FLAG(MNT_EXPUBLIC); + MNT_FLAG(MNT_LOCAL); + MNT_FLAG(MNT_QUOTA); + MNT_FLAG(MNT_ROOTFS); + MNT_FLAG(MNT_USER); + MNT_FLAG(MNT_IGNORE); + MNT_FLAG(MNT_UPDATE); + MNT_FLAG(MNT_DELEXPORT); + MNT_FLAG(MNT_RELOAD); + MNT_FLAG(MNT_FORCE); + MNT_FLAG(MNT_SNAPSHOT); + MNT_FLAG(MNT_BYFSID); +#undef MNT_FLAG + if (flags != 0) { + if (buf[0] != '\0') + strlcat(buf, ", ", sizeof(buf)); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "0x%08x", flags); + } + db_printf(" mnt_flag = %s\n", buf); + + buf[0] = '\0'; + flags = mp->mnt_kern_flag; +#define MNT_KERN_FLAG(flag) do { \ + if (flags & (flag)) { \ + if (buf[0] != '\0') \ + strlcat(buf, ", ", sizeof(buf)); \ + strlcat(buf, (#flag) + 5, sizeof(buf)); \ + flags &= ~(flag); \ + } \ +} while (0) + MNT_KERN_FLAG(MNTK_UNMOUNTF); + MNT_KERN_FLAG(MNTK_ASYNC); + MNT_KERN_FLAG(MNTK_SOFTDEP); + MNT_KERN_FLAG(MNTK_NOINSMNTQ); + MNT_KERN_FLAG(MNTK_UNMOUNT); + MNT_KERN_FLAG(MNTK_MWAIT); + MNT_KERN_FLAG(MNTK_SUSPEND); + MNT_KERN_FLAG(MNTK_SUSPEND2); + MNT_KERN_FLAG(MNTK_SUSPENDED); + MNT_KERN_FLAG(MNTK_MPSAFE); + MNT_KERN_FLAG(MNTK_NOKNOTE); + MNT_KERN_FLAG(MNTK_LOOKUP_SHARED); +#undef MNT_KERN_FLAG + if (flags != 0) { + if (buf[0] != '\0') + strlcat(buf, ", ", sizeof(buf)); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "0x%08x", flags); + } + db_printf(" mnt_kern_flag = %s\n", buf); + + sp = &mp->mnt_stat; + db_printf(" mnt_stat = { version=%u type=%u flags=0x%016jx " + "bsize=%ju iosize=%ju blocks=%ju bfree=%ju bavail=%jd files=%ju " + "ffree=%jd syncwrites=%ju asyncwrites=%ju syncreads=%ju " + "asyncreads=%ju namemax=%u owner=%u fsid=[%d, %d] }\n", + (u_int)sp->f_version, (u_int)sp->f_type, (uintmax_t)sp->f_flags, + (uintmax_t)sp->f_bsize, (uintmax_t)sp->f_iosize, + (uintmax_t)sp->f_blocks, (uintmax_t)sp->f_bfree, + (intmax_t)sp->f_bavail, (uintmax_t)sp->f_files, + (intmax_t)sp->f_ffree, (uintmax_t)sp->f_syncwrites, + (uintmax_t)sp->f_asyncwrites, (uintmax_t)sp->f_syncreads, + (uintmax_t)sp->f_asyncreads, (u_int)sp->f_namemax, + (u_int)sp->f_owner, (int)sp->f_fsid.val[0], (int)sp->f_fsid.val[1]); + + db_printf(" mnt_cred = { uid=%u ruid=%u", + (u_int)mp->mnt_cred->cr_uid, (u_int)mp->mnt_cred->cr_ruid); + if (mp->mnt_cred->cr_prison != NULL) + db_printf(", jail=%d", mp->mnt_cred->cr_prison->pr_id); + db_printf(" }\n"); + db_printf(" mnt_ref = %d\n", mp->mnt_ref); + db_printf(" mnt_gen = %d\n", mp->mnt_gen); + db_printf(" mnt_nvnodelistsize = %d\n", mp->mnt_nvnodelistsize); + db_printf(" mnt_writeopcount = %d\n", mp->mnt_writeopcount); + db_printf(" mnt_noasync = %u\n", mp->mnt_noasync); + db_printf(" mnt_maxsymlinklen = %d\n", mp->mnt_maxsymlinklen); + db_printf(" mnt_iosize_max = %d\n", mp->mnt_iosize_max); + db_printf(" mnt_hashseed = %u\n", mp->mnt_hashseed); + db_printf(" mnt_markercnt = %d\n", mp->mnt_markercnt); + db_printf(" mnt_holdcnt = %d\n", mp->mnt_holdcnt); + db_printf(" mnt_holdcntwaiters = %d\n", mp->mnt_holdcntwaiters); + db_printf(" mnt_secondary_writes = %d\n", mp->mnt_secondary_writes); + db_printf(" mnt_secondary_accwrites = %d\n", + mp->mnt_secondary_accwrites); + db_printf(" mnt_gjprovider = %s\n", + mp->mnt_gjprovider != NULL ? mp->mnt_gjprovider : "NULL"); + db_printf("\n"); + + TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) { + if (vp->v_type != VMARKER) + vn_printf(vp, "vnode "); + } +} #endif /* DDB */ /* Modified: stable/7/sys/sys/mount.h ============================================================================== --- stable/7/sys/sys/mount.h Sat Mar 14 19:03:34 2009 (r189809) +++ stable/7/sys/sys/mount.h Sat Mar 14 19:03:40 2009 (r189810) @@ -41,6 +41,11 @@ #include #endif +/* + * NOTE: When changing statfs structure, mount structure, MNT_* flags or + * MNTK_* flags also update DDB show mount command in vfs_subr.c. + */ + typedef struct fsid { int32_t val[2]; } fsid_t; /* filesystem id type */ /* From kib at FreeBSD.org Sat Mar 14 12:35:13 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sat Mar 14 12:35:30 2009 Subject: svn commit: r189823 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern Message-ID: <200903141935.n2EJZDYT006077@svn.freebsd.org> Author: kib Date: Sat Mar 14 19:35:13 2009 New Revision: 189823 URL: http://svn.freebsd.org/changeset/base/189823 Log: MFC r179093 (by pjd): Be more friendly for DDB pager. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/vfs_subr.c Modified: stable/7/sys/kern/vfs_subr.c ============================================================================== --- stable/7/sys/kern/vfs_subr.c Sat Mar 14 19:17:00 2009 (r189822) +++ stable/7/sys/kern/vfs_subr.c Sat Mar 14 19:35:13 2009 (r189823) @@ -2731,6 +2731,8 @@ DB_SHOW_COMMAND(mount, db_show_mount) mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname, mp->mnt_stat.f_fstypename); + if (db_pager_quit) + break; } db_printf("\nMore info: show mount \n"); return; @@ -2860,8 +2862,11 @@ DB_SHOW_COMMAND(mount, db_show_mount) db_printf("\n"); TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) { - if (vp->v_type != VMARKER) + if (vp->v_type != VMARKER) { vn_printf(vp, "vnode "); + if (db_pager_quit) + break; + } } } #endif /* DDB */ From mlaier at FreeBSD.org Sat Mar 14 14:03:04 2009 From: mlaier at FreeBSD.org (Max Laier) Date: Sat Mar 14 14:03:16 2009 Subject: svn commit: r189831 - stable/7/usr.bin/du Message-ID: <200903142103.n2EL33ee008078@svn.freebsd.org> Author: mlaier Date: Sat Mar 14 21:03:03 2009 New Revision: 189831 URL: http://svn.freebsd.org/changeset/base/189831 Log: MFC: - r184733, r184742 Add -A and -B options - r184654, r184656 style(9) changes - r173387, r173431 (by kevlo) Check return value for setenv() In effect sync head and releng/7. Modified: stable/7/usr.bin/du/ (props changed) stable/7/usr.bin/du/du.1 stable/7/usr.bin/du/du.c Modified: stable/7/usr.bin/du/du.1 ============================================================================== --- stable/7/usr.bin/du/du.1 Sat Mar 14 20:40:06 2009 (r189830) +++ stable/7/usr.bin/du/du.1 Sat Mar 14 21:03:03 2009 (r189831) @@ -32,7 +32,7 @@ .\" @(#)du.1 8.2 (Berkeley) 4/1/94 .\" $FreeBSD$ .\" -.Dd February 25, 2008 +.Dd November 6, 2008 .Dt DU 1 .Os .Sh NAME @@ -40,11 +40,12 @@ .Nd display disk usage statistics .Sh SYNOPSIS .Nm +.Op Fl A .Op Fl H | L | P .Op Fl a | s | d Ar depth .Op Fl c .Op Fl l -.Op Fl h | k | m +.Op Fl h | k | m | B Ar blocksize .Op Fl n .Op Fl x .Op Fl I Ar mask @@ -60,6 +61,25 @@ the current directory is displayed. .Pp The options are as follows: .Bl -tag -width indent +.It Fl A +Display the apparent size instead of the disk usage. +This can be helpful when operating on compressed volumes or sparse files. +.It Fl B Ar blocksize +Calculate block counts in +.Ar blocksize +byte blocks. +This is different from the +.Fl k, m +options or setting +.Ev BLOCKSIZE +and gives an estimate of how much space the examined file hierachy would +require on a filesystem with the given +.Ar blocksize . +Unless in +.Fl A +mode, +.Ar blocksize +is rounded up to the next multiple of 512. .It Fl H Symbolic links on the command line are followed, symbolic links in file hierarchies are not followed. @@ -136,14 +156,19 @@ followed is not counted or displayed. If the environment variable .Ev BLOCKSIZE is set, and the -.Fl k -option is not specified, the block counts will be displayed in units of that -size block. +.Fl k, m +or +.Fl h +options are not specified, the block counts will be displayed in units of +that block size. If .Ev BLOCKSIZE is not set, and the -.Fl k -option is not specified, the block counts will be displayed in 512-byte blocks. +.Fl k, m +or +.Fl h +options are not specified, the block counts will be displayed in 512-byte +blocks. .El .Sh SEE ALSO .Xr df 1 , Modified: stable/7/usr.bin/du/du.c ============================================================================== --- stable/7/usr.bin/du/du.c Sat Mar 14 20:40:06 2009 (r189830) +++ stable/7/usr.bin/du/du.c Sat Mar 14 21:03:03 2009 (r189831) @@ -73,20 +73,21 @@ struct ignentry { static int linkchk(FTSENT *); static void usage(void); -void prthumanval(int64_t); -void ignoreadd(const char *); -void ignoreclean(void); -int ignorep(FTSENT *); - -int nodumpflag = 0; +static void prthumanval(int64_t); +static void ignoreadd(const char *); +static void ignoreclean(void); +static int ignorep(FTSENT *); + +static int nodumpflag = 0; +static int Aflag; +static long blocksize, cblocksize; int main(int argc, char *argv[]) { FTS *fts; FTSENT *p; - off_t savednumber = 0; - long blocksize; + off_t savednumber, curblocks; int ftsoptions; int listall; int depth; @@ -98,75 +99,91 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); Hflag = Lflag = Pflag = aflag = sflag = dflag = cflag = hflag = - lflag = 0; + lflag = Aflag = 0; save = argv; ftsoptions = 0; + savednumber = 0; + cblocksize = DEV_BSIZE; + blocksize = 0; depth = INT_MAX; SLIST_INIT(&ignores); - while ((ch = getopt(argc, argv, "HI:LPasd:chklmnrx")) != -1) + while ((ch = getopt(argc, argv, "AB:HI:LPasd:chklmnrx")) != -1) switch (ch) { - case 'H': - Hflag = 1; - break; - case 'I': - ignoreadd(optarg); - break; - case 'L': - if (Pflag) - usage(); - Lflag = 1; - break; - case 'P': - if (Lflag) - usage(); - Pflag = 1; - break; - case 'a': - aflag = 1; - break; - case 's': - sflag = 1; - break; - case 'd': - dflag = 1; - errno = 0; - depth = atoi(optarg); - if (errno == ERANGE || depth < 0) { - warnx("invalid argument to option d: %s", optarg); - usage(); - } - break; - case 'c': - cflag = 1; - break; - case 'h': - setenv("BLOCKSIZE", "512", 1); - hflag = 1; - break; - case 'k': - hflag = 0; - setenv("BLOCKSIZE", "1024", 1); - break; - case 'l': - lflag = 1; - break; - case 'm': - hflag = 0; - setenv("BLOCKSIZE", "1048576", 1); - break; - case 'n': - nodumpflag = 1; - break; - case 'r': /* Compatibility. */ - break; - case 'x': - ftsoptions |= FTS_XDEV; - break; - case '?': - default: + case 'A': + Aflag = 1; + break; + case 'B': + errno = 0; + cblocksize = atoi(optarg); + if (errno == ERANGE || cblocksize <= 0) { + warnx("invalid argument to option B: %s", + optarg); + usage(); + } + break; + case 'H': + Hflag = 1; + break; + case 'I': + ignoreadd(optarg); + break; + case 'L': + if (Pflag) + usage(); + Lflag = 1; + break; + case 'P': + if (Lflag) usage(); + Pflag = 1; + break; + case 'a': + aflag = 1; + break; + case 's': + sflag = 1; + break; + case 'd': + dflag = 1; + errno = 0; + depth = atoi(optarg); + if (errno == ERANGE || depth < 0) { + warnx("invalid argument to option d: %s", + optarg); + usage(); + } + break; + case 'c': + cflag = 1; + break; + case 'h': + hflag = 1; + break; + case 'k': + hflag = 0; + blocksize = 1024; + break; + case 'l': + lflag = 1; + break; + case 'm': + hflag = 0; + blocksize = 1048576; + break; + case 'n': + nodumpflag = 1; + break; + case 'r': /* Compatibility. */ + break; + case 'x': + ftsoptions |= FTS_XDEV; + break; + case '?': + default: + usage(); + /* NOTREACHED */ } argc -= optind; @@ -200,6 +217,9 @@ main(int argc, char *argv[]) if (Pflag) ftsoptions |= FTS_PHYSICAL; + if (!Aflag && (cblocksize % DEV_BSIZE) != 0) + cblocksize = howmany(cblocksize, DEV_BSIZE) * DEV_BSIZE; + listall = 0; if (aflag) { @@ -218,8 +238,13 @@ main(int argc, char *argv[]) argv[1] = NULL; } - (void) getbsize(¬used, &blocksize); - blocksize /= 512; + if (blocksize == 0) + (void)getbsize(¬used, &blocksize); + + if (!Aflag) { + cblocksize /= DEV_BSIZE; + blocksize /= DEV_BSIZE; + } rval = 0; @@ -228,57 +253,65 @@ main(int argc, char *argv[]) while ((p = fts_read(fts)) != NULL) { switch (p->fts_info) { - case FTS_D: /* Ignore. */ - if (ignorep(p)) - fts_set(fts, p, FTS_SKIP); - break; - case FTS_DP: - if (ignorep(p)) - break; - - p->fts_parent->fts_bignum += - p->fts_bignum += p->fts_statp->st_blocks; - - if (p->fts_level <= depth) { - if (hflag) { - (void) prthumanval(howmany(p->fts_bignum, blocksize)); - (void) printf("\t%s\n", p->fts_path); - } else { - (void) printf("%jd\t%s\n", - (intmax_t)howmany(p->fts_bignum, blocksize), + case FTS_D: /* Ignore. */ + if (ignorep(p)) + fts_set(fts, p, FTS_SKIP); + break; + case FTS_DP: + if (ignorep(p)) + break; + + curblocks = Aflag ? + howmany(p->fts_statp->st_size, cblocksize) : + howmany(p->fts_statp->st_blocks, cblocksize); + p->fts_parent->fts_bignum += p->fts_bignum += + curblocks; + + if (p->fts_level <= depth) { + if (hflag) { + prthumanval(p->fts_bignum); + (void)printf("\t%s\n", p->fts_path); + } else { + (void)printf("%jd\t%s\n", + (intmax_t)howmany(p->fts_bignum * + cblocksize, blocksize), p->fts_path); - } } - break; - case FTS_DC: /* Ignore. */ - break; - case FTS_DNR: /* Warn, continue. */ - case FTS_ERR: - case FTS_NS: - warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); - rval = 1; - break; - default: - if (ignorep(p)) - break; - - if (lflag == 0 && - p->fts_statp->st_nlink > 1 && linkchk(p)) - break; - - if (listall || p->fts_level == 0) { - if (hflag) { - (void) prthumanval(howmany(p->fts_statp->st_blocks, - blocksize)); - (void) printf("\t%s\n", p->fts_path); - } else { - (void) printf("%jd\t%s\n", - (intmax_t)howmany(p->fts_statp->st_blocks, blocksize), - p->fts_path); - } + } + break; + case FTS_DC: /* Ignore. */ + break; + case FTS_DNR: /* Warn, continue. */ + case FTS_ERR: + case FTS_NS: + warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); + rval = 1; + break; + default: + if (ignorep(p)) + break; + + if (lflag == 0 && p->fts_statp->st_nlink > 1 && + linkchk(p)) + break; + + curblocks = Aflag ? + howmany(p->fts_statp->st_size, cblocksize) : + howmany(p->fts_statp->st_blocks, cblocksize); + + if (listall || p->fts_level == 0) { + if (hflag) { + prthumanval(curblocks); + (void)printf("\t%s\n", p->fts_path); + } else { + (void)printf("%jd\t%s\n", + (intmax_t)howmany(curblocks * + cblocksize, blocksize), + p->fts_path); } + } - p->fts_parent->fts_bignum += p->fts_statp->st_blocks; + p->fts_parent->fts_bignum += curblocks; } savednumber = p->fts_parent->fts_bignum; } @@ -288,10 +321,11 @@ main(int argc, char *argv[]) if (cflag) { if (hflag) { - (void) prthumanval(howmany(savednumber, blocksize)); - (void) printf("\ttotal\n"); + prthumanval(savednumber); + (void)printf("\ttotal\n"); } else { - (void) printf("%jd\ttotal\n", (intmax_t)howmany(savednumber, blocksize)); + (void)printf("%jd\ttotal\n", (intmax_t)howmany( + savednumber * cblocksize, blocksize)); } } @@ -344,7 +378,8 @@ linkchk(FTSENT *p) free_list = le->next; free(le); } - new_buckets = malloc(new_size * sizeof(new_buckets[0])); + new_buckets = malloc(new_size * + sizeof(new_buckets[0])); } if (new_buckets == NULL) { @@ -432,12 +467,14 @@ linkchk(FTSENT *p) return (0); } -void +static void prthumanval(int64_t bytes) { char buf[5]; - bytes *= DEV_BSIZE; + bytes *= cblocksize; + if (!Aflag) + bytes *= DEV_BSIZE; humanize_number(buf, sizeof(buf), bytes, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); @@ -449,12 +486,13 @@ static void usage(void) { (void)fprintf(stderr, - "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] " - "[-l] [-h | -k | -m] [-n] [-x] [-I mask] [file ...]\n"); + "usage: du [-A] [-H | -L | -P] [-a | -s | -d depth] [-c] " + "[-l] [-h | -k | -m | -B bsize] [-n] [-x] [-I mask] " + "[file ...]\n"); exit(EX_USAGE); } -void +static void ignoreadd(const char *mask) { struct ignentry *ign; @@ -468,7 +506,7 @@ ignoreadd(const char *mask) SLIST_INSERT_HEAD(&ignores, ign, next); } -void +static void ignoreclean(void) { struct ignentry *ign; @@ -481,7 +519,7 @@ ignoreclean(void) } } -int +static int ignorep(FTSENT *ent) { struct ignentry *ign; From kib at FreeBSD.org Sun Mar 15 03:43:49 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Mar 15 03:44:01 2009 Subject: svn commit: r189849 - stable/7/sbin/devd Message-ID: <200903151043.n2FAhmR4024131@svn.freebsd.org> Author: kib Date: Sun Mar 15 10:43:48 2009 New Revision: 189849 URL: http://svn.freebsd.org/changeset/base/189849 Log: MFC r189534: Document several notifications. MFC r189538 (by maxim): Spell. Sort .Xrs. Modified: stable/7/sbin/devd/ (props changed) stable/7/sbin/devd/devd.conf.5 Modified: stable/7/sbin/devd/devd.conf.5 ============================================================================== --- stable/7/sbin/devd/devd.conf.5 Sun Mar 15 09:58:31 2009 (r189848) +++ stable/7/sbin/devd/devd.conf.5 Sun Mar 15 10:43:48 2009 (r189849) @@ -41,7 +41,7 @@ .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE. .\" -.Dd October 25, 2006 +.Dd March 8, 2009 .Dt DEVD.CONF 5 .Os .Sh NAME @@ -120,7 +120,7 @@ Specifies PID file. .It Ic set Ar regexp-name Qq Ar (some|regexp) ; Creates a regular expression and assigns it to the variable .Ar regexp-name . -The variable is avaiable throughout the rest of +The variable is available throughout the rest of the configuration file. All regular expressions have an implicit .Ql ^$ @@ -208,7 +208,7 @@ The following sub-statements are support statement. The .Dq Li notify -variable is avaiable inside this statement and contains, a value, depending +variable is available inside this statement and contains, a value, depending on which system and subsystem that delivered the event. .Bl -tag -width ".Ic directory" .It Ic action Qq Ar command ; @@ -223,7 +223,7 @@ statements can exist within a statement; .Ar value can be either a fixed string or a regular expression. -Below is a list of avaiable systems, subsystems, and types. +Below is a list of available systems, subsystems, and types. .It Ic media-type Qq Ar string ; See above. .El @@ -238,6 +238,10 @@ statement. .Ic Description .It Li bus Device name of parent bus. +.It Li cdev +Device node path if one is created by the +.Xr devfs 5 +filesystem. .It Li cisproduct CIS-product. .It Li cisvendor @@ -280,7 +284,7 @@ A partial list of systems, subsystems, a .Ic notify mechanism. .Pp -.Bl -tag -width ".Li IFNET" -compact +.Bl -tag -width ".Li coretemp" -compact .It Sy System .It Li ACPI Events related to the ACPI subsystem. @@ -313,6 +317,55 @@ took place. Carrier status changed to UP. .It Li LINK_DOWN Carrier status changed to DOWN. +.It Li ATTACH +The network interface is attached to the system. +.It Li DETACH +The network interface is detached from the system. +.El +.El +.It Li DEVFS +Events related to the +.Xr devfs 5 +filesystem. +.Bl -tag -width ".Sy Subsystem" -compact +.It Sy Subsystem +.It Li CDEV +.Bl -tag -width ".Li DESTROY" -compact +.It Sy Type +.It Li CREATE +The +.Xr devfs 5 +node is created. +.It Li DESTROY +The +.Xr devfs 5 +node is destroyed. +.El +.El +.It Li coretemp +Events related to the +.Xr coretemp 4 +device. +.Bl -tag -width ".Sy Subsystem" -compact +.It Sy Subsystem +.It Li Thermal +Notification that the CPU core has reached critical temperature. +.Bl -tag -width ".Ar temperature" -compact +.It Sy Type +.It Ar temperature +String containing the temperature of the core that has become too hot. +.El +.El +.It Li kern +Events related to the kernel. +.Bl -tag -width ".Sy Subsystem" -compact +.It Sy Subsystem +.It Li power +Information about the state of the system. +.Bl -tag -width ".li resume" -compact +.It Sy Type +.It Li resume +Notification that the system has woken from the suspended state. .El .El .El @@ -430,4 +483,6 @@ The installed .Pa /etc/devd.conf has many additional examples. .Sh SEE ALSO +.Xr coretemp 4 , +.Xr devfs 5 , .Xr devd 8 From rnoland at FreeBSD.org Sun Mar 15 10:20:30 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Sun Mar 15 10:20:44 2009 Subject: svn commit: r189855 - in stable/7/sys: . conf contrib/pf dev/ath/ath_hal dev/cxgb dev/drm modules/drm/radeon Message-ID: <200903151720.n2FHKS1C034884@svn.freebsd.org> Author: rnoland Date: Sun Mar 15 17:20:28 2009 New Revision: 189855 URL: http://svn.freebsd.org/changeset/base/189855 Log: Merge 189499,189557,189558 This is the radeon r600+ code with fixes. A few days early, but it seems to fix some other vblank related issues as well. 189499: Import support for ATI Radeon R600 and R700 series chips. Tested on an HD3850 (RV670) on loan from Warren Block. Currently, you need one of the following for this to be useful: x11-drivers/xf86-video-radeonhd-devel (not tested) xf86-video-ati from git (EXA works, xv is too fast) xf86-video-radeonhd from git (EXA works, xv works) There is no 3d support available from dri just yet. 189557: Call the right function for the right chipset. 189558: -Make the PCI(E)/AGP calculations consistent -Calculate the scratch address correctly Added: stable/7/sys/dev/drm/r600_cp.c - copied, changed from r189499, head/sys/dev/drm/r600_cp.c stable/7/sys/dev/drm/r600_microcode.h - copied unchanged from r189499, head/sys/dev/drm/r600_microcode.h Modified: stable/7/sys/ (props changed) stable/7/sys/conf/files stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_pciids.h stable/7/sys/dev/drm/radeon_cp.c stable/7/sys/dev/drm/radeon_drm.h stable/7/sys/dev/drm/radeon_drv.h stable/7/sys/dev/drm/radeon_irq.c stable/7/sys/dev/drm/radeon_state.c stable/7/sys/modules/drm/radeon/Makefile Modified: stable/7/sys/conf/files ============================================================================== --- stable/7/sys/conf/files Sun Mar 15 16:12:50 2009 (r189854) +++ stable/7/sys/conf/files Sun Mar 15 17:20:28 2009 (r189855) @@ -755,6 +755,7 @@ dev/drm/r128_irq.c optional r128drm dev/drm/r128_state.c optional r128drm \ compile-with "${NORMAL_C} -finline-limit=13500" dev/drm/r300_cmdbuf.c optional radeondrm +dev/drm/r600_cp.c optional radeondrm dev/drm/radeon_cp.c optional radeondrm dev/drm/radeon_drv.c optional radeondrm dev/drm/radeon_irq.c optional radeondrm Modified: stable/7/sys/dev/drm/drm_pciids.h ============================================================================== --- stable/7/sys/dev/drm/drm_pciids.h Sun Mar 15 16:12:50 2009 (r189854) +++ stable/7/sys/dev/drm/drm_pciids.h Sun Mar 15 17:20:28 2009 (r189855) @@ -240,12 +240,123 @@ {0x1002, 0x7297, CHIP_RV560|RADEON_NEW_MEMMAP, "ATI RV560"}, \ {0x1002, 0x7834, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP, "ATI Radeon RS350 9000/9100 IGP"}, \ {0x1002, 0x7835, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Radeon RS350 Mobility IGP"}, \ + {0x1002, 0x793f, CHIP_RS600|RADEON_IS_IGP|RADEON_NEW_MEMMAP, "ATI Radeon X1200"}, \ + {0x1002, 0x7941, CHIP_RS600|RADEON_IS_IGP|RADEON_NEW_MEMMAP, "ATI Radeon X1200"}, \ + {0x1002, 0x7942, CHIP_RS600|RADEON_IS_IGP|RADEON_NEW_MEMMAP, "ATI Radeon X1200"}, \ {0x1002, 0x791e, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS690 X1250 IGP"}, \ {0x1002, 0x791f, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS690 X1270 IGP"}, \ {0x1002, 0x796c, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 HD2100 IGP"}, \ {0x1002, 0x796d, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 HD2100 IGP"}, \ {0x1002, 0x796e, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 HD2100 IGP"}, \ {0x1002, 0x796f, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 HD2100 IGP"}, \ + {0x1002, 0x9400, CHIP_R600|RADEON_NEW_MEMMAP, "ATI Radeon HD 2900 XT"}, \ + {0x1002, 0x9401, CHIP_R600|RADEON_NEW_MEMMAP, "ATI Radeon HD 2900 XT"}, \ + {0x1002, 0x9402, CHIP_R600|RADEON_NEW_MEMMAP, "ATI Radeon HD 2900 XT"}, \ + {0x1002, 0x9403, CHIP_R600|RADEON_NEW_MEMMAP, "ATI Radeon HD 2900 Pro"}, \ + {0x1002, 0x9405, CHIP_R600|RADEON_NEW_MEMMAP, "ATI Radeon HD 2900 GT"}, \ + {0x1002, 0x940A, CHIP_R600|RADEON_NEW_MEMMAP, "ATI FireGL V8650"}, \ + {0x1002, 0x940B, CHIP_R600|RADEON_NEW_MEMMAP, "ATI FireGL V8600"}, \ + {0x1002, 0x940F, CHIP_R600|RADEON_NEW_MEMMAP, "ATI FireGL V7600"}, \ + {0x1002, 0x94C0, CHIP_RV610|RADEON_NEW_MEMMAP, "RV610"}, \ + {0x1002, 0x94C1, CHIP_RV610|RADEON_NEW_MEMMAP, "Radeon HD 2400 XT"}, \ + {0x1002, 0x94C3, CHIP_RV610|RADEON_NEW_MEMMAP, "Radeon HD 2400 Pro"}, \ + {0x1002, 0x94C4, CHIP_RV610|RADEON_NEW_MEMMAP, "Radeon HD 2400 PRO AGP"}, \ + {0x1002, 0x94C5, CHIP_RV610|RADEON_NEW_MEMMAP, "FireGL V4000"}, \ + {0x1002, 0x94C6, CHIP_RV610|RADEON_NEW_MEMMAP, "RV610"}, \ + {0x1002, 0x94C7, CHIP_RV610|RADEON_NEW_MEMMAP, "ATI Radeon HD 2350"}, \ + {0x1002, 0x94C8, CHIP_RV610|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 2400 XT"}, \ + {0x1002, 0x94C9, CHIP_RV610|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 2400"}, \ + {0x1002, 0x94CB, CHIP_RV610|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI RADEON E2400"}, \ + {0x1002, 0x94CC, CHIP_RV610|RADEON_NEW_MEMMAP, "ATI RV610"}, \ + {0x1002, 0x94CD, CHIP_RV610|RADEON_NEW_MEMMAP, "ATI FireMV 2260"}, \ + {0x1002, 0x9500, CHIP_RV670|RADEON_NEW_MEMMAP, "ATI RV670"}, \ + {0x1002, 0x9501, CHIP_RV670|RADEON_NEW_MEMMAP, "ATI Radeon HD3870"}, \ + {0x1002, 0x9504, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 3850"}, \ + {0x1002, 0x9505, CHIP_RV670|RADEON_NEW_MEMMAP, "ATI Radeon HD3850"}, \ + {0x1002, 0x9506, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 3850 X2"}, \ + {0x1002, 0x9507, CHIP_RV670|RADEON_NEW_MEMMAP, "ATI RV670"}, \ + {0x1002, 0x9508, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 3870"}, \ + {0x1002, 0x9509, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 3870 X2"}, \ + {0x1002, 0x950F, CHIP_RV670|RADEON_NEW_MEMMAP, "ATI Radeon HD3870 X2"}, \ + {0x1002, 0x9511, CHIP_RV670|RADEON_NEW_MEMMAP, "ATI FireGL V7700"}, \ + {0x1002, 0x9515, CHIP_RV670|RADEON_NEW_MEMMAP, "ATI Radeon HD3850"}, \ + {0x1002, 0x9517, CHIP_RV670|RADEON_NEW_MEMMAP, "ATI Radeon HD3690"}, \ + {0x1002, 0x9519, CHIP_RV670|RADEON_NEW_MEMMAP, "AMD Firestream 9170"}, \ + {0x1002, 0x9580, CHIP_RV630|RADEON_NEW_MEMMAP, "ATI RV630"}, \ + {0x1002, 0x9581, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 2600"}, \ + {0x1002, 0x9583, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 2600 XT"}, \ + {0x1002, 0x9586, CHIP_RV630|RADEON_NEW_MEMMAP, "ATI Radeon HD 2600 XT AGP"}, \ + {0x1002, 0x9587, CHIP_RV630|RADEON_NEW_MEMMAP, "ATI Radeon HD 2600 Pro AGP"}, \ + {0x1002, 0x9588, CHIP_RV630|RADEON_NEW_MEMMAP, "ATI Radeon HD 2600 XT"}, \ + {0x1002, 0x9589, CHIP_RV630|RADEON_NEW_MEMMAP, "ATI Radeon HD 2600 Pro"}, \ + {0x1002, 0x958A, CHIP_RV630|RADEON_NEW_MEMMAP, "ATI Gemini RV630"}, \ + {0x1002, 0x958B, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Gemini Mobility Radeon HD 2600 XT"}, \ + {0x1002, 0x958C, CHIP_RV630|RADEON_NEW_MEMMAP, "ATI FireGL V5600"}, \ + {0x1002, 0x958D, CHIP_RV630|RADEON_NEW_MEMMAP, "ATI FireGL V3600"}, \ + {0x1002, 0x958E, CHIP_RV630|RADEON_NEW_MEMMAP, "ATI Radeon HD 2600 LE"}, \ + {0x1002, 0x958F, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility FireGL Graphics Processor"}, \ + {0x1002, 0x95C0, CHIP_RV620|RADEON_NEW_MEMMAP, "ATI Radeon HD 3470"}, \ + {0x1002, 0x95C5, CHIP_RV620|RADEON_NEW_MEMMAP, "ATI Radeon HD 3450"}, \ + {0x1002, 0x95C6, CHIP_RV620|RADEON_NEW_MEMMAP, "ATI Radeon HD 3450"}, \ + {0x1002, 0x95C7, CHIP_RV620|RADEON_NEW_MEMMAP, "ATI Radeon HD 3430"}, \ + {0x1002, 0x95C9, CHIP_RV620|RADEON_NEW_MEMMAP, "ATI Radeon HD 3450"}, \ + {0x1002, 0x95C2, CHIP_RV620|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 3430"}, \ + {0x1002, 0x95C4, CHIP_RV620|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 3400 Series"}, \ + {0x1002, 0x95CC, CHIP_RV620|RADEON_NEW_MEMMAP, "ATI FirePro V3700"}, \ + {0x1002, 0x95CD, CHIP_RV620|RADEON_NEW_MEMMAP, "ATI FireMV 2450"}, \ + {0x1002, 0x95CE, CHIP_RV620|RADEON_NEW_MEMMAP, "ATI FireMV 2260"}, \ + {0x1002, 0x95CF, CHIP_RV620|RADEON_NEW_MEMMAP, "ATI FireMV 2260"}, \ + {0x1002, 0x9590, CHIP_RV635|RADEON_NEW_MEMMAP, "ATI ATI Radeon HD 3600 Series"}, \ + {0x1002, 0x9596, CHIP_RV635|RADEON_NEW_MEMMAP, "ATI ATI Radeon HD 3650 AGP"}, \ + {0x1002, 0x9597, CHIP_RV635|RADEON_NEW_MEMMAP, "ATI ATI Radeon HD 3600 PRO"}, \ + {0x1002, 0x9598, CHIP_RV635|RADEON_NEW_MEMMAP, "ATI ATI Radeon HD 3600 XT"}, \ + {0x1002, 0x9599, CHIP_RV635|RADEON_NEW_MEMMAP, "ATI ATI Radeon HD 3600 PRO"}, \ + {0x1002, 0x9591, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 3650"}, \ + {0x1002, 0x9593, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 3670"}, \ + {0x1002, 0x9595, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility FireGL V5700"}, \ + {0x1002, 0x959B, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility FireGL V5725"}, \ + {0x1002, 0x9610, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Radeon HD 3200 Graphics"}, \ + {0x1002, 0x9611, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Radeon 3100 Graphics"}, \ + {0x1002, 0x9612, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Radeon HD 3200 Graphics"}, \ + {0x1002, 0x9613, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Radeon 3100 Graphics"}, \ + {0x1002, 0x9614, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Radeon 3300 Graphics"}, \ + {0x1002, 0x9440, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \ + {0x1002, 0x9441, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4870 X2"}, \ + {0x1002, 0x9442, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \ + {0x1002, 0x944C, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \ + {0x1002, 0x9450, CHIP_RV770|RADEON_NEW_MEMMAP, "AMD FireStream 9270"}, \ + {0x1002, 0x9452, CHIP_RV770|RADEON_NEW_MEMMAP, "AMD FireStream 9250"}, \ + {0x1002, 0x9444, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI FirePro V8750 (FireGL)"}, \ + {0x1002, 0x9446, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI FirePro V7760 (FireGL)"}, \ + {0x1002, 0x9456, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI FirePro V8700 (FireGL)"}, \ + {0x1002, 0x944E, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI FirePro RV770"}, \ + {0x1002, 0x944A, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 4850"}, \ + {0x1002, 0x944B, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 4850 X2"}, \ + {0x1002, 0x945A, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 4870"}, \ + {0x1002, 0x945B, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon M98"}, \ + {0x1002, 0x946A, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI FirePro M7750"}, \ + {0x1002, 0x946B, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI M98"}, \ + {0x1002, 0x947A, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI M98"}, \ + {0x1002, 0x947B, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI M98"}, \ + {0x1002, 0x9487, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI Radeon RV730 (AGP)"}, \ + {0x1002, 0x948F, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI Radeon RV730 (AGP)"}, \ + {0x1002, 0x9490, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI Radeon HD 4670"}, \ + {0x1002, 0x9498, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI Radeon HD 4650"}, \ + {0x1002, 0x9480, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 4650"}, \ + {0x1002, 0x9488, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 4670"}, \ + {0x1002, 0x9489, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI FirePro M5750"}, \ + {0x1002, 0x9491, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI RADEON E4600"}, \ + {0x1002, 0x949C, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI FirePro V7750 (FireGL)"}, \ + {0x1002, 0x949E, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI FirePro V5700 (FireGL)"}, \ + {0x1002, 0x949F, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI FirePro V3750 (FireGL)"}, \ + {0x1002, 0x9540, CHIP_RV710|RADEON_NEW_MEMMAP, "ATI Radeon HD 4550"}, \ + {0x1002, 0x9541, CHIP_RV710|RADEON_NEW_MEMMAP, "ATI Radeon RV710"}, \ + {0x1002, 0x9542, CHIP_RV710|RADEON_NEW_MEMMAP, "ATI Radeon RV710"}, \ + {0x1002, 0x954E, CHIP_RV710|RADEON_NEW_MEMMAP, "ATI Radeon RV710"}, \ + {0x1002, 0x954F, CHIP_RV710|RADEON_NEW_MEMMAP, "ATI Radeon HD 4350"}, \ + {0x1002, 0x9552, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon 4300 Series"}, \ + {0x1002, 0x9553, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon 4500 Series"}, \ + {0x1002, 0x9555, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon 4500 Series"}, \ {0, 0, 0, NULL} #define r128_PCI_IDS \ Copied and modified: stable/7/sys/dev/drm/r600_cp.c (from r189499, head/sys/dev/drm/r600_cp.c) ============================================================================== --- head/sys/dev/drm/r600_cp.c Sat Mar 7 21:36:57 2009 (r189499, copy source) +++ stable/7/sys/dev/drm/r600_cp.c Sun Mar 15 17:20:28 2009 (r189855) @@ -1633,6 +1633,7 @@ static void r600_cp_init_ring_buffer(str struct drm_file *file_priv) { u32 ring_start; + u64 rptr_addr; if (((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RV770)) r700_gfx_init(dev, dev_priv); @@ -1687,27 +1688,20 @@ static void r600_cp_init_ring_buffer(str #if __OS_HAS_AGP if (dev_priv->flags & RADEON_IS_AGP) { - /* XXX */ - RADEON_WRITE(R600_CP_RB_RPTR_ADDR, - (dev_priv->ring_rptr->offset - - dev->agp->base + dev_priv->gart_vm_start) >> 8); - RADEON_WRITE(R600_CP_RB_RPTR_ADDR_HI, 0); + rptr_addr = dev_priv->ring_rptr->offset + - dev->agp->base + + dev_priv->gart_vm_start; } else #endif { - struct drm_sg_mem *entry = dev->sg; - unsigned long tmp_ofs, page_ofs; - - tmp_ofs = dev_priv->ring_rptr->offset - - (unsigned long)dev->sg->virtual; - page_ofs = tmp_ofs >> PAGE_SHIFT; - - RADEON_WRITE(R600_CP_RB_RPTR_ADDR, entry->busaddr[page_ofs] >> 8); - RADEON_WRITE(R600_CP_RB_RPTR_ADDR_HI, 0); - DRM_DEBUG("ring rptr: offset=0x%08lx handle=0x%08lx\n", - (unsigned long)entry->busaddr[page_ofs], - entry->handle + tmp_ofs); - } + rptr_addr = dev_priv->ring_rptr->offset + - ((unsigned long) dev->sg->virtual) + + dev_priv->gart_vm_start; + } + RADEON_WRITE(R600_CP_RB_RPTR_ADDR, + rptr_addr & 0xffffffff); + RADEON_WRITE(R600_CP_RB_RPTR_ADDR_HI, + upper_32_bits(rptr_addr)); #ifdef __BIG_ENDIAN RADEON_WRITE(R600_CP_RB_CNTL, @@ -1756,8 +1750,17 @@ static void r600_cp_init_ring_buffer(str * We simply put this behind the ring read pointer, this works * with PCI GART as well as (whatever kind of) AGP GART */ - RADEON_WRITE(R600_SCRATCH_ADDR, ((RADEON_READ(R600_CP_RB_RPTR_ADDR) << 8) - + R600_SCRATCH_REG_OFFSET) >> 8); + { + u64 scratch_addr; + + scratch_addr = RADEON_READ(R600_CP_RB_RPTR_ADDR); + scratch_addr |= ((u64)RADEON_READ(R600_CP_RB_RPTR_ADDR_HI)) << 32; + scratch_addr += R600_SCRATCH_REG_OFFSET; + scratch_addr >>= 8; + scratch_addr &= 0xffffffff; + + RADEON_WRITE(R600_SCRATCH_ADDR, (uint32_t)scratch_addr); + } RADEON_WRITE(R600_SCRATCH_UMSK, 0x7); Copied: stable/7/sys/dev/drm/r600_microcode.h (from r189499, head/sys/dev/drm/r600_microcode.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/dev/drm/r600_microcode.h Sun Mar 15 17:20:28 2009 (r189855, copy of r189499, head/sys/dev/drm/r600_microcode.h) @@ -0,0 +1,23295 @@ +/*- + * Copyright 2007 Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include +__FBSDID("$FreeBSD$"); + +static const int ME_JUMP_TABLE_START = 1764; +static const int ME_JUMP_TABLE_END = 1792; + +#define PFP_UCODE_SIZE 576 +#define PM4_UCODE_SIZE 1792 +#define R700_PFP_UCODE_SIZE 848 +#define R700_PM4_UCODE_SIZE 1360 + +static const u32 R600_cp_microcode[][3]={ + { 0x00000000, 0xc0200400, 0x000 }, + { 0x00000000, 0x00a0000a, 0x000 }, + { 0x0000ffff, 0x00284621, 0x000 }, + { 0x00000000, 0xd9004800, 0x000 }, + { 0x00000000, 0xc0200400, 0x000 }, + { 0x00000000, 0x00a0000a, 0x000 }, + { 0x00000000, 0x00e00000, 0x000 }, + { 0x00010000, 0xc0294620, 0x000 }, + { 0x00000000, 0xd9004800, 0x000 }, + { 0x00000000, 0xc0200400, 0x000 }, + { 0x00000000, 0x00a0000a, 0x000 }, + { 0x81000000, 0x00204411, 0x000 }, + { 0x00000001, 0x00204811, 0x000 }, + { 0x00042004, 0x00604411, 0x614 }, + { 0x00000000, 0x00600000, 0x5b2 }, + { 0x00000000, 0x00600000, 0x5c5 }, + { 0x00000000, 0xc0200800, 0x000 }, + { 0x00000f00, 0x00281622, 0x000 }, + { 0x00000008, 0x00211625, 0x000 }, + { 0x00000020, 0x00203625, 0x000 }, + { 0x8d000000, 0x00204411, 0x000 }, + { 0x00000004, 0x002f0225, 0x000 }, + { 0x00000000, 0x0ce00000, 0x018 }, + { 0x00412000, 0x00404811, 0x019 }, + { 0x00422000, 0x00204811, 0x000 }, + { 0x8e000000, 0x00204411, 0x000 }, + { 0x00000031, 0x00204a2d, 0x000 }, + { 0x90000000, 0x00204411, 0x000 }, + { 0x00000000, 0x00204805, 0x000 }, + { 0x0000000c, 0x00211622, 0x000 }, + { 0x00000003, 0x00281625, 0x000 }, + { 0x00000019, 0x00211a22, 0x000 }, + { 0x00000004, 0x00281a26, 0x000 }, + { 0x00000000, 0x002914c5, 0x000 }, + { 0x00000021, 0x00203625, 0x000 }, + { 0x00000000, 0x003a1402, 0x000 }, + { 0x00000016, 0x00211625, 0x000 }, + { 0x00000003, 0x00281625, 0x000 }, + { 0x0000001d, 0x00200e2d, 0x000 }, + { 0xfffffffc, 0x00280e23, 0x000 }, + { 0x00000000, 0x002914a3, 0x000 }, + { 0x0000001d, 0x00203625, 0x000 }, + { 0x00008000, 0x00280e22, 0x000 }, + { 0x00000007, 0x00220e23, 0x000 }, + { 0x00000000, 0x0029386e, 0x000 }, + { 0x20000000, 0x00280e22, 0x000 }, + { 0x00000006, 0x00210e23, 0x000 }, + { 0x00000000, 0x0029386e, 0x000 }, + { 0x00000000, 0x00220222, 0x000 }, + { 0x00000000, 0x14e00000, 0x038 }, + { 0x00000000, 0x2ee00000, 0x035 }, + { 0x00000000, 0x2ce00000, 0x037 }, + { 0x00000000, 0x00400e2d, 0x039 }, + { 0x00000008, 0x00200e2d, 0x000 }, + { 0x00000009, 0x0040122d, 0x046 }, + { 0x00000001, 0x00400e2d, 0x039 }, + { 0x00000000, 0xc0200c00, 0x000 }, + { 0x003ffffc, 0x00281223, 0x000 }, + { 0x00000002, 0x00221224, 0x000 }, + { 0x0000001f, 0x00211e23, 0x000 }, + { 0x00000000, 0x14e00000, 0x03e }, + { 0x00000008, 0x00401c11, 0x041 }, + { 0x0000000d, 0x00201e2d, 0x000 }, + { 0x0000000f, 0x00281e27, 0x000 }, + { 0x00000003, 0x00221e27, 0x000 }, + { 0x7fc00000, 0x00281a23, 0x000 }, + { 0x00000014, 0x00211a26, 0x000 }, + { 0x00000001, 0x00331a26, 0x000 }, + { 0x00000008, 0x00221a26, 0x000 }, + { 0x00000000, 0x00290cc7, 0x000 }, + { 0x00000030, 0x00203624, 0x000 }, + { 0x00007f00, 0x00281221, 0x000 }, + { 0x00001400, 0x002f0224, 0x000 }, + { 0x00000000, 0x0ce00000, 0x04b }, + { 0x00000001, 0x00290e23, 0x000 }, + { 0x00000010, 0x00203623, 0x000 }, + { 0x0000e000, 0x00204411, 0x000 }, + { 0xfff80000, 0x00294a23, 0x000 }, + { 0x00000000, 0x003a2c02, 0x000 }, + { 0x00000002, 0x00220e2b, 0x000 }, + { 0xfc000000, 0x00280e23, 0x000 }, + { 0x00000011, 0x00203623, 0x000 }, + { 0x00001fff, 0x00294a23, 0x000 }, + { 0x00000030, 0x00204a2d, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000032, 0x00200e2d, 0x000 }, + { 0x060a0200, 0x00294a23, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000001, 0x00210222, 0x000 }, + { 0x00000000, 0x14e00000, 0x061 }, + { 0x00000000, 0x2ee00000, 0x05f }, + { 0x00000000, 0x2ce00000, 0x05e }, + { 0x00000000, 0x00400e2d, 0x062 }, + { 0x00000001, 0x00400e2d, 0x062 }, + { 0x0000000a, 0x00200e2d, 0x000 }, + { 0x0000000b, 0x0040122d, 0x06a }, + { 0x00000000, 0xc0200c00, 0x000 }, + { 0x003ffffc, 0x00281223, 0x000 }, + { 0x00000002, 0x00221224, 0x000 }, + { 0x7fc00000, 0x00281623, 0x000 }, + { 0x00000014, 0x00211625, 0x000 }, + { 0x00000001, 0x00331625, 0x000 }, + { 0x80000000, 0x00280e23, 0x000 }, + { 0x00000000, 0x00290ca3, 0x000 }, + { 0x3ffffc00, 0x00290e23, 0x000 }, + { 0x0000001f, 0x00211e23, 0x000 }, + { 0x00000000, 0x14e00000, 0x06d }, + { 0x00000100, 0x00401c11, 0x070 }, + { 0x0000000d, 0x00201e2d, 0x000 }, + { 0x000000f0, 0x00281e27, 0x000 }, + { 0x00000004, 0x00221e27, 0x000 }, + { 0x81000000, 0x00204411, 0x000 }, + { 0x0000000d, 0x00204811, 0x000 }, + { 0xfffff0ff, 0x00281a30, 0x000 }, + { 0x0000a028, 0x00204411, 0x000 }, + { 0x00000000, 0x002948e6, 0x000 }, + { 0x0000a018, 0x00204411, 0x000 }, + { 0x3fffffff, 0x00284a23, 0x000 }, + { 0x0000a010, 0x00204411, 0x000 }, + { 0x00000000, 0x00204804, 0x000 }, + { 0x0000002d, 0x0020162d, 0x000 }, + { 0x00000000, 0x002f00a3, 0x000 }, + { 0x00000000, 0x0cc00000, 0x080 }, + { 0x0000002e, 0x0020162d, 0x000 }, + { 0x00000000, 0x002f00a4, 0x000 }, + { 0x00000000, 0x0cc00000, 0x081 }, + { 0x00000000, 0x00400000, 0x087 }, + { 0x0000002d, 0x00203623, 0x000 }, + { 0x0000002e, 0x00203624, 0x000 }, + { 0x0000001d, 0x00201e2d, 0x000 }, + { 0x00000002, 0x00210227, 0x000 }, + { 0x00000000, 0x14e00000, 0x087 }, + { 0x00000000, 0x00600000, 0x5ed }, + { 0x00000000, 0x00600000, 0x5e1 }, + { 0x00000002, 0x00210e22, 0x000 }, + { 0x00000000, 0x14c00000, 0x08a }, + { 0x00000018, 0xc0403620, 0x090 }, + { 0x00000000, 0x2ee00000, 0x08e }, + { 0x00000000, 0x2ce00000, 0x08d }, + { 0x00000002, 0x00400e2d, 0x08f }, + { 0x00000003, 0x00400e2d, 0x08f }, + { 0x0000000c, 0x00200e2d, 0x000 }, + { 0x00000018, 0x00203623, 0x000 }, + { 0x00000003, 0x00210e22, 0x000 }, + { 0x00000000, 0x14c00000, 0x095 }, + { 0x0000a00c, 0x00204411, 0x000 }, + { 0x00000000, 0xc0204800, 0x000 }, + { 0x00000000, 0xc0404800, 0x09d }, + { 0x0000a00c, 0x00204411, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000000, 0x2ee00000, 0x09b }, + { 0x00000000, 0x2ce00000, 0x09a }, + { 0x00000002, 0x00400e2d, 0x09c }, + { 0x00000003, 0x00400e2d, 0x09c }, + { 0x0000000c, 0x00200e2d, 0x000 }, + { 0x00000000, 0x00204803, 0x000 }, + { 0x00000000, 0x003a0c02, 0x000 }, + { 0x003f0000, 0x00280e23, 0x000 }, + { 0x00000010, 0x00210e23, 0x000 }, + { 0x00000013, 0x00203623, 0x000 }, + { 0x0000001e, 0x0021022b, 0x000 }, + { 0x00000000, 0x14c00000, 0x0a4 }, + { 0x0000001c, 0xc0203620, 0x000 }, + { 0x0000001f, 0x0021022b, 0x000 }, + { 0x00000000, 0x14c00000, 0x0a7 }, + { 0x0000001b, 0xc0203620, 0x000 }, + { 0x00000008, 0x00210e2b, 0x000 }, + { 0x0000007f, 0x00280e23, 0x000 }, + { 0x00000000, 0x002f0223, 0x000 }, + { 0x00000000, 0x0ce00000, 0x0db }, + { 0x00000000, 0x27000000, 0x000 }, + { 0x00000000, 0x00600000, 0x28c }, + { 0x81000000, 0x00204411, 0x000 }, + { 0x00000006, 0x00204811, 0x000 }, + { 0x0000000c, 0x00221e30, 0x000 }, + { 0x99800000, 0x00204411, 0x000 }, + { 0x00000004, 0x0020122d, 0x000 }, + { 0x00000008, 0x00221224, 0x000 }, + { 0x00000010, 0x00201811, 0x000 }, + { 0x00000000, 0x00291ce4, 0x000 }, + { 0x00000000, 0x00604807, 0x128 }, + { 0x9b000000, 0x00204411, 0x000 }, + { 0x00000000, 0x00204802, 0x000 }, + { 0x9c000000, 0x00204411, 0x000 }, + { 0x00000000, 0x0033146f, 0x000 }, + { 0x00000001, 0x00333e23, 0x000 }, + { 0x00000000, 0xd9004800, 0x000 }, + { 0x00000000, 0x00203c05, 0x000 }, + { 0x81000000, 0x00204411, 0x000 }, + { 0x0000000e, 0x00204811, 0x000 }, + { 0x00000000, 0x00201010, 0x000 }, + { 0x0000e007, 0x00204411, 0x000 }, + { 0x0000000f, 0x0021022b, 0x000 }, + { 0x00000000, 0x14c00000, 0x0c5 }, + { 0x00f8ff08, 0x00204811, 0x000 }, + { 0x98000000, 0x00404811, 0x0d6 }, + { 0x000000f0, 0x00280e22, 0x000 }, + { 0x000000a0, 0x002f0223, 0x000 }, + { 0x00000000, 0x0cc00000, 0x0d4 }, + { 0x00000013, 0x00200e2d, 0x000 }, + { 0x00000001, 0x002f0223, 0x000 }, + { 0x00000000, 0x0ce00000, 0x0cf }, + { 0x00000002, 0x002f0223, 0x000 }, + { 0x00000000, 0x0ce00000, 0x0ce }, + { 0x00003f00, 0x00400c11, 0x0d0 }, + { 0x00001f00, 0x00400c11, 0x0d0 }, + { 0x00000f00, 0x00200c11, 0x000 }, + { 0x00380009, 0x00294a23, 0x000 }, + { 0x3f000000, 0x00280e2b, 0x000 }, + { 0x00000002, 0x00220e23, 0x000 }, + { 0x00000007, 0x00494a23, 0x0d6 }, + { 0x00380f09, 0x00204811, 0x000 }, + { 0x68000007, 0x00204811, 0x000 }, + { 0x00000008, 0x00214a27, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x060a0200, 0x00294a24, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x0000a202, 0x00204411, 0x000 }, + { 0x00ff0000, 0x00284a22, 0x000 }, + { 0x00000030, 0x00200e2d, 0x000 }, + { 0x0000002e, 0x0020122d, 0x000 }, + { 0x00000000, 0x002f0083, 0x000 }, + { 0x00000000, 0x0ce00000, 0x0e3 }, + { 0x00000000, 0x00600000, 0x5e7 }, + { 0x00000000, 0x00400000, 0x0e4 }, + { 0x00000000, 0x00600000, 0x5ea }, + { 0x00000007, 0x0020222d, 0x000 }, + { 0x00000005, 0x00220e22, 0x000 }, + { 0x00100000, 0x00280e23, 0x000 }, + { 0x00000000, 0x00292068, 0x000 }, + { 0x00000000, 0x003a0c02, 0x000 }, + { 0x000000ef, 0x00280e23, 0x000 }, + { 0x00000000, 0x00292068, 0x000 }, + { 0x0000001d, 0x00200e2d, 0x000 }, + { 0x00000003, 0x00210223, 0x000 }, + { 0x00000000, 0x14e00000, 0x0f1 }, + { 0x0000000b, 0x00210228, 0x000 }, + { 0x00000000, 0x14c00000, 0x0f1 }, + { 0x00000400, 0x00292228, 0x000 }, + { 0x0000001a, 0x00203628, 0x000 }, + { 0x0000001c, 0x00210e22, 0x000 }, + { 0x00000000, 0x14c00000, 0x0f6 }, + { 0x0000a30c, 0x00204411, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x0000001e, 0x00210e22, 0x000 }, + { 0x00000000, 0x14c00000, 0x104 }, + { 0x0000a30f, 0x00204411, 0x000 }, + { 0x00000013, 0x00200e2d, 0x000 }, + { 0x00000001, 0x002f0223, 0x000 }, + { 0x00000000, 0x0cc00000, 0x0fd }, + { 0xffffffff, 0x00404811, 0x104 }, + { 0x00000002, 0x002f0223, 0x000 }, + { 0x00000000, 0x0cc00000, 0x100 }, + { 0x0000ffff, 0x00404811, 0x104 }, + { 0x00000004, 0x002f0223, 0x000 }, + { 0x00000000, 0x0cc00000, 0x103 }, + { 0x000000ff, 0x00404811, 0x104 }, + { 0x00000001, 0x00204811, 0x000 }, + { 0x0002c400, 0x00204411, 0x000 }, + { 0x0000001f, 0x00210e22, 0x000 }, + { 0x00000000, 0x14c00000, 0x10b }, + { 0x00000010, 0x40210e20, 0x000 }, + { 0x00000019, 0x00203623, 0x000 }, + { 0x00000018, 0x40224a20, 0x000 }, + { 0x00000010, 0xc0424a20, 0x10d }, + { 0x00000000, 0x00200c11, 0x000 }, + { 0x00000019, 0x00203623, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x0000000a, 0x00201011, 0x000 }, + { 0x00000000, 0x002f0224, 0x000 }, + { 0x00000000, 0x0ce00000, 0x114 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000001, 0x00531224, 0x110 }, + { 0xffbfffff, 0x00283a2e, 0x000 }, + { 0x0000001b, 0x00210222, 0x000 }, + { 0x00000000, 0x14c00000, 0x127 }, + { 0x81000000, 0x00204411, 0x000 }, + { 0x0000000d, 0x00204811, 0x000 }, + { 0x00000018, 0x00220e30, 0x000 }, + { 0xfc000000, 0x00280e23, 0x000 }, + { 0x81000000, 0x00204411, 0x000 }, + { 0x0000000e, 0x00204811, 0x000 }, + { 0x00000000, 0x00201010, 0x000 }, + { 0x0000e00e, 0x00204411, 0x000 }, + { 0x07f8ff08, 0x00204811, 0x000 }, + { 0x00000000, 0x00294a23, 0x000 }, + { 0x00000024, 0x00201e2d, 0x000 }, + { 0x00000008, 0x00214a27, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x060a0200, 0x00294a24, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000000, 0x00800000, 0x000 }, + { 0x81000000, 0x00204411, 0x000 }, + { 0x00000001, 0x00204811, 0x000 }, + { 0x0000217c, 0x00204411, 0x000 }, + { 0x00800000, 0x00204811, 0x000 }, + { 0x00000000, 0x00204806, 0x000 }, + { 0x00000008, 0x00214a27, 0x000 }, + { 0x00000000, 0x17000000, 0x000 }, + { 0x0004217f, 0x00604411, 0x614 }, + { 0x0000001f, 0x00210230, 0x000 }, + { 0x00000000, 0x14c00000, 0x613 }, + { 0x00000004, 0x00404c11, 0x12e }, + { 0x00000000, 0x00600000, 0x00b }, + { 0x00000000, 0x00600411, 0x2fe }, + { 0x00000000, 0x00200411, 0x000 }, + { 0x00000000, 0x00600811, 0x19f }, + { 0x00000000, 0x00600000, 0x151 }, + { 0x0000ffff, 0x40280e20, 0x000 }, + { 0x00000010, 0xc0211220, 0x000 }, + { 0x0000ffff, 0x40280620, 0x000 }, + { 0x00000010, 0xc0210a20, 0x000 }, + { 0x00000000, 0x00341461, 0x000 }, + { 0x00000000, 0x00741882, 0x2a4 }, + { 0x0001a1fd, 0x00604411, 0x2c9 }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0cc00000, 0x138 }, + { 0x00000000, 0xc0400400, 0x001 }, + { 0x00000000, 0x00600000, 0x00b }, + { 0x00000000, 0x00600411, 0x2fe }, + { 0x00000000, 0x00200411, 0x000 }, + { 0x00000000, 0x00600811, 0x19f }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0ce00000, 0x000 }, + { 0x00000000, 0x00600000, 0x151 }, + { 0x00000010, 0x40210e20, 0x000 }, + { 0x0000ffff, 0xc0281220, 0x000 }, + { 0x00000010, 0x40211620, 0x000 }, + { 0x0000ffff, 0xc0681a20, 0x2a4 }, + { 0x0001a1fd, 0x00604411, 0x2c9 }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0cc00000, 0x149 }, + { 0x00000000, 0xc0400400, 0x001 }, + { 0x0000225c, 0x00204411, 0x000 }, + { 0x00000001, 0x00300a2f, 0x000 }, + { 0x00000001, 0x00210a22, 0x000 }, + { 0x00000003, 0x00384a22, 0x000 }, + { 0x00002256, 0x00204411, 0x000 }, + { 0x0000001a, 0x00204811, 0x000 }, + { 0x0000a1fc, 0x00204411, 0x000 }, + { 0x00000001, 0x00804811, 0x000 }, + { 0x00000000, 0x00600000, 0x00b }, + { 0x00000000, 0x00600000, 0x17c }, + { 0x00000000, 0x00600000, 0x18d }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0ce00000, 0x000 }, + { 0x00000000, 0x00202c08, 0x000 }, + { 0x00000000, 0x00202411, 0x000 }, + { 0x00000000, 0x00202811, 0x000 }, + { 0x00002256, 0x00204411, 0x000 }, + { 0x00000016, 0x00204811, 0x000 }, + { 0x0000225c, 0x00204411, 0x000 }, + { 0x00000003, 0x00204811, 0x000 }, + { 0x93800000, 0x00204411, 0x000 }, + { 0x00000002, 0x00221e29, 0x000 }, + { 0x00000000, 0x007048eb, 0x189 }, + { 0x00000000, 0x00600000, 0x2a4 }, + { 0x00000001, 0x40330620, 0x000 }, + { 0x00000000, 0xc0302409, 0x000 }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0ce00000, 0x000 }, + { 0x00000000, 0x00600000, 0x28c }, + { 0x95000000, 0x00204411, 0x000 }, + { 0x00000000, 0x002f0221, 0x000 }, + { 0x00000000, 0x0ce00000, 0x173 }, + { 0x00000000, 0xc0204800, 0x000 }, + { 0x00000001, 0x00530621, 0x16f }, + { 0x92000000, 0x00204411, 0x000 }, + { 0x00000000, 0xc0604800, 0x184 }, + { 0x0001a1fd, 0x00204411, 0x000 }, + { 0x00000013, 0x0020062d, 0x000 }, + { 0x00000000, 0x0078042a, 0x2e4 }, + { 0x00000000, 0x00202809, 0x000 }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0cc00000, 0x165 }, + { 0x00000000, 0xc0400400, 0x001 }, + { 0x00000210, 0x00600411, 0x2fe }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0ce00000, 0x181 }, + { 0x0000001b, 0xc0203620, 0x000 }, + { 0x0000001c, 0xc0203620, 0x000 }, + { 0x3f800000, 0x00200411, 0x000 }, + { 0x46000000, 0x00600811, 0x19f }, + { 0x00000000, 0x00800000, 0x000 }, + { 0x0000a1fc, 0x00204411, 0x000 }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0cc00000, 0x188 }, + { 0x00000001, 0x00804811, 0x000 }, + { 0x00000021, 0x00804811, 0x000 }, + { 0x0000ffff, 0x40280e20, 0x000 }, + { 0x00000010, 0xc0211220, 0x000 }, + { 0x0000ffff, 0x40281620, 0x000 }, + { 0x00000010, 0xc0811a20, 0x000 }, + { 0x81000000, 0x00204411, 0x000 }, + { 0x00000006, 0x00204811, 0x000 }, + { 0x00000008, 0x00221e30, 0x000 }, + { 0x00000032, 0x00201a2d, 0x000 }, + { 0x0000e000, 0x00204411, 0x000 }, + { 0xfffbff09, 0x00204811, 0x000 }, + { 0x00000011, 0x0020222d, 0x000 }, + { 0x00001fff, 0x00294a28, 0x000 }, + { 0x00000006, 0x0020222d, 0x000 }, + { 0x00000000, 0x002920e8, 0x000 }, + { 0x00000000, 0x00204808, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x060a0200, 0x00294a26, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000100, 0x00201811, 0x000 }, + { 0x00000008, 0x00621e28, 0x128 }, + { 0x00000008, 0x00822228, 0x000 }, + { 0x0002c000, 0x00204411, 0x000 }, + { 0x0000001b, 0x00600e2d, 0x1aa }, + { 0x0000001c, 0x00600e2d, 0x1aa }, + { 0x0000c008, 0x00204411, 0x000 }, + { 0x0000001d, 0x00200e2d, 0x000 }, + { 0x00000000, 0x14c00000, 0x1a6 }, + { 0x00000000, 0x00200411, 0x000 }, + { 0x00000000, 0x00204801, 0x000 }, + { 0x39000000, 0x00204811, 0x000 }, + { 0x00000000, 0x00204811, 0x000 }, + { 0x00000000, 0x00804802, 0x000 }, + { 0x00000020, 0x00202e2d, 0x000 }, + { 0x00000000, 0x003b0d63, 0x000 }, + { 0x00000008, 0x00224a23, 0x000 }, + { 0x00000010, 0x00224a23, 0x000 }, + { 0x00000018, 0x00224a23, 0x000 }, + { 0x00000000, 0x00804803, 0x000 }, + { 0x00000000, 0x00600000, 0x00b }, + { 0x00001000, 0x00600411, 0x2fe }, + { 0x00000000, 0x00200411, 0x000 }, + { 0x00000000, 0x00600811, 0x19f }, + { 0x00000007, 0x0021062f, 0x000 }, + { 0x00000019, 0x00200a2d, 0x000 }, + { 0x00000001, 0x00202c11, 0x000 }, + { 0x0000ffff, 0x40282220, 0x000 }, + { 0x0000000f, 0x00262228, 0x000 }, + { 0x00000010, 0x40212620, 0x000 }, + { 0x0000000f, 0x00262629, 0x000 }, + { 0x00000000, 0x00202802, 0x000 }, + { 0x00002256, 0x00204411, 0x000 }, + { 0x0000001b, 0x00204811, 0x000 }, + { 0x00000000, 0x002f0221, 0x000 }, + { 0x00000000, 0x0ce00000, 0x1cd }, + { 0x0000225c, 0x00204411, 0x000 }, + { 0x00000081, 0x00204811, 0x000 }, + { 0x0000a1fc, 0x00204411, 0x000 }, + { 0x00000001, 0x00204811, 0x000 }, + { 0x00000080, 0x00201c11, 0x000 }, + { 0x00000000, 0x002f0227, 0x000 }, + { 0x00000000, 0x0ce00000, 0x1c9 }, + { 0x00000000, 0x00600000, 0x1d6 }, + { 0x00000001, 0x00531e27, 0x1c5 }, + { 0x00000001, 0x00202c11, 0x000 }, + { 0x0000001f, 0x00280a22, 0x000 }, + { 0x0000001f, 0x00282a2a, 0x000 }, + { 0x00000001, 0x00530621, 0x1be }, + { 0x0000225c, 0x00204411, 0x000 }, + { 0x00000002, 0x00304a2f, 0x000 }, + { 0x0000a1fc, 0x00204411, 0x000 }, + { 0x00000001, 0x00204811, 0x000 }, + { 0x00000001, 0x00301e2f, 0x000 }, + { 0x00000000, 0x002f0227, 0x000 }, + { 0x00000000, 0x0ce00000, 0x000 }, + { 0x00000000, 0x00600000, 0x1d6 }, + { 0x00000001, 0x00531e27, 0x1d2 }, + { 0x0000ffff, 0x40280e20, 0x000 }, + { 0x0000000f, 0x00260e23, 0x000 }, + { 0x00000010, 0xc0211220, 0x000 }, + { 0x0000000f, 0x00261224, 0x000 }, + { 0x00000000, 0x00201411, 0x000 }, + { 0x00000000, 0x00601811, 0x2a4 }, + { 0x0001a1fd, 0x00204411, 0x000 }, + { 0x00000000, 0x002f022b, 0x000 }, + { 0x00000000, 0x0ce00000, 0x1e5 }, + { 0x00000010, 0x00221628, 0x000 }, + { 0xffff0000, 0x00281625, 0x000 }, + { 0x0000ffff, 0x00281a29, 0x000 }, + { 0x00000000, 0x002948c5, 0x000 }, + { 0x00000000, 0x0020480a, 0x000 }, + { 0x00000000, 0x00202c11, 0x000 }, + { 0x00000010, 0x00221623, 0x000 }, + { 0xffff0000, 0x00281625, 0x000 }, + { 0x0000ffff, 0x00281a24, 0x000 }, + { 0x00000000, 0x002948c5, 0x000 }, + { 0x00000000, 0x00731503, 0x1f2 }, + { 0x00000000, 0x00201805, 0x000 }, + { 0x00000000, 0x00731524, 0x1f2 }, + { 0x00000000, 0x002d14c5, 0x000 }, + { 0x00000000, 0x003008a2, 0x000 }, + { 0x00000000, 0x00204802, 0x000 }, + { 0x00000000, 0x00202802, 0x000 }, + { 0x00000000, 0x00202003, 0x000 }, + { 0x00000000, 0x00802404, 0x000 }, + { 0x0000000f, 0x00210225, 0x000 }, + { 0x00000000, 0x14c00000, 0x613 }, + { 0x00000000, 0x002b1405, 0x000 }, + { 0x00000001, 0x00901625, 0x000 }, + { 0x00000000, 0x00600000, 0x00b }, + { 0x00000000, 0x00600411, 0x2fe }, + { 0x00000000, 0x00200411, 0x000 }, + { 0x00000000, 0x00600811, 0x19f }, + { 0x00002256, 0x00204411, 0x000 }, + { 0x0000001a, 0x00294a22, 0x000 }, + { 0x00000000, 0xc0200000, 0x000 }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0ce00000, 0x000 }, + { 0x00000000, 0xc0200400, 0x000 }, + { 0x0000225c, 0x00204411, 0x000 }, + { 0x00000003, 0x00384a21, 0x000 }, + { 0x0000a1fc, 0x00204411, 0x000 }, + { 0x00000001, 0x00204811, 0x000 }, + { 0x0000ffff, 0x40281220, 0x000 }, + { 0x00000010, 0xc0211a20, 0x000 }, + { 0x0000ffff, 0x40280e20, 0x000 }, + { 0x00000010, 0xc0211620, 0x000 }, + { 0x00000000, 0x00741465, 0x2a4 }, + { 0x0001a1fd, 0x00604411, 0x2c9 }, + { 0x00000001, 0x00330621, 0x000 }, + { 0x00000000, 0x002f0221, 0x000 }, + { 0x00000000, 0x0cc00000, 0x206 }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0cc00000, 0x1ff }, + { 0x00000000, 0xc0400400, 0x001 }, + { 0x00000000, 0x00600000, 0x5c5 }, + { 0x00000000, 0x0040040f, 0x200 }, + { 0x00000000, 0x00600000, 0x5b2 }, + { 0x00000000, 0x00600000, 0x5c5 }, + { 0x00000210, 0x00600411, 0x2fe }, + { 0x00000000, 0x00600000, 0x18d }, + { 0x00000000, 0x00600000, 0x189 }, + { 0x00000000, 0x00600000, 0x2a4 }, + { 0x00000000, 0x00600000, 0x28c }, + { 0x93800000, 0x00204411, 0x000 }, + { 0x00000000, 0x00204808, 0x000 }, + { 0x95000000, 0x00204411, 0x000 }, + { 0x00000000, 0x002f022f, 0x000 }, + { 0x00000000, 0x0ce00000, 0x21f }, + { 0x00000000, 0xc0404800, 0x21c }, + { 0x92000000, 0x00204411, 0x000 }, + { 0x00000000, 0xc0204800, 0x000 }, + { 0x00002256, 0x00204411, 0x000 }, + { 0x00000016, 0x00204811, 0x000 }, + { 0x0000225c, 0x00204411, 0x000 }, + { 0x00000003, 0x00204811, 0x000 }, + { 0x0000a1fc, 0x00204411, 0x000 }, + { 0x00000001, 0x00204811, 0x000 }, + { 0x0001a1fd, 0x00204411, 0x000 }, + { 0x00000000, 0x00600411, 0x2e4 }, + { 0x00000000, 0xc0400400, 0x001 }, + { 0x00000000, 0x00600000, 0x5b2 }, + { 0x0000a00c, 0x00204411, 0x000 }, + { 0x00000000, 0xc0204800, 0x000 }, + { 0x00000000, 0xc0404800, 0x000 }, + { 0x00000000, 0x00600000, 0x00b }, + { 0x00000018, 0x40210a20, 0x000 }, + { 0x00000003, 0x002f0222, 0x000 }, + { 0x00000000, 0x0ae00000, 0x235 }, + { 0x0000001a, 0x0020222d, 0x000 }, + { 0x00080101, 0x00292228, 0x000 }, + { 0x0000001a, 0x00203628, 0x000 }, + { 0x0000a30c, 0x00204411, 0x000 }, + { 0x00000000, 0xc0204800, 0x000 }, + { 0x00000000, 0xc0204800, 0x000 }, + { 0x00000000, 0xc0404800, 0x23a }, + { 0x00000000, 0x00600000, 0x00b }, + { 0x00000010, 0x00600411, 0x2fe }, + { 0x3f800000, 0x00200411, 0x000 }, + { 0x00000000, 0x00600811, 0x19f }, + { 0x0000225c, 0x00204411, 0x000 }, + { 0x00000003, 0x00204811, 0x000 }, + { 0x00000000, 0x00600000, 0x265 }, + { 0x0000001d, 0x00201e2d, 0x000 }, + { 0x00000001, 0x00211e27, 0x000 }, + { 0x00000000, 0x14e00000, 0x253 }, + { 0x00000018, 0x00201e2d, 0x000 }, + { 0x0000ffff, 0x00281e27, 0x000 }, + { 0x00000000, 0x00341c27, 0x000 }, + { 0x00000000, 0x12c00000, 0x248 }, + { 0x00000000, 0x00201c11, 0x000 }, + { 0x00000000, 0x002f00e5, 0x000 }, + { 0x00000000, 0x08c00000, 0x24b }, + { 0x00000000, 0x00201407, 0x000 }, + { 0x00000018, 0x00201e2d, 0x000 }, + { 0x00000010, 0x00211e27, 0x000 }, + { 0x00000000, 0x00341c47, 0x000 }, + { 0x00000000, 0x12c00000, 0x250 }, + { 0x00000000, 0x00201c11, 0x000 }, + { 0x00000000, 0x002f00e6, 0x000 }, + { 0x00000000, 0x08c00000, 0x253 }, + { 0x00000000, 0x00201807, 0x000 }, + { 0x00000000, 0x00600000, 0x2aa }, + { 0x00002256, 0x00204411, 0x000 }, + { 0x00000000, 0x00342023, 0x000 }, + { 0x00000000, 0x12c00000, 0x25b }, + { 0x00000000, 0x00342044, 0x000 }, + { 0x00000000, 0x12c00000, 0x25a }, + { 0x00000016, 0x00404811, 0x25f }, + { 0x00000018, 0x00404811, 0x25f }, + { 0x00000000, 0x00342044, 0x000 }, + { 0x00000000, 0x12c00000, 0x25e }, + { 0x00000017, 0x00404811, 0x25f }, + { 0x00000019, 0x00204811, 0x000 }, + { 0x0000a1fc, 0x00204411, 0x000 }, + { 0x00000001, 0x00204811, 0x000 }, + { 0x0001a1fd, 0x00604411, 0x2d2 }, + { 0x00003fff, 0x002f022f, 0x000 }, + { 0x00000000, 0x0cc00000, 0x23f }, + { 0x00000000, 0xc0400400, 0x001 }, + { 0x00000010, 0x40210620, 0x000 }, + { 0x0000ffff, 0xc0280a20, 0x000 }, + { 0x00000010, 0x40210e20, 0x000 }, + { 0x0000ffff, 0xc0281220, 0x000 }, + { 0x00000010, 0x40211620, 0x000 }, + { 0x0000ffff, 0xc0881a20, 0x000 }, + { 0x81000000, 0x00204411, 0x000 }, + { 0x00000001, 0x00204811, 0x000 }, + { 0x00042004, 0x00604411, 0x614 }, + { 0x00000000, 0x00600000, 0x5b2 }, + { 0x00000000, 0xc0600000, 0x28c }, + { 0x00000005, 0x00200a2d, 0x000 }, + { 0x00000008, 0x00220a22, 0x000 }, + { 0x00000034, 0x00201a2d, 0x000 }, + { 0x00000024, 0x00201e2d, 0x000 }, + { 0x00007000, 0x00281e27, 0x000 }, + { 0x00000000, 0x00311ce6, 0x000 }, + { 0x00000033, 0x00201a2d, 0x000 }, + { 0x0000000c, 0x00221a26, 0x000 }, + { 0x00000000, 0x002f00e6, 0x000 }, + { 0x00000000, 0x06e00000, 0x27b }, + { 0x00000000, 0x00201c11, 0x000 }, + { 0x00000000, 0x00200c11, 0x000 }, + { 0x00000034, 0x00203623, 0x000 }, + { 0x00000010, 0x00201811, 0x000 }, + { 0x00000000, 0x00691ce2, 0x128 }, + { 0x93800000, 0x00204411, 0x000 }, + { 0x00000000, 0x00204807, 0x000 }, + { 0x95000000, 0x00204411, 0x000 }, + { 0x00000000, 0x002f022f, 0x000 }, + { 0x00000000, 0x0ce00000, 0x286 }, + { 0x00000001, 0x00333e2f, 0x000 }, + { 0x00000000, 0xd9004800, 0x000 }, + { 0x92000000, 0x00204411, 0x000 }, + { 0x00000000, 0xc0204800, 0x000 }, + { 0x00000024, 0x00403627, 0x000 }, + { 0x0000000c, 0xc0220a20, 0x000 }, + { 0x00000032, 0x00203622, 0x000 }, + { 0x00000031, 0xc0403620, 0x000 }, + { 0x0000a2a4, 0x00204411, 0x000 }, + { 0x00000009, 0x00204811, 0x000 }, + { 0xa1000000, 0x00204411, 0x000 }, + { 0x00000001, 0x00804811, 0x000 }, + { 0x00000029, 0x00201e2d, 0x000 }, + { 0x00000000, 0x002c1ce3, 0x000 }, + { 0x00000029, 0x00203627, 0x000 }, + { 0x0000002a, 0x00201e2d, 0x000 }, + { 0x00000000, 0x002c1ce4, 0x000 }, + { 0x0000002a, 0x00203627, 0x000 }, + { 0x0000002b, 0x00201e2d, 0x000 }, + { 0x00000000, 0x003120a3, 0x000 }, + { 0x00000000, 0x002d1d07, 0x000 }, + { 0x0000002b, 0x00203627, 0x000 }, + { 0x0000002c, 0x00201e2d, 0x000 }, + { 0x00000000, 0x003120c4, 0x000 }, + { 0x00000000, 0x002d1d07, 0x000 }, + { 0x0000002c, 0x00803627, 0x000 }, + { 0x00000029, 0x00203623, 0x000 }, + { 0x0000002a, 0x00203624, 0x000 }, + { 0x00000000, 0x00311ca3, 0x000 }, + { 0x0000002b, 0x00203627, 0x000 }, + { 0x00000000, 0x00311cc4, 0x000 }, + { 0x0000002c, 0x00803627, 0x000 }, + { 0x00000022, 0x00203627, 0x000 }, + { 0x00000023, 0x00203628, 0x000 }, + { 0x0000001d, 0x00201e2d, 0x000 }, + { 0x00000002, 0x00210227, 0x000 }, + { 0x00000000, 0x14c00000, 0x2c5 }, + { 0x00000000, 0x00400000, 0x2c2 }, + { 0x00000022, 0x00203627, 0x000 }, + { 0x00000023, 0x00203628, 0x000 }, + { 0x0000001d, 0x00201e2d, 0x000 }, + { 0x00000002, 0x00210227, 0x000 }, + { 0x00000000, 0x14e00000, 0x2c2 }, + { 0x00000003, 0x00210227, 0x000 }, + { 0x00000000, 0x14e00000, 0x2c5 }, + { 0x0000002b, 0x00201e2d, 0x000 }, + { 0x00000000, 0x002e00e1, 0x000 }, + { 0x00000000, 0x02c00000, 0x2c5 }, + { 0x00000029, 0x00201e2d, 0x000 }, + { 0x00000000, 0x003120a1, 0x000 }, + { 0x00000000, 0x002e00e8, 0x000 }, + { 0x00000000, 0x06c00000, 0x2c5 }, + { 0x0000002c, 0x00201e2d, 0x000 }, + { 0x00000000, 0x002e00e2, 0x000 }, + { 0x00000000, 0x02c00000, 0x2c5 }, + { 0x0000002a, 0x00201e2d, 0x000 }, + { 0x00000000, 0x003120c2, 0x000 }, + { 0x00000000, 0x002e00e8, 0x000 }, + { 0x00000000, 0x06c00000, 0x2c5 }, + { 0x00000000, 0x00600000, 0x5ed }, + { 0x00000000, 0x00600000, 0x29e }, + { 0x00000000, 0x00400000, 0x2c7 }, + { 0x00000000, 0x00600000, 0x29e }, + { 0x00000000, 0x00600000, 0x5e4 }, + { 0x00000000, 0x00400000, 0x2c7 }, + { 0x00000000, 0x00600000, 0x290 }, + { 0x00000000, 0x00400000, 0x2c7 }, + { 0x00000022, 0x00201e2d, 0x000 }, + { 0x00000023, 0x0080222d, 0x000 }, + { 0x00000010, 0x00221e23, 0x000 }, + { 0x00000000, 0x00294887, 0x000 }, + { 0x00000000, 0x00311ca3, 0x000 }, + { 0x00000010, 0x00221e27, 0x000 }, + { 0x00000000, 0x00294887, 0x000 }, + { 0x00000010, 0x00221e23, 0x000 }, + { 0x00000000, 0x003120c4, 0x000 }, + { 0x0000ffff, 0x00282228, 0x000 }, + { 0x00000000, 0x00894907, 0x000 }, + { 0x00000010, 0x00221e23, 0x000 }, + { 0x00000000, 0x00294887, 0x000 }, + { 0x00000010, 0x00221e21, 0x000 }, + { 0x00000000, 0x00294847, 0x000 }, + { 0x00000000, 0x00311ca3, 0x000 }, + { 0x00000010, 0x00221e27, 0x000 }, + { 0x00000000, 0x00294887, 0x000 }, + { 0x00000000, 0x00311ca1, 0x000 }, + { 0x00000010, 0x00221e27, 0x000 }, + { 0x00000000, 0x00294847, 0x000 }, + { 0x00000010, 0x00221e23, 0x000 }, + { 0x00000000, 0x003120c4, 0x000 }, + { 0x0000ffff, 0x00282228, 0x000 }, + { 0x00000000, 0x00294907, 0x000 }, + { 0x00000010, 0x00221e21, 0x000 }, + { 0x00000000, 0x003120c2, 0x000 }, + { 0x0000ffff, 0x00282228, 0x000 }, + { 0x00000000, 0x00894907, 0x000 }, + { 0x00000010, 0x00221e23, 0x000 }, + { 0x00000000, 0x00294887, 0x000 }, + { 0x00000001, 0x00220a21, 0x000 }, + { 0x00000000, 0x003308a2, 0x000 }, + { 0x00000010, 0x00221e22, 0x000 }, + { 0x00000010, 0x00212222, 0x000 }, + { 0x00000000, 0x00294907, 0x000 }, + { 0x00000000, 0x00311ca3, 0x000 }, + { 0x00000010, 0x00221e27, 0x000 }, + { 0x00000000, 0x00294887, 0x000 }, + { 0x00000001, 0x00220a21, 0x000 }, + { 0x00000000, 0x003008a2, 0x000 }, + { 0x00000010, 0x00221e22, 0x000 }, + { 0x00000010, 0x00212222, 0x000 }, + { 0x00000000, 0x00294907, 0x000 }, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From rnoland at FreeBSD.org Sun Mar 15 10:22:54 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Sun Mar 15 10:23:00 2009 Subject: svn commit: r189856 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903151722.n2FHMrHO034996@svn.freebsd.org> Author: rnoland Date: Sun Mar 15 17:22:53 2009 New Revision: 189856 URL: http://svn.freebsd.org/changeset/base/189856 Log: Merge 189559 Fix the flags to bus_dmamem_* to allow the allocation to sleep while waiting for resources. It is really the load that we can't defer. BUS_DMA_NOCACHE belongs on bus_dmamap_load() as well. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_scatter.c Modified: stable/7/sys/dev/drm/drm_scatter.c ============================================================================== --- stable/7/sys/dev/drm/drm_scatter.c Sun Mar 15 17:20:28 2009 (r189855) +++ stable/7/sys/dev/drm/drm_scatter.c Sun Mar 15 17:22:53 2009 (r189856) @@ -92,7 +92,7 @@ drm_sg_alloc(struct drm_device *dev, str } ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr, - BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_NOCACHE, &dmah->map); + BUS_DMA_WAITOK | BUS_DMA_ZERO, &dmah->map); if (ret != 0) { bus_dma_tag_destroy(dmah->tag); free(dmah, DRM_MEM_DMA); @@ -102,7 +102,8 @@ drm_sg_alloc(struct drm_device *dev, str } ret = bus_dmamap_load(dmah->tag, dmah->map, dmah->vaddr, - request->size, drm_sg_alloc_cb, entry, 0); + request->size, drm_sg_alloc_cb, entry, + BUS_DMA_NOWAIT | BUS_DMA_NOCACHE); if (ret != 0) { bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map); bus_dma_tag_destroy(dmah->tag); From rnoland at FreeBSD.org Sun Mar 15 10:23:49 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Sun Mar 15 10:24:00 2009 Subject: svn commit: r189857 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903151723.n2FHNktE035061@svn.freebsd.org> Author: rnoland Date: Sun Mar 15 17:23:46 2009 New Revision: 189857 URL: http://svn.freebsd.org/changeset/base/189857 Log: Merge r189560 Change the flags to bus_dmamem around to allow it to sleep waiting for resources during allocation, but not during map load. Also, zero the buffers here. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_pci.c Modified: stable/7/sys/dev/drm/drm_pci.c ============================================================================== --- stable/7/sys/dev/drm/drm_pci.c Sun Mar 15 17:22:53 2009 (r189856) +++ stable/7/sys/dev/drm/drm_pci.c Sun Mar 15 17:23:46 2009 (r189857) @@ -83,15 +83,15 @@ drm_pci_alloc(struct drm_device *dev, si maxaddr, BUS_SPACE_MAXADDR, /* lowaddr, highaddr */ NULL, NULL, /* filtfunc, filtfuncargs */ size, 1, size, /* maxsize, nsegs, maxsegsize */ - BUS_DMA_ALLOCNOW, NULL, NULL, /* flags, lockfunc, lockfuncargs */ + 0, NULL, NULL, /* flags, lockfunc, lockfuncargs */ &dmah->tag); if (ret != 0) { free(dmah, DRM_MEM_DMA); return NULL; } - ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr, BUS_DMA_NOWAIT, - &dmah->map); + ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr, + BUS_DMA_WAITOK | BUS_DMA_ZERO, &dmah->map); if (ret != 0) { bus_dma_tag_destroy(dmah->tag); free(dmah, DRM_MEM_DMA); @@ -99,7 +99,7 @@ drm_pci_alloc(struct drm_device *dev, si } ret = bus_dmamap_load(dmah->tag, dmah->map, dmah->vaddr, size, - drm_pci_busdma_callback, dmah, 0); + drm_pci_busdma_callback, dmah, BUS_DMA_NOWAIT); if (ret != 0) { bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map); bus_dma_tag_destroy(dmah->tag); From rnoland at FreeBSD.org Sun Mar 15 10:24:50 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Sun Mar 15 10:25:07 2009 Subject: svn commit: r189858 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903151724.n2FHOmDf035134@svn.freebsd.org> Author: rnoland Date: Sun Mar 15 17:24:48 2009 New Revision: 189858 URL: http://svn.freebsd.org/changeset/base/189858 Log: Merge r189561 There is no need to sync these buffers to swap. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_bufs.c Modified: stable/7/sys/dev/drm/drm_bufs.c ============================================================================== --- stable/7/sys/dev/drm/drm_bufs.c Sun Mar 15 17:23:46 2009 (r189857) +++ stable/7/sys/dev/drm/drm_bufs.c Sun Mar 15 17:24:48 2009 (r189858) @@ -1052,11 +1052,12 @@ int drm_mapbufs(struct drm_device *dev, vaddr = round_page((vm_offset_t)vms->vm_daddr + MAXDSIZ); #if __FreeBSD_version >= 600023 retcode = vm_mmap(&vms->vm_map, &vaddr, size, PROT_READ | PROT_WRITE, - VM_PROT_ALL, MAP_SHARED, OBJT_DEVICE, dev->devnode, foff); + VM_PROT_ALL, MAP_SHARED | MAP_NOSYNC, OBJT_DEVICE, + dev->devnode, foff); #else retcode = vm_mmap(&vms->vm_map, &vaddr, size, PROT_READ | PROT_WRITE, - VM_PROT_ALL, MAP_SHARED, SLIST_FIRST(&dev->devnode->si_hlist), - foff); + VM_PROT_ALL, MAP_SHARED | MAP_NOSYNC, + SLIST_FIRST(&dev->devnode->si_hlist), foff); #endif if (retcode) goto done; From rnoland at FreeBSD.org Sun Mar 15 10:25:46 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Sun Mar 15 10:25:58 2009 Subject: svn commit: r189859 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903151725.n2FHPiYn035208@svn.freebsd.org> Author: rnoland Date: Sun Mar 15 17:25:44 2009 New Revision: 189859 URL: http://svn.freebsd.org/changeset/base/189859 Log: Merge r189562 Clean up the printing on amd64. Should also be consistent on i386. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_sysctl.c Modified: stable/7/sys/dev/drm/drm_sysctl.c ============================================================================== --- stable/7/sys/dev/drm/drm_sysctl.c Sun Mar 15 17:24:48 2009 (r189858) +++ stable/7/sys/dev/drm/drm_sysctl.c Sun Mar 15 17:25:44 2009 (r189859) @@ -185,8 +185,8 @@ static int drm_vm_info DRM_SYSCTL_HANDLE DRM_UNLOCK(); - DRM_SYSCTL_PRINT("\nslot offset size type flags " - "address mtrr\n"); + DRM_SYSCTL_PRINT("\nslot offset size " + "type flags address mtrr\n"); for (i = 0; i < mapcount; i++) { map = &tempmaps[i]; @@ -202,7 +202,7 @@ static int drm_vm_info DRM_SYSCTL_HANDLE yesno = "yes"; DRM_SYSCTL_PRINT( - "%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx %s\n", i, + "%4d 0x%016lx 0x%08lx %4.4s 0x%02x 0x%016lx %s\n", i, map->offset, map->size, type, map->flags, (unsigned long)map->handle, yesno); } From rnoland at FreeBSD.org Sun Mar 15 10:27:10 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Sun Mar 15 10:27:59 2009 Subject: svn commit: r189860 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903151727.n2FHR6aQ035283@svn.freebsd.org> Author: rnoland Date: Sun Mar 15 17:27:06 2009 New Revision: 189860 URL: http://svn.freebsd.org/changeset/base/189860 Log: Merge r189563 Consistently use kdev for the kernel device. Submitted by: vehemens Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drmP.h stable/7/sys/dev/drm/drm_drv.c stable/7/sys/dev/drm/i915_drv.c stable/7/sys/dev/drm/mach64_drv.c stable/7/sys/dev/drm/mga_drv.c stable/7/sys/dev/drm/r128_drv.c stable/7/sys/dev/drm/radeon_drv.c stable/7/sys/dev/drm/savage_drv.c stable/7/sys/dev/drm/sis_drv.c stable/7/sys/dev/drm/tdfx_drv.c Modified: stable/7/sys/dev/drm/drmP.h ============================================================================== --- stable/7/sys/dev/drm/drmP.h Sun Mar 15 17:25:44 2009 (r189859) +++ stable/7/sys/dev/drm/drmP.h Sun Mar 15 17:27:06 2009 (r189860) @@ -720,10 +720,10 @@ static inline int drm_core_has_AGP(struc extern int drm_debug_flag; /* Device setup support (drm_drv.c) */ -int drm_probe(device_t nbdev, drm_pci_id_list_t *idlist); -int drm_attach(device_t nbdev, drm_pci_id_list_t *idlist); +int drm_probe(device_t kdev, drm_pci_id_list_t *idlist); +int drm_attach(device_t kdev, drm_pci_id_list_t *idlist); void drm_close(void *data); -int drm_detach(device_t nbdev); +int drm_detach(device_t kdev); d_ioctl_t drm_ioctl; d_open_t drm_open; d_read_t drm_read; Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Sun Mar 15 17:25:44 2009 (r189859) +++ stable/7/sys/dev/drm/drm_drv.c Sun Mar 15 17:27:06 2009 (r189860) @@ -158,53 +158,53 @@ static int drm_msi_is_blacklisted(int ve return 0; } -int drm_probe(device_t dev, drm_pci_id_list_t *idlist) +int drm_probe(device_t kdev, drm_pci_id_list_t *idlist) { drm_pci_id_list_t *id_entry; int vendor, device; #if __FreeBSD_version < 700010 device_t realdev; - if (!strcmp(device_get_name(dev), "drmsub")) - realdev = device_get_parent(dev); + if (!strcmp(device_get_name(kdev), "drmsub")) + realdev = device_get_parent(kdev); else - realdev = dev; + realdev = kdev; vendor = pci_get_vendor(realdev); device = pci_get_device(realdev); #else - vendor = pci_get_vendor(dev); - device = pci_get_device(dev); + vendor = pci_get_vendor(kdev); + device = pci_get_device(kdev); #endif - if (pci_get_class(dev) != PCIC_DISPLAY - || pci_get_subclass(dev) != PCIS_DISPLAY_VGA) + if (pci_get_class(kdev) != PCIC_DISPLAY + || pci_get_subclass(kdev) != PCIS_DISPLAY_VGA) return ENXIO; id_entry = drm_find_description(vendor, device, idlist); if (id_entry != NULL) { - device_set_desc(dev, id_entry->name); + device_set_desc(kdev, id_entry->name); return 0; } return ENXIO; } -int drm_attach(device_t nbdev, drm_pci_id_list_t *idlist) +int drm_attach(device_t kdev, drm_pci_id_list_t *idlist) { struct drm_device *dev; drm_pci_id_list_t *id_entry; int unit, msicount; - unit = device_get_unit(nbdev); - dev = device_get_softc(nbdev); + unit = device_get_unit(kdev); + dev = device_get_softc(kdev); #if __FreeBSD_version < 700010 - if (!strcmp(device_get_name(nbdev), "drmsub")) - dev->device = device_get_parent(nbdev); + if (!strcmp(device_get_name(kdev), "drmsub")) + dev->device = device_get_parent(kdev); else - dev->device = nbdev; + dev->device = kdev; #else - dev->device = nbdev; + dev->device = kdev; #endif dev->devnode = make_dev(&drm_cdevsw, unit, @@ -259,11 +259,11 @@ int drm_attach(device_t nbdev, drm_pci_i return drm_load(dev); } -int drm_detach(device_t nbdev) +int drm_detach(device_t kdev) { struct drm_device *dev; - dev = device_get_softc(nbdev); + dev = device_get_softc(kdev); drm_unload(dev); Modified: stable/7/sys/dev/drm/i915_drv.c ============================================================================== --- stable/7/sys/dev/drm/i915_drv.c Sun Mar 15 17:25:44 2009 (r189859) +++ stable/7/sys/dev/drm/i915_drv.c Sun Mar 15 17:27:06 2009 (r189860) @@ -43,9 +43,9 @@ static drm_pci_id_list_t i915_pciidlist[ i915_PCI_IDS }; -static int i915_suspend(device_t nbdev) +static int i915_suspend(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); struct drm_i915_private *dev_priv = dev->dev_private; if (!dev || !dev_priv) { @@ -57,16 +57,16 @@ static int i915_suspend(device_t nbdev) i915_save_state(dev); - return (bus_generic_suspend(nbdev)); + return (bus_generic_suspend(kdev)); } -static int i915_resume(device_t nbdev) +static int i915_resume(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); i915_restore_state(dev); - return (bus_generic_resume(nbdev)); + return (bus_generic_resume(kdev)); } static void i915_configure(struct drm_device *dev) @@ -100,31 +100,31 @@ static void i915_configure(struct drm_de } static int -i915_probe(device_t dev) +i915_probe(device_t kdev) { - return drm_probe(dev, i915_pciidlist); + return drm_probe(kdev, i915_pciidlist); } static int -i915_attach(device_t nbdev) +i915_attach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); i915_configure(dev); - return drm_attach(nbdev, i915_pciidlist); + return drm_attach(kdev, i915_pciidlist); } static int -i915_detach(device_t nbdev) +i915_detach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); int ret; - ret = drm_detach(nbdev); + ret = drm_detach(kdev); free(dev->driver, DRM_MEM_DRIVER); Modified: stable/7/sys/dev/drm/mach64_drv.c ============================================================================== --- stable/7/sys/dev/drm/mach64_drv.c Sun Mar 15 17:25:44 2009 (r189859) +++ stable/7/sys/dev/drm/mach64_drv.c Sun Mar 15 17:27:06 2009 (r189860) @@ -77,22 +77,22 @@ static void mach64_configure(struct drm_ } static int -mach64_probe(device_t dev) +mach64_probe(device_t kdev) { - return drm_probe(dev, mach64_pciidlist); + return drm_probe(kdev, mach64_pciidlist); } static int -mach64_attach(device_t nbdev) +mach64_attach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); mach64_configure(dev); - return drm_attach(nbdev, mach64_pciidlist); + return drm_attach(kdev, mach64_pciidlist); } int @@ -102,12 +102,12 @@ mach64_driver_load(struct drm_device * d } static int -mach64_detach(device_t nbdev) +mach64_detach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); int ret; - ret = drm_detach(nbdev); + ret = drm_detach(kdev); free(dev->driver, DRM_MEM_DRIVER); Modified: stable/7/sys/dev/drm/mga_drv.c ============================================================================== --- stable/7/sys/dev/drm/mga_drv.c Sun Mar 15 17:25:44 2009 (r189859) +++ stable/7/sys/dev/drm/mga_drv.c Sun Mar 15 17:27:06 2009 (r189860) @@ -120,31 +120,31 @@ static void mga_configure(struct drm_dev } static int -mga_probe(device_t dev) +mga_probe(device_t kdev) { - return drm_probe(dev, mga_pciidlist); + return drm_probe(kdev, mga_pciidlist); } static int -mga_attach(device_t nbdev) +mga_attach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); mga_configure(dev); - return drm_attach(nbdev, mga_pciidlist); + return drm_attach(kdev, mga_pciidlist); } static int -mga_detach(device_t nbdev) +mga_detach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); int ret; - ret = drm_detach(nbdev); + ret = drm_detach(kdev); free(dev->driver, DRM_MEM_DRIVER); Modified: stable/7/sys/dev/drm/r128_drv.c ============================================================================== --- stable/7/sys/dev/drm/r128_drv.c Sun Mar 15 17:25:44 2009 (r189859) +++ stable/7/sys/dev/drm/r128_drv.c Sun Mar 15 17:27:06 2009 (r189860) @@ -76,22 +76,22 @@ static void r128_configure(struct drm_de } static int -r128_probe(device_t dev) +r128_probe(device_t kdev) { - return drm_probe(dev, r128_pciidlist); + return drm_probe(kdev, r128_pciidlist); } static int -r128_attach(device_t nbdev) +r128_attach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); r128_configure(dev); - return drm_attach(nbdev, r128_pciidlist); + return drm_attach(kdev, r128_pciidlist); } int r128_driver_load(struct drm_device * dev, unsigned long flags) @@ -100,12 +100,12 @@ int r128_driver_load(struct drm_device * } static int -r128_detach(device_t nbdev) +r128_detach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); int ret; - ret = drm_detach(nbdev); + ret = drm_detach(kdev); free(dev->driver, DRM_MEM_DRIVER); Modified: stable/7/sys/dev/drm/radeon_drv.c ============================================================================== --- stable/7/sys/dev/drm/radeon_drv.c Sun Mar 15 17:25:44 2009 (r189859) +++ stable/7/sys/dev/drm/radeon_drv.c Sun Mar 15 17:27:06 2009 (r189860) @@ -80,31 +80,31 @@ static void radeon_configure(struct drm_ } static int -radeon_probe(device_t dev) +radeon_probe(device_t kdev) { - return drm_probe(dev, radeon_pciidlist); + return drm_probe(kdev, radeon_pciidlist); } static int -radeon_attach(device_t nbdev) +radeon_attach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); radeon_configure(dev); - return drm_attach(nbdev, radeon_pciidlist); + return drm_attach(kdev, radeon_pciidlist); } static int -radeon_detach(device_t nbdev) +radeon_detach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); int ret; - ret = drm_detach(nbdev); + ret = drm_detach(kdev); free(dev->driver, DRM_MEM_DRIVER); Modified: stable/7/sys/dev/drm/savage_drv.c ============================================================================== --- stable/7/sys/dev/drm/savage_drv.c Sun Mar 15 17:25:44 2009 (r189859) +++ stable/7/sys/dev/drm/savage_drv.c Sun Mar 15 17:27:06 2009 (r189860) @@ -66,31 +66,31 @@ static void savage_configure(struct drm_ } static int -savage_probe(device_t dev) +savage_probe(device_t kdev) { - return drm_probe(dev, savage_pciidlist); + return drm_probe(kdev, savage_pciidlist); } static int -savage_attach(device_t nbdev) +savage_attach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); savage_configure(dev); - return drm_attach(nbdev, savage_pciidlist); + return drm_attach(kdev, savage_pciidlist); } static int -savage_detach(device_t nbdev) +savage_detach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); int ret; - ret = drm_detach(nbdev); + ret = drm_detach(kdev); free(dev->driver, DRM_MEM_DRIVER); Modified: stable/7/sys/dev/drm/sis_drv.c ============================================================================== --- stable/7/sys/dev/drm/sis_drv.c Sun Mar 15 17:25:44 2009 (r189859) +++ stable/7/sys/dev/drm/sis_drv.c Sun Mar 15 17:27:06 2009 (r189860) @@ -60,31 +60,31 @@ static void sis_configure(struct drm_dev } static int -sis_probe(device_t dev) +sis_probe(device_t kdev) { - return drm_probe(dev, sis_pciidlist); + return drm_probe(kdev, sis_pciidlist); } static int -sis_attach(device_t nbdev) +sis_attach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); sis_configure(dev); - return drm_attach(nbdev, sis_pciidlist); + return drm_attach(kdev, sis_pciidlist); } static int -sis_detach(device_t nbdev) +sis_detach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); int ret; - ret = drm_detach(nbdev); + ret = drm_detach(kdev); free(dev->driver, DRM_MEM_DRIVER); Modified: stable/7/sys/dev/drm/tdfx_drv.c ============================================================================== --- stable/7/sys/dev/drm/tdfx_drv.c Sun Mar 15 17:25:44 2009 (r189859) +++ stable/7/sys/dev/drm/tdfx_drv.c Sun Mar 15 17:27:06 2009 (r189860) @@ -62,31 +62,31 @@ static void tdfx_configure(struct drm_de } static int -tdfx_probe(device_t dev) +tdfx_probe(device_t kdev) { - return drm_probe(dev, tdfx_pciidlist); + return drm_probe(kdev, tdfx_pciidlist); } static int -tdfx_attach(device_t nbdev) +tdfx_attach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); tdfx_configure(dev); - return drm_attach(nbdev, tdfx_pciidlist); + return drm_attach(kdev, tdfx_pciidlist); } static int -tdfx_detach(device_t nbdev) +tdfx_detach(device_t kdev) { - struct drm_device *dev = device_get_softc(nbdev); + struct drm_device *dev = device_get_softc(kdev); int ret; - ret = drm_detach(nbdev); + ret = drm_detach(kdev); free(dev->driver, DRM_MEM_DRIVER); From rwatson at FreeBSD.org Mon Mar 16 09:57:05 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 09:57:12 2009 Subject: svn commit: r189886 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb security/audit Message-ID: <200903161657.n2GGv4wg066390@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 16:57:04 2009 New Revision: 189886 URL: http://svn.freebsd.org/changeset/base/189886 Log: Merge r174894 from head to stable/7: Change "audit_pipe_preselect" to "audit_pipe_presel" to make it print with proper alignment in ddb(4) and vmstat(8). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/security/audit/audit_pipe.c Modified: stable/7/sys/security/audit/audit_pipe.c ============================================================================== --- stable/7/sys/security/audit/audit_pipe.c Mon Mar 16 16:55:05 2009 (r189885) +++ stable/7/sys/security/audit/audit_pipe.c Mon Mar 16 16:57:04 2009 (r189886) @@ -69,7 +69,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_AUDIT_PIPE, "audit_pipe", "Audit pipes"); static MALLOC_DEFINE(M_AUDIT_PIPE_ENTRY, "audit_pipeent", "Audit pipe entries and buffers"); -static MALLOC_DEFINE(M_AUDIT_PIPE_PRESELECT, "audit_pipe_preselect", +static MALLOC_DEFINE(M_AUDIT_PIPE_PRESELECT, "audit_pipe_presel", "Audit pipe preselection structure"); /* From rwatson at FreeBSD.org Mon Mar 16 10:03:35 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 10:03:42 2009 Subject: svn commit: r189887 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern security/audit Message-ID: <200903161703.n2GH3X8i066618@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 17:03:33 2009 New Revision: 189887 URL: http://svn.freebsd.org/changeset/base/189887 Log: Merge r182750, r182754 from head to stable/7: If the process id specified is invalid, the system call returns ESRCH Unbreak the build. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/kern_proc.c stable/7/sys/security/audit/audit_syscalls.c Modified: stable/7/sys/kern/kern_proc.c ============================================================================== --- stable/7/sys/kern/kern_proc.c Mon Mar 16 16:57:04 2009 (r189886) +++ stable/7/sys/kern/kern_proc.c Mon Mar 16 17:03:33 2009 (r189887) @@ -994,10 +994,10 @@ sysctl_out_proc(struct proc *p, struct s np = pfind(pid); } if (np == NULL) - return EAGAIN; + return (ESRCH); if (np != p) { PROC_UNLOCK(np); - return EAGAIN; + return (ESRCH); } PROC_UNLOCK(np); return (0); Modified: stable/7/sys/security/audit/audit_syscalls.c ============================================================================== --- stable/7/sys/security/audit/audit_syscalls.c Mon Mar 16 16:57:04 2009 (r189886) +++ stable/7/sys/security/audit/audit_syscalls.c Mon Mar 16 17:03:33 2009 (r189887) @@ -314,12 +314,12 @@ auditon(struct thread *td, struct audito case A_GETPINFO: if (udata.au_aupinfo.ap_pid < 1) - return (EINVAL); + return (ESRCH); if ((tp = pfind(udata.au_aupinfo.ap_pid)) == NULL) - return (EINVAL); - if (p_cansee(td, tp) != 0) { + return (ESRCH); + if ((error = p_cansee(td, tp)) != 0) { PROC_UNLOCK(tp); - return (EINVAL); + return (error); } cred = tp->p_ucred; if (cred->cr_audit.ai_termid.at_type == AU_IPv6) { @@ -341,16 +341,16 @@ auditon(struct thread *td, struct audito case A_SETPMASK: if (udata.au_aupinfo.ap_pid < 1) - return (EINVAL); + return (ESRCH); newcred = crget(); if ((tp = pfind(udata.au_aupinfo.ap_pid)) == NULL) { crfree(newcred); - return (EINVAL); + return (ESRCH); } - if (p_cansee(td, tp) != 0) { + if ((error = p_cansee(td, tp)) != 0) { PROC_UNLOCK(tp); crfree(newcred); - return (EINVAL); + return (error); } oldcred = tp->p_ucred; crcopy(newcred, oldcred); @@ -377,9 +377,9 @@ auditon(struct thread *td, struct audito case A_GETPINFO_ADDR: if (udata.au_aupinfo_addr.ap_pid < 1) - return (EINVAL); + return (ESRCH); if ((tp = pfind(udata.au_aupinfo_addr.ap_pid)) == NULL) - return (EINVAL); + return (ESRCH); cred = tp->p_ucred; udata.au_aupinfo_addr.ap_auid = cred->cr_audit.ai_auid; udata.au_aupinfo_addr.ap_mask.am_success = From rwatson at FreeBSD.org Mon Mar 16 10:08:11 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 10:08:18 2009 Subject: svn commit: r189888 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb security/audit Message-ID: <200903161708.n2GH8AFo066786@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 17:08:10 2009 New Revision: 189888 URL: http://svn.freebsd.org/changeset/base/189888 Log: Merge r186662 from head to stable/7: Fix white space botch: use carriage returns rather than tabs. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/security/audit/audit_pipe.c Modified: stable/7/sys/security/audit/audit_pipe.c ============================================================================== --- stable/7/sys/security/audit/audit_pipe.c Mon Mar 16 17:03:33 2009 (r189887) +++ stable/7/sys/security/audit/audit_pipe.c Mon Mar 16 17:08:10 2009 (r189888) @@ -169,7 +169,8 @@ struct audit_pipe { /* * Current pending record list. Protected by a combination of ap_mtx * and ap_sx. Note particularly that *both* locks are required to - * remove a record from the head of the queue, as an in-progress read * may sleep while copying and therefore cannot hold ap_mtx. + * remove a record from the head of the queue, as an in-progress read + * may sleep while copying and therefore cannot hold ap_mtx. */ TAILQ_HEAD(, audit_pipe_entry) ap_queue; From rwatson at FreeBSD.org Mon Mar 16 10:15:03 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 10:15:10 2009 Subject: svn commit: r189889 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb security/audit Message-ID: <200903161715.n2GHF2ek067023@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 17:15:02 2009 New Revision: 189889 URL: http://svn.freebsd.org/changeset/base/189889 Log: Merge r186822 from head to stable/7: In AUDIT_SYSCALL_EXIT(), invoke audit_syscall_exit() only if an audit record is active on the current thread--historically we may always have wanted to enter the audit code if auditing was enabled, but now we just commit the audit record so don't need to enter if there isn't one. Obtained from: TrustedBSD Project Sponsored by: Apple, Inc. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/security/audit/audit.h Modified: stable/7/sys/security/audit/audit.h ============================================================================== --- stable/7/sys/security/audit/audit.h Mon Mar 16 17:08:10 2009 (r189888) +++ stable/7/sys/security/audit/audit.h Mon Mar 16 17:15:02 2009 (r189889) @@ -198,11 +198,11 @@ void audit_thread_free(struct thread *t /* * Wrap the audit_syscall_exit() function so that it is called only when - * auditing is enabled, or we have a audit record on the thread. It is - * possible that an audit record was begun before auditing was turned off. + * we have a audit record on the thread. Audit records can persist after + * auditing is disabled, so we don't just check audit_enabled here. */ #define AUDIT_SYSCALL_EXIT(error, td) do { \ - if (audit_enabled || (td->td_ar != NULL)) \ + if (td->td_ar != NULL) \ audit_syscall_exit(error, td); \ } while (0) From rwatson at FreeBSD.org Mon Mar 16 10:25:10 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 10:25:22 2009 Subject: svn commit: r189890 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb security/audit sys Message-ID: <200903161725.n2GHP94b067289@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 17:25:09 2009 New Revision: 189890 URL: http://svn.freebsd.org/changeset/base/189890 Log: Merge r189570 from head to stable/7: Add a new thread-private flag, TDP_AUDITREC, to indicate whether or not there is an audit record hung off of td_ar on the current thread. Test this flag instead of td_ar when auditing syscall arguments or checking for an audit record to commit on syscall return. Under these circumstances, td_pflags is much more likely to be in the cache (especially if there is no auditing of the current system call), so this should help reduce cache misses in the system call return path. Reported by: kris Obtained from: TrustedBSD Project Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/security/audit/audit.c stable/7/sys/security/audit/audit.h stable/7/sys/security/audit/audit_syscalls.c stable/7/sys/sys/proc.h Modified: stable/7/sys/security/audit/audit.c ============================================================================== --- stable/7/sys/security/audit/audit.c Mon Mar 16 17:15:02 2009 (r189889) +++ stable/7/sys/security/audit/audit.c Mon Mar 16 17:25:09 2009 (r189890) @@ -446,6 +446,8 @@ audit_syscall_enter(unsigned short code, au_id_t auid; KASSERT(td->td_ar == NULL, ("audit_syscall_enter: td->td_ar != NULL")); + KASSERT((td->td_pflags & TDP_AUDITREC) == 0, + ("audit_syscall_enter: TDP_AUDITREC set")); /* * In FreeBSD, each ABI has its own system call table, and hence @@ -496,9 +498,13 @@ audit_syscall_enter(unsigned short code, panic("audit_failing_stop: thread continued"); } td->td_ar = audit_new(event, td); - } else if (audit_pipe_preselect(auid, event, class, AU_PRS_BOTH, 0)) + if (td->td_ar != NULL) + td->td_pflags |= TDP_AUDITREC; + } else if (audit_pipe_preselect(auid, event, class, AU_PRS_BOTH, 0)) { td->td_ar = audit_new(event, td); - else + if (td->td_ar != NULL) + td->td_pflags |= TDP_AUDITREC; + } else td->td_ar = NULL; } @@ -526,6 +532,7 @@ audit_syscall_exit(int error, struct thr audit_commit(td->td_ar, error, retval); td->td_ar = NULL; + td->td_pflags &= ~TDP_AUDITREC; } void @@ -580,6 +587,8 @@ audit_thread_free(struct thread *td) { KASSERT(td->td_ar == NULL, ("audit_thread_free: td_ar != NULL")); + KASSERT((td->td_pflags & TDP_AUDITREC) == 0, + ("audit_thread_free: TDP_AUDITREC set")); } void Modified: stable/7/sys/security/audit/audit.h ============================================================================== --- stable/7/sys/security/audit/audit.h Mon Mar 16 17:15:02 2009 (r189889) +++ stable/7/sys/security/audit/audit.h Mon Mar 16 17:25:09 2009 (r189890) @@ -186,7 +186,7 @@ void audit_thread_free(struct thread *t * audit_enabled flag before performing the actual call. */ #define AUDIT_ARG(op, args...) do { \ - if (td->td_ar != NULL) \ + if (td->td_pflags & TDP_AUDITREC) \ audit_arg_ ## op (args); \ } while (0) @@ -202,7 +202,7 @@ void audit_thread_free(struct thread *t * auditing is disabled, so we don't just check audit_enabled here. */ #define AUDIT_SYSCALL_EXIT(error, td) do { \ - if (td->td_ar != NULL) \ + if (td->td_pflags & TDP_AUDITREC) \ audit_syscall_exit(error, td); \ } while (0) @@ -210,7 +210,7 @@ void audit_thread_free(struct thread *t * A Macro to wrap the audit_sysclose() function. */ #define AUDIT_SYSCLOSE(td, fd) do { \ - if (audit_enabled) \ + if (td->td_pflags & TDP_AUDITREC) \ audit_sysclose(td, fd); \ } while (0) Modified: stable/7/sys/security/audit/audit_syscalls.c ============================================================================== --- stable/7/sys/security/audit/audit_syscalls.c Mon Mar 16 17:15:02 2009 (r189889) +++ stable/7/sys/security/audit/audit_syscalls.c Mon Mar 16 17:25:09 2009 (r189890) @@ -96,6 +96,7 @@ audit(struct thread *td, struct audit_ar td->td_ar = audit_new(AUE_NULL, td); if (td->td_ar == NULL) return (ENOTSUP); + td->td_pflags |= TDP_AUDITREC; ar = td->td_ar; } Modified: stable/7/sys/sys/proc.h ============================================================================== --- stable/7/sys/sys/proc.h Mon Mar 16 17:15:02 2009 (r189889) +++ stable/7/sys/sys/proc.h Mon Mar 16 17:25:09 2009 (r189890) @@ -379,6 +379,7 @@ do { \ #define TDP_WAKEUP 0x00080000 /* Don't sleep in umtx cond_wait */ #define TDP_INBDFLUSH 0x00100000 /* Already in BO_BDFLUSH, do not recurse */ #define TDP_IGNSUSP 0x00800000 /* Permission to ignore the MNTK_SUSPEND* */ +#define TDP_AUDITREC 0x01000000 /* Audit record pending on thread */ /* * Reasons that the current thread can not be run yet. From rwatson at FreeBSD.org Mon Mar 16 10:30:39 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 10:30:57 2009 Subject: svn commit: r189891 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern Message-ID: <200903161730.n2GHUc7L067488@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 17:30:38 2009 New Revision: 189891 URL: http://svn.freebsd.org/changeset/base/189891 Log: Merge r189545 from head to stable/7: By default, don't compile in counters of calls to various time query functions in the kernel, as these effectively serialize parallel calls to the gettimeofday(2) system call, as well as other kernel services that use timestamps. Use the NetBSD version of the fix (kern_tc.c:1.32 by ad@) as they have picked up our timecounter code and also ran into the same problem. Reported by: kris Obtained from: NetBSD Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/kern_tc.c Modified: stable/7/sys/kern/kern_tc.c ============================================================================== --- stable/7/sys/kern/kern_tc.c Mon Mar 16 17:25:09 2009 (r189890) +++ stable/7/sys/kern/kern_tc.c Mon Mar 16 17:30:38 2009 (r189891) @@ -103,6 +103,7 @@ static int timestepwarnings; SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RW, ×tepwarnings, 0, ""); +#ifdef TC_COUNTERS #define TC_STATS(foo) \ static u_int foo; \ SYSCTL_UINT(_kern_timecounter, OID_AUTO, foo, CTLFLAG_RD, &foo, 0, "");\ @@ -114,7 +115,11 @@ TC_STATS(ngetbinuptime); TC_STATS(ngetna TC_STATS(ngetbintime); TC_STATS(ngetnanotime); TC_STATS(ngetmicrotime); TC_STATS(nsetclock); +#define TC_COUNT(var) var++ #undef TC_STATS +#else +#define TC_COUNT(var) /* nothing */ +#endif /* TC_COUNTERS */ static void tc_windup(void); static void cpu_tick_calibrate(int); @@ -180,7 +185,7 @@ binuptime(struct bintime *bt) struct timehands *th; u_int gen; - nbinuptime++; + TC_COUNT(nbinuptime); do { th = timehands; gen = th->th_generation; @@ -194,7 +199,7 @@ nanouptime(struct timespec *tsp) { struct bintime bt; - nnanouptime++; + TC_COUNT(nnanouptime); binuptime(&bt); bintime2timespec(&bt, tsp); } @@ -204,7 +209,7 @@ microuptime(struct timeval *tvp) { struct bintime bt; - nmicrouptime++; + TC_COUNT(nmicrouptime); binuptime(&bt); bintime2timeval(&bt, tvp); } @@ -213,7 +218,7 @@ void bintime(struct bintime *bt) { - nbintime++; + TC_COUNT(nbintime); binuptime(bt); bintime_add(bt, &boottimebin); } @@ -223,7 +228,7 @@ nanotime(struct timespec *tsp) { struct bintime bt; - nnanotime++; + TC_COUNT(nnanotime); bintime(&bt); bintime2timespec(&bt, tsp); } @@ -233,7 +238,7 @@ microtime(struct timeval *tvp) { struct bintime bt; - nmicrotime++; + TC_COUNT(nmicrotime); bintime(&bt); bintime2timeval(&bt, tvp); } @@ -244,7 +249,7 @@ getbinuptime(struct bintime *bt) struct timehands *th; u_int gen; - ngetbinuptime++; + TC_COUNT(ngetbinuptime); do { th = timehands; gen = th->th_generation; @@ -258,7 +263,7 @@ getnanouptime(struct timespec *tsp) struct timehands *th; u_int gen; - ngetnanouptime++; + TC_COUNT(ngetnanouptime); do { th = timehands; gen = th->th_generation; @@ -272,7 +277,7 @@ getmicrouptime(struct timeval *tvp) struct timehands *th; u_int gen; - ngetmicrouptime++; + TC_COUNT(ngetmicrouptime); do { th = timehands; gen = th->th_generation; @@ -286,7 +291,7 @@ getbintime(struct bintime *bt) struct timehands *th; u_int gen; - ngetbintime++; + TC_COUNT(ngetbintime); do { th = timehands; gen = th->th_generation; @@ -301,7 +306,7 @@ getnanotime(struct timespec *tsp) struct timehands *th; u_int gen; - ngetnanotime++; + TC_COUNT(ngetnanotime); do { th = timehands; gen = th->th_generation; @@ -315,7 +320,7 @@ getmicrotime(struct timeval *tvp) struct timehands *th; u_int gen; - ngetmicrotime++; + TC_COUNT(ngetmicrotime); do { th = timehands; gen = th->th_generation; @@ -406,7 +411,7 @@ tc_setclock(struct timespec *ts) struct bintime bt, bt2; cpu_tick_calibrate(1); - nsetclock++; + TC_COUNT(nsetclock); nanotime(&tbef); timespec2bintime(ts, &bt); binuptime(&bt2); From rwatson at FreeBSD.org Mon Mar 16 10:46:57 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 10:47:08 2009 Subject: svn commit: r189892 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb Message-ID: <200903161746.n2GHktkE067879@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 17:46:55 2009 New Revision: 189892 URL: http://svn.freebsd.org/changeset/base/189892 Log: Merge r189655 from head to stable/7: Prefer ENETDOWN to ENXIO when returning queuing errors due to a link down, interface down, etc, with if_cxgb's if_transmit routine. Reviewed by: kmacy Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/cxgb/cxgb_multiq.c Modified: stable/7/sys/dev/cxgb/cxgb_multiq.c ============================================================================== --- stable/7/sys/dev/cxgb/cxgb_multiq.c Mon Mar 16 17:30:38 2009 (r189891) +++ stable/7/sys/dev/cxgb/cxgb_multiq.c Mon Mar 16 17:46:55 2009 (r189892) @@ -131,7 +131,7 @@ cxgb_pcpu_enqueue_packet_(struct sge_qse KASSERT(m->m_type == MT_DATA, ("bad mbuf type %d", m->m_type)); if (qs->qs_flags & QS_EXITING) { m_freem(m); - return (ENXIO); + return (ENETDOWN); } txq = &qs->txq[TXQ_ETH]; err = buf_ring_enqueue(&txq->txq_mr, m); @@ -425,13 +425,13 @@ cxgb_pcpu_start_(struct sge_qset *qs, st retry: if (!pi->link_config.link_ok) - initerr = ENXIO; + initerr = ENETDOWN; else if (qs->qs_flags & QS_EXITING) - initerr = ENXIO; + initerr = ENETDOWN; else if ((pi->ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) - initerr = ENXIO; + initerr = ENETDOWN; else if ((pi->ifp->if_flags & IFF_UP) == 0) - initerr = ENXIO; + initerr = ENETDOWN; else if (immpkt) { if (!buf_ring_empty(&txq->txq_mr)) From rwatson at FreeBSD.org Mon Mar 16 10:55:25 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 10:55:42 2009 Subject: svn commit: r189893 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cm dev/cxgb Message-ID: <200903161755.n2GHtOma068109@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 17:55:24 2009 New Revision: 189893 URL: http://svn.freebsd.org/changeset/base/189893 Log: Merge r188545 from head to stable/7: Remove unused ifaddr and ifreq local variables. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cm/smc90cx6.c stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/cm/smc90cx6.c ============================================================================== --- stable/7/sys/dev/cm/smc90cx6.c Mon Mar 16 17:46:55 2009 (r189892) +++ stable/7/sys/dev/cm/smc90cx6.c Mon Mar 16 17:55:24 2009 (r189893) @@ -861,14 +861,10 @@ cm_ioctl(ifp, command, data) caddr_t data; { struct cm_softc *sc; - struct ifaddr *ifa; - struct ifreq *ifr; int error; error = 0; sc = ifp->if_softc; - ifa = (struct ifaddr *)data; - ifr = (struct ifreq *)data; #if defined(CM_DEBUG) && (CM_DEBUG > 2) if_printf(ifp, "ioctl() called, cmd = 0x%lx\n", command); From rwatson at FreeBSD.org Mon Mar 16 10:57:31 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 10:57:37 2009 Subject: svn commit: r189894 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb net Message-ID: <200903161757.n2GHvTnP068208@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 17:57:29 2009 New Revision: 189894 URL: http://svn.freebsd.org/changeset/base/189894 Log: Merge r188546 from head to stable/7: Remove unused ifaddr local variable in ioctl routine. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/net/if_vlan.c Modified: stable/7/sys/net/if_vlan.c ============================================================================== --- stable/7/sys/net/if_vlan.c Mon Mar 16 17:55:24 2009 (r189893) +++ stable/7/sys/net/if_vlan.c Mon Mar 16 17:57:29 2009 (r189894) @@ -1296,7 +1296,6 @@ vlan_trunk_capabilities(struct ifnet *if static int vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { - struct ifaddr *ifa; struct ifnet *p; struct ifreq *ifr; struct ifvlan *ifv; @@ -1304,7 +1303,6 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd int error = 0; ifr = (struct ifreq *)data; - ifa = (struct ifaddr *)data; ifv = ifp->if_softc; switch (cmd) { From rwatson at FreeBSD.org Mon Mar 16 11:02:02 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 11:02:08 2009 Subject: svn commit: r189895 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netinet Message-ID: <200903161802.n2GI2179068384@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 18:02:00 2009 New Revision: 189895 URL: http://svn.freebsd.org/changeset/base/189895 Log: Merge r188962 from head to stable/7: In in_rtqkill(), assert the radix head lock, and pass RTF_RNH_LOCKED to in_rtrequest(); the radix head lock is already acquired before rnh_walktree is called in in_rtqtimo_one(). This avoids a recursive acquisition that is no longer permitted in 8.x due to use of an rwlock for the radix head lock. Reported by: dikshie While not strictly required in 7.x, I am merging this to keep locking as consistent as possible in the routing code between 7.x and 8.x. Note that because the rwlock change has not been merged, this becomes LOCK_ASSERT rather than WLOCK_ASSERT. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netinet/in_rmx.c Modified: stable/7/sys/netinet/in_rmx.c ============================================================================== --- stable/7/sys/netinet/in_rmx.c Mon Mar 16 17:57:29 2009 (r189894) +++ stable/7/sys/netinet/in_rmx.c Mon Mar 16 18:02:00 2009 (r189895) @@ -219,6 +219,8 @@ in_rtqkill(struct radix_node *rn, void * struct rtentry *rt = (struct rtentry *)rn; int err; + RADIX_NODE_HEAD_LOCK_ASSERT(ap->rnh); + if (rt->rt_flags & RTPRF_OURS) { ap->found++; @@ -229,7 +231,8 @@ in_rtqkill(struct radix_node *rn, void * err = in_rtrequest(RTM_DELETE, (struct sockaddr *)rt_key(rt), rt->rt_gateway, rt_mask(rt), - rt->rt_flags, 0, rt->rt_fibnum); + rt->rt_flags | RTF_RNH_LOCKED, 0, + rt->rt_fibnum); if (err) { log(LOG_WARNING, "in_rtqkill: error %d\n", err); } else { From rwatson at FreeBSD.org Mon Mar 16 11:05:34 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 11:05:40 2009 Subject: svn commit: r189896 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netinet6 Message-ID: <200903161805.n2GI5WQv068522@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 18:05:31 2009 New Revision: 189896 URL: http://svn.freebsd.org/changeset/base/189896 Log: Merge r188963 from head to stable/7: Assert the radix head lock in in6_rtqkill(). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netinet6/in6_rmx.c Modified: stable/7/sys/netinet6/in6_rmx.c ============================================================================== --- stable/7/sys/netinet6/in6_rmx.c Mon Mar 16 18:02:00 2009 (r189895) +++ stable/7/sys/netinet6/in6_rmx.c Mon Mar 16 18:05:31 2009 (r189896) @@ -289,6 +289,8 @@ in6_rtqkill(struct radix_node *rn, void struct rtentry *rt = (struct rtentry *)rn; int err; + RADIX_NODE_HEAD_LOCK_ASSERT(ap->rnh); + if (rt->rt_flags & RTPRF_OURS) { ap->found++; From rwatson at FreeBSD.org Mon Mar 16 11:07:27 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 11:07:33 2009 Subject: svn commit: r189897 - stable/7/share/man/man8 Message-ID: <200903161807.n2GI7Nbi068606@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 18:07:23 2009 New Revision: 189897 URL: http://svn.freebsd.org/changeset/base/189897 Log: Merge r189778 from head to stable/7: Don't suggest mounting procfs in diskless configurations. Modified: stable/7/share/man/man8/ (props changed) stable/7/share/man/man8/diskless.8 Modified: stable/7/share/man/man8/diskless.8 ============================================================================== --- stable/7/share/man/man8/diskless.8 Mon Mar 16 18:05:31 2009 (r189896) +++ stable/7/share/man/man8/diskless.8 Mon Mar 16 18:07:23 2009 (r189897) @@ -376,7 +376,6 @@ As a minimum, you normally need to have .Bd -literal -offset indent : / nfs ro 0 0 :/usr /usr nfs ro 0 0 -proc /proc procfs rw 0 0 .Ed .Pp You also need to create a customized version of From rwatson at FreeBSD.org Mon Mar 16 11:15:53 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Mar 16 11:16:25 2009 Subject: svn commit: r189898 - stable/7/sys/netinet6 Message-ID: <200903161815.n2GIFq3p068870@svn.freebsd.org> Author: rwatson Date: Mon Mar 16 18:15:52 2009 New Revision: 189898 URL: http://svn.freebsd.org/changeset/base/189898 Log: Merge adding RTF_RNH_LOCKED to the flags argument of rtrequest() in in6_rtqkill(), making it match in_rtqkill(). This change appeared in 8.x as part of the arpv2 merge (r186119) but that isn't appropriate to merge. Modified: stable/7/sys/netinet6/in6_rmx.c Modified: stable/7/sys/netinet6/in6_rmx.c ============================================================================== --- stable/7/sys/netinet6/in6_rmx.c Mon Mar 16 18:07:23 2009 (r189897) +++ stable/7/sys/netinet6/in6_rmx.c Mon Mar 16 18:15:52 2009 (r189898) @@ -301,7 +301,7 @@ in6_rtqkill(struct radix_node *rn, void err = rtrequest(RTM_DELETE, (struct sockaddr *)rt_key(rt), rt->rt_gateway, rt_mask(rt), - rt->rt_flags, 0); + rt->rt_flags|RTF_RNH_LOCKED, 0); if (err) { log(LOG_WARNING, "in6_rtqkill: error %d", err); } else { From lulf at FreeBSD.org Mon Mar 16 23:54:43 2009 From: lulf at FreeBSD.org (Ulf Lilleengen) Date: Mon Mar 16 23:54:50 2009 Subject: svn commit: r189918 - in stable/7: contrib/csup usr.bin/csup Message-ID: <200903170654.n2H6sgpu085502@svn.freebsd.org> Author: lulf Date: Tue Mar 17 06:54:41 2009 New Revision: 189918 URL: http://svn.freebsd.org/changeset/base/189918 Log: MFH: r186781 Merge support for CVSMode (aka. mirror mode) into csup. This means csup can now fetch a complete CVS repository. Support for rsync update of regular files are also included, but are not yet enabled. The change should not have an impact on existing csup usage, as little of the existing code has changed. r186871 - Update manpage now that cvs mode is supported. r188405 - Fix an issue where file attributes were not installed correctly during a Touch and SetAttrs operation. - SetAttrs and Touch were incorrectly switched. r188644 - Do not free the pattern lists immediately after use, as they might be needed again in case the connection is interrupted and csup have to reconnect. The lists will be freed after the collection has been completely processed. r189455 - Try to handle rcsfile write failures in the same way as cvsup, as they are not necessarily fatal. If the file was incorrectly written, the checksum will detect it and the file will be retransferred. Added: stable/7/contrib/csup/lex.rcs.c - copied unchanged from r186781, head/contrib/csup/lex.rcs.c stable/7/contrib/csup/rcsfile.c - copied unchanged from r186781, head/contrib/csup/rcsfile.c stable/7/contrib/csup/rcsfile.h - copied unchanged from r186781, head/contrib/csup/rcsfile.h stable/7/contrib/csup/rcsparse.c - copied unchanged from r186781, head/contrib/csup/rcsparse.c stable/7/contrib/csup/rcsparse.h - copied unchanged from r186781, head/contrib/csup/rcsparse.h stable/7/contrib/csup/rcstokenizer.h - copied unchanged from r186781, head/contrib/csup/rcstokenizer.h stable/7/contrib/csup/rcstokenizer.l - copied unchanged from r186781, head/contrib/csup/rcstokenizer.l stable/7/contrib/csup/rsyncfile.c - copied unchanged from r186781, head/contrib/csup/rsyncfile.c stable/7/contrib/csup/rsyncfile.h - copied unchanged from r186781, head/contrib/csup/rsyncfile.h Modified: stable/7/contrib/csup/ (props changed) stable/7/contrib/csup/GNUmakefile stable/7/contrib/csup/Makefile stable/7/contrib/csup/TODO stable/7/contrib/csup/config.c stable/7/contrib/csup/csup.1 stable/7/contrib/csup/detailer.c stable/7/contrib/csup/diff.c stable/7/contrib/csup/diff.h stable/7/contrib/csup/fattr.c stable/7/contrib/csup/fattr.h stable/7/contrib/csup/keyword.c stable/7/contrib/csup/keyword.h stable/7/contrib/csup/lister.c stable/7/contrib/csup/misc.c stable/7/contrib/csup/misc.h stable/7/contrib/csup/mux.c stable/7/contrib/csup/proto.c stable/7/contrib/csup/proto.h stable/7/contrib/csup/status.c stable/7/contrib/csup/stream.c stable/7/contrib/csup/stream.h stable/7/contrib/csup/updater.c stable/7/usr.bin/csup/ (props changed) stable/7/usr.bin/csup/Makefile Modified: stable/7/contrib/csup/GNUmakefile ============================================================================== --- stable/7/contrib/csup/GNUmakefile Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/GNUmakefile Tue Mar 17 06:54:41 2009 (r189918) @@ -12,8 +12,9 @@ GROUP?= 0 UNAME= $(shell uname -s) SRCS= attrstack.c config.c detailer.c diff.c fattr.c fixups.c fnmatch.c \ - globtree.c idcache.c keyword.c lister.c main.c misc.c mux.c pathcomp.c \ - parse.c proto.c status.c stream.c threads.c token.c updater.c + globtree.c idcache.c keyword.c lex.rcs.c lister.c main.c misc.c mux.c \ + pathcomp.c parse.c proto.c rcsfile.c rcsparse.c rsyncfile.c status.c \ + stream.c threads.c token.c updater.c OBJS= $(SRCS:.c=.o) WARNS= -Wall -W -Wno-unused-parameter -Wmissing-prototypes -Wpointer-arith \ Modified: stable/7/contrib/csup/Makefile ============================================================================== --- stable/7/contrib/csup/Makefile Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/Makefile Tue Mar 17 06:54:41 2009 (r189918) @@ -9,10 +9,11 @@ UNAME!= /usr/bin/uname -s PROG= csup SRCS= attrstack.c config.c detailer.c diff.c fattr.c fixups.c fnmatch.c \ globtree.c idcache.c keyword.c lister.c main.c misc.c mux.c parse.y \ - pathcomp.c proto.c status.c stream.c threads.c token.l updater.c + pathcomp.c proto.c status.c stream.c threads.c token.l updater.c \ + rcsfile.c rcsparse.c lex.rcs.c rsyncfile.c CFLAGS+= -I. -I${.CURDIR} -g -pthread -DHAVE_FFLAGS -DNDEBUG -WARNS?= 6 +WARNS?= 1 # A bit of tweaking is needed to get this Makefile working # with the bsd.prog.mk of all the *BSD OSes... Modified: stable/7/contrib/csup/TODO ============================================================================== --- stable/7/contrib/csup/TODO Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/TODO Tue Mar 17 06:54:41 2009 (r189918) @@ -28,4 +28,3 @@ MISSING FEATURES: checkout files (files in CVS/ subdirectores), a command line override to only update a specific collection and a third verbosity level to display commit log messages. -- Add support for CVS mode (maybe?). Modified: stable/7/contrib/csup/config.c ============================================================================== --- stable/7/contrib/csup/config.c Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/config.c Tue Mar 17 06:54:41 2009 (r189918) @@ -133,7 +133,6 @@ config_init(const char *file, struct col coll->co_options &= ~CO_CHECKRCS; /* In recent versions, we always try to set the file modes. */ coll->co_options |= CO_SETMODE; - /* XXX We don't support the rsync updating algorithm yet. */ coll->co_options |= CO_NORSYNC; error = config_parse_refusefiles(coll); if (error) @@ -444,10 +443,6 @@ coll_add(char *name) "\"%s\"\n", cur_coll->co_name); exit(1); } - if (!(cur_coll->co_options & CO_CHECKOUTMODE)) { - lprintf(-1, "Client only supports checkout mode\n"); - exit(1); - } if (!STAILQ_EMPTY(&colls)) { coll = STAILQ_LAST(&colls, coll, co_next); if (strcmp(coll->co_host, cur_coll->co_host) != 0) { Modified: stable/7/contrib/csup/csup.1 ============================================================================== --- stable/7/contrib/csup/csup.1 Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/csup.1 Tue Mar 17 06:54:41 2009 (r189918) @@ -442,8 +442,6 @@ They are called mode and .Em checkout mode. -.Nm -only supports the checkout mode for now. .Pp In CVS mode, the client receives copies of the actual RCS files making up the master CVS repository. CVS mode is the default mode of operation. Modified: stable/7/contrib/csup/detailer.c ============================================================================== --- stable/7/contrib/csup/detailer.c Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/detailer.c Tue Mar 17 06:54:41 2009 (r189918) @@ -30,13 +30,21 @@ #include #include #include +#include + +#include +#include +#include #include "config.h" #include "detailer.h" #include "fixups.h" +#include "globtree.h" #include "misc.h" #include "mux.h" #include "proto.h" +#include "rcsfile.h" +#include "rsyncfile.h" #include "status.h" #include "stream.h" @@ -56,8 +64,16 @@ struct detailer { static int detailer_batch(struct detailer *); static int detailer_coll(struct detailer *, struct coll *, struct status *); -static int detailer_dofile(struct detailer *, struct coll *, +static int detailer_dofile_co(struct detailer *, struct coll *, struct status *, char *); +static int detailer_dofile_rcs(struct detailer *, struct coll *, + char *, char *); +static int detailer_dofile_regular(struct detailer *, char *, char *); +static int detailer_dofile_rsync(struct detailer *, char *, char *); +static int detailer_checkrcsattr(struct detailer *, struct coll *, char *, + struct fattr *, int); +int detailer_send_details(struct detailer *, struct coll *, char *, + char *, struct fattr *); void * detailer(void *arg) @@ -186,8 +202,13 @@ detailer_batch(struct detailer *d) } if (fixup->f_coll != coll) break; - error = proto_printf(wr, "Y %s %s %s\n", fixup->f_name, - coll->co_tag, coll->co_date); + if (coll->co_options & CO_CHECKOUTMODE) + error = proto_printf(wr, "Y %s %s %s\n", + fixup->f_name, coll->co_tag, coll->co_date); + else { + error = proto_printf(wr, "A %s\n", + fixup->f_name); + } if (error) return (DETAILER_ERR_WRITE); fixup = NULL; @@ -208,12 +229,14 @@ detailer_batch(struct detailer *d) static int detailer_coll(struct detailer *d, struct coll *coll, struct status *st) { + struct fattr *rcsattr; struct stream *rd, *wr; - char *cmd, *file, *line, *msg; - int error; + char *attr, *cmd, *file, *line, *msg, *path, *target; + int error, attic; rd = d->rd; wr = d->wr; + attic = 0; line = stream_getln(rd, NULL); if (line == NULL) return (DETAILER_ERR_READ); @@ -226,17 +249,84 @@ detailer_coll(struct detailer *d, struct /* Delete file. */ file = proto_get_ascii(&line); if (file == NULL || line != NULL) - return (DETAILER_ERR_PROTO); + return (DETAILER_ERR_PROTO); error = proto_printf(wr, "D %s\n", file); if (error) return (DETAILER_ERR_WRITE); break; + case 'I': + case 'i': + case 'j': + /* Directory operations. */ + file = proto_get_ascii(&line); + if (file == NULL || line != NULL) + return (DETAILER_ERR_PROTO); + error = proto_printf(wr, "%s %s\n", cmd, file); + if (error) + return (DETAILER_ERR_WRITE); + break; + case 'J': + /* Set directory attributes. */ + file = proto_get_ascii(&line); + attr = proto_get_ascii(&line); + if (file == NULL || line != NULL || attr == NULL) + return (DETAILER_ERR_PROTO); + error = proto_printf(wr, "%s %s %s\n", cmd, file, attr); + if (error) + return (DETAILER_ERR_WRITE); + break; + case 'H': + case 'h': + /* Create a hard link. */ + file = proto_get_ascii(&line); + target = proto_get_ascii(&line); + if (file == NULL || target == NULL) + return (DETAILER_ERR_PROTO); + error = proto_printf(wr, "%s %s %s\n", cmd, file, + target); + break; + case 't': + file = proto_get_ascii(&line); + attr = proto_get_ascii(&line); + if (file == NULL || attr == NULL || line != NULL) { + return (DETAILER_ERR_PROTO); + } + rcsattr = fattr_decode(attr); + if (rcsattr == NULL) { + return (DETAILER_ERR_PROTO); + } + error = detailer_checkrcsattr(d, coll, file, rcsattr, + 1); + break; + + case 'T': + file = proto_get_ascii(&line); + attr = proto_get_ascii(&line); + if (file == NULL || attr == NULL || line != NULL) + return (DETAILER_ERR_PROTO); + rcsattr = fattr_decode(attr); + if (rcsattr == NULL) + return (DETAILER_ERR_PROTO); + error = detailer_checkrcsattr(d, coll, file, rcsattr, + 0); + break; + case 'U': /* Add or update file. */ file = proto_get_ascii(&line); if (file == NULL || line != NULL) return (DETAILER_ERR_PROTO); - error = detailer_dofile(d, coll, st, file); + if (coll->co_options & CO_CHECKOUTMODE) { + error = detailer_dofile_co(d, coll, st, file); + } else { + path = cvspath(coll->co_prefix, file, 0); + rcsattr = fattr_frompath(path, FATTR_NOFOLLOW); + error = detailer_send_details(d, coll, file, + path, rcsattr); + if (rcsattr != NULL) + fattr_free(rcsattr); + free(path); + } if (error) return (error); break; @@ -261,14 +351,110 @@ detailer_coll(struct detailer *d, struct return (0); } +/* + * Tell the server to update a regular file. + */ static int -detailer_dofile(struct detailer *d, struct coll *coll, struct status *st, - char *file) +detailer_dofile_regular(struct detailer *d, char *name, char *path) { + struct stream *wr; + struct stat st; char md5[MD5_DIGEST_SIZE]; + int error; + + wr = d->wr; + error = stat(path, &st); + /* If we don't have it or it's unaccessible, we want it again. */ + if (error) { + proto_printf(wr, "A %s\n", name); + return (0); + } + + /* If not, we want the file to be updated. */ + error = MD5_File(path, md5); + if (error) { + lprintf(-1, "Error reading \"%s\"\n", name); + return (error); + } + error = proto_printf(wr, "R %s %O %s\n", name, st.st_size, md5); + if (error) + return (DETAILER_ERR_WRITE); + return (0); +} + +/* + * Tell the server to update a file with the rsync algorithm. + */ +static int +detailer_dofile_rsync(struct detailer *d, char *name, char *path) +{ + struct stream *wr; + struct rsyncfile *rf; + + wr = d->wr; + rf = rsync_open(path, 0, 1); + if (rf == NULL) { + /* Fallback if we fail in opening it. */ + proto_printf(wr, "A %s\n", name); + return (0); + } + proto_printf(wr, "r %s %z %z\n", name, rsync_filesize(rf), + rsync_blocksize(rf)); + /* Detail the blocks. */ + while (rsync_nextblock(rf) != 0) + proto_printf(wr, "%s %s\n", rsync_rsum(rf), rsync_blockmd5(rf)); + proto_printf(wr, ".\n"); + rsync_close(rf); + return (0); +} + +/* + * Tell the server to update an RCS file that we have, or send it if we don't. + */ +static int +detailer_dofile_rcs(struct detailer *d, struct coll *coll, char *name, + char *path) +{ + struct stream *wr; + struct fattr *fa; + struct rcsfile *rf; + int error; + + wr = d->wr; + path = atticpath(coll->co_prefix, name); + fa = fattr_frompath(path, FATTR_NOFOLLOW); + if (fa == NULL) { + /* We don't have it, so send request to get it. */ + error = proto_printf(wr, "A %s\n", name); + if (error) + return (DETAILER_ERR_WRITE); + free(path); + return (0); + } + + rf = rcsfile_frompath(path, name, coll->co_cvsroot, coll->co_tag, 1); + free(path); + if (rf == NULL) { + error = proto_printf(wr, "A %s\n", name); + if (error) + return (DETAILER_ERR_WRITE); + return (0); + } + /* Tell to update the RCS file. The client version details follow. */ + rcsfile_send_details(rf, wr); + rcsfile_free(rf); + fattr_free(fa); + return (0); +} + +static int +detailer_dofile_co(struct detailer *d, struct coll *coll, struct status *st, + char *file) +{ struct stream *wr; struct fattr *fa; struct statusrec *sr; + char md5[MD5_DIGEST_SIZE]; char *path; int error, ret; @@ -337,3 +523,81 @@ detailer_dofile(struct detailer *d, stru return (DETAILER_ERR_WRITE); return (0); } + +int +detailer_checkrcsattr(struct detailer *d, struct coll *coll, char *name, + struct fattr *server_attr, int attic) +{ + struct fattr *client_attr; + char *attr, *path; + int error; + + /* + * I don't think we can use the status file, since it only records file + * attributes in cvsmode. + */ + client_attr = NULL; + path = cvspath(coll->co_prefix, name, attic); + if (path == NULL) { + return (DETAILER_ERR_PROTO); + } + + if (access(path, F_OK) == 0 && + ((client_attr = fattr_frompath(path, FATTR_NOFOLLOW)) != NULL) && + fattr_equal(client_attr, server_attr)) { + attr = fattr_encode(client_attr, NULL, 0); + if (attic) { + error = proto_printf(d->wr, "l %s %s\n", name, attr); + } else { + error = proto_printf(d->wr, "L %s %s\n", name, attr); + } + free(attr); + free(path); + fattr_free(client_attr); + if (error) + return (DETAILER_ERR_WRITE); + return (0); + } + /* We don't have it, so tell the server to send it. */ + error = detailer_send_details(d, coll, name, path, client_attr); + fattr_free(client_attr); + free(path); + return (error); +} + +int +detailer_send_details(struct detailer *d, struct coll *coll, char *name, + char *path, struct fattr *fa) +{ + int error; + size_t len; + + /* + * Try to check if the file exists either live or dead to see if we can + * edit it and put it live or dead, rather than receiving the entire + * file. + */ + if (fa == NULL) { + path = atticpath(coll->co_prefix, name); + fa = fattr_frompath(path, FATTR_NOFOLLOW); + } + if (fa == NULL) { + error = proto_printf(d->wr, "A %s\n", name); + if (error) + return (DETAILER_ERR_WRITE); + } else if (fattr_type(fa) == FT_FILE) { + if (isrcs(name, &len) && !(coll->co_options & CO_NORCS)) { + detailer_dofile_rcs(d, coll, name, path); + } else if (!(coll->co_options & CO_NORSYNC) && + !globtree_test(coll->co_norsync, name)) { + detailer_dofile_rsync(d, name, path); + } else { + detailer_dofile_regular(d, name, path); + } + } else { + error = proto_printf(d->wr, "N %s\n", name); + if (error) + return (DETAILER_ERR_WRITE); + } + return (0); +} Modified: stable/7/contrib/csup/diff.c ============================================================================== --- stable/7/contrib/csup/diff.c Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/diff.c Tue Mar 17 06:54:41 2009 (r189918) @@ -26,9 +26,12 @@ * $FreeBSD$ */ +#include + #include #include #include +#include #include #include @@ -36,15 +39,20 @@ #include "keyword.h" #include "misc.h" #include "stream.h" +#include "queue.h" typedef long lineno_t; #define EC_ADD 0 #define EC_DEL 1 +#define MAXKEY LONG_MAX /* Editing command and state. */ struct editcmd { int cmd; + long key; + int havetext; + int offset; lineno_t where; lineno_t count; lineno_t lasta; @@ -55,20 +63,28 @@ struct editcmd { struct diffinfo *di; struct stream *orig; struct stream *dest; + LIST_ENTRY(editcmd) next; +}; + +struct diffstart { + LIST_HEAD(, editcmd) dhead; }; static int diff_geteditcmd(struct editcmd *, char *); static int diff_copyln(struct editcmd *, lineno_t); +static int diff_ignoreln(struct editcmd *, lineno_t); static void diff_write(struct editcmd *, void *, size_t); +static int diff_insert_edit(struct diffstart *, struct editcmd *); +static void diff_free(struct diffstart *); int diff_apply(struct stream *rd, struct stream *orig, struct stream *dest, - struct keyword *keyword, struct diffinfo *di) + struct keyword *keyword, struct diffinfo *di, int comode) { struct editcmd ec; lineno_t i; - char *line; size_t size; + char *line; int empty, error, noeol; memset(&ec, 0, sizeof(ec)); @@ -104,7 +120,7 @@ diff_apply(struct stream *rd, struct str line = stream_getln(rd, &size); if (line == NULL) return (-1); - if (line[0] == '.') { + if (comode && line[0] == '.') { line++; size--; } @@ -124,10 +140,10 @@ diff_apply(struct stream *rd, struct str } line = stream_getln(rd, NULL); } - if (line == NULL) + if (comode && line == NULL) return (-1); /* If we got ".+", there's no ending newline. */ - if (strcmp(line, ".+") == 0 && !empty) + if (comode && strcmp(line, ".+") == 0 && !empty) noeol = 1; ec.where = 0; while ((line = stream_getln(orig, &size)) != NULL) @@ -143,6 +159,198 @@ diff_apply(struct stream *rd, struct str return (0); } +/* + * Reverse a diff using the same algorithm as in cvsup. + */ +static int +diff_write_reverse(struct stream *dest, struct diffstart *ds) +{ + struct editcmd *ec, *nextec; + long editline, endline, firstoutputlinedeleted; + long num_added, num_deleted, startline; + int num; + + nextec = LIST_FIRST(&ds->dhead); + editline = 0; + num = 0; + while (nextec != NULL) { + ec = nextec; + nextec = LIST_NEXT(nextec, next); + if (nextec == NULL) + break; + num++; + num_deleted = 0; + if (ec->havetext) + num_deleted = ec->count; + num_added = num_deleted + nextec->offset - ec->offset; + if (num_deleted > 0) { + firstoutputlinedeleted = ec->key - num_deleted + 1; + stream_printf(dest, "d%ld %ld\n", firstoutputlinedeleted, + num_deleted); + if (num_added <= 0) + continue; + } + if (num_added > 0) { + stream_printf(dest, "a%ld %ld\n", ec->key, num_added); + startline = ec->key - num_deleted + 1 + ec->offset; + endline = startline + num_added - 1; + + /* Copy lines from original file. First ignore some. */ + ec->editline = editline; + diff_ignoreln(ec, startline - 1); + diff_copyln(ec, endline); + editline = ec->editline; + } + } + return (0); +} + +/* + * Insert a diff into the list sorted on key. Should perhaps use quicker + * algorithms than insertion sort, but do this for now. + */ +static int +diff_insert_edit(struct diffstart *ds, struct editcmd *ec) +{ + struct editcmd *curec; + + if (ec == NULL) + return (0); + + if (LIST_EMPTY(&ds->dhead)) { + LIST_INSERT_HEAD(&ds->dhead, ec, next); + return (0); + } + + /* Insertion sort based on key. */ + LIST_FOREACH(curec, &ds->dhead, next) { + if (ec->key < curec->key) { + LIST_INSERT_BEFORE(curec, ec, next); + return (0); + } + if (LIST_NEXT(curec, next) == NULL) + break; + } + /* Just insert it after. */ + LIST_INSERT_AFTER(curec, ec, next); + return (0); +} + +static void +diff_free(struct diffstart *ds) +{ + struct editcmd *ec; + + while(!LIST_EMPTY(&ds->dhead)) { + ec = LIST_FIRST(&ds->dhead); + LIST_REMOVE(ec, next); + free(ec); + } +} + +/* + * Write the reverse diff from the diff in rd, and original file into + * destination. This algorithm is the same as used in cvsup. + */ +int +diff_reverse(struct stream *rd, struct stream *orig, struct stream *dest, + struct keyword *keyword, struct diffinfo *di) +{ + struct diffstart ds; + struct editcmd ec, *addec, *delec; + lineno_t i; + char *line; + int error, offset; + + memset(&ec, 0, sizeof(ec)); + ec.orig = orig; + ec.dest = dest; + ec.keyword = keyword; + ec.di = di; + addec = NULL; + delec = NULL; + ec.havetext = 0; + offset = 0; + LIST_INIT(&ds.dhead); + + /* Start with next since we need it. */ + line = stream_getln(rd, NULL); + /* First we build up the list of diffs from input. */ + while (line != NULL) { + error = diff_geteditcmd(&ec, line); + if (error) + break; + if (ec.cmd == EC_ADD) { + addec = xmalloc(sizeof(struct editcmd)); + *addec = ec; + addec->havetext = 1; + /* Ignore the lines we was supposed to add. */ + for (i = 0; i < ec.count; i++) { + line = stream_getln(rd, NULL); + if (line == NULL) + return (-1); + } + + /* Get the next diff command if we have one. */ + addec->key = addec->where + addec->count - offset; + if (delec != NULL && + delec->key == addec->key - addec->count) { + delec->key = addec->key; + delec->havetext = addec->havetext; + delec->count = addec->count; + diff_insert_edit(&ds, delec); + free(addec); + delec = NULL; + addec = NULL; + } else { + if (delec != NULL) { + diff_insert_edit(&ds, delec); + } + delec = NULL; + addec->offset = offset; + diff_insert_edit(&ds, addec); + addec = NULL; + } + offset -= ec.count; + } else if (ec.cmd == EC_DEL) { + if (delec != NULL) { + /* Update offset to our next. */ + diff_insert_edit(&ds, delec); + delec = NULL; + } + delec = xmalloc(sizeof(struct editcmd)); + *delec = ec; + delec->key = delec->where - 1 - offset; + delec->offset = offset; + delec->count = 0; + delec->havetext = 0; + /* Important to use the count we had before reset.*/ + offset += ec.count; + } + line = stream_getln(rd, NULL); + } + + while (line != NULL) + line = stream_getln(rd, NULL); + if (delec != NULL) { + diff_insert_edit(&ds, delec); + delec = NULL; + } + + addec = xmalloc(sizeof(struct editcmd)); + /* Should be filesize, but we set it to max value. */ + addec->key = MAXKEY; + addec->offset = offset; + addec->havetext = 0; + addec->count = 0; + diff_insert_edit(&ds, addec); + addec = NULL; + diff_write_reverse(dest, &ds); + diff_free(&ds); + stream_flush(dest); + return (0); +} + /* Get an editing command from the diff. */ static int diff_geteditcmd(struct editcmd *ec, char *line) @@ -181,8 +389,8 @@ diff_geteditcmd(struct editcmd *ec, char static int diff_copyln(struct editcmd *ec, lineno_t to) { - char *line; size_t size; + char *line; while (ec->editline < to) { line = stream_getln(ec->orig, &size); @@ -194,12 +402,28 @@ diff_copyln(struct editcmd *ec, lineno_t return (0); } +/* Ignore lines from the original version of the file up to line "to". */ +static int +diff_ignoreln(struct editcmd *ec, lineno_t to) +{ + size_t size; + char *line; + + while (ec->editline < to) { + line = stream_getln(ec->orig, &size); + if (line == NULL) + return (-1); + ec->editline++; + } + return (0); +} + /* Write a new line to the file, expanding RCS keywords appropriately. */ static void diff_write(struct editcmd *ec, void *buf, size_t size) { - char *line, *newline; size_t newsize; + char *line, *newline; int ret; line = buf; Modified: stable/7/contrib/csup/diff.h ============================================================================== --- stable/7/contrib/csup/diff.h Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/diff.h Tue Mar 17 06:54:41 2009 (r189918) @@ -45,6 +45,8 @@ struct diffinfo { }; int diff_apply(struct stream *, struct stream *, struct stream *, - struct keyword *, struct diffinfo *); + struct keyword *, struct diffinfo *, int); +int diff_reverse(struct stream *, struct stream *, + struct stream *, struct keyword *, struct diffinfo *); #endif /* !_DIFF_H_ */ Modified: stable/7/contrib/csup/fattr.c ============================================================================== --- stable/7/contrib/csup/fattr.c Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/fattr.c Tue Mar 17 06:54:41 2009 (r189918) @@ -44,7 +44,7 @@ /* * Include the appropriate definition for the file attributes we support. * There are two different files: fattr_bsd.h for BSD-like systems that - * support the extended file flags à la chflags() and fattr_posix.h for + * support the extended file flags a la chflags() and fattr_posix.h for * bare POSIX systems that don't. */ #ifdef HAVE_FFLAGS @@ -449,7 +449,7 @@ fattr_encode(const struct fattr *fa, fat piece++; } if (mask & FA_DEV) { - vallen = snprintf(piece->val, sizeof(piece->val), "%lld", + vallen = snprintf(piece->val, sizeof(piece->val), "%llx", (long long)fa->dev); len += snprintf(piece->len, sizeof(piece->len), "%lld", (long long)vallen) + vallen + 1; @@ -534,6 +534,13 @@ fattr_getlinkcount(const struct fattr *f return (fa->linkcount); } +char * +fattr_getlinktarget(const struct fattr *fa) +{ + + return (fa->linktarget); +} + /* * Eat the specified attribute and put it in the file attribute * structure. Returns NULL on error, or a pointer to the next @@ -732,18 +739,28 @@ fattr_makenode(const struct fattr *fa, c mode_t modemask, mode; int error; + error = 0; + if (fa->mask & FA_OWNER && fa->mask & FA_GROUP) modemask = FA_SETIDMASK | FA_PERMMASK; else modemask = FA_PERMMASK; /* We only implement fattr_makenode() for dirs for now. */ - assert(fa->type == FT_DIRECTORY); if (fa->mask & FA_MODE) mode = fa->mode & modemask; else mode = 0700; - error = mkdir(path, mode); + + if (fa->type == FT_DIRECTORY) + error = mkdir(path, mode); + else if (fa->type == FT_SYMLINK) { + error = symlink(fa->linktarget, path); + } else if (fa->type == FT_CDEV) { + lprintf(-1, "Character devices not supported!\n"); + } else if (fa->type == FT_BDEV) { + lprintf(-1, "Block devices not supported!\n"); + } return (error); } @@ -823,6 +840,19 @@ fattr_install(struct fattr *fa, const ch } #endif + /* + * If it is changed from a file to a symlink, remove the file + * and create the symlink. + */ + if (inplace && (fa->type == FT_SYMLINK) && + (old->type == FT_FILE)) { + error = unlink(topath); + if (error) + goto bad; + error = symlink(fa->linktarget, topath); + if (error) + goto bad; + } /* Determine whether we need to remove the target first. */ if (!inplace && (fa->type == FT_DIRECTORY) != (old->type == FT_DIRECTORY)) { @@ -853,8 +883,9 @@ fattr_install(struct fattr *fa, const ch if (mask & FA_GROUP) gid = fa->gid; error = chown(frompath, uid, gid); - if (error) + if (error) { goto bad; + } } if (mask & FA_MODE) { newmode = fa->mode & modemask; @@ -901,6 +932,9 @@ fattr_equal(const struct fattr *fa1, con mask = fa1->mask & fa2->mask; if (fa1->type == FT_UNKNOWN || fa2->type == FT_UNKNOWN) return (0); + if (mask & FA_FILETYPE) + if (fa1->type != fa2->type) + return (0); if (mask & FA_MODTIME) if (fa1->modtime != fa2->modtime) return (0); @@ -936,3 +970,12 @@ fattr_equal(const struct fattr *fa1, con return (0); return (1); } + +/* + * Must have to get the correct filesize sendt by the server. + */ +off_t +fattr_filesize(const struct fattr *fa) +{ + return (fa->size); +} Modified: stable/7/contrib/csup/fattr.h ============================================================================== --- stable/7/contrib/csup/fattr.h Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/fattr.h Tue Mar 17 06:54:41 2009 (r189918) @@ -101,6 +101,7 @@ int fattr_type(const struct fattr *); void fattr_maskout(struct fattr *, int); int fattr_getmask(const struct fattr *); nlink_t fattr_getlinkcount(const struct fattr *); +char *fattr_getlinktarget(const struct fattr *); void fattr_umask(struct fattr *, mode_t); void fattr_merge(struct fattr *, const struct fattr *); void fattr_mergedefault(struct fattr *); @@ -111,5 +112,7 @@ int fattr_install(struct fattr *, cons int fattr_equal(const struct fattr *, const struct fattr *); void fattr_free(struct fattr *); int fattr_supported(int); +off_t fattr_filesize(const struct fattr *); + #endif /* !_FATTR_H_ */ Modified: stable/7/contrib/csup/keyword.c ============================================================================== --- stable/7/contrib/csup/keyword.c Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/keyword.c Tue Mar 17 06:54:41 2009 (r189918) @@ -152,6 +152,29 @@ keyword_decode_expand(const char *expand return (-1); } +const char * +keyword_encode_expand(int expand) +{ + + switch (expand) { + case EXPAND_DEFAULT: + return ("."); + case EXPAND_KEYVALUE: + return ("kv"); + case EXPAND_KEYVALUELOCKER: + return ("kvl"); + case EXPAND_KEY: + return ("k"); + case EXPAND_OLD: + return ("o"); + case EXPAND_BINARY: + return ("b"); + case EXPAND_VALUE: + return ("v"); + } + return (NULL); +} + void keyword_free(struct keyword *keyword) { Modified: stable/7/contrib/csup/keyword.h ============================================================================== --- stable/7/contrib/csup/keyword.h Tue Mar 17 05:57:43 2009 (r189917) +++ stable/7/contrib/csup/keyword.h Tue Mar 17 06:54:41 2009 (r189918) @@ -42,6 +42,7 @@ struct keyword; struct keyword *keyword_new(void); int keyword_decode_expand(const char *); +const char *keyword_encode_expand(int); int keyword_alias(struct keyword *, const char *, const char *); int keyword_enable(struct keyword *, const char *); int keyword_disable(struct keyword *, const char *); Copied: stable/7/contrib/csup/lex.rcs.c (from r186781, head/contrib/csup/lex.rcs.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/contrib/csup/lex.rcs.c Tue Mar 17 06:54:41 2009 (r189918, copy of r186781, head/contrib/csup/lex.rcs.c) @@ -0,0 +1,2094 @@ + +#line 3 "lex.rcs.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From rwatson at FreeBSD.org Tue Mar 17 03:15:50 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Tue Mar 17 03:16:07 2009 Subject: svn commit: r189920 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netinet Message-ID: <200903171015.n2HAFnDa092044@svn.freebsd.org> Author: rwatson Date: Tue Mar 17 10:15:49 2009 New Revision: 189920 URL: http://svn.freebsd.org/changeset/base/189920 Log: Merge r188992 from head to stable/7: In tcp_usr_shutdown() and tcp_usr_send(), I missed converting NULL checks for the tcpcb, previously used to detect complete disconnection, with INP_DROPPED checks. Correct that, preventing shutdown() from improperly generating a TCP segment with destination IP and port of 0.0.0.0:0. PR: kern/132050 Reported by: david gueluy Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netinet/tcp_usrreq.c Modified: stable/7/sys/netinet/tcp_usrreq.c ============================================================================== --- stable/7/sys/netinet/tcp_usrreq.c Tue Mar 17 09:50:40 2009 (r189919) +++ stable/7/sys/netinet/tcp_usrreq.c Tue Mar 17 10:15:49 2009 (r189920) @@ -712,7 +712,8 @@ tcp_usr_shutdown(struct socket *so) TCPDEBUG1(); socantsendmore(so); tcp_usrclosed(tp); - error = tcp_output_disconnect(tp); + if (!(inp->inp_vflag & INP_DROPPED)) + error = tcp_output_disconnect(tp); out: TCPDEBUG2(PRU_SHUTDOWN); @@ -844,7 +845,7 @@ tcp_usr_send(struct socket *so, int flag INP_INFO_WUNLOCK(&tcbinfo); headlocked = 0; } - if (tp != NULL) { + if (!(inp->inp_vflag & INP_DROPPED)) { if (flags & PRUS_MORETOCOME) tp->t_flags |= TF_MORETOCOME; error = tcp_output_send(tp); From kensmith at FreeBSD.org Tue Mar 17 07:18:01 2009 From: kensmith at FreeBSD.org (Ken Smith) Date: Tue Mar 17 07:18:12 2009 Subject: svn commit: r189929 - stable/7/sys/conf Message-ID: <200903171417.n2HEHxNa097104@svn.freebsd.org> Author: kensmith Date: Tue Mar 17 14:17:59 2009 New Revision: 189929 URL: http://svn.freebsd.org/changeset/base/189929 Log: We're a little less than a week from code freeze for the 7.2-REL release cycle. Give people a heads-up that there might be higher than usual developer activity during this period by starting to call it 7.2-PRERELEASE now. Modified: stable/7/sys/conf/newvers.sh Modified: stable/7/sys/conf/newvers.sh ============================================================================== --- stable/7/sys/conf/newvers.sh Tue Mar 17 13:07:11 2009 (r189928) +++ stable/7/sys/conf/newvers.sh Tue Mar 17 14:17:59 2009 (r189929) @@ -31,8 +31,8 @@ # $FreeBSD$ TYPE="FreeBSD" -REVISION="7.1" -BRANCH="STABLE" +REVISION="7.2" +BRANCH="PRERELEASE" if [ "X${BRANCH_OVERRIDE}" != "X" ]; then BRANCH=${BRANCH_OVERRIDE} fi From rafan at FreeBSD.org Tue Mar 17 07:29:27 2009 From: rafan at FreeBSD.org (Rong-En Fan) Date: Tue Mar 17 07:29:43 2009 Subject: svn commit: r189930 - stable/7/share/termcap Message-ID: <200903171429.n2HETPY4097506@svn.freebsd.org> Author: rafan Date: Tue Mar 17 14:29:25 2009 New Revision: 189930 URL: http://svn.freebsd.org/changeset/base/189930 Log: MFC r189216 (ahead original schedule due to the upcoming 7.2-RELEASE) - Remove kH (kp_kll) from screen. It has the identical key sequence as @7 (kp_end). As ncurses has the limitation that it returns the first matched key symbol, you can not use END in ncurses based program under screen (like ports/misc/mc). We did similar changes to xterm entry last year for exactly the same reason. PR: 132199 Submitted by: Timur I. Bakeyev Modified: stable/7/share/termcap/ (props changed) stable/7/share/termcap/termcap.src Modified: stable/7/share/termcap/termcap.src ============================================================================== --- stable/7/share/termcap/termcap.src Tue Mar 17 14:17:59 2009 (r189929) +++ stable/7/share/termcap/termcap.src Tue Mar 17 14:29:25 2009 (r189930) @@ -2771,7 +2771,7 @@ SC|screen|VT 100/ANSI X3.64 virtual term :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\ :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:\ :k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:F1=\E[23~:F2=\E[24~:\ - :kh=\E[1~:kI=\E[2~:kD=\E[3~:kH=\E[4~:@7=\E[4~:kP=\E[5~:\ + :kh=\E[1~:kI=\E[2~:kD=\E[3~:@7=\E[4~:kP=\E[5~:\ :kN=\E[6~:eA=\E(B\E)0:as=^N:ae=^O:ti=\E[?1049h:te=\E[?1049l:\ :vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l:\ :Co#8:pa#64:AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:AX:\ From marcel at FreeBSD.org Tue Mar 17 12:38:44 2009 From: marcel at FreeBSD.org (Marcel Moolenaar) Date: Tue Mar 17 12:38:57 2009 Subject: svn commit: r189935 - in stable/7/sys: . contrib/pf dev/ata dev/ath/ath_hal dev/cxgb geom geom/part modules/geom/geom_part modules/geom/geom_part/geom_part_ebr sys Message-ID: <200903171938.n2HJceUA004503@svn.freebsd.org> Author: marcel Date: Tue Mar 17 19:38:40 2009 New Revision: 189935 URL: http://svn.freebsd.org/changeset/base/189935 Log: Sync gpart with the trunk. This includes: o APM scheme supports Tivo Series 1 partitions (read only). o Bootcode support added to BSD scheme. o New EBR scheme to support Extended Boot Records (logical partitions). o PC98 scheme fixes (credits to nyan@) o VTOC8 scheme fixes (credits to marius@) Added: stable/7/sys/geom/part/g_part_ebr.c - copied, changed from r188354, head/sys/geom/part/g_part_ebr.c stable/7/sys/modules/geom/geom_part/geom_part_ebr/ - copied from r188354, head/sys/modules/geom/geom_part/geom_part_ebr/ Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ata/atapi-cd.c stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/geom/geom.h stable/7/sys/geom/geom_dev.c stable/7/sys/geom/geom_subr.c stable/7/sys/geom/part/g_part.c stable/7/sys/geom/part/g_part.h stable/7/sys/geom/part/g_part_apm.c stable/7/sys/geom/part/g_part_bsd.c stable/7/sys/geom/part/g_part_gpt.c stable/7/sys/geom/part/g_part_if.m stable/7/sys/geom/part/g_part_mbr.c stable/7/sys/geom/part/g_part_pc98.c stable/7/sys/geom/part/g_part_vtoc8.c stable/7/sys/modules/geom/geom_part/Makefile stable/7/sys/sys/disk.h stable/7/sys/sys/diskpc98.h Modified: stable/7/sys/dev/ata/atapi-cd.c ============================================================================== --- stable/7/sys/dev/ata/atapi-cd.c Tue Mar 17 19:37:47 2009 (r189934) +++ stable/7/sys/dev/ata/atapi-cd.c Tue Mar 17 19:38:40 2009 (r189935) @@ -218,7 +218,10 @@ acd_geom_ioctl(struct g_provider *pp, u_ case CDIOCRESET: acd_test_ready(dev); break; - + + case DIOCGPROVIDERALIAS: + break; + default: acd_read_toc(dev); acd_prevent_allow(dev, 1); Modified: stable/7/sys/geom/geom.h ============================================================================== --- stable/7/sys/geom/geom.h Tue Mar 17 19:37:47 2009 (r189934) +++ stable/7/sys/geom/geom.h Tue Mar 17 19:38:40 2009 (r189935) @@ -227,10 +227,11 @@ void g_error_provider(struct g_provider struct g_provider *g_provider_by_name(char const *arg); int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len); #define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v)) -int g_handleattr(struct bio *bp, const char *attribute, void *val, int len); +int g_handleattr(struct bio *bp, const char *attribute, const void *val, + int len); int g_handleattr_int(struct bio *bp, const char *attribute, int val); int g_handleattr_off_t(struct bio *bp, const char *attribute, off_t val); -int g_handleattr_str(struct bio *bp, const char *attribute, char *str); +int g_handleattr_str(struct bio *bp, const char *attribute, const char *str); struct g_consumer * g_new_consumer(struct g_geom *gp); struct g_geom * g_new_geomf(struct g_class *mp, const char *fmt, ...); struct g_provider * g_new_providerf(struct g_geom *gp, const char *fmt, ...); Modified: stable/7/sys/geom/geom_dev.c ============================================================================== --- stable/7/sys/geom/geom_dev.c Tue Mar 17 19:37:47 2009 (r189934) +++ stable/7/sys/geom/geom_dev.c Tue Mar 17 19:38:40 2009 (r189935) @@ -124,6 +124,7 @@ g_dev_taste(struct g_class *mp, struct g { struct g_geom *gp; struct g_consumer *cp; + char *alias; int error; struct cdev *dev; u_int unit; @@ -147,6 +148,17 @@ g_dev_taste(struct g_class *mp, struct g gp->softc = dev; dev->si_drv1 = gp; dev->si_drv2 = cp; + + g_topology_unlock(); + + alias = g_malloc(MAXPATHLEN, M_WAITOK | M_ZERO); + error = (pp->geom->ioctl == NULL) ? ENODEV : + pp->geom->ioctl(pp, DIOCGPROVIDERALIAS, alias, 0, curthread); + if (!error && alias[0] != '\0') + make_dev_alias(dev, "%s", alias); + g_free(alias); + + g_topology_lock(); return (gp); } Modified: stable/7/sys/geom/geom_subr.c ============================================================================== --- stable/7/sys/geom/geom_subr.c Tue Mar 17 19:37:47 2009 (r189934) +++ stable/7/sys/geom/geom_subr.c Tue Mar 17 19:38:40 2009 (r189935) @@ -856,14 +856,14 @@ g_handleattr_off_t(struct bio *bp, const } int -g_handleattr_str(struct bio *bp, const char *attribute, char *str) +g_handleattr_str(struct bio *bp, const char *attribute, const char *str) { return (g_handleattr(bp, attribute, str, 0)); } int -g_handleattr(struct bio *bp, const char *attribute, void *val, int len) +g_handleattr(struct bio *bp, const char *attribute, const void *val, int len) { int error = 0; @@ -880,12 +880,13 @@ g_handleattr(struct bio *bp, const char } } else if (bp->bio_length == len) { bcopy(val, bp->bio_data, len); - bp->bio_completed = len; } else { printf("%s: %s bio_length %jd len %d -> EFAULT\n", __func__, bp->bio_to->name, (intmax_t)bp->bio_length, len); error = EFAULT; } + if (error == 0) + bp->bio_completed = bp->bio_length; g_io_deliver(bp, error); return (1); } Modified: stable/7/sys/geom/part/g_part.c ============================================================================== --- stable/7/sys/geom/part/g_part.c Tue Mar 17 19:37:47 2009 (r189934) +++ stable/7/sys/geom/part/g_part.c Tue Mar 17 19:38:40 2009 (r189935) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2002, 2005-2008 Marcel Moolenaar + * Copyright (c) 2002, 2005-2009 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -86,6 +87,7 @@ static g_taste_t g_part_taste; static g_access_t g_part_access; static g_dumpconf_t g_part_dumpconf; +static g_ioctl_t g_part_ioctl; static g_orphan_t g_part_orphan; static g_spoiled_t g_part_spoiled; static g_start_t g_part_start; @@ -102,6 +104,7 @@ static struct g_class g_part_class = { /* Geom methods. */ .access = g_part_access, .dumpconf = g_part_dumpconf, + .ioctl = g_part_ioctl, .orphan = g_part_orphan, .spoiled = g_part_spoiled, .start = g_part_start, @@ -109,23 +112,6 @@ static struct g_class g_part_class = { DECLARE_GEOM_CLASS(g_part_class, g_part); -enum g_part_ctl { - G_PART_CTL_NONE, - G_PART_CTL_ADD, - G_PART_CTL_BOOTCODE, - G_PART_CTL_COMMIT, - G_PART_CTL_CREATE, - G_PART_CTL_DELETE, - G_PART_CTL_DESTROY, - G_PART_CTL_MODIFY, - G_PART_CTL_MOVE, - G_PART_CTL_RECOVER, - G_PART_CTL_RESIZE, - G_PART_CTL_SET, - G_PART_CTL_UNDO, - G_PART_CTL_UNSET -}; - /* * Support functions. */ @@ -181,10 +167,8 @@ g_part_geometry(struct g_part_table *tab u_int heads, sectors; int idx; - if (g_getattr("GEOM::fwsectors", cp, §ors) != 0 || - sectors < 1 || sectors > 63 || - g_getattr("GEOM::fwheads", cp, &heads) != 0 || - heads < 1 || heads > 255) { + if (g_getattr("GEOM::fwsectors", cp, §ors) != 0 || sectors == 0 || + g_getattr("GEOM::fwheads", cp, &heads) != 0 || heads == 0) { table->gpt_fixgeom = 0; table->gpt_heads = 0; table->gpt_sectors = 0; @@ -245,7 +229,8 @@ g_part_new_entry(struct g_part_table *ta LIST_INSERT_HEAD(&table->gpt_entry, entry, gpe_entry); else LIST_INSERT_AFTER(last, entry, gpe_entry); - } + } else + entry->gpe_offset = 0; entry->gpe_start = start; entry->gpe_end = end; return (entry); @@ -258,11 +243,14 @@ g_part_new_provider(struct g_geom *gp, s char buf[32]; struct g_consumer *cp; struct g_provider *pp; + off_t offset; cp = LIST_FIRST(&gp->consumer); pp = cp->provider; - entry->gpe_offset = entry->gpe_start * pp->sectorsize; + offset = entry->gpe_start * pp->sectorsize; + if (entry->gpe_offset < offset) + entry->gpe_offset = offset; if (entry->gpe_pp == NULL) { entry->gpe_pp = g_new_providerf(gp, "%s%s", gp->name, @@ -272,6 +260,7 @@ g_part_new_provider(struct g_geom *gp, s entry->gpe_pp->index = entry->gpe_index - 1; /* index is 1-based. */ entry->gpe_pp->mediasize = (entry->gpe_end - entry->gpe_start + 1) * pp->sectorsize; + entry->gpe_pp->mediasize -= entry->gpe_offset - offset; entry->gpe_pp->sectorsize = pp->sectorsize; entry->gpe_pp->flags = pp->flags & G_PF_CANDELETE; if (pp->stripesize > 0) { @@ -534,8 +523,8 @@ g_part_ctl_bootcode(struct gctl_req *req error = ENODEV; goto fail; } - if (gpp->gpp_codesize != sz) { - error = EINVAL; + if (gpp->gpp_codesize > sz) { + error = EFBIG; goto fail; } @@ -579,6 +568,8 @@ g_part_ctl_commit(struct gctl_req *req, return (EPERM); } + g_topology_unlock(); + cp = LIST_FIRST(&gp->consumer); if ((table->gpt_smhead | table->gpt_smtail) != 0) { pp = cp->provider; @@ -607,6 +598,7 @@ g_part_ctl_commit(struct gctl_req *req, } if (table->gpt_scheme == &g_part_null_scheme) { + g_topology_lock(); g_access(cp, -1, -1, -1); g_part_wither(gp, ENXIO); return (0); @@ -627,10 +619,13 @@ g_part_ctl_commit(struct gctl_req *req, } table->gpt_created = 0; table->gpt_opened = 0; + + g_topology_lock(); g_access(cp, -1, -1, -1); return (0); fail: + g_topology_lock(); gctl_error(req, "%d", error); return (error); } @@ -714,14 +709,6 @@ g_part_ctl_create(struct gctl_req *req, error = g_getattr("PART::depth", cp, &attr); table->gpt_depth = (!error) ? attr + 1 : 0; - /* If we're nested, get the absolute sector offset on disk. */ - if (table->gpt_depth) { - error = g_getattr("PART::offset", cp, &attr); - if (error) - goto fail; - table->gpt_offset = attr; - } - /* * Synthesize a disk geometry. Some partitioning schemes * depend on it and since some file systems need it even @@ -1345,7 +1332,7 @@ g_part_ctlreq(struct gctl_req *req, stru /* Obtain permissions if possible/necessary. */ close_on_error = 0; - table = NULL; /* Suppress uninit. warning. */ + table = NULL; if (modifies && (gpp.gpp_parms & G_PART_PARM_GEOM)) { table = gpp.gpp_geom->softc; if (table != NULL && !table->gpt_opened) { @@ -1361,7 +1348,16 @@ g_part_ctlreq(struct gctl_req *req, stru } } - error = EDOOFUS; /* Prevent bogus uninit. warning. */ + /* Allow the scheme to check or modify the parameters. */ + if (table != NULL) { + error = G_PART_PRECHECK(table, ctlreq, &gpp); + if (error) { + gctl_error(req, "%d pre-check failed", error); + goto out; + } + } else + error = EDOOFUS; /* Prevent bogus uninit. warning. */ + switch (ctlreq) { case G_PART_CTL_NONE: panic("%s", __func__); @@ -1417,6 +1413,7 @@ g_part_ctlreq(struct gctl_req *req, stru } } + out: if (error && close_on_error) { g_access(LIST_FIRST(&gpp.gpp_geom->consumer), -1, -1, -1); table->gpt_opened = 0; @@ -1442,6 +1439,7 @@ g_part_taste(struct g_class *mp, struct struct g_geom *gp; struct g_part_entry *entry; struct g_part_table *table; + struct root_hold_token *rht; int attr, depth; int error; @@ -1463,6 +1461,7 @@ g_part_taste(struct g_class *mp, struct return (NULL); } + rht = root_mount_hold(mp->name); g_topology_unlock(); /* @@ -1489,14 +1488,6 @@ g_part_taste(struct g_class *mp, struct table = gp->softc; - /* If we're nested, get the absolute sector offset on disk. */ - if (table->gpt_depth) { - error = g_getattr("PART::offset", cp, &attr); - if (error) - goto fail; - table->gpt_offset = attr; - } - /* * Synthesize a disk geometry. Some partitioning schemes * depend on it and since some file systems need it even @@ -1515,11 +1506,13 @@ g_part_taste(struct g_class *mp, struct g_part_new_provider(gp, table, entry); } + root_mount_rel(rht); g_access(cp, -1, 0, 0); return (gp); fail: g_topology_lock(); + root_mount_rel(rht); g_access(cp, -1, 0, 0); g_part_wither(gp, error); return (NULL); @@ -1576,6 +1569,10 @@ g_part_dumpconf(struct sbuf *sb, const c entry = pp->private; if (entry == NULL) return; + sbuf_printf(sb, "%s%ju\n", indent, + (uintmax_t)entry->gpe_start); + sbuf_printf(sb, "%s%ju\n", indent, + (uintmax_t)entry->gpe_end); sbuf_printf(sb, "%s%u\n", indent, entry->gpe_index); sbuf_printf(sb, "%s%s\n", indent, @@ -1602,6 +1599,31 @@ g_part_dumpconf(struct sbuf *sb, const c } } +static int +g_part_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, + struct thread *td) +{ + struct g_geom *gp; + struct g_part_table *table; + struct g_part_entry *entry; + int error; + + gp = pp->geom; + table = gp->softc; + entry = pp->private; + + switch (cmd) { + case DIOCGPROVIDERALIAS: + error = G_PART_DEVALIAS(table, entry, data, MAXPATHLEN); + break; + default: + error = ENOTTY; + break; + } + + return (error); +} + static void g_part_orphan(struct g_consumer *cp) { @@ -1681,8 +1703,8 @@ g_part_start(struct bio *bp) return; if (g_handleattr_int(bp, "PART::depth", table->gpt_depth)) return; - if (g_handleattr_int(bp, "PART::offset", - table->gpt_offset + entry->gpe_start)) + if (g_handleattr_str(bp, "PART::scheme", + table->gpt_scheme->name)) return; if (!strcmp("GEOM::kerneldump", bp->bio_attribute)) { /* @@ -1722,7 +1744,7 @@ static void g_part_init(struct g_class *mp) { - TAILQ_INSERT_TAIL(&g_part_schemes, &g_part_null_scheme, scheme_list); + TAILQ_INSERT_HEAD(&g_part_schemes, &g_part_null_scheme, scheme_list); } static void Modified: stable/7/sys/geom/part/g_part.h ============================================================================== --- stable/7/sys/geom/part/g_part.h Tue Mar 17 19:37:47 2009 (r189934) +++ stable/7/sys/geom/part/g_part.h Tue Mar 17 19:38:40 2009 (r189935) @@ -103,13 +103,6 @@ struct g_part_table { */ uint32_t gpt_sectors; uint32_t gpt_heads; - /* - * gpt_offset holds the absolute block address of the scheme - * on disk. Some partitioning schemes (historically) use - * absolute addressing. Relative addresses are obtained by - * subtracting gpt_offset from the absolute addresses. - */ - uint64_t gpt_offset; int gpt_depth; /* Sub-partitioning level. */ int gpt_isleaf:1; /* Cannot be sub-partitioned. */ @@ -122,6 +115,23 @@ struct g_part_table { struct g_part_entry *g_part_new_entry(struct g_part_table *, int, quad_t, quad_t); +enum g_part_ctl { + G_PART_CTL_NONE, + G_PART_CTL_ADD, + G_PART_CTL_BOOTCODE, + G_PART_CTL_COMMIT, + G_PART_CTL_CREATE, + G_PART_CTL_DELETE, + G_PART_CTL_DESTROY, + G_PART_CTL_MODIFY, + G_PART_CTL_MOVE, + G_PART_CTL_RECOVER, + G_PART_CTL_RESIZE, + G_PART_CTL_SET, + G_PART_CTL_UNDO, + G_PART_CTL_UNSET +}; + /* G_PART ctlreq parameters. */ #define G_PART_PARM_ENTRIES 0x0001 #define G_PART_PARM_FLAGS 0x0002 Modified: stable/7/sys/geom/part/g_part_apm.c ============================================================================== --- stable/7/sys/geom/part/g_part_apm.c Tue Mar 17 19:37:47 2009 (r189934) +++ stable/7/sys/geom/part/g_part_apm.c Tue Mar 17 19:38:40 2009 (r189935) @@ -50,6 +50,7 @@ struct g_part_apm_table { struct g_part_table base; struct apm_ddr ddr; struct apm_ent self; + int tivo_series1; }; struct g_part_apm_entry { @@ -61,12 +62,12 @@ static int g_part_apm_add(struct g_part_ struct g_part_parms *); static int g_part_apm_create(struct g_part_table *, struct g_part_parms *); static int g_part_apm_destroy(struct g_part_table *, struct g_part_parms *); -static int g_part_apm_dumpconf(struct g_part_table *, struct g_part_entry *, +static void g_part_apm_dumpconf(struct g_part_table *, struct g_part_entry *, struct sbuf *, const char *); static int g_part_apm_dumpto(struct g_part_table *, struct g_part_entry *); static int g_part_apm_modify(struct g_part_table *, struct g_part_entry *, struct g_part_parms *); -static char *g_part_apm_name(struct g_part_table *, struct g_part_entry *, +static const char *g_part_apm_name(struct g_part_table *, struct g_part_entry *, char *, size_t); static int g_part_apm_probe(struct g_part_table *, struct g_consumer *); static int g_part_apm_read(struct g_part_table *, struct g_consumer *); @@ -99,6 +100,19 @@ static struct g_part_scheme g_part_apm_s }; G_PART_SCHEME_DECLARE(g_part_apm); +static void +swab(char *buf, size_t bufsz) +{ + int i; + char ch; + + for (i = 0; i < bufsz; i += 2) { + ch = buf[i]; + buf[i] = buf[i + 1]; + buf[i + 1] = ch; + } +} + static int apm_parse_type(const char *type, char *buf, size_t bufsz) { @@ -143,7 +157,8 @@ apm_parse_type(const char *type, char *b } static int -apm_read_ent(struct g_consumer *cp, uint32_t blk, struct apm_ent *ent) +apm_read_ent(struct g_consumer *cp, uint32_t blk, struct apm_ent *ent, + int tivo_series1) { struct g_provider *pp; char *buf; @@ -153,6 +168,8 @@ apm_read_ent(struct g_consumer *cp, uint buf = g_read_data(cp, pp->sectorsize * blk, pp->sectorsize, &error); if (buf == NULL) return (error); + if (tivo_series1) + swab(buf, pp->sectorsize); ent->ent_sig = be16dec(buf); ent->ent_pmblkcnt = be32dec(buf + 4); ent->ent_start = be32dec(buf + 8); @@ -231,7 +248,7 @@ g_part_apm_destroy(struct g_part_table * return (0); } -static int +static void g_part_apm_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry, struct sbuf *sb, const char *indent) { @@ -256,7 +273,6 @@ g_part_apm_dumpconf(struct g_part_table } else { /* confxml: scheme information */ } - return (0); } static int @@ -294,7 +310,7 @@ g_part_apm_modify(struct g_part_table *b return (0); } -static char * +static const char * g_part_apm_name(struct g_part_table *table, struct g_part_entry *baseentry, char *buf, size_t bufsz) { @@ -316,6 +332,7 @@ g_part_apm_probe(struct g_part_table *ba return (ENXIO); table = (struct g_part_apm_table *)basetable; + table->tivo_series1 = 0; pp = cp->provider; /* Sanity-check the provider. */ @@ -326,17 +343,35 @@ g_part_apm_probe(struct g_part_table *ba buf = g_read_data(cp, 0L, pp->sectorsize, &error); if (buf == NULL) return (error); - table->ddr.ddr_sig = be16dec(buf); - table->ddr.ddr_blksize = be16dec(buf + 2); - table->ddr.ddr_blkcount = be32dec(buf + 4); - g_free(buf); - if (table->ddr.ddr_sig != APM_DDR_SIG) - return (ENXIO); - if (table->ddr.ddr_blksize != pp->sectorsize) - return (ENXIO); + if (be16dec(buf) == be16toh(APM_DDR_SIG)) { + /* Normal Apple DDR */ + table->ddr.ddr_sig = be16dec(buf); + table->ddr.ddr_blksize = be16dec(buf + 2); + table->ddr.ddr_blkcount = be32dec(buf + 4); + g_free(buf); + if (table->ddr.ddr_blksize != pp->sectorsize) + return (ENXIO); + } else { + /* + * Check for Tivo drives, which have no DDR and a different + * signature. Those whose first two bytes are 14 92 are + * Series 2 drives, and aren't supported. Those that start + * with 92 14 are series 1 drives and are supported. + */ + if (be16dec(buf) != 0x9214) { + /* If this is 0x1492 it could be a series 2 drive */ + g_free(buf); + return (ENXIO); + } + table->ddr.ddr_sig = APM_DDR_SIG; /* XXX */ + table->ddr.ddr_blksize = pp->sectorsize; /* XXX */ + table->ddr.ddr_blkcount = pp->mediasize / pp->sectorsize;/* XXX */ + table->tivo_series1 = 1; + g_free(buf); + } /* Check that there's a Partition Map. */ - error = apm_read_ent(cp, 1, &table->self); + error = apm_read_ent(cp, 1, &table->self, table->tivo_series1); if (error) return (error); if (table->self.ent_sig != APM_ENT_SIG) @@ -363,7 +398,7 @@ g_part_apm_read(struct g_part_table *bas basetable->gpt_entries = table->self.ent_pmblkcnt - 1; for (index = table->self.ent_pmblkcnt - 1; index > 0; index--) { - error = apm_read_ent(cp, index + 1, &ent); + error = apm_read_ent(cp, index + 1, &ent, table->tivo_series1); if (error) continue; if (!strcmp(ent.ent_type, APM_ENT_TYPE_UNUSED)) @@ -413,6 +448,11 @@ g_part_apm_write(struct g_part_table *ba int error, index; table = (struct g_part_apm_table *)basetable; + /* + * Tivo Series 1 disk partitions are currently read-only. + */ + if (table->tivo_series1) + return (EOPNOTSUPP); bzero(buf, sizeof(buf)); /* Write the DDR and 'self' entry only when we're newly created. */ Modified: stable/7/sys/geom/part/g_part_bsd.c ============================================================================== --- stable/7/sys/geom/part/g_part_bsd.c Tue Mar 17 19:37:47 2009 (r189934) +++ stable/7/sys/geom/part/g_part_bsd.c Tue Mar 17 19:38:40 2009 (r189935) @@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$"); struct g_part_bsd_table { struct g_part_table base; - u_char *label; + u_char *bbarea; uint32_t offset; }; @@ -58,14 +58,15 @@ struct g_part_bsd_entry { static int g_part_bsd_add(struct g_part_table *, struct g_part_entry *, struct g_part_parms *); +static int g_part_bsd_bootcode(struct g_part_table *, struct g_part_parms *); static int g_part_bsd_create(struct g_part_table *, struct g_part_parms *); static int g_part_bsd_destroy(struct g_part_table *, struct g_part_parms *); -static int g_part_bsd_dumpconf(struct g_part_table *, struct g_part_entry *, +static void g_part_bsd_dumpconf(struct g_part_table *, struct g_part_entry *, struct sbuf *, const char *); static int g_part_bsd_dumpto(struct g_part_table *, struct g_part_entry *); static int g_part_bsd_modify(struct g_part_table *, struct g_part_entry *, struct g_part_parms *); -static char *g_part_bsd_name(struct g_part_table *, struct g_part_entry *, +static const char *g_part_bsd_name(struct g_part_table *, struct g_part_entry *, char *, size_t); static int g_part_bsd_probe(struct g_part_table *, struct g_consumer *); static int g_part_bsd_read(struct g_part_table *, struct g_consumer *); @@ -75,6 +76,7 @@ static int g_part_bsd_write(struct g_par static kobj_method_t g_part_bsd_methods[] = { KOBJMETHOD(g_part_add, g_part_bsd_add), + KOBJMETHOD(g_part_bootcode, g_part_bsd_bootcode), KOBJMETHOD(g_part_create, g_part_bsd_create), KOBJMETHOD(g_part_destroy, g_part_bsd_destroy), KOBJMETHOD(g_part_dumpconf, g_part_bsd_dumpconf), @@ -95,6 +97,7 @@ static struct g_part_scheme g_part_bsd_s .gps_entrysz = sizeof(struct g_part_bsd_entry), .gps_minent = 8, .gps_maxent = 20, + .gps_bootcodesz = BBSIZE, }; G_PART_SCHEME_DECLARE(g_part_bsd); @@ -157,6 +160,30 @@ g_part_bsd_add(struct g_part_table *base } static int +g_part_bsd_bootcode(struct g_part_table *basetable, struct g_part_parms *gpp) +{ + struct g_part_bsd_table *table; + const u_char *codeptr; + size_t hdsz, tlsz; + size_t codesz, tlofs; + + hdsz = 512; + tlofs = hdsz + 148 + basetable->gpt_entries * 16; + tlsz = BBSIZE - tlofs; + table = (struct g_part_bsd_table *)basetable; + bzero(table->bbarea, hdsz); + bzero(table->bbarea + tlofs, tlsz); + codeptr = gpp->gpp_codeptr; + codesz = MIN(hdsz, gpp->gpp_codesize); + if (codesz > 0) + bcopy(codeptr, table->bbarea, codesz); + codesz = MIN(tlsz, gpp->gpp_codesize - tlofs); + if (codesz > 0) + bcopy(codeptr + tlofs, table->bbarea + tlofs, codesz); + return (0); +} + +static int g_part_bsd_create(struct g_part_table *basetable, struct g_part_parms *gpp) { struct g_consumer *cp; @@ -173,13 +200,16 @@ g_part_bsd_create(struct g_part_table *b if (pp->sectorsize < sizeof(struct disklabel)) return (ENOSPC); + if (BBSIZE % pp->sectorsize) + return (ENOTBLK); msize = pp->mediasize / pp->sectorsize; secpercyl = basetable->gpt_sectors * basetable->gpt_heads; ncyls = msize / secpercyl; table = (struct g_part_bsd_table *)basetable; - ptr = table->label = g_malloc(pp->sectorsize, M_WAITOK | M_ZERO); + table->bbarea = g_malloc(BBSIZE, M_WAITOK | M_ZERO); + ptr = table->bbarea + pp->sectorsize; le32enc(ptr + 0, DISKMAGIC); /* d_magic */ le32enc(ptr + 40, pp->sectorsize); /* d_secsize */ @@ -216,7 +246,7 @@ g_part_bsd_destroy(struct g_part_table * return (0); } -static int +static void g_part_bsd_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry, struct sbuf *sb, const char *indent) { @@ -233,7 +263,6 @@ g_part_bsd_dumpconf(struct g_part_table } else { /* confxml: scheme information */ } - return (0); } static int @@ -241,9 +270,10 @@ g_part_bsd_dumpto(struct g_part_table *t { struct g_part_bsd_entry *entry; - /* Allow dumping to a swap partition only. */ + /* Allow dumping to a swap partition or an unused partition. */ entry = (struct g_part_bsd_entry *)baseentry; - return ((entry->part.p_fstype == FS_SWAP) ? 1 : 0); + return ((entry->part.p_fstype == FS_UNUSED || + entry->part.p_fstype == FS_SWAP) ? 1 : 0); } static int @@ -261,7 +291,7 @@ g_part_bsd_modify(struct g_part_table *b return (0); } -static char * +static const char * g_part_bsd_name(struct g_part_table *table, struct g_part_entry *baseentry, char *buf, size_t bufsz) { @@ -284,6 +314,8 @@ g_part_bsd_probe(struct g_part_table *ta if (pp->sectorsize < sizeof(struct disklabel) || pp->mediasize < BBSIZE) return (ENOSPC); + if (BBSIZE % pp->sectorsize) + return (ENOTBLK); /* Check that there's a disklabel. */ buf = g_read_data(cp, pp->sectorsize, pp->sectorsize, &error); @@ -313,16 +345,16 @@ g_part_bsd_read(struct g_part_table *bas table = (struct g_part_bsd_table *)basetable; msize = pp->mediasize / pp->sectorsize; - buf = g_read_data(cp, pp->sectorsize, pp->sectorsize, &error); - if (buf == NULL) + table->bbarea = g_read_data(cp, 0, BBSIZE, &error); + if (table->bbarea == NULL) return (error); - table->label = buf; + buf = table->bbarea + pp->sectorsize; if (le32dec(buf + 40) != pp->sectorsize) goto invalid_label; sectors = le32dec(buf + 44); - if (sectors < 1 || sectors > 63) + if (sectors < 1 || sectors > 255) goto invalid_label; if (sectors != basetable->gpt_sectors && !basetable->gpt_fixgeom) { g_part_geometry_heads(msize, sectors, &chs, &heads); @@ -341,8 +373,13 @@ g_part_bsd_read(struct g_part_table *bas printf("GEOM: %s: geometry does not match label.\n", pp->name); chs = le32dec(buf + 60); - if (chs < 1 || chs > msize) + if (chs < 1) goto invalid_label; + /* Fix-up a sysinstall bug. */ + if (chs > msize) { + chs = msize; + le32enc(buf + 60, msize); + } if (chs != msize) printf("GEOM: %s: media size does not match label.\n", pp->name); @@ -367,8 +404,6 @@ g_part_bsd_read(struct g_part_table *bas part.p_cpg = le16dec(p + 14); if (part.p_size == 0) continue; - if (part.p_fstype == FS_UNUSED && index != RAW_PART) - continue; if (part.p_offset < table->offset) continue; baseentry = g_part_new_entry(basetable, index + 1, @@ -376,7 +411,7 @@ g_part_bsd_read(struct g_part_table *bas part.p_offset - table->offset + part.p_size - 1); entry = (struct g_part_bsd_entry *)baseentry; entry->part = part; - if (part.p_fstype == FS_UNUSED) + if (index == RAW_PART) baseentry->gpe_internal = 1; } @@ -384,7 +419,7 @@ g_part_bsd_read(struct g_part_table *bas invalid_label: printf("GEOM: %s: invalid disklabel.\n", pp->name); - g_free(table->label); + g_free(table->bbarea); return (EINVAL); } @@ -417,14 +452,15 @@ g_part_bsd_write(struct g_part_table *ba struct g_part_bsd_entry *entry; struct g_part_bsd_table *table; uint16_t sum; - u_char *p, *pe; + u_char *label, *p, *pe; int error, index; pp = cp->provider; table = (struct g_part_bsd_table *)basetable; baseentry = LIST_FIRST(&basetable->gpt_entry); + label = table->bbarea + pp->sectorsize; for (index = 1; index <= basetable->gpt_entries; index++) { - p = table->label + 148 + (index - 1) * 16; + p = label + 148 + (index - 1) * 16; entry = (baseentry != NULL && index == baseentry->gpe_index) ? (struct g_part_bsd_entry *)baseentry : NULL; if (entry != NULL && !baseentry->gpe_deleted) { @@ -442,13 +478,13 @@ g_part_bsd_write(struct g_part_table *ba } /* Calculate checksum. */ - le16enc(table->label + 136, 0); - pe = table->label + 148 + basetable->gpt_entries * 16; + le16enc(label + 136, 0); + pe = label + 148 + basetable->gpt_entries * 16; sum = 0; - for (p = table->label; p < pe; p += 2) + for (p = label; p < pe; p += 2) sum ^= le16dec(p); - le16enc(table->label + 136, sum); + le16enc(label + 136, sum); - error = g_write_data(cp, pp->sectorsize, table->label, pp->sectorsize); + error = g_write_data(cp, 0, table->bbarea, BBSIZE); return (error); } Copied and modified: stable/7/sys/geom/part/g_part_ebr.c (from r188354, head/sys/geom/part/g_part_ebr.c) ============================================================================== --- head/sys/geom/part/g_part_ebr.c Sun Feb 8 23:51:44 2009 (r188354, copy source) +++ stable/7/sys/geom/part/g_part_ebr.c Tue Mar 17 19:38:40 2009 (r189935) @@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -55,12 +54,15 @@ struct g_part_ebr_table { struct g_part_ebr_entry { struct g_part_entry base; struct dos_partition ent; + int alias; }; static int g_part_ebr_add(struct g_part_table *, struct g_part_entry *, struct g_part_parms *); static int g_part_ebr_create(struct g_part_table *, struct g_part_parms *); static int g_part_ebr_destroy(struct g_part_table *, struct g_part_parms *); +static int g_part_ebr_devalias(struct g_part_table *, struct g_part_entry *, + char *, size_t); static void g_part_ebr_dumpconf(struct g_part_table *, struct g_part_entry *, struct sbuf *, const char *); static int g_part_ebr_dumpto(struct g_part_table *, struct g_part_entry *); @@ -68,6 +70,8 @@ static int g_part_ebr_modify(struct g_pa struct g_part_parms *); static const char *g_part_ebr_name(struct g_part_table *, struct g_part_entry *, char *, size_t); +static int g_part_ebr_precheck(struct g_part_table *, enum g_part_ctl, + struct g_part_parms *); static int g_part_ebr_probe(struct g_part_table *, struct g_consumer *); static int g_part_ebr_read(struct g_part_table *, struct g_consumer *); static int g_part_ebr_setunset(struct g_part_table *, struct g_part_entry *, @@ -80,10 +84,12 @@ static kobj_method_t g_part_ebr_methods[ KOBJMETHOD(g_part_add, g_part_ebr_add), KOBJMETHOD(g_part_create, g_part_ebr_create), KOBJMETHOD(g_part_destroy, g_part_ebr_destroy), + KOBJMETHOD(g_part_devalias, g_part_ebr_devalias), KOBJMETHOD(g_part_dumpconf, g_part_ebr_dumpconf), KOBJMETHOD(g_part_dumpto, g_part_ebr_dumpto), KOBJMETHOD(g_part_modify, g_part_ebr_modify), KOBJMETHOD(g_part_name, g_part_ebr_name), + KOBJMETHOD(g_part_precheck, g_part_ebr_precheck), KOBJMETHOD(g_part_probe, g_part_ebr_probe), KOBJMETHOD(g_part_read, g_part_ebr_read), KOBJMETHOD(g_part_setunset, g_part_ebr_setunset), @@ -102,6 +108,9 @@ static struct g_part_scheme g_part_ebr_s }; G_PART_SCHEME_DECLARE(g_part_ebr); +static void ebr_set_chs(struct g_part_table *, uint32_t, u_char *, u_char *, + u_char *); + static void ebr_entry_decode(const char *p, struct dos_partition *ent) { @@ -117,19 +126,142 @@ ebr_entry_decode(const char *p, struct d ent->dp_size = le32dec(p + 12); } +static void +ebr_entry_link(struct g_part_table *table, uint32_t start, uint32_t end, + u_char *buf) +{ + + buf[0] = 0 /* dp_flag */; + ebr_set_chs(table, start, &buf[3] /* dp_scyl */, &buf[1] /* dp_shd */, + &buf[2] /* dp_ssect */); + buf[4] = 5 /* dp_typ */; + ebr_set_chs(table, end, &buf[7] /* dp_ecyl */, &buf[5] /* dp_ehd */, + &buf[6] /* dp_esect */); + le32enc(buf + 8, start); + le32enc(buf + 12, end - start + 1); +} + +static int +ebr_parse_type(const char *type, u_char *dp_typ) +{ + const char *alias; + char *endp; + long lt; + + if (type[0] == '!') { + lt = strtol(type + 1, &endp, 0); + if (type[1] == '\0' || *endp != '\0' || lt <= 0 || lt >= 256) + return (EINVAL); + *dp_typ = (u_char)lt; + return (0); + } + alias = g_part_alias_name(G_PART_ALIAS_FREEBSD); + if (!strcasecmp(type, alias)) { + *dp_typ = DOSPTYP_386BSD; + return (0); + } + return (EINVAL); +} + +static void +ebr_set_chs(struct g_part_table *table, uint32_t lba, u_char *cylp, u_char *hdp, + u_char *secp) +{ + uint32_t cyl, hd, sec; + + sec = lba % table->gpt_sectors + 1; + lba /= table->gpt_sectors; + hd = lba % table->gpt_heads; + lba /= table->gpt_heads; + cyl = lba; + if (cyl > 1023) + sec = hd = cyl = ~0; + + *cylp = cyl & 0xff; + *hdp = hd & 0xff; + *secp = (sec & 0x3f) | ((cyl >> 2) & 0xc0); +} + static int g_part_ebr_add(struct g_part_table *basetable, struct g_part_entry *baseentry, struct g_part_parms *gpp) { + struct g_geom *gp; + struct g_provider *pp; + struct g_part_ebr_entry *entry; + uint32_t start, size, sectors; - return (ENOSYS); + if (gpp->gpp_parms & G_PART_PARM_LABEL) + return (EINVAL); + + gp = basetable->gpt_gp; + pp = LIST_FIRST(&gp->consumer)->provider; + sectors = basetable->gpt_sectors; + + entry = (struct g_part_ebr_entry *)baseentry; + + start = gpp->gpp_start; + size = gpp->gpp_size; + if (size < 2 * sectors) + return (EINVAL); + if (start % sectors) { + size = size - sectors + (start % sectors); + start = start - (start % sectors) + sectors; + } + if (size % sectors) + size = size - (size % sectors); + if (size < 2 * sectors) + return (EINVAL); + + if (baseentry->gpe_deleted) + bzero(&entry->ent, sizeof(entry->ent)); + + KASSERT(baseentry->gpe_start <= start, (__func__)); + KASSERT(baseentry->gpe_end >= start + size - 1, (__func__)); + baseentry->gpe_index = (start / sectors) + 1; + baseentry->gpe_offset = (off_t)(start + sectors) * pp->sectorsize; + baseentry->gpe_start = start; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From bz at FreeBSD.org Tue Mar 17 13:59:47 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Mar 17 13:59:59 2009 Subject: svn commit: r189938 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netinet Message-ID: <200903172059.n2HKxjMf006194@svn.freebsd.org> Author: bz Date: Tue Mar 17 20:59:45 2009 New Revision: 189938 URL: http://svn.freebsd.org/changeset/base/189938 Log: MFC r183001: Implement IPv6 support for TCP MD5 Signature Option (RFC 2385) the same way it has been implemented for IPv4. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netinet/tcp_output.c stable/7/sys/netinet/tcp_subr.c stable/7/sys/netinet/tcp_syncache.c Modified: stable/7/sys/netinet/tcp_output.c ============================================================================== --- stable/7/sys/netinet/tcp_output.c Tue Mar 17 19:57:11 2009 (r189937) +++ stable/7/sys/netinet/tcp_output.c Tue Mar 17 20:59:45 2009 (r189938) @@ -681,11 +681,7 @@ send: } #ifdef TCP_SIGNATURE /* TCP-MD5 (RFC2385). */ -#ifdef INET6 - if (!isipv6 && (tp->t_flags & TF_SIGNATURE)) -#else if (tp->t_flags & TF_SIGNATURE) -#endif /* INET6 */ to.to_flags |= TOF_SIGNATURE; #endif /* TCP_SIGNATURE */ @@ -954,12 +950,9 @@ send: tp->snd_up = tp->snd_una; /* drag it along */ #ifdef TCP_SIGNATURE -#ifdef INET6 - if (!isipv6) -#endif if (tp->t_flags & TF_SIGNATURE) { int sigoff = to.to_signature - opt; - tcp_signature_compute(m, sizeof(struct ip), len, optlen, + tcp_signature_compute(m, 0, len, optlen, (u_char *)(th + 1) + sigoff, IPSEC_DIR_OUTBOUND); } #endif Modified: stable/7/sys/netinet/tcp_subr.c ============================================================================== --- stable/7/sys/netinet/tcp_subr.c Tue Mar 17 19:57:11 2009 (r189937) +++ stable/7/sys/netinet/tcp_subr.c Tue Mar 17 20:59:45 2009 (r189938) @@ -102,6 +102,7 @@ __FBSDID("$FreeBSD$"); #include #endif #include +#include #endif /*IPSEC*/ #include @@ -1852,11 +1853,11 @@ tcp_signature_apply(void *fstate, void * } /* - * Compute TCP-MD5 hash of a TCPv4 segment. (RFC2385) + * Compute TCP-MD5 hash of a TCP segment. (RFC2385) * * Parameters: * m pointer to head of mbuf chain - * off0 offset to TCP header within the mbuf chain + * _unused * len length of TCP segment data, excluding options * optlen length of TCP segment options * buf pointer to storage for computed MD5 digest @@ -1866,9 +1867,6 @@ tcp_signature_apply(void *fstate, void * * When called from tcp_input(), we can be sure that th_sum has been * zeroed out and verified already. * - * This function is for IPv4 use only. Calling this function with an - * IPv6 packet in the mbuf chain will yield undefined results. - * * Return 0 if successful, otherwise return -1. * * XXX The key is retrieved from the system's PF_KEY SADB, by keying a @@ -1878,7 +1876,7 @@ tcp_signature_apply(void *fstate, void * * specify per-application flows but it is unstable. */ int -tcp_signature_compute(struct mbuf *m, int off0, int len, int optlen, +tcp_signature_compute(struct mbuf *m, int _unused, int len, int optlen, u_char *buf, u_int direction) { union sockaddr_union dst; @@ -1889,34 +1887,62 @@ tcp_signature_compute(struct mbuf *m, in struct ipovly *ipovly; struct secasvar *sav; struct tcphdr *th; +#ifdef INET6 + struct ip6_hdr *ip6; + struct in6_addr in6; + char ip6buf[INET6_ADDRSTRLEN]; + uint32_t plen; + uint16_t nhdr; +#endif u_short savecsum; KASSERT(m != NULL, ("NULL mbuf chain")); KASSERT(buf != NULL, ("NULL signature pointer")); /* Extract the destination from the IP header in the mbuf. */ - ip = mtod(m, struct ip *); bzero(&dst, sizeof(union sockaddr_union)); - dst.sa.sa_len = sizeof(struct sockaddr_in); - dst.sa.sa_family = AF_INET; - dst.sin.sin_addr = (direction == IPSEC_DIR_INBOUND) ? - ip->ip_src : ip->ip_dst; + ip = mtod(m, struct ip *); +#ifdef INET6 + ip6 = NULL; /* Make the compiler happy. */ +#endif + switch (ip->ip_v) { + case IPVERSION: + dst.sa.sa_len = sizeof(struct sockaddr_in); + dst.sa.sa_family = AF_INET; + dst.sin.sin_addr = (direction == IPSEC_DIR_INBOUND) ? + ip->ip_src : ip->ip_dst; + break; +#ifdef INET6 + case (IPV6_VERSION >> 4): + ip6 = mtod(m, struct ip6_hdr *); + dst.sa.sa_len = sizeof(struct sockaddr_in6); + dst.sa.sa_family = AF_INET6; + dst.sin6.sin6_addr = (direction == IPSEC_DIR_INBOUND) ? + ip6->ip6_src : ip6->ip6_dst; + break; +#endif + default: + return (EINVAL); + /* NOTREACHED */ + break; + } /* Look up an SADB entry which matches the address of the peer. */ sav = KEY_ALLOCSA(&dst, IPPROTO_TCP, htonl(TCP_SIG_SPI)); if (sav == NULL) { - printf("%s: SADB lookup failed for %s\n", __func__, - inet_ntoa(dst.sin.sin_addr)); + ipseclog((LOG_ERR, "%s: SADB lookup failed for %s\n", __func__, + (ip->ip_v == IPVERSION) ? inet_ntoa(dst.sin.sin_addr) : +#ifdef INET6 + (ip->ip_v == (IPV6_VERSION >> 4)) ? + ip6_sprintf(ip6buf, &dst.sin6.sin6_addr) : +#endif + "(unsupported)")); return (EINVAL); } MD5Init(&ctx); - ipovly = (struct ipovly *)ip; - th = (struct tcphdr *)((u_char *)ip + off0); - doff = off0 + sizeof(struct tcphdr) + optlen; - /* - * Step 1: Update MD5 hash with IP pseudo-header. + * Step 1: Update MD5 hash with IP(v6) pseudo-header. * * XXX The ippseudo header MUST be digested in network byte order, * or else we'll fail the regression test. Assume all fields we've @@ -1924,12 +1950,55 @@ tcp_signature_compute(struct mbuf *m, in * XXX One cannot depend on ipovly->ih_len here. When called from * tcp_output(), the underlying ip_len member has not yet been set. */ - ippseudo.ippseudo_src = ipovly->ih_src; - ippseudo.ippseudo_dst = ipovly->ih_dst; - ippseudo.ippseudo_pad = 0; - ippseudo.ippseudo_p = IPPROTO_TCP; - ippseudo.ippseudo_len = htons(len + sizeof(struct tcphdr) + optlen); - MD5Update(&ctx, (char *)&ippseudo, sizeof(struct ippseudo)); + switch (ip->ip_v) { + case IPVERSION: + ipovly = (struct ipovly *)ip; + ippseudo.ippseudo_src = ipovly->ih_src; + ippseudo.ippseudo_dst = ipovly->ih_dst; + ippseudo.ippseudo_pad = 0; + ippseudo.ippseudo_p = IPPROTO_TCP; + ippseudo.ippseudo_len = htons(len + sizeof(struct tcphdr) + + optlen); + MD5Update(&ctx, (char *)&ippseudo, sizeof(struct ippseudo)); + + th = (struct tcphdr *)((u_char *)ip + sizeof(struct ip)); + doff = sizeof(struct ip) + sizeof(struct tcphdr) + optlen; + break; +#ifdef INET6 + /* + * RFC 2385, 2.0 Proposal + * For IPv6, the pseudo-header is as described in RFC 2460, namely the + * 128-bit source IPv6 address, 128-bit destination IPv6 address, zero- + * extended next header value (to form 32 bits), and 32-bit segment + * length. + * Note: Upper-Layer Packet Length comes before Next Header. + */ + case (IPV6_VERSION >> 4): + in6 = ip6->ip6_src; + in6_clearscope(&in6); + MD5Update(&ctx, (char *)&in6, sizeof(struct in6_addr)); + in6 = ip6->ip6_dst; + in6_clearscope(&in6); + MD5Update(&ctx, (char *)&in6, sizeof(struct in6_addr)); + plen = htonl(len + sizeof(struct tcphdr) + optlen); + MD5Update(&ctx, (char *)&plen, sizeof(uint32_t)); + nhdr = 0; + MD5Update(&ctx, (char *)&nhdr, sizeof(uint8_t)); + MD5Update(&ctx, (char *)&nhdr, sizeof(uint8_t)); + MD5Update(&ctx, (char *)&nhdr, sizeof(uint8_t)); + nhdr = IPPROTO_TCP; + MD5Update(&ctx, (char *)&nhdr, sizeof(uint8_t)); + + th = (struct tcphdr *)((u_char *)ip6 + sizeof(struct ip6_hdr)); + doff = sizeof(struct ip6_hdr) + sizeof(struct tcphdr) + optlen; + break; +#endif + default: + return (EINVAL); + /* NOTREACHED */ + break; + } + /* * Step 2: Update MD5 hash with TCP header, excluding options. Modified: stable/7/sys/netinet/tcp_syncache.c ============================================================================== --- stable/7/sys/netinet/tcp_syncache.c Tue Mar 17 19:57:11 2009 (r189937) +++ stable/7/sys/netinet/tcp_syncache.c Tue Mar 17 20:59:45 2009 (r189938) @@ -1425,7 +1425,7 @@ syncache_respond(struct syncache *sc) #ifdef TCP_SIGNATURE if (sc->sc_flags & SCF_SIGNATURE) - tcp_signature_compute(m, sizeof(struct ip), 0, optlen, + tcp_signature_compute(m, 0, 0, optlen, to.to_signature, IPSEC_DIR_OUTBOUND); #endif #ifdef INET6 From yongari at FreeBSD.org Tue Mar 17 18:57:28 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 18:57:41 2009 Subject: svn commit: r189941 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/re Message-ID: <200903180157.n2I1vRkO011727@svn.freebsd.org> Author: yongari Date: Wed Mar 18 01:57:26 2009 New Revision: 189941 URL: http://svn.freebsd.org/changeset/base/189941 Log: MFC r187481: - Do not read and write RX configuration register multiple times. - Always program RX configuration register from scratch instead of doing read/modify/write. - Rename re_setmulti() to re_set_rxmode() to be reflect reality. - Simplify hash filter logic a little while I am here. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/re/if_re.c Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Tue Mar 17 21:21:33 2009 (r189940) +++ stable/7/sys/dev/re/if_re.c Wed Mar 18 01:57:26 2009 (r189941) @@ -266,7 +266,7 @@ static int re_miibus_readreg (device_t, static int re_miibus_writereg (device_t, int, int, int); static void re_miibus_statchg (device_t); -static void re_setmulti (struct rl_softc *); +static void re_set_rxmode (struct rl_softc *); static void re_reset (struct rl_softc *); static void re_setwol (struct rl_softc *); static void re_clrwol (struct rl_softc *); @@ -607,26 +607,23 @@ re_miibus_statchg(device_t dev) } /* - * Program the 64-bit multicast hash filter. + * Set the RX configuration and 64-bit multicast hash filter. */ static void -re_setmulti(struct rl_softc *sc) +re_set_rxmode(struct rl_softc *sc) { struct ifnet *ifp; - int h = 0; - u_int32_t hashes[2] = { 0, 0 }; struct ifmultiaddr *ifma; - u_int32_t rxfilt; - int mcnt = 0; + uint32_t hashes[2] = { 0, 0 }; + uint32_t h, rxfilt; RL_LOCK_ASSERT(sc); ifp = sc->rl_ifp; + rxfilt = RL_RXCFG_CONFIG | RL_RXCFG_RX_INDIV | RL_RXCFG_RX_BROAD; - rxfilt = CSR_READ_4(sc, RL_RXCFG); - rxfilt &= ~(RL_RXCFG_RX_ALLPHYS | RL_RXCFG_RX_MULTI); - if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) { + if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) { if (ifp->if_flags & IFF_PROMISC) rxfilt |= RL_RXCFG_RX_ALLPHYS; /* @@ -635,17 +632,10 @@ re_setmulti(struct rl_softc *sc) * promiscuous mode. */ rxfilt |= RL_RXCFG_RX_MULTI; - CSR_WRITE_4(sc, RL_RXCFG, rxfilt); - CSR_WRITE_4(sc, RL_MAR0, 0xFFFFFFFF); - CSR_WRITE_4(sc, RL_MAR4, 0xFFFFFFFF); - return; + hashes[0] = hashes[1] = 0xffffffff; + goto done; } - /* first, zot all the existing hash bits */ - CSR_WRITE_4(sc, RL_MAR0, 0); - CSR_WRITE_4(sc, RL_MAR4, 0); - - /* now program new ones */ IF_ADDR_LOCK(ifp); TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) @@ -656,31 +646,29 @@ re_setmulti(struct rl_softc *sc) hashes[0] |= (1 << h); else hashes[1] |= (1 << (h - 32)); - mcnt++; } IF_ADDR_UNLOCK(ifp); - if (mcnt) + if (hashes[0] != 0 || hashes[1] != 0) { + /* + * For some unfathomable reason, RealTek decided to + * reverse the order of the multicast hash registers + * in the PCI Express parts. This means we have to + * write the hash pattern in reverse order for those + * devices. + */ + if ((sc->rl_flags & RL_FLAG_INVMAR) != 0) { + h = bswap32(hashes[0]); + hashes[0] = bswap32(hashes[1]); + hashes[1] = h; + } rxfilt |= RL_RXCFG_RX_MULTI; - else - rxfilt &= ~RL_RXCFG_RX_MULTI; + } +done: + CSR_WRITE_4(sc, RL_MAR0, hashes[0]); + CSR_WRITE_4(sc, RL_MAR4, hashes[1]); CSR_WRITE_4(sc, RL_RXCFG, rxfilt); - - /* - * For some unfathomable reason, RealTek decided to reverse - * the order of the multicast hash registers in the PCI Express - * parts. This means we have to write the hash pattern in reverse - * order for those devices. - */ - - if ((sc->rl_flags & RL_FLAG_INVMAR) != 0) { - CSR_WRITE_4(sc, RL_MAR0, bswap32(hashes[1])); - CSR_WRITE_4(sc, RL_MAR4, bswap32(hashes[0])); - } else { - CSR_WRITE_4(sc, RL_MAR0, hashes[0]); - CSR_WRITE_4(sc, RL_MAR4, hashes[1]); - } } static void @@ -2498,7 +2486,6 @@ re_init_locked(struct rl_softc *sc) { struct ifnet *ifp = sc->rl_ifp; struct mii_data *mii; - u_int32_t rxcfg = 0; uint16_t cfg; union { uint32_t align_dummy; @@ -2583,7 +2570,7 @@ re_init_locked(struct rl_softc *sc) CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_TX_ENB|RL_CMD_RX_ENB); /* - * Set the initial TX and RX configuration. + * Set the initial TX configuration. */ if (sc->rl_testmode) { if (sc->rl_type == RL_8169) @@ -2597,32 +2584,10 @@ re_init_locked(struct rl_softc *sc) CSR_WRITE_1(sc, RL_EARLY_TX_THRESH, 16); - CSR_WRITE_4(sc, RL_RXCFG, RL_RXCFG_CONFIG); - - /* Set the individual bit to receive frames for this host only. */ - rxcfg = CSR_READ_4(sc, RL_RXCFG); - rxcfg |= RL_RXCFG_RX_INDIV; - - /* If we want promiscuous mode, set the allframes bit. */ - if (ifp->if_flags & IFF_PROMISC) - rxcfg |= RL_RXCFG_RX_ALLPHYS; - else - rxcfg &= ~RL_RXCFG_RX_ALLPHYS; - CSR_WRITE_4(sc, RL_RXCFG, rxcfg); - - /* - * Set capture broadcast bit to capture broadcast frames. - */ - if (ifp->if_flags & IFF_BROADCAST) - rxcfg |= RL_RXCFG_RX_BROAD; - else - rxcfg &= ~RL_RXCFG_RX_BROAD; - CSR_WRITE_4(sc, RL_RXCFG, rxcfg); - /* - * Program the multicast filter, if necessary. + * Set the initial RX configuration. */ - re_setmulti(sc); + re_set_rxmode(sc); #ifdef DEVICE_POLLING /* @@ -2761,7 +2726,7 @@ re_ioctl(struct ifnet *ifp, u_long comma if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { if (((ifp->if_flags ^ sc->rl_if_flags) & (IFF_PROMISC | IFF_ALLMULTI)) != 0) - re_setmulti(sc); + re_set_rxmode(sc); } else re_init_locked(sc); } else { @@ -2774,7 +2739,7 @@ re_ioctl(struct ifnet *ifp, u_long comma case SIOCADDMULTI: case SIOCDELMULTI: RL_LOCK(sc); - re_setmulti(sc); + re_set_rxmode(sc); RL_UNLOCK(sc); break; case SIOCGIFMEDIA: From yongari at FreeBSD.org Tue Mar 17 19:00:24 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 19:00:44 2009 Subject: svn commit: r189943 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/re pci Message-ID: <200903180200.n2I20NVT011893@svn.freebsd.org> Author: yongari Date: Wed Mar 18 02:00:23 2009 New Revision: 189943 URL: http://svn.freebsd.org/changeset/base/189943 Log: MFC r187482: Retire RL_FLAG_INVMAR bit to match its comment and reality. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/re/if_re.c stable/7/sys/pci/if_rlreg.h Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Wed Mar 18 01:57:54 2009 (r189942) +++ stable/7/sys/dev/re/if_re.c Wed Mar 18 02:00:23 2009 (r189943) @@ -657,7 +657,7 @@ re_set_rxmode(struct rl_softc *sc) * write the hash pattern in reverse order for those * devices. */ - if ((sc->rl_flags & RL_FLAG_INVMAR) != 0) { + if ((sc->rl_flags & RL_FLAG_PCIE) != 0) { h = bswap32(hashes[0]); hashes[0] = bswap32(hashes[1]); hashes[1] = h; @@ -1234,22 +1234,21 @@ re_attach(device_t dev) break; case RL_HWREV_8100E: case RL_HWREV_8101E: - sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR | - RL_FLAG_PHYWAKE | RL_FLAG_FASTETHER; + sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_PHYWAKE | + RL_FLAG_FASTETHER; break; case RL_HWREV_8102E: case RL_HWREV_8102EL: - sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR | - RL_FLAG_PHYWAKE | RL_FLAG_PAR | RL_FLAG_DESCV2 | - RL_FLAG_MACSTAT | RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP; + sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_PHYWAKE | + RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | + RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP; break; case RL_HWREV_8168_SPIN1: case RL_HWREV_8168_SPIN2: sc->rl_flags |= RL_FLAG_WOLRXENB; /* FALLTHROUGH */ case RL_HWREV_8168_SPIN3: - sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | - RL_FLAG_MACSTAT; + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_MACSTAT; break; case RL_HWREV_8168C_SPIN2: sc->rl_flags |= RL_FLAG_MACSLEEP; @@ -1260,9 +1259,8 @@ re_attach(device_t dev) /* FALLTHROUGH */ case RL_HWREV_8168CP: case RL_HWREV_8168D: - sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | - RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | - RL_FLAG_CMDSTOP; + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | + RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP; /* * These controllers support jumbo frame but it seems * that enabling it requires touching additional magic Modified: stable/7/sys/pci/if_rlreg.h ============================================================================== --- stable/7/sys/pci/if_rlreg.h Wed Mar 18 01:57:54 2009 (r189942) +++ stable/7/sys/pci/if_rlreg.h Wed Mar 18 02:00:23 2009 (r189943) @@ -852,7 +852,6 @@ struct rl_softc { int rl_txstart; uint32_t rl_flags; #define RL_FLAG_MSI 0x0001 -#define RL_FLAG_INVMAR 0x0004 #define RL_FLAG_PHYWAKE 0x0008 #define RL_FLAG_NOJUMBO 0x0010 #define RL_FLAG_PAR 0x0020 From yongari at FreeBSD.org Tue Mar 17 19:03:17 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 19:04:14 2009 Subject: svn commit: r189944 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/re pci Message-ID: <200903180203.n2I23G57012008@svn.freebsd.org> Author: yongari Date: Wed Mar 18 02:03:16 2009 New Revision: 189944 URL: http://svn.freebsd.org/changeset/base/189944 Log: MFC r187483: - Add support for 8110SCe part. Some magic registers were taken from Linux driver. - Swap hardware revisions for 8110S and 8169S as Linux driver claims. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/re/if_re.c stable/7/sys/pci/if_rlreg.h Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Wed Mar 18 02:00:23 2009 (r189943) +++ stable/7/sys/dev/re/if_re.c Wed Mar 18 02:03:16 2009 (r189944) @@ -199,9 +199,10 @@ static struct rl_hwrev re_hwrevs[] = { { RL_HWREV_8169, RL_8169, "8169"}, { RL_HWREV_8169S, RL_8169, "8169S"}, { RL_HWREV_8110S, RL_8169, "8110S"}, - { RL_HWREV_8169_8110SB, RL_8169, "8169SB"}, - { RL_HWREV_8169_8110SC, RL_8169, "8169SC"}, - { RL_HWREV_8169_8110SBL, RL_8169, "8169SBL"}, + { RL_HWREV_8169_8110SB, RL_8169, "8169SB/8110SB"}, + { RL_HWREV_8169_8110SC, RL_8169, "8169SC/8110SC"}, + { RL_HWREV_8169_8110SBL, RL_8169, "8169SBL/8110SBL"}, + { RL_HWREV_8169_8110SCE, RL_8169, "8169SC/8110SC"}, { RL_HWREV_8100, RL_8139, "8100"}, { RL_HWREV_8101, RL_8139, "8101"}, { RL_HWREV_8100E, RL_8169, "8100E"}, @@ -688,12 +689,10 @@ re_reset(struct rl_softc *sc) if (i == RL_TIMEOUT) device_printf(sc->rl_dev, "reset never completed!\n"); - if ((sc->rl_flags & RL_FLAG_PHY8169) != 0) + if ((sc->rl_flags & RL_FLAG_MACRESET) != 0) CSR_WRITE_1(sc, 0x82, 1); - if ((sc->rl_flags & RL_FLAG_PHY8110S) != 0) { - CSR_WRITE_1(sc, 0x82, 1); - re_gmii_writereg(sc->rl_dev, 1, 0x0B, 0); - } + if (sc->rl_hwrev == RL_HWREV_8169S) + re_gmii_writereg(sc->rl_dev, 1, 0x0b, 0); } #ifdef RE_DIAG @@ -1209,12 +1208,22 @@ re_attach(device_t dev) hw_rev = re_hwrevs; hwrev = CSR_READ_4(sc, RL_TXCFG); - device_printf(dev, "Chip rev. 0x%08x\n", hwrev & 0x7c800000); + switch (hwrev & 0x70000000) { + case 0x00000000: + case 0x10000000: + device_printf(dev, "Chip rev. 0x%08x\n", hwrev & 0xfc800000); + hwrev &= (RL_TXCFG_HWREV | 0x80000000); + break; + default: + device_printf(dev, "Chip rev. 0x%08x\n", hwrev & 0x7c800000); + hwrev &= RL_TXCFG_HWREV; + break; + } device_printf(dev, "MAC rev. 0x%08x\n", hwrev & 0x00700000); - hwrev &= RL_TXCFG_HWREV; while (hw_rev->rl_desc != NULL) { if (hw_rev->rl_rev == hwrev) { sc->rl_type = hw_rev->rl_type; + sc->rl_hwrev = hw_rev->rl_rev; break; } hw_rev++; @@ -1229,9 +1238,6 @@ re_attach(device_t dev) case RL_HWREV_8139CPLUS: sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_FASTETHER; break; - case RL_HWREV_8110S: - sc->rl_flags |= RL_FLAG_PHY8110S; - break; case RL_HWREV_8100E: case RL_HWREV_8101E: sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_PHYWAKE | @@ -1273,14 +1279,16 @@ re_attach(device_t dev) */ sc->rl_flags |= RL_FLAG_NOJUMBO; break; - case RL_HWREV_8169: - case RL_HWREV_8169S: - sc->rl_flags |= RL_FLAG_PHY8169; - break; case RL_HWREV_8169_8110SB: - case RL_HWREV_8169_8110SC: case RL_HWREV_8169_8110SBL: - sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHY8169; + case RL_HWREV_8169_8110SC: + case RL_HWREV_8169_8110SCE: + sc->rl_flags |= RL_FLAG_PHYWAKE; + /* FALLTHROUGH */ + case RL_HWREV_8169: + case RL_HWREV_8169S: + case RL_HWREV_8110S: + sc->rl_flags |= RL_FLAG_MACRESET; break; default: break; @@ -2484,6 +2492,7 @@ re_init_locked(struct rl_softc *sc) { struct ifnet *ifp = sc->rl_ifp; struct mii_data *mii; + uint32_t reg; uint16_t cfg; union { uint32_t align_dummy; @@ -2519,6 +2528,17 @@ re_init_locked(struct rl_softc *sc) } else cfg |= RL_CPLUSCMD_RXENB | RL_CPLUSCMD_TXENB; CSR_WRITE_2(sc, RL_CPLUS_CMD, cfg); + if (sc->rl_hwrev == RL_HWREV_8169_8110SC || + sc->rl_hwrev == RL_HWREV_8169_8110SCE) { + reg = 0x000fff00; + if ((CSR_READ_1(sc, RL_CFG2) & RL_CFG2_PCI66MHZ) != 0) + reg |= 0x000000ff; + if (sc->rl_hwrev == RL_HWREV_8169_8110SCE) + reg |= 0x00f00000; + CSR_WRITE_4(sc, 0x7c, reg); + /* Disable interrupt mitigation. */ + CSR_WRITE_2(sc, 0xe2, 0); + } /* * Disable TSO if interface MTU size is greater than MSS * allowed in controller. Modified: stable/7/sys/pci/if_rlreg.h ============================================================================== --- stable/7/sys/pci/if_rlreg.h Wed Mar 18 02:00:23 2009 (r189943) +++ stable/7/sys/pci/if_rlreg.h Wed Mar 18 02:03:16 2009 (r189944) @@ -154,8 +154,8 @@ /* Known revision codes. */ #define RL_HWREV_8169 0x00000000 -#define RL_HWREV_8110S 0x00800000 -#define RL_HWREV_8169S 0x04000000 +#define RL_HWREV_8169S 0x00800000 +#define RL_HWREV_8110S 0x04000000 #define RL_HWREV_8169_8110SB 0x10000000 #define RL_HWREV_8169_8110SC 0x18000000 #define RL_HWREV_8102EL 0x24800000 @@ -180,6 +180,7 @@ #define RL_HWREV_8101 0x74c00000 #define RL_HWREV_8100 0x78800000 #define RL_HWREV_8169_8110SBL 0x7CC00000 +#define RL_HWREV_8169_8110SCE 0x98000000 #define RL_TXDMA_16BYTES 0x00000000 #define RL_TXDMA_32BYTES 0x00000100 @@ -859,8 +860,7 @@ struct rl_softc { #define RL_FLAG_MACSTAT 0x0080 #define RL_FLAG_FASTETHER 0x0100 #define RL_FLAG_CMDSTOP 0x0200 -#define RL_FLAG_PHY8169 0x0400 -#define RL_FLAG_PHY8110S 0x0800 +#define RL_FLAG_MACRESET 0x0400 #define RL_FLAG_WOLRXENB 0x1000 #define RL_FLAG_MACSLEEP 0x2000 #define RL_FLAG_PCIE 0x4000 From yongari at FreeBSD.org Tue Mar 17 19:07:08 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 19:07:25 2009 Subject: svn commit: r189945 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/re Message-ID: <200903180207.n2I277fJ012125@svn.freebsd.org> Author: yongari Date: Wed Mar 18 02:07:07 2009 New Revision: 189945 URL: http://svn.freebsd.org/changeset/base/189945 Log: MFC r188381: Reclaim transmitted frames in re_tick(). This is for PCIe controllers that lose Tx completion interrupts under certain conditions. With this change it's safe to use MSI on PCIe controllers so enable MSI on these controllers. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/re/if_re.c Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Wed Mar 18 02:03:16 2009 (r189944) +++ stable/7/sys/dev/re/if_re.c Wed Mar 18 02:07:07 2009 (r189945) @@ -156,7 +156,7 @@ MODULE_DEPEND(re, miibus, 1, 1, 1); #include "miibus_if.h" /* Tunables. */ -static int msi_disable = 1; +static int msi_disable = 0; TUNABLE_INT("hw.re.msi_disable", &msi_disable); #define RE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP) @@ -2064,6 +2064,13 @@ re_tick(void *xsc) mii_tick(mii); if ((sc->rl_flags & RL_FLAG_LINK) == 0) re_miibus_statchg(sc->rl_dev); + /* + * Reclaim transmitted frames here. Technically it is not + * necessary to do here but it ensures periodic reclamation + * regardless of Tx completion interrupt which seems to be + * lost on PCIe based controllers under certain situations. + */ + re_txeof(sc); re_watchdog(sc); callout_reset(&sc->rl_stat_callout, hz, re_tick, sc); } From yongari at FreeBSD.org Tue Mar 17 19:10:02 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 19:10:08 2009 Subject: svn commit: r189946 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/re pci Message-ID: <200903180210.n2I2A1QB012231@svn.freebsd.org> Author: yongari Date: Wed Mar 18 02:10:01 2009 New Revision: 189946 URL: http://svn.freebsd.org/changeset/base/189946 Log: MFC r188474: Allocating 2 MSI messages do not seem to work on certain controllers so use just 1 MSI message. This fixes regression introduced in r188381. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/re/if_re.c stable/7/sys/pci/if_rlreg.h Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Wed Mar 18 02:07:07 2009 (r189945) +++ stable/7/sys/dev/re/if_re.c Wed Mar 18 02:10:01 2009 (r189946) @@ -1149,7 +1149,8 @@ re_attach(device_t dev) if (bootverbose) device_printf(dev, "MSI count : %d\n", msic); } - if (msic == RL_MSI_MESSAGES && msi_disable == 0) { + if (msic > 0 && msi_disable == 0) { + msic = 1; if (pci_alloc_msi(dev, &msic) == 0) { if (msic == RL_MSI_MESSAGES) { device_printf(dev, "Using %d MSI messages\n", Modified: stable/7/sys/pci/if_rlreg.h ============================================================================== --- stable/7/sys/pci/if_rlreg.h Wed Mar 18 02:07:07 2009 (r189945) +++ stable/7/sys/pci/if_rlreg.h Wed Mar 18 02:10:01 2009 (r189946) @@ -758,7 +758,7 @@ struct rl_stats { #define RE_RX_DESC_BUFLEN MCLBYTES #endif -#define RL_MSI_MESSAGES 2 +#define RL_MSI_MESSAGES 1 #define RL_ADDR_LO(y) ((uint64_t) (y) & 0xFFFFFFFF) #define RL_ADDR_HI(y) ((uint64_t) (y) >> 32) From yongari at FreeBSD.org Tue Mar 17 19:12:34 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 19:12:51 2009 Subject: svn commit: r189947 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/re Message-ID: <200903180212.n2I2CXwK012336@svn.freebsd.org> Author: yongari Date: Wed Mar 18 02:12:33 2009 New Revision: 189947 URL: http://svn.freebsd.org/changeset/base/189947 Log: MFC r189555: Add a new tunable hw.re.prefer_iomap which disables memory register mapping. The tunable is OFF for all controllers except RTL8169SC family. RTL8169SC seems to require more magic to use memory register mapping. r187483 added a fix for RTL8169SCe controller but it does not looke like fix other variants of RTL8169SC. Tested by: Gavin Stone-Tolcher g.stone-tolcher <> its dot uq dot edu dot au Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/re/if_re.c Modified: stable/7/sys/dev/re/if_re.c ============================================================================== --- stable/7/sys/dev/re/if_re.c Wed Mar 18 02:10:01 2009 (r189946) +++ stable/7/sys/dev/re/if_re.c Wed Mar 18 02:12:33 2009 (r189947) @@ -158,6 +158,8 @@ MODULE_DEPEND(re, miibus, 1, 1, 1); /* Tunables. */ static int msi_disable = 0; TUNABLE_INT("hw.re.msi_disable", &msi_disable); +static int prefer_iomap = 0; +TUNABLE_INT("hw.re.prefer_iomap", &prefer_iomap); #define RE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP) @@ -1118,25 +1120,35 @@ re_attach(device_t dev) pci_enable_busmaster(dev); devid = pci_get_device(dev); - /* Prefer memory space register mapping over IO space. */ - sc->rl_res_id = PCIR_BAR(1); - sc->rl_res_type = SYS_RES_MEMORY; - /* RTL8168/8101E seems to use different BARs. */ - if (devid == RT_DEVICEID_8168 || devid == RT_DEVICEID_8101E) - sc->rl_res_id = PCIR_BAR(2); + /* + * Prefer memory space register mapping over IO space. + * Because RTL8169SC does not seem to work when memory mapping + * is used always activate io mapping. + */ + if (devid == RT_DEVICEID_8169SC) + prefer_iomap = 1; + if (prefer_iomap == 0) { + sc->rl_res_id = PCIR_BAR(1); + sc->rl_res_type = SYS_RES_MEMORY; + /* RTL8168/8101E seems to use different BARs. */ + if (devid == RT_DEVICEID_8168 || devid == RT_DEVICEID_8101E) + sc->rl_res_id = PCIR_BAR(2); + } else { + sc->rl_res_id = PCIR_BAR(0); + sc->rl_res_type = SYS_RES_IOPORT; + } sc->rl_res = bus_alloc_resource_any(dev, sc->rl_res_type, &sc->rl_res_id, RF_ACTIVE); - - if (sc->rl_res == NULL) { + if (sc->rl_res == NULL && prefer_iomap == 0) { sc->rl_res_id = PCIR_BAR(0); sc->rl_res_type = SYS_RES_IOPORT; sc->rl_res = bus_alloc_resource_any(dev, sc->rl_res_type, &sc->rl_res_id, RF_ACTIVE); - if (sc->rl_res == NULL) { - device_printf(dev, "couldn't map ports/memory\n"); - error = ENXIO; - goto fail; - } + } + if (sc->rl_res == NULL) { + device_printf(dev, "couldn't map ports/memory\n"); + error = ENXIO; + goto fail; } sc->rl_btag = rman_get_bustag(sc->rl_res); From yongari at FreeBSD.org Tue Mar 17 19:23:02 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 19:23:20 2009 Subject: svn commit: r189948 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/nfe Message-ID: <200903180223.n2I2N1Vc012595@svn.freebsd.org> Author: yongari Date: Wed Mar 18 02:23:01 2009 New Revision: 189948 URL: http://svn.freebsd.org/changeset/base/189948 Log: MFC r183561, 186346: r183561: Add hardware MAC statistics support. Register information was obtained from Linux forcedeth driver. While I'm here move creating a sysctl node for process_limit to function nfe_sysctl_node(). Tested by: "Arno J. Klaassen" < arno heho dot snv dot jussieu dot fr > r186346: Fix a typo. Submitted by: clemens fischer via Shigeaki Tagashira Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/nfe/if_nfe.c stable/7/sys/dev/nfe/if_nfereg.h stable/7/sys/dev/nfe/if_nfevar.h Modified: stable/7/sys/dev/nfe/if_nfe.c ============================================================================== --- stable/7/sys/dev/nfe/if_nfe.c Wed Mar 18 02:12:33 2009 (r189947) +++ stable/7/sys/dev/nfe/if_nfe.c Wed Mar 18 02:23:01 2009 (r189948) @@ -122,6 +122,9 @@ static void nfe_dma_map_segs(void *, bus static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int); static int sysctl_hw_nfe_proc_limit(SYSCTL_HANDLER_ARGS); +static void nfe_sysctl_node(struct nfe_softc *); +static void nfe_stats_clear(struct nfe_softc *); +static void nfe_stats_update(struct nfe_softc *); #ifdef NFE_DEBUG static int nfedebug = 0; @@ -454,18 +457,19 @@ nfe_attach(device_t dev) break; case PCI_PRODUCT_NVIDIA_MCP51_LAN1: case PCI_PRODUCT_NVIDIA_MCP51_LAN2: - sc->nfe_flags |= NFE_40BIT_ADDR | NFE_PWR_MGMT; + sc->nfe_flags |= NFE_40BIT_ADDR | NFE_PWR_MGMT | NFE_MIB_V1; break; case PCI_PRODUCT_NVIDIA_CK804_LAN1: case PCI_PRODUCT_NVIDIA_CK804_LAN2: case PCI_PRODUCT_NVIDIA_MCP04_LAN1: case PCI_PRODUCT_NVIDIA_MCP04_LAN2: - sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM; + sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM | + NFE_MIB_V1; break; case PCI_PRODUCT_NVIDIA_MCP55_LAN1: case PCI_PRODUCT_NVIDIA_MCP55_LAN2: sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM | - NFE_HW_VLAN | NFE_PWR_MGMT | NFE_TX_FLOW_CTRL; + NFE_HW_VLAN | NFE_PWR_MGMT | NFE_TX_FLOW_CTRL | NFE_MIB_V2; break; case PCI_PRODUCT_NVIDIA_MCP61_LAN1: @@ -481,7 +485,7 @@ nfe_attach(device_t dev) case PCI_PRODUCT_NVIDIA_MCP73_LAN3: case PCI_PRODUCT_NVIDIA_MCP73_LAN4: sc->nfe_flags |= NFE_40BIT_ADDR | NFE_PWR_MGMT | - NFE_CORRECT_MACADDR | NFE_TX_FLOW_CTRL; + NFE_CORRECT_MACADDR | NFE_TX_FLOW_CTRL | NFE_MIB_V2; break; case PCI_PRODUCT_NVIDIA_MCP77_LAN1: case PCI_PRODUCT_NVIDIA_MCP77_LAN2: @@ -489,7 +493,7 @@ nfe_attach(device_t dev) case PCI_PRODUCT_NVIDIA_MCP77_LAN4: /* XXX flow control */ sc->nfe_flags |= NFE_40BIT_ADDR | NFE_HW_CSUM | NFE_PWR_MGMT | - NFE_CORRECT_MACADDR; + NFE_CORRECT_MACADDR | NFE_MIB_V3; break; case PCI_PRODUCT_NVIDIA_MCP79_LAN1: case PCI_PRODUCT_NVIDIA_MCP79_LAN2: @@ -497,14 +501,15 @@ nfe_attach(device_t dev) case PCI_PRODUCT_NVIDIA_MCP79_LAN4: /* XXX flow control */ sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM | - NFE_PWR_MGMT | NFE_CORRECT_MACADDR; + NFE_PWR_MGMT | NFE_CORRECT_MACADDR | NFE_MIB_V3; break; case PCI_PRODUCT_NVIDIA_MCP65_LAN1: case PCI_PRODUCT_NVIDIA_MCP65_LAN2: case PCI_PRODUCT_NVIDIA_MCP65_LAN3: case PCI_PRODUCT_NVIDIA_MCP65_LAN4: sc->nfe_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | - NFE_PWR_MGMT | NFE_CORRECT_MACADDR | NFE_TX_FLOW_CTRL; + NFE_PWR_MGMT | NFE_CORRECT_MACADDR | NFE_TX_FLOW_CTRL | + NFE_MIB_V2; break; } @@ -551,24 +556,8 @@ nfe_attach(device_t dev) goto fail; nfe_alloc_jrx_ring(sc, &sc->jrxq); - - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "process_limit", CTLTYPE_INT | CTLFLAG_RW, - &sc->nfe_process_limit, 0, sysctl_hw_nfe_proc_limit, "I", - "max number of Rx events to process"); - - sc->nfe_process_limit = NFE_PROC_DEFAULT; - error = resource_int_value(device_get_name(dev), device_get_unit(dev), - "process_limit", &sc->nfe_process_limit); - if (error == 0) { - if (sc->nfe_process_limit < NFE_PROC_MIN || - sc->nfe_process_limit > NFE_PROC_MAX) { - device_printf(dev, "process_limit value out of range; " - "using default: %d\n", NFE_PROC_DEFAULT); - sc->nfe_process_limit = NFE_PROC_DEFAULT; - } - } + /* Create sysctl node. */ + nfe_sysctl_node(sc); ifp->if_softc = sc; if_initname(ifp, device_get_name(dev), device_get_unit(dev)); @@ -2767,6 +2756,9 @@ nfe_init_locked(void *xsc) NFE_WRITE(sc, NFE_PHY_STATUS, 0xf); + /* Clear hardware stats. */ + nfe_stats_clear(sc); + #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) nfe_disable_intr(sc); @@ -2855,6 +2847,8 @@ nfe_stop(struct ifnet *ifp) tdata->m = NULL; } } + /* Update hardware stats. */ + nfe_stats_update(sc); } @@ -2906,6 +2900,7 @@ nfe_tick(void *xsc) mii = device_get_softc(sc->nfe_miibus); mii_tick(mii); + nfe_stats_update(sc); nfe_watchdog(ifp); callout_reset(&sc->nfe_stat_ch, hz, nfe_tick, sc); } @@ -3013,3 +3008,199 @@ sysctl_hw_nfe_proc_limit(SYSCTL_HANDLER_ return (sysctl_int_range(oidp, arg1, arg2, req, NFE_PROC_MIN, NFE_PROC_MAX)); } + + +#define NFE_SYSCTL_STAT_ADD32(c, h, n, p, d) \ + SYSCTL_ADD_UINT(c, h, OID_AUTO, n, CTLFLAG_RD, p, 0, d) +#define NFE_SYSCTL_STAT_ADD64(c, h, n, p, d) \ + SYSCTL_ADD_ULONG(c, h, OID_AUTO, n, CTLFLAG_RD, p, d) + +static void +nfe_sysctl_node(struct nfe_softc *sc) +{ + struct sysctl_ctx_list *ctx; + struct sysctl_oid_list *child, *parent; + struct sysctl_oid *tree; + struct nfe_hw_stats *stats; + int error; + + stats = &sc->nfe_stats; + ctx = device_get_sysctl_ctx(sc->nfe_dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->nfe_dev)); + SYSCTL_ADD_PROC(ctx, child, + OID_AUTO, "process_limit", CTLTYPE_INT | CTLFLAG_RW, + &sc->nfe_process_limit, 0, sysctl_hw_nfe_proc_limit, "I", + "max number of Rx events to process"); + + sc->nfe_process_limit = NFE_PROC_DEFAULT; + error = resource_int_value(device_get_name(sc->nfe_dev), + device_get_unit(sc->nfe_dev), "process_limit", + &sc->nfe_process_limit); + if (error == 0) { + if (sc->nfe_process_limit < NFE_PROC_MIN || + sc->nfe_process_limit > NFE_PROC_MAX) { + device_printf(sc->nfe_dev, + "process_limit value out of range; " + "using default: %d\n", NFE_PROC_DEFAULT); + sc->nfe_process_limit = NFE_PROC_DEFAULT; + } + } + + if ((sc->nfe_flags & (NFE_MIB_V1 | NFE_MIB_V2 | NFE_MIB_V3)) == 0) + return; + + tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", CTLFLAG_RD, + NULL, "NFE statistics"); + parent = SYSCTL_CHILDREN(tree); + + /* Rx statistics. */ + tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "rx", CTLFLAG_RD, + NULL, "Rx MAC statistics"); + child = SYSCTL_CHILDREN(tree); + + NFE_SYSCTL_STAT_ADD32(ctx, child, "frame_errors", + &stats->rx_frame_errors, "Framing Errors"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "extra_bytes", + &stats->rx_extra_bytes, "Extra Bytes"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "late_cols", + &stats->rx_late_cols, "Late Collisions"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "runts", + &stats->rx_runts, "Runts"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "jumbos", + &stats->rx_jumbos, "Jumbos"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "fifo_overuns", + &stats->rx_fifo_overuns, "FIFO Overruns"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "crc_errors", + &stats->rx_crc_errors, "CRC Errors"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "fae", + &stats->rx_fae, "Frame Alignment Errors"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "len_errors", + &stats->rx_len_errors, "Length Errors"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "unicast", + &stats->rx_unicast, "Unicast Frames"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "multicast", + &stats->rx_multicast, "Multicast Frames"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "broadcast", + &stats->rx_broadcast, "Broadcast Frames"); + if ((sc->nfe_flags & NFE_MIB_V2) != 0) { + NFE_SYSCTL_STAT_ADD64(ctx, child, "octets", + &stats->rx_octets, "Octets"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "pause", + &stats->rx_pause, "Pause frames"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "drops", + &stats->rx_drops, "Drop frames"); + } + + /* Tx statistics. */ + tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "tx", CTLFLAG_RD, + NULL, "Tx MAC statistics"); + child = SYSCTL_CHILDREN(tree); + NFE_SYSCTL_STAT_ADD64(ctx, child, "octets", + &stats->tx_octets, "Octets"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "zero_rexmits", + &stats->tx_zero_rexmits, "Zero Retransmits"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "one_rexmits", + &stats->tx_one_rexmits, "One Retransmits"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "multi_rexmits", + &stats->tx_multi_rexmits, "Multiple Retransmits"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "late_cols", + &stats->tx_late_cols, "Late Collisions"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "fifo_underuns", + &stats->tx_fifo_underuns, "FIFO Underruns"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "carrier_losts", + &stats->tx_carrier_losts, "Carrier Losts"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "excess_deferrals", + &stats->tx_excess_deferals, "Excess Deferrals"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "retry_errors", + &stats->tx_retry_errors, "Retry Errors"); + if ((sc->nfe_flags & NFE_MIB_V2) != 0) { + NFE_SYSCTL_STAT_ADD32(ctx, child, "deferrals", + &stats->tx_deferals, "Deferrals"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "frames", + &stats->tx_frames, "Frames"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "pause", + &stats->tx_pause, "Pause Frames"); + } + if ((sc->nfe_flags & NFE_MIB_V3) != 0) { + NFE_SYSCTL_STAT_ADD32(ctx, child, "unicast", + &stats->tx_deferals, "Unicast Frames"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "multicast", + &stats->tx_frames, "Multicast Frames"); + NFE_SYSCTL_STAT_ADD32(ctx, child, "broadcast", + &stats->tx_pause, "Broadcast Frames"); + } +} + +#undef NFE_SYSCTL_STAT_ADD32 +#undef NFE_SYSCTL_STAT_ADD64 + +static void +nfe_stats_clear(struct nfe_softc *sc) +{ + int i, mib_cnt; + + if ((sc->nfe_flags & NFE_MIB_V1) != 0) + mib_cnt = NFE_NUM_MIB_STATV1; + else if ((sc->nfe_flags & (NFE_MIB_V2 | NFE_MIB_V3)) != 0) + mib_cnt = NFE_NUM_MIB_STATV2; + else + return; + + for (i = 0; i < mib_cnt; i += sizeof(uint32_t)) + NFE_READ(sc, NFE_TX_OCTET + i); + + if ((sc->nfe_flags & NFE_MIB_V3) != 0) { + NFE_READ(sc, NFE_TX_UNICAST); + NFE_READ(sc, NFE_TX_MULTICAST); + NFE_READ(sc, NFE_TX_BROADCAST); + } +} + +static void +nfe_stats_update(struct nfe_softc *sc) +{ + struct nfe_hw_stats *stats; + + NFE_LOCK_ASSERT(sc); + + if ((sc->nfe_flags & (NFE_MIB_V1 | NFE_MIB_V2 | NFE_MIB_V3)) == 0) + return; + + stats = &sc->nfe_stats; + stats->tx_octets += NFE_READ(sc, NFE_TX_OCTET); + stats->tx_zero_rexmits += NFE_READ(sc, NFE_TX_ZERO_REXMIT); + stats->tx_one_rexmits += NFE_READ(sc, NFE_TX_ONE_REXMIT); + stats->tx_multi_rexmits += NFE_READ(sc, NFE_TX_MULTI_REXMIT); + stats->tx_late_cols += NFE_READ(sc, NFE_TX_LATE_COL); + stats->tx_fifo_underuns += NFE_READ(sc, NFE_TX_FIFO_UNDERUN); + stats->tx_carrier_losts += NFE_READ(sc, NFE_TX_CARRIER_LOST); + stats->tx_excess_deferals += NFE_READ(sc, NFE_TX_EXCESS_DEFERRAL); + stats->tx_retry_errors += NFE_READ(sc, NFE_TX_RETRY_ERROR); + stats->rx_frame_errors += NFE_READ(sc, NFE_RX_FRAME_ERROR); + stats->rx_extra_bytes += NFE_READ(sc, NFE_RX_EXTRA_BYTES); + stats->rx_late_cols += NFE_READ(sc, NFE_RX_LATE_COL); + stats->rx_runts += NFE_READ(sc, NFE_RX_RUNT); + stats->rx_jumbos += NFE_READ(sc, NFE_RX_JUMBO); + stats->rx_fifo_overuns += NFE_READ(sc, NFE_RX_FIFO_OVERUN); + stats->rx_crc_errors += NFE_READ(sc, NFE_RX_CRC_ERROR); + stats->rx_fae += NFE_READ(sc, NFE_RX_FAE); + stats->rx_len_errors += NFE_READ(sc, NFE_RX_LEN_ERROR); + stats->rx_unicast += NFE_READ(sc, NFE_RX_UNICAST); + stats->rx_multicast += NFE_READ(sc, NFE_RX_MULTICAST); + stats->rx_broadcast += NFE_READ(sc, NFE_RX_BROADCAST); + + if ((sc->nfe_flags & NFE_MIB_V2) != 0) { + stats->tx_deferals += NFE_READ(sc, NFE_TX_DEFERAL); + stats->tx_frames += NFE_READ(sc, NFE_TX_FRAME); + stats->rx_octets += NFE_READ(sc, NFE_RX_OCTET); + stats->tx_pause += NFE_READ(sc, NFE_TX_PAUSE); + stats->rx_pause += NFE_READ(sc, NFE_RX_PAUSE); + stats->rx_drops += NFE_READ(sc, NFE_RX_DROP); + } + + if ((sc->nfe_flags & NFE_MIB_V3) != 0) { + stats->tx_unicast += NFE_READ(sc, NFE_TX_UNICAST); + stats->tx_multicast += NFE_READ(sc, NFE_TX_MULTICAST); + stats->rx_broadcast += NFE_READ(sc, NFE_TX_BROADCAST); + } +} Modified: stable/7/sys/dev/nfe/if_nfereg.h ============================================================================== --- stable/7/sys/dev/nfe/if_nfereg.h Wed Mar 18 02:12:33 2009 (r189947) +++ stable/7/sys/dev/nfe/if_nfereg.h Wed Mar 18 02:23:01 2009 (r189948) @@ -87,11 +87,41 @@ #define NFE_PHY_SPEED 0x18c #define NFE_PHY_CTL 0x190 #define NFE_PHY_DATA 0x194 +#define NFE_TX_UNICAST 0x1a0 +#define NFE_TX_MULTICAST 0x1a4 +#define NFE_TX_BROADCAST 0x1a8 #define NFE_WOL_CTL 0x200 #define NFE_PATTERN_CRC 0x204 #define NFE_PATTERN_MASK 0x208 #define NFE_PWR_CAP 0x268 #define NFE_PWR_STATE 0x26c +#define NFE_TX_OCTET 0x280 +#define NFE_TX_ZERO_REXMIT 0x284 +#define NFE_TX_ONE_REXMIT 0x288 +#define NFE_TX_MULTI_REXMIT 0x28c +#define NFE_TX_LATE_COL 0x290 +#define NFE_TX_FIFO_UNDERUN 0x294 +#define NFE_TX_CARRIER_LOST 0x298 +#define NFE_TX_EXCESS_DEFERRAL 0x29c +#define NFE_TX_RETRY_ERROR 0x2a0 +#define NFE_RX_FRAME_ERROR 0x2a4 +#define NFE_RX_EXTRA_BYTES 0x2a8 +#define NFE_RX_LATE_COL 0x2ac +#define NFE_RX_RUNT 0x2b0 +#define NFE_RX_JUMBO 0x2b4 +#define NFE_RX_FIFO_OVERUN 0x2b8 +#define NFE_RX_CRC_ERROR 0x2bc +#define NFE_RX_FAE 0x2c0 +#define NFE_RX_LEN_ERROR 0x2c4 +#define NFE_RX_UNICAST 0x2c8 +#define NFE_RX_MULTICAST 0x2cc +#define NFE_RX_BROADCAST 0x2d0 +#define NFE_TX_DEFERAL 0x2d4 +#define NFE_TX_FRAME 0x2d8 +#define NFE_RX_OCTET 0x2dc +#define NFE_TX_PAUSE 0x2e0 +#define NFE_RX_PAUSE 0x2e4 +#define NFE_RX_DROP 0x2e8 #define NFE_VTAG_CTL 0x300 #define NFE_MSIX_MAP0 0x3e0 #define NFE_MSIX_MAP1 0x3e4 @@ -182,6 +212,10 @@ #define NFE_SEED_100TX 0x00002d00 #define NFE_SEED_1000T 0x00007400 +#define NFE_NUM_MIB_STATV1 21 +#define NFE_NUM_MIB_STATV2 27 +#define NFE_NUM_MIB_STATV3 30 + #define NFE_MSI_MESSAGES 8 #define NFE_MSI_VECTOR_0_ENABLED 0x01 Modified: stable/7/sys/dev/nfe/if_nfevar.h ============================================================================== --- stable/7/sys/dev/nfe/if_nfevar.h Wed Mar 18 02:12:33 2009 (r189947) +++ stable/7/sys/dev/nfe/if_nfevar.h Wed Mar 18 02:23:01 2009 (r189948) @@ -70,6 +70,39 @@ struct nfe_jrx_ring { int jnext; }; +struct nfe_hw_stats { + uint64_t rx_octets; + uint32_t rx_frame_errors; + uint32_t rx_extra_bytes; + uint32_t rx_late_cols; + uint32_t rx_runts; + uint32_t rx_jumbos; + uint32_t rx_fifo_overuns; + uint32_t rx_crc_errors; + uint32_t rx_fae; + uint32_t rx_len_errors; + uint32_t rx_unicast; + uint32_t rx_multicast; + uint32_t rx_broadcast; + uint32_t rx_pause; + uint32_t rx_drops; + uint64_t tx_octets; + uint32_t tx_zero_rexmits; + uint32_t tx_one_rexmits; + uint32_t tx_multi_rexmits; + uint32_t tx_late_cols; + uint32_t tx_fifo_underuns; + uint32_t tx_carrier_losts; + uint32_t tx_excess_deferals; + uint32_t tx_retry_errors; + uint32_t tx_deferals; + uint32_t tx_frames; + uint32_t tx_pause; + uint32_t tx_unicast; + uint32_t tx_multicast; + uint32_t tx_broadcast; +}; + struct nfe_softc { struct ifnet *nfe_ifp; device_t nfe_dev; @@ -96,10 +129,14 @@ struct nfe_softc { #define NFE_PWR_MGMT 0x0010 #define NFE_CORRECT_MACADDR 0x0020 #define NFE_TX_FLOW_CTRL 0x0040 +#define NFE_MIB_V1 0x0080 +#define NFE_MIB_V2 0x0100 +#define NFE_MIB_V3 0x0200 int nfe_jumbo_disable; uint32_t rxtxctl; uint8_t mii_phyaddr; uint8_t eaddr[ETHER_ADDR_LEN]; + struct nfe_hw_stats nfe_stats; struct taskqueue *nfe_tq; struct task nfe_int_task; struct task nfe_tx_task; From yongari at FreeBSD.org Tue Mar 17 19:26:48 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 19:28:13 2009 Subject: svn commit: r189949 - stable/7/share/man/man4 Message-ID: <200903180226.n2I2QkPe012722@svn.freebsd.org> Author: yongari Date: Wed Mar 18 02:26:46 2009 New Revision: 189949 URL: http://svn.freebsd.org/changeset/base/189949 Log: MFC r188382: Document loader tunable hw.re.msi_disable. Bump .Dd Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/igb.4 (props changed) stable/7/share/man/man4/re.4 Modified: stable/7/share/man/man4/re.4 ============================================================================== --- stable/7/share/man/man4/re.4 Wed Mar 18 02:23:01 2009 (r189948) +++ stable/7/share/man/man4/re.4 Wed Mar 18 02:26:46 2009 (r189949) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 14, 2006 +.Dd February 9, 2009 .Dt RE 4 .Os .Sh NAME @@ -169,6 +169,16 @@ USRobotics USR997902 Gigabit Ethernet (8 .It Xterasys XN-152 10/100/1000 NIC (8169) .El +.Sh LOADER TUNABLES +Tunables can be set at the +.Xr loader 8 +prompt before booting the kernel or stored in +.Xr loader.conf 5 . +.Bl -tag -width "xxxxxx" +.It Va hw.re.msi_disable +This tunable disables MSI support on the Ethernet hardware. +The default value is 0. +.El .Sh DIAGNOSTICS .Bl -diag .It "re%d: couldn't map memory" From yongari at FreeBSD.org Tue Mar 17 20:29:06 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 20:29:23 2009 Subject: svn commit: r189951 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/mii Message-ID: <200903180329.n2I3T5NK014255@svn.freebsd.org> Author: yongari Date: Wed Mar 18 03:29:05 2009 New Revision: 189951 URL: http://svn.freebsd.org/changeset/base/189951 Log: MFC r189564: Report current link state while auto-negotiation is in progress. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/mii/ip1000phy.c Modified: stable/7/sys/dev/mii/ip1000phy.c ============================================================================== --- stable/7/sys/dev/mii/ip1000phy.c Wed Mar 18 02:38:35 2009 (r189950) +++ stable/7/sys/dev/mii/ip1000phy.c Wed Mar 18 03:29:05 2009 (r189951) @@ -296,7 +296,7 @@ done: * Only retry autonegotiation every mii_anegticks seconds. */ if (sc->mii_ticks <= sc->mii_anegticks) - return (0); + break; sc->mii_ticks = 0; ip1000phy_mii_phy_auto(sc); From yongari at FreeBSD.org Tue Mar 17 20:31:20 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 20:31:27 2009 Subject: svn commit: r189952 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/mii Message-ID: <200903180331.n2I3VJ2E014354@svn.freebsd.org> Author: yongari Date: Wed Mar 18 03:31:19 2009 New Revision: 189952 URL: http://svn.freebsd.org/changeset/base/189952 Log: MFC r189565: For unknown speed, explicitly set IFM_NONE. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/mii/ip1000phy.c Modified: stable/7/sys/dev/mii/ip1000phy.c ============================================================================== --- stable/7/sys/dev/mii/ip1000phy.c Wed Mar 18 03:29:05 2009 (r189951) +++ stable/7/sys/dev/mii/ip1000phy.c Wed Mar 18 03:31:19 2009 (r189952) @@ -353,6 +353,9 @@ ip1000phy_status(struct mii_softc *sc) case IP1000PHY_LSR_SPEED_1000: mii->mii_media_active |= IFM_1000_T; break; + default: + mii->mii_media_active |= IFM_NONE; + return; } if ((stat & IP1000PHY_LSR_FULL_DUPLEX) != 0) mii->mii_media_active |= IFM_FDX; @@ -373,6 +376,9 @@ ip1000phy_status(struct mii_softc *sc) case PC_LinkSpeed_1000: mii->mii_media_active |= IFM_1000_T; break; + default: + mii->mii_media_active |= IFM_NONE; + return; } if ((stat & PC_PhyDuplexStatus) != 0) mii->mii_media_active |= IFM_FDX; From yongari at FreeBSD.org Tue Mar 17 20:33:46 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 20:33:53 2009 Subject: svn commit: r189953 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/mii Message-ID: <200903180333.n2I3Xj2L014457@svn.freebsd.org> Author: yongari Date: Wed Mar 18 03:33:45 2009 New Revision: 189953 URL: http://svn.freebsd.org/changeset/base/189953 Log: MFC r189566: Use mii_phy_add_media() and remove setting each media type. While I'm here, don't set mii_anegticks as it's set by mii_phy_add_media(). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/mii/ip1000phy.c Modified: stable/7/sys/dev/mii/ip1000phy.c ============================================================================== --- stable/7/sys/dev/mii/ip1000phy.c Wed Mar 18 03:31:19 2009 (r189952) +++ stable/7/sys/dev/mii/ip1000phy.c Wed Mar 18 03:33:45 2009 (r189953) @@ -118,7 +118,6 @@ ip1000phy_attach(device_t dev) sc->mii_phy = ma->mii_phyno; sc->mii_service = ip1000phy_service; sc->mii_pdata = mii; - sc->mii_anegticks = MII_ANEGTICKS_GIGE; sc->mii_flags |= MIIF_NOISOLATE; mii->mii_instance++; @@ -126,37 +125,14 @@ ip1000phy_attach(device_t dev) isc->model = MII_MODEL(ma->mii_id2); isc->revision = MII_REV(ma->mii_id2); + sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; + if (sc->mii_capabilities & BMSR_EXTSTAT) + sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); device_printf(dev, " "); -#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL) - - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), - BMCR_ISO); - - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst), - IP1000PHY_BMCR_10); - printf("10baseT, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_FDX, sc->mii_inst), - IP1000PHY_BMCR_10 | IP1000PHY_BMCR_FDX); - printf("10baseT-FDX, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, sc->mii_inst), - IP1000PHY_BMCR_100); - printf("100baseTX, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_FDX, sc->mii_inst), - IP1000PHY_BMCR_100 | IP1000PHY_BMCR_FDX); - printf("100baseTX-FDX, "); - /* 1000baseT half-duplex, really supported? */ - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, 0, sc->mii_inst), - IP1000PHY_BMCR_1000); - printf("1000baseTX, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_T, IFM_FDX, sc->mii_inst), - IP1000PHY_BMCR_1000 | IP1000PHY_BMCR_FDX); - printf("1000baseTX-FDX, "); - ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst), 0); - printf("auto\n"); -#undef ADD - ip1000phy_reset(sc); + mii_phy_add_media(sc); + printf("\n"); MIIBUS_MEDIAINIT(sc->mii_dev); return(0); From yongari at FreeBSD.org Tue Mar 17 20:36:10 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Mar 17 20:36:16 2009 Subject: svn commit: r189954 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/mii Message-ID: <200903180336.n2I3a80G014550@svn.freebsd.org> Author: yongari Date: Wed Mar 18 03:36:08 2009 New Revision: 189954 URL: http://svn.freebsd.org/changeset/base/189954 Log: MFC r189567: For IP1001 PHYs, read auto-negotiation advertisement register to get default next page configuration. While I'm here explicitly set IP1000PHY_ANAR_CSMA bit. This bit is read-only and always set by hardware so setting it has no effect but it would clear the intention. With this change controllers that couldn't establish 1000baseT link should work. PR: kern/130846 Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/mii/ip1000phy.c stable/7/sys/dev/mii/ip1000phyreg.h Modified: stable/7/sys/dev/mii/ip1000phy.c ============================================================================== --- stable/7/sys/dev/mii/ip1000phy.c Wed Mar 18 03:33:45 2009 (r189953) +++ stable/7/sys/dev/mii/ip1000phy.c Wed Mar 18 03:36:08 2009 (r189954) @@ -391,18 +391,24 @@ ip1000phy_status(struct mii_softc *sc) } static int -ip1000phy_mii_phy_auto(struct mii_softc *mii) +ip1000phy_mii_phy_auto(struct mii_softc *sc) { + struct ip1000phy_softc *isc; uint32_t reg; - PHY_WRITE(mii, IP1000PHY_MII_ANAR, - IP1000PHY_ANAR_10T | IP1000PHY_ANAR_10T_FDX | + isc = (struct ip1000phy_softc *)sc; + reg = 0; + if (isc->model == MII_MODEL_ICPLUS_IP1001) + reg = PHY_READ(sc, IP1000PHY_MII_ANAR); + reg |= IP1000PHY_ANAR_10T | IP1000PHY_ANAR_10T_FDX | IP1000PHY_ANAR_100TX | IP1000PHY_ANAR_100TX_FDX | - IP1000PHY_ANAR_PAUSE | IP1000PHY_ANAR_APAUSE); + IP1000PHY_ANAR_PAUSE | IP1000PHY_ANAR_APAUSE; + PHY_WRITE(sc, IP1000PHY_MII_ANAR, reg | IP1000PHY_ANAR_CSMA); + reg = IP1000PHY_1000CR_1000T | IP1000PHY_1000CR_1000T_FDX; reg |= IP1000PHY_1000CR_MASTER; - PHY_WRITE(mii, IP1000PHY_MII_1000CR, reg); - PHY_WRITE(mii, IP1000PHY_MII_BMCR, (IP1000PHY_BMCR_FDX | + PHY_WRITE(sc, IP1000PHY_MII_1000CR, reg); + PHY_WRITE(sc, IP1000PHY_MII_BMCR, (IP1000PHY_BMCR_FDX | IP1000PHY_BMCR_AUTOEN | IP1000PHY_BMCR_STARTNEG)); return (EJUSTRETURN); Modified: stable/7/sys/dev/mii/ip1000phyreg.h ============================================================================== --- stable/7/sys/dev/mii/ip1000phyreg.h Wed Mar 18 03:33:45 2009 (r189953) +++ stable/7/sys/dev/mii/ip1000phyreg.h Wed Mar 18 03:36:08 2009 (r189954) @@ -61,6 +61,7 @@ /* Autonegotiation advertisement register */ #define IP1000PHY_MII_ANAR 0x04 +#define IP1000PHY_ANAR_CSMA 0x0001 #define IP1000PHY_ANAR_10T 0x0020 #define IP1000PHY_ANAR_10T_FDX 0x0040 #define IP1000PHY_ANAR_100TX 0x0080 From bz at FreeBSD.org Wed Mar 18 04:30:48 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Wed Mar 18 04:31:00 2009 Subject: svn commit: r189956 - in stable/7: . sys sys/contrib/pf sys/dev/ath/ath_hal sys/dev/cxgb sys/netinet sys/netinet6 Message-ID: <200903181130.n2IBUlaH025146@svn.freebsd.org> Author: bz Date: Wed Mar 18 11:30:47 2009 New Revision: 189956 URL: http://svn.freebsd.org/changeset/base/189956 Log: MFC r184096: Bring over the change switching from using sequential to random ephemeral port allocation as implemented in netinet/in_pcb.c rev. 1.143 (initially from OpenBSD) and follow-up commits during the last four and a half years including rev. 1.157, 1.162 and 1.199. This now is relying on the same infrastructure as has been implemented in in_pcb.c since rev. 1.199. Reviewed by: rwatson (UPDATING) Modified: stable/7/UPDATING stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netinet/in_pcb.h stable/7/sys/netinet6/in6_src.c Modified: stable/7/UPDATING ============================================================================== --- stable/7/UPDATING Wed Mar 18 03:56:26 2009 (r189955) +++ stable/7/UPDATING Wed Mar 18 11:30:47 2009 (r189956) @@ -8,6 +8,13 @@ Items affecting the ports and packages s /usr/ports/UPDATING. Please read that file before running portupgrade. +20090318: + Change IPv6 ephemeral port allocation from sequential to + random allocation, like IPv4 has done for more than four years. + The implementation shares infrastructure with IPv4. This + means that there is only one set of sysctls to control both + IPv4 and IPv6. See ip(4) man page for details. + 20090312: A workaround is committed to allow the creation of System V shared memory segment of size > 2 GB on the 64-bit architectures. Modified: stable/7/sys/netinet/in_pcb.h ============================================================================== --- stable/7/sys/netinet/in_pcb.h Wed Mar 18 03:56:26 2009 (r189955) +++ stable/7/sys/netinet/in_pcb.h Wed Mar 18 11:30:47 2009 (r189956) @@ -483,6 +483,9 @@ extern int ipport_firstauto; extern int ipport_lastauto; extern int ipport_hifirstauto; extern int ipport_hilastauto; +extern int ipport_randomized; +extern int ipport_stoprandom; +extern int ipport_tcpallocs; extern struct callout ipport_tick_callout; void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *); Modified: stable/7/sys/netinet6/in6_src.c ============================================================================== --- stable/7/sys/netinet6/in6_src.c Wed Mar 18 03:56:26 2009 (r189955) +++ stable/7/sys/netinet6/in6_src.c Wed Mar 18 11:30:47 2009 (r189956) @@ -91,6 +91,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include #include @@ -774,7 +777,7 @@ in6_pcbsetport(struct in6_addr *laddr, s { struct socket *so = inp->inp_socket; u_int16_t lport = 0, first, last, *lastport; - int count, error, wild = 0; + int count, error, wild = 0, dorandom; struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; INP_INFO_WLOCK_ASSERT(pcbinfo); @@ -807,56 +810,58 @@ in6_pcbsetport(struct in6_addr *laddr, s last = ipport_lastauto; lastport = &pcbinfo->ipi_lastport; } + /* - * Simple check to ensure all ports are not used up causing - * a deadlock here. - * - * We split the two cases (up and down) so that the direction - * is not being tested on each round of the loop. + * For UDP, use random port allocation as long as the user + * allows it. For TCP (and as of yet unknown) connections, + * use random port allocation only if the user allows it AND + * ipport_tick() allows it. */ - if (first > last) { - /* - * counting down - */ - count = first - last; + if (ipport_randomized && + (!ipport_stoprandom || pcbinfo == &udbinfo)) + dorandom = 1; + else + dorandom = 0; + /* + * It makes no sense to do random port allocation if + * we have the only port available. + */ + if (first == last) + dorandom = 0; + /* Make sure to not include UDP packets in the count. */ + if (pcbinfo != &udbinfo) + ipport_tcpallocs++; - do { - if (count-- < 0) { /* completely used? */ - /* - * Undo any address bind that may have - * occurred above. - */ - inp->in6p_laddr = in6addr_any; - return (EAGAIN); - } - --*lastport; - if (*lastport > first || *lastport < last) - *lastport = first; - lport = htons(*lastport); - } while (in6_pcblookup_local(pcbinfo, &inp->in6p_laddr, - lport, wild, cred)); - } else { - /* - * counting up - */ - count = last - first; + /* + * Instead of having two loops further down counting up or down + * make sure that first is always <= last and go with only one + * code path implementing all logic. + */ + if (first > last) { + u_int16_t aux; - do { - if (count-- < 0) { /* completely used? */ - /* - * Undo any address bind that may have - * occurred above. - */ - inp->in6p_laddr = in6addr_any; - return (EAGAIN); - } - ++*lastport; - if (*lastport < first || *lastport > last) - *lastport = first; - lport = htons(*lastport); - } while (in6_pcblookup_local(pcbinfo, &inp->in6p_laddr, - lport, wild, cred)); - } + aux = first; + first = last; + last = aux; + } + + if (dorandom) + *lastport = first + (arc4random() % (last - first)); + + count = last - first; + + do { + if (count-- < 0) { /* completely used? */ + /* Undo an address bind that may have occurred. */ + inp->in6p_laddr = in6addr_any; + return (EADDRNOTAVAIL); + } + ++*lastport; + if (*lastport < first || *lastport > last) + *lastport = first; + lport = htons(*lastport); + } while (in6_pcblookup_local(pcbinfo, &inp->in6p_laddr, + lport, wild, cred)); inp->inp_lport = lport; if (in_pcbinshash(inp) != 0) { From bz at FreeBSD.org Wed Mar 18 05:25:42 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Wed Mar 18 05:25:58 2009 Subject: svn commit: r189957 - in stable/7/sys: . contrib/pf dev/cxgb kern Message-ID: <200903181225.n2ICPffj026168@svn.freebsd.org> Author: bz Date: Wed Mar 18 12:25:40 2009 New Revision: 189957 URL: http://svn.freebsd.org/changeset/base/189957 Log: MFC r185583: Fix a credential reference leak. [1] Close subtle but relatively unlikely race conditions when propagating the vnode write error to other active sessions tracing to the same vnode, without holding a reference on the vnode anymore. [2] PR: kern/126368 [1] Submitted by: rwatson [2] Reviewed by: kib, rwatson Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/kern_ktrace.c Modified: stable/7/sys/kern/kern_ktrace.c ============================================================================== --- stable/7/sys/kern/kern_ktrace.c Wed Mar 18 11:30:47 2009 (r189956) +++ stable/7/sys/kern/kern_ktrace.c Wed Mar 18 12:25:40 2009 (r189957) @@ -907,12 +907,7 @@ ktr_writerequest(struct thread *td, stru */ mtx_lock(&ktrace_mtx); vp = td->td_proc->p_tracevp; - if (vp != NULL) - VREF(vp); cred = td->td_proc->p_tracecred; - if (cred != NULL) - crhold(cred); - mtx_unlock(&ktrace_mtx); /* * If vp is NULL, the vp has been cleared out from under this @@ -921,9 +916,13 @@ ktr_writerequest(struct thread *td, stru */ if (vp == NULL) { KASSERT(cred == NULL, ("ktr_writerequest: cred != NULL")); + mtx_unlock(&ktrace_mtx); return; } + VREF(vp); KASSERT(cred != NULL, ("ktr_writerequest: cred == NULL")); + crhold(cred); + mtx_unlock(&ktrace_mtx); kth = &req->ktr_header; datalen = data_lengths[(u_short)kth->ktr_type & ~KTR_DROP]; @@ -963,18 +962,26 @@ ktr_writerequest(struct thread *td, stru error = VOP_WRITE(vp, &auio, IO_UNIT | IO_APPEND, cred); VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); - vrele(vp); - VFS_UNLOCK_GIANT(vfslocked); - if (!error) + crfree(cred); + if (!error) { + vrele(vp); + VFS_UNLOCK_GIANT(vfslocked); return; + } + VFS_UNLOCK_GIANT(vfslocked); + /* * If error encountered, give up tracing on this vnode. We defer * all the vrele()'s on the vnode until after we are finished walking * the various lists to avoid needlessly holding locks. + * NB: at this point we still hold the vnode reference that must + * not go away as we need the valid vnode to compare with. Thus let + * vrele_count start at 1 and the reference will be freed + * by the loop at the end after our last use of vp. */ log(LOG_NOTICE, "ktrace write failed, errno %d, tracing stopped\n", error); - vrele_count = 0; + vrele_count = 1; /* * First, clear this vnode from being used by any processes in the * system. From kib at FreeBSD.org Wed Mar 18 06:19:48 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Wed Mar 18 06:19:55 2009 Subject: svn commit: r189958 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/devfs Message-ID: <200903181319.n2IDJlrj027222@svn.freebsd.org> Author: kib Date: Wed Mar 18 13:19:46 2009 New Revision: 189958 URL: http://svn.freebsd.org/changeset/base/189958 Log: MFC r189693: Enable advisory file locking for devfs vnodes. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/devfs/devfs_vnops.c Modified: stable/7/sys/fs/devfs/devfs_vnops.c ============================================================================== --- stable/7/sys/fs/devfs/devfs_vnops.c Wed Mar 18 12:25:40 2009 (r189957) +++ stable/7/sys/fs/devfs/devfs_vnops.c Wed Mar 18 13:19:46 2009 (r189958) @@ -387,14 +387,6 @@ devfs_access(struct vop_access_args *ap) /* ARGSUSED */ static int -devfs_advlock(struct vop_advlock_args *ap) -{ - - return (ap->a_flags & F_FLOCK ? EOPNOTSUPP : EINVAL); -} - -/* ARGSUSED */ -static int devfs_close(struct vop_close_args *ap) { struct vnode *vp = ap->a_vp, *oldvp; @@ -1501,7 +1493,6 @@ static struct vop_vector devfs_specops = .vop_default = &default_vnodeops, .vop_access = devfs_access, - .vop_advlock = devfs_advlock, .vop_bmap = VOP_PANIC, .vop_close = devfs_close, .vop_create = VOP_PANIC, From bz at FreeBSD.org Wed Mar 18 06:47:46 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Wed Mar 18 06:47:57 2009 Subject: svn commit: r189960 - in stable/7/sys: . contrib/pf dev/cxgb kern Message-ID: <200903181347.n2IDljQN027812@svn.freebsd.org> Author: bz Date: Wed Mar 18 13:47:44 2009 New Revision: 189960 URL: http://svn.freebsd.org/changeset/base/189960 Log: MFC r185893: Make sure nmbclusters are initialized before maxsockets by running the tunable_mbinit() SYSINIT at SI_ORDER_MIDDLE before the init_maxsockets() SYSINT at SI_ORDER_ANY. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/kern_mbuf.c stable/7/sys/kern/uipc_socket.c Modified: stable/7/sys/kern/kern_mbuf.c ============================================================================== --- stable/7/sys/kern/kern_mbuf.c Wed Mar 18 13:40:37 2009 (r189959) +++ stable/7/sys/kern/kern_mbuf.c Wed Mar 18 13:47:44 2009 (r189960) @@ -101,6 +101,11 @@ int nmbjumbo9; /* limits number of 9k int nmbjumbo16; /* limits number of 16k jumbo clusters */ struct mbstat mbstat; +/* + * tunable_mbinit() has to be run before init_maxsockets() thus + * the SYSINIT order below is SI_ORDER_MIDDLE while init_maxsockets() + * runs at SI_ORDER_ANY. + */ static void tunable_mbinit(void *dummy) { @@ -112,7 +117,7 @@ tunable_mbinit(void *dummy) nmbjumbo16 = nmbjumbo9 / 2; TUNABLE_INT_FETCH("kern.ipc.nmbclusters", &nmbclusters); } -SYSINIT(tunable_mbinit, SI_SUB_TUNABLES, SI_ORDER_ANY, tunable_mbinit, NULL); +SYSINIT(tunable_mbinit, SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_mbinit, NULL); /* XXX: These should be tuneables. Can't change UMA limits on the fly. */ static int Modified: stable/7/sys/kern/uipc_socket.c ============================================================================== --- stable/7/sys/kern/uipc_socket.c Wed Mar 18 13:40:37 2009 (r189959) +++ stable/7/sys/kern/uipc_socket.c Wed Mar 18 13:47:44 2009 (r189960) @@ -237,7 +237,8 @@ SYSCTL_PROC(_kern_ipc, OID_AUTO, maxsock "Maximum number of sockets avaliable"); /* - * Initialise maxsockets. + * Initialise maxsockets. This SYSINIT must be run after + * tunable_mbinit(). */ static void init_maxsockets(void *ignored) { From bz at FreeBSD.org Wed Mar 18 07:36:50 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Wed Mar 18 07:36:56 2009 Subject: svn commit: r189964 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netinet netinet6 Message-ID: <200903181436.n2IEanvr028924@svn.freebsd.org> Author: bz Date: Wed Mar 18 14:36:49 2009 New Revision: 189964 URL: http://svn.freebsd.org/changeset/base/189964 Log: MFC r185333: Unify the v4 and v6 versions of pcbdetach and pcbfree as good as possible so that they are easily diffable. No functional changes. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netinet/in_pcb.c stable/7/sys/netinet6/in6_pcb.c Modified: stable/7/sys/netinet/in_pcb.c ============================================================================== --- stable/7/sys/netinet/in_pcb.c Wed Mar 18 14:33:10 2009 (r189963) +++ stable/7/sys/netinet/in_pcb.c Wed Mar 18 14:36:49 2009 (r189964) @@ -880,7 +880,7 @@ void in_pcbdetach(struct inpcb *inp) { - KASSERT(inp->inp_socket != NULL, ("in_pcbdetach: inp_socket == NULL")); + KASSERT(inp->inp_socket != NULL, ("%s: inp_socket == NULL", __func__)); inp->inp_socket->so_pcb = NULL; inp->inp_socket = NULL; @@ -895,14 +895,14 @@ in_pcbfree(struct inpcb *inp) { struct inpcbinfo *ipi = inp->inp_pcbinfo; - KASSERT(inp->inp_socket == NULL, ("in_pcbfree: inp_socket != NULL")); + KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); INP_INFO_WLOCK_ASSERT(ipi); INP_WLOCK_ASSERT(inp); #ifdef IPSEC ipsec4_delete_pcbpolicy(inp); -#endif /*IPSEC*/ +#endif /* IPSEC */ inp->inp_gencnt = ++ipi->ipi_gencnt; in_pcbremlists(inp); if (inp->inp_options) Modified: stable/7/sys/netinet6/in6_pcb.c ============================================================================== --- stable/7/sys/netinet6/in6_pcb.c Wed Mar 18 14:33:10 2009 (r189963) +++ stable/7/sys/netinet6/in6_pcb.c Wed Mar 18 14:36:49 2009 (r189964) @@ -416,7 +416,8 @@ void in6_pcbdetach(struct inpcb *inp) { - KASSERT(inp->inp_socket != NULL, ("in6_pcbdetach: inp_socket == NULL")); + KASSERT(inp->inp_socket != NULL, ("%s: inp_socket == NULL", __func__)); + inp->inp_socket->so_pcb = NULL; inp->inp_socket = NULL; } @@ -426,8 +427,9 @@ in6_pcbfree(struct inpcb *inp) { struct inpcbinfo *ipi = inp->inp_pcbinfo; - KASSERT(inp->inp_socket == NULL, ("in6_pcbfree: inp_socket != NULL")); - INP_INFO_WLOCK_ASSERT(inp->inp_pcbinfo); + KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); + + INP_INFO_WLOCK_ASSERT(ipi); INP_WLOCK_ASSERT(inp); #ifdef IPSEC @@ -445,6 +447,7 @@ in6_pcbfree(struct inpcb *inp) inp_freemoptions(inp->inp_moptions); inp->inp_vflag = 0; crfree(inp->inp_cred); + #ifdef MAC mac_destroy_inpcb(inp); #endif From bz at FreeBSD.org Wed Mar 18 07:43:57 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Wed Mar 18 07:44:08 2009 Subject: svn commit: r189965 - in stable/7/sys: . contrib/pf dev/cxgb kern Message-ID: <200903181443.n2IEhud4029096@svn.freebsd.org> Author: bz Date: Wed Mar 18 14:43:56 2009 New Revision: 189965 URL: http://svn.freebsd.org/changeset/base/189965 Log: MFC r185892: Style changes only. Put the return type on an extra line[1] and add an empty line at the beginning as we do not have any local variables. Submitted by: rwatson [1] Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/uipc_socket.c Modified: stable/7/sys/kern/uipc_socket.c ============================================================================== --- stable/7/sys/kern/uipc_socket.c Wed Mar 18 14:36:49 2009 (r189964) +++ stable/7/sys/kern/uipc_socket.c Wed Mar 18 14:43:56 2009 (r189965) @@ -240,8 +240,10 @@ SYSCTL_PROC(_kern_ipc, OID_AUTO, maxsock * Initialise maxsockets. This SYSINIT must be run after * tunable_mbinit(). */ -static void init_maxsockets(void *ignored) +static void +init_maxsockets(void *ignored) { + TUNABLE_INT_FETCH("kern.ipc.maxsockets", &maxsockets); maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters)); } From bz at FreeBSD.org Wed Mar 18 09:09:06 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Wed Mar 18 09:09:24 2009 Subject: svn commit: r189966 - in stable/7/sys: . contrib/pf dev/cxgb dev/cxgb/ulp/tom netinet netinet6 Message-ID: <200903181609.n2IG95Jf030784@svn.freebsd.org> Author: bz Date: Wed Mar 18 16:09:05 2009 New Revision: 189966 URL: http://svn.freebsd.org/changeset/base/189966 Log: MFC r186222: Use inc_flags instead of the inc_isipv6 alias which so far had been the only flag with random usage patterns. Switch inc_flags to be used as a real bit field by using INC_ISIPV6 with bitops to check for the 'isipv6' condition. While here fix a place or two where in case of v4 inc_flags were not properly initialized before.[1] Found by: rwatson during review [1] Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c stable/7/sys/netinet/in_pcb.c stable/7/sys/netinet/in_pcb.h stable/7/sys/netinet/tcp_hostcache.c stable/7/sys/netinet/tcp_input.c stable/7/sys/netinet/tcp_subr.c stable/7/sys/netinet/tcp_syncache.c stable/7/sys/netinet/tcp_timewait.c stable/7/sys/netinet/tcp_usrreq.c stable/7/sys/netinet6/icmp6.c stable/7/sys/netinet6/ip6_output.c Modified: stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c ============================================================================== --- stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Wed Mar 18 16:09:05 2009 (r189966) @@ -3270,8 +3270,6 @@ syncache_add_accept_req(struct cpl_pass_ toep->tp_iss = toep->tp_delack_seq = toep->tp_rcv_wup = toep->tp_copied_seq = rcv_isn + 1; - - inc.inc_isipv6 = 0; inc.inc_len = 0; inc.inc_faddr.s_addr = req->peer_ip; inc.inc_laddr.s_addr = req->local_ip; @@ -3611,7 +3609,6 @@ syncache_expand_establish_req(struct cpl th.th_seq = req->rcv_isn; th.th_flags = TH_ACK; - inc.inc_isipv6 = 0; inc.inc_len = 0; inc.inc_faddr.s_addr = req->peer_ip; inc.inc_laddr.s_addr = req->local_ip; Modified: stable/7/sys/netinet/in_pcb.c ============================================================================== --- stable/7/sys/netinet/in_pcb.c Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/netinet/in_pcb.c Wed Mar 18 16:09:05 2009 (r189966) @@ -1622,7 +1622,7 @@ db_print_inconninfo(struct in_conninfo * indent += 2; #ifdef INET6 - if (inc->inc_flags == 1) { + if (inc->inc_flags & INC_ISIPV6) { /* IPv6. */ ip6_sprintf(laddr_str, &inc->inc6_laddr); ip6_sprintf(faddr_str, &inc->inc6_faddr); Modified: stable/7/sys/netinet/in_pcb.h ============================================================================== --- stable/7/sys/netinet/in_pcb.h Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/netinet/in_pcb.h Wed Mar 18 16:09:05 2009 (r189966) @@ -106,6 +106,12 @@ struct in_conninfo { /* protocol dependent part */ struct in_endpoints inc_ie; }; + +/* + * Flags for inc_flags. + */ +#define INC_ISIPV6 0x01 + #define inc_isipv6 inc_flags /* temp compatability */ #define inc_fport inc_ie.ie_fport #define inc_lport inc_ie.ie_lport Modified: stable/7/sys/netinet/tcp_hostcache.c ============================================================================== --- stable/7/sys/netinet/tcp_hostcache.c Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/netinet/tcp_hostcache.c Wed Mar 18 16:09:05 2009 (r189966) @@ -276,7 +276,7 @@ tcp_hc_lookup(struct in_conninfo *inc) /* * Hash the foreign ip address. */ - if (inc->inc_isipv6) + if (inc->inc_flags & INC_ISIPV6) hash = HOSTCACHE_HASH6(&inc->inc6_faddr); else hash = HOSTCACHE_HASH(&inc->inc_faddr); @@ -294,7 +294,7 @@ tcp_hc_lookup(struct in_conninfo *inc) * Iterate through entries in bucket row looking for a match. */ TAILQ_FOREACH(hc_entry, &hc_head->hch_bucket, rmx_q) { - if (inc->inc_isipv6) { + if (inc->inc_flags & INC_ISIPV6) { if (memcmp(&inc->inc6_faddr, &hc_entry->ip6, sizeof(inc->inc6_faddr)) == 0) return hc_entry; @@ -331,7 +331,7 @@ tcp_hc_insert(struct in_conninfo *inc) /* * Hash the foreign ip address. */ - if (inc->inc_isipv6) + if (inc->inc_flags & INC_ISIPV6) hash = HOSTCACHE_HASH6(&inc->inc6_faddr); else hash = HOSTCACHE_HASH(&inc->inc_faddr); @@ -386,7 +386,7 @@ tcp_hc_insert(struct in_conninfo *inc) * Initialize basic information of hostcache entry. */ bzero(hc_entry, sizeof(*hc_entry)); - if (inc->inc_isipv6) + if (inc->inc_flags & INC_ISIPV6) bcopy(&inc->inc6_faddr, &hc_entry->ip6, sizeof(hc_entry->ip6)); else hc_entry->ip4 = inc->inc_faddr; Modified: stable/7/sys/netinet/tcp_input.c ============================================================================== --- stable/7/sys/netinet/tcp_input.c Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/netinet/tcp_input.c Wed Mar 18 16:09:05 2009 (r189966) @@ -564,9 +564,9 @@ findpcb: "tp not listening", __func__)); bzero(&inc, sizeof(inc)); - inc.inc_isipv6 = isipv6; #ifdef INET6 if (isipv6) { + inc.inc_flags |= INC_ISIPV6; inc.inc6_faddr = ip6->ip6_src; inc.inc6_laddr = ip6->ip6_dst; } else @@ -2974,14 +2974,11 @@ tcp_mssopt(struct in_conninfo *inc) u_long maxmtu = 0; u_long thcmtu = 0; size_t min_protoh; -#ifdef INET6 - int isipv6 = inc->inc_isipv6 ? 1 : 0; -#endif KASSERT(inc != NULL, ("tcp_mssopt with NULL in_conninfo pointer")); #ifdef INET6 - if (isipv6) { + if (inc->inc_flags & INC_ISIPV6) { mss = tcp_v6mssdflt; maxmtu = tcp_maxmtu6(inc, NULL); thcmtu = tcp_hc_getmtu(inc); /* IPv4 and IPv6 */ Modified: stable/7/sys/netinet/tcp_subr.c ============================================================================== --- stable/7/sys/netinet/tcp_subr.c Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/netinet/tcp_subr.c Wed Mar 18 16:09:05 2009 (r189966) @@ -1191,7 +1191,6 @@ tcp_ctlinput(int cmd, struct sockaddr *s * value (if given) and then notify. */ bzero(&inc, sizeof(inc)); - inc.inc_flags = 0; /* IPv4 */ inc.inc_faddr = faddr; inc.inc_fibnum = inp->inp_inc.inc_fibnum; @@ -1228,13 +1227,11 @@ tcp_ctlinput(int cmd, struct sockaddr *s if (inp != NULL) INP_WUNLOCK(inp); } else { + bzero(&inc, sizeof(inc)); inc.inc_fport = th->th_dport; inc.inc_lport = th->th_sport; inc.inc_faddr = faddr; inc.inc_laddr = ip->ip_src; -#ifdef INET6 - inc.inc_isipv6 = 0; -#endif syncache_unreach(&inc, th); } INP_INFO_WUNLOCK(&tcbinfo); @@ -1303,11 +1300,12 @@ tcp6_ctlinput(int cmd, struct sockaddr * (struct sockaddr *)ip6cp->ip6c_src, th.th_sport, cmd, NULL, notify); + bzero(&inc, sizeof(inc)); inc.inc_fport = th.th_dport; inc.inc_lport = th.th_sport; inc.inc6_faddr = ((struct sockaddr_in6 *)sa)->sin6_addr; inc.inc6_laddr = ip6cp->ip6c_src->sin6_addr; - inc.inc_isipv6 = 1; + inc.inc_flags |= INC_ISIPV6; INP_INFO_WLOCK(&tcbinfo); syncache_unreach(&inc, &th); INP_INFO_WUNLOCK(&tcbinfo); @@ -2188,7 +2186,7 @@ tcp_log_addrs(struct in_conninfo *inc, s strcat(s, "TCP: ["); sp = s + strlen(s); - if (inc && inc->inc_isipv6 == 0) { + if (inc && ((inc->inc_flags & INC_ISIPV6) == 0)) { inet_ntoa_r(inc->inc_faddr, sp); sp = s + strlen(s); sprintf(sp, "]:%i to [", ntohs(inc->inc_fport)); Modified: stable/7/sys/netinet/tcp_syncache.c ============================================================================== --- stable/7/sys/netinet/tcp_syncache.c Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/netinet/tcp_syncache.c Wed Mar 18 16:09:05 2009 (r189966) @@ -474,7 +474,7 @@ syncache_lookup(struct in_conninfo *inc, struct syncache_head *sch; #ifdef INET6 - if (inc->inc_isipv6) { + if (inc->inc_flags & INC_ISIPV6) { sch = &tcp_syncache.hashbase[ SYNCACHE_HASH6(inc, tcp_syncache.hashmask)]; *schp = sch; @@ -498,7 +498,7 @@ syncache_lookup(struct in_conninfo *inc, /* Circle through bucket row to find matching entry. */ TAILQ_FOREACH(sc, &sch->sch_bucket, sc_hash) { #ifdef INET6 - if (sc->sc_inc.inc_isipv6) + if (sc->sc_inc.inc_flags & INC_ISIPV6) continue; #endif if (ENDPTS_EQ(&inc->inc_ie, &sc->sc_inc.inc_ie)) @@ -683,9 +683,9 @@ syncache_socket(struct syncache *sc, str INP_WLOCK(inp); /* Insert new socket into PCB hash list. */ - inp->inp_inc.inc_isipv6 = sc->sc_inc.inc_isipv6; + inp->inp_inc.inc_flags = sc->sc_inc.inc_flags; #ifdef INET6 - if (sc->sc_inc.inc_isipv6) { + if (sc->sc_inc.inc_flags & INC_ISIPV6) { inp->in6p_laddr = sc->sc_inc.inc6_laddr; } else { inp->inp_vflag &= ~INP_IPV6; @@ -702,7 +702,7 @@ syncache_socket(struct syncache *sc, str * put the PCB on the hash lists. */ #ifdef INET6 - if (sc->sc_inc.inc_isipv6) + if (sc->sc_inc.inc_flags & INC_ISIPV6) inp->in6p_laddr = in6addr_any; else #endif @@ -716,7 +716,7 @@ syncache_socket(struct syncache *sc, str printf("syncache_socket: could not copy policy\n"); #endif #ifdef INET6 - if (sc->sc_inc.inc_isipv6) { + if (sc->sc_inc.inc_flags & INC_ISIPV6) { struct inpcb *oinp = sotoinpcb(lso); struct in6_addr laddr6; struct sockaddr_in6 sin6; @@ -1043,7 +1043,7 @@ _syncache_add(struct in_conninfo *inc, s cred = crhold(so->so_cred); #ifdef INET6 - if (inc->inc_isipv6 && + if ((inc->inc_flags & INC_ISIPV6) && (inp->in6p_flags & IN6P_AUTOFLOWLABEL)) autoflowlabel = 1; #endif @@ -1072,7 +1072,7 @@ _syncache_add(struct in_conninfo *inc, s * Remember the IP options, if any. */ #ifdef INET6 - if (!inc->inc_isipv6) + if (!(inc->inc_flags & INC_ISIPV6)) #endif ipopts = (m) ? ip_srcroute(m) : NULL; @@ -1173,10 +1173,11 @@ _syncache_add(struct in_conninfo *inc, s sc->sc_cred = cred; cred = NULL; sc->sc_ipopts = ipopts; + /* XXX-BZ this fib assignment is just useless. */ sc->sc_inc.inc_fibnum = inp->inp_inc.inc_fibnum; bcopy(inc, &sc->sc_inc, sizeof(struct in_conninfo)); #ifdef INET6 - if (!inc->inc_isipv6) + if (!(inc->inc_flags & INC_ISIPV6)) #endif { sc->sc_ip_tos = ip_tos; @@ -1316,7 +1317,7 @@ syncache_respond(struct syncache *sc) hlen = #ifdef INET6 - (sc->sc_inc.inc_isipv6) ? sizeof(struct ip6_hdr) : + (sc->sc_inc.inc_flags & INC_ISIPV6) ? sizeof(struct ip6_hdr) : #endif sizeof(struct ip); tlen = hlen + sizeof(struct tcphdr); @@ -1343,7 +1344,7 @@ syncache_respond(struct syncache *sc) m->m_pkthdr.rcvif = NULL; #ifdef INET6 - if (sc->sc_inc.inc_isipv6) { + if (sc->sc_inc.inc_flags & INC_ISIPV6) { ip6 = mtod(m, struct ip6_hdr *); ip6->ip6_vfc = IPV6_VERSION; ip6->ip6_nxt = IPPROTO_TCP; @@ -1429,7 +1430,7 @@ syncache_respond(struct syncache *sc) to.to_signature, IPSEC_DIR_OUTBOUND); #endif #ifdef INET6 - if (sc->sc_inc.inc_isipv6) + if (sc->sc_inc.inc_flags & INC_ISIPV6) ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) + optlen); else #endif @@ -1438,7 +1439,7 @@ syncache_respond(struct syncache *sc) optlen = 0; #ifdef INET6 - if (sc->sc_inc.inc_isipv6) { + if (sc->sc_inc.inc_flags & INC_ISIPV6) { th->th_sum = 0; th->th_sum = in6_cksum(m, IPPROTO_TCP, hlen, tlen + optlen - hlen); @@ -1691,7 +1692,7 @@ syncookie_lookup(struct in_conninfo *inc sc->sc_iss = ack; #ifdef INET6 - if (inc->inc_isipv6) { + if (inc->inc_flags & INC_ISIPV6) { if (sotoinpcb(so)->in6p_flags & IN6P_AUTOFLOWLABEL) sc->sc_flowlabel = md5_buffer[1] & IPV6_FLOWLABEL_MASK; } else @@ -1779,7 +1780,7 @@ syncache_pcblist(struct sysctl_req *req, continue; bzero(&xt, sizeof(xt)); xt.xt_len = sizeof(xt); - if (sc->sc_inc.inc_isipv6) + if (sc->sc_inc.inc_flags & INC_ISIPV6) xt.xt_inp.inp_vflag = INP_IPV6; else xt.xt_inp.inp_vflag = INP_IPV4; Modified: stable/7/sys/netinet/tcp_timewait.c ============================================================================== --- stable/7/sys/netinet/tcp_timewait.c Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/netinet/tcp_timewait.c Wed Mar 18 16:09:05 2009 (r189966) @@ -529,7 +529,7 @@ tcp_twrespond(struct tcptw *tw, int flag struct tcpopt to; #ifdef INET6 struct ip6_hdr *ip6 = NULL; - int isipv6 = inp->inp_inc.inc_isipv6; + int isipv6 = inp->inp_inc.inc_flags & INC_ISIPV6; #endif INP_WLOCK_ASSERT(inp); Modified: stable/7/sys/netinet/tcp_usrreq.c ============================================================================== --- stable/7/sys/netinet/tcp_usrreq.c Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/netinet/tcp_usrreq.c Wed Mar 18 16:09:05 2009 (r189966) @@ -538,7 +538,7 @@ tcp6_usr_connect(struct socket *so, stru } inp->inp_vflag &= ~INP_IPV4; inp->inp_vflag |= INP_IPV6; - inp->inp_inc.inc_isipv6 = 1; + inp->inp_inc.inc_flags |= INC_ISIPV6; if ((error = prison_remote_ip6(td->td_ucred, &sin6p->sin6_addr)) != 0) goto out; if ((error = tcp6_connect(tp, nam, td)) != 0) Modified: stable/7/sys/netinet6/icmp6.c ============================================================================== --- stable/7/sys/netinet6/icmp6.c Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/netinet6/icmp6.c Wed Mar 18 16:09:05 2009 (r189966) @@ -1129,7 +1129,7 @@ icmp6_mtudisc_update(struct ip6ctlparam mtu = IPV6_MMTU - 8; bzero(&inc, sizeof(inc)); - inc.inc_flags = 1; /* IPv6 */ + inc.inc_flags |= INC_ISIPV6; inc.inc6_faddr = *dst; if (in6_setscope(&inc.inc6_faddr, m->m_pkthdr.rcvif, NULL)) return; Modified: stable/7/sys/netinet6/ip6_output.c ============================================================================== --- stable/7/sys/netinet6/ip6_output.c Wed Mar 18 14:43:56 2009 (r189965) +++ stable/7/sys/netinet6/ip6_output.c Wed Mar 18 16:09:05 2009 (r189966) @@ -1314,7 +1314,7 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, s struct in_conninfo inc; bzero(&inc, sizeof(inc)); - inc.inc_flags = 1; /* IPv6 */ + inc.inc_flags |= INC_ISIPV6; inc.inc6_faddr = *dst; if (ifp == NULL) From alc at FreeBSD.org Wed Mar 18 09:24:40 2009 From: alc at FreeBSD.org (Alan Cox) Date: Wed Mar 18 09:24:52 2009 Subject: svn commit: r189968 - stable/7/sys/vm Message-ID: <200903181624.n2IGOdKk031166@svn.freebsd.org> Author: alc Date: Wed Mar 18 16:24:39 2009 New Revision: 189968 URL: http://svn.freebsd.org/changeset/base/189968 Log: MFC revision 1.363 Eliminate redundant code from vm_page_startup(). (In retrospect, this change should have been included in the superpages MFC. This change subsumes r189750.) Discussed with: jhb Modified: stable/7/sys/vm/vm_page.c Modified: stable/7/sys/vm/vm_page.c ============================================================================== --- stable/7/sys/vm/vm_page.c Wed Mar 18 16:19:44 2009 (r189967) +++ stable/7/sys/vm/vm_page.c Wed Mar 18 16:24:39 2009 (r189968) @@ -209,7 +209,6 @@ vm_offset_t vm_page_startup(vm_offset_t vaddr) { vm_offset_t mapped; - vm_size_t npages; vm_paddr_t page_range; vm_paddr_t new_end; int i; @@ -224,9 +223,6 @@ vm_page_startup(vm_offset_t vaddr) vm_paddr_t low_water, high_water; int biggestone; - vm_paddr_t total; - - total = 0; biggestsize = 0; biggestone = 0; nblocks = 0; @@ -252,7 +248,6 @@ vm_page_startup(vm_offset_t vaddr) if (phys_avail[i + 1] > high_water) high_water = phys_avail[i + 1]; ++nblocks; - total += size; } end = phys_avail[biggestone+1]; @@ -320,8 +315,6 @@ vm_page_startup(vm_offset_t vaddr) #else #error "Either VM_PHYSSEG_DENSE or VM_PHYSSEG_SPARSE must be defined." #endif - npages = (total - (page_range * sizeof(struct vm_page)) - - (end - new_end)) / PAGE_SIZE; end = new_end; /* @@ -363,22 +356,6 @@ vm_page_startup(vm_offset_t vaddr) vm_page_array[i].order = VM_NFREEORDER; vm_page_array_size = page_range; -#if 0 - /* - * This assertion tests the hypothesis that npages and total are - * redundant. XXX - * - * XXX: This always fails if VM_NRESERVLEVEL > 0 because - * npages includes the memory for vm_reserv_startup() but - * page_range doesn't. - */ - page_range = 0; - for (i = 0; phys_avail[i + 1] != 0; i += 2) - page_range += atop(phys_avail[i + 1] - phys_avail[i]); - KASSERT(page_range == npages, - ("vm_page_startup: inconsistent page counts")); -#endif - /* * Initialize the physical memory allocator. */ From bms at FreeBSD.org Wed Mar 18 10:14:45 2009 From: bms at FreeBSD.org (Bruce M Simpson) Date: Wed Mar 18 10:14:52 2009 Subject: svn commit: r189969 - stable/7/sys/dev/ae Message-ID: <200903181714.n2IHEib6032246@svn.freebsd.org> Author: bms Date: Wed Mar 18 17:14:44 2009 New Revision: 189969 URL: http://svn.freebsd.org/changeset/base/189969 Log: MFC r183567: Merge Wake-on-Lan (WOL) support for the Attansic/Atheros L2. This was left out of the backport to RELENG_7 as the WOL infrastructure had not yet been backported to RELENG_7 when the ae(4) driver was merged. Tested OK on an ASUS EeePC 701 using ports/net/wol. Submitted by: yongari Modified: stable/7/sys/dev/ae/if_ae.c Modified: stable/7/sys/dev/ae/if_ae.c ============================================================================== --- stable/7/sys/dev/ae/if_ae.c Wed Mar 18 16:24:39 2009 (r189968) +++ stable/7/sys/dev/ae/if_ae.c Wed Mar 18 17:14:44 2009 (r189969) @@ -380,8 +380,10 @@ ae_attach(device_t dev) ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN; IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); IFQ_SET_READY(&ifp->if_snd); - if (pci_find_extcap(dev, PCIY_PMG, &pmc) == 0) + if (pci_find_extcap(dev, PCIY_PMG, &pmc) == 0) { + ifp->if_capabilities |= IFCAP_WOL_MAGIC; sc->flags |= AE_FLAG_PMG; + } ifp->if_capenable = ifp->if_capabilities; /* @@ -1329,6 +1331,7 @@ ae_pm_init(ae_softc_t *sc) struct ifnet *ifp; uint32_t val; uint16_t pmstat; + struct mii_data *mii; int pmc; AE_LOCK_ASSERT(sc); @@ -1340,7 +1343,40 @@ ae_pm_init(ae_softc_t *sc) return; } - ae_powersave_enable(sc); + /* + * Configure WOL if enabled. + */ + if ((ifp->if_capenable & IFCAP_WOL) != 0) { + mii = device_get_softc(sc->miibus); + mii_pollstat(mii); + if ((mii->mii_media_status & IFM_AVALID) != 0 && + (mii->mii_media_status & IFM_ACTIVE) != 0) { + AE_WRITE_4(sc, AE_WOL_REG, AE_WOL_MAGIC | \ + AE_WOL_MAGIC_PME); + + /* + * Configure MAC. + */ + val = AE_MAC_RX_EN | AE_MAC_CLK_PHY | \ + AE_MAC_TX_CRC_EN | AE_MAC_TX_AUTOPAD | \ + ((AE_HALFBUF_DEFAULT << AE_HALFBUF_SHIFT) & \ + AE_HALFBUF_MASK) | \ + ((AE_MAC_PREAMBLE_DEFAULT << \ + AE_MAC_PREAMBLE_SHIFT) & AE_MAC_PREAMBLE_MASK) | \ + AE_MAC_BCAST_EN | AE_MAC_MCAST_EN; + if ((IFM_OPTIONS(mii->mii_media_active) & \ + IFM_FDX) != 0) + val |= AE_MAC_FULL_DUPLEX; + AE_WRITE_4(sc, AE_MAC_REG, val); + + } else { /* No link. */ + AE_WRITE_4(sc, AE_WOL_REG, AE_WOL_LNKCHG | \ + AE_WOL_LNKCHG_PME); + AE_WRITE_4(sc, AE_MAC_REG, 0); + } + } else { + ae_powersave_enable(sc); + } /* * PCIE hacks. Magic numbers. @@ -1358,6 +1394,8 @@ ae_pm_init(ae_softc_t *sc) pci_find_extcap(sc->dev, PCIY_PMG, &pmc); pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2); pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE); + if ((ifp->if_capenable & IFCAP_WOL) != 0) + pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2); } From jamie at FreeBSD.org Wed Mar 18 11:08:33 2009 From: jamie at FreeBSD.org (Jamie Gritton) Date: Wed Mar 18 11:08:40 2009 Subject: svn commit: r189970 - stable/7/sbin/ifconfig Message-ID: <200903181808.n2II8VT0033288@svn.freebsd.org> Author: jamie Date: Wed Mar 18 18:08:31 2009 New Revision: 189970 URL: http://svn.freebsd.org/changeset/base/189970 Log: MFC r189864: Default to AF_LOCAL instead of AF_INET sockets for non-family-specific operations. This allows the query operations to work in non-IPv4 jails, and will be necessary in a future of possible non-INET networking. Approved by: bz (mentor) Modified: stable/7/sbin/ifconfig/ (props changed) stable/7/sbin/ifconfig/ifclone.c stable/7/sbin/ifconfig/ifconfig.c stable/7/sbin/ifconfig/ifgroup.c Modified: stable/7/sbin/ifconfig/ifclone.c ============================================================================== --- stable/7/sbin/ifconfig/ifclone.c Wed Mar 18 17:14:44 2009 (r189969) +++ stable/7/sbin/ifconfig/ifclone.c Wed Mar 18 18:08:31 2009 (r189970) @@ -53,9 +53,9 @@ list_cloners(void) int idx; int s; - s = socket(AF_INET, SOCK_DGRAM, 0); + s = socket(AF_LOCAL, SOCK_DGRAM, 0); if (s == -1) - err(1, "socket(AF_INET,SOCK_DGRAM)"); + err(1, "socket(AF_LOCAL,SOCK_DGRAM)"); memset(&ifcr, 0, sizeof(ifcr)); Modified: stable/7/sbin/ifconfig/ifconfig.c ============================================================================== --- stable/7/sbin/ifconfig/ifconfig.c Wed Mar 18 17:14:44 2009 (r189969) +++ stable/7/sbin/ifconfig/ifconfig.c Wed Mar 18 18:08:31 2009 (r189970) @@ -434,21 +434,22 @@ static const struct cmd setifdstaddr_cmd DEF_CMD("ifdstaddr", 0, setifdstaddr); static int -ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *afp) +ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *uafp) { - const struct afswtch *nafp; + const struct afswtch *afp, *nafp; struct callback *cb; int s; strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); + afp = uafp != NULL ? uafp : af_getbyname("inet"); top: - if (afp == NULL) - afp = af_getbyname("inet"); ifr.ifr_addr.sa_family = afp->af_af == AF_LINK || afp->af_af == AF_UNSPEC ? - AF_INET : afp->af_af; + AF_LOCAL : afp->af_af; - if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0) + if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0 && + (uafp != NULL || errno != EPROTONOSUPPORT || + (s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0)) err(1, "socket(family %u,SOCK_DGRAM", ifr.ifr_addr.sa_family); while (argc > 0) { @@ -792,11 +793,12 @@ status(const struct afswtch *afp, const if (afp == NULL) { allfamilies = 1; - afp = af_getbyname("inet"); - } else + ifr.ifr_addr.sa_family = AF_LOCAL; + } else { allfamilies = 0; - - ifr.ifr_addr.sa_family = afp->af_af == AF_LINK ? AF_INET : afp->af_af; + ifr.ifr_addr.sa_family = + afp->af_af == AF_LINK ? AF_LOCAL : afp->af_af; + } strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0); Modified: stable/7/sbin/ifconfig/ifgroup.c ============================================================================== --- stable/7/sbin/ifconfig/ifgroup.c Wed Mar 18 17:14:44 2009 (r189969) +++ stable/7/sbin/ifconfig/ifgroup.c Wed Mar 18 18:08:31 2009 (r189970) @@ -131,9 +131,9 @@ printgroup(const char *groupname) int len, cnt = 0; int s; - s = socket(AF_INET, SOCK_DGRAM, 0); + s = socket(AF_LOCAL, SOCK_DGRAM, 0); if (s == -1) - err(1, "socket(AF_INET,SOCK_DGRAM)"); + err(1, "socket(AF_LOCAL,SOCK_DGRAM)"); bzero(&ifgr, sizeof(ifgr)); strlcpy(ifgr.ifgr_name, groupname, sizeof(ifgr.ifgr_name)); if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) { From jhb at FreeBSD.org Wed Mar 18 11:18:40 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 18 11:18:47 2009 Subject: svn commit: r189971 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/udf Message-ID: <200903181818.n2IIIcnF033542@svn.freebsd.org> Author: jhb Date: Wed Mar 18 18:18:38 2009 New Revision: 189971 URL: http://svn.freebsd.org/changeset/base/189971 Log: MFC: Add support for fifos to UDF. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/udf/udf.h stable/7/sys/fs/udf/udf_vfsops.c stable/7/sys/fs/udf/udf_vnops.c Modified: stable/7/sys/fs/udf/udf.h ============================================================================== --- stable/7/sys/fs/udf/udf.h Wed Mar 18 18:08:31 2009 (r189970) +++ stable/7/sys/fs/udf/udf.h Wed Mar 18 18:18:38 2009 (r189971) @@ -137,3 +137,5 @@ int udf_vget(struct mount *, ino_t, int, extern uma_zone_t udf_zone_trans; extern uma_zone_t udf_zone_node; extern uma_zone_t udf_zone_ds; + +extern struct vop_vector udf_fifoops; Modified: stable/7/sys/fs/udf/udf_vfsops.c ============================================================================== --- stable/7/sys/fs/udf/udf_vfsops.c Wed Mar 18 18:08:31 2009 (r189970) +++ stable/7/sys/fs/udf/udf_vfsops.c Wed Mar 18 18:18:38 2009 (r189971) @@ -681,6 +681,7 @@ udf_vget(struct mount *mp, ino_t ino, in break; case 9: vp->v_type = VFIFO; + vp->v_op = &udf_fifoops; break; case 10: vp->v_type = VSOCK; Modified: stable/7/sys/fs/udf/udf_vnops.c ============================================================================== --- stable/7/sys/fs/udf/udf_vnops.c Wed Mar 18 18:08:31 2009 (r189970) +++ stable/7/sys/fs/udf/udf_vnops.c Wed Mar 18 18:18:38 2009 (r189971) @@ -48,6 +48,7 @@ #include +#include #include #include #include @@ -60,9 +61,11 @@ static vop_getattr_t udf_getattr; static vop_open_t udf_open; static vop_ioctl_t udf_ioctl; static vop_pathconf_t udf_pathconf; +static vop_print_t udf_print; static vop_read_t udf_read; static vop_readdir_t udf_readdir; static vop_readlink_t udf_readlink; +static vop_setattr_t udf_setattr; static vop_strategy_t udf_strategy; static vop_bmap_t udf_bmap; static vop_cachedlookup_t udf_lookup; @@ -84,14 +87,26 @@ static struct vop_vector udf_vnodeops = .vop_lookup = vfs_cache_lookup, .vop_open = udf_open, .vop_pathconf = udf_pathconf, + .vop_print = udf_print, .vop_read = udf_read, .vop_readdir = udf_readdir, .vop_readlink = udf_readlink, .vop_reclaim = udf_reclaim, + .vop_setattr = udf_setattr, .vop_strategy = udf_strategy, .vop_vptofh = udf_vptofh, }; +struct vop_vector udf_fifoops = { + .vop_default = &fifo_specops, + .vop_access = udf_access, + .vop_getattr = udf_getattr, + .vop_print = udf_print, + .vop_reclaim = udf_reclaim, + .vop_setattr = udf_setattr, + .vop_vptofh = udf_vptofh, +}; + MALLOC_DEFINE(M_UDFFID, "udf_fid", "UDF FileId structure"); MALLOC_DEFINE(M_UDFDS, "udf_ds", "UDF Dirstream structure"); @@ -305,6 +320,38 @@ udf_getattr(struct vop_getattr_args *a) return (0); } +static int +udf_setattr(struct vop_setattr_args *a) +{ + struct vnode *vp; + struct vattr *vap; + + vp = a->a_vp; + vap = a->a_vap; + if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL || + vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL || + vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) + return (EROFS); + if (vap->va_size != (u_quad_t)VNOVAL) { + switch (vp->v_type) { + case VDIR: + return (EISDIR); + case VLNK: + case VREG: + return (EROFS); + case VCHR: + case VBLK: + case VSOCK: + case VFIFO: + case VNON: + case VBAD: + case VMARKER: + return (0); + } + } + return (0); +} + /* * File specific ioctls. */ @@ -341,6 +388,20 @@ udf_pathconf(struct vop_pathconf_args *a } } +static int +udf_print(struct vop_print_args *ap) +{ + struct vnode *vp = ap->a_vp; + struct udf_node *node = VTON(vp); + + printf(" ino %lu, on dev %s", (u_long)node->hash_id, + devtoname(node->udfmp->im_dev)); + if (vp->v_type == VFIFO) + fifo_printinfo(vp); + printf("\n"); + return (0); +} + #define lblkno(udfmp, loc) ((loc) >> (udfmp)->bshift) #define blkoff(udfmp, loc) ((loc) & (udfmp)->bmask) #define lblktosize(imp, blk) ((blk) << (udfmp)->bshift) From jhb at FreeBSD.org Wed Mar 18 11:20:23 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 18 11:21:10 2009 Subject: svn commit: r189972 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/udf Message-ID: <200903181820.n2IIKLFr033632@svn.freebsd.org> Author: jhb Date: Wed Mar 18 18:20:20 2009 New Revision: 189972 URL: http://svn.freebsd.org/changeset/base/189972 Log: MFC: Add rudimentary support for symbolic links on UDF. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/udf/ecma167-udf.h stable/7/sys/fs/udf/udf_vnops.c Modified: stable/7/sys/fs/udf/ecma167-udf.h ============================================================================== --- stable/7/sys/fs/udf/ecma167-udf.h Wed Mar 18 18:18:38 2009 (r189971) +++ stable/7/sys/fs/udf/ecma167-udf.h Wed Mar 18 18:20:20 2009 (r189972) @@ -354,6 +354,18 @@ struct file_entry { #define UDF_FENTRY_PERM_GRP_MASK 0xE0 #define UDF_FENTRY_PERM_OWNER_MASK 0x1C00 +/* Path Component [4/14.16.1] */ +struct path_component { + uint8_t type; + uint8_t length; + uint16_t version; + uint8_t identifier[1]; +} __packed; +#define UDF_PATH_ROOT 2 +#define UDF_PATH_DOTDOT 3 +#define UDF_PATH_DOT 4 +#define UDF_PATH_PATH 5 + union dscrptr { struct desc_tag tag; struct anchor_vdp avdp; Modified: stable/7/sys/fs/udf/udf_vnops.c ============================================================================== --- stable/7/sys/fs/udf/udf_vnops.c Wed Mar 18 18:18:38 2009 (r189971) +++ stable/7/sys/fs/udf/udf_vnops.c Wed Mar 18 18:20:20 2009 (r189972) @@ -846,12 +846,121 @@ udf_readdir(struct vop_readdir_args *a) return (error); } -/* Are there any implementations out there that do soft-links? */ static int udf_readlink(struct vop_readlink_args *ap) { - printf("%s called\n", __func__); - return (EOPNOTSUPP); + struct path_component *pc, *end; + struct vnode *vp; + struct uio uio; + struct iovec iov[1]; + struct udf_node *node; + void *buf; + char *cp; + int error, len, root; + + /* + * A symbolic link in UDF is a list of variable-length path + * component structures. We build a pathname in the caller's + * uio by traversing this list. + */ + vp = ap->a_vp; + node = VTON(vp); + len = le64toh(node->fentry->inf_len); + buf = malloc(iov[0].iov_len, M_DEVBUF, M_WAITOK); + iov[0].iov_base = buf; + iov[0].iov_len = len; + uio.uio_iov = iov; + uio.uio_iovcnt = 1; + uio.uio_offset = 0; + uio.uio_resid = iov[0].iov_len; + uio.uio_segflg = UIO_SYSSPACE; + uio.uio_rw = UIO_READ; + uio.uio_td = curthread; + error = VOP_READ(vp, &uio, 0, ap->a_cred); + if (error) + goto error; + + pc = buf; + end = (void *)((char *)buf + len); + root = 0; + while (pc < end) { + switch (pc->type) { + case UDF_PATH_ROOT: + /* Only allow this at the beginning of a path. */ + if ((void *)pc != buf) { + error = EINVAL; + goto error; + } + cp = "/"; + len = 1; + root = 1; + break; + case UDF_PATH_DOT: + cp = "."; + len = 1; + break; + case UDF_PATH_DOTDOT: + cp = ".."; + len = 2; + break; + case UDF_PATH_PATH: + if (pc->length == 0) { + error = EINVAL; + goto error; + } + /* + * XXX: We only support CS8 which appears to map + * to ASCII directly. + */ + switch (pc->identifier[0]) { + case 8: + cp = pc->identifier + 1; + len = pc->length - 1; + break; + default: + error = EOPNOTSUPP; + goto error; + } + break; + default: + error = EINVAL; + goto error; + } + + /* + * If this is not the first component, insert a path + * separator. + */ + if (pc != buf) { + /* If we started with root we already have a "/". */ + if (root) + goto skipslash; + root = 0; + if (ap->a_uio->uio_resid < 1) { + error = ENAMETOOLONG; + goto error; + } + error = uiomove("/", 1, ap->a_uio); + if (error) + break; + } + skipslash: + + /* Append string at 'cp' of length 'len' to our path. */ + if (len > ap->a_uio->uio_resid) { + error = ENAMETOOLONG; + goto error; + } + error = uiomove(cp, len, ap->a_uio); + if (error) + break; + + /* Advance to next component. */ + pc = (void *)((char *)pc + 4 + pc->length); + } +error: + free(buf, M_DEVBUF); + return (error); } static int From jhb at FreeBSD.org Wed Mar 18 11:25:58 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 18 11:26:04 2009 Subject: svn commit: r189973 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/udf Message-ID: <200903181825.n2IIPunx033795@svn.freebsd.org> Author: jhb Date: Wed Mar 18 18:25:56 2009 New Revision: 189973 URL: http://svn.freebsd.org/changeset/base/189973 Log: MFC: Mark udf(4) MPSAFE and add support for using shared vnode locks for pathname lookups. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/udf/udf_vfsops.c stable/7/sys/fs/udf/udf_vnops.c Modified: stable/7/sys/fs/udf/udf_vfsops.c ============================================================================== --- stable/7/sys/fs/udf/udf_vfsops.c Wed Mar 18 18:20:20 2009 (r189972) +++ stable/7/sys/fs/udf/udf_vfsops.c Wed Mar 18 18:25:56 2009 (r189973) @@ -344,6 +344,7 @@ udf_mountfs(struct vnode *devvp, struct mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; + mp->mnt_kern_flag |= MNTK_MPSAFE | MNTK_LOOKUP_SHARED; MNT_IUNLOCK(mp); udfmp->im_mountp = mp; udfmp->im_dev = devvp->v_rdev; @@ -546,22 +547,13 @@ static int udf_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td) { struct udf_mnt *udfmp; - struct vnode *vp; ino_t id; - int error; udfmp = VFSTOUDFFS(mp); id = udf_getid(&udfmp->root_icb); - error = udf_vget(mp, id, LK_EXCLUSIVE, vpp); - if (error) - return error; - - vp = *vpp; - vp->v_vflag |= VV_ROOT; - - return (0); + return (udf_vget(mp, id, flags, vpp)); } static int @@ -597,6 +589,22 @@ udf_vget(struct mount *mp, ino_t ino, in if (error || *vpp != NULL) return (error); + /* + * We must promote to an exclusive lock for vnode creation. This + * can happen if lookup is passed LOCKSHARED. + */ + if ((flags & LK_TYPE_MASK) == LK_SHARED) { + flags &= ~LK_TYPE_MASK; + flags |= LK_EXCLUSIVE; + } + + /* + * We do not lock vnode creation as it is believed to be too + * expensive for such rare case as simultaneous creation of vnode + * for same ino by different processes. We just allow them to race + * and check later to decide who wins. Let the race begin! + */ + td = curthread; udfmp = VFSTOUDFFS(mp); @@ -690,6 +698,13 @@ udf_vget(struct mount *mp, ino_t ino, in vp->v_type = VLNK; break; } + + if (vp->v_type != VFIFO) + VN_LOCK_ASHARE(vp); + + if (ino == udf_getid(&udfmp->root_icb)) + vp->v_vflag |= VV_ROOT; + *vpp = vp; return (0); Modified: stable/7/sys/fs/udf/udf_vnops.c ============================================================================== --- stable/7/sys/fs/udf/udf_vnops.c Wed Mar 18 18:20:20 2009 (r189972) +++ stable/7/sys/fs/udf/udf_vnops.c Wed Mar 18 18:25:56 2009 (r189973) @@ -1056,13 +1056,14 @@ udf_lookup(struct vop_cachedlookup_args long namelen; ino_t id = 0; int offset, error = 0; - int numdirpasses, fsize; + int fsize, lkflags, ltype, numdirpasses; dvp = a->a_dvp; node = VTON(dvp); udfmp = node->udfmp; nameiop = a->a_cnp->cn_nameiop; flags = a->a_cnp->cn_flags; + lkflags = a->a_cnp->cn_lkflags; nameptr = a->a_cnp->cn_nameptr; namelen = a->a_cnp->cn_namelen; fsize = le64toh(node->fentry->inf_len); @@ -1124,20 +1125,36 @@ lookloop: /* Did we have a match? */ if (id) { - if (flags & ISDOTDOT) - VOP_UNLOCK(dvp, 0, a->a_cnp->cn_thread); - error = udf_vget(udfmp->im_mountp, id, LK_EXCLUSIVE, &tdp); - if (flags & ISDOTDOT) - vn_lock(dvp, LK_EXCLUSIVE|LK_RETRY, a->a_cnp->cn_thread); - if (!error) { + /* + * Remember where this entry was if it's the final + * component. + */ + if ((flags & ISLASTCN) && nameiop == LOOKUP) + node->diroff = ds->offset + ds->off; + if (numdirpasses == 2) + nchstats.ncs_pass2++; + udf_closedir(ds); + + if (flags & ISDOTDOT) { + error = vn_vget_ino(dvp, id, lkflags, &tdp); + } else if (node->hash_id == id) { + VREF(dvp); /* we want ourself, ie "." */ /* - * Remember where this entry was if it's the final - * component. + * When we lookup "." we still can be asked to lock it + * differently. */ - if ((flags & ISLASTCN) && nameiop == LOOKUP) - node->diroff = ds->offset + ds->off; - if (numdirpasses == 2) - nchstats.ncs_pass2++; + ltype = lkflags & LK_TYPE_MASK; + if (ltype != VOP_ISLOCKED(dvp, td)) { + if (ltype == LK_EXCLUSIVE) + vn_lock(dvp, LK_UPGRADE | LK_RETRY, td); + else /* if (ltype == LK_SHARED) */ + vn_lock(dvp, LK_DOWNGRADE | LK_RETRY, + td); + } + tdp = dvp; + } else + error = udf_vget(udfmp->im_mountp, id, lkflags, &tdp); + if (!error) { *vpp = tdp; /* Put this entry in the cache */ if (flags & MAKEENTRY) @@ -1151,6 +1168,7 @@ lookloop: udf_closedir(ds); goto lookloop; } + udf_closedir(ds); /* Enter name into cache as non-existant */ if (flags & MAKEENTRY) @@ -1164,7 +1182,6 @@ lookloop: } } - udf_closedir(ds); return (error); } From jhb at FreeBSD.org Wed Mar 18 11:30:01 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 18 11:30:18 2009 Subject: svn commit: r189974 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb ufs/ffs Message-ID: <200903181830.n2IIU0F4033938@svn.freebsd.org> Author: jhb Date: Wed Mar 18 18:30:00 2009 New Revision: 189974 URL: http://svn.freebsd.org/changeset/base/189974 Log: MFC: - If the g_access() call for the initial root mount fails, then fully cleanup. Before the GEOM consumer would not have been closed. - Bump the reference on the character device being mounted while the associated devfs vnode is locked. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/ufs/ffs/ffs_vfsops.c Modified: stable/7/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vfsops.c Wed Mar 18 18:25:56 2009 (r189973) +++ stable/7/sys/ufs/ffs/ffs_vfsops.c Wed Mar 18 18:30:00 2009 (r189974) @@ -622,10 +622,13 @@ ffs_mountfs(devvp, mp, td) struct g_consumer *cp; struct mount *nmp; - dev = devvp->v_rdev; + bp = NULL; + ump = NULL; cred = td ? td->td_ucred : NOCRED; - ronly = (mp->mnt_flag & MNT_RDONLY) != 0; + + dev = devvp->v_rdev; + dev_ref(dev); DROP_GIANT(); g_topology_lock(); error = g_vfs_open(devvp, &cp, "ffs", ronly ? 0 : 1); @@ -640,8 +643,7 @@ ffs_mountfs(devvp, mp, td) PICKUP_GIANT(); VOP_UNLOCK(devvp, 0, td); if (error) - return (error); - dev_ref(dev); + goto out; if (devvp->v_rdev->si_iosize_max != 0) mp->mnt_iosize_max = devvp->v_rdev->si_iosize_max; if (mp->mnt_iosize_max > MAXPHYS) @@ -650,8 +652,6 @@ ffs_mountfs(devvp, mp, td) devvp->v_bufobj.bo_private = cp; devvp->v_bufobj.bo_ops = &ffs_ops; - bp = NULL; - ump = NULL; fs = NULL; sblockloc = 0; /* From jhb at FreeBSD.org Wed Mar 18 11:38:28 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 18 11:38:44 2009 Subject: svn commit: r189975 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/cd9660 Message-ID: <200903181838.n2IIcQAp034183@svn.freebsd.org> Author: jhb Date: Wed Mar 18 18:38:26 2009 New Revision: 189975 URL: http://svn.freebsd.org/changeset/base/189975 Log: MFC: Keep the vnode for the mountpoint locked on return from namei() until after g_vfs_open() to match other filesystems. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/cd9660/cd9660_vfsops.c Modified: stable/7/sys/fs/cd9660/cd9660_vfsops.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_vfsops.c Wed Mar 18 18:30:00 2009 (r189974) +++ stable/7/sys/fs/cd9660/cd9660_vfsops.c Wed Mar 18 18:38:26 2009 (r189975) @@ -154,14 +154,14 @@ cd9660_mount(struct mount *mp, struct th * Not an update, or updating the name: look up the name * and verify that it refers to a sensible block device. */ - NDINIT(&ndp, LOOKUP, FOLLOW, UIO_SYSSPACE, fspec, td); + NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspec, td); if ((error = namei(&ndp))) return (error); NDFREE(&ndp, NDF_ONLY_PNBUF); devvp = ndp.ni_vp; if (!vn_isdisk(devvp, &error)) { - vrele(devvp); + vput(devvp); return (error); } @@ -170,7 +170,6 @@ cd9660_mount(struct mount *mp, struct th * or has superuser abilities */ accessmode = VREAD; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); error = VOP_ACCESS(devvp, accessmode, td->td_ucred, td); if (error) error = priv_check(td, PRIV_VFS_MOUNT_PERM); @@ -178,22 +177,20 @@ cd9660_mount(struct mount *mp, struct th vput(devvp); return (error); } - VOP_UNLOCK(devvp, 0, td); if ((mp->mnt_flag & MNT_UPDATE) == 0) { error = iso_mountfs(devvp, mp, td); + if (error) + vrele(devvp); } else { if (devvp != imp->im_devvp) error = EINVAL; /* needs translation */ - else - vrele(devvp); - } - if (error) { - vrele(devvp); - return error; + vput(devvp); } + if (error) + return (error); vfs_mountedfrom(mp, fspec); - return 0; + return (0); } /* @@ -224,7 +221,6 @@ iso_mountfs(devvp, mp, td) struct bufobj *bo; char *cs_local, *cs_disk; - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); DROP_GIANT(); g_topology_lock(); error = g_vfs_open(devvp, &cp, "cd9660", 0); From jhb at FreeBSD.org Wed Mar 18 11:42:50 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 18 11:42:56 2009 Subject: svn commit: r189976 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/cd9660 fs/udf Message-ID: <200903181842.n2IIgmvI034311@svn.freebsd.org> Author: jhb Date: Wed Mar 18 18:42:48 2009 New Revision: 189976 URL: http://svn.freebsd.org/changeset/base/189976 Log: MFC: Consolidate error handling in mount routines and make the mountpoint hold a reference on the cdev the fs is mounted on. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/cd9660/cd9660_vfsops.c stable/7/sys/fs/udf/udf_vfsops.c Modified: stable/7/sys/fs/cd9660/cd9660_vfsops.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_vfsops.c Wed Mar 18 18:38:26 2009 (r189975) +++ stable/7/sys/fs/cd9660/cd9660_vfsops.c Wed Mar 18 18:42:48 2009 (r189976) @@ -205,7 +205,7 @@ iso_mountfs(devvp, mp, td) struct iso_mnt *isomp = (struct iso_mnt *)0; struct buf *bp = NULL; struct buf *pribp = NULL, *supbp = NULL; - struct cdev *dev = devvp->v_rdev; + struct cdev *dev; int error = EINVAL; int high_sierra = 0; int iso_bsize; @@ -221,6 +221,8 @@ iso_mountfs(devvp, mp, td) struct bufobj *bo; char *cs_local, *cs_disk; + dev = devvp->v_rdev; + dev_ref(dev); DROP_GIANT(); g_topology_lock(); error = g_vfs_open(devvp, &cp, "cd9660", 0); @@ -228,27 +230,21 @@ iso_mountfs(devvp, mp, td) PICKUP_GIANT(); VOP_UNLOCK(devvp, 0, td); if (error) - return error; + goto out; if (devvp->v_rdev->si_iosize_max != 0) mp->mnt_iosize_max = devvp->v_rdev->si_iosize_max; if (mp->mnt_iosize_max > MAXPHYS) mp->mnt_iosize_max = MAXPHYS; bo = &devvp->v_bufobj; - bo->bo_private = cp; - bo->bo_ops = g_vfs_bufops; /* This is the "logical sector size". The standard says this * should be 2048 or the physical sector size on the device, * whichever is greater. */ if ((ISO_DEFAULT_BLOCK_SIZE % cp->provider->sectorsize) != 0) { - DROP_GIANT(); - g_topology_lock(); - g_vfs_close(cp, td); - g_topology_unlock(); - PICKUP_GIANT(); - return (EINVAL); + error = EINVAL; + goto out; } iso_bsize = cp->provider->sectorsize; @@ -487,6 +483,7 @@ out: free((caddr_t)isomp, M_ISOFSMNT); mp->mnt_data = (qaddr_t)0; } + dev_rel(dev); return error; } @@ -526,6 +523,7 @@ cd9660_unmount(mp, mntflags, td) g_topology_unlock(); PICKUP_GIANT(); vrele(isomp->im_devvp); + dev_rel(isomp->im_dev); free((caddr_t)isomp, M_ISOFSMNT); mp->mnt_data = (qaddr_t)0; MNT_ILOCK(mp); Modified: stable/7/sys/fs/udf/udf_vfsops.c ============================================================================== --- stable/7/sys/fs/udf/udf_vfsops.c Wed Mar 18 18:38:26 2009 (r189975) +++ stable/7/sys/fs/udf/udf_vfsops.c Wed Mar 18 18:42:48 2009 (r189976) @@ -301,8 +301,10 @@ udf_checktag(struct desc_tag *tag, uint1 } static int -udf_mountfs(struct vnode *devvp, struct mount *mp, struct thread *td) { +udf_mountfs(struct vnode *devvp, struct mount *mp, struct thread *td) +{ struct buf *bp = NULL; + struct cdev *dev; struct anchor_vdp avdp; struct udf_mnt *udfmp = NULL; struct part_desc *pd; @@ -319,6 +321,8 @@ udf_mountfs(struct vnode *devvp, struct struct g_consumer *cp; struct bufobj *bo; + dev = devvp->v_rdev; + dev_ref(dev); DROP_GIANT(); g_topology_lock(); error = g_vfs_open(devvp, &cp, "udf", 0); @@ -326,7 +330,7 @@ udf_mountfs(struct vnode *devvp, struct PICKUP_GIANT(); VOP_UNLOCK(devvp, 0, td); if (error) - return error; + goto bail; bo = &devvp->v_bufobj; @@ -347,7 +351,7 @@ udf_mountfs(struct vnode *devvp, struct mp->mnt_kern_flag |= MNTK_MPSAFE | MNTK_LOOKUP_SHARED; MNT_IUNLOCK(mp); udfmp->im_mountp = mp; - udfmp->im_dev = devvp->v_rdev; + udfmp->im_dev = dev; udfmp->im_devvp = devvp; udfmp->im_d2l = NULL; udfmp->im_cp = cp; @@ -364,12 +368,8 @@ udf_mountfs(struct vnode *devvp, struct if (((logical_secsize % cp->provider->sectorsize) != 0) || (logical_secsize < cp->provider->sectorsize)) { - DROP_GIANT(); - g_topology_lock(); - g_vfs_close(cp, td); - g_topology_unlock(); - PICKUP_GIANT(); - return (EINVAL); + error = EINVAL; + goto bail; } bsize = cp->provider->sectorsize; @@ -492,11 +492,14 @@ bail: FREE(udfmp, M_UDFMOUNT); if (bp != NULL) brelse(bp); - DROP_GIANT(); - g_topology_lock(); - g_vfs_close(cp, td); - g_topology_unlock(); - PICKUP_GIANT(); + if (cp != NULL) { + DROP_GIANT(); + g_topology_lock(); + g_vfs_close(cp, td); + g_topology_unlock(); + PICKUP_GIANT(); + } + dev_rel(dev); return error; }; @@ -529,6 +532,7 @@ udf_unmount(struct mount *mp, int mntfla g_topology_unlock(); PICKUP_GIANT(); vrele(udfmp->im_devvp); + dev_rel(udfmp->im_dev); if (udfmp->s_table != NULL) FREE(udfmp->s_table, M_UDFMOUNT); From jhb at FreeBSD.org Wed Mar 18 11:46:52 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 18 11:47:04 2009 Subject: svn commit: r189979 - stable/7/sys/sys Message-ID: <200903181846.n2IIkoc6034614@svn.freebsd.org> Author: jhb Date: Wed Mar 18 18:46:50 2009 New Revision: 189979 URL: http://svn.freebsd.org/changeset/base/189979 Log: MFC: Add VN_LOCK_ASHARE() and VN_LOCK_AREC() macros to make it easier to share code with HEAD. Modified: stable/7/sys/sys/vnode.h Modified: stable/7/sys/sys/vnode.h ============================================================================== --- stable/7/sys/sys/vnode.h Wed Mar 18 18:43:31 2009 (r189978) +++ stable/7/sys/sys/vnode.h Wed Mar 18 18:46:50 2009 (r189979) @@ -397,6 +397,9 @@ extern void (*lease_updatetime)(int delt #define VI_UNLOCK(vp) mtx_unlock(&(vp)->v_interlock) #define VI_MTX(vp) (&(vp)->v_interlock) +#define VN_LOCK_AREC(vp) ((vp)->v_vnlock->lk_flags |= LK_CANRECURSE) +#define VN_LOCK_ASHARE(vp) ((vp)->v_vnlock->lk_flags &= ~LK_NOSHARE) + #endif /* _KERNEL */ /* From luigi at FreeBSD.org Wed Mar 18 12:51:42 2009 From: luigi at FreeBSD.org (Luigi Rizzo) Date: Wed Mar 18 12:51:53 2009 Subject: svn commit: r189982 - stable/7/release/picobsd/bridge Message-ID: <200903181951.n2IJpe8J036022@svn.freebsd.org> Author: luigi Date: Wed Mar 18 19:51:40 2009 New Revision: 189982 URL: http://svn.freebsd.org/changeset/base/189982 Log: replace vnconfig with mdconfig and related tools (mdmfs, newfs) and libraries. Also add the kld* tools so we can load modules. Modified: stable/7/release/picobsd/bridge/crunch.conf Modified: stable/7/release/picobsd/bridge/crunch.conf ============================================================================== --- stable/7/release/picobsd/bridge/crunch.conf Wed Mar 18 19:38:39 2009 (r189981) +++ stable/7/release/picobsd/bridge/crunch.conf Wed Mar 18 19:51:40 2009 (r189982) @@ -135,8 +135,9 @@ progs arp # 0KB. progs bsdlabel # 4KB. progs fdisk # 4KB. -progs vnconfig # 0KB. +progs mdconfig # 0KB. +progs kldload kldunload kldstat kldxref #progs grep # 16KB. progs date # 4KB. #progs mount_nfs # 0KB. @@ -145,9 +146,11 @@ progs ping # 4KB. #progs routed # 32KB. progs ipfw # 12KB. progs traceroute # 0KB. +progs mdmfs +ln mdmfs mount_mfs # progs mount_cd9660 # 4KB. # ln mount_cd9660 cd9660 -# progs newfs # 12KB. +progs newfs #ln newfs mount_mfs ln chown chgrp # ln mount_msdosfs msdos @@ -180,3 +183,4 @@ libs -ledit -lutil -lmd -lcrypt -lmp -lm libs -lz -lpcap -lwrap libs -ltermcap -lgnuregex # -lcurses libs -lgeom +libs -lsbuf -lbsdxml From bz at FreeBSD.org Wed Mar 18 13:18:24 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Wed Mar 18 13:18:41 2009 Subject: svn commit: r189984 - in stable/7/sys: . contrib/pf dev/cxgb netinet6 netipsec Message-ID: <200903182018.n2IKINLA036637@svn.freebsd.org> Author: bz Date: Wed Mar 18 20:18:23 2009 New Revision: 189984 URL: http://svn.freebsd.org/changeset/base/189984 Log: MFC r186791: Switch protosw* structs to C99 initializers. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netinet6/in6_gif.c stable/7/sys/netipsec/xform_ipip.c Modified: stable/7/sys/netinet6/in6_gif.c ============================================================================== --- stable/7/sys/netinet6/in6_gif.c Wed Mar 18 20:03:33 2009 (r189983) +++ stable/7/sys/netinet6/in6_gif.c Wed Mar 18 20:18:23 2009 (r189984) @@ -74,12 +74,15 @@ static int gif_validate6(const struct ip struct ifnet *); extern struct domain inet6domain; -struct ip6protosw in6_gif_protosw = -{ SOCK_RAW, &inet6domain, 0/* IPPROTO_IPV[46] */, PR_ATOMIC|PR_ADDR, - in6_gif_input, rip6_output, 0, rip6_ctloutput, - 0, - 0, 0, 0, 0, - &rip6_usrreqs +struct ip6protosw in6_gif_protosw = { + .pr_type = SOCK_RAW, + .pr_domain = &inet6domain, + .pr_protocol = 0, /* IPPROTO_IPV[46] */ + .pr_flags = PR_ATOMIC|PR_ADDR, + .pr_input = in6_gif_input, + .pr_output = rip6_output, + .pr_ctloutput = rip6_ctloutput, + .pr_usrreqs = &rip6_usrreqs }; int Modified: stable/7/sys/netipsec/xform_ipip.c ============================================================================== --- stable/7/sys/netipsec/xform_ipip.c Wed Mar 18 20:03:33 2009 (r189983) +++ stable/7/sys/netipsec/xform_ipip.c Wed Mar 18 20:18:23 2009 (r189984) @@ -652,22 +652,24 @@ static struct xformsw ipe4_xformsw = { }; extern struct domain inetdomain; -static struct protosw ipe4_protosw = -{ SOCK_RAW, &inetdomain, IPPROTO_IPV4, PR_ATOMIC|PR_ADDR|PR_LASTHDR, - ip4_input, - 0, 0, rip_ctloutput, - 0, - 0, 0, 0, 0, - &rip_usrreqs +static struct protosw ipe4_protosw = { + .pr_type = SOCK_RAW, + .pr_domain = &inetdomain, + .pr_protocol = IPPROTO_IPV4, + .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, + .pr_input = ip4_input, + .pr_ctloutput = rip_ctloutput, + .pr_usrreqs = &rip_usrreqs }; #ifdef INET6 -static struct ip6protosw ipe6_protosw = -{ SOCK_RAW, &inetdomain, IPPROTO_IPV6, PR_ATOMIC|PR_ADDR|PR_LASTHDR, - ip4_input6, - 0, 0, rip_ctloutput, - 0, - 0, 0, 0, 0, - &rip_usrreqs +static struct ip6protosw ipe6_protosw = { + .pr_type = SOCK_RAW, + .pr_domain = &inetdomain, + .pr_protocol = IPPROTO_IPV6, + .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, + .pr_input = ip4_input6, + .pr_ctloutput = rip_ctloutput, + .pr_usrreqs = &rip_usrreqs }; #endif From bz at FreeBSD.org Wed Mar 18 13:22:24 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Wed Mar 18 13:22:35 2009 Subject: svn commit: r189985 - stable/7 Message-ID: <200903182022.n2IKMMRI036766@svn.freebsd.org> Author: bz Date: Wed Mar 18 20:22:21 2009 New Revision: 189985 URL: http://svn.freebsd.org/changeset/base/189985 Log: MFC r179232 by jb: Add a knob to allow just the kernels to be built during a 'make universe'. MFC r185250 by des: Change the universe target to warn the user for every world or kernel that fails. The error message includes a reference to the relevant log file. Modified: stable/7/Makefile (contents, props changed) Modified: stable/7/Makefile ============================================================================== --- stable/7/Makefile Wed Mar 18 20:18:23 2009 (r189984) +++ stable/7/Makefile Wed Mar 18 20:22:21 2009 (r189985) @@ -285,22 +285,30 @@ KERNCONFS:= ${KERNCONFS:S/^NOTES$/LINT/} universe: universe_${target} .ORDER: universe_prologue universe_${target} universe_epilogue universe_${target}: +.if !defined(MAKE_JUST_KERNELS) @echo ">> ${target} started on `LC_ALL=C date`" - -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildworld \ + @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ + ${MAKE} ${JFLAG} buildworld \ TARGET=${target} \ - __MAKE_CONF=/dev/null \ - > _.${target}.buildworld 2>&1 + > _.${target}.buildworld 2>&1 || \ + echo "${target} world failed," \ + "check _.${target}.buildworld for details") @echo ">> ${target} buildworld completed on `LC_ALL=C date`" +.endif .if exists(${.CURDIR}/sys/${target}/conf/NOTES) - -cd ${.CURDIR}/sys/${target}/conf && ${MAKE} LINT \ - > ${.CURDIR}/_.${target}.makeLINT 2>&1 + @(cd ${.CURDIR}/sys/${target}/conf && env __MAKE_CONF=/dev/null \ + ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \ + echo "${target} 'make LINT' failed," \ + "check _.${target}.makeLINT for details") .endif .for kernel in ${KERNCONFS} - -cd ${.CURDIR} && ${MAKE} ${JFLAG} buildkernel \ + @(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \ + ${MAKE} ${JFLAG} buildkernel \ TARGET=${target} \ KERNCONF=${kernel} \ - __MAKE_CONF=/dev/null \ - > _.${target}.${kernel} 2>&1 + > _.${target}.${kernel} 2>&1 || \ + echo "${target} ${kernel} kernel failed," \ + "check _.${target}.${kernel} for details") .endfor @echo ">> ${target} completed on `LC_ALL=C date`" .endfor From emax at FreeBSD.org Wed Mar 18 14:43:17 2009 From: emax at FreeBSD.org (Maksim Yevmenkin) Date: Wed Mar 18 14:43:37 2009 Subject: svn commit: r189989 - stable/7/lib/libbluetooth Message-ID: <200903182143.n2ILhGwW038397@svn.freebsd.org> Author: emax Date: Wed Mar 18 21:43:16 2009 New Revision: 189989 URL: http://svn.freebsd.org/changeset/base/189989 Log: MFC r189462 MFC is ahead of schedule due to request. Add Bluetooth compatibility shims. Inspired by Linux BlueZ and NetBSD. Discussed with: Iain Hibbert plunky -at- rya-online -dot- net of NetBSD Requested by: Bruce Simpson bms -at- incunabulum -dot- net Tested by: Bruce Simpson bms -at- incunabulum -dot- net Added: stable/7/lib/libbluetooth/dev.c - copied unchanged from r189462, head/lib/libbluetooth/dev.c stable/7/lib/libbluetooth/hci.c - copied unchanged from r189462, head/lib/libbluetooth/hci.c Modified: stable/7/lib/libbluetooth/ (props changed) stable/7/lib/libbluetooth/Makefile stable/7/lib/libbluetooth/bluetooth.3 stable/7/lib/libbluetooth/bluetooth.c stable/7/lib/libbluetooth/bluetooth.h Modified: stable/7/lib/libbluetooth/Makefile ============================================================================== --- stable/7/lib/libbluetooth/Makefile Wed Mar 18 21:33:53 2009 (r189988) +++ stable/7/lib/libbluetooth/Makefile Wed Mar 18 21:43:16 2009 (r189989) @@ -9,7 +9,7 @@ CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../.. SHLIB_MAJOR= 3 -SRCS= bluetooth.c +SRCS= bluetooth.c dev.c hci.c INCS= bluetooth.h MLINKS+= bluetooth.3 bt_gethostbyname.3 @@ -27,6 +27,12 @@ MLINKS+= bluetooth.3 bt_endprotoent.3 MLINKS+= bluetooth.3 bt_ntoa.3 MLINKS+= bluetooth.3 bt_aton.3 +MLINKS+= bluetooth.3 bt_devaddr.3 +MLINKS+= bluetooth.3 bt_devname.3 + +MLINKS+= bluetooth.3 bt_devinfo.3 +MLINKS+= bluetooth.3 bt_devenum.3 + MLINKS+= bluetooth.3 bdaddr_same.3 MLINKS+= bluetooth.3 bdaddr_any.3 MLINKS+= bluetooth.3 bdaddr_copy.3 Modified: stable/7/lib/libbluetooth/bluetooth.3 ============================================================================== --- stable/7/lib/libbluetooth/bluetooth.3 Wed Mar 18 21:33:53 2009 (r189988) +++ stable/7/lib/libbluetooth/bluetooth.3 Wed Mar 18 21:43:16 2009 (r189989) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2003 Maksim Yevmenkin +.\" Copyright (c) 2003-2009 Maksim Yevmenkin .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -25,7 +25,7 @@ .\" $Id: bluetooth.3,v 1.5 2003/05/20 23:04:30 max Exp $ .\" $FreeBSD$ .\" -.Dd August 13, 2008 +.Dd February 13, 2009 .Dt BLUETOOTH 3 .Os .Sh NAME @@ -74,6 +74,16 @@ .Ft const char * .Fn bt_ntoa "const bdaddr_t *ba" "char *str" .Ft int +.Fn bt_devaddr "const char *devname" "bdaddr_t *addr" +.Ft int +.Fn bt_devname "char *devname" "const bdaddr_t *addr" +.Ft int +.Fn (bt_devenum_cb_t) "int s" "struct bt_devinfo const *di" "void *arg" +.Ft int +.Fn bt_devinfo "struct bt_devinfo *di" +.Ft int +.Fn bt_devenum "bt_devenum_cb_t *cb" "void *arg" +.Ft int .Fn bdaddr_same "const bdaddr_t *a" "const bdaddr_t *b" .Ft int .Fn bdaddr_any "const bdaddr_t *a" @@ -197,6 +207,110 @@ It is up to the caller to ensure that pr If no buffer was provided then internal static buffer will be used. .Pp The +.Fn bt_devaddr +function interprets the specified +.Fa devname +string as the address or device name of a Bluetooth device on the local system, +and places the device address in the provided +.Fa bdaddr , +if any. +The function returns 1 if the string was successfully interpreted, +or 0 if the string did not match any local device. +The +.Fn bt_devname +function takes a Bluetooth device address and copies the local device +name associated with that address into the buffer provided, +if any. +Caller must ensure that provided buffer is at least +.Dv HCI_DEVNAME_SIZE +characters in size. +The function returns 1 when the device was found, +otherwise 0. +.Pp +The +.Fn bt_devinfo +function populates prodivded +.Vt bt_devinfo +structure with the information about given Bluetooth device. +The caller is expected to pass Bluetooth device name in the +.Fa devname +field of the passed +.Vt bt_devinfo +structure. +The function returns 0 when successful, +otherwise -1. +The +.Vt bt_devinfo +structure is defined as follows +.Bd -literal -offset indent +struct bt_devinfo +{ + char devname[HCI_DEVNAME_SIZE]; + + uint32_t state; + + bdaddr_t bdaddr; + uint16_t _reserved0; + + uint8_t features[HCI_DEVFEATURES_SIZE]; + + /* buffer info */ + uint16_t _reserved1; + uint16_t cmd_free; + uint16_t sco_size; + uint16_t sco_pkts; + uint16_t sco_free; + uint16_t acl_size; + uint16_t acl_pkts; + uint16_t acl_free; + + /* stats */ + uint32_t cmd_sent; + uint32_t evnt_recv; + uint32_t acl_recv; + uint32_t acl_sent; + uint32_t sco_recv; + uint32_t sco_sent; + uint32_t bytes_recv; + uint32_t bytes_sent; + + /* misc/specific */ + uint16_t link_policy_info; + uint16_t packet_type_info; + uint16_t role_switch_info; + uint16_t debug; + + uint8_t _padding[20]; +}; +.Ed +.Pp +The +.Fn bt_devenum +function enumerates Bluetooth devices present in the system. +For every device found, +the function will call provided +.Fa cb +callback function which should be of +.Vt bt_devenum_cb_t +type. +The callback function is passed a +.Dv HCI +socket +.Fa s , +fully populated +.Vt bt_devinfo +structure +.Fa di +and +.Fa arg +argument provided to the +.Fn bt_devenum . +The callback function can stop enumeration by returning a value +that is greater than zero. +The function returns number of successfully enumerated devices, +or -1 if an error occurred. +.Pp +The .Fn bdaddr_same , .Fn bdaddr_any and @@ -287,7 +401,8 @@ on EOF or error. .Xr getprotobynumber 3 , .Xr herror 3 , .Xr inet_aton 3 , -.Xr inet_ntoa 3 +.Xr inet_ntoa 3 , +.Xr ng_hci 4 .Sh CAVEAT The .Fn bt_gethostent @@ -312,6 +427,20 @@ The function opens and/or rewinds the .Pa /etc/bluetooth/protocols file. +.Pp +The +.Fn bt_devenum +function enumerates up to +.Dv HCI_DEVMAX +Bluetooth devices. +During enumeration the +.Fn bt_devenum +function uses the same +.Dv HCI +socket. +The function guarantees that the socket, +passed to the callback function, +will be bound and connected to the Bluetooth device being enumerated. .Sh AUTHORS .An Maksim Yevmenkin Aq m_evmenkin@yahoo.com .Sh BUGS Modified: stable/7/lib/libbluetooth/bluetooth.c ============================================================================== --- stable/7/lib/libbluetooth/bluetooth.c Wed Mar 18 21:33:53 2009 (r189988) +++ stable/7/lib/libbluetooth/bluetooth.c Wed Mar 18 21:43:16 2009 (r189989) @@ -1,7 +1,9 @@ /* * bluetooth.c - * - * Copyright (c) 2001-2003 Maksim Yevmenkin + */ + +/*- + * Copyright (c) 2001-2009 Maksim Yevmenkin * All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: stable/7/lib/libbluetooth/bluetooth.h ============================================================================== --- stable/7/lib/libbluetooth/bluetooth.h Wed Mar 18 21:33:53 2009 (r189988) +++ stable/7/lib/libbluetooth/bluetooth.h Wed Mar 18 21:43:16 2009 (r189989) @@ -1,7 +1,9 @@ /* * bluetooth.h - * - * Copyright (c) 2001-2003 Maksim Yevmenkin + */ + +/*- + * Copyright (c) 2001-2009 Maksim Yevmenkin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,9 +37,12 @@ #include #include #include +#include #include #include +#include #include +#include #include #include #include @@ -72,6 +77,63 @@ void bt_endprotoent (v char const * bt_ntoa (bdaddr_t const *ba, char *str); int bt_aton (char const *str, bdaddr_t *ba); +/* bt_devXXXX() functions (inspired by NetBSD) */ +int bt_devaddr (char const *devname, bdaddr_t *addr); +int bt_devname (char *devname, bdaddr_t const *addr); + +/* + * Bluetooth HCI functions + */ + +#define HCI_DEVMAX 32 /* arbitrary */ +#define HCI_DEVNAME_SIZE NG_NODESIZ +#define HCI_DEVFEATURES_SIZE NG_HCI_FEATURES_SIZE + +struct bt_devinfo +{ + char devname[HCI_DEVNAME_SIZE]; + + uint32_t state; /* device/implementation specific */ + + bdaddr_t bdaddr; + uint16_t _reserved0; + + uint8_t features[HCI_DEVFEATURES_SIZE]; + + /* buffer info */ + uint16_t _reserved1; + uint16_t cmd_free; + uint16_t sco_size; + uint16_t sco_pkts; + uint16_t sco_free; + uint16_t acl_size; + uint16_t acl_pkts; + uint16_t acl_free; + + /* stats */ + uint32_t cmd_sent; + uint32_t evnt_recv; + uint32_t acl_recv; + uint32_t acl_sent; + uint32_t sco_recv; + uint32_t sco_sent; + uint32_t bytes_recv; + uint32_t bytes_sent; + + /* misc/specific */ + uint16_t link_policy_info; + uint16_t packet_type_info; + uint16_t role_switch_info; + uint16_t debug; + + uint8_t _padding[20]; /* leave space for future additions */ +}; + +typedef int (bt_devenum_cb_t)(int, struct bt_devinfo const *, void *); + +int bt_devinfo (struct bt_devinfo *di); +int bt_devenum (bt_devenum_cb_t *cb, void *arg); + /* * bdaddr utility functions (from NetBSD) */ Copied: stable/7/lib/libbluetooth/dev.c (from r189462, head/lib/libbluetooth/dev.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/lib/libbluetooth/dev.c Wed Mar 18 21:43:16 2009 (r189989, copy of r189462, head/lib/libbluetooth/dev.c) @@ -0,0 +1,95 @@ +/* + * dev.c + */ + +/*- + * Copyright (c) 2009 Maksim Yevmenkin + * 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$ + */ + +#include +#include +#include + +struct bt_devaddr_match_arg +{ + char devname[HCI_DEVNAME_SIZE]; + bdaddr_t const *bdaddr; +}; + +static bt_devenum_cb_t bt_devaddr_match; + +int +bt_devaddr(char const *devname, bdaddr_t *addr) +{ + struct bt_devinfo di; + + strlcpy(di.devname, devname, sizeof(di.devname)); + + if (bt_devinfo(&di) < 0) + return (0); + + if (addr != NULL) + bdaddr_copy(addr, &di.bdaddr); + + return (1); +} + +int +bt_devname(char *devname, bdaddr_t const *addr) +{ + struct bt_devaddr_match_arg arg; + + memset(&arg, 0, sizeof(arg)); + arg.bdaddr = addr; + + if (bt_devenum(&bt_devaddr_match, &arg) < 0) + return (0); + + if (arg.devname[0] == '\0') { + errno = ENXIO; + return (0); + } + + if (devname != NULL) + strlcpy(devname, arg.devname, HCI_DEVNAME_SIZE); + + return (1); +} + +static int +bt_devaddr_match(int s, struct bt_devinfo const *di, void *arg) +{ + struct bt_devaddr_match_arg *m = (struct bt_devaddr_match_arg *)arg; + + if (!bdaddr_same(&di->bdaddr, m->bdaddr)) + return (0); + + strlcpy(m->devname, di->devname, sizeof(m->devname)); + + return (1); +} + Copied: stable/7/lib/libbluetooth/hci.c (from r189462, head/lib/libbluetooth/hci.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/lib/libbluetooth/hci.c Wed Mar 18 21:43:16 2009 (r189989, copy of r189462, head/lib/libbluetooth/hci.c) @@ -0,0 +1,246 @@ +/* + * hci.c + */ + +/*- + * Copyright (c) 2009 Maksim Yevmenkin + * 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$ + */ + +#include +#include +#include +#include +#include + +static char * bt_dev2node (char const *devname, char *nodename, int nnlen); + +int +bt_devinfo(struct bt_devinfo *di) +{ + union { + struct ng_btsocket_hci_raw_node_state r0; + struct ng_btsocket_hci_raw_node_bdaddr r1; + struct ng_btsocket_hci_raw_node_features r2; + struct ng_btsocket_hci_raw_node_buffer r3; + struct ng_btsocket_hci_raw_node_stat r4; + struct ng_btsocket_hci_raw_node_link_policy_mask r5; + struct ng_btsocket_hci_raw_node_packet_mask r6; + struct ng_btsocket_hci_raw_node_role_switch r7; + struct ng_btsocket_hci_raw_node_debug r8; + } rp; + struct sockaddr_hci ha; + int s, rval; + + if (di == NULL) { + errno = EINVAL; + return (-1); + } + + memset(&ha, 0, sizeof(ha)); + ha.hci_len = sizeof(ha); + ha.hci_family = AF_BLUETOOTH; + + if (bt_aton(di->devname, &rp.r1.bdaddr)) { + if (!bt_devname(ha.hci_node, &rp.r1.bdaddr)) + return (-1); + } else if (bt_dev2node(di->devname, ha.hci_node, + sizeof(ha.hci_node)) == NULL) { + errno = ENXIO; + return (-1); + } + + s = socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_HCI); + if (s < 0) + return (-1); + + rval = -1; + + if (bind(s, (struct sockaddr *) &ha, sizeof(ha)) < 0 || + connect(s, (struct sockaddr *) &ha, sizeof(ha)) < 0) + goto bad; + strlcpy(di->devname, ha.hci_node, sizeof(di->devname)); + + if (ioctl(s, SIOC_HCI_RAW_NODE_GET_STATE, &rp.r0, sizeof(rp.r0)) < 0) + goto bad; + di->state = rp.r0.state; + + if (ioctl(s, SIOC_HCI_RAW_NODE_GET_BDADDR, &rp.r1, sizeof(rp.r1)) < 0) + goto bad; + bdaddr_copy(&di->bdaddr, &rp.r1.bdaddr); + + if (ioctl(s, SIOC_HCI_RAW_NODE_GET_FEATURES, &rp.r2, sizeof(rp.r2)) < 0) + goto bad; + memcpy(di->features, rp.r2.features, sizeof(di->features)); + + if (ioctl(s, SIOC_HCI_RAW_NODE_GET_BUFFER, &rp.r3, sizeof(rp.r3)) < 0) + goto bad; + di->cmd_free = rp.r3.buffer.cmd_free; + di->sco_size = rp.r3.buffer.sco_size; + di->sco_pkts = rp.r3.buffer.sco_pkts; + di->sco_free = rp.r3.buffer.sco_free; + di->acl_size = rp.r3.buffer.acl_size; + di->acl_pkts = rp.r3.buffer.acl_pkts; + di->acl_free = rp.r3.buffer.acl_free; + + if (ioctl(s, SIOC_HCI_RAW_NODE_GET_STAT, &rp.r4, sizeof(rp.r4)) < 0) + goto bad; + di->cmd_sent = rp.r4.stat.cmd_sent; + di->evnt_recv = rp.r4.stat.evnt_recv; + di->acl_recv = rp.r4.stat.acl_recv; + di->acl_sent = rp.r4.stat.acl_sent; + di->sco_recv = rp.r4.stat.sco_recv; + di->sco_sent = rp.r4.stat.sco_sent; + di->bytes_recv = rp.r4.stat.bytes_recv; + di->bytes_sent = rp.r4.stat.bytes_sent; + + if (ioctl(s, SIOC_HCI_RAW_NODE_GET_LINK_POLICY_MASK, + &rp.r5, sizeof(rp.r5)) < 0) + goto bad; + di->link_policy_info = rp.r5.policy_mask; + + if (ioctl(s, SIOC_HCI_RAW_NODE_GET_PACKET_MASK, + &rp.r6, sizeof(rp.r6)) < 0) + goto bad; + di->packet_type_info = rp.r6.packet_mask; + + if (ioctl(s, SIOC_HCI_RAW_NODE_GET_ROLE_SWITCH, + &rp.r7, sizeof(rp.r7)) < 0) + goto bad; + di->role_switch_info = rp.r7.role_switch; + + if (ioctl(s, SIOC_HCI_RAW_NODE_GET_DEBUG, &rp.r8, sizeof(rp.r8)) < 0) + goto bad; + di->debug = rp.r8.debug; + + rval = 0; +bad: + close(s); + + return (rval); +} + +int +bt_devenum(bt_devenum_cb_t cb, void *arg) +{ + struct ng_btsocket_hci_raw_node_list_names rp; + struct bt_devinfo di; + struct sockaddr_hci ha; + int s, i, count; + + rp.num_names = HCI_DEVMAX; + rp.names = (struct nodeinfo *) calloc(rp.num_names, + sizeof(struct nodeinfo)); + if (rp.names == NULL) { + errno = ENOMEM; + return (-1); + } + + memset(&ha, 0, sizeof(ha)); + ha.hci_len = sizeof(ha); + ha.hci_family = AF_BLUETOOTH; + ha.hci_node[0] = 'x'; + + s = socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_HCI); + if (s < 0) { + free(rp.names); + + return (-1); + } + + if (bind(s, (struct sockaddr *) &ha, sizeof(ha)) < 0 || + connect(s, (struct sockaddr *) &ha, sizeof(ha)) < 0 || + ioctl(s, SIOC_HCI_RAW_NODE_LIST_NAMES, &rp, sizeof(rp)) < 0) { + close(s); + free(rp.names); + + return (-1); + } + + for (count = 0, i = 0; i < rp.num_names; i ++) { + strlcpy(di.devname, rp.names[i].name, sizeof(di.devname)); + if (bt_devinfo(&di) < 0) + continue; + + count ++; + + if (cb == NULL) + continue; + + strlcpy(ha.hci_node, rp.names[i].name, sizeof(ha.hci_node)); + if (bind(s, (struct sockaddr *) &ha, sizeof(ha)) < 0 || + connect(s, (struct sockaddr *) &ha, sizeof(ha)) < 0) + continue; + + if ((*cb)(s, &di, arg) > 0) + break; + } + + close (s); + free(rp.names); + + return (count); +} + +static char * +bt_dev2node(char const *devname, char *nodename, int nnlen) +{ + static char const * bt_dev_prefix[] = { + "btccc", /* 3Com Bluetooth PC-CARD */ + "h4", /* UART/serial Bluetooth devices */ + "ubt", /* Bluetooth USB devices */ + NULL /* should be last */ + }; + + static char _nodename[HCI_DEVNAME_SIZE]; + char const **p; + char *ep; + int plen, unit; + + if (nodename == NULL) { + nodename = _nodename; + nnlen = HCI_DEVNAME_SIZE; + } + + for (p = bt_dev_prefix; *p != NULL; p ++) { + plen = strlen(*p); + if (strncmp(devname, *p, plen) != 0) + continue; + + unit = strtoul(devname + plen, &ep, 10); + if (*ep != '\0' && + strcmp(ep, "hci") != 0 && + strcmp(ep, "l2cap") != 0) + return (NULL); /* can't make sense of device name */ + + snprintf(nodename, nnlen, "%s%uhci", *p, unit); + + return (nodename); + } + + return (NULL); +} + From imp at FreeBSD.org Wed Mar 18 14:46:57 2009 From: imp at FreeBSD.org (Warner Losh) Date: Wed Mar 18 14:47:14 2009 Subject: svn commit: r189990 - in stable/7/sys: . conf contrib/pf dev/ath/ath_hal dev/cxgb dev/sis modules/sis pci Message-ID: <200903182146.n2ILktXB038567@svn.freebsd.org> Author: imp Date: Wed Mar 18 21:46:55 2009 New Revision: 189990 URL: http://svn.freebsd.org/changeset/base/189990 Log: MFC 181524: Move sis to sys/dev/sis for consistency. Added: stable/7/sys/dev/sis/ - copied from r181524, head/sys/dev/sis/ Deleted: stable/7/sys/pci/if_sis.c stable/7/sys/pci/if_sisreg.h Modified: stable/7/sys/ (props changed) stable/7/sys/conf/files stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/modules/sis/Makefile Modified: stable/7/sys/conf/files ============================================================================== --- stable/7/sys/conf/files Wed Mar 18 21:43:16 2009 (r189989) +++ stable/7/sys/conf/files Wed Mar 18 21:46:55 2009 (r189990) @@ -1107,6 +1107,7 @@ dev/si/si3_t225.c optional si dev/si/si_eisa.c optional si eisa dev/si/si_isa.c optional si isa dev/si/si_pci.c optional si pci +dev/sis/if_sis.c optional sis pci dev/sk/if_sk.c optional sk pci dev/smbus/smb.c optional smb dev/smbus/smbconf.c optional smbus @@ -2112,7 +2113,6 @@ pci/amdsmb.c optional amdsmb pci pci/if_mn.c optional mn pci pci/if_pcn.c optional pcn pci pci/if_rl.c optional rl pci -pci/if_sis.c optional sis pci pci/if_ste.c optional ste pci pci/if_tl.c optional tl pci pci/if_wb.c optional wb pci Modified: stable/7/sys/modules/sis/Makefile ============================================================================== --- stable/7/sys/modules/sis/Makefile Wed Mar 18 21:43:16 2009 (r189989) +++ stable/7/sys/modules/sis/Makefile Wed Mar 18 21:46:55 2009 (r189990) @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../pci +.PATH: ${.CURDIR}/../../dev/sis KMOD= if_sis SRCS= if_sis.c device_if.h bus_if.h pci_if.h From jhb at FreeBSD.org Wed Mar 18 14:51:05 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 18 14:51:17 2009 Subject: svn commit: r189991 - in stable/7/sys: . compat/linux compat/svr4 contrib/pf dev/ath/ath_hal dev/cxgb fs/coda i386/ibcs2 kern nfsserver Message-ID: <200903182151.n2ILp2IH038712@svn.freebsd.org> Author: jhb Date: Wed Mar 18 21:51:02 2009 New Revision: 189991 URL: http://svn.freebsd.org/changeset/base/189991 Log: MFC: Use shared vnode locks when invoking VOP_READDIR(). Modified: stable/7/sys/ (props changed) stable/7/sys/compat/linux/linux_file.c stable/7/sys/compat/linux/linux_getcwd.c stable/7/sys/compat/svr4/svr4_misc.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/coda/coda_vnops.c stable/7/sys/i386/ibcs2/ibcs2_misc.c stable/7/sys/kern/vfs_syscalls.c stable/7/sys/nfsserver/nfs_serv.c Modified: stable/7/sys/compat/linux/linux_file.c ============================================================================== --- stable/7/sys/compat/linux/linux_file.c Wed Mar 18 21:46:55 2009 (r189990) +++ stable/7/sys/compat/linux/linux_file.c Wed Mar 18 21:51:02 2009 (r189991) @@ -465,7 +465,7 @@ getdents_common(struct thread *td, struc buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); lbuf = malloc(LINUX_MAXRECLEN, M_TEMP, M_WAITOK | M_ZERO); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(vp, LK_SHARED | LK_RETRY, td); again: aiov.iov_base = buf; Modified: stable/7/sys/compat/linux/linux_getcwd.c ============================================================================== --- stable/7/sys/compat/linux/linux_getcwd.c Wed Mar 18 21:46:55 2009 (r189990) +++ stable/7/sys/compat/linux/linux_getcwd.c Wed Mar 18 21:51:02 2009 (r189991) @@ -163,7 +163,7 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bu cn.cn_nameptr = ".."; cn.cn_namelen = 2; cn.cn_consume = 0; - cn.cn_lkflags = LK_EXCLUSIVE; + cn.cn_lkflags = LK_SHARED; /* * At this point, lvp is locked and will be unlocked by the lookup. Modified: stable/7/sys/compat/svr4/svr4_misc.c ============================================================================== --- stable/7/sys/compat/svr4/svr4_misc.c Wed Mar 18 21:46:55 2009 (r189990) +++ stable/7/sys/compat/svr4/svr4_misc.c Wed Mar 18 21:51:02 2009 (r189991) @@ -278,7 +278,7 @@ svr4_sys_getdents64(td, uap) buflen = max(DIRBLKSIZ, nbytes); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(vp, LK_SHARED | LK_RETRY, td); again: aiov.iov_base = buf; aiov.iov_len = buflen; @@ -447,7 +447,7 @@ svr4_sys_getdents(td, uap) buflen = min(MAXBSIZE, uap->nbytes); buf = malloc(buflen, M_TEMP, M_WAITOK); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(vp, LK_SHARED | LK_RETRY, td); off = fp->f_offset; again: aiov.iov_base = buf; Modified: stable/7/sys/fs/coda/coda_vnops.c ============================================================================== --- stable/7/sys/fs/coda/coda_vnops.c Wed Mar 18 21:46:55 2009 (r189990) +++ stable/7/sys/fs/coda/coda_vnops.c Wed Mar 18 21:51:02 2009 (r189991) @@ -1510,7 +1510,7 @@ coda_readdir(struct vop_readdir_args *ap */ CODADEBUG(CODA_READDIR, myprintf(("indirect readdir: fid = %s, " "refcnt = %d\n", coda_f2s(&cp->c_fid), vp->v_usecount));); - vn_lock(cp->c_ovp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(cp->c_ovp, LK_SHARED | LK_RETRY, td); error = VOP_READDIR(cp->c_ovp, uiop, cred, eofflag, ncookies, cookies); VOP_UNLOCK(cp->c_ovp, 0, td); Modified: stable/7/sys/i386/ibcs2/ibcs2_misc.c ============================================================================== --- stable/7/sys/i386/ibcs2/ibcs2_misc.c Wed Mar 18 21:46:55 2009 (r189990) +++ stable/7/sys/i386/ibcs2/ibcs2_misc.c Wed Mar 18 21:51:02 2009 (r189991) @@ -356,7 +356,7 @@ ibcs2_getdents(td, uap) buflen = max(DIRBLKSIZ, uap->nbytes); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(vp, LK_SHARED | LK_RETRY, td); again: aiov.iov_base = buf; aiov.iov_len = buflen; @@ -518,7 +518,7 @@ ibcs2_read(td, uap) buflen = max(DIRBLKSIZ, uap->nbytes); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(vp, LK_SHARED | LK_RETRY, td); again: aiov.iov_base = buf; aiov.iov_len = buflen; Modified: stable/7/sys/kern/vfs_syscalls.c ============================================================================== --- stable/7/sys/kern/vfs_syscalls.c Wed Mar 18 21:46:55 2009 (r189990) +++ stable/7/sys/kern/vfs_syscalls.c Wed Mar 18 21:51:02 2009 (r189991) @@ -3665,7 +3665,7 @@ unionread: auio.uio_segflg = UIO_USERSPACE; auio.uio_td = td; auio.uio_resid = uap->count; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(vp, LK_SHARED | LK_RETRY, td); loff = auio.uio_offset = fp->f_offset; #ifdef MAC error = mac_check_vnode_readdir(td->td_ucred, vp); @@ -3824,8 +3824,7 @@ unionread: auio.uio_segflg = UIO_USERSPACE; auio.uio_td = td; auio.uio_resid = count; - /* vn_lock(vp, LK_SHARED | LK_RETRY, td); */ - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(vp, LK_SHARED | LK_RETRY, td); AUDIT_ARG(vnode, vp, ARG_VNODE1); loff = auio.uio_offset = fp->f_offset; #ifdef MAC Modified: stable/7/sys/nfsserver/nfs_serv.c ============================================================================== --- stable/7/sys/nfsserver/nfs_serv.c Wed Mar 18 21:46:55 2009 (r189990) +++ stable/7/sys/nfsserver/nfs_serv.c Wed Mar 18 21:51:02 2009 (r189991) @@ -3236,7 +3236,7 @@ again: io.uio_rw = UIO_READ; io.uio_td = NULL; eofflag = 0; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(vp, LK_SHARED | LK_RETRY, td); if (cookies) { free((caddr_t)cookies, M_TEMP); cookies = NULL; @@ -3518,7 +3518,7 @@ again: io.uio_rw = UIO_READ; io.uio_td = NULL; eofflag = 0; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + vn_lock(vp, LK_SHARED | LK_RETRY, td); if (cookies) { free((caddr_t)cookies, M_TEMP); cookies = NULL; From jhb at FreeBSD.org Wed Mar 18 14:54:30 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 18 14:54:37 2009 Subject: svn commit: r189993 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/sis kern Message-ID: <200903182154.n2ILsSn0038862@svn.freebsd.org> Author: jhb Date: Wed Mar 18 21:54:28 2009 New Revision: 189993 URL: http://svn.freebsd.org/changeset/base/189993 Log: MFC: Remove a comment and expand scope of sysctl sx lock a bit to fully restore limiting of wired memory by userspace for sysctls. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/sis/if_sis.c (props changed) stable/7/sys/dev/sis/if_sisreg.h (props changed) stable/7/sys/kern/kern_sysctl.c Modified: stable/7/sys/kern/kern_sysctl.c ============================================================================== --- stable/7/sys/kern/kern_sysctl.c Wed Mar 18 21:51:11 2009 (r189992) +++ stable/7/sys/kern/kern_sysctl.c Wed Mar 18 21:54:28 2009 (r189993) @@ -1199,14 +1199,6 @@ kernel_sysctlbyname(struct thread *td, c oid[1] = 3; /* name2oid */ oidlen = sizeof(oid); - /* - * XXX: Prone to a possible race condition between lookup and - * execution? Maybe put locking around it? - * - * Userland is just as racy, so I think the current implementation - * is fine. - */ - error = kernel_sysctl(td, oid, 2, oid, &oidlen, (void *)name, strlen(name), &plen, flags); if (error) @@ -1517,10 +1509,10 @@ userland_sysctl(struct thread *td, int * uio_yield(); } - SYSCTL_XUNLOCK(); if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); + SYSCTL_XUNLOCK(); if (error && error != ENOMEM) return (error); From jhb at FreeBSD.org Wed Mar 18 14:57:39 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Mar 18 14:57:57 2009 Subject: svn commit: r189995 - stable/7/sys/dev/sis Message-ID: <200903182157.n2ILvZgG039017@svn.freebsd.org> Author: jhb Date: Wed Mar 18 21:57:35 2009 New Revision: 189995 URL: http://svn.freebsd.org/changeset/base/189995 Log: Remove the empty mergeinfo from these files. Modified: stable/7/sys/dev/sis/if_sis.c (props changed) stable/7/sys/dev/sis/if_sisreg.h (props changed) From marius at FreeBSD.org Wed Mar 18 15:12:56 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Wed Mar 18 15:13:02 2009 Subject: svn commit: r189996 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb net netinet netinet6 Message-ID: <200903182212.n2IMCsAP039363@svn.freebsd.org> Author: marius Date: Wed Mar 18 22:12:54 2009 New Revision: 189996 URL: http://svn.freebsd.org/changeset/base/189996 Log: MFC: r189494 On architectures with strict alignment requirements compensate the misalignment of the IP header that prepending the EtherIP header might have caused. PR: 131921 Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/net/if_gif.h stable/7/sys/netinet/in_gif.c stable/7/sys/netinet6/in6_gif.c Modified: stable/7/sys/net/if_gif.h ============================================================================== --- stable/7/sys/net/if_gif.h Wed Mar 18 21:57:35 2009 (r189995) +++ stable/7/sys/net/if_gif.h Wed Mar 18 22:12:54 2009 (r189996) @@ -100,6 +100,8 @@ struct etherip_header { #define ETHERIP_VER_VERS_MASK 0x0f #define ETHERIP_VER_RSVD_MASK 0xf0 #define ETHERIP_VERSION 0x03 +/* mbuf adjust factor to force 32-bit alignment of IP header */ +#define ETHERIP_ALIGN 2 /* Prototypes */ void gif_input(struct mbuf *, int, struct ifnet *); Modified: stable/7/sys/netinet/in_gif.c ============================================================================== --- stable/7/sys/netinet/in_gif.c Wed Mar 18 21:57:35 2009 (r189995) +++ stable/7/sys/netinet/in_gif.c Wed Mar 18 22:12:54 2009 (r189996) @@ -98,7 +98,7 @@ in_gif_output(struct ifnet *ifp, int fam struct sockaddr_in *sin_dst = (struct sockaddr_in *)sc->gif_pdst; struct ip iphdr; /* capsule IP header, host byte ordered */ struct etherip_header eiphdr; - int proto, error; + int error, len, proto; u_int8_t tos; GIF_LOCK_ASSERT(sc); @@ -182,13 +182,27 @@ in_gif_output(struct ifnet *ifp, int fam &iphdr.ip_tos, &tos); /* prepend new IP header */ - M_PREPEND(m, sizeof(struct ip), M_DONTWAIT); - if (m && m->m_len < sizeof(struct ip)) - m = m_pullup(m, sizeof(struct ip)); + len = sizeof(struct ip); +#ifndef __NO_STRICT_ALIGNMENT + if (family == AF_LINK) + len += ETHERIP_ALIGN; +#endif + M_PREPEND(m, len, M_DONTWAIT); + if (m != NULL && m->m_len < len) + m = m_pullup(m, len); if (m == NULL) { printf("ENOBUFS in in_gif_output %d\n", __LINE__); return ENOBUFS; } +#ifndef __NO_STRICT_ALIGNMENT + if (family == AF_LINK) { + len = mtod(m, vm_offset_t) & 3; + KASSERT(len == 0 || len == ETHERIP_ALIGN, + ("in_gif_output: unexpected misalignment")); + m->m_data += len; + m->m_len -= ETHERIP_ALIGN; + } +#endif bcopy(&iphdr, mtod(m, struct ip *), sizeof(struct ip)); M_SETFIB(m, sc->gif_fibnum); Modified: stable/7/sys/netinet6/in6_gif.c ============================================================================== --- stable/7/sys/netinet6/in6_gif.c Wed Mar 18 21:57:35 2009 (r189995) +++ stable/7/sys/netinet6/in6_gif.c Wed Mar 18 22:12:54 2009 (r189996) @@ -96,7 +96,7 @@ in6_gif_output(struct ifnet *ifp, struct sockaddr_in6 *sin6_dst = (struct sockaddr_in6 *)sc->gif_pdst; struct ip6_hdr *ip6; struct etherip_header eiphdr; - int proto, error; + int error, len, proto; u_int8_t itos, otos; GIF_LOCK_ASSERT(sc); @@ -164,13 +164,27 @@ in6_gif_output(struct ifnet *ifp, } /* prepend new IP header */ - M_PREPEND(m, sizeof(struct ip6_hdr), M_DONTWAIT); - if (m && m->m_len < sizeof(struct ip6_hdr)) - m = m_pullup(m, sizeof(struct ip6_hdr)); + len = sizeof(struct ip6_hdr); +#ifndef __NO_STRICT_ALIGNMENT + if (family == AF_LINK) + len += ETHERIP_ALIGN; +#endif + M_PREPEND(m, len, M_DONTWAIT); + if (m != NULL && m->m_len < len) + m = m_pullup(m, len); if (m == NULL) { printf("ENOBUFS in in6_gif_output %d\n", __LINE__); return ENOBUFS; } +#ifndef __NO_STRICT_ALIGNMENT + if (family == AF_LINK) { + len = mtod(m, vm_offset_t) & 3; + KASSERT(len == 0 || len == ETHERIP_ALIGN, + ("in6_gif_output: unexpected misalignment")); + m->m_data += len; + m->m_len -= ETHERIP_ALIGN; + } +#endif ip6 = mtod(m, struct ip6_hdr *); ip6->ip6_flow = 0; From marius at FreeBSD.org Wed Mar 18 15:57:56 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Wed Mar 18 15:58:08 2009 Subject: svn commit: r189998 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/mpt Message-ID: <200903182257.n2IMvt1h040392@svn.freebsd.org> Author: marius Date: Wed Mar 18 22:57:55 2009 New Revision: 189998 URL: http://svn.freebsd.org/changeset/base/189998 Log: MFC: r172842 (partial), r178725 Restore multi-release tradition of the driver. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/mpt/mpt.h stable/7/sys/dev/mpt/mpt_cam.c stable/7/sys/dev/mpt/mpt_raid.c Modified: stable/7/sys/dev/mpt/mpt.h ============================================================================== --- stable/7/sys/dev/mpt/mpt.h Wed Mar 18 22:13:29 2009 (r189997) +++ stable/7/sys/dev/mpt/mpt.h Wed Mar 18 22:57:55 2009 (r189998) @@ -270,13 +270,30 @@ void mpt_map_rquest(void *, bus_dma_segm #define mpt_setup_intr bus_setup_intr #endif +/* **************************** NewBUS CAM Support ****************************/ +#if __FreeBSD_version < 700049 +#define mpt_xpt_bus_register(sim, parent, bus) \ + xpt_bus_register(sim, bus) +#else +#define mpt_xpt_bus_register xpt_bus_register +#endif + /**************************** Kernel Thread Support ***************************/ -#if __FreeBSD_version > 500005 +#if __FreeBSD_version > 800001 +#define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \ + kproc_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) +#define mpt_kthread_exit(status) \ + kproc_exit(status) +#elif __FreeBSD_version > 500005 #define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \ kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) +#define mpt_kthread_exit(status) \ + kthread_exit(status) #else #define mpt_kthread_create(func, farg, proc_ptr, flags, stackpgs, fmtstr, arg) \ kthread_create(func, farg, proc_ptr, fmtstr, arg) +#define mpt_kthread_exit(status) \ + kthread_exit(status) #endif /****************************** Timer Facilities ******************************/ Modified: stable/7/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/7/sys/dev/mpt/mpt_cam.c Wed Mar 18 22:13:29 2009 (r189997) +++ stable/7/sys/dev/mpt/mpt_cam.c Wed Mar 18 22:57:55 2009 (r189998) @@ -346,7 +346,7 @@ mpt_cam_attach(struct mpt_softc *mpt) * Register exactly this bus. */ MPT_LOCK(mpt); - if (xpt_bus_register(mpt->sim, mpt->dev, 0) != CAM_SUCCESS) { + if (mpt_xpt_bus_register(mpt->sim, mpt->dev, 0) != CAM_SUCCESS) { mpt_prt(mpt, "Bus registration Failed!\n"); error = ENOMEM; MPT_UNLOCK(mpt); @@ -385,7 +385,8 @@ mpt_cam_attach(struct mpt_softc *mpt) * Register this bus. */ MPT_LOCK(mpt); - if (xpt_bus_register(mpt->phydisk_sim, mpt->dev, 1) != CAM_SUCCESS) { + if (mpt_xpt_bus_register(mpt->phydisk_sim, mpt->dev, 1) != + CAM_SUCCESS) { mpt_prt(mpt, "Physical Disk Bus registration Failed!\n"); error = ENOMEM; MPT_UNLOCK(mpt); @@ -3988,7 +3989,7 @@ mpt_recovery_thread(void *arg) mpt->recovery_thread = NULL; wakeup(&mpt->recovery_thread); MPT_UNLOCK(mpt); - kthread_exit(0); + mpt_kthread_exit(0); } static int Modified: stable/7/sys/dev/mpt/mpt_raid.c ============================================================================== --- stable/7/sys/dev/mpt/mpt_raid.c Wed Mar 18 22:13:29 2009 (r189997) +++ stable/7/sys/dev/mpt/mpt_raid.c Wed Mar 18 22:57:55 2009 (r189998) @@ -722,7 +722,7 @@ mpt_raid_thread(void *arg) mpt->raid_thread = NULL; wakeup(&mpt->raid_thread); MPT_UNLOCK(mpt); - kthread_exit(0); + mpt_kthread_exit(0); } #if 0 From bms at incunabulum.net Wed Mar 18 16:08:29 2009 From: bms at incunabulum.net (Bruce Simpson) Date: Wed Mar 18 16:08:42 2009 Subject: svn commit: r189989 - stable/7/lib/libbluetooth In-Reply-To: <200903182143.n2ILhGwW038397@svn.freebsd.org> References: <200903182143.n2ILhGwW038397@svn.freebsd.org> Message-ID: <49C17EE3.5090305@incunabulum.net> Maksim Yevmenkin wrote: > Author: emax > Date: Wed Mar 18 21:43:16 2009 > New Revision: 189989 > URL: http://svn.freebsd.org/changeset/base/189989 > > Log: > MFC r189462 > MFC is ahead of schedule due to request. > > Add Bluetooth compatibility shims. Inspired by Linux BlueZ and NetBSD. > Most excellent, thank you! From marius at FreeBSD.org Wed Mar 18 16:13:37 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Wed Mar 18 16:13:44 2009 Subject: svn commit: r189999 - in stable/7/sys: . contrib/pf dev/cxgb dev/mpt Message-ID: <200903182313.n2INDZFs040748@svn.freebsd.org> Author: marius Date: Wed Mar 18 23:13:35 2009 New Revision: 189999 URL: http://svn.freebsd.org/changeset/base/189999 Log: MFC: r186878 Make the whole initiator mode part of mpt(4) endian-clean, specifically SPI controllers now also work in big-endian machines and some conversions relevant for FC and SAS controllers as well as support for ILP32 machines which all were omitted in previous attempts are now also implemented. The IOCTL-interface is intentionally left (and where needed actually changed) to be completely little-endian as otherwise we would have to add conversion code for every possible configuration page to mpt(4), which didn't seem the right thing to do, neither did converting only half of the user- interface to the native byte order. This change was tested on amd64 (SAS+SPI), i386 (SAS) and sparc64 (SAS+SPI). Due to lack of the necessary hardware the target mode code is still left to be made endian-clean. Reviewed by: scottl Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/mpt/mpt.c stable/7/sys/dev/mpt/mpt.h stable/7/sys/dev/mpt/mpt_cam.c stable/7/sys/dev/mpt/mpt_raid.c stable/7/sys/dev/mpt/mpt_user.c Modified: stable/7/sys/dev/mpt/mpt.c ============================================================================== --- stable/7/sys/dev/mpt/mpt.c Wed Mar 18 22:57:55 2009 (r189998) +++ stable/7/sys/dev/mpt/mpt.c Wed Mar 18 23:13:35 2009 (r189999) @@ -1637,7 +1637,7 @@ mpt_read_extcfg_header(struct mpt_softc rslt->PageVersion = cfgp->Header.PageVersion; rslt->PageNumber = cfgp->Header.PageNumber; rslt->PageType = cfgp->Header.PageType; - rslt->ExtPageLength = cfgp->ExtPageLength; + rslt->ExtPageLength = le16toh(cfgp->ExtPageLength); rslt->ExtPageType = cfgp->ExtPageType; error = 0; break; @@ -1668,7 +1668,7 @@ mpt_read_extcfg_page(struct mpt_softc *m req = mpt_get_request(mpt, sleep_ok); if (req == NULL) { - mpt_prt(mpt, "mpt_read_cfg_page: Get request failed!\n"); + mpt_prt(mpt, "mpt_read_extcfg_page: Get request failed!\n"); return (-1); } @@ -2025,6 +2025,7 @@ mpt_read_config_info_ioc(struct mpt_soft mpt_raid_free_mem(mpt); return (EIO); } + mpt2host_config_page_ioc3(mpt->ioc_page3); mpt_raid_wakeup(mpt); return (0); } @@ -2760,6 +2761,7 @@ mpt_enable_ioc(struct mpt_softc *mpt, in void mpt2host_sge_simple_union(SGE_SIMPLE_UNION *sge) { + MPT_2_HOST32(sge, FlagsLength); MPT_2_HOST32(sge, u.Address64.Low); MPT_2_HOST32(sge, u.Address64.High); @@ -2768,6 +2770,7 @@ mpt2host_sge_simple_union(SGE_SIMPLE_UNI void mpt2host_iocfacts_reply(MSG_IOC_FACTS_REPLY *rp) { + MPT_2_HOST16(rp, MsgVersion); MPT_2_HOST16(rp, HeaderVersion); MPT_2_HOST32(rp, MsgContext); @@ -2794,6 +2797,7 @@ mpt2host_iocfacts_reply(MSG_IOC_FACTS_RE void mpt2host_portfacts_reply(MSG_PORT_FACTS_REPLY *pfp) { + MPT_2_HOST16(pfp, Reserved); MPT_2_HOST16(pfp, Reserved1); MPT_2_HOST32(pfp, MsgContext); @@ -2809,20 +2813,139 @@ mpt2host_portfacts_reply(MSG_PORT_FACTS_ MPT_2_HOST16(pfp, Reserved4); MPT_2_HOST32(pfp, Reserved5); } + void mpt2host_config_page_ioc2(CONFIG_PAGE_IOC_2 *ioc2) { int i; - ioc2->CapabilitiesFlags = htole32(ioc2->CapabilitiesFlags); + + MPT_2_HOST32(ioc2, CapabilitiesFlags); for (i = 0; i < MPI_IOC_PAGE_2_RAID_VOLUME_MAX; i++) { MPT_2_HOST16(ioc2, RaidVolume[i].Reserved3); } } void +mpt2host_config_page_ioc3(CONFIG_PAGE_IOC_3 *ioc3) +{ + + MPT_2_HOST16(ioc3, Reserved2); +} + +void +mpt2host_config_page_scsi_port_0(CONFIG_PAGE_SCSI_PORT_0 *sp0) +{ + + MPT_2_HOST32(sp0, Capabilities); + MPT_2_HOST32(sp0, PhysicalInterface); +} + +void +mpt2host_config_page_scsi_port_1(CONFIG_PAGE_SCSI_PORT_1 *sp1) +{ + + MPT_2_HOST32(sp1, Configuration); + MPT_2_HOST32(sp1, OnBusTimerValue); + MPT_2_HOST16(sp1, IDConfig); +} + +void +host2mpt_config_page_scsi_port_1(CONFIG_PAGE_SCSI_PORT_1 *sp1) +{ + + HOST_2_MPT32(sp1, Configuration); + HOST_2_MPT32(sp1, OnBusTimerValue); + HOST_2_MPT16(sp1, IDConfig); +} + +void +mpt2host_config_page_scsi_port_2(CONFIG_PAGE_SCSI_PORT_2 *sp2) +{ + int i; + + MPT_2_HOST32(sp2, PortFlags); + MPT_2_HOST32(sp2, PortSettings); + for (i = 0; i < sizeof(sp2->DeviceSettings) / + sizeof(*sp2->DeviceSettings); i++) { + MPT_2_HOST16(sp2, DeviceSettings[i].DeviceFlags); + } +} + +void +mpt2host_config_page_scsi_device_0(CONFIG_PAGE_SCSI_DEVICE_0 *sd0) +{ + + MPT_2_HOST32(sd0, NegotiatedParameters); + MPT_2_HOST32(sd0, Information); +} + +void +mpt2host_config_page_scsi_device_1(CONFIG_PAGE_SCSI_DEVICE_1 *sd1) +{ + + MPT_2_HOST32(sd1, RequestedParameters); + MPT_2_HOST32(sd1, Reserved); + MPT_2_HOST32(sd1, Configuration); +} + +void +host2mpt_config_page_scsi_device_1(CONFIG_PAGE_SCSI_DEVICE_1 *sd1) +{ + + HOST_2_MPT32(sd1, RequestedParameters); + HOST_2_MPT32(sd1, Reserved); + HOST_2_MPT32(sd1, Configuration); +} + +void +mpt2host_config_page_fc_port_0(CONFIG_PAGE_FC_PORT_0 *fp0) +{ + + MPT_2_HOST32(fp0, Flags); + MPT_2_HOST32(fp0, PortIdentifier); + MPT_2_HOST32(fp0, WWNN.Low); + MPT_2_HOST32(fp0, WWNN.High); + MPT_2_HOST32(fp0, WWPN.Low); + MPT_2_HOST32(fp0, WWPN.High); + MPT_2_HOST32(fp0, SupportedServiceClass); + MPT_2_HOST32(fp0, SupportedSpeeds); + MPT_2_HOST32(fp0, CurrentSpeed); + MPT_2_HOST32(fp0, MaxFrameSize); + MPT_2_HOST32(fp0, FabricWWNN.Low); + MPT_2_HOST32(fp0, FabricWWNN.High); + MPT_2_HOST32(fp0, FabricWWPN.Low); + MPT_2_HOST32(fp0, FabricWWPN.High); + MPT_2_HOST32(fp0, DiscoveredPortsCount); + MPT_2_HOST32(fp0, MaxInitiators); +} + +void +mpt2host_config_page_fc_port_1(CONFIG_PAGE_FC_PORT_1 *fp1) +{ + + MPT_2_HOST32(fp1, Flags); + MPT_2_HOST32(fp1, NoSEEPROMWWNN.Low); + MPT_2_HOST32(fp1, NoSEEPROMWWNN.High); + MPT_2_HOST32(fp1, NoSEEPROMWWPN.Low); + MPT_2_HOST32(fp1, NoSEEPROMWWPN.High); +} + +void +host2mpt_config_page_fc_port_1(CONFIG_PAGE_FC_PORT_1 *fp1) +{ + + HOST_2_MPT32(fp1, Flags); + HOST_2_MPT32(fp1, NoSEEPROMWWNN.Low); + HOST_2_MPT32(fp1, NoSEEPROMWWNN.High); + HOST_2_MPT32(fp1, NoSEEPROMWWPN.Low); + HOST_2_MPT32(fp1, NoSEEPROMWWPN.High); +} + +void mpt2host_config_page_raid_vol_0(CONFIG_PAGE_RAID_VOL_0 *volp) { int i; + MPT_2_HOST16(volp, VolumeStatus.Reserved); MPT_2_HOST16(volp, VolumeSettings.Settings); MPT_2_HOST32(volp, MaxLBA); @@ -2836,8 +2959,21 @@ mpt2host_config_page_raid_vol_0(CONFIG_P } void +mpt2host_config_page_raid_phys_disk_0(CONFIG_PAGE_RAID_PHYS_DISK_0 *rpd0) +{ + + MPT_2_HOST32(rpd0, Reserved1); + MPT_2_HOST16(rpd0, PhysDiskStatus.Reserved); + MPT_2_HOST32(rpd0, MaxLBA); + MPT_2_HOST16(rpd0, ErrorData.Reserved); + MPT_2_HOST16(rpd0, ErrorData.ErrorCount); + MPT_2_HOST16(rpd0, ErrorData.SmartCount); +} + +void mpt2host_mpi_raid_vol_indicator(MPI_RAID_VOL_INDICATOR *vi) { + MPT_2_HOST16(vi, TotalBlocks.High); MPT_2_HOST16(vi, TotalBlocks.Low); MPT_2_HOST16(vi, BlocksRemaining.High); Modified: stable/7/sys/dev/mpt/mpt.h ============================================================================== --- stable/7/sys/dev/mpt/mpt.h Wed Mar 18 22:57:55 2009 (r189998) +++ stable/7/sys/dev/mpt/mpt.h Wed Mar 18 23:13:35 2009 (r189999) @@ -317,14 +317,39 @@ void mpt2host_sge_simple_union(SGE_SIMPL void mpt2host_iocfacts_reply(MSG_IOC_FACTS_REPLY *); void mpt2host_portfacts_reply(MSG_PORT_FACTS_REPLY *); void mpt2host_config_page_ioc2(CONFIG_PAGE_IOC_2 *); +void mpt2host_config_page_ioc3(CONFIG_PAGE_IOC_3 *); +void mpt2host_config_page_scsi_port_0(CONFIG_PAGE_SCSI_PORT_0 *); +void mpt2host_config_page_scsi_port_1(CONFIG_PAGE_SCSI_PORT_1 *); +void host2mpt_config_page_scsi_port_1(CONFIG_PAGE_SCSI_PORT_1 *); +void mpt2host_config_page_scsi_port_2(CONFIG_PAGE_SCSI_PORT_2 *); +void mpt2host_config_page_scsi_device_0(CONFIG_PAGE_SCSI_DEVICE_0 *); +void mpt2host_config_page_scsi_device_1(CONFIG_PAGE_SCSI_DEVICE_1 *); +void host2mpt_config_page_scsi_device_1(CONFIG_PAGE_SCSI_DEVICE_1 *); +void mpt2host_config_page_fc_port_0(CONFIG_PAGE_FC_PORT_0 *); +void mpt2host_config_page_fc_port_1(CONFIG_PAGE_FC_PORT_1 *); +void host2mpt_config_page_fc_port_1(CONFIG_PAGE_FC_PORT_1 *); void mpt2host_config_page_raid_vol_0(CONFIG_PAGE_RAID_VOL_0 *); +void mpt2host_config_page_raid_phys_disk_0(CONFIG_PAGE_RAID_PHYS_DISK_0 *); void mpt2host_mpi_raid_vol_indicator(MPI_RAID_VOL_INDICATOR *); #else #define mpt2host_sge_simple_union(x) do { ; } while (0) #define mpt2host_iocfacts_reply(x) do { ; } while (0) #define mpt2host_portfacts_reply(x) do { ; } while (0) #define mpt2host_config_page_ioc2(x) do { ; } while (0) +#define mpt2host_config_page_ioc3(x) do { ; } while (0) +#define mpt2host_config_page_scsi_port_0(x) do { ; } while (0) +#define mpt2host_config_page_scsi_port_1(x) do { ; } while (0) +#define host2mpt_config_page_scsi_port_1(x) do { ; } while (0) +#define mpt2host_config_page_scsi_port_2(x) do { ; } while (0) +#define mpt2host_config_page_scsi_device_0(x) do { ; } while (0) +#define mpt2host_config_page_scsi_device_1(x) do { ; } while (0) +#define host2mpt_config_page_scsi_device_1(x) do { ; } while (0) +#define mpt2host_config_page_fc_port_0(x) do { ; } while (0) +#define mpt2host_config_page_fc_port_1(x) do { ; } while (0) +#define host2mpt_config_page_fc_port_1(x) do { ; } while (0) #define mpt2host_config_page_raid_vol_0(x) do { ; } while (0) +#define mpt2host_config_page_raid_phys_disk_0(x) \ + do { ; } while (0) #define mpt2host_mpi_raid_vol_indicator(x) do { ; } while (0) #endif Modified: stable/7/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/7/sys/dev/mpt/mpt_cam.c Wed Mar 18 22:57:55 2009 (r189998) +++ stable/7/sys/dev/mpt/mpt_cam.c Wed Mar 18 23:13:35 2009 (r189999) @@ -437,6 +437,7 @@ mpt_read_config_info_fc(struct mpt_softc mpt_prt(mpt, "failed to read FC Port Page 0\n"); return (-1); } + mpt2host_config_page_fc_port_0(&mpt->mpt_fcport_page0); mpt->mpt_fcport_speed = mpt->mpt_fcport_page0.CurrentSpeed; @@ -527,13 +528,14 @@ mpt_set_initial_config_fc(struct mpt_sof mpt_prt(mpt, "failed to read FC page 1\n"); return (mpt_fc_reset_link(mpt, 1)); } + mpt2host_config_page_fc_port_1(&fc); /* * Check our flags to make sure we support the role we want. */ doit = 0; role = 0; - fl = le32toh(fc.Flags);; + fl = fc.Flags; if (fl & MPI_FCPORTPAGE1_FLAGS_PROT_FCP_INIT) { role |= MPT_ROLE_INITIATOR; @@ -587,7 +589,8 @@ mpt_set_initial_config_fc(struct mpt_sof } if (doit) { - fc.Flags = htole32(fl); + fc.Flags = fl; + host2mpt_config_page_fc_port_1(&fc); r = mpt_write_cfg_page(mpt, MPI_CONFIG_ACTION_PAGE_WRITE_NVRAM, 0, &fc.Header, sizeof(fc), FALSE, 5000); @@ -982,6 +985,7 @@ mpt_read_config_info_spi(struct mpt_soft if (rv) { mpt_prt(mpt, "failed to read SPI Port Page 0\n"); } else { + mpt2host_config_page_scsi_port_0(&mpt->mpt_port_page0); mpt_lprt(mpt, MPT_PRT_NEGOTIATION, "SPI Port Page 0: Capabilities %x PhysicalInterface %x\n", mpt->mpt_port_page0.Capabilities, @@ -993,6 +997,7 @@ mpt_read_config_info_spi(struct mpt_soft if (rv) { mpt_prt(mpt, "failed to read SPI Port Page 1\n"); } else { + mpt2host_config_page_scsi_port_1(&mpt->mpt_port_page1); mpt_lprt(mpt, MPT_PRT_DEBUG, "SPI Port Page 1: Configuration %x OnBusTimerValue %x\n", mpt->mpt_port_page1.Configuration, @@ -1008,6 +1013,7 @@ mpt_read_config_info_spi(struct mpt_soft "Port Page 2: Flags %x Settings %x\n", mpt->mpt_port_page2.PortFlags, mpt->mpt_port_page2.PortSettings); + mpt2host_config_page_scsi_port_2(&mpt->mpt_port_page2); for (i = 0; i < 16; i++) { mpt_lprt(mpt, MPT_PRT_NEGOTIATION, " Port Page 2 Tgt %d: timo %x SF %x Flags %x\n", @@ -1026,6 +1032,7 @@ mpt_read_config_info_spi(struct mpt_soft "cannot read SPI Target %d Device Page 0\n", i); continue; } + mpt2host_config_page_scsi_device_0(&mpt->mpt_dev_page0[i]); mpt_lprt(mpt, MPT_PRT_NEGOTIATION, "target %d page 0: Negotiated Params %x Information %x\n", i, mpt->mpt_dev_page0[i].NegotiatedParameters, @@ -1039,6 +1046,7 @@ mpt_read_config_info_spi(struct mpt_soft "cannot read SPI Target %d Device Page 1\n", i); continue; } + mpt2host_config_page_scsi_device_1(&mpt->mpt_dev_page1[i]); mpt_lprt(mpt, MPT_PRT_NEGOTIATION, "target %d page 1: Requested Params %x Configuration %x\n", i, mpt->mpt_dev_page1[i].RequestedParameters, @@ -1068,6 +1076,7 @@ mpt_set_initial_config_spi(struct mpt_so "be %x\n", mpt->mpt_port_page1.Configuration, pp1val); tmp = mpt->mpt_port_page1; tmp.Configuration = pp1val; + host2mpt_config_page_scsi_port_1(&tmp); error = mpt_write_cur_cfg_page(mpt, 0, &tmp.Header, sizeof(tmp), FALSE, 5000); if (error) { @@ -1078,6 +1087,7 @@ mpt_set_initial_config_spi(struct mpt_so if (error) { return (-1); } + mpt2host_config_page_scsi_port_1(&tmp); if (tmp.Configuration != pp1val) { mpt_prt(mpt, "failed to reset SPI Port Page 1 Config value\n"); @@ -1432,7 +1442,8 @@ bad: memset(se, 0, sizeof (*se)); se->Address.Low = htole32(dm_segs->ds_addr & 0xffffffff); if (sizeof(bus_addr_t) > 4) { - se->Address.High = ((uint64_t) dm_segs->ds_addr) >> 32; + se->Address.High = + htole32(((uint64_t)dm_segs->ds_addr) >> 32); } MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len); tf = flags; @@ -1507,9 +1518,9 @@ bad: chain_list_addr += cur_off; if (sizeof (bus_addr_t) > 4) { ce->Address.High = - htole32((uint32_t) ((uint64_t)chain_list_addr >> 32)); + htole32(((uint64_t)chain_list_addr) >> 32); } - ce->Address.Low = htole32((uint32_t) chain_list_addr); + ce->Address.Low = htole32(chain_list_addr & 0xffffffff); ce->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT | MPI_SGE_FLAGS_64_BIT_ADDRESSING; @@ -1536,6 +1547,7 @@ bad: ce->Length = (this_seg_lim - seg) * sizeof (SGE_SIMPLE64); } + ce->Length = htole16(ce->Length); /* * Fill in the chain list SGE elements with our segment data. @@ -1546,7 +1558,8 @@ bad: */ while (seg < this_seg_lim) { memset(se, 0, sizeof (*se)); - se->Address.Low = htole32(dm_segs->ds_addr); + se->Address.Low = htole32(dm_segs->ds_addr & + 0xffffffff); if (sizeof (bus_addr_t) > 4) { se->Address.High = htole32(((uint64_t)dm_segs->ds_addr) >> 32); @@ -1830,7 +1843,7 @@ bad: uint32_t tf; memset(se, 0,sizeof (*se)); - se->Address = dm_segs->ds_addr; + se->Address = htole32(dm_segs->ds_addr); @@ -1908,7 +1921,7 @@ bad: - ce->Address = chain_list_addr; + ce->Address = htole32(chain_list_addr); ce->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT; @@ -1935,6 +1948,7 @@ bad: ce->Length = (this_seg_lim - seg) * sizeof (SGE_SIMPLE32); } + ce->Length = htole16(ce->Length); /* * Fill in the chain list SGE elements with our segment data. @@ -1945,7 +1959,7 @@ bad: */ while (seg < this_seg_lim) { memset(se, 0, sizeof (*se)); - se->Address = dm_segs->ds_addr; + se->Address = htole32(dm_segs->ds_addr); @@ -2193,6 +2207,7 @@ mpt_start(struct cam_sim *sim, union ccb mpt_req->Control |= MPI_SCSIIO_CONTROL_NO_DISCONNECT; } } + mpt_req->Control = htole32(mpt_req->Control); /* Copy the scsi command block into place */ if ((ccb->ccb_h.flags & CAM_CDB_POINTER) != 0) { @@ -2317,7 +2332,7 @@ mpt_bus_reset(struct mpt_softc *mpt, tar error = mpt_wait_req(mpt, mpt->tmf_req, REQ_STATE_DONE, REQ_STATE_DONE, sleep_ok, 5000); - status = mpt->tmf_req->IOCStatus; + status = le16toh(mpt->tmf_req->IOCStatus); response = mpt->tmf_req->ResponseCode; mpt->tmf_req->state = REQ_STATE_FREE; @@ -2524,10 +2539,11 @@ mpt_cam_event(struct mpt_softc *mpt, req struct cam_sim *sim; struct cam_path *tmppath; struct ccb_relsim crs; - PTR_EVENT_DATA_QUEUE_FULL pqf = - (PTR_EVENT_DATA_QUEUE_FULL) msg->Data; + PTR_EVENT_DATA_QUEUE_FULL pqf; lun_id_t lun_id; + pqf = (PTR_EVENT_DATA_QUEUE_FULL)msg->Data; + pqf->CurrentDepth = le16toh(pqf->CurrentDepth); mpt_prt(mpt, "QUEUE FULL EVENT: Bus 0x%02x Target 0x%02x Depth " "%d\n", pqf->Bus, pqf->TargetID, pqf->CurrentDepth); if (mpt->phydisk_sim) { @@ -3086,9 +3102,10 @@ mpt_scsi_reply_frame_handler(struct mpt_ && (ccb->ccb_h.flags & (CAM_SENSE_PHYS | CAM_SENSE_PTR)) == 0) { ccb->ccb_h.status |= CAM_AUTOSNS_VALID; ccb->csio.sense_resid = - ccb->csio.sense_len - scsi_io_reply->SenseCount; + ccb->csio.sense_len - le32toh(scsi_io_reply->SenseCount); bcopy(req->sense_vbuf, &ccb->csio.sense_data, - min(ccb->csio.sense_len, scsi_io_reply->SenseCount)); + min(ccb->csio.sense_len, + le32toh(scsi_io_reply->SenseCount))); } if ((sstate & MPI_SCSI_STATE_QUEUE_TAG_REJECTED) != 0) { @@ -3776,6 +3793,8 @@ mpt_get_spi_settings(struct mpt_softc *m mpt_prt(mpt, "can't get tgt %d config page 0\n", tgt); return (rv); } + mpt2host_config_page_scsi_device_0(&tmp); + MPTLOCK_2_CAMLOCK(mpt); mpt_lprt(mpt, MPT_PRT_DEBUG, "mpt_get_spi_settings[%d]: current NP %x Info %x\n", tgt, @@ -3905,6 +3924,7 @@ mpt_update_spi_config(struct mpt_softc * "mpt_update_spi_config[%d].page1: Requested Params 0x%08x\n", tgt, mpt->mpt_dev_page1[tgt].RequestedParameters); tmp = mpt->mpt_dev_page1[tgt]; + host2mpt_config_page_scsi_device_1(&tmp); rv = mpt_write_cur_cfg_page(mpt, tgt, &tmp.Header, sizeof(tmp), FALSE, 5000); if (rv) { @@ -4156,7 +4176,7 @@ mpt_recover_commands(struct mpt_softc *m error = mpt_wait_req(mpt, mpt->tmf_req, REQ_STATE_DONE, REQ_STATE_DONE, TRUE, 500); - status = mpt->tmf_req->IOCStatus; + status = le16toh(mpt->tmf_req->IOCStatus); response = mpt->tmf_req->ResponseCode; mpt->tmf_req->state = REQ_STATE_FREE; Modified: stable/7/sys/dev/mpt/mpt_raid.c ============================================================================== --- stable/7/sys/dev/mpt/mpt_raid.c Wed Mar 18 22:57:55 2009 (r189998) +++ stable/7/sys/dev/mpt/mpt_raid.c Wed Mar 18 23:13:35 2009 (r189999) @@ -564,7 +564,7 @@ mpt_raid_reply_frame_handler(struct mpt_ action_result = REQ_TO_RAID_ACTION_RESULT(req); memcpy(&action_result->action_data, &reply->ActionData, sizeof(action_result->action_data)); - action_result->action_status = reply->ActionStatus; + action_result->action_status = le16toh(reply->ActionStatus); return (TRUE); } @@ -583,7 +583,7 @@ mpt_issue_raid_req(struct mpt_softc *mpt rap = req->req_vbuf; memset(rap, 0, sizeof *rap); rap->Action = Action; - rap->ActionDataWord = ActionDataWord; + rap->ActionDataWord = htole32(ActionDataWord); rap->Function = MPI_FUNCTION_RAID_ACTION; rap->VolumeID = vol->config_page->VolumeID; rap->VolumeBus = vol->config_page->VolumeBus; @@ -592,12 +592,13 @@ mpt_issue_raid_req(struct mpt_softc *mpt else rap->PhysDiskNum = 0xFF; se = (SGE_SIMPLE32 *)&rap->ActionDataSGE; - se->Address = addr; + se->Address = htole32(addr); MPI_pSGE_SET_LENGTH(se, len); MPI_pSGE_SET_FLAGS(se, (MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER | MPI_SGE_FLAGS_END_OF_LIST | write ? MPI_SGE_FLAGS_HOST_TO_IOC : MPI_SGE_FLAGS_IOC_TO_HOST)); + se->FlagsLength = htole32(se->FlagsLength); rap->MsgContext = htole32(req->index | raid_handler_id); mpt_check_doorbell(mpt); @@ -1226,6 +1227,7 @@ mpt_refresh_raid_disk(struct mpt_softc * mpt_prt(mpt, "mpt_refresh_raid_disk: " "Failed to read RAID Disk Page(%d)\n", ioc_disk->PhysDiskNum); + mpt2host_config_page_raid_phys_disk_0(&mpt_disk->config_page); } static void @@ -1354,6 +1356,7 @@ mpt_refresh_raid_data(struct mpt_softc * "mpt_refresh_raid_data: Failed to read IOC Page 3\n"); return (-1); } + mpt2host_config_page_ioc3(mpt->ioc_page3); ioc_disk = mpt->ioc_page3->PhysDisk; ioc_last_disk = ioc_disk + mpt->ioc_page3->NumPhysDisks; @@ -1384,6 +1387,7 @@ mpt_refresh_raid_data(struct mpt_softc * "Failed to read IOC Page 2\n"); return (-1); } + mpt2host_config_page_ioc2(mpt->ioc_page2); ioc_vol = mpt->ioc_page2->RaidVolume; ioc_last_vol = ioc_vol + mpt->ioc_page2->NumActiveVolumes; Modified: stable/7/sys/dev/mpt/mpt_user.c ============================================================================== --- stable/7/sys/dev/mpt/mpt_user.c Wed Mar 18 22:57:55 2009 (r189998) +++ stable/7/sys/dev/mpt/mpt_user.c Wed Mar 18 23:13:35 2009 (r189999) @@ -256,7 +256,7 @@ mpt_user_read_cfg_header(struct mpt_soft params.PageLength = 0; params.PageNumber = page_req->header.PageNumber; params.PageType = page_req->header.PageType; - params.PageAddress = page_req->page_address; + params.PageAddress = le32toh(page_req->page_address); error = mpt_issue_cfg_req(mpt, req, ¶ms, /*addr*/0, /*len*/0, TRUE, 5000); if (error != 0) { @@ -270,7 +270,7 @@ mpt_user_read_cfg_header(struct mpt_soft return (ETIMEDOUT); } - page_req->ioc_status = req->IOCStatus; + page_req->ioc_status = htole16(req->IOCStatus); if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) { cfgp = req->req_vbuf; bcopy(&cfgp->Header, &page_req->header, @@ -301,15 +301,15 @@ mpt_user_read_cfg_page(struct mpt_softc params.PageLength = hdr->PageLength; params.PageNumber = hdr->PageNumber; params.PageType = hdr->PageType & MPI_CONFIG_PAGETYPE_MASK; - params.PageAddress = page_req->page_address; + params.PageAddress = le32toh(page_req->page_address); error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr, - page_req->len, TRUE, 5000); + le32toh(page_req->len), TRUE, 5000); if (error != 0) { mpt_prt(mpt, "mpt_user_read_cfg_page timed out\n"); return (ETIMEDOUT); } - page_req->ioc_status = req->IOCStatus; + page_req->ioc_status = htole16(req->IOCStatus); if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) bus_dmamap_sync(mpt_page->tag, mpt_page->map, BUS_DMASYNC_POSTREAD); @@ -337,7 +337,7 @@ mpt_user_read_extcfg_header(struct mpt_s params.PageLength = 0; params.PageNumber = ext_page_req->header.PageNumber; params.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; - params.PageAddress = ext_page_req->page_address; + params.PageAddress = le32toh(ext_page_req->page_address); params.ExtPageType = ext_page_req->header.ExtPageType; params.ExtPageLength = 0; error = mpt_issue_cfg_req(mpt, req, ¶ms, /*addr*/0, /*len*/0, @@ -353,7 +353,7 @@ mpt_user_read_extcfg_header(struct mpt_s return (ETIMEDOUT); } - ext_page_req->ioc_status = req->IOCStatus; + ext_page_req->ioc_status = htole16(req->IOCStatus); if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) { cfgp = req->req_vbuf; ext_page_req->header.PageVersion = cfgp->Header.PageVersion; @@ -387,17 +387,17 @@ mpt_user_read_extcfg_page(struct mpt_sof params.PageLength = 0; params.PageNumber = hdr->PageNumber; params.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; - params.PageAddress = ext_page_req->page_address; + params.PageAddress = le32toh(ext_page_req->page_address); params.ExtPageType = hdr->ExtPageType; params.ExtPageLength = hdr->ExtPageLength; error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr, - ext_page_req->len, TRUE, 5000); + le32toh(ext_page_req->len), TRUE, 5000); if (error != 0) { mpt_prt(mpt, "mpt_user_read_extcfg_page timed out\n"); return (ETIMEDOUT); } - ext_page_req->ioc_status = req->IOCStatus; + ext_page_req->ioc_status = htole16(req->IOCStatus); if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) bus_dmamap_sync(mpt_page->tag, mpt_page->map, BUS_DMASYNC_POSTREAD); @@ -446,7 +446,7 @@ mpt_user_write_cfg_page(struct mpt_softc params.PageVersion = hdr->PageVersion; params.PageLength = hdr->PageLength; params.PageNumber = hdr->PageNumber; - params.PageAddress = page_req->page_address; + params.PageAddress = le32toh(page_req->page_address); #if 0 /* Restore stripped out attributes */ hdr->PageType |= hdr_attr; @@ -455,13 +455,13 @@ mpt_user_write_cfg_page(struct mpt_softc params.PageType = hdr->PageType; #endif error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr, - page_req->len, TRUE, 5000); + le32toh(page_req->len), TRUE, 5000); if (error != 0) { mpt_prt(mpt, "mpt_write_cfg_page timed out\n"); return (ETIMEDOUT); } - page_req->ioc_status = req->IOCStatus; + page_req->ioc_status = htole16(req->IOCStatus); mpt_free_request(mpt, req); return (0); } @@ -536,14 +536,15 @@ mpt_user_raid_action(struct mpt_softc *m if (mpt_page->vaddr != NULL && raid_act->len != 0) { bus_dmamap_sync(mpt_page->tag, mpt_page->map, BUS_DMASYNC_PREWRITE); - se->Address = mpt_page->paddr; - MPI_pSGE_SET_LENGTH(se, raid_act->len); + se->Address = htole32(mpt_page->paddr); + MPI_pSGE_SET_LENGTH(se, le32toh(raid_act->len)); MPI_pSGE_SET_FLAGS(se, (MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER | MPI_SGE_FLAGS_END_OF_LIST | raid_act->write ? MPI_SGE_FLAGS_HOST_TO_IOC : MPI_SGE_FLAGS_IOC_TO_HOST)); } + se->FlagsLength = htole32(se->FlagsLength); rap->MsgContext = htole32(req->index | user_handler_id); mpt_check_doorbell(mpt); @@ -559,7 +560,7 @@ mpt_user_raid_action(struct mpt_softc *m return (error); } - raid_act->ioc_status = req->IOCStatus; + raid_act->ioc_status = htole16(req->IOCStatus); if ((req->IOCStatus & MPI_IOCSTATUS_MASK) != MPI_IOCSTATUS_SUCCESS) { mpt_free_request(mpt, req); return (0); From marius at FreeBSD.org Wed Mar 18 16:25:13 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Wed Mar 18 16:25:19 2009 Subject: svn commit: r190000 - in stable/7/sys: . boot/sparc64/loader contrib/pf dev/ath/ath_hal dev/cxgb sparc64/include sun4v/include Message-ID: <200903182325.n2INPCZd041098@svn.freebsd.org> Author: marius Date: Wed Mar 18 23:25:12 2009 New Revision: 190000 URL: http://svn.freebsd.org/changeset/base/190000 Log: MFC: r181398 - Reimplement {d,i}tlb_enter() and {d,i}tlb_va_to_pa() in C. There's no particular reason for them to be implemented in assembler and having them in C allows easier extension as well as using more C macros and {d,i}tlb_slot_max rather than hard-coding magic (and actually spitfire-only) values. - Fix the compilation of pmap_print_tte(). - Change pmap_print_tlb() to use ldxa() rather than re-rolling it inline as well as TLB_DAR_SLOT and {d,i}tlb_slot_max rather than hardcoding magic (and actually spitfire-only) values. - While at it, suffix the above mentioned functions with "_sun4u" to underline they're architecture-specific. - Use __FBSDID and macros instead of magic values in locore.S. - Remove unused includes and smp_stack in locore.S. Modified: stable/7/sys/ (props changed) stable/7/sys/boot/sparc64/loader/locore.S stable/7/sys/boot/sparc64/loader/main.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/sparc64/include/tte.h stable/7/sys/sun4v/include/tte.h Modified: stable/7/sys/boot/sparc64/loader/locore.S ============================================================================== --- stable/7/sys/boot/sparc64/loader/locore.S Wed Mar 18 23:13:35 2009 (r189999) +++ stable/7/sys/boot/sparc64/loader/locore.S Wed Mar 18 23:25:12 2009 (r190000) @@ -4,35 +4,34 @@ * All rights reserved. * * As long as the above copyright statement and this notice remain - * unchanged, you can do what ever you want with this file. - * - * $FreeBSD$ + * unchanged, you can do what ever you want with this file. */ +#include +__FBSDID("$FreeBSD$"); + #define LOCORE -#include -#include +#include +#include +#include #include -#include -#include #define PAGE_SIZE 8192 #define PAGE_SHIFT 13 -#define SPOFF 2047 #define STACK_SIZE (2 * PAGE_SIZE) ENTRY(_start) - /* limit interrupts */ - wrpr %g0, 13, %pil + /* Limit interrupts. */ + wrpr %g0, PIL_TICK - 1, %pil /* * PSTATE: privileged, interrupts enabled, floating point * unit enabled */ - wrpr %g0, PSTATE_PRIV|PSTATE_IE|PSTATE_PEF, %pstate - wr %g0, 0x4, %fprs + wrpr %g0, PSTATE_PRIV | PSTATE_IE | PSTATE_PEF, %pstate + wr %g0, FPRS_FEF, %fprs setx stack + STACK_SIZE - SPOFF - CCFSZ, %l7, %l6 mov %l6, %sp @@ -40,74 +39,4 @@ ENTRY(_start) mov %o4, %o0 sir -/* - * %o0 input VA constant - * %o1 current iTLB offset - * %o2 current iTLB TTE tag - */ -ENTRY(itlb_va_to_pa) - clr %o1 -0: ldxa [%o1] ASI_ITLB_TAG_READ_REG, %o2 - cmp %o2, %o0 - bne,a %xcc, 1f - nop - /* return PA of matching entry */ - ldxa [%o1] ASI_ITLB_DATA_ACCESS_REG, %o0 - sllx %o0, 23, %o0 - srlx %o0, PAGE_SHIFT+23, %o0 - sllx %o0, PAGE_SHIFT, %o0 - retl - mov %o0, %o1 -1: cmp %o1, 63<<3 - blu %xcc, 0b - add %o1, 8, %o1 - clr %o0 - retl - not %o0 - -ENTRY(dtlb_va_to_pa) - clr %o1 -0: ldxa [%o1] ASI_DTLB_TAG_READ_REG, %o2 - cmp %o2, %o0 - bne,a %xcc, 1f - nop - /* return PA of matching entry */ - ldxa [%o1] ASI_DTLB_DATA_ACCESS_REG, %o0 - sllx %o0, 23, %o0 - srlx %o0, PAGE_SHIFT+23, %o0 - sllx %o0, PAGE_SHIFT, %o0 - retl - mov %o0, %o1 -1: cmp %o1, 63<<3 - blu %xcc, 0b - add %o1, 8, %o1 - clr %o0 - retl - not %o0 - -/* - * %o0 = vpn - * %o1 = tte data - */ -ENTRY(itlb_enter) - rdpr %pstate, %o4 - wrpr %o4, PSTATE_IE, %pstate - mov AA_IMMU_TAR, %o3 - stxa %o0, [%o3] ASI_IMMU - stxa %o1, [%g0] ASI_ITLB_DATA_IN_REG - membar #Sync - retl - wrpr %o4, 0, %pstate - -ENTRY(dtlb_enter) - rdpr %pstate, %o4 - wrpr %o4, PSTATE_IE, %pstate - mov AA_DMMU_TAR, %o3 - stxa %o0, [%o3] ASI_DMMU - stxa %o1, [%g0] ASI_DTLB_DATA_IN_REG - membar #Sync - retl - wrpr %o4, 0, %pstate - .comm stack, STACK_SIZE, 32 - .comm smp_stack, STACK_SIZE, 32 Modified: stable/7/sys/boot/sparc64/loader/main.c ============================================================================== --- stable/7/sys/boot/sparc64/loader/main.c Wed Mar 18 23:13:35 2009 (r189999) +++ stable/7/sys/boot/sparc64/loader/main.c Wed Mar 18 23:25:12 2009 (r190000) @@ -4,7 +4,7 @@ * All rights reserved. * * As long as the above copyright statement and this notice remain - * unchanged, you can do what ever you want with this file. + * unchanged, you can do what ever you want with this file. */ #include @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "bootstrap.h" @@ -56,10 +57,10 @@ static struct mmu_ops { typedef void kernel_entry_t(vm_offset_t mdp, u_long o1, u_long o2, u_long o3, void *openfirmware); -extern void itlb_enter(u_long vpn, u_long data); -extern void dtlb_enter(u_long vpn, u_long data); -extern vm_offset_t itlb_va_to_pa(vm_offset_t); -extern vm_offset_t dtlb_va_to_pa(vm_offset_t); +static void dtlb_enter_sun4u(u_long vpn, u_long data); +static vm_offset_t dtlb_va_to_pa_sun4u(vm_offset_t); +static void itlb_enter_sun4u(u_long vpn, u_long data); +static vm_offset_t itlb_va_to_pa_sun4u(vm_offset_t); extern vm_offset_t md_load(char *, vm_offset_t *); static int sparc64_autoload(void); static ssize_t sparc64_readin(const int, vm_offset_t, const size_t); @@ -76,6 +77,13 @@ static vm_offset_t init_heap(void); static void tlb_init_sun4u(void); static void tlb_init_sun4v(void); +#ifdef LOADER_DEBUG +typedef u_int64_t tte_t; + +static void pmap_print_tlb_sun4u(void); +static void pmap_print_tte_sun4u(tte_t, tte_t); +#endif + static struct mmu_ops mmu_ops_sun4u = { tlb_init_sun4u, mmu_mapin_sun4u }; static struct mmu_ops mmu_ops_sun4v = { tlb_init_sun4v, mmu_mapin_sun4v }; @@ -344,9 +352,8 @@ __elfN(exec)(struct preloaded_file *fp) return (error); printf("jumping to kernel entry at %#lx.\n", e->e_entry); -#if 0 - pmap_print_tlb('i'); - pmap_print_tlb('d'); +#if LOADER_DEBUG + pmap_print_tlb_sun4u(); #endif entry = e->e_entry; @@ -358,6 +365,64 @@ __elfN(exec)(struct preloaded_file *fp) panic("%s: exec returned", __func__); } +static vm_offset_t +dtlb_va_to_pa_sun4u(vm_offset_t va) +{ + u_long reg; + int i; + + for (i = 0; i < dtlb_slot_max; i++) { + reg = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_TAG_READ_REG); + if (TLB_TAR_VA(reg) != va) + continue; + reg = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_DATA_ACCESS_REG); + return ((reg & TD_PA_SF_MASK) >> TD_PA_SHIFT); + } + return (-1); +} + +static vm_offset_t +itlb_va_to_pa_sun4u(vm_offset_t va) +{ + u_long reg; + int i; + + for (i = 0; i < itlb_slot_max; i++) { + reg = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_TAG_READ_REG); + if (TLB_TAR_VA(reg) != va) + continue; + reg = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_DATA_ACCESS_REG); + return ((reg & TD_PA_SF_MASK) >> TD_PA_SHIFT); + } + return (-1); +} + +static void +itlb_enter_sun4u(u_long vpn, u_long data) +{ + u_long reg; + + reg = rdpr(pstate); + wrpr(pstate, reg & ~PSTATE_IE, 0); + stxa(AA_IMMU_TAR, ASI_IMMU, vpn); + stxa(0, ASI_ITLB_DATA_IN_REG, data); + membar(Sync); + wrpr(pstate, reg, 0); +} + +static void +dtlb_enter_sun4u(u_long vpn, u_long data) +{ + u_long reg; + + reg = rdpr(pstate); + wrpr(pstate, reg & ~PSTATE_IE, 0); + stxa(AA_DMMU_TAR, ASI_DMMU, vpn); + stxa(0, ASI_DTLB_DATA_IN_REG, data); + membar(Sync); + wrpr(pstate, reg, 0); +} + static int mmu_mapin_sun4u(vm_offset_t va, vm_size_t len) { @@ -371,8 +436,8 @@ mmu_mapin_sun4u(vm_offset_t va, vm_size_ len += va & PAGE_MASK_4M; va &= ~PAGE_MASK_4M; while (len) { - if (dtlb_va_to_pa(va) == (vm_offset_t)-1 || - itlb_va_to_pa(va) == (vm_offset_t)-1) { + if (dtlb_va_to_pa_sun4u(va) == (vm_offset_t)-1 || + itlb_va_to_pa_sun4u(va) == (vm_offset_t)-1) { /* Allocate a physical page, claim the virtual area. */ if (pa == (vm_offset_t)-1) { pa = alloc_phys(PAGE_SIZE_4M, PAGE_SIZE_4M); @@ -404,8 +469,8 @@ mmu_mapin_sun4u(vm_offset_t va, vm_size_ itlb_store[itlb_slot].te_va = va; dtlb_slot++; itlb_slot++; - dtlb_enter(va, data); - itlb_enter(va, data); + dtlb_enter_sun4u(va, data); + itlb_enter_sun4u(va, data); pa = (vm_offset_t)-1; } len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len; @@ -620,14 +685,12 @@ exit(int code) } #ifdef LOADER_DEBUG -typedef u_int64_t tte_t; - static const char *page_sizes[] = { " 8k", " 64k", "512k", " 4m" }; static void -pmap_print_tte(tte_t tag, tte_t tte) +pmap_print_tte_sun4u(tte_t tag, tte_t tte) { printf("%s %s ", @@ -641,36 +704,31 @@ pmap_print_tte(tte_t tag, tte_t tte) printf(tte & TD_L ? "\e[32mL\e[0m " : " "); printf(tte & TD_IE ? "IE " : " "); printf(tte & TD_NFO ? "NFO " : " "); - printf("tag=0x%lx pa=0x%lx va=0x%lx ctx=%ld\n", tag, TD_PA(tte), - TT_VA(tag), TT_CTX(tag)); + printf("pa=0x%lx va=0x%lx ctx=%ld\n", + TD_PA(tte), TLB_TAR_VA(tag), TLB_TAR_CTX(tag)); } -void -pmap_print_tlb(char which) + +static void +pmap_print_tlb_sun4u(void) { + tte_t tag, tte; int i; - tte_t tte, tag; - for (i = 0; i < 64*8; i += 8) { - if (which == 'i') { - __asm__ __volatile__("ldxa [%1] %2, %0\n" : - "=r" (tag) : "r" (i), - "i" (ASI_ITLB_TAG_READ_REG)); - __asm__ __volatile__("ldxa [%1] %2, %0\n" : - "=r" (tte) : "r" (i), - "i" (ASI_ITLB_DATA_ACCESS_REG)); - } - else { - __asm__ __volatile__("ldxa [%1] %2, %0\n" : - "=r" (tag) : "r" (i), - "i" (ASI_DTLB_TAG_READ_REG)); - __asm__ __volatile__("ldxa [%1] %2, %0\n" : - "=r" (tte) : "r" (i), - "i" (ASI_DTLB_DATA_ACCESS_REG)); - } + for (i = 0; i < itlb_slot_max; i++) { + tte = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_DATA_ACCESS_REG); + if (!(tte & TD_V)) + continue; + tag = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_TAG_READ_REG); + printf("iTLB-%2u: ", i); + pmap_print_tte_sun4u(tag, tte); + } + for (i = 0; i < dtlb_slot_max; i++) { + tte = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_DATA_ACCESS_REG); if (!(tte & TD_V)) continue; - printf("%cTLB-%2u: ", which, i>>3); - pmap_print_tte(tag, tte); + tag = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_TAG_READ_REG); + printf("dTLB-%2u: ", i); + pmap_print_tte_sun4u(tag, tte); } } #endif Modified: stable/7/sys/sparc64/include/tte.h ============================================================================== --- stable/7/sys/sparc64/include/tte.h Wed Mar 18 23:13:35 2009 (r189999) +++ stable/7/sys/sparc64/include/tte.h Wed Mar 18 23:25:12 2009 (r190000) @@ -43,12 +43,16 @@ #define TD_SIZE_BITS (2) #define TD_SOFT2_BITS (9) #define TD_DIAG_BITS (9) -#define TD_PA_BITS (28) +#define TD_PA_CH_BITS (30) +#define TD_PA_SF_BITS (28) +#define TD_PA_BITS TD_PA_SF_BITS #define TD_SOFT_BITS (6) #define TD_SIZE_MASK ((1UL << TD_SIZE_BITS) - 1) #define TD_SOFT2_MASK ((1UL << TD_SOFT2_BITS) - 1) #define TD_DIAG_MASK ((1UL << TD_DIAG_BITS) - 1) +#define TD_PA_CH_MASK ((1UL << TD_PA_CH_BITS) - 1) +#define TD_PA_SF_MASK ((1UL << TD_PA_SF_BITS) - 1) #define TD_PA_MASK ((1UL << TD_PA_BITS) - 1) #define TD_SOFT_MASK ((1UL << TD_SOFT_BITS) - 1) Modified: stable/7/sys/sun4v/include/tte.h ============================================================================== --- stable/7/sys/sun4v/include/tte.h Wed Mar 18 23:13:35 2009 (r189999) +++ stable/7/sys/sun4v/include/tte.h Wed Mar 18 23:25:12 2009 (r190000) @@ -41,11 +41,15 @@ #define TD_SOFT2_BITS (9) #define TD_DIAG_BITS (9) +#define TD_PA_CH_BITS (30) +#define TD_PA_SF_BITS (28) #define TD_PA_BITS (42) #define TD_SOFT_BITS (6) #define TD_SOFT2_MASK ((1UL << TD_SOFT2_BITS) - 1) #define TD_DIAG_MASK ((1UL << TD_DIAG_BITS) - 1) +#define TD_PA_CH_MASK ((1UL << TD_PA_CH_BITS) - 1) +#define TD_PA_SF_MASK ((1UL << TD_PA_SF_BITS) - 1) #define TD_PA_MASK ((1UL << TD_PA_BITS) - 1) #define TD_SOFT_MASK ((1UL << TD_SOFT_BITS) - 1) From marius at FreeBSD.org Wed Mar 18 16:35:41 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Wed Mar 18 16:35:52 2009 Subject: svn commit: r190001 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb sparc64/include Message-ID: <200903182335.n2INZepv041343@svn.freebsd.org> Author: marius Date: Wed Mar 18 23:35:40 2009 New Revision: 190001 URL: http://svn.freebsd.org/changeset/base/190001 Log: MFC: r181642 Assume OpenSolaris knows better and use their value for VM_MAX_PROM_ADDRESS. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/sparc64/include/vmparam.h Modified: stable/7/sys/sparc64/include/vmparam.h ============================================================================== --- stable/7/sys/sparc64/include/vmparam.h Wed Mar 18 23:25:12 2009 (r190000) +++ stable/7/sys/sparc64/include/vmparam.h Wed Mar 18 23:35:40 2009 (r190001) @@ -194,7 +194,7 @@ #define VM_MAX_KERNEL_ADDRESS (vm_max_kernel_address) #define VM_MIN_PROM_ADDRESS (0x00000000f0000000UL) -#define VM_MAX_PROM_ADDRESS (0x00000000ffffe000UL) +#define VM_MAX_PROM_ADDRESS (0x00000000ffffffffUL) #define VM_MIN_USER_ADDRESS (0x0000000000000000UL) #define VM_MAX_USER_ADDRESS (0x000007fe00000000UL) From marius at FreeBSD.org Wed Mar 18 16:50:26 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Wed Mar 18 16:50:32 2009 Subject: svn commit: r190002 - in stable/7/sys: . boot/sparc64/loader contrib/pf dev/ath/ath_hal dev/cxgb Message-ID: <200903182350.n2INoPhF041690@svn.freebsd.org> Author: marius Date: Wed Mar 18 23:50:25 2009 New Revision: 190002 URL: http://svn.freebsd.org/changeset/base/190002 Log: MFC: r182478, r182766 - Read ASI_{D,I}TLB_DATA_ACCESS_REG twice in order to work around errata of USIII and beyond (USIII erratum #19, USIII+ erratum #1, USIIIi erratum #1). - Use the cheetah PA mask in {d,i}tlb_va_to_pa_sun4u() for USIII and beyond. This is done so that these functions will still mask the debug bits of spitfire-class CPUs once we increase TD_PA_BITS to match the number of bits used for the PA by cheetah-class CPUs. - Change {d,i}tlb_enter_sun4u() to also set TLB_CTX_KERNEL as the context of the mappings entered. This is more or less cosmetic as TLB_CTX_KERNEL is 0. - Now that we have to distinguish between different sun4u CPUs in the loader anyway, no longer do trial and error when reading the portid property. Modified: stable/7/sys/ (props changed) stable/7/sys/boot/sparc64/loader/main.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/boot/sparc64/loader/main.c ============================================================================== --- stable/7/sys/boot/sparc64/loader/main.c Wed Mar 18 23:35:40 2009 (r190001) +++ stable/7/sys/boot/sparc64/loader/main.c Wed Mar 18 23:50:25 2009 (r190002) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "bootstrap.h" #include "libofw.h" @@ -57,8 +58,10 @@ static struct mmu_ops { typedef void kernel_entry_t(vm_offset_t mdp, u_long o1, u_long o2, u_long o3, void *openfirmware); +static inline u_long dtlb_get_data_sun4u(int slot); static void dtlb_enter_sun4u(u_long vpn, u_long data); static vm_offset_t dtlb_va_to_pa_sun4u(vm_offset_t); +static inline u_long itlb_get_data_sun4u(int slot); static void itlb_enter_sun4u(u_long vpn, u_long data); static vm_offset_t itlb_va_to_pa_sun4u(vm_offset_t); extern vm_offset_t md_load(char *, vm_offset_t *); @@ -92,6 +95,7 @@ struct tlb_entry *dtlb_store; struct tlb_entry *itlb_store; int dtlb_slot; int itlb_slot; +int cpu_impl; static int dtlb_slot_max; static int itlb_slot_max; @@ -365,60 +369,98 @@ __elfN(exec)(struct preloaded_file *fp) panic("%s: exec returned", __func__); } +static inline u_long +dtlb_get_data_sun4u(int slot) +{ + + /* + * We read ASI_DTLB_DATA_ACCESS_REG twice in order to work + * around errata of USIII and beyond. + */ + (void)ldxa(TLB_DAR_SLOT(slot), ASI_DTLB_DATA_ACCESS_REG); + return (ldxa(TLB_DAR_SLOT(slot), ASI_DTLB_DATA_ACCESS_REG)); +} + +static inline u_long +itlb_get_data_sun4u(int slot) +{ + + /* + * We read ASI_ITLB_DATA_ACCESS_REG twice in order to work + * around errata of USIII and beyond. + */ + (void)ldxa(TLB_DAR_SLOT(slot), ASI_ITLB_DATA_ACCESS_REG); + return (ldxa(TLB_DAR_SLOT(slot), ASI_ITLB_DATA_ACCESS_REG)); +} + static vm_offset_t dtlb_va_to_pa_sun4u(vm_offset_t va) { - u_long reg; + u_long pstate, reg; int i; + pstate = rdpr(pstate); + wrpr(pstate, pstate & ~PSTATE_IE, 0); for (i = 0; i < dtlb_slot_max; i++) { reg = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_TAG_READ_REG); if (TLB_TAR_VA(reg) != va) continue; - reg = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_DATA_ACCESS_REG); + reg = dtlb_get_data_sun4u(i); + wrpr(pstate, pstate, 0); + if (cpu_impl >= CPU_IMPL_ULTRASPARCIII) + return ((reg & TD_PA_CH_MASK) >> TD_PA_SHIFT); return ((reg & TD_PA_SF_MASK) >> TD_PA_SHIFT); } + wrpr(pstate, pstate, 0); return (-1); } static vm_offset_t itlb_va_to_pa_sun4u(vm_offset_t va) { - u_long reg; + u_long pstate, reg; int i; + pstate = rdpr(pstate); + wrpr(pstate, pstate & ~PSTATE_IE, 0); for (i = 0; i < itlb_slot_max; i++) { reg = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_TAG_READ_REG); if (TLB_TAR_VA(reg) != va) continue; - reg = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_DATA_ACCESS_REG); + reg = itlb_get_data_sun4u(i); + wrpr(pstate, pstate, 0); + if (cpu_impl >= CPU_IMPL_ULTRASPARCIII) + return ((reg & TD_PA_CH_MASK) >> TD_PA_SHIFT); return ((reg & TD_PA_SF_MASK) >> TD_PA_SHIFT); } + wrpr(pstate, pstate, 0); return (-1); } static void -itlb_enter_sun4u(u_long vpn, u_long data) +dtlb_enter_sun4u(u_long vpn, u_long data) { u_long reg; reg = rdpr(pstate); wrpr(pstate, reg & ~PSTATE_IE, 0); - stxa(AA_IMMU_TAR, ASI_IMMU, vpn); - stxa(0, ASI_ITLB_DATA_IN_REG, data); + stxa(AA_DMMU_TAR, ASI_DMMU, + TLB_TAR_VA(vpn) | TLB_TAR_CTX(TLB_CTX_KERNEL)); + stxa(0, ASI_DTLB_DATA_IN_REG, data); membar(Sync); wrpr(pstate, reg, 0); } static void -dtlb_enter_sun4u(u_long vpn, u_long data) +itlb_enter_sun4u(u_long vpn, u_long data) { u_long reg; reg = rdpr(pstate); wrpr(pstate, reg & ~PSTATE_IE, 0); - stxa(AA_DMMU_TAR, ASI_DMMU, vpn); - stxa(0, ASI_DTLB_DATA_IN_REG, data); + stxa(AA_IMMU_TAR, ASI_IMMU, + TLB_TAR_VA(vpn) | TLB_TAR_CTX(TLB_CTX_KERNEL)); + stxa(0, ASI_ITLB_DATA_IN_REG, data); membar(Sync); wrpr(pstate, reg, 0); } @@ -539,19 +581,18 @@ tlb_init_sun4u(void) u_int bootcpu; u_int cpu; + cpu_impl = VER_IMPL(rdpr(ver)); bootcpu = UPA_CR_GET_MID(ldxa(0, ASI_UPA_CONFIG_REG)); for (child = OF_child(root); child != 0; child = OF_peer(child)) { - if (child == -1) - panic("%s: can't get child phandle", __func__); - if (OF_getprop(child, "device_type", buf, sizeof(buf)) > 0 && - strcmp(buf, "cpu") == 0) { - if (OF_getprop(child, "upa-portid", &cpu, - sizeof(cpu)) == -1 && OF_getprop(child, "portid", - &cpu, sizeof(cpu)) == -1) - panic("%s: can't get portid", __func__); - if (cpu == bootcpu) - break; - } + if (OF_getprop(child, "device_type", buf, sizeof(buf)) <= 0) + continue; + if (strcmp(buf, "cpu") != 0) + continue; + if (OF_getprop(child, cpu_impl < CPU_IMPL_ULTRASPARCIII ? + "upa-portid" : "portid", &cpu, sizeof(cpu)) <= 0) + continue; + if (cpu == bootcpu) + break; } if (cpu != bootcpu) panic("%s: no node for bootcpu?!?!", __func__); @@ -712,10 +753,14 @@ static void pmap_print_tlb_sun4u(void) { tte_t tag, tte; + u_long pstate; int i; + pstate = rdpr(pstate); for (i = 0; i < itlb_slot_max; i++) { - tte = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_DATA_ACCESS_REG); + wrpr(pstate, pstate & ~PSTATE_IE, 0); + tte = itlb_get_data_sun4u(i); + wrpr(pstate, pstate, 0); if (!(tte & TD_V)) continue; tag = ldxa(TLB_DAR_SLOT(i), ASI_ITLB_TAG_READ_REG); @@ -723,7 +768,9 @@ pmap_print_tlb_sun4u(void) pmap_print_tte_sun4u(tag, tte); } for (i = 0; i < dtlb_slot_max; i++) { - tte = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_DATA_ACCESS_REG); + wrpr(pstate, pstate & ~PSTATE_IE, 0); + tte = dtlb_get_data_sun4u(i); + wrpr(pstate, pstate, 0); if (!(tte & TD_V)) continue; tag = ldxa(TLB_DAR_SLOT(i), ASI_DTLB_TAG_READ_REG); From marius at FreeBSD.org Wed Mar 18 17:02:09 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Wed Mar 18 17:02:21 2009 Subject: svn commit: r190004 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb sparc64/include sparc64/sparc64 Message-ID: <200903190002.n2J027PR042014@svn.freebsd.org> Author: marius Date: Thu Mar 19 00:02:07 2009 New Revision: 190004 URL: http://svn.freebsd.org/changeset/base/190004 Log: MFC: r182689 - USIII-based machines can consist of CPUs having different cache sizes (and running at different frequencies) so move the cacheinfo to the PCPU data. While at it, remove some redundant and/or unused members from struct cacheinfo. - In sparc64_init don't assume the first CPU node we find in the OFW device tree is the BSP. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/sparc64/include/cache.h stable/7/sys/sparc64/include/pcpu.h stable/7/sys/sparc64/sparc64/cache.c stable/7/sys/sparc64/sparc64/cheetah.c stable/7/sys/sparc64/sparc64/genassym.c stable/7/sys/sparc64/sparc64/machdep.c stable/7/sys/sparc64/sparc64/mp_exception.S stable/7/sys/sparc64/sparc64/mp_machdep.c stable/7/sys/sparc64/sparc64/spitfire.c Modified: stable/7/sys/sparc64/include/cache.h ============================================================================== --- stable/7/sys/sparc64/include/cache.h Wed Mar 18 23:52:20 2009 (r190003) +++ stable/7/sys/sparc64/include/cache.h Thu Mar 19 00:02:07 2009 (r190004) @@ -45,10 +45,6 @@ #ifndef _MACHINE_CACHE_H_ #define _MACHINE_CACHE_H_ -#ifndef LOCORE -#include -#endif - #define DCACHE_COLOR_BITS (1) #define DCACHE_COLORS (1 << DCACHE_COLOR_BITS) #define DCACHE_COLOR_MASK (DCACHE_COLORS - 1) @@ -80,31 +76,27 @@ * Cache control information */ struct cacheinfo { - u_int c_enabled; /* true => cache is enabled */ u_int ic_size; /* instruction cache */ - u_int ic_set; - u_int ic_l2set; u_int ic_assoc; u_int ic_linesize; u_int dc_size; /* data cache */ - u_int dc_l2size; u_int dc_assoc; u_int dc_linesize; u_int ec_size; /* external cache info */ u_int ec_assoc; - u_int ec_l2set; u_int ec_linesize; - u_int ec_l2linesize; }; #ifdef _KERNEL +struct pcpu; + typedef void cache_enable_t(void); typedef void cache_flush_t(void); typedef void dcache_page_inval_t(vm_paddr_t pa); typedef void icache_page_inval_t(vm_paddr_t pa); -void cache_init(phandle_t node); +void cache_init(struct pcpu *pcpu); cache_enable_t cheetah_cache_enable; cache_flush_t cheetah_cache_flush; @@ -121,8 +113,6 @@ extern cache_flush_t *cache_flush; extern dcache_page_inval_t *dcache_page_inval; extern icache_page_inval_t *icache_page_inval; -extern struct cacheinfo cache; - #endif /* KERNEL */ #endif /* !LOCORE */ Modified: stable/7/sys/sparc64/include/pcpu.h ============================================================================== --- stable/7/sys/sparc64/include/pcpu.h Wed Mar 18 23:52:20 2009 (r190003) +++ stable/7/sys/sparc64/include/pcpu.h Thu Mar 19 00:02:07 2009 (r190004) @@ -31,6 +31,7 @@ #define _MACHINE_PCPU_H_ #include +#include #include #include @@ -43,6 +44,7 @@ struct pmap; * point at the globaldata structure. */ #define PCPU_MD_FIELDS \ + struct cacheinfo pc_cache; \ struct intr_request pc_irpool[IR_FREE]; \ struct intr_request *pc_irhead; \ struct intr_request **pc_irtail; \ Modified: stable/7/sys/sparc64/sparc64/cache.c ============================================================================== --- stable/7/sys/sparc64/sparc64/cache.c Wed Mar 18 23:52:20 2009 (r190003) +++ stable/7/sys/sparc64/sparc64/cache.c Thu Mar 19 00:02:07 2009 (r190004) @@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include @@ -81,8 +82,6 @@ __FBSDID("$FreeBSD$"); #include #include -struct cacheinfo cache; - cache_enable_t *cache_enable; cache_flush_t *cache_flush; dcache_page_inval_t *dcache_page_inval; @@ -94,33 +93,41 @@ icache_page_inval_t *icache_page_inval; * Fill in the cache parameters using the cpu node. */ void -cache_init(phandle_t node) +cache_init(struct pcpu *pcpu) { u_long set; - if (OF_GET(node, "icache-size", cache.ic_size) == -1 || - OF_GET(node, "icache-line-size", cache.ic_linesize) == -1 || - OF_GET(node, "icache-associativity", cache.ic_assoc) == -1 || - OF_GET(node, "dcache-size", cache.dc_size) == -1 || - OF_GET(node, "dcache-line-size", cache.dc_linesize) == -1 || - OF_GET(node, "dcache-associativity", cache.dc_assoc) == -1 || - OF_GET(node, "ecache-size", cache.ec_size) == -1 || - OF_GET(node, "ecache-line-size", cache.ec_linesize) == -1 || - OF_GET(node, "ecache-associativity", cache.ec_assoc) == -1) + if (OF_GET(pcpu->pc_node, "icache-size", + pcpu->pc_cache.ic_size) == -1 || + OF_GET(pcpu->pc_node, "icache-line-size", + pcpu->pc_cache.ic_linesize) == -1 || + OF_GET(pcpu->pc_node, "icache-associativity", + pcpu->pc_cache.ic_assoc) == -1 || + OF_GET(pcpu->pc_node, "dcache-size", + pcpu->pc_cache.dc_size) == -1 || + OF_GET(pcpu->pc_node, "dcache-line-size", + pcpu->pc_cache.dc_linesize) == -1 || + OF_GET(pcpu->pc_node, "dcache-associativity", + pcpu->pc_cache.dc_assoc) == -1 || + OF_GET(pcpu->pc_node, "ecache-size", + pcpu->pc_cache.ec_size) == -1 || + OF_GET(pcpu->pc_node, "ecache-line-size", + pcpu->pc_cache.ec_linesize) == -1 || + OF_GET(pcpu->pc_node, "ecache-associativity", + pcpu->pc_cache.ec_assoc) == -1) panic("cache_init: could not retrieve cache parameters"); - cache.ic_set = cache.ic_size / cache.ic_assoc; - cache.ic_l2set = ffs(cache.ic_set) - 1; - if ((cache.ic_set & ~(1UL << cache.ic_l2set)) != 0) + set = pcpu->pc_cache.ic_size / pcpu->pc_cache.ic_assoc; + if ((set & ~(1UL << (ffs(set) - 1))) != 0) panic("cache_init: I$ set size not a power of 2"); - cache.dc_l2size = ffs(cache.dc_size) - 1; - if ((cache.dc_size & ~(1UL << cache.dc_l2size)) != 0) + if ((pcpu->pc_cache.dc_size & + ~(1UL << (ffs(pcpu->pc_cache.dc_size) - 1))) != 0) panic("cache_init: D$ size not a power of 2"); - if (((cache.dc_size / cache.dc_assoc) / PAGE_SIZE) != DCACHE_COLORS) + if (((pcpu->pc_cache.dc_size / pcpu->pc_cache.dc_assoc) / + PAGE_SIZE) != DCACHE_COLORS) panic("cache_init: too many D$ colors"); - set = cache.ec_size / cache.ec_assoc; - cache.ec_l2set = ffs(set) - 1; - if ((set & ~(1UL << cache.ec_l2set)) != 0) + set = pcpu->pc_cache.ec_size / pcpu->pc_cache.ec_assoc; + if ((set & ~(1UL << (ffs(set) - 1))) != 0) panic("cache_init: E$ set size not a power of 2"); if (cpu_impl >= CPU_IMPL_ULTRASPARCIII) { Modified: stable/7/sys/sparc64/sparc64/cheetah.c ============================================================================== --- stable/7/sys/sparc64/sparc64/cheetah.c Wed Mar 18 23:52:20 2009 (r190003) +++ stable/7/sys/sparc64/sparc64/cheetah.c Thu Mar 19 00:02:07 2009 (r190004) @@ -72,7 +72,7 @@ cheetah_dcache_page_inval(vm_paddr_t spa KASSERT((spa & PAGE_MASK) == 0, ("%s: pa not page aligned", __func__)); cookie = ipi_dcache_page_inval(tl_ipi_cheetah_dcache_page_inval, spa); - for (pa = spa; pa < spa + PAGE_SIZE; pa += cache.dc_linesize) + for (pa = spa; pa < spa + PAGE_SIZE; pa += PCPU_GET(cache.dc_linesize)) stxa_sync(pa, ASI_DCACHE_INVALIDATE, 0); ipi_wait(cookie); } Modified: stable/7/sys/sparc64/sparc64/genassym.c ============================================================================== --- stable/7/sys/sparc64/sparc64/genassym.c Wed Mar 18 23:52:20 2009 (r190003) +++ stable/7/sys/sparc64/sparc64/genassym.c Thu Mar 19 00:02:07 2009 (r190004) @@ -188,11 +188,12 @@ ASSYM(PM_TSB_MISS_COUNT, offsetof(struct ASSYM(PM_TSB_CAP_MISS_COUNT, offsetof(struct pmap, pm_tsb_cap_miss_count)); #endif #ifdef SUN4U +ASSYM(PC_CACHE, offsetof(struct pcpu, pc_cache)); ASSYM(PC_MID, offsetof(struct pcpu, pc_mid)); +ASSYM(PC_PMAP, offsetof(struct pcpu, pc_pmap)); ASSYM(PC_TLB_CTX, offsetof(struct pcpu, pc_tlb_ctx)); ASSYM(PC_TLB_CTX_MAX, offsetof(struct pcpu, pc_tlb_ctx_max)); ASSYM(PC_TLB_CTX_MIN, offsetof(struct pcpu, pc_tlb_ctx_min)); -ASSYM(PC_PMAP, offsetof(struct pcpu, pc_pmap)); #endif ASSYM(IR_NEXT, offsetof(struct intr_request, ir_next)); Modified: stable/7/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/machdep.c Wed Mar 18 23:52:20 2009 (r190003) +++ stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 00:02:07 2009 (r190004) @@ -279,6 +279,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_l phandle_t child; phandle_t root; u_int clock; + uint32_t portid; end = 0; kmdp = NULL; @@ -314,12 +315,40 @@ sparc64_init(caddr_t mdp, u_long o1, u_l init_param1(); + /* + * Prime our per-CPU data page for use. Note, we are using it for + * our stack, so don't pass the real size (PAGE_SIZE) to pcpu_init + * or it'll zero it out from under us. + */ + pc = (struct pcpu *)(pcpu0 + (PCPU_PAGES * PAGE_SIZE)) - 1; + pcpu_init(pc, 0, sizeof(struct pcpu)); + pc->pc_addr = (vm_offset_t)pcpu0; + pc->pc_mid = UPA_CR_GET_MID(ldxa(0, ASI_UPA_CONFIG_REG)); + pc->pc_tlb_ctx = TLB_CTX_USER_MIN; + pc->pc_tlb_ctx_min = TLB_CTX_USER_MIN; + pc->pc_tlb_ctx_max = TLB_CTX_USER_MAX; + + /* + * Determine the OFW node (and ensure the + * BSP is in the device tree in the first place). + */ + pc->pc_node = 0; root = OF_peer(0); for (child = OF_child(root); child != 0; child = OF_peer(child)) { - OF_getprop(child, "device_type", type, sizeof(type)); - if (strcmp(type, "cpu") == 0) + if (OF_getprop(child, "device_type", type, sizeof(type)) <= 0) + continue; + if (strcmp(type, "cpu") != 0) + continue; + if (OF_getprop(child, cpu_impl < CPU_IMPL_ULTRASPARCIII ? + "upa-portid" : "portid", &portid, sizeof(portid)) <= 0) + continue; + if (portid == pc->pc_mid) { + pc->pc_node = child; break; + } } + if (pc->pc_node == 0) + OF_exit(); /* * Initialize the tick counter. Must be before the console is inited @@ -353,8 +382,8 @@ sparc64_init(caddr_t mdp, u_long o1, u_l end = (vm_offset_t)_end; } - cache_init(child); - uma_set_align(cache.dc_linesize - 1); + cache_init(pc); + uma_set_align(pc->pc_cache.dc_linesize - 1); cpu_block_copy = bcopy; cpu_block_zero = bzero; @@ -397,7 +426,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_l intr_init1(); /* - * Initialize proc0 stuff (p_contested needs to be done early). + * Initialize proc0, set kstack0, frame0, curthread and curpcb. */ proc_linkup0(&proc0, &thread0); proc0.p_md.md_sigtramp = NULL; @@ -407,22 +436,8 @@ sparc64_init(caddr_t mdp, u_long o1, u_l (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; frame0.tf_tstate = TSTATE_IE | TSTATE_PEF | TSTATE_PRIV; thread0.td_frame = &frame0; - - /* - * Prime our per-cpu data page for use. Note, we are using it for our - * stack, so don't pass the real size (PAGE_SIZE) to pcpu_init or - * it'll zero it out from under us. - */ - pc = (struct pcpu *)(pcpu0 + (PCPU_PAGES * PAGE_SIZE)) - 1; - pcpu_init(pc, 0, sizeof(struct pcpu)); pc->pc_curthread = &thread0; pc->pc_curpcb = thread0.td_pcb; - pc->pc_mid = UPA_CR_GET_MID(ldxa(0, ASI_UPA_CONFIG_REG)); - pc->pc_addr = (vm_offset_t)pcpu0; - pc->pc_node = child; - pc->pc_tlb_ctx = TLB_CTX_USER_MIN; - pc->pc_tlb_ctx_min = TLB_CTX_USER_MIN; - pc->pc_tlb_ctx_max = TLB_CTX_USER_MAX; /* * Initialize global registers. Modified: stable/7/sys/sparc64/sparc64/mp_exception.S ============================================================================== --- stable/7/sys/sparc64/sparc64/mp_exception.S Wed Mar 18 23:52:20 2009 (r190003) +++ stable/7/sys/sparc64/sparc64/mp_exception.S Thu Mar 19 00:02:07 2009 (r190004) @@ -57,9 +57,8 @@ ENTRY(tl_ipi_spitfire_dcache_page_inval) ldx [%g5 + ICA_PA], %g6 srlx %g6, PAGE_SHIFT - DC_TAG_SHIFT, %g6 - SET(cache, %g3, %g2) - lduw [%g2 + DC_SIZE], %g3 - lduw [%g2 + DC_LINESIZE], %g4 + lduw [PCPU(CACHE) + DC_SIZE], %g3 + lduw [PCPU(CACHE) + DC_LINESIZE], %g4 sub %g3, %g4, %g2 1: ldxa [%g2] ASI_DCACHE_TAG, %g1 @@ -98,9 +97,8 @@ ENTRY(tl_ipi_spitfire_icache_page_inval) ldx [%g5 + ICA_PA], %g6 srlx %g6, PAGE_SHIFT - IC_TAG_SHIFT, %g6 - SET(cache, %g3, %g2) - lduw [%g2 + IC_SIZE], %g3 - lduw [%g2 + IC_LINESIZE], %g4 + lduw [PCPU(CACHE) + IC_SIZE], %g3 + lduw [PCPU(CACHE) + IC_LINESIZE], %g4 sub %g3, %g4, %g2 1: ldda [%g2] ASI_ICACHE_TAG, %g0 /*, %g1 */ @@ -140,8 +138,7 @@ ENTRY(tl_ipi_cheetah_dcache_page_inval) set PAGE_SIZE, %g2 add %g1, %g2, %g3 - SET(cache, %g4, %g2) - lduw [%g2 + DC_LINESIZE], %g2 + lduw [PCPU(CACHE) + DC_LINESIZE], %g2 1: stxa %g0, [%g1] ASI_DCACHE_INVALIDATE membar #Sync Modified: stable/7/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/mp_machdep.c Wed Mar 18 23:52:20 2009 (r190003) +++ stable/7/sys/sparc64/sparc64/mp_machdep.c Thu Mar 19 00:02:07 2009 (r190004) @@ -294,6 +294,8 @@ cpu_mp_start(void) pc->pc_mid = mid; pc->pc_node = child; + cache_init(pc); + all_cpus |= 1 << cpuid; intr_add_cpu(cpuid); } Modified: stable/7/sys/sparc64/sparc64/spitfire.c ============================================================================== --- stable/7/sys/sparc64/sparc64/spitfire.c Wed Mar 18 23:52:20 2009 (r190003) +++ stable/7/sys/sparc64/sparc64/spitfire.c Thu Mar 19 00:02:07 2009 (r190004) @@ -72,9 +72,11 @@ spitfire_cache_flush(void) { u_long addr; - for (addr = 0; addr < cache.dc_size; addr += cache.dc_linesize) + for (addr = 0; addr < PCPU_GET(cache.dc_size); + addr += PCPU_GET(cache.dc_linesize)) stxa_sync(addr, ASI_DCACHE_TAG, 0); - for (addr = 0; addr < cache.ic_size; addr += cache.ic_linesize) + for (addr = 0; addr < PCPU_GET(cache.ic_size); + addr += PCPU_GET(cache.ic_linesize)) stxa_sync(addr, ASI_ICACHE_TAG, 0); } @@ -93,7 +95,8 @@ spitfire_dcache_page_inval(vm_paddr_t pa PMAP_STATS_INC(spitfire_dcache_npage_inval); target = pa >> (PAGE_SHIFT - DC_TAG_SHIFT); cookie = ipi_dcache_page_inval(tl_ipi_spitfire_dcache_page_inval, pa); - for (addr = 0; addr < cache.dc_size; addr += cache.dc_linesize) { + for (addr = 0; addr < PCPU_GET(cache.dc_size); + addr += PCPU_GET(cache.dc_linesize)) { tag = ldxa(addr, ASI_DCACHE_TAG); if (((tag >> DC_VALID_SHIFT) & DC_VALID_MASK) == 0) continue; @@ -121,7 +124,8 @@ spitfire_icache_page_inval(vm_paddr_t pa PMAP_STATS_INC(spitfire_icache_npage_inval); target = pa >> (PAGE_SHIFT - IC_TAG_SHIFT); cookie = ipi_icache_page_inval(tl_ipi_spitfire_icache_page_inval, pa); - for (addr = 0; addr < cache.ic_size; addr += cache.ic_linesize) { + for (addr = 0; addr < PCPU_GET(cache.ic_size); + addr += PCPU_GET(cache.ic_linesize)) { __asm __volatile("ldda [%1] %2, %%g0" /*, %g1 */ : "=r" (tag) : "r" (addr), "n" (ASI_ICACHE_TAG)); if (((tag >> IC_VALID_SHIFT) & IC_VALID_MASK) == 0) From marius at FreeBSD.org Wed Mar 18 17:04:32 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Wed Mar 18 17:04:38 2009 Subject: svn commit: r190005 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb sun4v/sun4v Message-ID: <200903190004.n2J04Ukt042125@svn.freebsd.org> Author: marius Date: Thu Mar 19 00:04:30 2009 New Revision: 190005 URL: http://svn.freebsd.org/changeset/base/190005 Log: MFC: r182691 Resurrect clock.c from r164371. Added: stable/7/sys/sun4v/sun4v/clock.c - copied unchanged from r182691, head/sys/sun4v/sun4v/clock.c Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Copied: stable/7/sys/sun4v/sun4v/clock.c (from r182691, head/sys/sun4v/sun4v/clock.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/sun4v/sun4v/clock.c Thu Mar 19 00:04:30 2009 (r190005, copy of r182691, head/sys/sun4v/sun4v/clock.c) @@ -0,0 +1,67 @@ +/*- + * Copyright (c) 2001 Jake Burkholder. + * 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$ + */ + +#include +#include +#include + +u_long tick_increment; +u_long tick_freq; +u_long tick_MHz; + +void +DELAY(int n) +{ + u_long start, end; + + start = rd(tick); + if (n < 0) + return; + end = start + (u_long)n * tick_MHz; + while (rd(tick) < end) + ; +} + +void +cpu_startprofclock(void) +{ +} + +void +cpu_stopprofclock(void) +{ +} + +int +sysbeep(int pitch, int period) +{ + /* + * XXX: function exists to enable RAID drivers to compile at the moment. + */ + return (0); +} From sam at FreeBSD.org Wed Mar 18 17:28:55 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Wed Mar 18 17:29:01 2009 Subject: svn commit: r190006 - in stable/7/usr.sbin: . makefs Message-ID: <200903190028.n2J0SsTa042656@svn.freebsd.org> Author: sam Date: Thu Mar 19 00:28:54 2009 New Revision: 190006 URL: http://svn.freebsd.org/changeset/base/190006 Log: MFC makefs: a tool for creating a file system image from a directory tree Added: stable/7/usr.sbin/makefs/ (props changed) - copied from r189999, head/usr.sbin/makefs/ Modified: stable/7/usr.sbin/Makefile Modified: stable/7/usr.sbin/Makefile ============================================================================== --- stable/7/usr.sbin/Makefile Thu Mar 19 00:04:30 2009 (r190005) +++ stable/7/usr.sbin/Makefile Thu Mar 19 00:28:54 2009 (r190006) @@ -86,6 +86,7 @@ SUBDIR= ${_ac} \ ${_lptcontrol} \ ${_mailstats} \ mailwrapper \ + makefs \ ${_makemap} \ manctl \ memcontrol \ From yongari at FreeBSD.org Wed Mar 18 17:52:31 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Wed Mar 18 17:52:48 2009 Subject: svn commit: r190008 - in stable/7/sys: . contrib/pf dev/cxgb dev/sis Message-ID: <200903190052.n2J0qUSj043249@svn.freebsd.org> Author: yongari Date: Thu Mar 19 00:52:30 2009 New Revision: 190008 URL: http://svn.freebsd.org/changeset/base/190008 Log: MFC r185784: Fix a long standing VLAN tagged frame handling bug. When VLAN tagged frame is received the hardware sets 'LONG' bit of Rx status word. It is always set when the size of received frame exceeded 1518 bytes, including CRC. This VLAN tagged frame clears 'OK' bit of Rx status word such that driver should not rely on 'OK' bit of Rx status word to pass the VLAN tagged frame to upper stack. To fix the bug, don't use SIS_CMDSTS_PKT_OK for Rx error check and introduce SIS_RXSTAT_ERROR macro that checks Rx errors. If we are configured to accept VLAN tagged frames and the received frame size is less than or equal to maximum allowed length of VLAN tagged frame, clear 'LONG' bit of Rx status word before checking Rx errors. Reported by: Vladimir Ermako < samflanker <> gmail DOT com > Tested by: Vladimir Ermako < samflanker <> gmail DOT com > Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/sis/if_sis.c stable/7/sys/dev/sis/if_sisreg.h Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Thu Mar 19 00:44:22 2009 (r190007) +++ stable/7/sys/dev/sis/if_sis.c Thu Mar 19 00:52:30 2009 (r190008) @@ -1431,7 +1431,11 @@ sis_rxeof(struct sis_softc *sc) * it should simply get re-used next time this descriptor * comes up in the ring. */ - if (!(rxstat & SIS_CMDSTS_PKT_OK)) { + if ((ifp->if_capenable & IFCAP_VLAN_MTU) != 0 && + total_len <= (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN - + ETHER_CRC_LEN)) + rxstat &= ~SIS_RXSTAT_GIANT; + if (SIS_RXSTAT_ERROR(rxstat) != 0) { ifp->if_ierrors++; if (rxstat & SIS_RXSTAT_COLL) ifp->if_collisions++; Modified: stable/7/sys/dev/sis/if_sisreg.h ============================================================================== --- stable/7/sys/dev/sis/if_sisreg.h Thu Mar 19 00:44:22 2009 (r190007) +++ stable/7/sys/dev/sis/if_sisreg.h Thu Mar 19 00:52:30 2009 (r190008) @@ -348,6 +348,11 @@ struct sis_desc { #define SIS_RXSTAT_OVERRUN 0x02000000 #define SIS_RXSTAT_RX_ABORT 0x04000000 +#define SIS_RXSTAT_ERROR(x) \ + ((x) & (SIS_RXSTAT_RX_ABORT | SIS_RXSTAT_OVERRUN | \ + SIS_RXSTAT_GIANT | SIS_RXSTAT_SYMBOLERR | SIS_RXSTAT_RUNT | \ + SIS_RXSTAT_CRCERR | SIS_RXSTAT_ALIGNERR)) + #define SIS_DSTCLASS_REJECT 0x00000000 #define SIS_DSTCLASS_UNICAST 0x00800000 #define SIS_DSTCLASS_MULTICAST 0x01000000 From yongari at FreeBSD.org Wed Mar 18 17:55:28 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Wed Mar 18 17:55:45 2009 Subject: svn commit: r190009 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/sis Message-ID: <200903190055.n2J0tRqc043360@svn.freebsd.org> Author: yongari Date: Thu Mar 19 00:55:27 2009 New Revision: 190009 URL: http://svn.freebsd.org/changeset/base/190009 Log: MFC r188550: Receving VLAN oversized frames raise SIS_ISR_RX_ERR interrupt, so make sis_rxeof() handle that too. Previously it used to receive the frame and reset controller. PR: kern/131414 Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/sis/if_sis.c Modified: stable/7/sys/dev/sis/if_sis.c ============================================================================== --- stable/7/sys/dev/sis/if_sis.c Thu Mar 19 00:52:30 2009 (r190008) +++ stable/7/sys/dev/sis/if_sis.c Thu Mar 19 00:55:27 2009 (r190009) @@ -1662,10 +1662,11 @@ sis_intr(void *arg) SIS_ISR_TX_OK | SIS_ISR_TX_IDLE) ) sis_txeof(sc); - if (status & (SIS_ISR_RX_DESC_OK|SIS_ISR_RX_OK|SIS_ISR_RX_IDLE)) + if (status & (SIS_ISR_RX_DESC_OK | SIS_ISR_RX_OK | + SIS_ISR_RX_ERR | SIS_ISR_RX_IDLE)) sis_rxeof(sc); - if (status & (SIS_ISR_RX_ERR | SIS_ISR_RX_OFLOW)) + if (status & SIS_ISR_RX_OFLOW) sis_rxeoc(sc); if (status & (SIS_ISR_RX_IDLE)) From yongari at FreeBSD.org Wed Mar 18 18:07:23 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Wed Mar 18 18:07:31 2009 Subject: svn commit: r190010 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/txp Message-ID: <200903190107.n2J17LhO043610@svn.freebsd.org> Author: yongari Date: Thu Mar 19 01:07:21 2009 New Revision: 190010 URL: http://svn.freebsd.org/changeset/base/190010 Log: MFC r189022: Update to latest 3Com firmware image. The latest fimware is required to make 3CR990 familiy controllers run on NV flash firmware version 03.001.008. The latest firmware added HMAC digest information so teach txp(4) to pass them to sleep image before downloading is started. While I'm here restore previous IMR/IER register if firmware downloading have failed. PR: kern/89876, kern/132047 Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/txp/3c990img.h stable/7/sys/dev/txp/if_txp.c stable/7/sys/dev/txp/if_txpreg.h Modified: stable/7/sys/dev/txp/3c990img.h ============================================================================== --- stable/7/sys/dev/txp/3c990img.h Thu Mar 19 00:55:27 2009 (r190009) +++ stable/7/sys/dev/txp/3c990img.h Thu Mar 19 01:07:21 2009 (r190010) @@ -1,22 +1,17 @@ -/* $OpenBSD: 3c990img.h,v 1.2 2001/06/05 02:15:17 jason Exp $ */ -/* $FreeBSD$ */ +/* $FreeBSD$ */ /*- - * Copyright (C) 1999-2001 3Com, Inc. - * All rights reserved. + * Copyright 1999-2003 3Com Corporation. All Rights Reserved. * - * Redistribution and use in source and binary forms of the 3CR990 microcode - * are permitted provided - * that the following conditions are met: + * Redistribution and use in source and binary forms of the 3c990img.h + * microcode software are permitted provided that the following conditions + * are met: * 1. Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistribution 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes 3CR990 microcode - * 4. The name of 3Com may not be used to endorse or promote products + * 3. The name of 3Com may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY 3COM ``AS IS'' AND ANY EXPRESS OR @@ -30,735 +25,458 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * USER ACKNOWLEDGES AND AGREES THAT PURCHASE OR USE OF THE 3CR990 microcode - * SOFTWARE WILL NOT CREATE OR GIVE GROUNDS FOR A LICENSE BY IMPLICATION, - * ESTOPPEL, OR OTHERWISE IN ANY INTELLECTUAL PROPERTY RIGHTS (PATENT, COPYRIGHT, - * TRADE SECRET, MASK WORK, OR OTHER PROPRIETARY RIGHT) EMBODIED IN ANY OTHER - * 3COM HARDWARE OR SOFTWARE EITHER SOLELY OR IN COMBINATION WITH THE 3CR990 - * microcode SOFTWARE - */ + * USER ACKNOWLEDGES AND AGREES THAT PURCHASE OR USE OF THE 3c990img.h + * MICROCODE SOFTWARE WILL NOT CREATE OR GIVE GROUNDS FOR A LICENSE BY + * IMPLICATION, ESTOPPEL, OR OTHERWISE IN ANY INTELLECTUAL PROPERTY RIGHTS + * (PATENT, COPYRIGHT, TRADE SECRET, MASK WORK, OR OTHER PROPRIETARY RIGHT) + * EMBODIED IN ANY OTHER 3COM HARDWARE OR SOFTWARE EITHER SOLELY OR IN + * COMBINATION WITH THE 3c990img.h MICROCODE SOFTWARE + */ unsigned char tc990image[] = { 0x54, 0x59, 0x50, 0x48, 0x4f, 0x4f, 0x4e, 0x00, 0x02, 0x00, 0x00, 0x00, -0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x40, 0x01, 0x00, 0x00, -0xd6, 0xbb, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x39, 0x00, 0x00, 0xea, -0x05, 0x00, 0x00, 0xea, 0x04, 0x00, 0x00, 0xea, 0x03, 0x00, 0x00, 0xea, -0x02, 0x00, 0x00, 0xea, 0x01, 0x00, 0x00, 0xea, 0x4a, 0x05, 0x00, 0xea, -0xb4, 0x1d, 0x00, 0xea, 0x07, 0x00, 0x2d, 0xe9, 0x0e, 0x00, 0xa0, 0xe1, -0x00, 0x10, 0x0f, 0xe1, 0xd0, 0x20, 0x9f, 0xe5, 0x12, 0xff, 0x2f, 0xe1, -0xfe, 0xff, 0xff, 0xea, 0x01, 0x00, 0x80, 0xe0, 0x04, 0x20, 0x81, 0xe4, -0x01, 0x00, 0x50, 0xe1, 0xfc, 0xff, 0xff, 0x1a, 0x0e, 0xf0, 0xa0, 0xe1, -0x00, 0xa0, 0xa0, 0xe1, 0x0e, 0xb0, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe3, -0xa8, 0x10, 0x9f, 0xe5, 0x00, 0x00, 0x81, 0xe5, 0xa4, 0x10, 0x9f, 0xe5, -0x00, 0x00, 0x81, 0xe5, 0x01, 0x16, 0xa0, 0xe3, 0x00, 0x00, 0x91, 0xe5, -0x01, 0x00, 0x80, 0xe3, 0x00, 0x00, 0x81, 0xe5, 0xd7, 0x00, 0xa0, 0xe3, -0x00, 0xf0, 0x21, 0xe1, 0x88, 0xd0, 0x9f, 0xe5, 0xdb, 0x00, 0xa0, 0xe3, -0x00, 0xf0, 0x21, 0xe1, 0x7c, 0xd0, 0x9f, 0xe5, 0xd2, 0x00, 0xa0, 0xe3, -0x00, 0xf0, 0x21, 0xe1, 0x74, 0xd0, 0x9f, 0xe5, 0xd1, 0x00, 0xa0, 0xe3, -0x00, 0xf0, 0x21, 0xe1, 0x6c, 0xd0, 0x9f, 0xe5, 0x8a, 0x1d, 0x00, 0xeb, -0xd3, 0x00, 0xa0, 0xe3, 0x00, 0xf0, 0x21, 0xe1, 0x60, 0xd0, 0x9f, 0xe5, -0x60, 0x00, 0x9f, 0xe5, 0x60, 0x10, 0x9f, 0xe5, 0x60, 0x20, 0x9f, 0xe5, -0xdb, 0xff, 0xff, 0xeb, 0x5c, 0x00, 0x9f, 0xe5, 0x5c, 0x10, 0x9f, 0xe5, -0x00, 0x20, 0xa0, 0xe3, 0xd7, 0xff, 0xff, 0xeb, 0x54, 0x00, 0x9f, 0xe5, -0x54, 0x10, 0x9f, 0xe5, 0xd4, 0xff, 0xff, 0xeb, 0x0a, 0x00, 0xa0, 0xe1, -0x0b, 0xf0, 0xa0, 0xe1, 0xd3, 0x10, 0xa0, 0xe3, 0x01, 0xf0, 0x21, 0xe1, -0xd4, 0xff, 0xff, 0xeb, 0x3c, 0xa0, 0x9f, 0xe5, 0x1a, 0xff, 0x2f, 0xe1, -0xc6, 0xff, 0xff, 0xea, 0x01, 0x2e, 0xff, 0xff, 0x0c, 0x00, 0x10, 0x00, -0x1c, 0x00, 0x10, 0x00, 0x3c, 0x38, 0x00, 0x80, 0xfc, 0x37, 0x00, 0x80, -0xfc, 0x3f, 0x00, 0x80, 0xfc, 0x33, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, -0x00, 0x30, 0x00, 0x80, 0xad, 0xde, 0xad, 0xde, 0xc8, 0xc2, 0x00, 0x00, -0x20, 0xab, 0x20, 0x40, 0x5c, 0x2b, 0x00, 0x00, 0x9c, 0x04, 0x00, 0x80, -0xd1, 0xd1, 0x21, 0x40, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x40, 0x7b, 0x00, 0x00, 0x4d, 0x42, 0x00, 0x00, -0x60, 0x01, 0xff, 0xff, 0xb0, 0xb5, 0x07, 0x1c, 0x12, 0x4c, 0x00, 0x25, -0x60, 0x6b, 0x00, 0x28, 0x1d, 0xd0, 0x38, 0x1c, 0x10, 0x49, 0x06, 0xf0, -0x55, 0xff, 0x61, 0x6b, 0xc0, 0x46, 0x08, 0x60, 0x00, 0x28, 0x14, 0xd0, -0x38, 0x01, 0x0d, 0x49, 0x40, 0x18, 0x19, 0x23, 0xdb, 0x01, 0xc0, 0x18, -0x41, 0x6b, 0x80, 0x29, 0x0b, 0xd2, 0x01, 0x31, 0x41, 0x63, 0x60, 0x6b, -0xc1, 0x69, 0xc0, 0x46, 0x61, 0x63, 0x39, 0x07, 0x41, 0x60, 0xc7, 0x62, -0xb0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x28, 0x1c, 0xfa, 0xe7, 0x00, 0x00, -0x38, 0x17, 0x00, 0x80, 0xee, 0x05, 0x00, 0x00, 0x58, 0x1d, 0x00, 0x80, -0x02, 0x49, 0x4a, 0x6b, 0xc0, 0x46, 0xc2, 0x61, 0x48, 0x63, 0x70, 0x47, -0x38, 0x17, 0x00, 0x80, 0x00, 0x20, 0x02, 0x49, 0xc0, 0x46, 0x48, 0x61, -0x70, 0x47, 0x00, 0x00, 0x9c, 0x04, 0x00, 0x80, -0x00, 0xb5, 0x00, 0x20, 0x04, 0x49, 0xc0, 0x46, 0x48, 0x61, 0x04, 0x48, -0x04, 0x49, 0x09, 0x68, 0x07, 0xf0, 0xa3, 0xf9, 0x08, 0xbc, 0x18, 0x47, -0x9c, 0x04, 0x00, 0x80, 0xdd, 0x01, 0xff, 0xff, 0x74, 0x76, 0x21, 0x40, -0xf0, 0xb5, 0x04, 0x1c, 0x41, 0x4e, 0x00, 0x25, 0x70, 0x69, 0x00, 0x28, -0x03, 0xd1, 0xff, 0xf7, 0xa7, 0xff, 0x07, 0x1c, 0x03, 0xd1, 0x28, 0x1c, -0xf0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x3c, 0x21, 0x00, 0x20, 0x79, 0x60, -0xbd, 0x60, 0x06, 0xf0, 0x2f, 0xff, 0x00, 0x20, 0x79, 0x68, 0x00, 0x29, -0x06, 0xd9, 0x39, 0x68, 0xc0, 0x46, 0x0d, 0x54, 0x79, 0x68, 0x01, 0x30, -0x81, 0x42, 0xf8, 0xd8, 0x39, 0x68, 0x00, 0x20, 0xff, 0x23, 0x0a, 0x18, -0x13, 0x70, 0x43, 0x08, 0x05, 0xd3, 0x43, 0x08, 0x5b, 0x00, 0x1b, 0x19, -0x1b, 0x89, 0x1b, 0x0a, 0x05, 0xe0, 0x43, 0x08, 0x5b, 0x00, 0x1b, 0x19, -0x1b, 0x89, 0x1b, 0x06, 0x1b, 0x0e, 0x93, 0x71, 0x01, 0x30, 0x06, 0x28, -0xea, 0xd3, 0xc1, 0x20, 0xc0, 0x00, 0x08, 0x73, 0x03, 0x0a, 0x4b, 0x73, -0x38, 0x68, 0xff, 0x21, 0x01, 0x31, 0x81, 0x73, 0x0b, 0x0a, 0xc3, 0x73, -0x08, 0x22, 0x02, 0x74, 0x13, 0x0a, 0x43, 0x74, 0x06, 0x22, 0x82, 0x74, -0x04, 0x22, 0xc2, 0x74, 0x01, 0x75, 0x0b, 0x0a, 0x43, 0x75, 0x0e, 0x30, -0x00, 0x21, 0x4a, 0x00, 0x13, 0x19, 0x1d, 0x89, 0x16, 0x18, 0x35, 0x72, -0x2b, 0x0a, 0x73, 0x72, 0x00, 0x25, 0x17, 0x4e, 0x92, 0x19, 0xd5, 0x81, -0x01, 0x31, 0x03, 0x29, 0xf1, 0xd3, 0x21, 0x68, 0xc0, 0x46, 0x81, 0x73, -0x0b, 0x0a, 0xc3, 0x73, 0x0b, 0x0c, 0x03, 0x74, 0x0b, 0x0e, 0x43, 0x74, -0x31, 0x60, 0x61, 0x68, 0xc0, 0x46, 0x01, 0x76, 0x0b, 0x0a, 0x43, 0x76, -0x0b, 0x0c, 0x83, 0x76, 0x0b, 0x0e, 0xc3, 0x76, 0x71, 0x60, 0x60, 0x69, -0xc0, 0x46, 0x70, 0x61, 0xa0, 0x69, 0xc0, 0x46, 0xb0, 0x61, 0x38, 0x1c, -0x06, 0xf0, 0x3a, 0xff, 0x38, 0x1c, 0xff, 0xf7, 0x61, 0xff, 0x05, 0x48, -0x05, 0x49, 0x0b, 0x68, 0x05, 0x4a, 0x00, 0x21, 0x07, 0xf0, 0x19, 0xf9, -0x01, 0x20, 0x85, 0xe7, 0x9c, 0x04, 0x00, 0x80, 0xdd, 0x01, 0xff, 0xff, -0x70, 0x76, 0x21, 0x40, 0x98, 0x3a, 0x00, 0x00, 0x90, 0xb5, 0x1d, 0x4f, -0x79, 0x69, 0x00, 0x29, 0x32, 0xd0, 0x80, 0x6a, 0x01, 0x7b, 0x43, 0x7b, -0x1b, 0x02, 0x19, 0x43, 0xc1, 0x23, 0xdb, 0x00, 0x99, 0x42, 0x29, 0xd1, -0x01, 0x7d, 0x43, 0x7d, 0x1b, 0x02, 0x19, 0x43, 0x01, 0x23, 0x5b, 0x02, -0x0e, 0x30, 0x99, 0x42, 0x20, 0xd1, 0xc3, 0x1d, 0x07, 0x33, 0x14, 0xcb, -0x9b, 0x07, 0xdb, 0x0e, 0xda, 0x40, 0x5b, 0x42, 0x20, 0x33, 0x9c, 0x40, -0x14, 0x43, 0x79, 0x68, 0xa1, 0x42, 0x13, 0xd1, 0x00, 0x21, 0x4a, 0x00, -0x13, 0x18, 0x1c, 0x7a, 0x5b, 0x7a, 0x1b, 0x02, 0x1c, 0x43, 0xd2, 0x19, -0xd4, 0x81, 0x01, 0x31, 0x09, 0x06, 0x09, 0x0e, 0x03, 0x29, 0xf2, 0xdb, -0x79, 0x69, 0x38, 0x1c, 0x07, 0xf0, 0xd7, 0xf8, 0x00, 0x20, 0x78, 0x61, -0x90, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, 0x9c, 0x04, 0x00, 0x80, -0xf0, 0xb5, 0x07, 0x1c, 0x01, 0x25, 0x20, 0x48, 0x01, 0x22, 0x00, 0x21, -0x03, 0x68, 0x08, 0x20, 0x07, 0xf0, 0xc7, 0xf8, 0x04, 0x1c, 0xff, 0x2c, -0x03, 0xd1, 0x00, 0x20, 0xf0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x20, 0x1c, -0x19, 0x4e, 0x00, 0x22, 0x11, 0x21, 0x33, 0x68, 0x07, 0xf0, 0xb9, 0xf8, -0xff, 0x23, 0x45, 0x33, 0x98, 0x42, 0x1e, 0xd1, 0x20, 0x1c, 0x39, 0x1c, -0x14, 0x4a, 0x13, 0x68, 0xff, 0x22, 0x45, 0x32, -0x07, 0xf0, 0xad, 0xf8, 0xff, 0x23, 0x45, 0x33, 0x98, 0x42, 0x12, 0xd1, -0x00, 0x22, 0x13, 0x21, 0x33, 0x68, 0x20, 0x1c, 0x07, 0xf0, 0xa3, 0xf8, -0x06, 0x06, 0x36, 0x0e, 0x00, 0x20, 0x78, 0x71, 0x38, 0x1c, 0x0b, 0x49, -0x0a, 0x68, 0xff, 0x21, 0x45, 0x31, 0x07, 0xf0, 0x97, 0xf8, 0xb0, 0x42, -0x00, 0xd0, 0x00, 0x25, 0x20, 0x1c, 0x07, 0x49, 0x09, 0x68, 0x07, 0xf0, -0x8e, 0xf8, 0x28, 0x1c, 0xca, 0xe7, 0x00, 0x00, 0x74, 0x6e, 0x21, 0x40, -0x8c, 0x6e, 0x21, 0x40, 0x80, 0x6e, 0x21, 0x40, 0x94, 0x6e, 0x21, 0x40, -0x88, 0x6e, 0x21, 0x40, 0xf0, 0xb5, 0xff, 0x21, 0x45, 0x31, 0x00, 0x20, -0x51, 0x4f, 0x00, 0x26, 0x3a, 0x18, 0xe1, 0x23, 0x1b, 0x01, 0xd2, 0x18, -0x16, 0x73, 0x01, 0x30, 0x88, 0x42, 0xf7, 0xd3, 0x4d, 0x4b, 0xf8, 0x18, -0xff, 0xf7, 0xa0, 0xff, 0x01, 0x25, 0x2d, 0x05, 0x00, 0x28, 0x0e, 0xd0, -0xe1, 0x23, 0x1b, 0x01, 0xf8, 0x18, 0x01, 0x7b, 0x41, 0x29, 0x16, 0xd0, -0x41, 0x7b, 0x53, 0x29, 0x13, 0xd0, 0x81, 0x7b, 0x46, 0x29, 0x10, 0xd0, -0xc0, 0x7b, 0x00, 0x28, 0x0d, 0xd0, 0x01, 0x23, 0x1b, 0x03, 0xb8, 0x69, -0x98, 0x43, 0xb8, 0x61, 0xe8, 0x61, 0x5b, 0x00, 0xb8, 0x69, 0x98, 0x43, -0xb8, 0x61, 0xe8, 0x61, 0xf0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x3c, 0x49, -0x39, 0x23, 0x9b, 0x01, 0xf8, 0x18, 0x0a, 0x68, 0xc0, 0x46, 0xc2, 0x80, -0x4a, 0x68, 0xc0, 0x46, 0x02, 0x81, 0x89, 0x68, 0xc0, 0x46, 0x41, 0x81, -0x3c, 0x1c, 0x00, 0x21, 0x37, 0x1c, 0x4a, 0x00, 0x12, 0x19, 0x39, 0x23, -0x9b, 0x01, 0xd2, 0x18, 0x17, 0x80, 0x01, 0x31, 0x09, 0x06, 0x09, 0x0e, -0x03, 0x29, 0xf4, 0xdb, 0x07, 0x73, 0x2f, 0x48, 0x2f, 0x49, 0x0b, 0x68, -0x2f, 0x4a, 0x00, 0x21, 0x07, 0xf0, 0x2d, 0xf8, 0xe9, 0x23, 0x1b, 0x01, -0xe0, 0x18, 0x07, 0x73, 0x42, 0x89, 0x19, 0x21, 0x49, 0x01, 0x8a, 0x42, -0x00, 0xda, 0x41, 0x81, 0x00, 0x21, 0x82, 0x7b, 0x00, 0x2a, 0x0c, 0xdd, -0x16, 0x22, 0x4a, 0x43, 0x12, 0x19, 0x75, 0x23, 0x5b, 0x01, 0xd2, 0x18, -0xd7, 0x70, 0x01, 0x31, 0x09, 0x06, 0x09, 0x0e, 0x82, 0x7b, 0x8a, 0x42, -0xf2, 0xdc, 0xef, 0x23, 0x1b, 0x01, 0xe0, 0x18, 0xc7, 0x71, 0x39, 0x1c, -0x00, 0x20, 0x42, 0x00, 0x12, 0x19, 0xef, 0x23, 0x1b, 0x01, 0xd2, 0x18, -0x11, 0x72, 0x51, 0x72, 0x01, 0x30, 0x00, 0x06, 0x00, 0x0e, 0x04, 0x28, -0xf3, 0xdb, 0x79, 0x23, 0x5b, 0x01, 0xe0, 0x18, 0x01, 0x72, 0x3d, 0x23, -0x9b, 0x01, 0xe0, 0x18, 0x81, 0x60, 0x14, 0x48, 0x14, 0x49, 0xc0, 0x46, -0x08, 0x60, 0x01, 0x23, 0x1b, 0x03, 0xa0, 0x69, 0x18, 0x43, 0xa0, 0x61, -0xe1, 0x69, 0x99, 0x43, 0xe1, 0x61, 0xe8, 0x61, 0xe0, 0x69, 0xc0, 0x46, -0x28, 0x62, 0x5b, 0x00, 0xa0, 0x69, 0x98, 0x43, 0xa0, 0x61, 0xe8, 0x61, -0x03, 0xf0, 0xee, 0xff, 0x0a, 0x48, 0x0b, 0x49, 0xc0, 0x46, 0x08, 0x60, -0x88, 0xe7, 0x00, 0x00, 0xf8, 0x0d, 0x00, 0x80, 0x1c, 0x0e, 0x00, 0x00, -0x40, 0x00, 0x14, 0x40, 0x39, 0x06, 0xff, 0xff, 0x70, 0x76, 0x21, 0x40, -0x80, 0x4f, 0x12, 0x00, 0x08, 0x6e, 0x21, 0x40, 0x88, 0x70, 0x21, 0x40, -0x7d, 0x0c, 0xff, 0xff, 0x78, 0x70, 0x21, 0x40, 0xb0, 0xb5, 0x00, 0x20, -0x1c, 0x4f, 0xef, 0x23, 0x1b, 0x01, 0xfc, 0x18, 0xe1, 0x79, 0x00, 0x29, -0x0c, 0xdd, 0x00, 0x21, 0x42, 0x00, 0xd2, 0x19, 0xef, 0x23, 0x1b, 0x01, -0xd2, 0x18, 0x51, 0x72, 0x01, 0x30, 0x00, 0x06, 0x00, 0x0e, 0xe2, 0x79, -0x82, 0x42, 0xf3, 0xdc, 0x39, 0x23, 0x9b, 0x01, -0xf8, 0x18, 0xc2, 0x6a, 0x11, 0x4d, 0x00, 0x2a, 0x04, 0xd0, 0x11, 0x48, -0x00, 0x21, 0x2b, 0x68, 0x06, 0xf0, 0xa5, 0xff, 0x00, 0xf0, 0x2a, 0xf8, -0x0e, 0x48, 0x05, 0x22, 0x00, 0x21, 0x2b, 0x68, 0x06, 0xf0, 0x9d, 0xff, -0xe0, 0x79, 0x00, 0x28, 0x05, 0xd1, 0xe9, 0x23, 0x1b, 0x01, 0xf8, 0x18, -0x80, 0x7b, 0x00, 0x28, 0x04, 0xd0, 0x08, 0x48, 0x7d, 0x21, 0x09, 0x01, -0x00, 0xf0, 0x71, 0xf8, 0xb0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, -0xf8, 0x0d, 0x00, 0x80, 0x70, 0x76, 0x21, 0x40, 0xb5, 0x07, 0xff, 0xff, -0x6d, 0x07, 0xff, 0xff, 0xd1, 0x07, 0xff, 0xff, 0x00, 0x20, 0x02, 0x49, -0xc0, 0x46, 0x08, 0x73, 0x70, 0x47, 0x00, 0x00, 0x38, 0x1c, 0x00, 0x80, -0x80, 0xb4, 0x00, 0x21, 0x09, 0x48, 0xc0, 0x46, 0x01, 0x60, 0x00, 0x20, -0x08, 0x4a, 0x43, 0x00, 0x1b, 0x18, 0x9b, 0x00, 0x9f, 0x18, 0xb9, 0x60, -0xd1, 0x50, 0x79, 0x60, 0x01, 0x30, 0x00, 0x06, 0x00, 0x0e, 0x05, 0x28, -0xf3, 0xdb, 0x80, 0xbc, 0x70, 0x47, 0x00, 0x00, 0x04, 0x6e, 0x21, 0x40, -0x40, 0xab, 0x20, 0x40, 0xb0, 0xb4, 0x00, 0x29, 0x03, 0xd0, 0x07, 0x68, -0x00, 0x2f, 0x02, 0xd1, 0x01, 0x60, 0xb0, 0xbc, 0x70, 0x47, 0x3a, 0x1c, -0x53, 0x68, 0x4c, 0x68, 0xa3, 0x42, 0x08, 0xd8, 0x13, 0x1c, 0x12, 0x68, -0x00, 0x2a, 0x02, 0xd0, 0x55, 0x68, 0xa5, 0x42, 0xf8, 0xd9, 0x00, 0x2b, -0x03, 0xd1, 0x3a, 0x68, 0xc0, 0x46, 0x0a, 0x60, 0xea, 0xe7, 0x18, 0x68, -0xc0, 0x46, 0x08, 0x60, 0x19, 0x60, 0xe6, 0xe7, 0x90, 0xb4, 0x00, 0x29, -0x15, 0xd0, 0x02, 0x68, 0x17, 0x1c, 0x8a, 0x42, 0x08, 0xd0, 0x13, 0x1c, -0x14, 0x68, 0x00, 0x2c, 0x02, 0xd0, 0x22, 0x1c, 0x8a, 0x42, 0xf8, 0xd1, -0x00, 0x2b, 0x03, 0xd1, 0x3a, 0x68, 0xc0, 0x46, 0x02, 0x60, 0x02, 0xe0, -0x10, 0x68, 0xc0, 0x46, 0x18, 0x60, 0x00, 0x20, 0x08, 0x60, 0x90, 0xbc, -0x70, 0x47, 0x00, 0xb5, 0x01, 0x68, 0xff, 0xf7, 0xe1, 0xff, 0x08, 0xbc, -0x18, 0x47, 0x90, 0xb5, 0x00, 0x22, 0x11, 0x4c, 0x53, 0x00, 0x9b, 0x18, -0x9b, 0x00, 0x1b, 0x19, 0x9b, 0x68, 0x00, 0x2b, 0x04, 0xd1, 0x53, 0x00, -0x9b, 0x18, 0x9b, 0x00, 0x1f, 0x19, 0x04, 0xe0, 0x01, 0x32, 0x12, 0x06, -0x12, 0x0e, 0x05, 0x2a, 0xee, 0xdb, 0x00, 0x23, 0x05, 0x2a, 0x03, 0xd1, -0x18, 0x1c, 0x90, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0xb8, 0x60, 0x79, 0x60, -0x3b, 0x60, 0x39, 0x1c, 0x03, 0x48, 0xff, 0xf7, 0x9d, 0xff, 0x38, 0x1c, -0xf3, 0xe7, 0x00, 0x00, 0x40, 0xab, 0x20, 0x40, 0x04, 0x6e, 0x21, 0x40, -0x80, 0xb5, 0x07, 0x1c, 0x39, 0x1c, 0x04, 0x48, 0xff, 0xf7, 0xb0, 0xff, -0x00, 0x20, 0xb8, 0x60, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, -0x04, 0x6e, 0x21, 0x40, 0xf0, 0xb5, 0x0f, 0x4c, 0x27, 0x68, 0x00, 0x2f, -0x17, 0xd0, 0x78, 0x68, 0x00, 0x28, 0x0c, 0xd1, 0x0c, 0x4e, 0x00, 0x25, -0x30, 0x1c, 0xff, 0xf7, 0xb6, 0xff, 0xb8, 0x68, 0x06, 0xf0, 0xd4, 0xfe, -0xbd, 0x60, 0x27, 0x68, 0x78, 0x68, 0x00, 0x28, 0xf4, 0xd0, 0x00, 0x2f, -0x05, 0xd0, 0x78, 0x68, 0x01, 0x38, 0x78, 0x60, 0x3f, 0x68, 0x00, 0x2f, -0xf9, 0xd1, 0xf0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x04, 0x6e, 0x21, 0x40, -0x04, 0x6e, 0x21, 0x40, 0x00, 0xb5, 0x04, 0x48, 0x04, 0x49, 0x0a, 0x68, -0x01, 0x21, 0x06, 0xf0, 0xbb, 0xfe, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, -0x68, 0x1c, 0x00, 0x80, 0xc0, 0x6f, 0x21, 0x40, 0x80, 0xb5, 0x0b, 0x4f, -0x78, 0x7b, 0x01, 0x28, 0x08, 0xd0, 0x02, 0x28, -0x01, 0xd1, 0x00, 0xf0, 0x65, 0xf8, 0x78, 0x7b, 0x01, 0x28, 0x04, 0xd1, -0x79, 0x7a, 0x03, 0xe0, 0x00, 0xf0, 0x0c, 0xf8, 0xf7, 0xe7, 0x79, 0x89, -0x03, 0x48, 0xff, 0xf7, 0x82, 0xff, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, -0x88, 0x1c, 0x00, 0x80, 0xd1, 0x07, 0xff, 0xff, 0x00, 0xb5, 0x08, 0x48, -0xe9, 0x23, 0x1b, 0x01, 0xc1, 0x18, 0x09, 0x7b, 0x49, 0x00, 0x08, 0x18, -0xef, 0x23, 0x1b, 0x01, 0xc0, 0x18, 0x41, 0x7a, 0x00, 0x7a, 0x00, 0xf0, -0xd5, 0xf9, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, 0xf8, 0x0d, 0x00, 0x80, -0x90, 0xb5, 0xc8, 0x00, 0x40, 0x18, 0x80, 0x00, 0x19, 0x49, 0x40, 0x18, -0x41, 0x78, 0x19, 0x4c, 0xe9, 0x23, 0x1b, 0x01, 0xe7, 0x18, 0x08, 0x29, -0x1d, 0xd2, 0x02, 0xa3, 0x5b, 0x5c, 0x5b, 0x00, 0x9f, 0x44, 0x00, 0x1c, -0x10, 0x10, 0x04, 0x04, 0x10, 0x10, 0x19, 0x1c, 0x02, 0x30, 0x00, 0x21, -0x01, 0x31, 0x09, 0x06, 0x09, 0x0e, 0x03, 0x29, 0xfa, 0xdb, 0x0f, 0x49, -0x0a, 0x68, 0x01, 0x21, 0x06, 0xf0, 0x62, 0xfe, 0x38, 0x7b, 0x40, 0x00, -0x00, 0x19, 0xef, 0x23, 0x1b, 0x01, 0xc0, 0x18, 0x41, 0x7a, 0x01, 0x31, -0x41, 0x72, 0x90, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x20, 0x39, 0x7b, -0x49, 0x00, 0x09, 0x19, 0xef, 0x23, 0x1b, 0x01, 0xc9, 0x18, 0x48, 0x72, -0xf3, 0xe7, 0x00, 0x00, 0xe4, 0x2b, 0x00, 0x80, 0xf8, 0x0d, 0x00, 0x80, -0xc0, 0x6f, 0x21, 0x40, 0x00, 0xb5, 0x0b, 0x48, 0xe9, 0x23, 0x1b, 0x01, -0xc1, 0x18, 0x09, 0x7b, 0x16, 0x23, 0x59, 0x43, 0x08, 0x18, 0x75, 0x23, -0x5b, 0x01, 0xc1, 0x18, 0x09, 0x78, 0xe9, 0x23, 0x1b, 0x01, 0xc0, 0x18, -0xc0, 0x7b, 0xfe, 0x23, 0x18, 0x40, 0x00, 0xf0, 0xad, 0xf9, 0x08, 0xbc, -0x18, 0x47, 0x00, 0x00, 0xf8, 0x0d, 0x00, 0x80, 0xf0, 0xb5, 0x04, 0x1c, -0xc8, 0x00, 0x40, 0x18, 0x80, 0x00, 0x32, 0x49, 0x46, 0x18, 0x00, 0x25, -0x31, 0x48, 0xe9, 0x23, 0x1b, 0x01, 0xc7, 0x18, 0x39, 0x7b, 0x16, 0x23, -0x59, 0x43, 0x08, 0x18, 0x75, 0x23, 0x5b, 0x01, 0xc2, 0x18, 0xd1, 0x78, -0x63, 0x68, 0x1b, 0x06, 0x1b, 0x0e, 0x0c, 0x2b, 0x3b, 0xd1, 0x29, 0x4b, -0x54, 0x78, 0x36, 0x78, 0x34, 0x40, 0x24, 0x06, 0x24, 0x0e, 0x1e, 0x1c, -0xe9, 0x23, 0x1b, 0x01, 0xc0, 0x18, 0xc0, 0x7b, 0x40, 0x08, 0x07, 0xd3, -0x8c, 0x42, 0x24, 0xd0, 0x90, 0x78, 0xa0, 0x42, 0x0a, 0xd0, 0x88, 0x42, -0x1f, 0xd1, 0x06, 0xe0, 0x00, 0x2c, 0x02, 0xd0, 0x00, 0x29, 0x1a, 0xd1, -0x02, 0xe0, 0x00, 0x29, 0x17, 0xd0, 0x01, 0x25, 0x00, 0x2d, 0x03, 0xd0, -0x90, 0x79, 0x80, 0x23, 0x18, 0x43, 0x90, 0x71, 0x00, 0x25, 0x38, 0x7b, -0x16, 0x23, 0x58, 0x43, 0x80, 0x19, 0x16, 0x4b, 0xc0, 0x18, 0x16, 0x49, -0x0a, 0x68, 0x01, 0x21, 0x06, 0xf0, 0xe4, 0xfd, 0x68, 0x1c, 0x05, 0x06, -0x2d, 0x0e, 0x03, 0x2d, 0xef, 0xdb, 0x38, 0x7b, 0x16, 0x23, 0x58, 0x43, -0x80, 0x19, 0x75, 0x23, 0x5b, 0x01, 0xc0, 0x18, 0xc4, 0x70, 0x0b, 0x48, -0x39, 0x7b, 0x01, 0x31, 0x39, 0x73, 0x39, 0x7b, 0xba, 0x7b, 0x91, 0x42, -0x09, 0xdb, 0x00, 0x21, 0x39, 0x73, 0xef, 0x23, 0x1b, 0x01, 0xc0, 0x18, -0xc0, 0x79, 0x00, 0x28, 0x01, 0xd0, 0x01, 0x20, 0x78, 0x73, 0xf0, 0xbc, -0x08, 0xbc, 0x18, 0x47, 0xe4, 0x2b, 0x00, 0x80, 0xf8, 0x0d, 0x00, 0x80, -0xa4, 0x0e, 0x00, 0x00, 0xc0, 0x6f, 0x21, 0x40, 0xb0, 0xb5, 0x00, 0x27, -0x07, 0x4d, 0x08, 0x4c, 0x01, 0x21, 0x2a, 0x68, 0x20, 0x1c, 0x06, 0xf0, -0xb1, 0xfd, 0x78, 0x1c, 0x07, 0x06, 0x3f, 0x0e, -0x03, 0x2f, 0xf5, 0xdb, 0xb0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, -0xc0, 0x6f, 0x21, 0x40, 0x44, 0x1d, 0x00, 0x80, 0xb0, 0xb5, 0xc8, 0x00, -0x40, 0x18, 0x80, 0x00, 0x19, 0x49, 0x47, 0x18, 0x38, 0x78, 0x0d, 0x28, -0x2a, 0xdb, 0x12, 0x28, 0x28, 0xdc, 0xb8, 0x78, 0x10, 0x28, 0x25, 0xd1, -0x79, 0x78, 0x15, 0x48, 0x3d, 0x23, 0x9b, 0x01, 0xc4, 0x18, 0x13, 0x29, -0x16, 0xd1, 0x13, 0x4b, 0xc5, 0x18, 0xa0, 0x68, 0x00, 0x28, 0x01, 0xd0, -0xff, 0xf7, 0x94, 0xfe, 0x00, 0x20, 0x39, 0x18, 0xc9, 0x78, 0xc0, 0x46, -0x29, 0x54, 0x01, 0x30, 0x0e, 0x28, 0xf8, 0xd3, 0x38, 0x79, 0x00, 0x02, -0xf9, 0x78, 0x01, 0x43, 0x0a, 0x48, 0xff, 0xf7, 0x5c, 0xfe, 0xa0, 0x60, -0x78, 0x78, 0x14, 0x28, 0x04, 0xd1, 0xa0, 0x68, 0x00, 0x28, 0x01, 0xd0, -0xff, 0xf7, 0x7c, 0xfe, 0xb0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, -0xe4, 0x2b, 0x00, 0x80, 0xf8, 0x0d, 0x00, 0x80, 0x4c, 0x0f, 0x00, 0x00, -0xc5, 0x09, 0xff, 0xff, 0xf0, 0xb5, 0xcb, 0x00, 0x59, 0x18, 0x89, 0x00, -0x17, 0x4a, 0x8f, 0x18, 0x39, 0x78, 0xc5, 0x1d, 0x19, 0x35, 0x0b, 0x29, -0x22, 0xdb, 0x10, 0x29, 0x20, 0xdc, 0xb8, 0x78, 0x10, 0x28, 0x1d, 0xd1, -0xfe, 0x1c, 0x78, 0x78, 0x15, 0x28, 0x0e, 0xd1, 0x00, 0x24, 0x30, 0x1c, -0x0f, 0x49, 0x0a, 0x68, 0x01, 0x21, 0x06, 0xf0, 0x49, 0xfd, 0x00, 0x28, -0x00, 0xd1, 0x28, 0x71, 0x60, 0x1c, 0x04, 0x06, 0x24, 0x0e, 0x03, 0x2c, -0xf1, 0xdb, 0x78, 0x78, 0x16, 0x28, 0x09, 0xd1, 0x30, 0x1c, 0x07, 0x49, -0x0a, 0x68, 0x01, 0x21, 0x06, 0xf0, 0x38, 0xfd, 0x00, 0x28, 0x01, 0xd1, -0x00, 0x20, 0x28, 0x71, 0xf0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, -0xe4, 0x2b, 0x00, 0x80, 0xc0, 0x6f, 0x21, 0x40, 0xc8, 0x00, 0x40, 0x18, -0x80, 0x00, 0x0c, 0x49, 0x40, 0x18, 0x01, 0x78, 0x0d, 0x29, 0x12, 0xd1, -0x41, 0x78, 0x15, 0x29, 0x0f, 0xd1, 0x80, 0x78, 0x10, 0x28, 0x0c, 0xd1, -0x07, 0x48, 0x08, 0x4b, 0xc3, 0x18, 0x00, 0x21, 0x00, 0x22, 0x5a, 0x54, -0x01, 0x31, 0x0c, 0x29, 0xfb, 0xd3, 0x79, 0x23, 0x5b, 0x01, 0xc0, 0x18, -0x02, 0x72, 0x70, 0x47, 0xe4, 0x2b, 0x00, 0x80, 0xf8, 0x0d, 0x00, 0x80, -0x28, 0x0f, 0x00, 0x00, 0x83, 0x00, 0x18, 0x18, 0x80, 0x00, 0x02, 0x49, -0x40, 0x18, 0x02, 0x4b, 0xc0, 0x18, 0x70, 0x47, 0xf8, 0x0d, 0x00, 0x80, -0x81, 0x0e, 0x00, 0x00, 0x80, 0xb4, 0x00, 0x20, 0x09, 0x49, 0x00, 0x22, -0x43, 0x00, 0x5f, 0x18, 0xef, 0x23, 0x1b, 0x01, 0xfb, 0x18, 0x1a, 0x72, -0x01, 0x30, 0x00, 0x06, 0x00, 0x0e, 0x04, 0x28, 0xf4, 0xdb, 0xef, 0x23, -0x1b, 0x01, 0xc8, 0x18, 0xc2, 0x71, 0x80, 0xbc, 0x70, 0x47, 0x00, 0x00, -0xf8, 0x0d, 0x00, 0x80, 0x88, 0xb5, 0x01, 0x1c, 0x0b, 0x4a, 0xc0, 0x46, -0x00, 0x92, 0x0b, 0x4f, 0x0b, 0x4b, 0xf8, 0x18, 0x1a, 0x23, 0x0a, 0x1c, -0x04, 0x21, 0x04, 0xf0, 0xe9, 0xf8, 0x05, 0x28, 0x06, 0xd1, 0x00, 0x20, -0xef, 0x23, 0x1b, 0x01, 0xf9, 0x18, 0xc8, 0x71, 0xff, 0xf7, 0x0a, 0xfd, -0x88, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, 0xad, 0x0b, 0xff, 0xff, -0xf8, 0x0d, 0x00, 0x80, 0xf8, 0x0e, 0x00, 0x00, 0x00, 0xb5, 0x43, 0x00, -0x18, 0x18, 0x80, 0x00, 0x04, 0x49, 0x40, 0x18, 0x40, 0x7a, 0x04, 0x49, -0xc0, 0x46, 0xc8, 0x71, 0xff, 0xf7, 0xf4, 0xfc, 0x08, 0xbc, 0x18, 0x47, -0x5c, 0xac, 0x20, 0x40, 0xe8, 0x1c, 0x00, 0x80, 0xb0, 0xb5, 0x04, 0x1c, -0x0d, 0x1c, 0x00, 0x27, 0x03, 0xf0, 0x42, 0xfe, -0x00, 0x28, 0x1d, 0xd0, 0x18, 0x21, 0x01, 0x70, 0x0f, 0x49, 0xc0, 0x46, -0xc1, 0x60, 0x0f, 0x49, 0xc0, 0x46, 0x41, 0x60, 0x0e, 0x49, 0xc0, 0x46, -0x81, 0x60, 0x04, 0x74, 0x01, 0x21, 0x41, 0x74, 0x04, 0x21, 0x81, 0x74, -0x11, 0x21, 0xc1, 0x74, 0x10, 0x21, 0x01, 0x75, 0x45, 0x75, 0x00, 0x21, -0x81, 0x75, 0x01, 0x21, 0x21, 0x43, 0xc1, 0x75, 0x00, 0x21, 0x03, 0xf0, -0xd9, 0xfc, 0x07, 0x1c, 0x38, 0x1c, 0xb0, 0xbc, 0x08, 0xbc, 0x18, 0x47, -0xe4, 0x2b, 0x00, 0x80, 0x00, 0x3f, 0xf3, 0x03, 0x31, 0x08, 0xff, 0xff, -0xb0, 0xb5, 0x04, 0x1c, 0x0d, 0x1c, 0x00, 0x27, 0x03, 0xf0, 0x12, 0xfe, -0x00, 0x28, 0x13, 0xd0, 0x08, 0x21, 0x01, 0x70, 0x0a, 0x49, 0xc0, 0x46, -0xc1, 0x60, 0x0a, 0x49, 0xc0, 0x46, 0x41, 0x60, 0x09, 0x49, 0xc0, 0x46, -0x81, 0x60, 0x04, 0x74, 0x45, 0x74, 0x01, 0x21, 0x21, 0x43, 0x81, 0x74, -0x00, 0x21, 0x03, 0xf0, 0xb3, 0xfc, 0x07, 0x1c, 0x38, 0x1c, 0xb0, 0xbc, -0x08, 0xbc, 0x18, 0x47, 0xe4, 0x2b, 0x00, 0x80, 0x00, 0x3f, 0xf3, 0x13, -0xe1, 0x08, 0xff, 0xff, 0xc1, 0x10, 0x05, 0xd1, 0x40, 0x07, 0x40, 0x0f, -0x80, 0x00, 0x02, 0x49, 0x08, 0x58, 0x70, 0x47, 0x00, 0x20, 0xfc, 0xe7, -0x20, 0x6e, 0x21, 0x40, 0xcb, 0x00, 0x59, 0x18, 0x89, 0x00, 0x08, 0x48, -0x42, 0x5c, 0x03, 0x2a, 0x0a, 0xd1, 0x08, 0x18, 0x41, 0x78, 0x18, 0x29, -0x06, 0xd1, 0x81, 0x78, 0x10, 0x29, 0x03, 0xd1, 0xc0, 0x78, 0x03, 0x49, -0xc0, 0x46, 0xc8, 0x62, 0x70, 0x47, 0x00, 0x00, 0xe4, 0x2b, 0x00, 0x80, -0xf8, 0x1b, 0x00, 0x80, 0xf0, 0xb4, 0x02, 0x7c, 0xd6, 0x07, 0xf6, 0x0f, -0xc7, 0x1d, 0x19, 0x37, 0x1c, 0x4d, 0x00, 0x24, 0xca, 0x00, 0x52, 0x18, -0x92, 0x00, 0x00, 0x2e, 0x23, 0xd0, 0xae, 0x5c, 0x19, 0x4d, 0xcb, 0x00, -0x59, 0x18, 0x89, 0x00, 0x69, 0x18, 0x00, 0x2e, 0x15, 0xd1, 0x03, 0x23, -0xab, 0x54, 0x13, 0x22, 0x4a, 0x70, 0x10, 0x22, 0x8a, 0x70, 0x09, 0x22, -0x13, 0x4b, 0x5d, 0x6a, 0x02, 0x23, 0x1d, 0x40, 0x00, 0xd1, 0x01, 0x22, -0x04, 0x23, 0x00, 0x2d, 0x00, 0xd1, 0x00, 0x23, 0x1a, 0x43, 0xca, 0x70, -0x15, 0x22, 0x3a, 0x71, 0x00, 0xe0, 0x3c, 0x71, 0xc1, 0x61, 0x04, 0x62, -0x44, 0x61, 0xf0, 0xbc, 0x70, 0x47, 0x14, 0x21, 0x39, 0x71, 0x09, 0x49, -0x52, 0x19, 0x01, 0x62, 0x82, 0x61, 0x00, 0x21, 0x54, 0x54, 0x01, 0x31, -0x24, 0x29, 0xfb, 0xd3, 0x05, 0x49, 0xc0, 0x46, 0x41, 0x61, 0xee, 0xe7, -0xe4, 0x2b, 0x00, 0x80, 0x08, 0x2c, 0x00, 0x80, 0xf8, 0x1b, 0x00, 0x80, -0x95, 0x0c, 0xff, 0xff, 0xc5, 0x0c, 0xff, 0xff, 0x14, 0x22, 0xc3, 0x1d, -0x19, 0x33, 0x1a, 0x71, 0xcb, 0x00, 0x59, 0x18, 0x89, 0x00, 0x04, 0x4a, -0x89, 0x18, 0x81, 0x61, 0x03, 0x49, 0xc0, 0x46, 0x01, 0x62, 0x00, 0x21, -0x41, 0x61, 0x70, 0x47, 0xe4, 0x2b, 0x00, 0x80, 0xf1, 0x09, 0xff, 0xff, -0x80, 0xb4, 0x02, 0x7c, 0xd7, 0x07, 0xff, 0x0f, 0xcb, 0x00, 0x59, 0x18, -0x89, 0x00, 0xc2, 0x1d, 0x19, 0x32, 0x00, 0x2f, 0x27, 0xd0, 0x1a, 0x4b, -0xc9, 0x18, 0x15, 0x23, 0x13, 0x71, 0x00, 0x22, 0xc1, 0x61, 0x42, 0x61, -0x02, 0x62, 0x17, 0x4a, 0x79, 0x23, 0x5b, 0x01, 0xd0, 0x18, 0x03, 0x7a, -0x10, 0x20, 0x00, 0x2b, 0x11, 0xd0, 0x0d, 0x23, 0x0b, 0x70, 0x16, 0x23, -0x4b, 0x70, 0x88, 0x70, 0x00, 0x20, 0x17, 0x18, 0x79, 0x23, 0x5b, 0x01, -0xfb, 0x18, 0x5b, 0x7a, 0x0f, 0x18, 0xfb, 0x70, 0x01, 0x30, 0x0b, 0x28, -0xf5, 0xd3, 0x80, 0xbc, 0x70, 0x47, 0x02, 0x22, -0x0a, 0x70, 0x17, 0x22, 0x4a, 0x70, 0x88, 0x70, 0xf7, 0xe7, 0x14, 0x23, -0x13, 0x71, 0x07, 0x4a, 0x89, 0x18, 0x81, 0x61, 0x06, 0x49, 0xc0, 0x46, -0x01, 0x62, 0x06, 0x49, 0xc0, 0x46, 0x41, 0x61, 0xeb, 0xe7, 0x00, 0x00, -0x08, 0x2c, 0x00, 0x80, 0xf8, 0x0d, 0x00, 0x80, 0xe4, 0x2b, 0x00, 0x80, -0xe1, 0x0a, 0xff, 0xff, 0x81, 0x0d, 0xff, 0xff, 0x14, 0x22, 0xc3, 0x1d, -0x19, 0x33, 0x1a, 0x71, 0x04, 0x4a, 0xcb, 0x00, 0x59, 0x18, 0x89, 0x00, -0x02, 0x62, 0x03, 0x4a, 0x89, 0x18, 0x81, 0x61, 0x70, 0x47, 0x00, 0x00, -0x71, 0x0a, 0xff, 0xff, 0xe4, 0x2b, 0x00, 0x80, 0x00, 0x00, 0x0f, 0xe1, -0x00, 0x10, 0xa0, 0xe1, 0xc0, 0x10, 0x81, 0xe3, 0x01, 0xf0, 0x21, 0xe1, -0x1e, 0xff, 0x2f, 0xe1, 0x00, 0xf0, 0x21, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, -0x00, 0x00, 0x0f, 0xe1, 0xc0, 0x00, 0x80, 0xe3, 0x00, 0xf0, 0x21, 0xe1, -0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x0f, 0xe1, 0xc0, 0x00, 0xc0, 0xe3, +0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbf, 0xcd, 0x57, 0xc3, +0xba, 0x01, 0x2c, 0xe8, 0xcd, 0xef, 0xa9, 0xd9, 0x6f, 0xbb, 0x76, 0x2f, +0x86, 0x49, 0xac, 0x1b, 0x40, 0x01, 0x00, 0x00, 0x8a, 0xe4, 0x00, 0x00, +0x00, 0x00, 0xff, 0xff, 0x39, 0x00, 0x00, 0xea, 0x05, 0x00, 0x00, 0xea, +0x04, 0x00, 0x00, 0xea, 0x03, 0x00, 0x00, 0xea, 0x02, 0x00, 0x00, 0xea, +0x01, 0x00, 0x00, 0xea, 0x32, 0x02, 0x00, 0xea, 0xc0, 0x14, 0x00, 0xea, +0x07, 0x00, 0x2d, 0xe9, 0x0e, 0x00, 0xa0, 0xe1, 0x00, 0x10, 0x0f, 0xe1, +0xd0, 0x20, 0x9f, 0xe5, 0x12, 0xff, 0x2f, 0xe1, 0xfe, 0xff, 0xff, 0xea, +0x01, 0x00, 0x80, 0xe0, 0x04, 0x20, 0x81, 0xe4, 0x01, 0x00, 0x50, 0xe1, +0xfc, 0xff, 0xff, 0x1a, 0x0e, 0xf0, 0xa0, 0xe1, 0x00, 0xa0, 0xa0, 0xe1, +0x0e, 0xb0, 0xa0, 0xe1, 0x00, 0x00, 0xa0, 0xe3, 0xa8, 0x10, 0x9f, 0xe5, +0x00, 0x00, 0x81, 0xe5, 0xa4, 0x10, 0x9f, 0xe5, 0x00, 0x00, 0x81, 0xe5, +0x01, 0x16, 0xa0, 0xe3, 0x00, 0x00, 0x91, 0xe5, 0x01, 0x00, 0x80, 0xe3, +0x00, 0x00, 0x81, 0xe5, 0xd7, 0x00, 0xa0, 0xe3, 0x00, 0xf0, 0x21, 0xe1, +0x88, 0xd0, 0x9f, 0xe5, 0xdb, 0x00, 0xa0, 0xe3, 0x00, 0xf0, 0x21, 0xe1, +0x7c, 0xd0, 0x9f, 0xe5, 0xd2, 0x00, 0xa0, 0xe3, 0x00, 0xf0, 0x21, 0xe1, +0x74, 0xd0, 0x9f, 0xe5, 0xd1, 0x00, 0xa0, 0xe3, 0x00, 0xf0, 0x21, 0xe1, +0x6c, 0xd0, 0x9f, 0xe5, 0x96, 0x14, 0x00, 0xeb, 0xd3, 0x00, 0xa0, 0xe3, +0x00, 0xf0, 0x21, 0xe1, 0x60, 0xd0, 0x9f, 0xe5, 0x60, 0x00, 0x9f, 0xe5, +0x60, 0x10, 0x9f, 0xe5, 0x60, 0x20, 0x9f, 0xe5, 0xdb, 0xff, 0xff, 0xeb, +0x5c, 0x00, 0x9f, 0xe5, 0x5c, 0x10, 0x9f, 0xe5, 0x00, 0x20, 0xa0, 0xe3, +0xd7, 0xff, 0xff, 0xeb, 0x54, 0x00, 0x9f, 0xe5, 0x54, 0x10, 0x9f, 0xe5, +0xd4, 0xff, 0xff, 0xeb, 0x0a, 0x00, 0xa0, 0xe1, 0x0b, 0xf0, 0xa0, 0xe1, +0xd3, 0x10, 0xa0, 0xe3, 0x01, 0xf0, 0x21, 0xe1, 0xd4, 0xff, 0xff, 0xeb, +0x3c, 0xa0, 0x9f, 0xe5, 0x1a, 0xff, 0x2f, 0xe1, 0xc6, 0xff, 0xff, 0xea, +0x01, 0x21, 0xff, 0xff, 0x0c, 0x00, 0x10, 0x00, 0x1c, 0x00, 0x10, 0x00, +0x3c, 0x38, 0x00, 0x80, 0xfc, 0x37, 0x00, 0x80, 0xfc, 0x3f, 0x00, 0x80, +0x7c, 0x34, 0x00, 0x80, 0x80, 0x0f, 0x00, 0x00, 0x80, 0x30, 0x00, 0x80, +0xad, 0xde, 0xad, 0xde, 0x5c, 0xbc, 0x00, 0x00, 0x24, 0xab, 0x20, 0x40, +0x48, 0x29, 0x00, 0x00, 0x28, 0x05, 0x00, 0x80, 0x8d, 0xd2, 0x21, 0x40, +0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x44, 0x57, 0x00, 0x00, 0x71, 0xaf, 0x00, 0x00, 0x60, 0x01, 0xff, 0xff, +0xb0, 0xb5, 0x07, 0x1c, 0x12, 0x4c, 0x00, 0x25, 0x20, 0x68, 0x00, 0x28, +0x1d, 0xd0, 0x38, 0x1c, 0x10, 0x49, 0x04, 0xf0, 0x71, 0xfd, 0x21, 0x68, +0xc0, 0x46, 0x08, 0x60, 0x00, 0x28, 0x14, 0xd0, 0x38, 0x01, 0x0d, 0x49, +0x40, 0x18, 0x19, 0x23, 0xdb, 0x01, 0xc0, 0x18, 0x41, 0x6b, 0x80, 0x29, +0x0b, 0xd2, 0x01, 0x31, 0x41, 0x63, 0x20, 0x68, 0xc1, 0x69, 0xc0, 0x46, +0x21, 0x60, 0x39, 0x07, 0x41, 0x60, 0xc7, 0x62, 0xb0, 0xbc, 0x08, 0xbc, +0x18, 0x47, 0x28, 0x1c, 0xfa, 0xe7, 0x00, 0x00, 0xe8, 0x17, 0x00, 0x80, +0xee, 0x05, 0x00, 0x00, 0xa0, 0x1c, 0x00, 0x80, 0x02, 0x49, 0x0a, 0x68, +0xc0, 0x46, 0xc2, 0x61, 0x08, 0x60, 0x70, 0x47, +0xe8, 0x17, 0x00, 0x80, 0x70, 0x47, 0x00, 0x00, 0x70, 0x47, 0x00, 0x00, +0x70, 0x47, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xe1, 0x00, 0x10, 0xa0, 0xe1, +0xc0, 0x10, 0x81, 0xe3, 0x01, 0xf0, 0x21, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0x00, 0xf0, 0x21, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x0f, 0xe1, -0x40, 0x00, 0x80, 0xe3, 0x00, 0xf0, 0x21, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, -0x00, 0x00, 0x0f, 0xe1, 0x80, 0x00, 0x10, 0xe3, 0x80, 0x00, 0x80, 0xe3, -0x00, 0xf0, 0x21, 0xe1, 0x00, 0x00, 0x00, 0x12, 0x1e, 0xff, 0x2f, 0xe1, -0x00, 0x00, 0x50, 0xe3, 0x00, 0x00, 0x0f, 0xe1, 0x80, 0x00, 0xc0, 0x13, +0xc0, 0x00, 0x80, 0xe3, 0x00, 0xf0, 0x21, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, +0x00, 0x00, 0x0f, 0xe1, 0xc0, 0x00, 0xc0, 0xe3, 0x00, 0xf0, 0x21, 0xe1, +0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x0f, 0xe1, 0x40, 0x00, 0x80, 0xe3, 0x00, 0xf0, 0x21, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x0f, 0xe1, -0x80, 0x00, 0xc0, 0xe3, 0x00, 0xf0, 0x21, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, -0x91, 0x00, 0x00, 0xe0, 0x1e, 0xff, 0x2f, 0xe1, 0x01, 0x20, 0x80, 0xe0, -0x01, 0x00, 0x80, 0xe0, 0x1e, 0xff, 0x2f, 0xe1, 0x80, 0xb5, 0x08, 0x4f, -0x64, 0x28, 0x04, 0xd3, 0x64, 0x20, 0xf8, 0x62, 0x00, 0x20, 0xc0, 0x43, -0x03, 0xe0, 0xf8, 0x62, 0x04, 0x49, 0x06, 0xf0, 0xb1, 0xfe, 0x38, 0x63, -0x78, 0x63, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0xf8, 0x0d, 0x00, 0x80, -0x88, 0x13, 0x00, 0x00, 0x80, 0xb4, 0x10, 0x4b, 0x00, 0x22, 0xdf, 0x6a, -0x64, 0x2f, 0x03, 0xd2, 0x09, 0x68, 0x09, 0x68, 0x49, 0x08, 0x02, 0xd2, -0x10, 0x1c, 0x80, 0xbc, 0x70, 0x47, 0x19, 0x1c, 0x9b, 0x6b, 0x0f, 0x6b, -0xbb, 0x42, 0x05, 0xd2, 0x40, 0x68, 0x00, 0x04, 0x00, 0x0c, 0x18, 0x18, -0x88, 0x63, 0xf1, 0xe7, 0x41, 0x68, 0x05, 0x4b, 0x19, 0x43, 0x41, 0x60, -0x04, 0x48, 0xc1, 0x6b, 0x01, 0x31, 0xc1, 0x63, 0x02, 0x20, 0xe8, 0xe7, -0xf8, 0x0d, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x94, 0x2c, 0x00, 0x80, -0x90, 0xb5, 0x07, 0x1c, 0x15, 0x4c, 0x00, 0x20, 0xe1, 0x6a, 0x64, 0x29, -0x0b, 0xd2, 0xb9, 0x6e, 0x49, 0x08, 0x08, 0xd3, 0xe1, 0x6b, 0x62, 0x6b, -0x91, 0x42, 0x07, 0xd2, 0xfa, 0x1d, 0x39, 0x32, 0x52, 0x8b, 0x89, 0x18, -0xe1, 0x63, 0x90, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x78, 0x6a, 0x39, 0x6b, -0xc0, 0x46, 0x48, 0x62, 0x38, 0x6b, 0x03, 0xf0, 0xc7, 0xf9, 0x38, 0x1c, -0x02, 0xf0, 0x7d, 0xfe, 0x01, 0x20, 0xbb, 0x23, 0x1b, 0x01, 0xe1, 0x18, -0xc8, 0x70, 0x05, 0x49, 0x0a, 0x6c, 0x12, 0x18, 0x0a, 0x64, 0x04, 0x49, -0x8a, 0x6d, 0x12, 0x18, 0x8a, 0x65, 0xe4, 0xe7, 0xf8, 0x0d, 0x00, 0x80, -0x94, 0x2c, 0x00, 0x80, 0x2c, 0x2c, 0x00, 0x80, 0x80, 0xb4, 0x0a, 0x48, -0xc0, 0x6d, 0x02, 0x23, 0x18, 0x40, 0x09, 0x4a, 0x00, 0x21, 0x00, 0x28, -0x03, 0xd0, 0x91, 0x63, 0xd1, 0x63, 0x80, 0xbc, 0x70, 0x47, 0x06, 0x48, -0x07, 0x68, 0x7b, 0x1c, 0x03, 0x60, 0x0a, 0x2f, -0xf7, 0xd3, 0x01, 0x60, 0xf3, 0xe7, 0x00, 0x00, 0x2c, 0x2c, 0x00, 0x80, -0xf8, 0x0d, 0x00, 0x80, 0x5c, 0x01, 0x00, 0x80, 0x70, 0x47, 0x02, 0x04, -0x12, 0x0c, 0x00, 0x0c, 0x10, 0x18, 0x0a, 0x04, 0x12, 0x0c, 0x09, 0x0c, -0x51, 0x18, 0x08, 0x18, 0x01, 0x0c, 0x05, 0xd0, 0x01, 0x04, 0x09, 0x0c, -0x00, 0x0c, 0x08, 0x18, 0x01, 0x0c, 0xf9, 0xd1, 0x00, 0x04, 0x00, 0x0c, -0x70, 0x47, 0x80, 0xb4, 0x00, 0x22, 0x00, 0x29, 0x18, 0xd0, 0x4f, 0x08, -0x7b, 0x1e, 0x00, 0x2f, 0x06, 0xd0, 0x07, 0x88, 0xba, 0x18, 0x02, 0x30, -0x1f, 0x1c, 0x01, 0x3b, 0x00, 0x2f, 0xf8, 0xd1, 0x49, 0x08, 0x03, 0xd3, -0x00, 0x88, 0x00, 0x06, 0x00, 0x0e, 0x82, 0x18, 0x10, 0x0c, 0x05, 0xd0, -0x10, 0x04, 0x00, 0x0c, 0x11, 0x0c, 0x42, 0x18, 0x10, 0x0c, 0xf9, 0xd1, -0x10, 0x04, 0x00, 0x0c, 0x80, 0xbc, 0x70, 0x47, 0x80, 0xb5, 0x83, 0x89, -0xc7, 0x89, 0xfb, 0x18, 0x07, 0x8a, 0xfb, 0x18, 0x47, 0x8a, 0xfb, 0x18, -0x40, 0x7a, 0x00, 0x02, 0xc7, 0x18, 0x38, 0x0c, 0x05, 0xd0, 0x38, 0x04, -0x00, 0x0c, 0x3b, 0x0c, 0xc7, 0x18, 0x38, 0x0c, 0xf9, 0xd1, 0x08, 0x1c, -0x11, 0x1c, 0xff, 0xf7, 0xc8, 0xff, 0x01, 0x1c, 0x38, 0x1c, 0xff, 0xf7, -0xb0, 0xff, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x90, 0xb5, 0x02, 0x23, -0x82, 0x68, 0x1a, 0x40, 0x00, 0x27, 0x00, 0x2a, 0x0f, 0xd0, 0x0a, 0x4a, -0x93, 0x69, 0x01, 0x33, 0x93, 0x61, 0x0a, 0x68, 0x8b, 0x68, 0x9a, 0x18, -0x00, 0x68, 0x1c, 0x18, 0x57, 0x81, 0x09, 0x69, 0x10, 0x1c, 0xff, 0xf7, -0xac, 0xff, 0xc0, 0x43, 0x60, 0x81, 0x38, 0x1c, 0x90, 0xbc, 0x08, 0xbc, -0x18, 0x47, 0x00, 0x00, 0x94, 0x2c, 0x00, 0x80, 0x90, 0xb5, 0x04, 0x23, -0x82, 0x68, 0x1a, 0x40, 0x00, 0x27, 0x00, 0x2a, 0x11, 0xd0, 0x4a, 0x68, -0x52, 0x09, 0x0e, 0xd3, 0x09, 0x4a, 0x13, 0x6a, 0x01, 0x33, 0x13, 0x62, -0xcb, 0x68, 0x02, 0x68, 0x9c, 0x18, 0x01, 0x23, 0x9b, 0x07, 0x08, 0x3a, -0x1a, 0x43, 0x12, 0x68, 0x00, 0xf0, 0x2e, 0xf8, 0x20, 0x82, 0x38, 0x1c, -0x90, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, 0x94, 0x2c, 0x00, 0x80, -0x90, 0xb5, 0x80, 0x23, 0x82, 0x68, 0x1a, 0x40, 0x00, 0x24, 0x00, 0x2a, -0x15, 0xd0, 0x4a, 0x68, 0x92, 0x09, 0x12, 0xd3, 0x0b, 0x4a, 0xd3, 0x69, -0x01, 0x33, 0xd3, 0x61, 0xcb, 0x68, 0x02, 0x68, 0x9f, 0x18, 0x01, 0x23, -0x9b, 0x07, 0x08, 0x3a, 0x1a, 0x43, 0x12, 0x68, 0x00, 0xf0, 0x0e, 0xf8, -0x00, 0x28, 0x00, 0xd1, 0x04, 0x48, 0xc0, 0x46, 0xf8, 0x80, 0x20, 0x1c, -0x90, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, 0x94, 0x2c, 0x00, 0x80, -0xff, 0xff, 0x00, 0x00, 0xb0, 0xb5, 0x14, 0x1c, 0x05, 0x1c, 0x0f, 0x1c, -0x38, 0x69, 0xb9, 0x68, 0x41, 0x18, 0x38, 0x68, 0xff, 0xf7, 0x53, 0xff, -0xc0, 0x43, 0x01, 0x04, 0x09, 0x0c, 0x20, 0x1c, 0xff, 0xf7, 0x39, 0xff, -0x04, 0x1c, 0xb8, 0x68, 0x79, 0x69, 0x40, 0x18, 0x69, 0x68, 0x88, 0x42, -0x0c, 0xd2, 0x2a, 0x68, 0x12, 0x18, 0x09, 0x1a, 0x10, 0x1c, 0x00, 0xf0, -0x05, 0xf9, 0xc0, 0x43, 0x01, 0x04, 0x09, 0x0c, 0x20, 0x1c, 0xff, 0xf7, -0x26, 0xff, 0x04, 0x1c, 0xe0, 0x43, 0x00, 0x04, 0x00, 0x0c, 0xb0, 0xbc, -0x08, 0xbc, 0x18, 0x47, 0x80, 0xb5, 0x07, 0x1c, 0xb8, 0x6b, 0xc0, 0x08, -0x1a, 0xd3, 0xb8, 0x6a, 0xf9, 0x6b, 0x40, 0x18, 0x79, 0x6c, 0x00, 0xf0, -0xed, 0xf8, 0xc0, 0x43, 0x01, 0x04, 0x09, 0x0c, 0x0a, 0x48, 0x07, 0xd0, -0x20, 0x23, 0xb9, 0x69, 0x19, 0x43, 0xb9, 0x61, -0x01, 0x6b, 0x01, 0x31, 0x01, 0x63, 0x07, 0xe0, 0xff, 0x23, 0x01, 0x33, -0xb9, 0x69, 0x19, 0x43, 0xb9, 0x61, 0x41, 0x6a, 0x01, 0x31, 0x41, 0x62, -0x00, 0x20, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x94, 0x2c, 0x00, 0x80, -0x80, 0xb5, 0x07, 0x1c, 0xb8, 0x6b, 0x41, 0x09, 0x1c, 0xd3, 0xc0, 0x08, -0x1a, 0xd3, 0xf8, 0x1d, 0x39, 0x30, 0x00, 0x7b, 0x06, 0x28, 0x15, 0xd1, -0x38, 0x1c, 0x00, 0xf0, 0x53, 0xf8, 0x01, 0x1c, 0x0a, 0x48, 0x07, 0xd0, -0x40, 0x23, 0xb9, 0x69, 0x19, 0x43, 0xb9, 0x61, 0x81, 0x6b, 0x01, 0x31, -0x81, 0x63, 0x07, 0xe0, 0x01, 0x23, 0x9b, 0x02, 0xb9, 0x69, 0x19, 0x43, -0xb9, 0x61, 0xc1, 0x6a, 0x01, 0x31, 0xc1, 0x62, 0x00, 0x20, 0x80, 0xbc, -0x08, 0xbc, 0x18, 0x47, 0x94, 0x2c, 0x00, 0x80, 0xb0, 0xb5, 0x07, 0x1c, -0xb8, 0x6b, 0x81, 0x09, 0x2c, 0xd3, 0xc0, 0x08, 0x2a, 0xd3, 0xf8, 0x1d, -0x39, 0x30, 0x00, 0x7b, 0x11, 0x28, 0x25, 0xd1, 0xb8, 0x6a, 0x39, 0x6c, -0x40, 0x18, 0x01, 0x23, 0x9b, 0x07, 0x06, 0x30, 0x18, 0x43, 0x00, 0x68, -0x05, 0x04, 0x2d, 0x0c, 0x0f, 0x4c, 0x11, 0xd0, 0x38, 0x1c, 0x00, 0xf0, -0x1f, 0xf8, 0x00, 0x28, 0x0c, 0xd0, 0xa8, 0x42, 0x02, 0xd1, 0x0c, 0x4b, -0x98, 0x42, 0x07, 0xd0, 0x80, 0x23, 0xb8, 0x69, 0x18, 0x43, 0xb8, 0x61, -0x60, 0x6b, 0x01, 0x30, 0x60, 0x63, 0x07, 0xe0, 0x01, 0x23, 0x5b, 0x02, -0xb8, 0x69, 0x18, 0x43, 0xb8, 0x61, 0xa0, 0x6a, 0x01, 0x30, 0xa0, 0x62, -0x00, 0x20, 0xb0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x94, 0x2c, 0x00, 0x80, -0xff, 0xff, 0x00, 0x00, 0xf0, 0xb5, 0xff, 0xb0, 0x99, 0xb0, 0x04, 0x1c, -0xe0, 0x6b, 0x61, 0x6c, 0x09, 0x18, 0x03, 0xaa, 0x85, 0x18, 0xa3, 0x6a, -0x00, 0x20, 0x8a, 0x08, 0x01, 0x32, 0x97, 0x92, 0x07, 0xd0, 0x82, 0x00, -0x9f, 0x58, 0x03, 0xae, 0xb7, 0x50, 0x97, 0x9a, 0x01, 0x30, 0x82, 0x42, -0xf7, 0xd8, 0x60, 0x6a, 0x01, 0x23, 0x9b, 0x07, 0x04, 0x30, 0x18, 0x43, -0x00, 0x68, 0xc0, 0x46, 0x02, 0x90, 0x02, 0xaf, 0x3f, 0x88, 0x03, 0xa8, -0xff, 0xf7, 0x87, 0xfe, 0xc0, 0x43, 0x01, 0x04, 0x09, 0x0c, 0x38, 0x1c, -0xff, 0xf7, 0x6d, 0xfe, 0x07, 0x1c, 0xe0, 0x6b, 0xa1, 0x6c, 0x40, 0x18, -0x61, 0x6a, 0x01, 0x23, 0x9b, 0x07, 0x08, 0x31, 0x19, 0x43, 0x09, 0x68, -0xc0, 0x46, 0x01, 0x91, 0x01, 0xa9, 0x09, 0x88, 0x01, 0x31, 0x88, 0x42, -0x0c, 0xd2, 0xa2, 0x6a, 0x12, 0x18, 0x09, 0x1a, 0x10, 0x1c, 0x00, 0xf0, -0x2f, 0xf8, 0xc0, 0x43, 0x01, 0x04, 0x09, 0x0c, 0x38, 0x1c, 0xff, 0xf7, -0x50, 0xfe, 0x07, 0x1c, 0xa8, 0x89, 0xe9, 0x89, 0x08, 0x18, 0x29, 0x8a, -0x08, 0x18, 0x69, 0x8a, 0x08, 0x18, 0x69, 0x7a, 0x09, 0x02, 0x08, 0x18, -0xa1, 0x6c, 0x62, 0x6c, 0x89, 0x1a, 0x0a, 0x04, 0x12, 0x0c, 0x11, 0x02, -0x12, 0x0a, 0x11, 0x43, 0x09, 0x04, 0x09, 0x0c, 0x09, 0x18, 0x08, 0x0c, -0x05, 0xd0, 0x08, 0x04, 0x00, 0x0c, 0x09, 0x0c, 0x41, 0x18, 0x08, 0x0c, -0xf9, 0xd1, 0x38, 0x1c, 0xff, 0xf7, 0x2f, 0xfe, 0xc0, 0x43, 0x00, 0x04, -0x00, 0x0c, 0x7f, 0xb0, 0x19, 0xb0, 0xf0, 0xbc, 0x08, 0xbc, 0x18, 0x47, -0xb0, 0xb4, 0x00, 0x22, 0x00, 0x29, 0x2e, 0xd0, 0x83, 0x07, 0x9b, 0x0f, -0xdc, 0x00, 0x47, 0x18, 0x04, 0x25, 0xef, 0x1b, 0xbf, 0x07, 0xbf, 0x0f, -0xff, 0x00, 0x80, 0x08, 0x80, 0x00, 0x59, 0x18, 0x03, 0x31, 0x89, 0x08, -0x4d, 0x1e, 0x02, 0xc8, 0xe1, 0x40, 0xa1, 0x40, 0x6b, 0x1e, 0x00, 0x2d, -0x09, 0xd0, 0x0c, 0x04, 0x24, 0x0c, 0xa2, 0x18, -0x09, 0x0c, 0x8a, 0x18, 0x02, 0xc8, 0x1c, 0x1c, 0x01, 0x3b, 0x00, 0x2c, -0xf5, 0xd1, 0xb9, 0x40, 0x08, 0x1c, 0xf8, 0x40, 0x01, 0x04, 0x09, 0x0c, -0x89, 0x18, 0x00, 0x0c, 0x42, 0x18, 0x10, 0x0c, 0x05, 0xd0, 0x10, 0x04, -0x00, 0x0c, 0x11, 0x0c, 0x42, 0x18, 0x10, 0x0c, 0xf9, 0xd1, 0x10, 0x04, -0x00, 0x0c, 0xb0, 0xbc, 0x70, 0x47, 0x00, 0x00, 0x90, 0xb4, 0x00, 0x20, -0x01, 0x27, 0x11, 0x49, 0x42, 0x00, 0x12, 0x18, 0xd2, 0x00, 0x53, 0x18, -0x9c, 0x68, 0x01, 0x23, 0x9b, 0x07, 0x23, 0x43, 0x1b, 0x68, 0x1b, 0x03, -0x1b, 0x0b, 0x8a, 0x58, 0x12, 0x03, 0x12, 0x0b, 0x93, 0x42, 0x0c, 0xd1, -0x01, 0x30, 0x04, 0x28, 0xec, 0xd3, 0x08, 0x48, 0xc0, 0x6a, 0x01, 0x03, -0x09, 0x0b, 0x07, 0x48, 0xc0, 0x6e, 0x00, 0x03, 0x00, 0x0b, 0x81, 0x42, -0x02, 0xd0, 0x38, 0x1c, 0x90, 0xbc, 0x70, 0x47, 0x00, 0x20, 0xfb, 0xe7, -0x18, 0x03, 0x00, 0x80, 0x00, 0x40, 0x14, 0x40, 0xf8, 0x0d, 0x00, 0x80, -0x98, 0xb4, 0x14, 0x4a, 0xc0, 0x46, 0x00, 0x92, 0x83, 0x00, 0x13, 0x48, -0xc0, 0x58, 0x07, 0x03, 0x3f, 0x0b, 0x12, 0x48, 0xc0, 0x58, 0x02, 0x03, -0x12, 0x0b, 0x11, 0x48, 0xc0, 0x58, 0x00, 0x03, 0x00, 0x0b, 0x10, 0x4c, -0xe4, 0x58, 0x01, 0x23, 0x9b, 0x07, 0x23, 0x43, 0x1b, 0x68, 0x9b, 0x00, -0xcc, 0x00, 0x01, 0x21, 0x98, 0x42, 0x01, 0xd1, 0x08, 0x1c, 0x09, 0xe0, -0x98, 0x42, 0x03, 0xd9, 0x10, 0x1a, 0xda, 0x1b, 0x80, 0x18, 0x00, 0xe0, -0x18, 0x1a, 0x84, 0x42, 0xf4, 0xd3, 0x00, 0x20, 0x98, 0xbc, 0x70, 0x47, -0x55, 0x55, 0x55, 0x55, 0x90, 0x03, 0x00, 0x80, 0x98, 0x03, 0x00, 0x80, -0x78, 0x03, 0x00, 0x80, 0x88, 0x03, 0x00, 0x80, 0x80, 0xb4, 0x13, 0x04, -0x00, 0xd0, 0x01, 0x3a, 0x80, 0x00, 0x0b, 0x1c, 0x13, 0x49, 0x0f, 0x58, -0xc0, 0x46, 0x3b, 0x60, 0x0b, 0x58, 0xc0, 0x46, 0x5a, 0x60, 0x0a, 0x58, -0x08, 0x32, 0x10, 0x4b, 0x1b, 0x58, 0x9a, 0x42, 0x01, 0xd3, 0x0f, 0x4a, -0x12, 0x58, 0x0f, 0x4b, 0x1f, 0x58, 0x01, 0x23, 0x9b, 0x07, 0x3b, 0x43, -0x1b, 0x68, 0x9b, 0x00, 0x17, 0x03, 0x3f, 0x0b, 0x9f, 0x42, 0x06, 0xd1, -0x0a, 0x48, 0xc1, 0x68, 0x01, 0x31, 0xc1, 0x60, 0x01, 0x20, 0x80, 0xbc, -0x70, 0x47, 0x08, 0x4b, 0x1b, 0x58, 0xc0, 0x46, 0x1a, 0x60, 0x0a, 0x50, -0x00, 0x20, 0xf6, 0xe7, 0x78, 0x03, 0x00, 0x80, 0x98, 0x03, 0x00, 0x80, -0x90, 0x03, 0x00, 0x80, 0x88, 0x03, 0x00, 0x80, 0xa0, 0x82, 0x20, 0x40, -0x80, 0x03, 0x00, 0x80, 0xff, 0x5f, 0x2d, 0xe9, 0x48, 0xfe, 0xff, 0xeb, -0x01, 0xb6, 0xa0, 0xe3, 0x01, 0xb1, 0x8b, 0xe2, 0x02, 0x7a, 0xa0, 0xe3, -0x01, 0x6a, 0xa0, 0xe3, 0xc4, 0xa0, 0x9f, 0xe5, 0x01, 0x99, 0xa0, 0xe3, -0x01, 0x56, 0xa0, 0xe3, 0xbc, 0x80, 0x9f, 0xe5, 0x14, 0x40, 0x9b, 0xe5, -0x00, 0x00, 0x54, 0xe3, 0x29, 0x00, 0x00, 0x0a, 0x03, 0x0a, 0x14, 0xe3, -0x17, 0x00, 0x00, 0x0a, 0x08, 0x00, 0x9a, 0xe5, 0x00, 0x00, 0x50, 0xe3, -0x0a, 0x00, 0x00, 0x0a, 0x01, 0x0a, 0x14, 0xe3, 0x03, 0x00, 0x00, 0x0a, -0x00, 0x00, 0xa0, 0xe3, 0xb0, 0x19, 0x00, 0xeb, 0x14, 0x60, 0x85, 0xe5, -0x0e, 0x00, 0x00, 0xea, 0x02, 0x0a, 0x14, 0xe3, 0x0c, 0x00, 0x00, 0x0a, -0x01, 0x00, 0xa0, 0xe3, 0xaa, 0x19, 0x00, 0xeb, 0x08, 0x00, 0x00, 0xea, -0x18, 0x00, 0x9a, 0xe5, 0x01, 0x0a, 0xc0, 0xe3, 0x18, 0x00, 0x8a, 0xe5, -0x1c, 0x00, 0x85, 0xe5, 0x14, 0x60, 0x85, 0xe5, 0x18, 0x00, 0x9a, 0xe5, -0x02, 0x0a, 0xc0, 0xe3, 0x18, 0x00, 0x8a, 0xe5, -0x1c, 0x00, 0x85, 0xe5, 0x14, 0x70, 0x85, 0xe5, 0x01, 0x09, 0x14, 0xe3, -0x01, 0x00, 0x00, 0x0a, 0x99, 0x19, 0x00, 0xeb, 0x14, 0x90, 0x85, 0xe5, -0x02, 0x00, 0x14, 0xe3, 0x3a, 0x00, 0x00, 0x1b, 0x01, 0x00, 0x14, 0xe3, -0x3e, 0x00, 0x00, 0x1b, 0x02, 0x0b, 0x14, 0xe3, 0x42, 0x00, 0x00, 0x1b, -0x01, 0x0b, 0x14, 0xe3, 0x1a, 0x00, 0x00, 0x1b, 0x18, 0x00, 0x98, 0xe5, -0x01, 0x00, 0x80, 0xe2, 0x18, 0x00, 0x88, 0xe5, 0xd2, 0xff, 0xff, 0xea, -0xff, 0x5f, 0xbd, 0xe8, 0x04, 0xf0, 0x5e, 0xe2, 0xf8, 0x0d, 0x00, 0x80, -0x04, 0x83, 0x20, 0x40, 0x10, 0x10, 0x1f, 0xe5, 0x10, 0x30, 0x91, 0xe5, -0x00, 0x20, 0xc3, 0xe1, 0x10, 0x20, 0x81, 0xe5, 0x01, 0x16, 0xa0, 0xe3, -0x0c, 0x20, 0x81, 0xe5, 0x0b, 0x12, 0xa0, 0xe3, 0x00, 0x00, 0x81, 0xe5, -0x18, 0x10, 0x9f, 0xe5, 0xb0, 0x24, 0xd1, 0xe1, 0x01, 0x20, 0x82, 0xe2, -0xb0, 0x24, 0xc1, 0xe1, 0x3c, 0x20, 0x91, 0xe5, 0x00, 0x00, 0x82, 0xe1, -0x3c, 0x00, 0x81, 0xe5, 0x1e, 0xff, 0x2f, 0xe1, 0xa0, 0x82, 0x20, 0x40, -0xff, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x01, 0x0b, 0xa0, 0xe3, -0x01, 0x16, 0xa0, 0xe3, 0x14, 0x00, 0x81, 0xe5, 0x00, 0x1a, 0x81, 0xe1, -0x24, 0x20, 0x91, 0xe5, 0x70, 0x00, 0x1f, 0xe5, 0x00, 0x00, 0x00, 0x00, -0x20, 0x20, 0x80, 0xe5, 0x28, 0x10, 0x91, 0xe5, 0x00, 0x00, 0x00, 0x00, -0x24, 0x10, 0x80, 0xe5, 0x28, 0x20, 0x90, 0xe5, 0x01, 0x20, 0x82, 0xe2, -0x28, 0x20, 0x80, 0xe5, 0x3f, 0x00, 0x01, 0xe2, 0x3f, 0x00, 0x50, 0xe3, -0x1e, 0xff, 0x2f, 0x11, 0x18, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, -0x01, 0x10, 0x81, 0xe2, 0x00, 0x10, 0x80, 0xe5, 0x02, 0x18, 0xa0, 0xe3, -0x0b, 0x02, 0xa0, 0xe3, 0x00, 0x10, 0x80, 0xe5, 0x1e, 0xff, 0x2f, 0xe1, -0xa0, 0x03, 0x00, 0x80, 0x0b, 0x10, 0xa0, 0xe3, 0x02, 0x19, 0x81, 0xe2, -0x06, 0x07, 0xa0, 0xe3, 0x4c, 0x11, 0x80, 0xe5, 0xff, 0xff, 0xff, 0xea, -0xfe, 0xff, 0xff, 0xea, 0x0c, 0x10, 0xa0, 0xe3, 0x02, 0x19, 0x81, 0xe2, -0x06, 0x07, 0xa0, 0xe3, 0x4c, 0x11, 0x80, 0xe5, 0xff, 0xff, 0xff, 0xea, +0x80, 0x00, 0x10, 0xe3, 0x80, 0x00, 0x80, 0xe3, 0x00, 0xf0, 0x21, 0xe1, +0x00, 0x00, 0x00, 0x12, 0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x50, 0xe3, +0x00, 0x00, 0x0f, 0xe1, 0x80, 0x00, 0xc0, 0x13, 0x00, 0xf0, 0x21, 0xe1, +0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x0f, 0xe1, 0x80, 0x00, 0xc0, 0xe3, +0x00, 0xf0, 0x21, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0x91, 0x00, 0x00, 0xe0, +0x1e, 0xff, 0x2f, 0xe1, 0x01, 0x20, 0x80, 0xe0, 0x01, 0x00, 0x80, 0xe0, +0x1e, 0xff, 0x2f, 0xe1, 0x80, 0xb5, 0x08, 0x4f, 0x64, 0x28, 0x04, 0xd3, +0x64, 0x20, 0x38, 0x63, 0x00, 0x20, 0xc0, 0x43, 0x03, 0xe0, 0x38, 0x63, +0x04, 0x49, 0x05, 0xf0, 0xf7, 0xfa, 0x78, 0x63, 0xb8, 0x63, 0x80, 0xbc, +0x08, 0xbc, 0x18, 0x47, 0x68, 0x0e, 0x00, 0x80, 0x88, 0x13, 0x00, 0x00, +0x80, 0xb4, 0x10, 0x4b, 0x00, 0x22, 0x1f, 0x6b, 0x64, 0x2f, 0x03, 0xd2, +0x09, 0x68, 0x09, 0x68, 0x49, 0x08, 0x02, 0xd2, 0x10, 0x1c, 0x80, 0xbc, +0x70, 0x47, 0x19, 0x1c, 0xdb, 0x6b, 0x4f, 0x6b, 0xbb, 0x42, 0x05, 0xd2, +0x40, 0x68, 0x00, 0x04, 0x00, 0x0c, 0x18, 0x18, 0xc8, 0x63, 0xf1, 0xe7, +0x41, 0x68, 0x05, 0x4b, 0x19, 0x43, 0x41, 0x60, 0x04, 0x48, 0xc1, 0x6b, +0x01, 0x31, 0xc1, 0x63, 0x02, 0x20, 0xe8, 0xe7, 0x68, 0x0e, 0x00, 0x80, +0x00, 0x00, 0x00, 0x80, 0x0c, 0x2b, 0x00, 0x80, 0x90, 0xb5, 0x07, 0x1c, +0x15, 0x4c, 0x00, 0x20, 0x21, 0x6b, 0x64, 0x29, 0x0b, 0xd2, 0xb9, 0x6e, +0x49, 0x08, 0x08, 0xd3, 0x21, 0x6c, 0xa2, 0x6b, 0x91, 0x42, 0x07, 0xd2, +0xfa, 0x1d, 0x39, 0x32, 0x52, 0x8b, 0x89, 0x18, 0x21, 0x64, 0x90, 0xbc, +0x08, 0xbc, 0x18, 0x47, 0x78, 0x6a, 0x39, 0x6b, 0xc0, 0x46, 0x48, 0x62, +0x38, 0x6b, 0x02, 0xf0, 0x23, 0xfe, 0x38, 0x1c, 0x02, 0xf0, 0xde, 0xfa, +0x01, 0x20, 0xbb, 0x23, 0x1b, 0x01, 0xe1, 0x18, 0xc8, 0x73, 0x05, 0x49, +0x0a, 0x6c, 0x12, 0x18, 0x0a, 0x64, 0x04, 0x49, 0x8a, 0x6d, 0x12, 0x18, +0x8a, 0x65, 0xe4, 0xe7, 0x68, 0x0e, 0x00, 0x80, 0x0c, 0x2b, 0x00, 0x80, +0xa4, 0x2a, 0x00, 0x80, 0x80, 0xb4, 0x0a, 0x48, 0xc0, 0x6d, 0x02, 0x23, +0x18, 0x40, 0x09, 0x4a, 0x00, 0x21, 0x00, 0x28, 0x03, 0xd0, 0xd1, 0x63, +0x11, 0x64, 0x80, 0xbc, 0x70, 0x47, 0x06, 0x48, 0x07, 0x68, 0x7b, 0x1c, +0x03, 0x60, 0x0a, 0x2f, 0xf7, 0xd3, 0x01, 0x60, 0xf3, 0xe7, 0x00, 0x00, +0xa4, 0x2a, 0x00, 0x80, 0x68, 0x0e, 0x00, 0x80, 0xe0, 0x01, 0x00, 0x80, +0x70, 0x47, 0x02, 0x04, 0x12, 0x0c, 0x00, 0x0c, 0x10, 0x18, 0x0a, 0x04, +0x12, 0x0c, 0x09, 0x0c, 0x51, 0x18, 0x08, 0x18, 0x01, 0x0c, 0x05, 0xd0, +0x01, 0x04, 0x09, 0x0c, 0x00, 0x0c, 0x08, 0x18, 0x01, 0x0c, 0xf9, 0xd1, +0x00, 0x04, 0x00, 0x0c, 0x70, 0x47, 0x80, 0xb4, 0x00, 0x22, 0x00, 0x29, +0x18, 0xd0, 0x4f, 0x08, 0x7b, 0x1e, 0x00, 0x2f, +0x06, 0xd0, 0x07, 0x88, 0xba, 0x18, 0x02, 0x30, 0x1f, 0x1c, 0x01, 0x3b, +0x00, 0x2f, 0xf8, 0xd1, 0x49, 0x08, 0x03, 0xd3, 0x00, 0x88, 0x00, 0x06, +0x00, 0x0e, 0x82, 0x18, 0x10, 0x0c, 0x05, 0xd0, 0x10, 0x04, 0x00, 0x0c, +0x11, 0x0c, 0x42, 0x18, 0x10, 0x0c, 0xf9, 0xd1, 0x10, 0x04, 0x00, 0x0c, +0x80, 0xbc, 0x70, 0x47, 0x80, 0xb5, 0x83, 0x89, 0xc7, 0x89, 0xfb, 0x18, +0x07, 0x8a, 0xfb, 0x18, 0x47, 0x8a, 0xfb, 0x18, 0x40, 0x7a, 0x00, 0x02, +0xc7, 0x18, 0x38, 0x0c, 0x05, 0xd0, 0x38, 0x04, 0x00, 0x0c, 0x3b, 0x0c, +0xc7, 0x18, 0x38, 0x0c, 0xf9, 0xd1, 0x08, 0x1c, 0x11, 0x1c, 0xff, 0xf7, +0xc8, 0xff, 0x01, 0x1c, 0x38, 0x1c, 0xff, 0xf7, 0xb0, 0xff, 0x80, 0xbc, +0x08, 0xbc, 0x18, 0x47, 0x90, 0xb5, 0x02, 0x23, 0x82, 0x68, 0x1a, 0x40, +0x00, 0x27, 0x00, 0x2a, 0x0f, 0xd0, 0x0a, 0x4a, 0x93, 0x69, 0x01, 0x33, +0x93, 0x61, 0x0a, 0x68, 0x8b, 0x68, 0x9a, 0x18, 0x00, 0x68, 0x1c, 0x18, +0x57, 0x81, 0x09, 0x69, 0x10, 0x1c, 0xff, 0xf7, 0xac, 0xff, 0xc0, 0x43, +0x60, 0x81, 0x38, 0x1c, 0x90, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, +0x0c, 0x2b, 0x00, 0x80, 0x90, 0xb5, 0x04, 0x23, 0x82, 0x68, 0x1a, 0x40, +0x00, 0x27, 0x00, 0x2a, 0x11, 0xd0, 0x4a, 0x68, 0x52, 0x09, 0x0e, 0xd3, +0x09, 0x4a, 0x13, 0x6a, 0x01, 0x33, 0x13, 0x62, 0xcb, 0x68, 0x02, 0x68, +0x9c, 0x18, 0x01, 0x23, 0x9b, 0x07, 0x08, 0x3a, 0x1a, 0x43, 0x12, 0x68, +0x00, 0xf0, 0x2e, 0xf8, 0x20, 0x82, 0x38, 0x1c, 0x90, 0xbc, 0x08, 0xbc, +0x18, 0x47, 0x00, 0x00, 0x0c, 0x2b, 0x00, 0x80, 0x90, 0xb5, 0x80, 0x23, +0x82, 0x68, 0x1a, 0x40, 0x00, 0x24, 0x00, 0x2a, 0x15, 0xd0, 0x4a, 0x68, +0x92, 0x09, 0x12, 0xd3, 0x0b, 0x4a, 0xd3, 0x69, 0x01, 0x33, 0xd3, 0x61, +0xcb, 0x68, 0x02, 0x68, 0x9f, 0x18, 0x01, 0x23, 0x9b, 0x07, 0x08, 0x3a, +0x1a, 0x43, 0x12, 0x68, 0x00, 0xf0, 0x0e, 0xf8, 0x00, 0x28, 0x00, 0xd1, +0x04, 0x48, 0xc0, 0x46, 0xf8, 0x80, 0x20, 0x1c, 0x90, 0xbc, 0x08, 0xbc, +0x18, 0x47, 0x00, 0x00, 0x0c, 0x2b, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, +0xb0, 0xb5, 0x14, 0x1c, 0x05, 0x1c, 0x0f, 0x1c, 0x38, 0x69, 0xb9, 0x68, +0x41, 0x18, 0x38, 0x68, 0xff, 0xf7, 0x53, 0xff, 0xc0, 0x43, 0x01, 0x04, +0x09, 0x0c, 0x20, 0x1c, 0xff, 0xf7, 0x39, 0xff, 0x04, 0x1c, 0xb8, 0x68, +0x79, 0x69, 0x40, 0x18, 0x69, 0x68, 0x88, 0x42, 0x0c, 0xd2, 0x2a, 0x68, +0x12, 0x18, 0x09, 0x1a, 0x10, 0x1c, 0x00, 0xf0, 0x05, 0xf9, 0xc0, 0x43, +0x01, 0x04, 0x09, 0x0c, 0x20, 0x1c, 0xff, 0xf7, 0x26, 0xff, 0x04, 0x1c, +0xe0, 0x43, 0x00, 0x04, 0x00, 0x0c, 0xb0, 0xbc, 0x08, 0xbc, 0x18, 0x47, +0x80, 0xb5, 0x07, 0x1c, 0xb8, 0x6b, 0xc0, 0x08, 0x1a, 0xd3, 0xb8, 0x6a, +0xf9, 0x6b, 0x40, 0x18, 0x79, 0x6c, 0x00, 0xf0, 0xed, 0xf8, 0xc0, 0x43, +0x01, 0x04, 0x09, 0x0c, 0x0a, 0x48, 0x07, 0xd0, 0x20, 0x23, 0xb9, 0x69, +0x19, 0x43, 0xb9, 0x61, 0x01, 0x6b, 0x01, 0x31, 0x01, 0x63, 0x07, 0xe0, +0xff, 0x23, 0x01, 0x33, 0xb9, 0x69, 0x19, 0x43, 0xb9, 0x61, 0x41, 0x6a, +0x01, 0x31, 0x41, 0x62, 0x00, 0x20, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, +0x0c, 0x2b, 0x00, 0x80, 0x80, 0xb5, 0x07, 0x1c, 0xb8, 0x6b, 0x41, 0x09, +0x1c, 0xd3, 0xc0, 0x08, 0x1a, 0xd3, 0xf8, 0x1d, 0x39, 0x30, 0x00, 0x7b, +0x06, 0x28, 0x15, 0xd1, 0x38, 0x1c, 0x00, 0xf0, 0x53, 0xf8, 0x01, 0x1c, +0x0a, 0x48, 0x07, 0xd0, 0x40, 0x23, 0xb9, 0x69, +0x19, 0x43, 0xb9, 0x61, 0x81, 0x6b, 0x01, 0x31, 0x81, 0x63, 0x07, 0xe0, +0x01, 0x23, 0x9b, 0x02, 0xb9, 0x69, 0x19, 0x43, 0xb9, 0x61, 0xc1, 0x6a, +0x01, 0x31, 0xc1, 0x62, 0x00, 0x20, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, +0x0c, 0x2b, 0x00, 0x80, 0xb0, 0xb5, 0x07, 0x1c, 0xb8, 0x6b, 0x81, 0x09, +0x2c, 0xd3, 0xc0, 0x08, 0x2a, 0xd3, 0xf8, 0x1d, 0x39, 0x30, 0x00, 0x7b, +0x11, 0x28, 0x25, 0xd1, 0xb8, 0x6a, 0x39, 0x6c, 0x40, 0x18, 0x01, 0x23, +0x9b, 0x07, 0x06, 0x30, 0x18, 0x43, 0x00, 0x68, 0x05, 0x04, 0x2d, 0x0c, +0x0f, 0x4c, 0x11, 0xd0, 0x38, 0x1c, 0x00, 0xf0, 0x1f, 0xf8, 0x00, 0x28, +0x0c, 0xd0, 0xa8, 0x42, 0x02, 0xd1, 0x0c, 0x4b, 0x98, 0x42, 0x07, 0xd0, +0x80, 0x23, 0xb8, 0x69, 0x18, 0x43, 0xb8, 0x61, 0x60, 0x6b, 0x01, 0x30, +0x60, 0x63, 0x07, 0xe0, 0x01, 0x23, 0x5b, 0x02, 0xb8, 0x69, 0x18, 0x43, +0xb8, 0x61, 0xa0, 0x6a, 0x01, 0x30, 0xa0, 0x62, 0x00, 0x20, 0xb0, 0xbc, +0x08, 0xbc, 0x18, 0x47, 0x0c, 0x2b, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, +0xf0, 0xb5, 0xff, 0xb0, 0x99, 0xb0, 0x04, 0x1c, 0xe0, 0x6b, 0x61, 0x6c, +0x09, 0x18, 0x03, 0xaa, 0x85, 0x18, 0xa3, 0x6a, 0x00, 0x20, 0x8a, 0x08, +0x01, 0x32, 0x97, 0x92, 0x07, 0xd0, 0x82, 0x00, 0x9f, 0x58, 0x03, 0xae, +0xb7, 0x50, 0x97, 0x9a, 0x01, 0x30, 0x82, 0x42, 0xf7, 0xd8, 0x60, 0x6a, +0x01, 0x23, 0x9b, 0x07, 0x04, 0x30, 0x18, 0x43, 0x00, 0x68, 0xc0, 0x46, +0x02, 0x90, 0x02, 0xaf, 0x3f, 0x88, 0x03, 0xa8, 0xff, 0xf7, 0x87, 0xfe, +0xc0, 0x43, 0x01, 0x04, 0x09, 0x0c, 0x38, 0x1c, 0xff, 0xf7, 0x6d, 0xfe, +0x07, 0x1c, 0xe0, 0x6b, 0xa1, 0x6c, 0x40, 0x18, 0x61, 0x6a, 0x01, 0x23, +0x9b, 0x07, 0x08, 0x31, 0x19, 0x43, 0x09, 0x68, 0xc0, 0x46, 0x01, 0x91, +0x01, 0xa9, 0x09, 0x88, 0x01, 0x31, 0x88, 0x42, 0x0c, 0xd2, 0xa2, 0x6a, +0x12, 0x18, 0x09, 0x1a, 0x10, 0x1c, 0x00, 0xf0, 0x2f, 0xf8, 0xc0, 0x43, +0x01, 0x04, 0x09, 0x0c, 0x38, 0x1c, 0xff, 0xf7, 0x50, 0xfe, 0x07, 0x1c, +0xa8, 0x89, 0xe9, 0x89, 0x08, 0x18, 0x29, 0x8a, 0x08, 0x18, 0x69, 0x8a, +0x08, 0x18, 0x69, 0x7a, 0x09, 0x02, 0x08, 0x18, 0xa1, 0x6c, 0x62, 0x6c, +0x89, 0x1a, 0x0a, 0x04, 0x12, 0x0c, 0x11, 0x02, 0x12, 0x0a, 0x11, 0x43, +0x09, 0x04, 0x09, 0x0c, 0x09, 0x18, 0x08, 0x0c, 0x05, 0xd0, 0x08, 0x04, +0x00, 0x0c, 0x09, 0x0c, 0x41, 0x18, 0x08, 0x0c, 0xf9, 0xd1, 0x38, 0x1c, +0xff, 0xf7, 0x2f, 0xfe, 0xc0, 0x43, 0x00, 0x04, 0x00, 0x0c, 0x7f, 0xb0, +0x19, 0xb0, 0xf0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0xb0, 0xb4, 0x00, 0x22, +0x00, 0x29, 0x2e, 0xd0, 0x83, 0x07, 0x9b, 0x0f, 0xdc, 0x00, 0x47, 0x18, +0x04, 0x25, 0xef, 0x1b, 0xbf, 0x07, 0xbf, 0x0f, 0xff, 0x00, 0x80, 0x08, +0x80, 0x00, 0x59, 0x18, 0x03, 0x31, 0x89, 0x08, 0x4d, 0x1e, 0x02, 0xc8, +0xe1, 0x40, 0xa1, 0x40, 0x6b, 0x1e, 0x00, 0x2d, 0x09, 0xd0, 0x0c, 0x04, +0x24, 0x0c, 0xa2, 0x18, 0x09, 0x0c, 0x8a, 0x18, 0x02, 0xc8, 0x1c, 0x1c, +0x01, 0x3b, 0x00, 0x2c, 0xf5, 0xd1, 0xb9, 0x40, 0x08, 0x1c, 0xf8, 0x40, +0x01, 0x04, 0x09, 0x0c, 0x89, 0x18, 0x00, 0x0c, 0x42, 0x18, 0x10, 0x0c, +0x05, 0xd0, 0x10, 0x04, 0x00, 0x0c, 0x11, 0x0c, 0x42, 0x18, 0x10, 0x0c, +0xf9, 0xd1, 0x10, 0x04, 0x00, 0x0c, 0xb0, 0xbc, 0x70, 0x47, 0x00, 0x00, +0x90, 0xb4, 0x00, 0x20, 0x01, 0x27, 0x11, 0x49, 0x42, 0x00, 0x12, 0x18, +0xd2, 0x00, 0x53, 0x18, 0x9c, 0x68, 0x01, 0x23, +0x9b, 0x07, 0x23, 0x43, 0x1b, 0x68, 0x1b, 0x03, 0x1b, 0x0b, 0x8a, 0x58, +0x12, 0x03, 0x12, 0x0b, 0x93, 0x42, 0x0c, 0xd1, 0x01, 0x30, 0x04, 0x28, +0xec, 0xd3, 0x08, 0x48, 0xc0, 0x6a, 0x01, 0x03, 0x09, 0x0b, 0x07, 0x48, +0x00, 0x6f, 0x00, 0x03, 0x00, 0x0b, 0x81, 0x42, 0x02, 0xd0, 0x38, 0x1c, +0x90, 0xbc, 0x70, 0x47, 0x00, 0x20, 0xfb, 0xe7, 0xa8, 0x03, 0x00, 0x80, +0x00, 0x40, 0x14, 0x40, 0x68, 0x0e, 0x00, 0x80, 0x98, 0xb4, 0x14, 0x4a, +0xc0, 0x46, 0x00, 0x92, 0x83, 0x00, 0x13, 0x48, 0xc0, 0x58, 0x07, 0x03, +0x3f, 0x0b, 0x12, 0x48, 0xc0, 0x58, 0x02, 0x03, 0x12, 0x0b, 0x11, 0x48, +0xc0, 0x58, 0x00, 0x03, 0x00, 0x0b, 0x10, 0x4c, 0xe4, 0x58, 0x01, 0x23, +0x9b, 0x07, 0x23, 0x43, 0x1b, 0x68, 0x9b, 0x00, 0xcc, 0x00, 0x01, 0x21, +0x98, 0x42, 0x01, 0xd1, 0x08, 0x1c, 0x09, 0xe0, 0x98, 0x42, 0x03, 0xd9, +0x10, 0x1a, 0xda, 0x1b, 0x80, 0x18, 0x00, 0xe0, 0x18, 0x1a, 0x84, 0x42, +0xf4, 0xd3, 0x00, 0x20, 0x98, 0xbc, 0x70, 0x47, 0x55, 0x55, 0x55, 0x55, +0x20, 0x04, 0x00, 0x80, 0x28, 0x04, 0x00, 0x80, 0x08, 0x04, 0x00, 0x80, +0x18, 0x04, 0x00, 0x80, 0x80, 0xb4, 0x13, 0x04, 0x00, 0xd0, 0x01, 0x3a, +0x80, 0x00, 0x0b, 0x1c, 0x13, 0x49, 0x0f, 0x58, 0xc0, 0x46, 0x3b, 0x60, +0x0b, 0x58, 0xc0, 0x46, 0x5a, 0x60, 0x0a, 0x58, 0x08, 0x32, 0x10, 0x4b, +0x1b, 0x58, 0x9a, 0x42, 0x01, 0xd3, 0x0f, 0x4a, 0x12, 0x58, 0x0f, 0x4b, +0x1f, 0x58, 0x01, 0x23, 0x9b, 0x07, 0x3b, 0x43, 0x1b, 0x68, 0x9b, 0x00, +0x17, 0x03, 0x3f, 0x0b, 0x9f, 0x42, 0x06, 0xd1, 0x0a, 0x48, 0xc1, 0x68, +0x01, 0x31, 0xc1, 0x60, 0x01, 0x20, 0x80, 0xbc, 0x70, 0x47, 0x08, 0x4b, +0x1b, 0x58, 0xc0, 0x46, 0x1a, 0x60, 0x0a, 0x50, 0x00, 0x20, 0xf6, 0xe7, +0x08, 0x04, 0x00, 0x80, 0x28, 0x04, 0x00, 0x80, 0x20, 0x04, 0x00, 0x80, +0x18, 0x04, 0x00, 0x80, 0xa0, 0x82, 0x20, 0x40, 0x10, 0x04, 0x00, 0x80, +0xff, 0x5f, 0x2d, 0xe9, 0x48, 0xfe, 0xff, 0xeb, 0x01, 0xb6, 0xa0, 0xe3, +0x01, 0xb1, 0x8b, 0xe2, 0x02, 0x8a, 0xa0, 0xe3, 0x01, 0x7a, 0xa0, 0xe3, +0x01, 0xa9, 0xa0, 0xe3, 0x01, 0x56, 0xa0, 0xe3, 0xc8, 0x60, 0x9f, 0xe5, +0xc8, 0x90, 0x9f, 0xe5, 0x14, 0x40, 0x9b, 0xe5, 0x00, 0x00, 0x54, 0xe3, +0x2c, 0x00, 0x00, 0x0a, 0x03, 0x0a, 0x14, 0xe3, 0x11, 0x00, 0x00, 0x0a, +0x0c, 0x00, 0x96, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x21, 0x00, 0x00, 0x0a, +0x01, 0x0a, 0x14, 0xe3, 0x05, 0x00, 0x00, 0x0a, 0x1c, 0x00, 0x96, 0xe5, +0x01, 0x0a, 0xc0, 0xe3, 0x1c, 0x00, 0x86, 0xe5, 0x1c, 0x00, 0x85, 0xe5, +0x14, 0x70, 0x85, 0xe5, 0x06, 0x00, 0x00, 0xea, 0x02, 0x0a, 0x14, 0xe3, +0x04, 0x00, 0x00, 0x0a, 0x1c, 0x00, 0x96, 0xe5, 0x02, 0x0a, 0xc0, 0xe3, +0x1c, 0x00, 0x86, 0xe5, 0x1c, 0x00, 0x85, 0xe5, 0x14, 0x80, 0x85, 0xe5, +0x01, 0x09, 0x14, 0xe3, 0x04, 0x00, 0x00, 0x0a, 0x1c, 0x00, 0x96, 0xe5, +0x01, 0x09, 0xc0, 0xe3, 0x1c, 0x00, 0x86, 0xe5, 0x1c, 0x00, 0x85, 0xe5, +0x14, 0xa0, 0x85, 0xe5, 0x02, 0x00, 0x14, 0xe3, 0x40, 0x00, 0x00, 0x1b, +0x01, 0x00, 0x14, 0xe3, 0x54, 0x00, 0x00, 0x1b, 0x02, 0x0b, 0x14, 0xe3, +0x67, 0x00, 0x00, 0x1b, 0x01, 0x0b, 0x14, 0xe3, 0x20, 0x00, 0x00, 0x1b, +0x18, 0x00, 0x99, 0xe5, 0x01, 0x00, 0x80, 0xe2, 0x18, 0x00, 0x89, 0xe5, +0xd5, 0xff, 0xff, 0xea, 0x1c, 0x00, 0x96, 0xe5, 0x01, 0x0a, 0xc0, 0xe3, +0x1c, 0x00, 0x86, 0xe5, 0x1c, 0x00, 0x85, 0xe5, +0x14, 0x70, 0x85, 0xe5, 0xe1, 0xff, 0xff, 0xea, 0xff, 0x5f, 0xbd, 0xe8, +0x04, 0xf0, 0x5e, 0xe2, 0x68, 0x0e, 0x00, 0x80, 0x08, 0x83, 0x20, 0x40, +0x10, 0x10, 0x1f, 0xe5, 0x14, 0x30, 0x91, 0xe5, 0x00, 0x20, 0xc3, 0xe1, +0x14, 0x20, 0x81, 0xe5, 0x01, 0x16, 0xa0, 0xe3, 0x0c, 0x20, 0x81, 0xe5, +0x0b, 0x12, 0xa0, 0xe3, 0x00, 0x00, 0x81, 0xe5, 0x18, 0x10, 0x9f, 0xe5, +0xb0, 0x24, 0xd1, 0xe1, 0x01, 0x20, 0x82, 0xe2, 0xb0, 0x24, 0xc1, 0xe1, +0x3c, 0x20, 0x91, 0xe5, 0x00, 0x00, 0x82, 0xe1, 0x3c, 0x00, 0x81, 0xe5, +0x1e, 0xff, 0x2f, 0xe1, 0xa0, 0x82, 0x20, 0x40, 0xff, 0xff, 0xff, 0xea, +0xfe, 0xff, 0xff, 0xea, 0x01, 0x0b, 0xa0, 0xe3, 0x01, 0x16, 0xa0, 0xe3, +0x14, 0x00, 0x81, 0xe5, 0x00, 0x1a, 0x81, 0xe1, 0x24, 0x20, 0x91, 0xe5, +0x70, 0x00, 0x1f, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x24, 0x20, 0x80, 0xe5, +0x28, 0x10, 0x91, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x28, 0x10, 0x80, 0xe5, +0x2c, 0x20, 0x90, 0xe5, 0x01, 0x20, 0x82, 0xe2, 0x2c, 0x20, 0x80, 0xe5, +0x3f, 0x00, 0x01, 0xe2, 0x3f, 0x00, 0x50, 0xe3, 0x1e, 0xff, 0x2f, 0x11, +0x18, 0x00, 0x9f, 0xe5, 0x00, 0x10, 0x90, 0xe5, 0x01, 0x10, 0x81, 0xe2, +0x00, 0x10, 0x80, 0xe5, 0x02, 0x18, 0xa0, 0xe3, 0x0b, 0x02, 0xa0, 0xe3, +0x00, 0x10, 0x80, 0xe5, 0x1e, 0xff, 0x2f, 0xe1, 0x30, 0x04, 0x00, 0x80, +0x01, 0x06, 0xa0, 0xe3, 0x01, 0x01, 0x80, 0xe2, 0x00, 0x10, 0x90, 0xe5, +0x01, 0x08, 0x11, 0xe3, 0x0b, 0x10, 0xa0, 0xe3, 0x02, 0x19, 0x81, 0xe2, +0x05, 0x00, 0x00, 0x1a, 0x00, 0x20, 0x90, 0xe5, 0x42, 0x28, 0xb0, 0xe1, +0x05, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x90, 0xe5, 0x02, 0x0c, 0x10, 0xe3, +0x02, 0x00, 0x00, 0x0a, 0x06, 0x07, 0xa0, 0xe3, 0x4c, 0x11, 0x80, 0xe5, +0x03, 0x00, 0x00, 0xea, 0x0c, 0x00, 0x9f, 0xe5, 0x00, 0x00, 0x00, 0x00, +0x40, 0x10, 0x80, 0xe5, 0xff, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, +0x00, 0x00, 0x00, 0x80, 0x01, 0x06, 0xa0, 0xe3, 0x01, 0x01, 0x80, 0xe2, +0x00, 0x10, 0x90, 0xe5, 0x01, 0x08, 0x11, 0xe3, 0x0c, 0x10, 0xa0, 0xe3, +0x02, 0x19, 0x81, 0xe2, 0x05, 0x00, 0x00, 0x1a, 0x00, 0x20, 0x90, 0xe5, +0x42, 0x28, 0xb0, 0xe1, 0x05, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x90, 0xe5, +0x02, 0x0c, 0x10, 0xe3, 0x02, 0x00, 0x00, 0x0a, 0x06, 0x07, 0xa0, 0xe3, +0x4c, 0x11, 0x80, 0xe5, 0x03, 0x00, 0x00, 0xea, 0x4c, 0x00, 0x1f, 0xe5, +0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x80, 0xe5, 0xff, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x02, 0x1b, 0xa0, 0xe3, 0x01, 0x06, 0xa0, 0xe3, -0x14, 0x10, 0x80, 0xe5, 0x1e, 0xff, 0x2f, 0xe1, 0x04, 0x21, 0x1f, 0xe5, -0x10, 0x30, 0x92, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x80, 0xe5, -0x18, 0x00, 0x92, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xe5, -0x00, 0x10, 0xa0, 0xe3, 0x10, 0x10, 0x82, 0xe5, 0x01, 0x06, 0xa0, 0xe3, -0x18, 0x10, 0x82, 0xe5, 0x0c, 0x10, 0x80, 0xe5, 0x18, 0x10, 0x92, 0xe5, +0x14, 0x10, 0x80, 0xe5, 0x1e, 0xff, 0x2f, 0xe1, 0x80, 0x21, 0x1f, 0xe5, +0x14, 0x30, 0x92, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x80, 0xe5, +0x1c, 0x00, 0x92, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xe5, +0x00, 0x10, 0xa0, 0xe3, 0x14, 0x10, 0x82, 0xe5, 0x01, 0x06, 0xa0, 0xe3, +0x1c, 0x10, 0x82, 0xe5, 0x0c, 0x10, 0x80, 0xe5, 0x1c, 0x10, 0x92, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x10, 0x80, 0xe5, 0x1e, 0xff, 0x2f, 0xe1, -0x44, 0x21, 0x1f, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x18, 0x10, 0x82, 0xe5, -0x01, 0x16, 0xa0, 0xe3, 0x10, 0x00, 0x82, 0xe5, 0x0c, 0x00, 0x81, 0xe5, -0x18, 0x00, 0x92, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x81, 0xe5, +0xc0, 0x21, 0x1f, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x10, 0x82, 0xe5, +0x01, 0x16, 0xa0, 0xe3, 0x14, 0x00, 0x82, 0xe5, 0x0c, 0x00, 0x81, 0xe5, +0x1c, 0x00, 0x92, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x81, 0xe5, 0x1e, 0xff, 0x2f, 0xe1, 0x80, 0xb5, 0x0f, 0x1c, 0x38, 0x1c, 0x00, 0xf0, -0x17, 0xf8, 0x00, 0x28, 0x02, 0xd0, 0x38, 0x1c, 0x00, 0xf0, 0x76, 0xf8, -0x00, 0x20, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x80, 0xb5, 0x0f, 0x1c, -0x38, 0x1c, 0x00, 0xf0, 0x09, 0xf8, 0x00, 0x28, 0x02, 0xd0, 0x38, 0x1c, -0x00, 0xf0, 0x68, 0xf8, 0x00, 0x20, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, -0xf0, 0xb4, 0x07, 0x68, 0x3a, 0x78, 0xd2, 0x07, 0xd2, 0x0f, 0x00, 0x24, -0x00, 0x2a, 0x03, 0xd0, 0xff, 0x22, 0x01, 0x32, +0x17, 0xf8, 0x00, 0x28, 0x02, 0xd0, 0x38, 0x1c, +0x00, 0xf0, 0x92, 0xf8, 0x00, 0x20, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, +0x80, 0xb5, 0x0f, 0x1c, 0x38, 0x1c, 0x00, 0xf0, 0x09, 0xf8, 0x00, 0x28, +0x02, 0xd0, 0x38, 0x1c, 0x00, 0xf0, 0x84, 0xf8, 0x00, 0x20, 0x80, 0xbc, +0x08, 0xbc, 0x18, 0x47, 0xf0, 0xb4, 0x07, 0x68, 0x3a, 0x78, 0xd2, 0x07, +0xd2, 0x0f, 0x00, 0x24, 0x00, 0x2a, 0x03, 0xd0, 0xff, 0x22, 0x01, 0x32, 0x42, 0x60, 0x00, 0xe0, 0x44, 0x60, 0x3a, 0x7b, 0x7b, 0x7b, 0x1b, 0x02, 0x1a, 0x43, 0x81, 0x2a, 0x08, 0xd1, 0x01, 0x23, 0x5b, 0x02, 0x42, 0x68, 0x1a, 0x43, 0x42, 0x60, 0x04, 0x22, 0xbf, 0x18, 0x82, 0x60, 0x00, 0xe0, 0x84, 0x60, 0x3a, 0x7b, 0x7b, 0x7b, 0x1b, 0x02, 0x1a, 0x43, 0x08, 0x2a, 0x06, 0xd1, 0x06, 0x23, 0x41, 0x68, 0x19, 0x43, 0x41, 0x60, 0x81, 0x68, -0x0e, 0x31, 0x2c, 0xe0, 0x13, 0x02, 0x12, 0x0a, 0x12, 0x06, 0x12, 0x0e, -0x1a, 0x43, 0x12, 0x04, 0x12, 0x0c, 0x2e, 0x3a, 0x16, 0x4b, 0x9a, 0x42, -0x24, 0xd8, 0x01, 0x25, 0x42, 0x68, 0x15, 0x43, 0x45, 0x60, 0xba, 0x7b, -0xfb, 0x7b, 0x1b, 0x02, 0x1a, 0x43, 0x12, 0x4b, 0x9a, 0x42, 0x19, 0xd1, -0xfb, 0x1d, 0x09, 0x33, 0x44, 0xcb, 0x9b, 0x07, 0xdb, 0x0e, 0xda, 0x40, -0x5b, 0x42, 0x20, 0x33, 0x9e, 0x40, 0x16, 0x43, 0x03, 0x2e, 0x0f, 0xd1, -0x39, 0x7d, 0x7b, 0x7d, 0x1b, 0x02, 0x19, 0x43, 0x08, 0x29, 0x07, 0xd1, -0x04, 0x21, 0x29, 0x43, 0x41, 0x60, 0x81, 0x68, 0x16, 0x31, 0x81, 0x60, -0x01, 0x21, 0x01, 0xe0, 0x00, 0x21, 0x84, 0x60, 0x08, 0x1c, 0xf0, 0xbc, -0x70, 0x47, 0x00, 0x00, 0xae, 0x05, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, -0x80, 0xb4, 0x42, 0x68, 0xd1, 0x08, 0x3f, 0xd3, 0x01, 0x68, 0x83, 0x68, -0x59, 0x18, 0x02, 0x39, 0x8f, 0x78, 0xff, 0x06, 0xff, 0x0e, 0x05, 0x2f, -0x03, 0xd1, 0xda, 0x1d, 0x0d, 0x32, 0xc2, 0x60, 0x05, 0xe0, 0xbf, 0x00, -0xdb, 0x19, 0xc3, 0x60, 0x08, 0x23, 0x1a, 0x43, 0x42, 0x60, 0x8a, 0x78, -0xd2, 0x06, 0xd2, 0x0e, 0x92, 0x00, 0x02, 0x61, 0x0a, 0x79, 0x4b, 0x79, -0x1b, 0x02, 0x1a, 0x43, 0x13, 0x02, 0x12, 0x0a, 0x12, 0x06, 0x12, 0x0e, -0x1a, 0x43, 0x12, 0x04, 0x12, 0x0c, 0x42, 0x61, 0xca, 0x7a, 0x06, 0x2a, -0x03, 0xd1, 0x10, 0x23, 0x42, 0x68, 0x1a, 0x43, 0x10, 0xe0, 0x11, 0x2a, -0x03, 0xd1, 0x20, 0x23, 0x42, 0x68, 0x1a, 0x43, 0x0a, 0xe0, 0x33, 0x2a, -0x03, 0xd1, 0x40, 0x23, 0x42, 0x68, 0x1a, 0x43, 0x04, 0xe0, 0x32, 0x2a, -0x03, 0xd1, 0x80, 0x23, 0x42, 0x68, 0x1a, 0x43, 0x42, 0x60, 0xc9, 0x7a, -0xc0, 0x46, 0x01, 0x76, 0x80, 0xbc, 0x70, 0x47, 0x0a, 0x78, 0xc0, 0x46, -0x02, 0x60, 0x4b, 0x78, 0x1b, 0x02, 0x1a, 0x43, 0x02, 0x60, 0x8b, 0x78, -0x1b, 0x04, 0x1a, 0x43, 0x02, 0x60, 0xc9, 0x78, 0x09, 0x06, 0x11, 0x43, -0x01, 0x60, 0x70, 0x47, 0xf0, 0xb5, 0x00, 0x21, 0x00, 0x24, 0x00, 0x27, -0x80, 0x6a, 0x02, 0x7b, 0x43, 0x7b, 0x1b, 0x02, 0x1a, 0x43, 0x81, 0x2a, -0x00, 0xd1, 0x04, 0x30, 0x02, 0x7b, 0x43, 0x7b, 0x1b, 0x02, 0x1a, 0x43, -0x08, 0x2a, 0x01, 0xd1, 0x0e, 0x30, 0x24, 0xe0, 0x13, 0x02, 0x12, 0x0a, -0x12, 0x06, 0x12, 0x0e, 0x1a, 0x43, 0x12, 0x04, 0x12, 0x0c, 0x2e, 0x3a, -0x42, 0x4b, 0x9a, 0x42, 0x74, 0xd8, 0x82, 0x7b, 0xc3, 0x7b, 0x1b, 0x02, -0x1a, 0x43, 0x40, 0x4b, 0x9a, 0x42, 0x6e, 0xd1, 0xc3, 0x1d, 0x09, 0x33, -0x24, 0xcb, 0x9b, 0x07, 0xdb, 0x0e, 0xda, 0x40, 0x5b, 0x42, 0x20, 0x33, -0x9d, 0x40, 0x15, 0x43, 0x03, 0x2d, 0x63, 0xd1, 0x02, 0x7d, 0x43, 0x7d, -0x1b, 0x02, 0x1a, 0x43, 0x08, 0x2a, 0x5c, 0xd1, 0x16, 0x30, 0x42, 0x7a, -0x11, 0x2a, 0x58, 0xd1, 0x02, 0x78, 0xd2, 0x06, 0xd2, 0x0e, 0x92, 0x00, -0x10, 0x18, 0x02, 0x78, 0x43, 0x78, 0x1b, 0x02, 0x1a, 0x43, 0x43, 0x23, -0x1b, 0x02, 0x9a, 0x42, 0x4b, 0xd1, 0xc3, 0x1d, 0x01, 0x33, 0xd8, 0x1d, -0xe9, 0x30, 0x02, 0x78, 0x35, 0x2a, 0x04, 0xd1, -0x82, 0x78, 0x05, 0x2a, 0x19, 0xd1, 0x01, 0x21, 0x0d, 0xe0, 0x01, 0x2a, -0x01, 0xd1, 0x87, 0x1c, 0x09, 0xe0, 0x03, 0x2a, 0x01, 0xd1, 0x84, 0x1c, -0x05, 0xe0, 0xff, 0x2a, 0x0d, 0xd0, 0x00, 0x2a, 0x01, 0xd1, 0x01, 0x30, -0x02, 0xe0, 0x42, 0x78, 0x10, 0x18, 0x02, 0x30, 0x00, 0x2f, 0xe4, 0xd0, -0x00, 0x2c, 0xe2, 0xd0, 0x00, 0x29, 0xe0, 0xd0, 0x01, 0xe0, 0x00, 0x29, -0x2e, 0xd0, 0xd9, 0x1d, 0x09, 0x31, 0x0e, 0x1c, 0x19, 0x4d, 0xe3, 0x23, -0x1b, 0x01, 0xe8, 0x18, 0xff, 0xf7, 0x78, 0xff, 0x00, 0x2f, 0x04, 0xd0, -0x16, 0x4b, 0xe8, 0x18, 0x39, 0x1c, 0xff, 0xf7, 0x71, 0xff, 0x00, 0x2c, -0x04, 0xd0, 0x14, 0x4b, 0xe8, 0x18, 0x21, 0x1c, 0xff, 0xf7, 0x6a, 0xff, -0x31, 0x1c, 0x12, 0x4d, 0xe8, 0x1d, 0x11, 0x30, 0xff, 0xf7, 0x64, 0xff, -0x00, 0x2f, 0x08, 0xd0, 0xe8, 0x1d, 0x0d, 0x30, 0x39, 0x1c, 0xff, 0xf7, -0x5d, 0xff, 0x02, 0xe0, 0x08, 0xe0, 0x07, 0xe0, 0x06, 0xe0, 0x00, 0x2c, -0x04, 0xd0, 0xe8, 0x1d, 0x09, 0x30, 0x21, 0x1c, 0xff, 0xf7, 0x52, 0xff, -0xf0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x00, 0xae, 0x05, 0x00, 0x00, -0xaa, 0xaa, 0x00, 0x00, 0xf8, 0x0d, 0x00, 0x80, 0x34, 0x0e, 0x00, 0x00, -0x38, 0x0e, 0x00, 0x00, 0x98, 0x6e, 0x21, 0x40, 0x80, 0xb5, 0x07, 0x1c, -0x48, 0x68, 0x80, 0x09, 0x26, 0xd3, 0xb8, 0x6a, 0xc9, 0x68, 0x40, 0x18, -0x01, 0x23, 0x9b, 0x07, 0x02, 0x30, 0x18, 0x43, 0x00, 0x68, 0x00, 0x04, -0x00, 0x0c, 0x11, 0x23, 0x9b, 0x02, 0x98, 0x42, 0x18, 0xd1, 0x78, 0x6a, -0x39, 0x6b, 0xc0, 0x46, 0x48, 0x62, 0x38, 0x6b, 0x02, 0xf0, 0x26, 0xfc, -0x38, 0x1c, 0x02, 0xf0, 0xdc, 0xf8, 0x01, 0x20, 0x07, 0x49, 0xc0, 0x46, -0xc8, 0x70, 0x07, 0x49, 0x4a, 0x6c, 0x12, 0x18, 0x4a, 0x64, 0x06, 0x49, -0x8a, 0x6d, 0x12, 0x18, 0x8a, 0x65, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, -0x00, 0x20, 0xfa, 0xe7, 0xa8, 0x19, 0x00, 0x80, 0x94, 0x2c, 0x00, 0x80, -0x2c, 0x2c, 0x00, 0x80, 0x81, 0x07, 0x19, 0xd0, 0x80, 0x08, 0x80, 0x00, -0x01, 0x23, 0x9b, 0x07, 0x01, 0x1d, 0x18, 0x43, 0x00, 0x68, 0x19, 0x43, -0x09, 0x68, 0x02, 0x02, 0x12, 0x0e, 0x12, 0x06, 0x00, 0x0a, 0xff, 0x23, -0x1b, 0x04, 0x18, 0x40, 0x10, 0x43, 0x0a, 0x0a, 0x12, 0x06, 0x12, 0x0e, -0x10, 0x43, 0x09, 0x02, 0x1b, 0x0a, 0x19, 0x40, 0x08, 0x43, 0x70, 0x47, -0x01, 0x23, 0x9b, 0x07, 0x18, 0x43, 0x00, 0x68, 0x01, 0x06, 0x02, 0x02, -0xff, 0x23, 0x1b, 0x04, 0x1a, 0x40, 0x11, 0x43, 0x02, 0x0a, 0x1b, 0x0a, -0x1a, 0x40, 0x11, 0x43, 0x00, 0x0e, 0x08, 0x43, 0xed, 0xe7, 0x00, 0x00, -0xf0, 0xb5, 0x04, 0x23, 0x81, 0x6b, 0x19, 0x40, 0x00, 0x22, 0x00, 0x29, -0x46, 0xd0, 0xc7, 0x1d, 0x39, 0x37, 0x39, 0x7b, 0x33, 0x29, 0x01, 0xd0, -0x32, 0x29, 0x3f, 0xd1, 0x01, 0x6b, 0xc0, 0x46, 0x4a, 0x65, 0xc4, 0x1d, -0x2d, 0x34, 0xcd, 0x1d, 0x2d, 0x35, 0x00, 0x22, 0x93, 0x00, 0xe6, 0x58, -0xc0, 0x46, 0xee, 0x50, 0x01, 0x32, 0x07, 0x2a, 0xf8, 0xd3, 0x82, 0x6a, -0xc0, 0x46, 0x4a, 0x63, 0x82, 0x6a, 0xc0, 0x46, 0x8a, 0x62, 0x7a, 0x8b, -0xcb, 0x1d, 0x39, 0x33, 0x5a, 0x83, 0x40, 0x6a, 0xc0, 0x46, 0x48, 0x62, -0x12, 0x48, 0x01, 0x27, 0x42, 0x68, 0x00, 0x2a, 0x10, 0xd1, 0xc2, 0x68, -0x00, 0x2a, 0x13, 0xd1, 0x42, 0x69, 0x00, 0x2a, 0x0d, 0xd1, 0x01, 0x61, -0xc1, 0x60, 0x01, 0x6a, 0x02, 0x29, 0x02, 0xd3, 0x20, 0x30, 0x07, 0x71, -0x0c, 0xe0, 0x00, 0xf0, 0x13, 0xf8, 0x09, 0xe0, -0xc2, 0x68, 0x00, 0x2a, 0x02, 0xd1, 0x01, 0x61, 0xc1, 0x60, 0x03, 0xe0, -0x02, 0x69, 0xc0, 0x46, 0x51, 0x65, 0x01, 0x61, 0x38, 0x1c, 0xf0, 0xbc, -0x08, 0xbc, 0x18, 0x47, 0x10, 0x1c, 0xfa, 0xe7, 0xfc, 0x05, 0x00, 0x80, -0x90, 0xb5, 0x1e, 0x49, 0x00, 0x27, 0xca, 0x68, 0x00, 0x2a, 0x35, 0xd0, -0xc8, 0x1d, 0xf9, 0x30, 0x82, 0x62, 0xca, 0x68, 0x92, 0x6a, 0xc0, 0x46, -0xc2, 0x62, 0xca, 0x69, 0x53, 0x00, 0x9b, 0x18, 0x5b, 0x02, 0x17, 0x4a, -0x9c, 0x18, 0x17, 0x4b, 0xe3, 0x18, 0x82, 0x63, 0x03, 0x63, 0xcb, 0x1d, -0xff, 0x33, 0x5a, 0x33, 0x1f, 0x72, 0x3a, 0x1c, 0xcb, 0x69, 0x00, 0x2b, -0x01, 0xd0, 0xca, 0x61, 0x01, 0xe0, 0x01, 0x23, 0xcb, 0x61, 0x0f, 0x1c, -0xc9, 0x68, 0x49, 0x6a, 0x09, 0x89, 0x01, 0x31, 0x41, 0x63, 0xf8, 0x1d, -0xff, 0x30, 0x3a, 0x30, 0x42, 0x60, 0x02, 0x82, 0x82, 0x60, 0xc2, 0x60, -0x38, 0x1c, 0x00, 0xf0, 0xcb, 0xfa, 0x38, 0x6a, 0x01, 0x30, 0x38, 0x62, -0x38, 0x1c, 0x00, 0xf0, 0x0b, 0xf8, 0x90, 0xbc, 0x08, 0xbc, 0x18, 0x47, -0x38, 0x1c, 0xfa, 0xe7, 0xfc, 0x05, 0x00, 0x80, 0x48, 0xad, 0x20, 0x40, -0x64, 0x07, 0x00, 0x00, 0xf0, 0xb5, 0x07, 0x1c, 0xf9, 0x1d, 0xf9, 0x31, +0x0e, 0x31, 0x3c, 0xe0, 0xc1, 0x23, 0xdb, 0x00, 0x9a, 0x42, 0x03, 0xd1, +0x41, 0x68, 0x24, 0x4b, 0x19, 0x43, 0x3e, 0xe0, 0x23, 0x4b, 0x9a, 0x42, +0x04, 0xd1, 0x01, 0x23, 0x1b, 0x03, 0x41, 0x68, 0x19, 0x43, 0x36, 0xe0, +0x13, 0x02, 0x12, 0x0a, 0x12, 0x06, 0x12, 0x0e, 0x1a, 0x43, 0x12, 0x04, +0x12, 0x0c, 0x2e, 0x3a, 0x1c, 0x4b, 0x9a, 0x42, 0x2d, 0xd8, 0x01, 0x25, +0x42, 0x68, 0x15, 0x43, 0x45, 0x60, 0xba, 0x7b, 0xfb, 0x7b, 0x1b, 0x02, +0x1a, 0x43, 0x18, 0x4b, 0x9a, 0x42, 0x22, 0xd1, 0xfb, 0x1d, 0x09, 0x33, +0x44, 0xcb, 0x9b, 0x07, 0xdb, 0x0e, 0xda, 0x40, 0x5b, 0x42, 0x20, 0x33, +0x9e, 0x40, 0x16, 0x43, 0x03, 0x2e, 0x18, 0xd1, 0x39, 0x7d, 0x7b, 0x7d, +0x1b, 0x02, 0x19, 0x43, 0x08, 0x29, 0x07, 0xd1, 0x04, 0x21, 0x29, 0x43, +0x41, 0x60, 0x81, 0x68, 0x16, 0x31, 0x81, 0x60, 0x01, 0x21, 0x0a, 0xe0, +0xc1, 0x23, 0xdb, 0x00, 0x99, 0x42, 0x04, 0xd1, 0x01, 0x21, 0x89, 0x03, +0x29, 0x43, 0x41, 0x60, 0x00, 0xe0, 0x84, 0x60, 0x00, 0x21, 0x08, 0x1c, +0xf0, 0xbc, 0x70, 0x47, 0x02, 0x40, 0x00, 0x00, 0x81, 0x80, 0x00, 0x00, +0xae, 0x05, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x80, 0xb4, 0x42, 0x68, +0xd1, 0x08, 0x3f, 0xd3, 0x01, 0x68, 0x83, 0x68, 0x59, 0x18, 0x02, 0x39, +0x8f, 0x78, 0x3f, 0x07, 0x3f, 0x0f, 0x05, 0x2f, 0x03, 0xd1, 0xda, 0x1d, +0x0d, 0x32, 0xc2, 0x60, 0x05, 0xe0, 0xbf, 0x00, 0xdb, 0x19, 0xc3, 0x60, +0x08, 0x23, 0x1a, 0x43, 0x42, 0x60, 0x8a, 0x78, 0x12, 0x07, 0x12, 0x0f, +0x92, 0x00, 0x02, 0x61, 0x0a, 0x79, 0x4b, 0x79, 0x1b, 0x02, 0x1a, 0x43, +0x13, 0x02, 0x12, 0x0a, 0x12, 0x06, 0x12, 0x0e, 0x1a, 0x43, 0x12, 0x04, +0x12, 0x0c, 0x42, 0x61, 0xca, 0x7a, 0x06, 0x2a, 0x03, 0xd1, 0x10, 0x23, +0x42, 0x68, 0x1a, 0x43, 0x10, 0xe0, 0x11, 0x2a, 0x03, 0xd1, 0x20, 0x23, +0x42, 0x68, 0x1a, 0x43, 0x0a, 0xe0, 0x33, 0x2a, 0x03, 0xd1, 0x40, 0x23, +0x42, 0x68, 0x1a, 0x43, 0x04, 0xe0, 0x32, 0x2a, 0x03, 0xd1, 0x80, 0x23, +0x42, 0x68, 0x1a, 0x43, 0x42, 0x60, 0xc9, 0x7a, 0xc0, 0x46, 0x01, 0x76, +0x80, 0xbc, 0x70, 0x47, 0x0a, 0x78, 0xc0, 0x46, 0x02, 0x60, 0x4b, 0x78, +0x1b, 0x02, 0x1a, 0x43, 0x02, 0x60, 0x8b, 0x78, 0x1b, 0x04, 0x1a, 0x43, +0x02, 0x60, 0xc9, 0x78, 0x09, 0x06, 0x11, 0x43, 0x01, 0x60, 0x70, 0x47, +0x80, 0xb5, 0x07, 0x1c, 0x48, 0x68, 0x80, 0x09, 0x26, 0xd3, 0xb8, 0x6a, +0xc9, 0x68, 0x40, 0x18, 0x01, 0x23, 0x9b, 0x07, 0x02, 0x30, 0x18, 0x43, +0x00, 0x68, 0x00, 0x04, 0x00, 0x0c, 0x11, 0x23, 0x9b, 0x02, 0x98, 0x42, +0x18, 0xd1, 0x78, 0x6a, 0x39, 0x6b, 0xc0, 0x46, +0x48, 0x62, 0x38, 0x6b, 0x02, 0xf0, 0xd0, 0xf8, 0x38, 0x1c, 0x01, 0xf0, +0x8b, 0xfd, 0x01, 0x20, 0x07, 0x49, 0xc0, 0x46, 0xc8, 0x73, 0x07, 0x49, +0x4a, 0x6c, 0x12, 0x18, 0x4a, 0x64, 0x06, 0x49, 0x8a, 0x6d, 0x12, 0x18, +0x8a, 0x65, 0x80, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x00, 0x20, 0xfa, 0xe7, +0x18, 0x1a, 0x00, 0x80, 0x0c, 0x2b, 0x00, 0x80, 0xa4, 0x2a, 0x00, 0x80, +0x81, 0x07, 0x19, 0xd0, 0x80, 0x08, 0x80, 0x00, 0x01, 0x23, 0x9b, 0x07, +0x01, 0x1d, 0x18, 0x43, 0x00, 0x68, 0x19, 0x43, 0x09, 0x68, 0x02, 0x02, +0x12, 0x0e, 0x12, 0x06, 0x00, 0x0a, 0xff, 0x23, 0x1b, 0x04, 0x18, 0x40, +0x10, 0x43, 0x0a, 0x0a, 0x12, 0x06, 0x12, 0x0e, 0x10, 0x43, 0x09, 0x02, +0x1b, 0x0a, 0x19, 0x40, 0x08, 0x43, 0x70, 0x47, 0x01, 0x23, 0x9b, 0x07, +0x18, 0x43, 0x00, 0x68, 0x01, 0x06, 0x02, 0x02, 0xff, 0x23, 0x1b, 0x04, +0x1a, 0x40, 0x11, 0x43, 0x02, 0x0a, 0x1b, 0x0a, 0x1a, 0x40, 0x11, 0x43, +0x00, 0x0e, 0x08, 0x43, 0xed, 0xe7, 0x00, 0x00, 0xf0, 0xb5, 0x04, 0x23, +0x81, 0x6b, 0x19, 0x40, 0x00, 0x22, 0x00, 0x29, 0x46, 0xd0, 0xc7, 0x1d, +0x39, 0x37, 0x39, 0x7b, 0x33, 0x29, 0x01, 0xd0, 0x32, 0x29, 0x3f, 0xd1, +0x01, 0x6b, 0xc0, 0x46, 0x4a, 0x65, 0xc4, 0x1d, 0x2d, 0x34, 0xcd, 0x1d, +0x2d, 0x35, 0x00, 0x22, 0x93, 0x00, 0xe6, 0x58, 0xc0, 0x46, 0xee, 0x50, +0x01, 0x32, 0x07, 0x2a, 0xf8, 0xd3, 0x82, 0x6a, 0xc0, 0x46, 0x4a, 0x63, +0x82, 0x6a, 0xc0, 0x46, 0x8a, 0x62, 0x7a, 0x8b, 0xcb, 0x1d, 0x39, 0x33, +0x5a, 0x83, 0x40, 0x6a, 0xc0, 0x46, 0x48, 0x62, 0x12, 0x48, 0x01, 0x27, +0x42, 0x68, 0x00, 0x2a, 0x10, 0xd1, 0xc2, 0x68, 0x00, 0x2a, 0x13, 0xd1, +0x42, 0x69, 0x00, 0x2a, 0x0d, 0xd1, 0x01, 0x61, 0xc1, 0x60, 0x01, 0x6a, +0x02, 0x29, 0x02, 0xd3, 0x20, 0x30, 0x07, 0x71, 0x0c, 0xe0, 0x00, 0xf0, +0x13, 0xf8, 0x09, 0xe0, 0xc2, 0x68, 0x00, 0x2a, 0x02, 0xd1, 0x01, 0x61, +0xc1, 0x60, 0x03, 0xe0, 0x02, 0x69, 0xc0, 0x46, 0x51, 0x65, 0x01, 0x61, +0x38, 0x1c, 0xf0, 0xbc, 0x08, 0xbc, 0x18, 0x47, 0x10, 0x1c, 0xfa, 0xe7, +0x6c, 0x06, 0x00, 0x80, 0x80, 0xb5, 0x1e, 0x49, 0x00, 0x22, 0xcb, 0x68, +0x00, 0x2b, 0x34, 0xd0, 0xc8, 0x1d, 0xf9, 0x30, 0x83, 0x62, 0xcb, 0x68, +0x9b, 0x6a, 0xc0, 0x46, 0xc3, 0x62, 0xcf, 0x69, 0x7b, 0x00, 0xdf, 0x19, +0x7f, 0x02, 0x17, 0x4b, 0xff, 0x18, 0xff, 0x37, 0x65, 0x37, 0x83, 0x63, +0x07, 0x63, 0xcb, 0x1d, 0xff, 0x33, 0x5a, 0x33, 0x1a, 0x72, 0xcb, 0x69, +0x00, 0x2b, 0x01, 0xd0, 0xca, 0x61, 0x01, 0xe0, 0x01, 0x23, 0xcb, 0x61, +0x0f, 0x1c, 0xc9, 0x68, 0x49, 0x6a, 0x09, 0x89, 0x01, 0x31, 0x41, 0x63, +0xf8, 0x1d, 0xff, 0x30, 0x3a, 0x30, 0x42, 0x60, 0x02, 0x82, 0x82, 0x60, +0xc2, 0x60, 0x38, 0x1c, 0x00, 0xf0, 0xce, 0xfa, 0x38, 0x6a, 0x01, 0x30, +0x38, 0x62, 0x38, 0x1c, 0x00, 0xf0, 0x0a, 0xf8, 0x80, 0xbc, 0x08, 0xbc, +0x18, 0x47, 0x10, 0x1c, 0xfa, 0xe7, 0x00, 0x00, 0x6c, 0x06, 0x00, 0x80, +0x1c, 0xad, 0x20, 0x40, 0xf0, 0xb5, 0x07, 0x1c, 0xf9, 0x1d, 0xf9, 0x31, 0x88, 0x6a, 0xc2, 0x1d, 0x2d, 0x32, 0x01, 0x23, 0x9b, 0x07, 0x08, 0x32, 0x1a, 0x43, 0xc8, 0x6a, 0x12, 0x68, 0x12, 0x04, 0x12, 0x0c, 0x80, 0x18, 0x82, 0x79, 0xc3, 0x79, 0x1b, 0x02, 0x1a, 0x43, 0x13, 0x02, 0x12, 0x0a, 0x12, 0x06, 0x12, 0x0e, 0x1a, 0x43, 0x12, 0x04, 0x12, 0x0c, 0x02, 0x38, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From yongari at FreeBSD.org Wed Mar 18 19:13:17 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Wed Mar 18 19:13:23 2009 Subject: svn commit: r190013 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/msk Message-ID: <200903190213.n2J2DFKv044983@svn.freebsd.org> Author: yongari Date: Thu Mar 19 02:13:14 2009 New Revision: 190013 URL: http://svn.freebsd.org/changeset/base/190013 Log: MFC r187325: Add hardware MAC statistics support. Also added some reserved statistics register definition. Users can get current MAC statistics from dev.msk.%d.stats sysctl node(%d is unit number of a device). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/msk/if_msk.c stable/7/sys/dev/msk/if_mskreg.h Modified: stable/7/sys/dev/msk/if_msk.c ============================================================================== --- stable/7/sys/dev/msk/if_msk.c Thu Mar 19 01:43:03 2009 (r190012) +++ stable/7/sys/dev/msk/if_msk.c Thu Mar 19 02:13:14 2009 (r190013) @@ -291,6 +291,11 @@ static void msk_setmulti(struct msk_if_s static void msk_setvlan(struct msk_if_softc *, struct ifnet *); static void msk_setpromisc(struct msk_if_softc *); +static void msk_stats_clear(struct msk_if_softc *); +static void msk_stats_update(struct msk_if_softc *); +static int msk_sysctl_stat32(SYSCTL_HANDLER_ARGS); +static int msk_sysctl_stat64(SYSCTL_HANDLER_ARGS); +static void msk_sysctl_node(struct msk_if_softc *); static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int); static int sysctl_hw_msk_proc_limit(SYSCTL_HANDLER_ARGS); @@ -1435,6 +1440,7 @@ msk_attach(device_t dev) callout_init_mtx(&sc_if->msk_tick_ch, &sc_if->msk_softc->msk_mtx, 0); TASK_INIT(&sc_if->msk_link_task, 0, msk_link_task, sc_if); + msk_sysctl_node(sc_if); /* Disable jumbo frame for Yukon FE. */ if (sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_FE) @@ -3544,15 +3550,8 @@ msk_init_locked(struct msk_if_softc *sc_ /* Dummy read the Interrupt Source Register. */ CSR_READ_1(sc, MR_ADDR(sc_if->msk_port, GMAC_IRQ_SRC)); - /* Set MIB Clear Counter Mode. */ - gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_PHY_ADDR); - GMAC_WRITE_2(sc, sc_if->msk_port, GM_PHY_ADDR, gmac | GM_PAR_MIB_CLR); - /* Read all MIB Counters with Clear Mode set. */ - for (i = 0; i < GM_MIB_CNT_SIZE; i++) - GMAC_READ_2(sc, sc_if->msk_port, GM_MIB_CNT_BASE + 8 * i); - /* Clear MIB Clear Counter Mode. */ - gmac &= ~GM_PAR_MIB_CLR; - GMAC_WRITE_2(sc, sc_if->msk_port, GM_PHY_ADDR, gmac); + /* Clear MIB stats. */ + msk_stats_clear(sc_if); /* Disable FCS. */ GMAC_WRITE_2(sc, sc_if->msk_port, GM_RX_CTRL, GM_RXCR_CRC_DIS); @@ -3838,6 +3837,8 @@ msk_stop(struct msk_if_softc *sc_if) GMAC_WRITE_2(sc, sc_if->msk_port, GM_GP_CTRL, val); /* Read again to ensure writing. */ GMAC_READ_2(sc, sc_if->msk_port, GM_GP_CTRL); + /* Update stats and clear counters. */ + msk_stats_update(sc_if); /* Stop Tx BMU. */ CSR_WRITE_4(sc, Q_ADDR(sc_if->msk_txq, Q_CSR), BMU_STOP); @@ -3953,6 +3954,295 @@ msk_stop(struct msk_if_softc *sc_if) sc_if->msk_link = 0; } +/* + * When GM_PAR_MIB_CLR bit of GM_PHY_ADDR is set, reading lower + * counter clears high 16 bits of the counter such that accessing + * lower 16 bits should be the last operation. + */ +#define MSK_READ_MIB32(x, y) \ + (((uint32_t)GMAC_READ_2(sc, x, (y) + 4)) << 16) + \ + (uint32_t)GMAC_READ_2(sc, x, y) +#define MSK_READ_MIB64(x, y) \ + (((uint64_t)MSK_READ_MIB32(x, (y) + 8)) << 32) + \ + (uint64_t)MSK_READ_MIB32(x, y) + +static void +msk_stats_clear(struct msk_if_softc *sc_if) +{ + struct msk_softc *sc; + uint32_t reg; + uint16_t gmac; + int i; + + MSK_IF_LOCK_ASSERT(sc_if); + + sc = sc_if->msk_softc; + /* Set MIB Clear Counter Mode. */ + gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_PHY_ADDR); + GMAC_WRITE_2(sc, sc_if->msk_port, GM_PHY_ADDR, gmac | GM_PAR_MIB_CLR); + /* Read all MIB Counters with Clear Mode set. */ + for (i = GM_RXF_UC_OK; i <= GM_TXE_FIFO_UR; i++) + reg = MSK_READ_MIB32(sc_if->msk_port, i); + /* Clear MIB Clear Counter Mode. */ + gmac &= ~GM_PAR_MIB_CLR; + GMAC_WRITE_2(sc, sc_if->msk_port, GM_PHY_ADDR, gmac); +} + +static void +msk_stats_update(struct msk_if_softc *sc_if) +{ + struct msk_softc *sc; + struct ifnet *ifp; + struct msk_hw_stats *stats; + uint16_t gmac; + uint32_t reg; + + MSK_IF_LOCK_ASSERT(sc_if); + + ifp = sc_if->msk_ifp; + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + return; + sc = sc_if->msk_softc; + stats = &sc_if->msk_stats; + /* Set MIB Clear Counter Mode. */ + gmac = GMAC_READ_2(sc, sc_if->msk_port, GM_PHY_ADDR); + GMAC_WRITE_2(sc, sc_if->msk_port, GM_PHY_ADDR, gmac | GM_PAR_MIB_CLR); + + /* Rx stats. */ + stats->rx_ucast_frames += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_UC_OK); + stats->rx_bcast_frames += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_BC_OK); + stats->rx_pause_frames += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_MPAUSE); + stats->rx_mcast_frames += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_MC_OK); + stats->rx_crc_errs += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_FCS_ERR); + reg = MSK_READ_MIB32(sc_if->msk_port, GM_RXF_SPARE1); + stats->rx_good_octets += + MSK_READ_MIB64(sc_if->msk_port, GM_RXO_OK_LO); + stats->rx_bad_octets += + MSK_READ_MIB64(sc_if->msk_port, GM_RXO_ERR_LO); + stats->rx_runts += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_SHT); + stats->rx_runt_errs += + MSK_READ_MIB32(sc_if->msk_port, GM_RXE_FRAG); + stats->rx_pkts_64 += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_64B); + stats->rx_pkts_65_127 += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_127B); + stats->rx_pkts_128_255 += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_255B); + stats->rx_pkts_256_511 += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_511B); + stats->rx_pkts_512_1023 += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_1023B); + stats->rx_pkts_1024_1518 += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_1518B); + stats->rx_pkts_1519_max += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_MAX_SZ); + stats->rx_pkts_too_long += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_LNG_ERR); + stats->rx_pkts_jabbers += + MSK_READ_MIB32(sc_if->msk_port, GM_RXF_JAB_PKT); + reg = MSK_READ_MIB32(sc_if->msk_port, GM_RXF_SPARE2); + stats->rx_fifo_oflows += + MSK_READ_MIB32(sc_if->msk_port, GM_RXE_FIFO_OV); + reg = MSK_READ_MIB32(sc_if->msk_port, GM_RXF_SPARE3); + + /* Tx stats. */ + stats->tx_ucast_frames += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_UC_OK); + stats->tx_bcast_frames += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_BC_OK); + stats->tx_pause_frames += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_MPAUSE); + stats->tx_mcast_frames += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_MC_OK); + stats->tx_octets += + MSK_READ_MIB64(sc_if->msk_port, GM_TXO_OK_LO); + stats->tx_pkts_64 += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_64B); + stats->tx_pkts_65_127 += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_127B); + stats->tx_pkts_128_255 += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_255B); + stats->tx_pkts_256_511 += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_511B); + stats->tx_pkts_512_1023 += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_1023B); + stats->tx_pkts_1024_1518 += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_1518B); + stats->tx_pkts_1519_max += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_MAX_SZ); + reg = MSK_READ_MIB32(sc_if->msk_port, GM_TXF_SPARE1); + stats->tx_colls += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_COL); + stats->tx_late_colls += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_LAT_COL); + stats->tx_excess_colls += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_ABO_COL); + stats->tx_multi_colls += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_MUL_COL); + stats->tx_single_colls += + MSK_READ_MIB32(sc_if->msk_port, GM_TXF_SNG_COL); + stats->tx_underflows += + MSK_READ_MIB32(sc_if->msk_port, GM_TXE_FIFO_UR); + /* Clear MIB Clear Counter Mode. */ + gmac &= ~GM_PAR_MIB_CLR; + GMAC_WRITE_2(sc, sc_if->msk_port, GM_PHY_ADDR, gmac); +} + +static int +msk_sysctl_stat32(SYSCTL_HANDLER_ARGS) +{ + struct msk_softc *sc; + struct msk_if_softc *sc_if; + uint32_t result, *stat; + int off; + + sc_if = (struct msk_if_softc *)arg1; + sc = sc_if->msk_softc; + off = arg2; + stat = (uint32_t *)((uint8_t *)&sc_if->msk_stats + off); + + MSK_IF_LOCK(sc_if); + result = MSK_READ_MIB32(sc_if->msk_port, GM_MIB_CNT_BASE + off * 2); + result += *stat; + MSK_IF_UNLOCK(sc_if); + + return (sysctl_handle_int(oidp, &result, 0, req)); +} + +static int +msk_sysctl_stat64(SYSCTL_HANDLER_ARGS) +{ + struct msk_softc *sc; + struct msk_if_softc *sc_if; + uint64_t result, *stat; + int off; + + sc_if = (struct msk_if_softc *)arg1; + sc = sc_if->msk_softc; + off = arg2; + stat = (uint64_t *)((uint8_t *)&sc_if->msk_stats + off); + + MSK_IF_LOCK(sc_if); + result = MSK_READ_MIB64(sc_if->msk_port, GM_MIB_CNT_BASE + off * 2); + result += *stat; + MSK_IF_UNLOCK(sc_if); + + return (sysctl_handle_quad(oidp, &result, 0, req)); +} + +#undef MSK_READ_MIB32 +#undef MSK_READ_MIB64 + +#define MSK_SYSCTL_STAT32(sc, c, o, p, n, d) \ + SYSCTL_ADD_PROC(c, p, OID_AUTO, o, CTLTYPE_UINT | CTLFLAG_RD, \ + sc, offsetof(struct msk_hw_stats, n), msk_sysctl_stat32, \ + "IU", d) +#define MSK_SYSCTL_STAT64(sc, c, o, p, n, d) \ + SYSCTL_ADD_PROC(c, p, OID_AUTO, o, CTLTYPE_UINT | CTLFLAG_RD, \ + sc, offsetof(struct msk_hw_stats, n), msk_sysctl_stat64, \ + "Q", d) + +static void +msk_sysctl_node(struct msk_if_softc *sc_if) +{ + struct sysctl_ctx_list *ctx; + struct sysctl_oid_list *child, *schild; + struct sysctl_oid *tree; + + ctx = device_get_sysctl_ctx(sc_if->msk_if_dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc_if->msk_if_dev)); + + tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", CTLFLAG_RD, + NULL, "MSK Statistics"); + schild = child = SYSCTL_CHILDREN(tree); + tree = SYSCTL_ADD_NODE(ctx, schild, OID_AUTO, "rx", CTLFLAG_RD, + NULL, "MSK RX Statistics"); + child = SYSCTL_CHILDREN(tree); + MSK_SYSCTL_STAT32(sc_if, ctx, "ucast_frames", + child, rx_ucast_frames, "Good unicast frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "bcast_frames", + child, rx_bcast_frames, "Good broadcast frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "pause_frames", + child, rx_pause_frames, "Pause frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "mcast_frames", + child, rx_mcast_frames, "Multicast frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "crc_errs", + child, rx_crc_errs, "CRC errors"); + MSK_SYSCTL_STAT64(sc_if, ctx, "good_octets", + child, rx_good_octets, "Good octets"); + MSK_SYSCTL_STAT64(sc_if, ctx, "bad_octets", + child, rx_bad_octets, "Bad octets"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_64", + child, rx_pkts_64, "64 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_65_127", + child, rx_pkts_65_127, "65 to 127 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_128_255", + child, rx_pkts_128_255, "128 to 255 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_256_511", + child, rx_pkts_256_511, "256 to 511 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_512_1023", + child, rx_pkts_512_1023, "512 to 1023 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_1024_1518", + child, rx_pkts_1024_1518, "1024 to 1518 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_1519_max", + child, rx_pkts_1519_max, "1519 to max frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_too_long", + child, rx_pkts_too_long, "frames too long"); + MSK_SYSCTL_STAT32(sc_if, ctx, "jabbers", + child, rx_pkts_jabbers, "Jabber errors"); + MSK_SYSCTL_STAT32(sc_if, ctx, "jabbers", + child, rx_fifo_oflows, "FIFO overflows"); + + tree = SYSCTL_ADD_NODE(ctx, schild, OID_AUTO, "tx", CTLFLAG_RD, + NULL, "MSK TX Statistics"); + child = SYSCTL_CHILDREN(tree); + MSK_SYSCTL_STAT32(sc_if, ctx, "ucast_frames", + child, tx_ucast_frames, "Unicast frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "bcast_frames", + child, tx_bcast_frames, "Broadcast frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "pause_frames", + child, tx_pause_frames, "Pause frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "mcast_frames", + child, tx_mcast_frames, "Multicast frames"); + MSK_SYSCTL_STAT64(sc_if, ctx, "octets", + child, tx_octets, "Octets"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_64", + child, tx_pkts_64, "64 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_65_127", + child, tx_pkts_65_127, "65 to 127 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_128_255", + child, tx_pkts_128_255, "128 to 255 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_256_511", + child, tx_pkts_256_511, "256 to 511 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_512_1023", + child, tx_pkts_512_1023, "512 to 1023 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_1024_1518", + child, tx_pkts_1024_1518, "1024 to 1518 bytes frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "frames_1519_max", + child, tx_pkts_1519_max, "1519 to max frames"); + MSK_SYSCTL_STAT32(sc_if, ctx, "colls", + child, tx_colls, "Collisions"); + MSK_SYSCTL_STAT32(sc_if, ctx, "late_colls", + child, tx_late_colls, "Late collisions"); + MSK_SYSCTL_STAT32(sc_if, ctx, "excess_colls", + child, tx_excess_colls, "Excessive collisions"); + MSK_SYSCTL_STAT32(sc_if, ctx, "multi_colls", + child, tx_multi_colls, "Multiple collisions"); + MSK_SYSCTL_STAT32(sc_if, ctx, "single_colls", + child, tx_single_colls, "Single collisions"); + MSK_SYSCTL_STAT32(sc_if, ctx, "underflows", + child, tx_underflows, "FIFO underflows"); +} + +#undef MSK_SYSCTL_STAT32 +#undef MSK_SYSCTL_STAT64 + static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int low, int high) { Modified: stable/7/sys/dev/msk/if_mskreg.h ============================================================================== --- stable/7/sys/dev/msk/if_mskreg.h Thu Mar 19 01:43:03 2009 (r190012) +++ stable/7/sys/dev/msk/if_mskreg.h Thu Mar 19 02:13:14 2009 (r190013) @@ -1614,6 +1614,8 @@ (GM_MIB_CNT_BASE + 24) /* Multicast Frames Received OK */ #define GM_RXF_FCS_ERR \ (GM_MIB_CNT_BASE + 32) /* Rx Frame Check Seq. Error */ +#define GM_RXF_SPARE1 \ + (GM_MIB_CNT_BASE + 40) /* Rx spare 1 */ #define GM_RXO_OK_LO \ (GM_MIB_CNT_BASE + 48) /* Octets Received OK Low */ #define GM_RXO_OK_HI \ @@ -1644,8 +1646,12 @@ (GM_MIB_CNT_BASE + 152) /* Rx Frame too Long Error */ #define GM_RXF_JAB_PKT \ (GM_MIB_CNT_BASE + 160) /* Rx Jabber Packet Frame */ +#define GM_RXF_SPARE2 \ + (GM_MIB_CNT_BASE + 168) /* Rx spare 2 */ #define GM_RXE_FIFO_OV \ (GM_MIB_CNT_BASE + 176) /* Rx FIFO overflow Event */ +#define GM_RXF_SPARE3 \ + (GM_MIB_CNT_BASE + 184) /* Rx spare 3 */ #define GM_TXF_UC_OK \ (GM_MIB_CNT_BASE + 192) /* Unicast Frames Xmitted OK */ #define GM_TXF_BC_OK \ @@ -1672,6 +1678,8 @@ (GM_MIB_CNT_BASE + 280) /* 1024-1518 Byte Tx Frame */ #define GM_TXF_MAX_SZ \ (GM_MIB_CNT_BASE + 288) /* 1519-MaxSize Byte Tx Frame */ +#define GM_TXF_SPARE1 \ + (GM_MIB_CNT_BASE + 296) /* Tx spare 1 */ #define GM_TXF_COL \ (GM_MIB_CNT_BASE + 304) /* Tx Collision */ #define GM_TXF_LAT_COL \ @@ -2270,6 +2278,52 @@ struct msk_ring_data { /* Forward decl. */ struct msk_if_softc; +struct msk_hw_stats { + /* Rx stats. */ + uint32_t rx_ucast_frames; + uint32_t rx_bcast_frames; + uint32_t rx_pause_frames; + uint32_t rx_mcast_frames; + uint32_t rx_crc_errs; + uint32_t rx_spare1; + uint64_t rx_good_octets; + uint64_t rx_bad_octets; + uint32_t rx_runts; + uint32_t rx_runt_errs; + uint32_t rx_pkts_64; + uint32_t rx_pkts_65_127; + uint32_t rx_pkts_128_255; + uint32_t rx_pkts_256_511; + uint32_t rx_pkts_512_1023; + uint32_t rx_pkts_1024_1518; + uint32_t rx_pkts_1519_max; + uint32_t rx_pkts_too_long; + uint32_t rx_pkts_jabbers; + uint32_t rx_spare2; + uint32_t rx_fifo_oflows; + uint32_t rx_spare3; + /* Tx stats. */ + uint32_t tx_ucast_frames; + uint32_t tx_bcast_frames; + uint32_t tx_pause_frames; + uint32_t tx_mcast_frames; + uint64_t tx_octets; + uint32_t tx_pkts_64; + uint32_t tx_pkts_65_127; + uint32_t tx_pkts_128_255; + uint32_t tx_pkts_256_511; + uint32_t tx_pkts_512_1023; + uint32_t tx_pkts_1024_1518; + uint32_t tx_pkts_1519_max; + uint32_t tx_spare1; + uint32_t tx_colls; + uint32_t tx_late_colls; + uint32_t tx_excess_colls; + uint32_t tx_multi_colls; + uint32_t tx_single_colls; + uint32_t tx_underflows; +}; + /* Softc for the Marvell Yukon II controller. */ struct msk_softc { struct resource *msk_res[1]; /* I/O resource */ @@ -2340,6 +2394,7 @@ struct msk_if_softc { struct msk_chain_data msk_cdata; struct msk_ring_data msk_rdata; struct msk_softc *msk_softc; /* parent controller */ + struct msk_hw_stats msk_stats; struct task msk_link_task; struct task msk_tx_task; int msk_if_flags; From marcel at FreeBSD.org Wed Mar 18 23:44:01 2009 From: marcel at FreeBSD.org (Marcel Moolenaar) Date: Wed Mar 18 23:44:19 2009 Subject: svn commit: r190014 - in stable/7/sbin/geom: . class/part misc Message-ID: <200903190644.n2J6i0Cl050743@svn.freebsd.org> Author: marcel Date: Thu Mar 19 06:44:00 2009 New Revision: 190014 URL: http://svn.freebsd.org/changeset/base/190014 Log: MFC r184070,185454,185495-185496,188330 -- gpart(8): o Add support for multiple attributes. o Parse the error string returned by the kernel. o Prefer the start and end attributes over the offset and size attributes. Modified: stable/7/sbin/geom/ (props changed) stable/7/sbin/geom/class/part/ (props changed) stable/7/sbin/geom/class/part/geom_part.c stable/7/sbin/geom/misc/ (props changed) Modified: stable/7/sbin/geom/class/part/geom_part.c ============================================================================== --- stable/7/sbin/geom/class/part/geom_part.c Thu Mar 19 02:13:14 2009 (r190013) +++ stable/7/sbin/geom/class/part/geom_part.c Thu Mar 19 06:44:00 2009 (r190014) @@ -63,10 +63,11 @@ static char index_param[] = "index"; static char partcode_param[] = "partcode"; static void gpart_bootcode(struct gctl_req *, unsigned int); +static void gpart_issue(struct gctl_req *, unsigned int); static void gpart_show(struct gctl_req *, unsigned int); struct g_command PUBSYM(class_commands)[] = { - { "add", 0, NULL, { + { "add", 0, gpart_issue, { { 'b', "start", NULL, G_TYPE_STRING }, { 's', "size", NULL, G_TYPE_STRING }, { 't', "type", NULL, G_TYPE_STRING }, @@ -84,25 +85,25 @@ struct g_command PUBSYM(class_commands)[ G_OPT_SENTINEL }, "geom", NULL }, - { "commit", 0, NULL, G_NULL_OPTS, "geom", NULL }, - { "create", 0, NULL, { + { "commit", 0, gpart_issue, G_NULL_OPTS, "geom", NULL }, + { "create", 0, gpart_issue, { { 's', "scheme", NULL, G_TYPE_STRING }, { 'n', "entries", optional, G_TYPE_STRING }, { 'f', "flags", flags, G_TYPE_STRING }, G_OPT_SENTINEL }, "provider", NULL }, - { "delete", 0, NULL, { + { "delete", 0, gpart_issue, { { 'i', index_param, NULL, G_TYPE_STRING }, { 'f', "flags", flags, G_TYPE_STRING }, G_OPT_SENTINEL }, "geom", NULL }, - { "destroy", 0, NULL, { + { "destroy", 0, gpart_issue, { { 'f', "flags", flags, G_TYPE_STRING }, G_OPT_SENTINEL }, "geom", NULL }, - { "modify", 0, NULL, { + { "modify", 0, gpart_issue, { { 'i', index_param, NULL, G_TYPE_STRING }, { 'l', "label", optional, G_TYPE_STRING }, { 't', "type", optional, G_TYPE_STRING }, @@ -110,7 +111,7 @@ struct g_command PUBSYM(class_commands)[ G_OPT_SENTINEL }, "geom", NULL }, - { "set", 0, NULL, { + { "set", 0, gpart_issue, { { 'a', "attrib", NULL, G_TYPE_STRING }, { 'i', index_param, NULL, G_TYPE_STRING }, { 'f', "flags", flags, G_TYPE_STRING }, @@ -123,8 +124,8 @@ struct g_command PUBSYM(class_commands)[ G_OPT_SENTINEL }, NULL, "[-lr] [geom ...]" }, - { "undo", 0, NULL, G_NULL_OPTS, "geom", NULL }, - { "unset", 0, NULL, { + { "undo", 0, gpart_issue, G_NULL_OPTS, "geom", NULL }, + { "unset", 0, gpart_issue, { { 'a', "attrib", NULL, G_TYPE_STRING }, { 'i', index_param, NULL, G_TYPE_STRING }, { 'f', "flags", flags, G_TYPE_STRING }, @@ -186,17 +187,23 @@ static struct gprovider * find_provider(struct ggeom *gp, unsigned long long minsector) { struct gprovider *pp, *bestpp; - unsigned long long offset; + const char *s; unsigned long long sector, bestsector; bestpp = NULL; LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { - offset = atoll(find_provcfg(pp, "offset")); - sector = offset / pp->lg_sectorsize; + s = find_provcfg(pp, "start"); + if (s == NULL) { + s = find_provcfg(pp, "offset"); + sector = atoll(s) / pp->lg_sectorsize; + } else + sector = atoll(s); + if (sector < minsector) continue; if (bestpp != NULL && sector >= bestsector) continue; + bestpp = pp; bestsector = sector; } @@ -216,13 +223,20 @@ fmtsize(int64_t rawsz) static const char * fmtattrib(struct gprovider *pp) { - static char buf[64]; - const char *val; + static char buf[128]; + struct gconfig *gc; + u_int idx; - val = find_provcfg(pp, "attrib"); - if (val == NULL) - return (""); - snprintf(buf, sizeof(buf), " [%s] ", val); + buf[0] = '\0'; + idx = 0; + LIST_FOREACH(gc, &pp->lg_config, lg_config) { + if (strcmp(gc->lg_name, "attrib") != 0) + continue; + idx += snprintf(buf + idx, sizeof(buf) - idx, "%s%s", + (idx == 0) ? " [" : ",", gc->lg_val); + } + if (idx > 0) + snprintf(buf + idx, sizeof(buf) - idx, "] "); return (buf); } @@ -232,7 +246,7 @@ gpart_show_geom(struct ggeom *gp, const struct gprovider *pp; const char *s, *scheme; unsigned long long first, last, sector, end; - unsigned long long offset, length, secsz; + unsigned long long length, secsz; int idx, wblocks, wname; scheme = find_geomcfg(gp, "scheme"); @@ -250,14 +264,24 @@ gpart_show_geom(struct ggeom *gp, const scheme, fmtsize(pp->lg_mediasize)); while ((pp = find_provider(gp, first)) != NULL) { - s = find_provcfg(pp, "offset"); - offset = atoll(s); - sector = offset / secsz; - s = find_provcfg(pp, "length"); - length = atoll(s); + s = find_provcfg(pp, "start"); + if (s == NULL) { + s = find_provcfg(pp, "offset"); + sector = atoll(s) / secsz; + } else + sector = atoll(s); + + s = find_provcfg(pp, "end"); + if (s == NULL) { + s = find_provcfg(pp, "length"); + length = atoll(s) / secsz; + end = sector + length - 1; + } else { + end = atoll(s); + length = end - sector + 1; + } s = find_provcfg(pp, "index"); idx = atoi(s); - end = sector + length / secsz; if (first < sector) { printf(" %*llu %*llu %*s - free - (%s)\n", wblocks, first, wblocks, sector - first, @@ -265,16 +289,17 @@ gpart_show_geom(struct ggeom *gp, const fmtsize((sector - first) * secsz)); } printf(" %*llu %*llu %*d %s %s (%s)\n", - wblocks, sector, wblocks, end - sector, + wblocks, sector, wblocks, length, wname, idx, find_provcfg(pp, element), fmtattrib(pp), fmtsize(pp->lg_mediasize)); - first = end; + first = end + 1; } if (first <= last) { + length = last - first + 1; printf(" %*llu %*llu %*s - free - (%s)\n", - wblocks, first, wblocks, last - first + 1, + wblocks, first, wblocks, length, wname, "", - fmtsize((last - first + 1) * secsz)); + fmtsize(length * secsz)); } printf("\n"); } @@ -439,7 +464,7 @@ gpart_write_partcode(struct gctl_req *re } static void -gpart_bootcode(struct gctl_req *req, unsigned int fl __unused) +gpart_bootcode(struct gctl_req *req, unsigned int fl) { const char *s; char *sp; @@ -494,9 +519,42 @@ gpart_bootcode(struct gctl_req *req, uns errx(EXIT_FAILURE, "no -b nor -p"); } - if (bootcode != NULL) { - s = gctl_issue(req); - if (s != NULL) - errx(EXIT_FAILURE, "%s", s); - } + if (bootcode != NULL) + gpart_issue(req, fl); +} + +static void +gpart_issue(struct gctl_req *req, unsigned int fl __unused) +{ + char buf[4096]; + char *errmsg; + const char *errstr; + int error, status; + + bzero(buf, sizeof(buf)); + gctl_rw_param(req, "output", sizeof(buf), buf); + errstr = gctl_issue(req); + if (errstr == NULL || errstr[0] == '\0') { + if (buf[0] != '\0') + printf("%s", buf); + status = EXIT_SUCCESS; + goto done; + } + + error = strtol(errstr, &errmsg, 0); + if (errmsg != errstr) { + while (errmsg[0] == ' ') + errmsg++; + if (errmsg[0] != '\0') + warnc(error, "%s", errmsg); + else + warnc(error, NULL); + } else + warnx("%s", errmsg); + + status = EXIT_FAILURE; + + done: + gctl_free(req); + exit(status); } From rnoland at FreeBSD.org Thu Mar 19 00:37:02 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Thu Mar 19 00:37:19 2009 Subject: svn commit: r190015 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903190737.n2J7b0OL051975@svn.freebsd.org> Author: rnoland Date: Thu Mar 19 07:37:00 2009 New Revision: 190015 URL: http://svn.freebsd.org/changeset/base/190015 Log: Merge 189868 Fix R600 writeback across suspend/resume. This is likely a NOOP for us, since I haven't ported the suspend/resume code yet. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/r600_cp.c Modified: stable/7/sys/dev/drm/r600_cp.c ============================================================================== --- stable/7/sys/dev/drm/r600_cp.c Thu Mar 19 06:44:00 2009 (r190014) +++ stable/7/sys/dev/drm/r600_cp.c Thu Mar 19 07:37:00 2009 (r190015) @@ -1740,9 +1740,6 @@ static void r600_cp_init_ring_buffer(str RADEON_WRITE(R600_CP_DEBUG, (1 << 27) | (1 << 28)); - /* Start with assuming that writeback doesn't work */ - dev_priv->writeback_works = 0; - /* Initialize the scratch register pointer. This will cause * the scratch register values to be written out to memory * whenever they are updated. From rnoland at FreeBSD.org Thu Mar 19 00:39:08 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Thu Mar 19 00:39:14 2009 Subject: svn commit: r190016 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903190739.n2J7d7o0052064@svn.freebsd.org> Author: rnoland Date: Thu Mar 19 07:39:07 2009 New Revision: 190016 URL: http://svn.freebsd.org/changeset/base/190016 Log: Merge 189869 Get rid of any remaining PZERO flags in mtx_sleep() Also, clean up some ifdef mess while I'm here. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/drm_drv.c stable/7/sys/dev/drm/drm_lock.c stable/7/sys/dev/drm/radeon_cp.c Modified: stable/7/sys/dev/drm/drm_drv.c ============================================================================== --- stable/7/sys/dev/drm/drm_drv.c Thu Mar 19 07:37:00 2009 (r190015) +++ stable/7/sys/dev/drm/drm_drv.c Thu Mar 19 07:39:07 2009 (r190016) @@ -666,7 +666,7 @@ void drm_close(void *data) } /* Contention */ retcode = mtx_sleep((void *)&dev->lock.lock_queue, - &dev->dev_lock, PZERO | PCATCH, "drmlk2", 0); + &dev->dev_lock, PCATCH, "drmlk2", 0); if (retcode) break; } Modified: stable/7/sys/dev/drm/drm_lock.c ============================================================================== --- stable/7/sys/dev/drm/drm_lock.c Thu Mar 19 07:37:00 2009 (r190015) +++ stable/7/sys/dev/drm/drm_lock.c Thu Mar 19 07:39:07 2009 (r190016) @@ -82,7 +82,7 @@ int drm_lock(struct drm_device *dev, voi /* Contention */ ret = mtx_sleep((void *)&dev->lock.lock_queue, &dev->dev_lock, - PZERO | PCATCH, "drmlk2", 0); + PCATCH, "drmlk2", 0); if (ret != 0) break; } Modified: stable/7/sys/dev/drm/radeon_cp.c ============================================================================== --- stable/7/sys/dev/drm/radeon_cp.c Thu Mar 19 07:37:00 2009 (r190015) +++ stable/7/sys/dev/drm/radeon_cp.c Thu Mar 19 07:39:07 2009 (r190016) @@ -1708,26 +1708,14 @@ void radeon_do_release(struct drm_device if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600) { while ((ret = r600_do_cp_idle(dev_priv)) != 0) { DRM_DEBUG("radeon_do_cp_idle %d\n", ret); -#ifdef __linux__ - schedule(); -#elsif defined(__FreeBSD__) mtx_sleep(&ret, &dev->dev_lock, 0, "rdnrel", 1); -#else - tsleep(&ret, PZERO, "rdnrel", 1); -#endif } } else { while ((ret = radeon_do_cp_idle(dev_priv)) != 0) { DRM_DEBUG("radeon_do_cp_idle %d\n", ret); -#ifdef __linux__ - schedule(); -#elsif defined(__FreeBSD__) mtx_sleep(&ret, &dev->dev_lock, 0, "rdnrel", 1); -#else - tsleep(&ret, PZERO, "rdnrel", 1); -#endif } } if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600) { From rnoland at FreeBSD.org Thu Mar 19 00:40:42 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Thu Mar 19 00:40:49 2009 Subject: svn commit: r190017 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/atkbdc dev/cxgb Message-ID: <200903190740.n2J7efQm052150@svn.freebsd.org> Author: rnoland Date: Thu Mar 19 07:40:41 2009 New Revision: 190017 URL: http://svn.freebsd.org/changeset/base/190017 Log: Merge 189870 Teach psm about O_ASYNC This makes Xorg happy if you aren't using moused. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/atkbdc/psm.c stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/dev/atkbdc/psm.c ============================================================================== --- stable/7/sys/dev/atkbdc/psm.c Thu Mar 19 07:39:07 2009 (r190016) +++ stable/7/sys/dev/atkbdc/psm.c Thu Mar 19 07:40:41 2009 (r190017) @@ -70,7 +70,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include +#include #include #include #include @@ -212,6 +215,7 @@ struct psm_softc { /* Driver status inf struct cdev *bdev; int lasterr; int cmdcount; + struct sigio *async; /* Processes waiting for SIGIO */ }; static devclass_t psm_devclass; #define PSM_SOFTC(unit) \ @@ -1383,6 +1387,7 @@ psmopen(struct cdev *dev, int flag, int sc->mode.level = sc->dflt_mode.level; sc->mode.protocol = sc->dflt_mode.protocol; sc->watchdog = FALSE; + sc->async = NULL; /* flush the event queue */ sc->queue.count = 0; @@ -1522,6 +1527,12 @@ psmclose(struct cdev *dev, int flag, int /* remove anything left in the output buffer */ empty_aux_buffer(sc->kbdc, 10); + /* clean up and sigio requests */ + if (sc->async != NULL) { + funsetown(&sc->async); + sc->async = NULL; + } + /* close is almost always successful */ sc->state &= ~PSM_OPEN; kbdc_lock(sc->kbdc, FALSE); @@ -2083,6 +2094,15 @@ psmioctl(struct cdev *dev, u_long cmd, c break; #endif /* MOUSE_GETHWID */ + case FIONBIO: + case FIOASYNC: + break; + case FIOSETOWN: + error = fsetown(*(int *)addr, &sc->async); + break; + case FIOGETOWN: + *(int *) addr = fgetown(&sc->async); + break; default: return (ENOTTY); } @@ -2972,6 +2992,9 @@ next: wakeup(sc); } selwakeuppri(&sc->rsel, PZERO); + if (sc->async != NULL) { + pgsigio(&sc->async, SIGIO, 0); + } sc->state &= ~PSM_SOFTARMED; splx(s); } From rnoland at FreeBSD.org Thu Mar 19 00:41:59 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Thu Mar 19 00:42:15 2009 Subject: svn commit: r190018 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/drm Message-ID: <200903190741.n2J7fwqh052219@svn.freebsd.org> Author: rnoland Date: Thu Mar 19 07:41:58 2009 New Revision: 190018 URL: http://svn.freebsd.org/changeset/base/190018 Log: Merge 189899 Use the right MSI_REARM for RS600. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/drm/radeon_irq.c Modified: stable/7/sys/dev/drm/radeon_irq.c ============================================================================== --- stable/7/sys/dev/drm/radeon_irq.c Thu Mar 19 07:40:41 2009 (r190017) +++ stable/7/sys/dev/drm/radeon_irq.c Thu Mar 19 07:41:58 2009 (r190018) @@ -229,6 +229,7 @@ irqreturn_t radeon_driver_irq_handler(DR RADEON_WRITE(RADEON_AIC_CNTL, tmp | RS400_MSI_REARM); break; + case CHIP_RS600: case CHIP_RS690: case CHIP_RS740: tmp = RADEON_READ(RADEON_BUS_CNTL) & From rnoland at FreeBSD.org Thu Mar 19 01:18:15 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Thu Mar 19 01:18:21 2009 Subject: svn commit: r190019 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb Message-ID: <200903190818.n2J8ID8R053090@svn.freebsd.org> Author: rnoland Date: Thu Mar 19 08:18:13 2009 New Revision: 190019 URL: http://svn.freebsd.org/changeset/base/190019 Log: Record only commit to document that 173573,175381,176624,177480,183397 have all been merged. Not sure where these got lost exactly... Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) From marius at FreeBSD.org Thu Mar 19 05:32:14 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Thu Mar 19 05:32:25 2009 Subject: svn commit: r190028 - in stable/7/sys: . conf contrib/pf dev/ath/ath_hal dev/cxgb Message-ID: <200903191232.n2JCWDYx060840@svn.freebsd.org> Author: marius Date: Thu Mar 19 12:32:13 2009 New Revision: 190028 URL: http://svn.freebsd.org/changeset/base/190028 Log: MFC: r182729 Switch sun4v to back to using its own clock.c, which was ressurected in r190005, as the sparc64 version is going to be rototilled and sun4v currently can't be verified to still work with the new sparc64 one due to its overall state. Modified: stable/7/sys/ (props changed) stable/7/sys/conf/files.sun4v stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/conf/files.sun4v ============================================================================== --- stable/7/sys/conf/files.sun4v Thu Mar 19 12:31:59 2009 (r190027) +++ stable/7/sys/conf/files.sun4v Thu Mar 19 12:32:13 2009 (r190028) @@ -34,7 +34,7 @@ libkern/fls.c standard libkern/flsl.c standard sparc64/sparc64/autoconf.c standard sun4v/sun4v/bus_machdep.c standard -sparc64/sparc64/clock.c standard +sun4v/sun4v/clock.c standard sparc64/sparc64/db_disasm.c optional ddb sun4v/sun4v/db_interface.c optional ddb sun4v/sun4v/db_trace.c optional ddb From marius at FreeBSD.org Thu Mar 19 05:55:13 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Thu Mar 19 05:55:32 2009 Subject: svn commit: r190033 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb sparc64/include sparc64/sparc64 Message-ID: <200903191255.n2JCtB7p061565@svn.freebsd.org> Author: marius Date: Thu Mar 19 12:55:11 2009 New Revision: 190033 URL: http://svn.freebsd.org/changeset/base/190033 Log: MFC: r182730, r182743, r183201 - USIII-based machines can consist of CPUs running at different frequencies (and having different cache sizes) so use the STICK (System TICK) timer, which was introduced due to this and is driven by the same frequency across all CPUs, instead of the TICK timer, whose frequency varies with the CPU clock, to drive hardclock. We use the STICK timers only when absolutely necessary though as the STICK timers are driven at frequencies as low as 5MHz, resulting in bad granularity compared to the TICK timers. However, don't employ the workaround for the BlackBird erratum #1 when using the TICK timer on machines with cheetah-class CPUs for performance reasons. Note that using the STICK counter also causes a hang with USIIIi MP machines for reasons unknown, but these can only consist of identical CPUs anyway. - Given that we only (try to) synchronize the (S)TICK timers of APs with the BSP during startup, we could end up spinning forever in DELAY(9) if that function is migrated to another CPU while we're spinning due to clock drift afterwards, so pin to the CPU in order to avoid migration. Unfortunately, pinning doesn't work at the point DELAY(9) is required by the low-level console drivers, yet, so switch to a function pointer, which is updated accordingly, for implementing DELAY(9). For USIII and beyond, this would also allow to easily use the STICK counter instead of the TICK one here, there's no benefit in doing so however. While at it, use cpu_spinwait(9) for spinning in the delay- functions. This currently is a NOP though. - Don't set the TICK timer of the BSP to 0 during startup as there's no need to do so. - Implement cpu_est_clockrate(). - Unfortunately, USIIIi-based machines don't provide a timecounter device besides the STICK and TICK counters (well, in theory the Tomatillo bridges have a performance counter that can be (ab)used as timecounter by configuring it to count bus cycles, though unlike the performance counter of Schizo bridges, the Tomatillo one is broken and counts Sun knows what in this mode). This means that we've to use a (S)TICK counter for timecounting, which has the old problem of not being in sync across CPUs, so provide an additional timecounter function which binds itself to the BSP but has an adequate low priority. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/sparc64/include/clock.h stable/7/sys/sparc64/include/cpufunc.h stable/7/sys/sparc64/include/pcpu.h stable/7/sys/sparc64/include/smp.h stable/7/sys/sparc64/include/tick.h stable/7/sys/sparc64/include/ver.h stable/7/sys/sparc64/sparc64/clock.c stable/7/sys/sparc64/sparc64/exception.S stable/7/sys/sparc64/sparc64/genassym.c stable/7/sys/sparc64/sparc64/locore.S stable/7/sys/sparc64/sparc64/machdep.c stable/7/sys/sparc64/sparc64/mp_locore.S stable/7/sys/sparc64/sparc64/mp_machdep.c stable/7/sys/sparc64/sparc64/tick.c Modified: stable/7/sys/sparc64/include/clock.h ============================================================================== --- stable/7/sys/sparc64/include/clock.h Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/include/clock.h Thu Mar 19 12:55:11 2009 (r190033) @@ -29,10 +29,12 @@ #ifndef _MACHINE_CLOCK_H_ #define _MACHINE_CLOCK_H_ -extern u_long tick_increment; -extern u_long tick_freq; -extern u_long tick_MHz; +extern void (*delay_func)(int usec); +extern u_long clock_boot; -int sysbeep(int, int); +void delay_boot(int usec); +void delay_tick(int usec); + +int sysbeep(int pitch, int period); #endif /* !_MACHINE_CLOCK_H_ */ Modified: stable/7/sys/sparc64/include/cpufunc.h ============================================================================== --- stable/7/sys/sparc64/include/cpufunc.h Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/include/cpufunc.h Thu Mar 19 12:55:11 2009 (r190033) @@ -174,6 +174,15 @@ int fasword32(u_long asi, void *addr, ui } while (0) /* + * Trick GAS/GCC into compiling access to STICK/STICK_COMPARE independently + * of the selected instruction set. + */ +#define rdstick() rd(asr24) +#define rdstickcmpr() rd(asr25) +#define wrstick(val, xor) wr(asr24, (val), (xor)) +#define wrstickcmpr(val, xor) wr(asr25, (val), (xor)) + +/* * Macro intended to be used instead of wr(asr23, val, xor) for writing to * the TICK_COMPARE register in order to avoid a bug in BlackBird CPUs that * can cause these writes to fail under certain condidtions which in turn Modified: stable/7/sys/sparc64/include/pcpu.h ============================================================================== --- stable/7/sys/sparc64/include/pcpu.h Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/include/pcpu.h Thu Mar 19 12:55:11 2009 (r190033) @@ -53,6 +53,7 @@ struct pmap; vm_offset_t pc_addr; \ u_long pc_tickref; \ u_long pc_tickadj; \ + u_int pc_clock; \ u_int pc_mid; \ u_int pc_node; \ u_int pc_tlb_ctx; \ Modified: stable/7/sys/sparc64/include/smp.h ============================================================================== --- stable/7/sys/sparc64/include/smp.h Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/include/smp.h Thu Mar 19 12:55:11 2009 (r190033) @@ -29,9 +29,10 @@ #ifndef _MACHINE_SMP_H_ #define _MACHINE_SMP_H_ -#define CPU_CLKSYNC 1 -#define CPU_INIT 2 -#define CPU_BOOTSTRAP 3 +#define CPU_TICKSYNC 1 +#define CPU_STICKSYNC 2 +#define CPU_INIT 3 +#define CPU_BOOTSTRAP 4 #ifndef LOCORE @@ -62,6 +63,7 @@ struct cpu_start_args { u_int csa_state; vm_offset_t csa_pcpu; u_long csa_tick; + u_long csa_stick; u_long csa_ver; struct tte csa_ttes[PCPU_PAGES]; }; Modified: stable/7/sys/sparc64/include/tick.h ============================================================================== --- stable/7/sys/sparc64/include/tick.h Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/include/tick.h Thu Mar 19 12:55:11 2009 (r190033) @@ -29,7 +29,9 @@ #ifndef _MACHINE_TICK_H_ #define _MACHINE_TICK_H_ -void tick_init(u_long clock); +extern u_int hardclock_use_stick; + +void tick_clear(void); void tick_start(void); void tick_stop(void); Modified: stable/7/sys/sparc64/include/ver.h ============================================================================== --- stable/7/sys/sparc64/include/ver.h Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/include/ver.h Thu Mar 19 12:55:11 2009 (r190033) @@ -41,6 +41,8 @@ #define VER_MAXTL_SIZE (8) #define VER_MAXWIN_SIZE (5) +#ifndef LOCORE + #define VER_MANUF_MASK (((1L< #include +#include +#include +#include + #include +#include +#include + +void (*delay_func)(int usec); +u_long clock_boot; + +void +DELAY(int usec) +{ -u_long tick_increment; -u_long tick_freq; -u_long tick_MHz; + (*delay_func)(usec); +} void -DELAY(int n) +delay_boot(int usec) { - u_long start, end; + u_long end; - start = rd(tick); - if (n < 0) + if (usec < 0) return; - end = start + (u_long)n * tick_MHz; + + end = rd(tick) + (u_long)usec * clock_boot / 1000000; while (rd(tick) < end) - ; + cpu_spinwait(); +} + +void +delay_tick(int usec) +{ + u_long end; + + if (usec < 0) + return; + + /* + * We avoid being migrated to another CPU with a possibly + * unsynchronized TICK timer while spinning. + */ + sched_pin(); + + end = rd(tick) + (u_long)usec * PCPU_GET(clock) / 1000000; + while (rd(tick) < end) + cpu_spinwait(); + + sched_unpin(); } void Modified: stable/7/sys/sparc64/sparc64/exception.S ============================================================================== --- stable/7/sys/sparc64/sparc64/exception.S Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/sparc64/exception.S Thu Mar 19 12:55:11 2009 (r190033) @@ -550,7 +550,7 @@ END(tl0_sfsr_trap) tl ## traplvl ## _intr level, 1 << level #define TICK(traplvl) \ - tl ## traplvl ## _intr PIL_TICK, 1 + tl ## traplvl ## _intr PIL_TICK, 0x10001 #define INTR_LEVEL(tl) \ INTR(1, tl) ; \ Modified: stable/7/sys/sparc64/sparc64/genassym.c ============================================================================== --- stable/7/sys/sparc64/sparc64/genassym.c Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/sparc64/genassym.c Thu Mar 19 12:55:11 2009 (r190033) @@ -83,10 +83,11 @@ ASSYM(PAGE_SIZE_4M, PAGE_SIZE_4M); ASSYM(CSA_PCPU, offsetof(struct cpu_start_args, csa_pcpu)); ASSYM(CSA_STATE, offsetof(struct cpu_start_args, csa_state)); #ifdef SUN4U -ASSYM(CSA_TICK, offsetof(struct cpu_start_args, csa_tick)); -ASSYM(CSA_VER, offsetof(struct cpu_start_args, csa_ver)); ASSYM(CSA_MID, offsetof(struct cpu_start_args, csa_mid)); +ASSYM(CSA_STICK, offsetof(struct cpu_start_args, csa_stick)); +ASSYM(CSA_TICK, offsetof(struct cpu_start_args, csa_tick)); ASSYM(CSA_TTES, offsetof(struct cpu_start_args, csa_ttes)); +ASSYM(CSA_VER, offsetof(struct cpu_start_args, csa_ver)); #endif #ifdef SUN4V ASSYM(CSA_CPUID, offsetof(struct cpu_start_args, csa_cpuid)); Modified: stable/7/sys/sparc64/sparc64/locore.S ============================================================================== --- stable/7/sys/sparc64/sparc64/locore.S Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/sparc64/locore.S Thu Mar 19 12:55:11 2009 (r190033) @@ -54,7 +54,6 @@ ENTRY(_start) wrpr %g0, 0, %cleanwin wrpr %g0, 0, %pil wr %g0, 0, %fprs - wrpr %g0, 0, %tick /* * Get onto our per-CPU panic stack, which precedes the struct pcpu in Modified: stable/7/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 12:55:11 2009 (r190033) @@ -133,18 +133,6 @@ struct kva_md_info kmi; u_long ofw_vec; u_long ofw_tba; -/* - * Note: timer quality for CPU's is set low to try and prevent them from - * being chosen as the primary timecounter. The CPU counters are not - * synchronized among the CPU's so in MP machines this causes problems - * when calculating the time. With this value the CPU's should only be - * chosen as the primary timecounter as a last resort. - */ - -#define UP_TICK_QUALITY 1000 -#define MP_TICK_QUALITY -100 -static struct timecounter tick_tc; - char sparc64_model[32]; static int cpu_use_vis = 1; @@ -152,7 +140,6 @@ static int cpu_use_vis = 1; cpu_block_copy_t *cpu_block_copy; cpu_block_zero_t *cpu_block_zero; -static timecounter_get_t tick_get_timecount; void sparc64_init(caddr_t mdp, u_long o1, u_long o2, u_long o3, ofw_vec_t *vec); void sparc64_shutdown_final(void *dummy, int howto); @@ -180,22 +167,6 @@ cpu_startup(void *arg) vm_paddr_t physsz; int i; - tick_tc.tc_get_timecount = tick_get_timecount; - tick_tc.tc_poll_pps = NULL; - tick_tc.tc_counter_mask = ~0u; - tick_tc.tc_frequency = tick_freq; - tick_tc.tc_name = "tick"; - tick_tc.tc_quality = UP_TICK_QUALITY; -#ifdef SMP - /* - * We do not know if each CPU's tick counter is synchronized. - */ - if (cpu_mp_probe()) - tick_tc.tc_quality = MP_TICK_QUALITY; -#endif - - tc_init(&tick_tc); - physsz = 0; for (i = 0; i < sparc64_nmemreg; i++) physsz += sparc64_memreg[i].mr_size; @@ -217,7 +188,7 @@ cpu_startup(void *arg) if (bootverbose) printf("machine: %s\n", sparc64_model); - cpu_identify(rdpr(ver), tick_freq, PCPU_GET(cpuid)); + cpu_identify(rdpr(ver), PCPU_GET(clock), curcpu); } void @@ -262,12 +233,6 @@ spinlock_exit(void) wrpr(pil, td->td_md.md_saved_pil, 0); } -unsigned -tick_get_timecount(struct timecounter *tc) -{ - return ((unsigned)rd(tick)); -} - void sparc64_init(caddr_t mdp, u_long o1, u_long o2, u_long o3, ofw_vec_t *vec) { @@ -278,7 +243,6 @@ sparc64_init(caddr_t mdp, u_long o1, u_l caddr_t kmdp; phandle_t child; phandle_t root; - u_int clock; uint32_t portid; end = 0; @@ -291,6 +255,21 @@ sparc64_init(caddr_t mdp, u_long o1, u_l cpu_impl = VER_IMPL(rdpr(ver)); /* + * Clear (S)TICK timer (including NPT). + */ + tick_clear(); + + /* + * UltraSparc II[e,i] based systems come up with the tick interrupt + * enabled and a handler that resets the tick counter, causing DELAY() + * to not work properly when used early in boot. + * UltraSPARC III based systems come up with the system tick interrupt + * enabled, causing an interrupt storm on startup since they are not + * handled. + */ + tick_stop(); + + /* * Initialize Open Firmware (needed for console). */ OF_init(vec); @@ -329,7 +308,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_l pc->pc_tlb_ctx_max = TLB_CTX_USER_MAX; /* - * Determine the OFW node (and ensure the + * Determine the OFW node and frequency of the BSP (and ensure the * BSP is in the device tree in the first place). */ pc->pc_node = 0; @@ -349,17 +328,23 @@ sparc64_init(caddr_t mdp, u_long o1, u_l } if (pc->pc_node == 0) OF_exit(); + if (OF_getprop(child, "clock-frequency", &pc->pc_clock, + sizeof(pc->pc_clock)) <= 0) + OF_exit(); /* - * Initialize the tick counter. Must be before the console is inited - * in order to provide the low-level console drivers with a working - * DELAY(). + * Provide a DELAY() that works before PCPU_REG is set. We can't + * set PCPU_REG without also taking over the trap table or the + * firmware will overwrite it. Unfortunately, it's way to early + * to also take over the trap table at this point. */ - OF_getprop(child, "clock-frequency", &clock, sizeof(clock)); - tick_init(clock); + clock_boot = pc->pc_clock; + delay_func = delay_boot; /* * Initialize the console before printing anything. + * NB: the low-level console drivers require a working DELAY() at + * this point. */ cninit(); @@ -445,6 +430,11 @@ sparc64_init(caddr_t mdp, u_long o1, u_l cpu_setregs(pc); /* + * It's now safe to use the real DELAY(). + */ + delay_func = delay_tick; + + /* * Initialize the message buffer (after setting trap table). */ msgbufinit(msgbufp, MSGBUF_SIZE); @@ -720,8 +710,13 @@ cpu_shutdown(void *args) int cpu_est_clockrate(int cpu_id, uint64_t *rate) { + struct pcpu *pc; - return (ENXIO); + pc = pcpu_find(cpu_id); + if (pc == NULL || rate == NULL) + return (EINVAL); + *rate = pc->pc_clock; + return (0); } /* Modified: stable/7/sys/sparc64/sparc64/mp_locore.S ============================================================================== --- stable/7/sys/sparc64/sparc64/mp_locore.S Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/sparc64/mp_locore.S Thu Mar 19 12:55:11 2009 (r190033) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "assym.s" @@ -92,7 +93,7 @@ ENTRY(mp_startup) SET(cpu_start_args, %l1, %l0) - mov CPU_CLKSYNC, %l1 + mov CPU_TICKSYNC, %l1 membar #StoreLoad stw %l1, [%l0 + CSA_STATE] @@ -101,7 +102,25 @@ ENTRY(mp_startup) nop wrpr %l1, 0, %tick - UPA_GET_MID(%o0) + rdpr %ver, %l1 + stx %l1, [%l0 + CSA_VER] + + srlx %l1, VER_IMPL_SHIFT, %l1 + sll %l1, VER_IMPL_SIZE, %l1 + srl %l1, VER_IMPL_SIZE, %l1 + cmp %l1, CPU_IMPL_ULTRASPARCIII + bl %icc, 3f + nop + mov CPU_STICKSYNC, %l1 + membar #StoreLoad + stw %l1, [%l0 + CSA_STATE] + +2: ldx [%l0 + CSA_STICK], %l1 + brz %l1, 2b + nop + wr %l1, 0, %asr24 + +3: UPA_GET_MID(%o0) #if KTR_COMPILE & KTR_SMP CATR(KTR_SMP, "mp_start: CPU %d entered kernel" @@ -110,9 +129,6 @@ ENTRY(mp_startup) 9: #endif - rdpr %ver, %l1 - stx %l1, [%l0 + CSA_VER] - /* * Inform the boot processor we have inited. */ @@ -123,9 +139,9 @@ ENTRY(mp_startup) /* * Wait till its our turn to bootstrap. */ -2: lduw [%l0 + CSA_MID], %l1 +4: lduw [%l0 + CSA_MID], %l1 cmp %l1, %o0 - bne %xcc, 2b + bne %xcc, 4b nop #if KTR_COMPILE & KTR_SMP @@ -141,7 +157,7 @@ ENTRY(mp_startup) /* * Map the per-CPU pages. */ -3: sllx %l2, TTE_SHIFT, %l3 +5: sllx %l2, TTE_SHIFT, %l3 add %l1, %l3, %l3 ldx [%l3 + TTE_VPN], %l4 @@ -156,7 +172,7 @@ ENTRY(mp_startup) add %l2, 1, %l2 cmp %l2, PCPU_PAGES - bne %xcc, 3b + bne %xcc, 5b nop /* Modified: stable/7/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/mp_machdep.c Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/sparc64/mp_machdep.c Thu Mar 19 12:55:11 2009 (r190033) @@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -101,7 +102,7 @@ static ih_func_t cpu_ipi_stop; * since the other processors will use it before the boot CPU enters the * kernel. */ -struct cpu_start_args cpu_start_args = { 0, -1, -1, 0, 0 }; +struct cpu_start_args cpu_start_args = { 0, -1, -1, 0, 0, 0 }; struct ipi_cache_args ipi_cache_args; struct ipi_tlb_args ipi_tlb_args; struct pcb stoppcbs[MAXCPU]; @@ -270,17 +271,25 @@ cpu_mp_start(void) if (OF_getprop(child, "clock-frequency", &clock, sizeof(clock)) <= 0) panic("%s: can't get clock", __func__); + if (clock != PCPU_GET(clock)) + hardclock_use_stick = 1; csa->csa_state = 0; sun4u_startcpu(child, (void *)mp_tramp, 0); s = intr_disable(); - while (csa->csa_state != CPU_CLKSYNC) + while (csa->csa_state != CPU_TICKSYNC) ; membar(StoreLoad); csa->csa_tick = rd(tick); + if (cpu_impl >= CPU_IMPL_ULTRASPARCIII) { + while (csa->csa_state != CPU_STICKSYNC) + ; + membar(StoreLoad); + csa->csa_stick = rdstick(); + } while (csa->csa_state != CPU_INIT) ; - csa->csa_tick = 0; + csa->csa_tick = csa->csa_stick = 0; intr_restore(s); cpuid = mp_ncpus++; @@ -291,6 +300,7 @@ cpu_mp_start(void) pc = (struct pcpu *)(va + (PCPU_PAGES * PAGE_SIZE)) - 1; pcpu_init(pc, cpuid, sizeof(*pc)); pc->pc_addr = va; + pc->pc_clock = clock; pc->pc_mid = mid; pc->pc_node = child; Modified: stable/7/sys/sparc64/sparc64/tick.c ============================================================================== --- stable/7/sys/sparc64/sparc64/tick.c Thu Mar 19 12:52:19 2009 (r190032) +++ stable/7/sys/sparc64/sparc64/tick.c Thu Mar 19 12:55:11 2009 (r190033) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2001 Jake Burkholder. + * Copyright (c) 2005, 2008 Marius Strobl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,22 +29,30 @@ __FBSDID("$FreeBSD$"); #include -#include #include -#include -#include +#include +#include +#include #include +#include +#include +#include #include #include -#include +#include + #include #include #include #include #include -#define TICK_GRACE 10000 +/* 10000 ticks proved okay for 500MHz. */ +#define TICK_GRACE(clock) ((clock) / 1000000 * 2 * 10) + +#define TICK_QUALITY_MP 10 +#define TICK_QUALITY_UP 1000 SYSCTL_NODE(_machdep, OID_AUTO, tick, CTLFLAG_RD, 0, "tick statistics"); @@ -63,7 +72,24 @@ static int adjust_ticks = 0; SYSCTL_INT(_machdep_tick, OID_AUTO, adjust_ticks, CTLFLAG_RD, &adjust_ticks, 0, "total number of tick interrupts with adjustment"); +u_int hardclock_use_stick = 0; +SYSCTL_INT(_machdep_tick, OID_AUTO, hardclock_use_stick, CTLFLAG_RD, + &hardclock_use_stick, 0, "hardclock uses STICK instead of TICK timer"); + +static struct timecounter tick_tc; +static u_long tick_increment; + +static uint64_t tick_cputicks(void); +static timecounter_get_t tick_get_timecount_up; +#ifdef SMP +static timecounter_get_t tick_get_timecount_mp; +#endif static void tick_hardclock(struct trapframe *tf); +static void tick_hardclock_bbwar(struct trapframe *tf); +static inline void tick_hardclock_common(struct trapframe *tf, u_long tick, + u_long adj); +static inline void tick_process(struct trapframe *tf); +static void stick_hardclock(struct trapframe *tf); static uint64_t tick_cputicks(void) @@ -75,9 +101,65 @@ tick_cputicks(void) void cpu_initclocks(void) { + uint32_t clock; stathz = hz; + + /* + * Given that the STICK timers typically are driven at rather low + * frequencies they shouldn't be used except when really necessary. + */ + if (hardclock_use_stick != 0) { + if (OF_getprop(OF_parent(PCPU_GET(node)), "stick-frequency", + &clock, sizeof(clock)) == -1) + panic("%s: could not determine STICK frequency", __func__); + intr_setup(PIL_TICK, stick_hardclock, -1, NULL, NULL); + /* + * We don't provide a CPU ticker as long as the frequency + * supplied isn't actually used per-CPU. + */ + } else { + clock = PCPU_GET(clock); + intr_setup(PIL_TICK, cpu_impl < CPU_IMPL_ULTRASPARCIII ? + tick_hardclock_bbwar : tick_hardclock, -1, NULL, NULL); + set_cputicker(tick_cputicks, clock, 0); + } + tick_increment = clock / hz; + /* + * Avoid stopping of hardclock in terms of a lost (S)TICK interrupt + * by ensuring that the (S)TICK period is at least TICK_GRACE ticks. + */ + if (tick_increment < TICK_GRACE(clock)) + panic("%s: HZ too high, decrease to at least %d", + __func__, clock / TICK_GRACE(clock)); tick_start(); + + /* + * Initialize the TICK-based timecounter. This must not happen + * before SI_SUB_INTRINSIC for tick_get_timecount_mp() to work. + */ + tick_tc.tc_get_timecount = tick_get_timecount_up; + tick_tc.tc_poll_pps = NULL; + tick_tc.tc_counter_mask = ~0u; + tick_tc.tc_frequency = PCPU_GET(clock); + tick_tc.tc_name = "tick"; + tick_tc.tc_quality = TICK_QUALITY_UP; + tick_tc.tc_priv = NULL; +#ifdef SMP + /* + * We (try to) sync the (S)TICK timers of APs with the BSP during + * their startup but not afterwards. The resulting drift can + * cause problems when the time is calculated based on (S)TICK + * values read on different CPUs. Thus we bind to the BSP for + * reading the register and use a low quality for the otherwise + * high quality (S)TICK timers in the MP case. + */ + if (cpu_mp_probe()) { + tick_tc.tc_get_timecount = tick_get_timecount_mp; + tick_tc.tc_quality = TICK_QUALITY_MP; + } +#endif + tc_init(&tick_tc); } static inline void @@ -93,27 +175,68 @@ tick_process(struct trapframe *tf) statclock(TRAPF_USERMODE(tf)); } +/* + * NB: the sequence of reading the (S)TICK register, calculating the value + * of the next tick and writing it to the (S)TICK_COMPARE register must not + * be interrupted, not even by an IPI, otherwise a value that is in the past + * could be written in the worst case, causing hardclock to stop. + */ + static void tick_hardclock(struct trapframe *tf) { - u_long adj, ref, tick; - long delta; + u_long adj, tick; + register_t s; + + critical_enter(); + adj = PCPU_GET(tickadj); + s = intr_disable(); + tick = rd(tick); + wr(tick_cmpr, tick + tick_increment - adj, 0); + intr_restore(s); + tick_hardclock_common(tf, tick, adj); + critical_exit(); +} + +static void +tick_hardclock_bbwar(struct trapframe *tf) +{ + u_long adj, tick; register_t s; - int count; - /* - * The sequence of reading the TICK register, calculating the value - * of the next tick and writing it to the TICK_CMPR register must not - * be interrupted, not even by an IPI, otherwise a value that is in - * the past could be written in the worst case, causing hardclock to - * stop. - */ critical_enter(); adj = PCPU_GET(tickadj); s = intr_disable(); tick = rd(tick); wrtickcmpr(tick + tick_increment - adj, 0); intr_restore(s); + tick_hardclock_common(tf, tick, adj); + critical_exit(); +} + +static void +stick_hardclock(struct trapframe *tf) +{ + u_long adj, stick; + register_t s; + + critical_enter(); + adj = PCPU_GET(tickadj); + s = intr_disable(); + stick = rdstick(); + wrstickcmpr(stick + tick_increment - adj, 0); + intr_restore(s); + tick_hardclock_common(tf, stick, adj); + critical_exit(); +} + +static inline void +tick_hardclock_common(struct trapframe *tf, u_long tick, u_long adj) +{ + u_long ref; + long delta; + int count; + ref = PCPU_GET(tickref); delta = tick - ref; count = 0; @@ -139,29 +262,36 @@ tick_hardclock(struct trapframe *tf) } PCPU_SET(tickref, ref); PCPU_SET(tickadj, adj); - critical_exit(); } -void -tick_init(u_long clock) +static u_int +tick_get_timecount_up(struct timecounter *tc) { - tick_freq = clock; - tick_MHz = clock / 1000000; - tick_increment = clock / hz; + return ((u_int)rd(tick)); +} - /* - * UltraSparc II[e,i] based systems come up with the tick interrupt - * enabled and a handler that resets the tick counter, causing DELAY() - * to not work properly when used early in boot. - * UltraSPARC III based systems come up with the system tick interrupt - * enabled, causing an interrupt storm on startup since they are not - * handled. - */ - tick_stop(); +#ifdef SMP +static u_int +tick_get_timecount_mp(struct timecounter *tc) +{ + struct thread *td; + u_int tick; + + td = curthread; + thread_lock(td); + sched_bind(td, 0); + thread_unlock(td); + + tick = tick_get_timecount_up(tc); + + thread_lock(td); + sched_unbind(td); + thread_unlock(td); - set_cputicker(tick_cputicks, tick_freq, 0); + return (tick); } +#endif void tick_start(void) @@ -170,32 +300,34 @@ tick_start(void) register_t s; /* - * Avoid stopping of hardclock in terms of a lost tick interrupt - * by ensuring that the tick period is at least TICK_GRACE ticks. - * This check would be better placed in tick_init(), however we - * have to call tick_init() before cninit() in order to provide - * the low-level console drivers with a working DELAY() which in - * turn means we cannot use panic() in tick_init(). - */ - if (tick_increment < TICK_GRACE) - panic("%s: HZ too high, decrease to at least %ld", __func__, - tick_freq / TICK_GRACE); - - if (curcpu == 0) - intr_setup(PIL_TICK, tick_hardclock, -1, NULL, NULL); - - /* - * Try to make the tick interrupts as synchronously as possible on - * all CPUs to avoid inaccuracies for migrating processes. Leave out - * one tick to make sure that it is not missed. + * Try to make the (S)TICK interrupts as synchronously as possible + * on all CPUs to avoid inaccuracies for migrating processes. Leave + * out one tick to make sure that it is not missed. */ + critical_enter(); PCPU_SET(tickadj, 0); s = intr_disable(); - base = rd(tick); + if (hardclock_use_stick != 0) + base = rdstick(); + else + base = rd(tick); base = roundup(base, tick_increment); PCPU_SET(tickref, base); - wrtickcmpr(base + tick_increment, 0); + if (hardclock_use_stick != 0) + wrstickcmpr(base + tick_increment, 0); + else + wrtickcmpr(base + tick_increment, 0); intr_restore(s); + critical_exit(); +} + +void +tick_clear(void) +{ + + if (cpu_impl >= CPU_IMPL_ULTRASPARCIII) + wrstick(0, 0); + wrpr(tick, 0, 0); } void @@ -203,6 +335,6 @@ tick_stop(void) { if (cpu_impl >= CPU_IMPL_ULTRASPARCIII) - wr(asr25, 1L << 63, 0); + wrstickcmpr(1L << 63, 0); wrtickcmpr(1L << 63, 0); } From nyan at FreeBSD.org Thu Mar 19 06:00:22 2009 From: nyan at FreeBSD.org (Takahashi Yoshihiro) Date: Thu Mar 19 06:01:44 2009 Subject: svn commit: r190034 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb dev/ppc Message-ID: <200903191300.n2JD0LmH061754@svn.freebsd.org> Author: nyan Date: Thu Mar 19 13:00:21 2009 New Revision: 190034 URL: http://svn.freebsd.org/changeset/base/190034 Log: MFC: r182441 Remove unneeded include. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/ppc/ppc_isa.c Modified: stable/7/sys/dev/ppc/ppc_isa.c ============================================================================== --- stable/7/sys/dev/ppc/ppc_isa.c Thu Mar 19 12:55:11 2009 (r190033) +++ stable/7/sys/dev/ppc/ppc_isa.c Thu Mar 19 13:00:21 2009 (r190034) @@ -37,11 +37,6 @@ __FBSDID("$FreeBSD$"); #include #include -#if defined(__i386__) && defined(PC98) -#include -#else -#include -#endif #include #include From nyan at FreeBSD.org Thu Mar 19 06:02:39 2009 From: nyan at FreeBSD.org (Takahashi Yoshihiro) Date: Thu Mar 19 06:02:45 2009 Subject: svn commit: r190035 - in stable/7/sys: . boot contrib/pf dev/cxgb Message-ID: <200903191302.n2JD2b5n061848@svn.freebsd.org> Author: nyan Date: Thu Mar 19 13:02:37 2009 New Revision: 190035 URL: http://svn.freebsd.org/changeset/base/190035 Log: MFC: r186073 Disconnect the efi from pc98. Modified: stable/7/sys/ (props changed) stable/7/sys/boot/Makefile stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/boot/Makefile ============================================================================== --- stable/7/sys/boot/Makefile Thu Mar 19 13:00:21 2009 (r190034) +++ stable/7/sys/boot/Makefile Thu Mar 19 13:02:37 2009 (r190035) @@ -8,7 +8,7 @@ SUBDIR+= ficl .endif # Build EFI library. -.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "ia64" +.if ${MACHINE_ARCH} == "amd64" || ${MACHINE} == "i386" || ${MACHINE_ARCH} == "ia64" SUBDIR+= efi .endif From marius at FreeBSD.org Thu Mar 19 06:08:25 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Thu Mar 19 06:08:31 2009 Subject: svn commit: r190038 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb sparc64/include sparc64/sparc64 Message-ID: <200903191308.n2JD8OnB062106@svn.freebsd.org> Author: marius Date: Thu Mar 19 13:08:24 2009 New Revision: 190038 URL: http://svn.freebsd.org/changeset/base/190038 Log: MFC: r182767 The physical address space of cheetah-class CPUs has been extended to 43 bits so update TD_PA_BITS accordingly. For the most part this increase is transparent to the existing code except for when reading the physical address from ASI_{D,I}TLB_DATA_ACCESS_REG, which we only do in the loader and which was already adjusted in r190002, or from the OFW translations node. While at it, ensure we are only taking valid OFW mapping entries into account. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/sparc64/include/tte.h stable/7/sys/sparc64/sparc64/pmap.c Modified: stable/7/sys/sparc64/include/tte.h ============================================================================== --- stable/7/sys/sparc64/include/tte.h Thu Mar 19 13:03:17 2009 (r190037) +++ stable/7/sys/sparc64/include/tte.h Thu Mar 19 13:08:24 2009 (r190038) @@ -36,21 +36,24 @@ #define TD_SIZE_SHIFT (61) #define TD_SOFT2_SHIFT (50) -#define TD_DIAG_SHIFT (41) +#define TD_DIAG_SF_SHIFT (41) +#define TD_RSVD_CH_SHIFT (43) #define TD_PA_SHIFT (13) #define TD_SOFT_SHIFT (7) #define TD_SIZE_BITS (2) #define TD_SOFT2_BITS (9) -#define TD_DIAG_BITS (9) +#define TD_DIAG_SF_BITS (9) +#define TD_RSVD_CH_BITS (7) #define TD_PA_CH_BITS (30) #define TD_PA_SF_BITS (28) -#define TD_PA_BITS TD_PA_SF_BITS +#define TD_PA_BITS TD_PA_CH_BITS #define TD_SOFT_BITS (6) #define TD_SIZE_MASK ((1UL << TD_SIZE_BITS) - 1) #define TD_SOFT2_MASK ((1UL << TD_SOFT2_BITS) - 1) -#define TD_DIAG_MASK ((1UL << TD_DIAG_BITS) - 1) +#define TD_DIAG_SF_MASK ((1UL << TD_DIAG_SF_BITS) - 1) +#define TD_RSVD_CH_MASK ((1UL << TD_RSVD_CH_BITS) - 1) #define TD_PA_CH_MASK ((1UL << TD_PA_CH_BITS) - 1) #define TD_PA_SF_MASK ((1UL << TD_PA_SF_BITS) - 1) #define TD_PA_MASK ((1UL << TD_PA_BITS) - 1) Modified: stable/7/sys/sparc64/sparc64/pmap.c ============================================================================== --- stable/7/sys/sparc64/sparc64/pmap.c Thu Mar 19 13:03:17 2009 (r190037) +++ stable/7/sys/sparc64/sparc64/pmap.c Thu Mar 19 13:08:24 2009 (r190038) @@ -103,6 +103,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #define PMAP_DEBUG @@ -473,6 +474,8 @@ pmap_bootstrap(vm_offset_t ekva) "translation: start=%#lx size=%#lx tte=%#lx", translations[i].om_start, translations[i].om_size, translations[i].om_tte); + if ((translations[i].om_tte & TD_V) == 0) + continue; if (translations[i].om_start < VM_MIN_PROM_ADDRESS || translations[i].om_start > VM_MAX_PROM_ADDRESS) continue; @@ -483,7 +486,11 @@ pmap_bootstrap(vm_offset_t ekva) tp->tte_vpn = TV_VPN(va, TS_8K); tp->tte_data = ((translations[i].om_tte & - ~(TD_SOFT_MASK << TD_SOFT_SHIFT)) | TD_EXEC) + + ~((TD_SOFT2_MASK << TD_SOFT2_SHIFT) | + (cpu_impl < CPU_IMPL_ULTRASPARCIII ? + (TD_DIAG_SF_MASK << TD_DIAG_SF_SHIFT) : + (TD_RSVD_CH_MASK << TD_RSVD_CH_SHIFT)) | + (TD_SOFT_MASK << TD_SOFT_SHIFT))) | TD_EXEC) + off; } } @@ -603,6 +610,8 @@ pmap_init(void) for (i = 0; i < translations_size; i++) { addr = translations[i].om_start; size = translations[i].om_size; + if ((translations[i].om_tte & TD_V) == 0) + continue; if (addr < VM_MIN_PROM_ADDRESS || addr > VM_MAX_PROM_ADDRESS) continue; result = vm_map_find(kernel_map, NULL, 0, &addr, size, FALSE, From marius at FreeBSD.org Thu Mar 19 06:09:55 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Thu Mar 19 06:10:12 2009 Subject: svn commit: r190039 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb sparc64/include sparc64/sparc64 Message-ID: <200903191309.n2JD9rLm062180@svn.freebsd.org> Author: marius Date: Thu Mar 19 13:09:53 2009 New Revision: 190039 URL: http://svn.freebsd.org/changeset/base/190039 Log: MFC: r182768 Flesh out MMU and cache handling of cheetah-class CPUs. Added: stable/7/sys/sparc64/include/dcr.h - copied unchanged from r182768, head/sys/sparc64/include/dcr.h Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/sparc64/include/cpu.h stable/7/sys/sparc64/sparc64/cheetah.c stable/7/sys/sparc64/sparc64/genassym.c stable/7/sys/sparc64/sparc64/machdep.c stable/7/sys/sparc64/sparc64/mp_machdep.c Modified: stable/7/sys/sparc64/include/cpu.h ============================================================================== --- stable/7/sys/sparc64/include/cpu.h Thu Mar 19 13:08:24 2009 (r190038) +++ stable/7/sys/sparc64/include/cpu.h Thu Mar 19 13:09:53 2009 (r190039) @@ -52,6 +52,7 @@ extern char btext[]; extern char etext[]; +void cheetah_init(void); void cpu_halt(void); void cpu_reset(void); void fork_trampoline(void); Copied: stable/7/sys/sparc64/include/dcr.h (from r182768, head/sys/sparc64/include/dcr.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/sparc64/include/dcr.h Thu Mar 19 13:09:53 2009 (r190039, copy of r182768, head/sys/sparc64/include/dcr.h) @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2008 Marius Strobl + * 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$ + */ + +#ifndef _MACHINE_DCR_H_ +#define _MACHINE_DCR_H_ + +/* + * Definitions for the UltraSPARC-III Depatch Control Register (ASR 18). + */ +#define DCR_MS (1UL << 0) +#define DCR_IFPOE (1UL << 1) +#define DCR_SI (1UL << 3) +#define DCR_RPE (1UL << 4) +#define DCR_BPE (1UL << 5) + +#define DCR_OBSDATA_SHIFT 6 +#define DCR_OBSDATA_CT_BITS 8 +#define DCR_OBSDATA_CT_MASK \ + (((1UL << DCR_OBSDATA_CT_BITS) - 1) << DCR_OBSDATA_SHIFT) + +/* The following bits are valid for the UltraSPARC-III+/IV+ only. */ +#define DCR_IPE (1UL << 5) + +#define DCR_OBSDATA_CTP_BITS 6 +#define DCR_OBSDATA_CTP_MASK \ + (((1UL << DCR_OBSDATA_CTP_BITS) - 1) << DCR_OBSDATA_SHIFT) + +#define DCR_DPE (1UL << 12) + +/* The following bits are valid for the UltraSPARC-IV+ only. */ +#define DCR_BPM_SHIFT 13 +#define DCR_BPM_BITS 2 +#define DCR_BPM_MASK \ + (((1UL << DCR_BPM_BITS) - 1) << DCR_BPM_SHIFT) + +#define DCR_JPE (1UL << 15) +#define DCR_ITPE (1UL << 16) +#define DCR_DTPE (1UL << 17) +#define DCR_PPE (1UL << 18) + +#endif /* _MACHINE_DCR_H_ */ Modified: stable/7/sys/sparc64/sparc64/cheetah.c ============================================================================== --- stable/7/sys/sparc64/sparc64/cheetah.c Thu Mar 19 13:08:24 2009 (r190038) +++ stable/7/sys/sparc64/sparc64/cheetah.c Thu Mar 19 13:09:53 2009 (r190039) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2003 Jake Burkholder. + * Copyright (c) 2005, 2008 Marius Strobl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,9 +40,60 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include +#include #include #include +#include +#include + +/* A FLUSH is required after changing LSU_IC (the address is ignored). */ +#define CHEETAH_FLUSH_LSU_IC() __asm __volatile("flush %%g0" : :) + +#define CHEETAH_ICACHE_TAG_LOWER 0x30 + +/* + * CPU-specific initialization + */ +void +cheetah_init(void) +{ + register_t s; + + /* + * Disable interrupts for safety, this shouldn't be actually + * necessary though. + */ + s = intr_disable(); + + /* + * Ensure DCR_IFPOE is disabled as long as we haven't implemented + * support for it (if ever) as most if not all firmware versions + * apparently turn it on. Not making use of DCR_IFPOE should also + * avoid Cheetah erratum #109. + */ + wr(asr18, rd(asr18) & ~DCR_IFPOE, 0); + + /* Ensure the TSB Extension Registers hold 0 as TSB_Base. */ + + stxa(AA_DMMU_TSB_PEXT_REG, ASI_DMMU, 0); + stxa(AA_IMMU_TSB_PEXT_REG, ASI_IMMU, 0); + membar(Sync); + + stxa(AA_DMMU_TSB_SEXT_REG, ASI_DMMU, 0); + /* + * NB: the secondary context was removed from the iMMU. + */ + membar(Sync); + + stxa(AA_DMMU_TSB_NEXT_REG, ASI_DMMU, 0); + stxa(AA_IMMU_TSB_NEXT_REG, ASI_IMMU, 0); + membar(Sync); + + intr_restore(s); +} /* * Enable level 1 caches. @@ -49,7 +101,15 @@ __FBSDID("$FreeBSD$"); void cheetah_cache_enable(void) { + u_long lsu; + lsu = ldxa(0, ASI_LSU_CTL_REG); + if (cpu_impl == CPU_IMPL_ULTRASPARCIII) { + /* Disable P$ due to Cheetah erratum #18. */ + lsu &= ~LSU_PE; + } + stxa(0, ASI_LSU_CTL_REG, lsu | LSU_IC | LSU_DC); + CHEETAH_FLUSH_LSU_IC(); } /* @@ -58,7 +118,22 @@ cheetah_cache_enable(void) void cheetah_cache_flush(void) { + u_long addr, lsu; + for (addr = 0; addr < PCPU_GET(cache.dc_size); + addr += PCPU_GET(cache.dc_linesize)) + stxa_sync(addr, ASI_DCACHE_TAG, 0); + + /* The I$ must be disabled when flushing it so ensure it's off. */ + lsu = ldxa(0, ASI_LSU_CTL_REG); + stxa(0, ASI_LSU_CTL_REG, lsu & ~(LSU_IC)); + CHEETAH_FLUSH_LSU_IC(); + for (addr = CHEETAH_ICACHE_TAG_LOWER; + addr < PCPU_GET(cache.ic_size) * 2; + addr += PCPU_GET(cache.ic_linesize) * 2) + stxa_sync(addr, ASI_ICACHE_TAG, 0); + stxa(0, ASI_LSU_CTL_REG, lsu); + CHEETAH_FLUSH_LSU_IC(); } /* @@ -87,6 +162,12 @@ cheetah_icache_page_inval(vm_paddr_t pa) } +#define cheetah_dmap_all() do { \ + stxa(TLB_DEMAP_ALL, ASI_DMMU_DEMAP, 0); \ + stxa(TLB_DEMAP_ALL, ASI_IMMU_DEMAP, 0); \ + flush(KERNBASE); \ +} while (0) + /* * Flush all non-locked mappings from the TLB. */ @@ -94,15 +175,20 @@ void cheetah_tlb_flush_nonlocked(void) { - panic("cheetah_tlb_flush_nonlocked"); + cheetah_dmap_all(); } /* * Flush all user mappings from the TLB. */ void -cheetah_tlb_flush_user(void) +cheetah_tlb_flush_user() { - panic("cheetah_tlb_flush_user"); + /* + * Just use cheetah_dmap_all() and accept somes TLB misses + * rather than searching all 1040 D-TLB and 144 I-TLB slots + * for non-kernel mappings. + */ + cheetah_dmap_all(); } Modified: stable/7/sys/sparc64/sparc64/genassym.c ============================================================================== --- stable/7/sys/sparc64/sparc64/genassym.c Thu Mar 19 13:08:24 2009 (r190038) +++ stable/7/sys/sparc64/sparc64/genassym.c Thu Mar 19 13:09:53 2009 (r190039) @@ -66,10 +66,13 @@ ASSYM(PCPU_PAGES, PCPU_PAGES); ASSYM(TAR_VPN_SHIFT, TAR_VPN_SHIFT); -ASSYM(TLB_DEMAP_NUCLEUS, TLB_DEMAP_NUCLEUS); -ASSYM(TLB_DEMAP_PRIMARY, TLB_DEMAP_PRIMARY); +#ifdef SUN4U +ASSYM(TLB_DEMAP_ALL, TLB_DEMAP_ALL); +#endif ASSYM(TLB_DEMAP_CONTEXT, TLB_DEMAP_CONTEXT); +ASSYM(TLB_DEMAP_NUCLEUS, TLB_DEMAP_NUCLEUS); ASSYM(TLB_DEMAP_PAGE, TLB_DEMAP_PAGE); +ASSYM(TLB_DEMAP_PRIMARY, TLB_DEMAP_PRIMARY); ASSYM(INT_SHIFT, INT_SHIFT); ASSYM(PTR_SHIFT, PTR_SHIFT); Modified: stable/7/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 13:08:24 2009 (r190038) +++ stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 13:09:53 2009 (r190039) @@ -255,6 +255,12 @@ sparc64_init(caddr_t mdp, u_long o1, u_l cpu_impl = VER_IMPL(rdpr(ver)); /* + * Do CPU-specific Initialization. + */ + if (cpu_impl >= CPU_IMPL_ULTRASPARCIII) + cheetah_init(); + + /* * Clear (S)TICK timer (including NPT). */ tick_clear(); Modified: stable/7/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/mp_machdep.c Thu Mar 19 13:08:24 2009 (r190038) +++ stable/7/sys/sparc64/sparc64/mp_machdep.c Thu Mar 19 13:09:53 2009 (r190039) @@ -379,6 +379,8 @@ cpu_mp_bootstrap(struct pcpu *pc) volatile struct cpu_start_args *csa; csa = &cpu_start_args; + if (cpu_impl >= CPU_IMPL_ULTRASPARCIII) + cheetah_init(); pmap_map_tsb(); /* * Flush all non-locked TLB entries possibly left over by the From marius at FreeBSD.org Thu Mar 19 06:11:04 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Thu Mar 19 06:11:15 2009 Subject: svn commit: r190040 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb sparc64/sparc64 Message-ID: <200903191311.n2JDB2qB062288@svn.freebsd.org> Author: marius Date: Thu Mar 19 13:11:02 2009 New Revision: 190040 URL: http://svn.freebsd.org/changeset/base/190040 Log: MFC: r182769 Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/sparc64/sparc64/machdep.c stable/7/sys/sparc64/sparc64/mp_machdep.c Modified: stable/7/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 13:09:53 2009 (r190039) +++ stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 13:11:02 2009 (r190040) @@ -374,6 +374,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_l } cache_init(pc); + cache_enable(); uma_set_align(pc->pc_cache.dc_linesize - 1); cpu_block_copy = bcopy; Modified: stable/7/sys/sparc64/sparc64/mp_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/mp_machdep.c Thu Mar 19 13:09:53 2009 (r190039) +++ stable/7/sys/sparc64/sparc64/mp_machdep.c Thu Mar 19 13:11:02 2009 (r190040) @@ -381,6 +381,7 @@ cpu_mp_bootstrap(struct pcpu *pc) csa = &cpu_start_args; if (cpu_impl >= CPU_IMPL_ULTRASPARCIII) cheetah_init(); + cache_enable(); pmap_map_tsb(); /* * Flush all non-locked TLB entries possibly left over by the From marius at FreeBSD.org Thu Mar 19 06:17:23 2009 From: marius at FreeBSD.org (Marius Strobl) Date: Thu Mar 19 06:17:35 2009 Subject: svn commit: r190041 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb sparc64/include sparc64/sparc64 Message-ID: <200903191317.n2JDHJvv062517@svn.freebsd.org> Author: marius Date: Thu Mar 19 13:17:19 2009 New Revision: 190041 URL: http://svn.freebsd.org/changeset/base/190041 Log: MFC: r182773 Use the PROM provided SUNW,set-trap-table to take over the trap table. This is required in order to set obp-control-relinquished within the PROM, allowing to safely read the OFW translations node. Without this, f.e. a `ofwdump -ap` triggers a fatal reset error or worse things on machines based on USIII and beyond. In theory this should allow to remove touching %tba in cpu_setregs(), in practice we seem to currently face a chicken and egg problem when doing so however. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/sparc64/include/trap.h stable/7/sys/sparc64/sparc64/machdep.c stable/7/sys/sparc64/sparc64/trap.c Modified: stable/7/sys/sparc64/include/trap.h ============================================================================== --- stable/7/sys/sparc64/include/trap.h Thu Mar 19 13:11:02 2009 (r190040) +++ stable/7/sys/sparc64/include/trap.h Thu Mar 19 13:17:19 2009 (r190041) @@ -90,6 +90,7 @@ #define T_KERNEL 64 #ifndef LOCORE +void sun4u_set_traptable(void *tba_addr); extern const char *trap_msg[]; #endif Modified: stable/7/sys/sparc64/sparc64/machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 13:11:02 2009 (r190040) +++ stable/7/sys/sparc64/sparc64/machdep.c Thu Mar 19 13:17:19 2009 (r190041) @@ -437,6 +437,16 @@ sparc64_init(caddr_t mdp, u_long o1, u_l cpu_setregs(pc); /* + * Take over the trap table via the PROM. Using the PROM for this + * is necessary in order to set obp-control-relinquished to true + * within the PROM so obtaining /virtual-memory/translations doesn't + * trigger a fatal reset error or worse things further down the road. + * XXX it should be possible to use this soley instead of writing + * %tba in cpu_setregs(). Doing so causes a hang however. + */ + sun4u_set_traptable(tl0_base); + + /* * It's now safe to use the real DELAY(). */ delay_func = delay_tick; Modified: stable/7/sys/sparc64/sparc64/trap.c ============================================================================== --- stable/7/sys/sparc64/sparc64/trap.c Thu Mar 19 13:11:02 2009 (r190040) +++ stable/7/sys/sparc64/sparc64/trap.c Thu Mar 19 13:17:19 2009 (r190041) @@ -70,6 +70,8 @@ __FBSDID("$FreeBSD$"); #endif #include +#include + #include #include #include @@ -227,6 +229,28 @@ int debugger_on_signal = 0; SYSCTL_INT(_debug, OID_AUTO, debugger_on_signal, CTLFLAG_RW, &debugger_on_signal, 0, ""); +/* + * SUNW,set-trap-table allows to take over %tba from the PROM, which + * will turn off interrupts and handle outstanding ones while doing so, + * in a safe way. + */ +void +sun4u_set_traptable(void *tba_addr) +{ + static struct { + cell_t name; + cell_t nargs; + cell_t nreturns; + cell_t tba_addr; + } args = { + (cell_t)"SUNW,set-trap-table", + 2, + }; + + args.tba_addr = (cell_t)tba_addr; + openfirmware(&args); +} + void trap(struct trapframe *tf) { From brueffer at FreeBSD.org Thu Mar 19 06:18:29 2009 From: brueffer at FreeBSD.org (Christian Brueffer) Date: Thu Mar 19 06:18:46 2009 Subject: svn commit: r190042 - stable/7/usr.sbin/sysinstall Message-ID: <200903191318.n2JDISH8062598@svn.freebsd.org> Author: brueffer Date: Thu Mar 19 13:18:28 2009 New Revision: 190042 URL: http://svn.freebsd.org/changeset/base/190042 Log: MFC: r186965 Recognize et(4), igb(4), ixgbe(4) and nxge(4) devices. Correct some minor whitespace in the ae(4) entry. The iwn(4) entry was left out as the driver has not been merged. Modified: stable/7/usr.sbin/sysinstall/ (props changed) stable/7/usr.sbin/sysinstall/devices.c Modified: stable/7/usr.sbin/sysinstall/devices.c ============================================================================== --- stable/7/usr.sbin/sysinstall/devices.c Thu Mar 19 13:17:19 2009 (r190041) +++ stable/7/usr.sbin/sysinstall/devices.c Thu Mar 19 13:18:28 2009 (r190042) @@ -93,7 +93,7 @@ static struct _devname { DISK("mfid%d", "LSI MegaRAID SAS array", 4), FLOPPY("fd%d", "floppy drive unit A", 4), SERIAL("cuad%d", "%s on device %s (COM%d)", 16), - NETWORK("ae", "Attansic/Atheros L2 FastEthernet"), + NETWORK("ae", "Attansic/Atheros L2 Fast Ethernet"), NETWORK("age", "Attansic/Atheros L1 Gigabit Ethernet"), NETWORK("ale", "Atheros AR8121/AR8113/AR8114 PCIe Ethernet"), NETWORK("an", "Aironet 4500/4800 802.11 wireless adapter"), @@ -115,12 +115,15 @@ static struct _devname { NETWORK("ed", "Novell NE1000/2000; 3C503; NE2000-compatible PCMCIA"), NETWORK("ep", "3Com 3C509 Ethernet card/3C589 PCMCIA"), NETWORK("em", "Intel(R) PRO/1000 Ethernet card"), + NETWORK("et", "Agere ET1310 based PCI Express Gigabit Ethernet card"), NETWORK("ex", "Intel EtherExpress Pro/10 Ethernet card"), NETWORK("fe", "Fujitsu MB86960A/MB86965A Ethernet card"), NETWORK("gem", "Apple GMAC or Sun ERI/GEM Ethernet adapter"), NETWORK("hme", "Sun HME (Happy Meal Ethernet) Ethernet adapter"), NETWORK("ie", "AT&T StarLAN 10 and EN100; 3Com