Date: Sun, 10 Dec 2006 04:27:16 GMT From: Matt Jacob <mjacob@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 111362 for review Message-ID: <200612100427.kBA4RGAx066583@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=111362 Change 111362 by mjacob@newisp on 2006/12/10 04:26:34 IFC1. Affected files ... .. //depot/projects/newisp/dev/isp/isp_freebsd.c#34 integrate .. //depot/projects/newisp/dev/isp/isp_pci.c#21 integrate .. //depot/projects/newisp/dev/isp/isp_sbus.c#9 integrate .. //depot/projects/newisp/dev/isp/ispmbox.h#16 integrate .. //depot/projects/newisp/dev/ispfw/ispfw.c#3 integrate .. //depot/projects/newisp/dev/mpt/mpt_cam.c#22 integrate .. //depot/projects/newisp/dev/mpt/mpt_pci.c#7 integrate .. //depot/projects/newisp/dev/sound/pci/hda/hdac.c#6 integrate .. //depot/projects/newisp/fs/msdosfs/msdosfs_vfsops.c#4 integrate .. //depot/projects/newisp/fs/unionfs/union_subr.c#3 integrate .. //depot/projects/newisp/fs/unionfs/union_vfsops.c#4 integrate .. //depot/projects/newisp/fs/unionfs/union_vnops.c#3 integrate .. //depot/projects/newisp/sparc64/sparc64/elf_machdep.c#2 integrate .. //depot/projects/newisp/sun4v/sun4v/pmap.c#7 integrate Differences ... ==== //depot/projects/newisp/dev/isp/isp_freebsd.c#34 (text+ko) ==== @@ -29,7 +29,7 @@ * Platform (FreeBSD) dependent common attachment code for Qlogic adapters. */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/isp/isp_freebsd.c,v 1.129 2006/12/05 07:50:23 mjacob Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/isp/isp_freebsd.c,v 1.130 2006/12/09 01:30:05 mjacob Exp $"); #include <dev/isp/isp_freebsd.h> #include <sys/unistd.h> #include <sys/kthread.h> ==== //depot/projects/newisp/dev/isp/isp_pci.c#21 (text+ko) ==== @@ -30,7 +30,7 @@ * FreeBSD Version. */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/isp/isp_pci.c,v 1.127 2006/11/18 03:53:16 mjacob Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/isp/isp_pci.c,v 1.128 2006/12/10 03:41:48 mjacob Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -352,10 +352,7 @@ }; static devclass_t isp_devclass; DRIVER_MODULE(isp, pci, isp_pci_driver, isp_devclass, 0, 0); -#if __FreeBSD_version >= 700000 -MODULE_DEPEND(isp, ispfw, 1, 1, 1); -MODULE_DEPEND(isp, firmware, 1, 1, 1); -#else +#if __FreeBSD_version < 700000 extern ispfwfunc *isp_get_firmware_p; #endif ==== //depot/projects/newisp/dev/isp/isp_sbus.c#9 (text+ko) ==== @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/isp/isp_sbus.c,v 1.23 2006/11/02 03:21:31 mjacob Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/isp/isp_sbus.c,v 1.24 2006/12/10 03:41:48 mjacob Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -113,9 +113,7 @@ }; static devclass_t isp_devclass; DRIVER_MODULE(isp, sbus, isp_sbus_driver, isp_devclass, 0, 0); -#if __FreeBSD_version >= 700000 -MODULE_DEPEND(isp, firmware, 1, 1, 1); -#else +#if __FreeBSD_version < 700000 extern ispfwfunc *isp_get_firmware_p; #endif ==== //depot/projects/newisp/dev/isp/ispmbox.h#16 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/dev/isp/ispmbox.h,v 1.55 2006/11/18 03:53:16 mjacob Exp $ */ +/* $FreeBSD: src/sys/dev/isp/ispmbox.h,v 1.56 2006/12/09 01:33:55 mjacob Exp $ */ /*- * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters. * @@ -638,7 +638,7 @@ typedef struct { isphdr_t ms_header; uint32_t ms_handle; - uint16_t ms_nphdl; /* XXX: Note, this is for 2K Logins only */ + uint16_t ms_nphdl; /* handle in high byte for !2k f/w */ uint16_t ms_status; uint16_t ms_flags; uint16_t ms_reserved1; /* low 8 bits */ ==== //depot/projects/newisp/dev/ispfw/ispfw.c#3 (text+ko) ==== @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/ispfw/ispfw.c,v 1.18 2006/08/26 18:39:18 mjacob Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/ispfw/ispfw.c,v 1.19 2006/12/10 03:42:57 mjacob Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -52,7 +52,7 @@ #ifdef __sparc64__ #define ISP_1000 1 #endif -#define MODULE_NAME "isp" +#define MODULE_NAME "ispfw" #endif #if defined(ISP_1040) || defined(ISP_1040_IT) ==== //depot/projects/newisp/dev/mpt/mpt_cam.c#22 (text+ko) ==== @@ -94,7 +94,7 @@ * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_cam.c,v 1.45 2006/12/07 22:02:28 mjacob Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_cam.c,v 1.46 2006/12/10 01:13:56 mjacob Exp $"); #include <dev/mpt/mpt.h> #include <dev/mpt/mpt_cam.h> @@ -179,6 +179,7 @@ }; DECLARE_MPT_PERSONALITY(mpt_cam, SI_ORDER_SECOND); +MODULE_DEPEND(mpt_cam, cam, 1, 1, 1); int mpt_cam_probe(struct mpt_softc *mpt) ==== //depot/projects/newisp/dev/mpt/mpt_pci.c#7 (text+ko) ==== @@ -99,7 +99,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_pci.c,v 1.44 2006/11/19 23:24:52 mjacob Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/mpt/mpt_pci.c,v 1.45 2006/12/10 01:13:56 mjacob Exp $"); #include <dev/mpt/mpt.h> #include <dev/mpt/mpt_cam.h> @@ -210,6 +210,7 @@ }; static devclass_t mpt_devclass; DRIVER_MODULE(mpt, pci, mpt_driver, mpt_devclass, 0, 0); +MODULE_DEPEND(mpt, pci, 1, 1, 1); MODULE_VERSION(mpt, 1); static int ==== //depot/projects/newisp/dev/sound/pci/hda/hdac.c#6 (text+ko) ==== @@ -80,10 +80,10 @@ #include "mixer_if.h" -#define HDA_DRV_TEST_REV "20061203_0035" +#define HDA_DRV_TEST_REV "20061210_0036" #define HDA_WIDGET_PARSER_REV 1 -SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/hda/hdac.c,v 1.12 2006/12/02 17:12:24 ariff Exp $"); +SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/hda/hdac.c,v 1.13 2006/12/09 17:52:54 ariff Exp $"); #undef HDA_DEBUG_ENABLED #define HDA_DEBUG_ENABLED 1 @@ -242,10 +242,11 @@ #define HDA_QUIRK_GPIO0 (1 << 0) #define HDA_QUIRK_GPIO1 (1 << 1) #define HDA_QUIRK_GPIO2 (1 << 2) -#define HDA_QUIRK_SOFTPCMVOL (1 << 15) -#define HDA_QUIRK_FIXEDRATE (1 << 16) -#define HDA_QUIRK_FORCESTEREO (1 << 17) -#define HDA_QUIRK_EAPDINV (1 << 18) +#define HDA_QUIRK_GPIOFLUSH (1 << 15) +#define HDA_QUIRK_SOFTPCMVOL (1 << 16) +#define HDA_QUIRK_FIXEDRATE (1 << 17) +#define HDA_QUIRK_FORCESTEREO (1 << 18) +#define HDA_QUIRK_EAPDINV (1 << 19) static const struct { char *key; @@ -254,6 +255,7 @@ { "gpio0", HDA_QUIRK_GPIO0 }, { "gpio1", HDA_QUIRK_GPIO1 }, { "gpio2", HDA_QUIRK_GPIO2 }, + { "gpioflush", HDA_QUIRK_GPIOFLUSH }, { "softpcmvol", HDA_QUIRK_SOFTPCMVOL }, { "fixedrate", HDA_QUIRK_FIXEDRATE }, { "forcestereo", HDA_QUIRK_FORCESTEREO }, @@ -448,33 +450,38 @@ uint32_t model; uint32_t id; int type; + int inverted; nid_t hpnid; nid_t spkrnid[8]; nid_t eapdnid; } hdac_hp_switch[] = { /* Specific OEM models */ - { HP_V3000_SUBVENDOR, HDA_CODEC_CXVENICE, HDAC_HP_SWITCH_CTL, + { HP_V3000_SUBVENDOR, HDA_CODEC_CXVENICE, HDAC_HP_SWITCH_CTL, 0, 17, { 16, -1 }, 16 }, - { HP_NX7400_SUBVENDOR, HDA_CODEC_AD1981HD, HDAC_HP_SWITCH_CTL, + { HP_NX7400_SUBVENDOR, HDA_CODEC_AD1981HD, HDAC_HP_SWITCH_CTL, 0, 6, { 5, -1 }, 5 }, - { HP_NX6310_SUBVENDOR, HDA_CODEC_AD1981HD, HDAC_HP_SWITCH_CTL, + { HP_NX6310_SUBVENDOR, HDA_CODEC_AD1981HD, HDAC_HP_SWITCH_CTL, 0, 6, { 5, -1 }, 5 }, - { DELL_D820_SUBVENDOR, HDA_CODEC_STAC9220, HDAC_HP_SWITCH_CTRL, + { DELL_D820_SUBVENDOR, HDA_CODEC_STAC9220, HDAC_HP_SWITCH_CTRL, 0, 13, { 14, -1 }, -1 }, - { DELL_I1300_SUBVENDOR, HDA_CODEC_STAC9220, HDAC_HP_SWITCH_CTRL, + { DELL_I1300_SUBVENDOR, HDA_CODEC_STAC9220, HDAC_HP_SWITCH_CTRL, 0, 13, { 14, -1 }, -1 }, - { APPLE_INTEL_MAC, HDA_CODEC_STAC9221, HDAC_HP_SWITCH_CTRL, + { APPLE_INTEL_MAC, HDA_CODEC_STAC9221, HDAC_HP_SWITCH_CTRL, 0, 10, { 13, -1 }, -1 }, + { LENOVO_3KN100_SUBVENDOR, HDA_CODEC_AD1986A, HDAC_HP_SWITCH_CTL, 1, + 26, { 27, -1 }, -1 }, /* * All models that at least come from the same vendor with * simmilar codec. */ - { HP_ALL_SUBVENDOR, HDA_CODEC_CXVENICE, HDAC_HP_SWITCH_CTL, + { HP_ALL_SUBVENDOR, HDA_CODEC_CXVENICE, HDAC_HP_SWITCH_CTL, 0, 17, { 16, -1 }, 16 }, - { HP_ALL_SUBVENDOR, HDA_CODEC_AD1981HD, HDAC_HP_SWITCH_CTL, + { HP_ALL_SUBVENDOR, HDA_CODEC_AD1981HD, HDAC_HP_SWITCH_CTL, 0, 6, { 5, -1 }, 5 }, - { DELL_ALL_SUBVENDOR, HDA_CODEC_STAC9220, HDAC_HP_SWITCH_CTRL, + { DELL_ALL_SUBVENDOR, HDA_CODEC_STAC9220, HDAC_HP_SWITCH_CTRL, 0, 13, { 14, -1 }, -1 }, + { LENOVO_ALL_SUBVENDOR, HDA_CODEC_AD1986A, HDAC_HP_SWITCH_CTL, 1, + 26, { 27, -1 }, -1 }, }; #define HDAC_HP_SWITCH_LEN \ (sizeof(hdac_hp_switch) / sizeof(hdac_hp_switch[0])) @@ -683,6 +690,7 @@ hdac_hp_switch[i].hpnid, res); ); res >>= 31; + res ^= hdac_hp_switch[i].inverted; switch (hdac_hp_switch[i].type) { case HDAC_HP_SWITCH_CTL: @@ -3457,11 +3465,11 @@ { HDA_MATCH_ALL, HDA_MATCH_ALL, HDA_QUIRK_FORCESTEREO, 0 }, { ACER_ALL_SUBVENDOR, HDA_MATCH_ALL, - HDA_QUIRK_GPIO1, 0 }, + HDA_QUIRK_GPIO0, 0 }, { ASUS_M5200_SUBVENDOR, HDA_CODEC_ALC880, + HDA_QUIRK_GPIO0, 0 }, + { MEDION_MD95257_SUBVENDOR, HDA_CODEC_ALC880, HDA_QUIRK_GPIO1, 0 }, - { MEDION_MD95257_SUBVENDOR, HDA_CODEC_ALC880, - HDA_QUIRK_GPIO2, 0 }, { ASUS_U5F_SUBVENDOR, HDA_CODEC_AD1986A, HDA_QUIRK_EAPDINV, 0 }, { ASUS_A8JC_SUBVENDOR, HDA_CODEC_AD1986A, @@ -3470,6 +3478,8 @@ HDA_QUIRK_EAPDINV, 0 }, { SAMSUNG_Q1_SUBVENDOR, HDA_CODEC_AD1986A, HDA_QUIRK_EAPDINV, 0 }, + { APPLE_INTEL_MAC, HDA_CODEC_STAC9221, + HDA_QUIRK_GPIO0 | HDA_QUIRK_GPIO1, 0 }, { HDA_MATCH_ALL, HDA_CODEC_CXVENICE, 0, HDA_QUIRK_FORCESTEREO }, { HDA_MATCH_ALL, HDA_CODEC_STACXXXX, @@ -4096,23 +4106,55 @@ cad = devinfo->codec->cad; if (cfl & HDA_COMMIT_GPIO) { - if (sc->pci_subvendor == APPLE_INTEL_MAC) { - uint32_t gdata, gmask, gdir; + uint32_t gdata, gmask, gdir; + int commitgpio = 0; - gdata = hdac_command(sc, - HDA_CMD_GET_GPIO_DATA(cad, devinfo->nid), - cad); - gmask = hdac_command(sc, - HDA_CMD_GET_GPIO_ENABLE_MASK(cad, devinfo->nid), - cad); - gdir = hdac_command(sc, - HDA_CMD_GET_GPIO_DIRECTION(cad, devinfo->nid), - cad); - gdata |= 0x03; - gmask |= 0x03; - gdir |= 0x03; + gdata = 0; + gmask = 0; + gdir = 0; + + if (sc->pci_subvendor == APPLE_INTEL_MAC) hdac_command(sc, HDA_CMD_12BIT(cad, devinfo->nid, 0x7e7, 0), cad); + + if (devinfo->function.audio.quirks & HDA_QUIRK_GPIOFLUSH) + commitgpio = 1; + else { + for (i = 0; i < HDA_GPIO_MAX; i++) { + if (!(devinfo->function.audio.quirks & + (1 << i))) + continue; + if (commitgpio == 0) { + commitgpio = 1; + gdata = hdac_command(sc, + HDA_CMD_GET_GPIO_DATA(cad, + devinfo->nid), cad); + gmask = hdac_command(sc, + HDA_CMD_GET_GPIO_ENABLE_MASK(cad, + devinfo->nid), cad); + gdir = hdac_command(sc, + HDA_CMD_GET_GPIO_DIRECTION(cad, + devinfo->nid), cad); + HDA_BOOTVERBOSE( + device_printf(sc->dev, + "GPIO init: data=0x%08x " + "mask=0x%08x dir=0x%08x\n", + gdata, gmask, gdir); + ); + } + gdata |= 1 << i; + gmask |= 1 << i; + gdir |= 1 << i; + } + } + + if (commitgpio != 0) { + HDA_BOOTVERBOSE( + device_printf(sc->dev, + "GPIO commit: data=0x%08x mask=0x%08x " + "dir=0x%08x\n", + gdata, gmask, gdir); + ); hdac_command(sc, HDA_CMD_SET_GPIO_ENABLE_MASK(cad, devinfo->nid, gmask), cad); @@ -4122,21 +4164,6 @@ hdac_command(sc, HDA_CMD_SET_GPIO_DATA(cad, devinfo->nid, gdata), cad); - } else { - for (i = 0; i < HDA_GPIO_MAX; i++) { - if (!(devinfo->function.audio.quirks & - (1 << i))) - continue; - hdac_command(sc, - HDA_CMD_SET_GPIO_ENABLE_MASK(cad, - devinfo->nid, i), cad); - hdac_command(sc, - HDA_CMD_SET_GPIO_DIRECTION(cad, - devinfo->nid, i), cad); - hdac_command(sc, - HDA_CMD_SET_GPIO_DATA(cad, devinfo->nid, - i), cad); - } } } ==== //depot/projects/newisp/fs/msdosfs/msdosfs_vfsops.c#4 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/fs/msdosfs/msdosfs_vfsops.c,v 1.154 2006/11/06 13:41:57 rwatson Exp $ */ +/* $FreeBSD: src/sys/fs/msdosfs/msdosfs_vfsops.c,v 1.155 2006/12/09 01:49:19 rodrigc Exp $ */ /* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */ /*- @@ -262,11 +262,15 @@ pmp = VFSTOMSDOSFS(mp); if (vfs_flagopt(mp->mnt_optnew, "export", NULL, 0)) { - /* Process export requests. */ - if ((pmp->pm_flags & MSDOSFS_LARGEFS) != 0) + /* + * Forbid export requests if filesystem has + * MSDOSFS_LARGEFS flag set. + */ + if ((pmp->pm_flags & MSDOSFS_LARGEFS) != 0) { + vfs_mount_error(mp, + "MSDOSFS_LARGEFS flag set, cannot export"); return (EOPNOTSUPP); - else - return (0); + } } if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) && vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0)) { ==== //depot/projects/newisp/fs/unionfs/union_subr.c#3 (text+ko) ==== @@ -33,7 +33,7 @@ * SUCH DAMAGE. * * @(#)union_subr.c 8.20 (Berkeley) 5/20/95 - * $FreeBSD: src/sys/fs/unionfs/union_subr.c,v 1.87 2006/12/02 19:35:56 rodrigc Exp $ + * $FreeBSD: src/sys/fs/unionfs/union_subr.c,v 1.88 2006/12/09 16:27:50 rodrigc Exp $ */ #include <sys/param.h> @@ -317,7 +317,7 @@ { int vfslocked; struct unionfs_node *unp; - struct unionfs_node_status *unsp; + struct unionfs_node_status *unsp, *unsp_tmp; struct vnode *lvp; struct vnode *uvp; @@ -367,7 +367,8 @@ free(unp->un_path, M_UNIONFSPATH); unp->un_path = NULL; } - while ((unsp = LIST_FIRST(&(unp->un_unshead))), NULL != unsp) { + + LIST_FOREACH_SAFE(unsp, &(unp->un_unshead), uns_list, unsp_tmp) { LIST_REMOVE(unsp, uns_list); free(unsp, M_TEMP); } ==== //depot/projects/newisp/fs/unionfs/union_vfsops.c#4 (text+ko) ==== @@ -33,7 +33,7 @@ * SUCH DAMAGE. * * @(#)union_vfsops.c 8.20 (Berkeley) 5/20/95 - * $FreeBSD: src/sys/fs/unionfs/union_vfsops.c,v 1.79 2006/12/02 19:35:56 rodrigc Exp $ + * $FreeBSD: src/sys/fs/unionfs/union_vfsops.c,v 1.81 2006/12/09 17:24:18 rodrigc Exp $ */ #include <sys/param.h> @@ -139,14 +139,18 @@ copymode = UNIONFS_TRADITIONAL; /* default */ ndp = &nd; - if (mp->mnt_flag & MNT_ROOTFS) + if (mp->mnt_flag & MNT_ROOTFS) { + vfs_mount_error(mp, "Cannot union mount root filesystem"); return (EOPNOTSUPP); + } /* * Update is a no operation. */ - if (mp->mnt_flag & MNT_UPDATE) + if (mp->mnt_flag & MNT_UPDATE) { + vfs_mount_error(mp, "unionfs does not support mount update"); return (EOPNOTSUPP); + } /* * Get argument @@ -394,12 +398,10 @@ unionfs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td) { struct unionfs_mount *ump; - struct unionfs_node *unp; struct vnode *vp; ump = MOUNTTOUNIONFSMOUNT(mp); vp = ump->um_rootvp; - unp = VTOUNIONFS(vp); UNIONFSDEBUG("unionfs_root: rootvp=%p locked=%x\n", vp, VOP_ISLOCKED(vp, td)); ==== //depot/projects/newisp/fs/unionfs/union_vnops.c#3 (text+ko) ==== @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)union_vnops.c 8.32 (Berkeley) 6/23/95 - * $FreeBSD: src/sys/fs/unionfs/union_vnops.c,v 1.136 2006/12/02 22:30:30 rodrigc Exp $ + * $FreeBSD: src/sys/fs/unionfs/union_vnops.c,v 1.138 2006/12/09 16:51:09 rodrigc Exp $ * */ @@ -872,9 +872,11 @@ UNIONFS_INTERNAL_DEBUG("unionfs_ioctl: enter\n"); + vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, ap->a_td); unp = VTOUNIONFS(ap->a_vp); unionfs_get_node_status(unp, ap->a_td, &unsp); ovp = (unsp->uns_upper_opencnt ? unp->un_uppervp : unp->un_lowervp); + VOP_UNLOCK(ap->a_vp, 0, ap->a_td); if (ovp == NULLVP) return (EBADF); @@ -894,9 +896,11 @@ struct unionfs_node_status *unsp; struct vnode *ovp; + vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, ap->a_td); unp = VTOUNIONFS(ap->a_vp); unionfs_get_node_status(unp, ap->a_td, &unsp); ovp = (unsp->uns_upper_opencnt ? unp->un_uppervp : unp->un_lowervp); + VOP_UNLOCK(ap->a_vp, 0, ap->a_td); if (ovp == NULLVP) return (EBADF); @@ -1462,6 +1466,10 @@ uio->uio_offset = 0; } + if (lvp == NULLVP) { + error = EBADF; + goto unionfs_readdir_exit; + } /* read lower */ error = VOP_READDIR(lvp, uio, ap->a_cred, ap->a_eofflag, ap->a_ncookies, ap->a_cookies); ==== //depot/projects/newisp/sparc64/sparc64/elf_machdep.c#2 (text+ko) ==== @@ -36,7 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * from: NetBSD: mdreloc.c,v 1.5 2001/04/25 12:24:51 kleink Exp - * $FreeBSD: src/sys/sparc64/sparc64/elf_machdep.c,v 1.21 2005/12/26 21:23:55 sobomax Exp $ + * $FreeBSD: src/sys/sparc64/sparc64/elf_machdep.c,v 1.22 2006/12/10 04:18:03 kmacy Exp $ */ #include <sys/param.h> @@ -310,7 +310,7 @@ return (0); if (rtype == R_SPARC_JMP_SLOT || rtype == R_SPARC_COPY || - rtype > R_SPARC_UA16) + rtype >= (sizeof(reloc_target_bitmask)/sizeof(long))) return (-1); if (RELOC_UNALIGNED(rtype)) ==== //depot/projects/newisp/sun4v/sun4v/pmap.c#7 (text+ko) ==== @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/sun4v/sun4v/pmap.c,v 1.18 2006/12/04 19:35:40 kmacy Exp $"); +__FBSDID("$FreeBSD: src/sys/sun4v/sun4v/pmap.c,v 1.22 2006/12/10 04:14:29 kmacy Exp $"); #include "opt_kstack_pages.h" #include "opt_msgbuf.h" @@ -134,7 +134,8 @@ static struct vm_object pvzone_obj; static int pv_entry_count = 0, pv_entry_max = 0, pv_entry_high_water = 0; int pmap_debug = 0; -int pmap_debug_range = 0; +static int pmap_debug_range = 1; +static int use_256M_pages = 1; static struct mtx pmap_ctx_lock; static uint16_t ctx_stack[PMAP_CONTEXT_MAX]; @@ -443,12 +444,12 @@ { struct pmap *pm; vm_offset_t off, va; - vm_paddr_t pa, kernel_hash_pa, nucleus_memory_start; + vm_paddr_t pa, tsb_8k_pa, tsb_4m_pa, kernel_hash_pa, nucleus_memory_start; vm_size_t physsz, virtsz, kernel_hash_shift; ihandle_t pmem, vmem; - int i, sz, j; - uint64_t tsb_8k_size, tsb_4m_size, error, physmem_tunable; - vm_paddr_t real_phys_avail[128]; + int i, j, k, sz; + uint64_t tsb_8k_size, tsb_4m_size, error, physmem_tunable, physmemstart_tunable; + vm_paddr_t real_phys_avail[128], tmp_phys_avail[128]; if ((vmem = OF_finddevice("/virtual-memory")) == -1) panic("pmap_bootstrap: finddevice /virtual-memory"); @@ -469,24 +470,26 @@ KDPRINTF("om_size=%ld om_start=%lx om_tte=%lx\n", translations[i].om_size, translations[i].om_start, translations[i].om_tte); - if (translations[i].om_size == PAGE_SIZE_4M && - (translations[i].om_start >= KERNBASE && - translations[i].om_start <= KERNBASE + 3*PAGE_SIZE_4M)) { - KDPRINTF("mapping permanent translation\n"); - pa = TTE_GET_PA(translations[i].om_tte); - error = hv_mmu_map_perm_addr(translations[i].om_start, - KCONTEXT, pa | TTE_KERNEL | VTD_4M, MAP_ITLB | MAP_DTLB); - if (error != H_EOK) - panic("map_perm_addr returned error=%ld", error); - - if ((nucleus_memory_start == 0) || (pa < nucleus_memory_start)) - nucleus_memory_start = pa; - nucleus_mappings[permanent_mappings++] = pa; - nucleus_memory += PAGE_SIZE_4M; + if ((translations[i].om_start >= KERNBASE) && + (translations[i].om_start <= KERNBASE + 3*PAGE_SIZE_4M)) { + for (j = 0; j < translations[i].om_size; j += PAGE_SIZE_4M) { + KDPRINTF("mapping permanent translation\n"); + pa = TTE_GET_PA(translations[i].om_tte) + j; + va = translations[i].om_start + j; + error = hv_mmu_map_perm_addr(va, KCONTEXT, + pa | TTE_KERNEL | VTD_4M, MAP_ITLB | MAP_DTLB); + if (error != H_EOK) + panic("map_perm_addr returned error=%ld", error); + + if ((nucleus_memory_start == 0) || (pa < nucleus_memory_start)) + nucleus_memory_start = pa; + printf("nucleus_mappings[%d] = 0x%lx\n", permanent_mappings, pa); + nucleus_mappings[permanent_mappings++] = pa; + nucleus_memory += PAGE_SIZE_4M; #ifdef SMP - mp_add_nucleus_mapping(translations[i].om_start, - pa | TTE_KERNEL | VTD_4M); + mp_add_nucleus_mapping(va, pa|TTE_KERNEL|VTD_4M); #endif + } } } @@ -511,15 +514,20 @@ CTR0(KTR_PMAP, "pmap_bootstrap: physical memory"); qsort(mra, sz, sizeof (*mra), mr_cmp); - physmem_tunable = physmem = physsz = 0; + physmemstart_tunable = physmem_tunable = physmem = physsz = 0; + if (TUNABLE_ULONG_FETCH("hw.physmemstart", &physmemstart_tunable)) { + KDPRINTF("desired physmemstart=0x%lx\n", physmemstart_tunable); + } if (TUNABLE_ULONG_FETCH("hw.physmem", &physmem_tunable)) { physmem = atop(physmem_tunable); KDPRINTF("desired physmem=0x%lx\n", physmem_tunable); } - - for (i = 0; i < 128; i++) - real_phys_avail[i] = 0; + if ((physmem_tunable != 0) && (physmemstart_tunable != 0)) + physmem_tunable += physmemstart_tunable; + + bzero(real_phys_avail, sizeof(real_phys_avail)); + bzero(tmp_phys_avail, sizeof(tmp_phys_avail)); for (i = 0, j = 0; i < sz; i++) { uint64_t size; @@ -531,12 +539,11 @@ uint64_t newstart, roundup; newstart = ((mra[i].mr_start + (PAGE_SIZE_4M-1)) & ~PAGE_MASK_4M); roundup = newstart - mra[i].mr_start; - size = mra[i].mr_size - roundup; + size = (mra[i].mr_size - roundup) & ~PAGE_MASK_4M; + mra[i].mr_start = newstart; if (size < PAGE_SIZE_4M) continue; - size = (size & ~PAGE_MASK_4M); mra[i].mr_size = size; - mra[i].mr_start = newstart; } real_phys_avail[j] = mra[i].mr_start; if (physmem_tunable != 0 && ((physsz + mra[i].mr_size) >= physmem_tunable)) { @@ -549,67 +556,96 @@ real_phys_avail[j + 1] = mra[i].mr_start + mra[i].mr_size; j += 2; } - physmem = btoc(physsz); - for (i = 0; real_phys_avail[i] != 0; i += 2) { - if (real_phys_avail[i] == (nucleus_memory_start + nucleus_memory)) - real_phys_avail[i] -= nucleus_memory; - if (real_phys_avail[i + 1] == nucleus_memory_start) - real_phys_avail[i + 1] += nucleus_memory; - - if (real_phys_avail[i + 1] == real_phys_avail[i + 2]) { - real_phys_avail[i + 1] = real_phys_avail[i + 3]; - for (j = i + 2; real_phys_avail[j] != 0; j += 2) { - real_phys_avail[j] = real_phys_avail[j + 2]; - real_phys_avail[j + 1] = real_phys_avail[j + 3]; - } - } - } - - + physmem = btoc(physsz - physmemstart_tunable); /* - * This is for versions of OFW that would allocate us memory + * This is needed for versions of OFW that would allocate us memory * and then forget to remove it from the available ranges ... + * as well as for compensating for the above move of nucleus pages */ - - for (i = 0, j = 0; i < sz; i++) { - vm_paddr_t start = mra[i].mr_start; - uint64_t size = mra[i].mr_size; - CTR2(KTR_PMAP, "start=%#lx size=%#lx\n", mra[i].mr_start, mra[i].mr_size); - KDPRINTF("start=%#lx size=%#lx\n", mra[i].mr_start, mra[i].mr_size); - - if (mra[i].mr_size < PAGE_SIZE_4M) - continue; + for (i = 0, j = 0; real_phys_avail[i] != 0; i += 2) { + vm_paddr_t start = real_phys_avail[i]; + uint64_t size = real_phys_avail[i + 1] - real_phys_avail[i]; + CTR2(KTR_PMAP, "start=%#lx size=%#lx\n", start,size); + KDPRINTF("real_phys start=%#lx size=%#lx\n", start, size); /* * Is kernel memory at the beginning of range? */ - if (nucleus_memory_start == mra[i].mr_start) { - mra[i].mr_start += nucleus_memory; - mra[i].mr_size -= nucleus_memory; + if (nucleus_memory_start == start) { + start = start + nucleus_memory; } /* * Is kernel memory at the end of range? */ if (nucleus_memory_start == (start + size - nucleus_memory)) - mra[i].mr_size -= nucleus_memory; + size -= nucleus_memory; + + if (physmemstart_tunable != 0 && + ((mra[i].mr_start + mra[i].mr_size) < physmemstart_tunable)) + continue; + if (physmemstart_tunable != 0 && + ((start < physmemstart_tunable))) { + size -= (physmemstart_tunable - start); + start = physmemstart_tunable; + } /* * Is kernel memory in the middle somewhere? */ - if ((nucleus_memory_start > start) && (nucleus_memory_start < (start + size))) { + if ((nucleus_memory_start > start) && + (nucleus_memory_start < (start + size))) { uint64_t firstsize = (nucleus_memory_start - start); phys_avail[j] = start; phys_avail[j+1] = nucleus_memory_start; + start = nucleus_memory_start + nucleus_memory; size = size - firstsize - nucleus_memory; - mra[i].mr_start = nucleus_memory_start + nucleus_memory; - mra[i].mr_size = size; j += 2; } - phys_avail[j] = mra[i].mr_start; - phys_avail[j + 1] = mra[i].mr_start + mra[i].mr_size; + phys_avail[j] = start; + phys_avail[j + 1] = start + size; j += 2; } + + /* + * Merge nucleus memory in to real_phys_avail + * + */ + for (i = 0; real_phys_avail[i] != 0; i += 2) { + if (real_phys_avail[i] == nucleus_memory_start + nucleus_memory) + real_phys_avail[i] -= nucleus_memory; + + if (real_phys_avail[i + 1] == nucleus_memory_start) + real_phys_avail[i + 1] += nucleus_memory; + + if (real_phys_avail[i + 1] == real_phys_avail[i + 2]) { + real_phys_avail[i + 1] = real_phys_avail[i + 3]; + for (k = i + 2; real_phys_avail[k] != 0; k += 2) { + real_phys_avail[k] = real_phys_avail[k + 2]; + real_phys_avail[k + 1] = real_phys_avail[k + 3]; + } + } + } + for (i = 0; phys_avail[i] != 0; i += 2) + if (pmap_debug_range || pmap_debug) + printf("phys_avail[%d]=0x%lx phys_avail[%d]=0x%lx\n", + i, phys_avail[i], i+1, phys_avail[i+1]); + /* + * Shuffle the memory range containing the 256MB page with + * nucleus_memory to the beginning of the phys_avail array + * so that physical memory from that page is preferentially + * allocated first + */ + for (j = 0; phys_avail[j] != 0; j += 2) + if (nucleus_memory_start < phys_avail[j]) + break; + for (i = j, k = 0; phys_avail[i] != 0; k++, i++) + tmp_phys_avail[k] = phys_avail[i]; + for (i = 0; i < j; i++) + tmp_phys_avail[k + i] = phys_avail[i]; + for (i = 0; i < 128; i++) + phys_avail[i] = tmp_phys_avail[i]; + for (i = 0; real_phys_avail[i] != 0; i += 2) if (pmap_debug_range || pmap_debug) printf("real_phys_avail[%d]=0x%lx real_phys_avail[%d]=0x%lx\n", @@ -658,17 +694,21 @@ tsb_8k_size = PAGE_SIZE_4M; #endif - pa = pmap_bootstrap_alloc(tsb_8k_size); - if (pa & PAGE_MASK_4M) + tsb_8k_pa = pmap_bootstrap_alloc(tsb_8k_size); + if (tsb_8k_pa & PAGE_MASK_4M) panic("pmap_bootstrap: tsb unaligned\n"); - KDPRINTF("tsb_8k_size is 0x%lx, tsb_8k_pa is 0x%lx\n", tsb_8k_size, pa); + KDPRINTF("tsb_8k_size is 0x%lx, tsb_8k_pa is 0x%lx\n", tsb_8k_size, tsb_8k_pa); + + tsb_4m_size = (virtsz >> (PAGE_SHIFT_4M - TTE_SHIFT)) << 3; + tsb_4m_pa = pmap_bootstrap_alloc(tsb_4m_size); + kernel_td[TSB8K_INDEX].hti_idxpgsz = TTE8K; kernel_td[TSB8K_INDEX].hti_assoc = 1; kernel_td[TSB8K_INDEX].hti_ntte = (tsb_8k_size >> TTE_SHIFT); kernel_td[TSB8K_INDEX].hti_ctx_index = 0; kernel_td[TSB8K_INDEX].hti_pgszs = TSB8K; kernel_td[TSB8K_INDEX].hti_rsvd = 0; - kernel_td[TSB8K_INDEX].hti_ra = pa; + kernel_td[TSB8K_INDEX].hti_ra = tsb_8k_pa; /* * Initialize kernel's private TSB from 8K page TSB @@ -680,7 +720,7 @@ kernel_pmap->pm_tsb.hti_ctx_index = 0; kernel_pmap->pm_tsb.hti_pgszs = TSB8K; kernel_pmap->pm_tsb.hti_rsvd = 0; - kernel_pmap->pm_tsb.hti_ra = pa; + kernel_pmap->pm_tsb.hti_ra = tsb_8k_pa; kernel_pmap->pm_tsb_ra = vtophys((vm_offset_t)&kernel_pmap->pm_tsb); tsb_set_scratchpad_kernel(&kernel_pmap->pm_tsb); @@ -690,18 +730,15 @@ * currently (not by design) used for permanent mappings */ - tsb_4m_size = (virtsz >> (PAGE_SHIFT_4M - TTE_SHIFT)) << 3; - pa = pmap_bootstrap_alloc(tsb_4m_size); - KDPRINTF("tsb_4m_pa is 0x%lx tsb_4m_size is 0x%lx\n", pa, tsb_4m_size); + KDPRINTF("tsb_4m_pa is 0x%lx tsb_4m_size is 0x%lx\n", tsb_4m_pa, tsb_4m_size); kernel_td[TSB4M_INDEX].hti_idxpgsz = TTE4M; kernel_td[TSB4M_INDEX].hti_assoc = 1; kernel_td[TSB4M_INDEX].hti_ntte = (tsb_4m_size >> TTE_SHIFT); kernel_td[TSB4M_INDEX].hti_ctx_index = 0; - kernel_td[TSB4M_INDEX].hti_pgszs = TSB4M; + kernel_td[TSB4M_INDEX].hti_pgszs = TSB4M|TSB256M; kernel_td[TSB4M_INDEX].hti_rsvd = 0; - kernel_td[TSB4M_INDEX].hti_ra = pa; - + kernel_td[TSB4M_INDEX].hti_ra = tsb_4m_pa; /* * allocate MMU fault status areas for all CPUS */ @@ -765,8 +802,8 @@ } } - error = hv_mmu_tsb_ctx0(MAX_TSB_INFO, vtophys((vm_offset_t)&kernel_td)); - if (error != H_EOK) + if ((error = hv_mmu_tsb_ctx0(MAX_TSB_INFO, + vtophys((vm_offset_t)kernel_td))) != H_EOK) panic("failed to set ctx0 TSBs error: %ld", error); #ifdef SMP @@ -777,10 +814,23 @@ * */ for (i = 0, pa = real_phys_avail[i]; pa != 0; i += 2, pa = real_phys_avail[i]) { + vm_paddr_t tag_pa = 0, next_pa = 0; + uint64_t size_bits = VTD_4M; while (pa < real_phys_avail[i + 1]) { + if (use_256M_pages && + (pa & PAGE_MASK_256M) == 0 && + ((pa + PAGE_SIZE_256M) <= real_phys_avail[i + 1])) { + tag_pa = pa; + size_bits = VTD_256M; + next_pa = pa + PAGE_SIZE_256M; + } else if (next_pa <= pa) { + tag_pa = pa; + size_bits = VTD_4M; + } tsb_assert_invalid(&kernel_td[TSB4M_INDEX], TLB_PHYS_TO_DIRECT(pa)); tsb_set_tte_real(&kernel_td[TSB4M_INDEX], TLB_PHYS_TO_DIRECT(pa), - TLB_PHYS_TO_DIRECT(pa), pa | TTE_KERNEL | VTD_4M, 0); + TLB_PHYS_TO_DIRECT(pa), + tag_pa | TTE_KERNEL | size_bits, 0); pa += PAGE_SIZE_4M; } } @@ -848,11 +898,6 @@ tte_hash_insert(pm->pm_hash, TLB_PHYS_TO_DIRECT(pa), pa | TTE_KERNEL | VTD_4M); #endif - /* XXX relies on the fact that memory ranges only get smaller */ - for (i = 0; phys_avail[i + 2] != 0; i += 2) - if (phys_avail[i + 1] - phys_avail[i] < PAGE_SIZE_4M) - phys_avail[i] = phys_avail[i+1] = 0; - } @@ -1231,14 +1276,19 @@ void *ptr; m = NULL; - while (m == NULL) { - m = vm_page_alloc_contig(npages, phys_avail[0], - phys_avail[1], alignment, (1UL<<34)); + while (m == NULL) { + for (i = 0; phys_avail[i + 1] != 0; i += 2) { + m = vm_page_alloc_contig(npages, phys_avail[i], + phys_avail[i + 1], alignment, (1UL<<34)); + if (m) + goto found; + } if (m == NULL) { printf("vm_page_alloc_contig failed - waiting to retry\n"); VM_WAIT; } } +found: for (i = 0, tm = m; i < npages; i++, tm++) { tm->wire_count++; if ((tm->flags & PG_ZERO) == 0)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200612100427.kBA4RGAx066583>