PERFORCE change 124751 for review

Roman Divacky rdivacky at FreeBSD.org
Sun Aug 5 14:11:09 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=124751

Change 124751 by rdivacky at rdivacky_witten on 2007/08/05 21:10:54

	IFC

Affected files ...

.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/conf/NOTES#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/conf/options#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/dev/adlink/adlink.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/dev/dc/if_dc.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/dev/dc/if_dcreg.h#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/dev/re/if_re.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/fs/msdosfs/msdosfs_fat.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/fs/msdosfs/msdosfs_vfsops.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/ia64/ia64/clock.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/ia64/ia64/machdep.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/ia64/ia64/mp_machdep.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/ia64/ia64/pmap.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/ia64/include/ia64_cpu.h#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/kern/kern_switch.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/kern/sched_ule.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/net/bridgestp.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/net/bridgestp.h#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/netinet/ip_input.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/netinet/ip_ipsec.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/netinet/ip_ipsec.h#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/netinet6/ip6_ipsec.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/netinet6/ip6_ipsec.h#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/sparc64/include/iommureg.h#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/sparc64/include/iommuvar.h#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/sparc64/pci/psycho.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/sparc64/pci/psychoreg.h#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/sparc64/sbus/sbus.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/sparc64/sbus/sbusreg.h#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/sparc64/sparc64/iommu.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/vm/device_pager.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/vm/phys_pager.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/vm/swap_pager.c#2 integrate
.. //depot/projects/soc2007/rdivacky/linux_fixes/sys/vm/vm_pager.c#2 integrate

Differences ...

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/conf/NOTES#2 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/NOTES,v 1.1447 2007/07/24 15:35:01 scottl Exp $
+# $FreeBSD: src/sys/conf/NOTES,v 1.1448 2007/08/05 16:16:15 bz Exp $
 #
 # NOTES -- Lines that can be cut/pasted into kernel and hints configs.
 #
@@ -501,15 +501,15 @@
 options 	IPSEC			#IP security (requires device crypto)
 #options 	IPSEC_DEBUG		#debug for IP security
 #
-# Set IPSEC_FILTERGIF to force packets coming through a gif tunnel
-# to be processed by any configured packet filtering (ipfw, ipf).
-# The default is that packets coming from a tunnel are _not_ processed;
+# Set IPSEC_FILTERTUNNEL to force packets coming through a tunnel
+# to be processed by any configured packet filtering twice.
+# The default is that packets coming out of a tunnel are _not_ processed;
 # they are assumed trusted.
 #
 # IPSEC history is preserved for such packets, and can be filtered
 # using ipfw(8)'s 'ipsec' keyword, when this option is enabled.
 #
-#options 	IPSEC_FILTERGIF		#filter ipsec packets from a tunnel
+#options 	IPSEC_FILTERTUNNEL	#filter ipsec packets from a tunnel
 
 options 	IPX			#IPX/SPX communications protocols
 

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/conf/options#2 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/options,v 1.603 2007/07/24 15:35:01 scottl Exp $
+# $FreeBSD: src/sys/conf/options,v 1.604 2007/08/05 16:16:15 bz Exp $
 #
 #        On the handling of kernel options
 #
@@ -362,7 +362,7 @@
 INET6			opt_inet6.h
 IPSEC			opt_ipsec.h
 IPSEC_DEBUG		opt_ipsec.h
-IPSEC_FILTERGIF		opt_ipsec.h
+IPSEC_FILTERTUNNEL	opt_ipsec.h
 IPDIVERT
 DUMMYNET		opt_ipdn.h
 IPFILTER		opt_ipfilter.h

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/dev/adlink/adlink.c#2 (text+ko) ====

@@ -43,7 +43,7 @@
 
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/adlink/adlink.c,v 1.16 2007/02/23 12:18:29 piso Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/adlink/adlink.c,v 1.17 2007/08/04 17:43:11 kib Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -119,6 +119,7 @@
 
 static struct cdevsw adlink_cdevsw = {
 	.d_version =	D_VERSION,
+	.d_flags =	D_NEEDGIANT,
 	.d_ioctl =	adlink_ioctl,
 	.d_mmap =	adlink_mmap,
 	.d_name =	"adlink",

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/dev/dc/if_dc.c#2 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/dc/if_dc.c,v 1.191 2007/02/23 12:18:37 piso Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/dc/if_dc.c,v 1.192 2007/08/05 11:28:19 marius Exp $");
 
 /*
  * DEC "tulip" clone ethernet driver. Supports the DEC/Intel 21143
@@ -294,7 +294,6 @@
 static void dc_apply_fixup(struct dc_softc *, int);
 
 static void dc_dma_map_txbuf(void *, bus_dma_segment_t *, int, bus_size_t, int);
-static void dc_dma_map_rxbuf(void *, bus_dma_segment_t *, int, bus_size_t, int);
 
 #ifdef DC_USEIOSPACE
 #define DC_RES			SYS_RES_IOPORT
@@ -2424,29 +2423,6 @@
 	return (0);
 }
 
-static void
-dc_dma_map_rxbuf(arg, segs, nseg, mapsize, error)
-	void *arg;
-	bus_dma_segment_t *segs;
-	int nseg;
-	bus_size_t mapsize;
-	int error;
-{
-	struct dc_softc *sc;
-	struct dc_desc *c;
-
-	sc = arg;
-	c = &sc->dc_ldata->dc_rx_list[sc->dc_cdata.dc_rx_cur];
-	if (error) {
-		sc->dc_cdata.dc_rx_err = error;
-		return;
-	}
-
-	KASSERT(nseg == 1, ("wrong number of segments, should be 1"));
-	sc->dc_cdata.dc_rx_err = 0;
-	c->dc_data = htole32(segs->ds_addr);
-}
-
 /*
  * Initialize an RX descriptor and attach an MBUF cluster.
  */
@@ -2455,7 +2431,8 @@
 {
 	struct mbuf *m_new;
 	bus_dmamap_t tmp;
-	int error;
+	bus_dma_segment_t segs[1];
+	int error, nseg;
 
 	if (alloc) {
 		m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
@@ -2478,17 +2455,14 @@
 
 	/* No need to remap the mbuf if we're reusing it. */
 	if (alloc) {
-		sc->dc_cdata.dc_rx_cur = i;
-		error = bus_dmamap_load_mbuf(sc->dc_mtag, sc->dc_sparemap,
-		    m_new, dc_dma_map_rxbuf, sc, 0);
+		error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, sc->dc_sparemap,
+		    m_new, segs, &nseg, 0);
+		KASSERT(nseg == 1, ("wrong number of segments, should be 1"));
 		if (error) {
 			m_freem(m_new);
 			return (error);
 		}
-		if (sc->dc_cdata.dc_rx_err != 0) {
-			m_freem(m_new);
-			return (sc->dc_cdata.dc_rx_err);
-		}
+		sc->dc_ldata->dc_rx_list[i].dc_data = htole32(segs->ds_addr);
 		bus_dmamap_unload(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i]);
 		tmp = sc->dc_cdata.dc_rx_map[i];
 		sc->dc_cdata.dc_rx_map[i] = sc->dc_sparemap;
@@ -2865,12 +2839,11 @@
 		sc->dc_cdata.dc_tx_cnt--;
 		DC_INC(idx, DC_TX_LIST_CNT);
 	}
+	sc->dc_cdata.dc_tx_cons = idx;
 
-	if (idx != sc->dc_cdata.dc_tx_cons) {
-	    	/* Some buffers have been freed. */
-		sc->dc_cdata.dc_tx_cons = idx;
+	if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt > DC_TX_LIST_RSVD)
 		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-	}
+
 	if (sc->dc_cdata.dc_tx_cnt == 0)
 		sc->dc_wdog_timer = 0;
 }
@@ -3161,10 +3134,8 @@
 	int cur, first, frag, i;
 
 	sc = arg;
-	if (error) {
-		sc->dc_cdata.dc_tx_err = error;
+	if (error)
 		return;
-	}
 
 	first = cur = frag = sc->dc_cdata.dc_tx_prod;
 	for (i = 0; i < nseg; i++) {
@@ -3217,7 +3188,7 @@
 	/*
 	 * If there's no way we can send any packets, return now.
 	 */
-	if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt < 6)
+	if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt <= DC_TX_LIST_RSVD)
 		return (ENOBUFS);
 
 	/*
@@ -3229,27 +3200,30 @@
 	for (m = *m_head; m != NULL; m = m->m_next)
 		chainlen++;
 
-	if ((chainlen > DC_TX_LIST_CNT / 4) ||
-	    ((DC_TX_LIST_CNT - (chainlen + sc->dc_cdata.dc_tx_cnt)) < 6)) {
+	m = NULL;
+	if ((sc->dc_flags & DC_TX_COALESCE && ((*m_head)->m_next != NULL ||
+	    sc->dc_flags & DC_TX_ALIGN)) || (chainlen > DC_TX_LIST_CNT / 4) ||
+	    (DC_TX_LIST_CNT - (chainlen + sc->dc_cdata.dc_tx_cnt) <=
+	    DC_TX_LIST_RSVD)) {
 		m = m_defrag(*m_head, M_DONTWAIT);
-		if (m == NULL)
+		if (m == NULL) {
+			m_freem(*m_head);
+			*m_head = NULL;
 			return (ENOBUFS);
+		}
 		*m_head = m;
 	}
-
-	/*
-	 * Start packing the mbufs in this chain into
-	 * the fragment pointers. Stop when we run out
-	 * of fragments or hit the end of the mbuf chain.
-	 */
 	idx = sc->dc_cdata.dc_tx_prod;
 	sc->dc_cdata.dc_tx_mapping = *m_head;
 	error = bus_dmamap_load_mbuf(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx],
 	    *m_head, dc_dma_map_txbuf, sc, 0);
-	if (error)
-		return (error);
-	if (sc->dc_cdata.dc_tx_err != 0)
-		return (sc->dc_cdata.dc_tx_err);
+	if (error != 0 || sc->dc_cdata.dc_tx_err != 0) {
+		if (m != NULL) {
+			m_freem(m);
+			*m_head = NULL;
+		}
+		return (error != 0 ? error : sc->dc_cdata.dc_tx_err);
+	}
 	bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx],
 	    BUS_DMASYNC_PREWRITE);
 	bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap,
@@ -3279,7 +3253,7 @@
 dc_start_locked(struct ifnet *ifp)
 {
 	struct dc_softc *sc;
-	struct mbuf *m_head = NULL, *m;
+	struct mbuf *m_head = NULL;
 	unsigned int queued = 0;
 	int idx;
 
@@ -3300,20 +3274,9 @@
 		if (m_head == NULL)
 			break;
 
-		if (sc->dc_flags & DC_TX_COALESCE &&
-		    (m_head->m_next != NULL ||
-		     sc->dc_flags & DC_TX_ALIGN)) {
-			m = m_defrag(m_head, M_DONTWAIT);
-			if (m == NULL) {
-				IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
-				ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+		if (dc_encap(sc, &m_head)) {
+			if (m_head == NULL)
 				break;
-			} else {
-				m_head = m;
-			}
-		}
-
-		if (dc_encap(sc, &m_head)) {
 			IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
 			ifp->if_drv_flags |= IFF_DRV_OACTIVE;
 			break;

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/dev/dc/if_dcreg.h#2 (text+ko) ====

@@ -29,7 +29,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/dc/if_dcreg.h,v 1.53 2006/12/06 01:56:38 marius Exp $
+ * $FreeBSD: src/sys/dev/dc/if_dcreg.h,v 1.54 2007/08/05 11:28:19 marius Exp $
  */
 
 /*
@@ -461,6 +461,7 @@
 #define DC_RX_LIST_CNT		64
 #endif
 #define DC_TX_LIST_CNT		256
+#define DC_TX_LIST_RSVD		5
 #define DC_MIN_FRAMELEN		60
 #define DC_RXLEN		1536
 
@@ -496,8 +497,6 @@
 	int			dc_tx_prod;
 	int			dc_tx_cons;
 	int			dc_tx_cnt;
-	int			dc_rx_err;
-	int			dc_rx_cur;
 	int			dc_rx_prod;
 };
 

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/dev/re/if_re.c#2 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/re/if_re.c,v 1.93 2007/07/27 00:43:12 yongari Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/re/if_re.c,v 1.94 2007/08/05 11:20:33 marius Exp $");
 
 /*
  * RealTek 8139C+/8169/8169S/8110S/8168/8111/8101E PCI NIC driver
@@ -1005,6 +1005,7 @@
 		}
 		cmdstat = segs[i].ds_len;
 		totlen += segs[i].ds_len;
+		d->rl_vlanctl = 0;
 		d->rl_bufaddr_lo = htole32(RL_ADDR_LO(segs[i].ds_addr));
 		d->rl_bufaddr_hi = htole32(RL_ADDR_HI(segs[i].ds_addr));
 		if (i == 0)

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/fs/msdosfs/msdosfs_fat.c#2 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/fs/msdosfs/msdosfs_fat.c,v 1.42 2007/07/20 16:21:47 bde Exp $ */
+/* $FreeBSD: src/sys/fs/msdosfs/msdosfs_fat.c,v 1.43 2007/08/03 23:13:50 bde Exp $ */
 /*	$NetBSD: msdosfs_fat.c,v 1.28 1997/11/17 15:36:49 ws Exp $	*/
 
 /*-
@@ -376,7 +376,7 @@
 				+ ffs(pmp->pm_inusemap[cn / N_INUSEBITS]
 				      ^ (u_int)-1) - 1;
 		}
-		if (bread(pmp->pm_devvp, pmp->pm_fsinfo, pmp->pm_bpcluster,
+		if (bread(pmp->pm_devvp, pmp->pm_fsinfo, pmp->pm_BytesPerSec,
 		    NOCRED, &bpn) != 0) {
 			/*
 			 * Ignore the error, but turn off FSInfo update for the future.

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/fs/msdosfs/msdosfs_vfsops.c#2 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/fs/msdosfs/msdosfs_vfsops.c,v 1.167 2007/07/23 07:10:17 bde Exp $ */
+/* $FreeBSD: src/sys/fs/msdosfs/msdosfs_vfsops.c,v 1.169 2007/08/05 12:58:34 bde Exp $ */
 /*	$NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $	*/
 
 /*-
@@ -649,12 +649,15 @@
 	bp = NULL;
 
 	/*
-	 * Check FSInfo.
+	 * Check the fsinfo sector if we have one.  Silently fix up our
+	 * in-core copy of fp->fsinxtfree if it is unknown (0xffffffff)
+	 * or too large.  Ignore fp->fsinfree for now, since we need to
+	 * read the entire FAT anyway to fill the inuse map.
 	 */
 	if (pmp->pm_fsinfo) {
 		struct fsinfo *fp;
 
-		if ((error = bread(devvp, pmp->pm_fsinfo, pmp->pm_bpcluster,
+		if ((error = bread(devvp, pmp->pm_fsinfo, pmp->pm_BytesPerSec,
 		    NOCRED, &bp)) != 0)
 			goto error_exit;
 		fp = (struct fsinfo *)bp->b_data;
@@ -662,7 +665,7 @@
 		    && !bcmp(fp->fsisig2, "rrAa", 4)
 		    && !bcmp(fp->fsisig3, "\0\0\125\252", 4)) {
 			pmp->pm_nxtfree = getulong(fp->fsinxtfree);
-			if (pmp->pm_nxtfree == 0xffffffff)
+			if (pmp->pm_nxtfree > pmp->pm_maxcluster)
 				pmp->pm_nxtfree = CLUST_FIRST;
 		} else
 			pmp->pm_fsinfo = 0;
@@ -671,15 +674,14 @@
 	}
 
 	/*
-	 * Check and validate (or perhaps invalidate?) the fsinfo structure?
+	 * Finish initializing pmp->pm_nxtfree (just in case the first few
+	 * sectors aren't properly reserved in the FAT).  This completes
+	 * the fixup for fp->fsinxtfree, and fixes up the zero-initialized
+	 * value if there is no fsinfo.  We will use pmp->pm_nxtfree
+	 * internally even if there is no fsinfo.
 	 */
-	if (pmp->pm_fsinfo && pmp->pm_nxtfree > pmp->pm_maxcluster) {
-		printf(
-		"Next free cluster in FSInfo (%lu) exceeds maxcluster (%lu)\n",
-		    pmp->pm_nxtfree, pmp->pm_maxcluster);
-		error = EINVAL;
-		goto error_exit;
-	}
+	if (pmp->pm_nxtfree < CLUST_FIRST)
+		pmp->pm_nxtfree = CLUST_FIRST;
 
 	/*
 	 * Allocate memory for the bitmap of allocated clusters, and then

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/ia64/ia64/clock.c#2 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/ia64/ia64/clock.c,v 1.31 2007/07/23 09:42:31 dwmalone Exp $");
+__FBSDID("$FreeBSD: src/sys/ia64/ia64/clock.c,v 1.32 2007/08/04 19:28:19 marcel Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -72,6 +72,7 @@
 	PCPU_SET(clock, ia64_get_itc());
 	ia64_set_itm(PCPU_GET(clock) + ia64_clock_reload);
 	ia64_set_itv(CLOCK_VECTOR);	/* highest priority class */
+	ia64_srlz_d();
 }
 
 /*

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/ia64/ia64/machdep.c#2 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/ia64/ia64/machdep.c,v 1.224 2007/07/30 22:12:53 marcel Exp $");
+__FBSDID("$FreeBSD: src/sys/ia64/ia64/machdep.c,v 1.225 2007/08/04 19:33:27 marcel Exp $");
 
 #include "opt_compat.h"
 #include "opt_ddb.h"
@@ -449,13 +449,13 @@
 
 	__asm __volatile("mov   %0=psr" : "=r"(psr));
 	__asm __volatile("rsm   psr.ic|psr.i");
-	__asm __volatile("srlz.i");
-	__asm __volatile("mov   cr.ifa=%0" :: "r"(vhpt));
-	__asm __volatile("mov   cr.itir=%0" :: "r"(IA64_ID_PAGE_SHIFT << 2));
+	ia64_srlz_i();
+	ia64_set_ifa(vhpt);
+	ia64_set_itir(IA64_ID_PAGE_SHIFT << 2);
+	ia64_srlz_d();
 	__asm __volatile("itr.d dtr[%0]=%1" :: "r"(2), "r"(pte));
-	__asm __volatile("srlz.d");             /* XXX not needed. */
 	__asm __volatile("mov   psr.l=%0" :: "r" (psr));
-	__asm __volatile("srlz.i");
+	ia64_srlz_i();
 }
 
 void
@@ -476,15 +476,15 @@
 
 	__asm __volatile("mov	%0=psr" : "=r"(psr));
 	__asm __volatile("rsm	psr.ic|psr.i");
-	__asm __volatile("srlz.i");
-	__asm __volatile("mov	cr.ifa=%0" ::
-	    "r"(IA64_PHYS_TO_RR7(ia64_pal_base)));
-	__asm __volatile("mov	cr.itir=%0" :: "r"(IA64_ID_PAGE_SHIFT << 2));
+	ia64_srlz_i();
+	ia64_set_ifa(IA64_PHYS_TO_RR7(ia64_pal_base));
+	ia64_set_itir(IA64_ID_PAGE_SHIFT << 2);
+	ia64_srlz_d();
 	__asm __volatile("itr.d	dtr[%0]=%1" :: "r"(1), "r"(pte));
-	__asm __volatile("srlz.d");		/* XXX not needed. */
+	ia64_srlz_d();
 	__asm __volatile("itr.i	itr[%0]=%1" :: "r"(1), "r"(pte));
 	__asm __volatile("mov	psr.l=%0" :: "r" (psr));
-	__asm __volatile("srlz.i");
+	ia64_srlz_i();
 }
 
 void
@@ -502,14 +502,15 @@
 
 	__asm __volatile("mov	%0=psr" : "=r"(psr));
 	__asm __volatile("rsm	psr.ic|psr.i");
-	__asm __volatile("srlz.i");
-	__asm __volatile("mov	cr.ifa=%0" :: "r"(VM_MAX_ADDRESS));
-	__asm __volatile("mov	cr.itir=%0" :: "r"(PAGE_SHIFT << 2));
+	ia64_srlz_i();
+	ia64_set_ifa(VM_MAX_ADDRESS);
+	ia64_set_itir(PAGE_SHIFT << 2);
+	ia64_srlz_d();
 	__asm __volatile("itr.d	dtr[%0]=%1" :: "r"(3), "r"(pte));
-	__asm __volatile("srlz.d");		/* XXX not needed. */
+	ia64_srlz_d();
 	__asm __volatile("itr.i	itr[%0]=%1" :: "r"(3), "r"(pte));
 	__asm __volatile("mov	psr.l=%0" :: "r" (psr));
-	__asm __volatile("srlz.i");
+	ia64_srlz_i();
 
 	/* Expose the mapping to userland in ar.k5 */
 	ia64_set_k5(VM_MAX_ADDRESS);
@@ -827,6 +828,7 @@
 #endif
 
 	ia64_set_tpr(0);
+	ia64_srlz_d();
 
 	/*
 	 * Save our current context so that we have a known (maybe even

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/ia64/ia64/mp_machdep.c#2 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/ia64/ia64/mp_machdep.c,v 1.65 2007/07/30 22:12:53 marcel Exp $");
+__FBSDID("$FreeBSD: src/sys/ia64/ia64/mp_machdep.c,v 1.66 2007/08/04 19:52:10 marcel Exp $");
 
 #include "opt_kstack_pages.h"
 
@@ -91,8 +91,8 @@
 	ia64_set_k4((intptr_t)pcpup);
 
 	map_vhpt(ap_vhpt);
-	__asm __volatile("mov cr.pta=%0;; srlz.i;;" ::
-	    "r" (ap_vhpt + (1<<8) + (pmap_vhpt_log2size<<2) + 1));
+	ia64_set_pta(ap_vhpt + (1 << 8) + (pmap_vhpt_log2size << 2) + 1);
+	ia64_srlz_i();
 
 	ap_awake = 1;
 	ap_delay = 0;
@@ -106,8 +106,6 @@
 	while (ap_spin)
 		DELAY(0);
 
-	__asm __volatile("ssm psr.i;; srlz.d;;");
-
 	/* Initialize curthread. */
 	KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread"));
 	PCPU_SET(curthread, PCPU_GET(idlethread));
@@ -125,11 +123,13 @@
 
 	CTR1(KTR_SMP, "SMP: cpu%d launched", PCPU_GET(cpuid));
 
-	ia64_set_tpr(0);
-
 	/* kick off the clock on this AP */
 	pcpu_initclock();
 
+	ia64_set_tpr(0);
+	ia64_srlz_d();
+	enable_intr();
+
 	sched_throw(NULL);
 	/* NOTREACHED */
 }

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/ia64/ia64/pmap.c#2 (text+ko) ====

@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/ia64/ia64/pmap.c,v 1.190 2007/07/30 22:12:53 marcel Exp $");
+__FBSDID("$FreeBSD: src/sys/ia64/ia64/pmap.c,v 1.191 2007/08/04 19:36:14 marcel Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -450,8 +450,9 @@
 	}
 
 	map_vhpt(pmap_vhpt_base[0]);
-	__asm __volatile("mov cr.pta=%0;; srlz.i;;" ::
-	    "r" (pmap_vhpt_base[0] + (1<<8) + (pmap_vhpt_log2size<<2) + 1));
+	ia64_set_pta(pmap_vhpt_base[0] + (1 << 8) +
+	    (pmap_vhpt_log2size << 2) + 1);
+	ia64_srlz_i();
 
 	virtual_avail = VM_MIN_KERNEL_ADDRESS;
 	virtual_end = VM_MAX_KERNEL_ADDRESS;
@@ -480,6 +481,7 @@
 	 */
 	ia64_set_rr(IA64_RR_BASE(6), (6 << 8) | (IA64_ID_PAGE_SHIFT << 2));
 	ia64_set_rr(IA64_RR_BASE(7), (7 << 8) | (IA64_ID_PAGE_SHIFT << 2));
+	ia64_srlz_d();
 
 	/*
 	 * Clear out any random TLB entries left over from booting.
@@ -2254,7 +2256,7 @@
 		atomic_set_32(&pm->pm_active, PCPU_GET(cpumask));
 	}
 	PCPU_SET(current_pmap, pm);
-	__asm __volatile("srlz.d");
+	ia64_srlz_d();
 
 out:
 	critical_exit();

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/ia64/include/ia64_cpu.h#2 (text+ko) ====

@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/ia64/include/ia64_cpu.h,v 1.21 2007/05/27 19:02:47 marcel Exp $
+ * $FreeBSD: src/sys/ia64/include/ia64_cpu.h,v 1.23 2007/08/05 18:19:38 marcel Exp $
  */
 
 #ifndef _MACHINE_IA64_CPU_H_
@@ -400,7 +400,7 @@
 static __inline void
 ia64_set_rr(u_int64_t rrbase, u_int64_t v)
 {
-	__asm __volatile("mov rr[%0]=%1;; srlz.d;;"
+	__asm __volatile("mov rr[%0]=%1"
 			 :: "r"(rrbase), "r"(v) : "memory");
 }
 
@@ -428,6 +428,18 @@
 	__asm __volatile("rsm psr.dfh;; srlz.d");
 }
 
+static __inline void
+ia64_srlz_d(void)
+{
+	__asm __volatile("srlz.d");
+}
+
+static __inline void
+ia64_srlz_i(void)
+{
+	__asm __volatile("srlz.i;;");
+}
+
 #endif /* !LOCORE */
 
 #endif /* _MACHINE_IA64_CPU_H_ */

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/kern/kern_switch.c#2 (text+ko) ====

@@ -26,7 +26,7 @@
 
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_switch.c,v 1.132 2007/07/19 08:58:40 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_switch.c,v 1.133 2007/08/03 23:35:35 jeff Exp $");
 
 #include "opt_sched.h"
 
@@ -192,7 +192,7 @@
 			thread_lock(td);
 			td->td_critnest--;
 			SCHED_STAT_INC(switch_owepreempt);
-			mi_switch(SW_INVOL, NULL);
+			mi_switch(SW_INVOL|SW_PREEMPT, NULL);
 			thread_unlock(td);
 		}
 	} else

==== //depot/projects/soc2007/rdivacky/linux_fixes/sys/kern/sched_ule.c#2 (text+ko) ====

@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/sched_ule.c,v 1.202 2007/07/19 20:03:15 jeff Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/sched_ule.c,v 1.204 2007/08/04 01:21:28 jeff Exp $");
 
 #include "opt_hwpmc_hooks.h"
 #include "opt_sched.h"
@@ -183,7 +183,7 @@
  * locking in sched_pickcpu();
  */
 struct tdq {
-	struct mtx	tdq_lock;		/* Protects all fields below. */
+	struct mtx	*tdq_lock;		/* Pointer to group lock. */
 	struct runq	tdq_realtime;		/* real-time run queue. */
 	struct runq	tdq_timeshare;		/* timeshare run queue. */
 	struct runq	tdq_idle;		/* Queue of IDLE threads. */
@@ -198,7 +198,6 @@
 #else
 	int		tdq_sysload;		/* For loadavg, !ITHD load. */
 #endif
-	char		tdq_name[16];		/* lock name. */
 } __aligned(64);
 
 
@@ -212,13 +211,15 @@
  * load balancer.
  */
 struct tdq_group {
-	int	tdg_cpus;		/* Count of CPUs in this tdq group. */
-	cpumask_t tdg_cpumask;		/* Mask of cpus in this group. */
-	cpumask_t tdg_idlemask;		/* Idle cpus in this group. */
-	cpumask_t tdg_mask;		/* Bit mask for first cpu. */
-	int	tdg_load;		/* Total load of this group. */
+	struct mtx	tdg_lock;	/* Protects all fields below. */
+	int		tdg_cpus;	/* Count of CPUs in this tdq group. */
+	cpumask_t 	tdg_cpumask;	/* Mask of cpus in this group. */
+	cpumask_t 	tdg_idlemask;	/* Idle cpus in this group. */
+	cpumask_t 	tdg_mask;	/* Bit mask for first cpu. */
+	int		tdg_load;	/* Total load of this group. */
 	int	tdg_transferable;	/* Transferable load of this group. */
 	LIST_HEAD(, tdq) tdg_members;	/* Linked list of all members. */
+	char		tdg_name[16];	/* lock name. */
 } __aligned(64);
 
 #define	SCHED_AFFINITY_DEFAULT	(max(1, hz / 300))
@@ -249,10 +250,12 @@
 
 #define	TDQ_SELF()	(&tdq_cpu[PCPU_GET(cpuid)])
 #define	TDQ_CPU(x)	(&tdq_cpu[(x)])
-#define	TDQ_ID(x)	((x) - tdq_cpu)
+#define	TDQ_ID(x)	((int)((x) - tdq_cpu))
 #define	TDQ_GROUP(x)	(&tdq_groups[(x)])
+#define	TDG_ID(x)	((int)((x) - tdq_groups))
 #else	/* !SMP */
 static struct tdq	tdq_cpu;
+static struct mtx	tdq_lock;
 
 #define	TDQ_ID(x)	(0)
 #define	TDQ_SELF()	(&tdq_cpu)
@@ -263,7 +266,7 @@
 #define	TDQ_LOCK(t)		mtx_lock_spin(TDQ_LOCKPTR((t)))
 #define	TDQ_LOCK_FLAGS(t, f)	mtx_lock_spin_flags(TDQ_LOCKPTR((t)), (f))
 #define	TDQ_UNLOCK(t)		mtx_unlock_spin(TDQ_LOCKPTR((t)))
-#define	TDQ_LOCKPTR(t)		(&(t)->tdq_lock)
+#define	TDQ_LOCKPTR(t)		((t)->tdq_lock)
 
 static void sched_priority(struct thread *);
 static void sched_thread_priority(struct thread *, u_char);
@@ -296,6 +299,7 @@
 static inline struct tdq *sched_setcpu(struct td_sched *, int, int);
 static inline struct mtx *thread_block_switch(struct thread *);
 static inline void thread_unblock_switch(struct thread *, struct mtx *);
+static struct mtx *sched_switch_migrate(struct tdq *, struct thread *, int);
 
 #define	THREAD_CAN_MIGRATE(td)	 ((td)->td_pinned == 0)
 #endif
@@ -343,9 +347,8 @@
 
 	tdq = TDQ_CPU(cpu);
 
-	printf("tdq:\n");
+	printf("tdq %d:\n", TDQ_ID(tdq));
 	printf("\tlockptr         %p\n", TDQ_LOCKPTR(tdq));
-	printf("\tlock name       %s\n", tdq->tdq_name);
 	printf("\tload:           %d\n", tdq->tdq_load);
 	printf("\ttimeshare idx:  %d\n", tdq->tdq_idx);
 	printf("\ttimeshare ridx: %d\n", tdq->tdq_ridx);
@@ -357,7 +360,9 @@
 	runq_print(&tdq->tdq_idle);
 #ifdef SMP
 	printf("\tload transferable: %d\n", tdq->tdq_transferable);
-	printf("\tlowest priority: %d\n", tdq->tdq_lowpri);
+	printf("\tlowest priority:   %d\n", tdq->tdq_lowpri);
+	printf("\tgroup:             %d\n", TDG_ID(tdq->tdq_group));
+	printf("\tLock name:         %s\n", tdq->tdq_group->tdg_name);
 #endif
 }
 
@@ -389,7 +394,7 @@
 		 * This queue contains only priorities between MIN and MAX
 		 * realtime.  Use the whole queue to represent these values.
 		 */
-		if ((flags & SRQ_BORROWING) == 0) {
+		if ((flags & (SRQ_BORROWING|SRQ_PREEMPTED)) == 0) {
 			pri = (pri - PRI_MIN_TIMESHARE) / TS_RQ_PPQ;
 			pri = (pri + tdq->tdq_idx) % RQ_NQS;
 			/*
@@ -454,7 +459,7 @@
 	THREAD_LOCK_ASSERT(ts->ts_thread, MA_OWNED);
 	class = PRI_BASE(ts->ts_thread->td_pri_class);
 	tdq->tdq_load++;
-	CTR2(KTR_SCHED, "cpu %jd load: %d", TDQ_ID(tdq), tdq->tdq_load);
+	CTR2(KTR_SCHED, "cpu %d load: %d", TDQ_ID(tdq), tdq->tdq_load);
 	if (class != PRI_ITHD &&
 	    (ts->ts_thread->td_proc->p_flag & P_NOLOAD) == 0)
 #ifdef SMP
@@ -484,7 +489,7 @@
 		tdq->tdq_sysload--;
 #endif
 	KASSERT(tdq->tdq_load != 0,
-	    ("tdq_load_rem: Removing with 0 load on queue %d", (int)TDQ_ID(tdq)));
+	    ("tdq_load_rem: Removing with 0 load on queue %d", TDQ_ID(tdq)));
 	tdq->tdq_load--;
 	CTR1(KTR_SCHED, "load: %d", tdq->tdq_load);
 	ts->ts_runq = NULL;
@@ -916,6 +921,8 @@
 	tdq = TDQ_CPU(cpu);
 	td = ts->ts_thread;
 	ts->ts_cpu = cpu;
+
+	/* If the lock matches just return the queue. */
 	if (td->td_lock == TDQ_LOCKPTR(tdq))
 		return (tdq);
 #ifdef notyet
@@ -936,9 +943,7 @@
 	 */
 	thread_lock_block(td);
 	TDQ_LOCK(tdq);
-	/* Return to sched_switch() with the lock still blocked */
-	if ((flags & SRQ_OURSELF) == 0)
-		thread_lock_unblock(td, TDQ_LOCKPTR(tdq));
+	thread_lock_unblock(td, TDQ_LOCKPTR(tdq));
 	return (tdq);
 }
 
@@ -1129,107 +1134,159 @@
 tdq_setup(struct tdq *tdq)
 {
 
-	snprintf(tdq->tdq_name, sizeof(tdq->tdq_name),
-	    "sched lock %d", (int)TDQ_ID(tdq));
-	mtx_init(&tdq->tdq_lock, tdq->tdq_name, "sched lock",
-	    MTX_SPIN | MTX_RECURSE);
+	if (bootverbose)
+		printf("ULE: setup cpu %d\n", TDQ_ID(tdq));
 	runq_init(&tdq->tdq_realtime);
 	runq_init(&tdq->tdq_timeshare);
 	runq_init(&tdq->tdq_idle);
 	tdq->tdq_load = 0;
 }
 
-/*
- * Setup the thread queues and initialize the topology based on MD
- * information.
- */
+#ifdef SMP
+static void
+tdg_setup(struct tdq_group *tdg)
+{
+	if (bootverbose)
+		printf("ULE: setup cpu group %d\n", TDG_ID(tdg));
+	snprintf(tdg->tdg_name, sizeof(tdg->tdg_name),
+	    "sched lock %d", (int)TDG_ID(tdg));
+	mtx_init(&tdg->tdg_lock, tdg->tdg_name, "sched lock",
+	    MTX_SPIN | MTX_RECURSE);
+	LIST_INIT(&tdg->tdg_members);
+	tdg->tdg_load = 0;
+	tdg->tdg_transferable = 0;
+	tdg->tdg_cpus = 0;
+	tdg->tdg_mask = 0;
+	tdg->tdg_cpumask = 0;
+	tdg->tdg_idlemask = 0;
+}
+
+static void
+tdg_add(struct tdq_group *tdg, struct tdq *tdq)
+{
+	if (tdg->tdg_mask == 0)
+		tdg->tdg_mask |= 1 << TDQ_ID(tdq);
+	tdg->tdg_cpumask |= 1 << TDQ_ID(tdq);
+	tdg->tdg_cpus++;
+	tdq->tdq_group = tdg;
+	tdq->tdq_lock = &tdg->tdg_lock;
+	LIST_INSERT_HEAD(&tdg->tdg_members, tdq, tdq_siblings);
+	if (bootverbose)
+		printf("ULE: adding cpu %d to group %d: cpus %d mask 0x%X\n",
+		    TDQ_ID(tdq), TDG_ID(tdg), tdg->tdg_cpus, tdg->tdg_cpumask);
+}
+
 static void
-sched_setup(void *dummy)
+sched_setup_topology(void)
 {
+	struct tdq_group *tdg;
+	struct cpu_group *cg;
+	int balance_groups;
 	struct tdq *tdq;
-#ifdef SMP
-	int balance_groups;
 	int i;
+	int j;
 
+	topology = 1;
 	balance_groups = 0;
-	/*
-	 * Initialize the tdqs.
-	 */
-	for (i = 0; i < MAXCPU; i++) {
+	for (i = 0; i < smp_topology->ct_count; i++) {
+		cg = &smp_topology->ct_group[i];
+		tdg = &tdq_groups[i];
+		/*
+		 * Initialize the group.
+		 */
+		tdg_setup(tdg);
+		/*
+		 * Find all of the group members and add them.
+		 */
+		for (j = 0; j < MAXCPU; j++) { 
+			if ((cg->cg_mask & (1 << j)) != 0) {
+				tdq = TDQ_CPU(j);
+				tdq_setup(tdq);
+				tdg_add(tdg, tdq);
+			}
+		}
+		if (tdg->tdg_cpus > 1)
+			balance_groups = 1;
+	}
+	tdg_maxid = smp_topology->ct_count - 1;
+	if (balance_groups)
+		sched_balance_groups(NULL);
+}
+
+static void
+sched_setup_smp(void)
+{
+	struct tdq_group *tdg;
+	struct tdq *tdq;
+	int cpus;
+	int i;
+
+	for (cpus = 0, i = 0; i < MAXCPU; i++) {
+		if (CPU_ABSENT(i))
+			continue;
 		tdq = &tdq_cpu[i];
-		tdq_setup(&tdq_cpu[i]);
+		tdg = &tdq_groups[i];
+		/*
+		 * Setup a tdq group with one member.
+		 */
+		tdg_setup(tdg);
+		tdq_setup(tdq);
+		tdg_add(tdg, tdq);
+		cpus++;
 	}
-	if (smp_topology == NULL) {
-		struct tdq_group *tdg;
-		int cpus;
+	tdg_maxid = cpus - 1;
+}
+
+/*
+ * Fake a topology with one group containing all CPUs.
+ */
+static void
+sched_fake_topo(void)
+{
+#ifdef SCHED_FAKE_TOPOLOGY
+	static struct cpu_top top;
+	static struct cpu_group group;
+
+	top.ct_count = 1;
+	top.ct_group = &group;
+	group.cg_mask = all_cpus;
+	group.cg_count = mp_ncpus;
+	group.cg_children = 0;
+	smp_topology = &top;
+#endif
+}
+#endif
 
-		for (cpus = 0, i = 0; i < MAXCPU; i++) {
-			if (CPU_ABSENT(i))
-				continue;
-			tdq = &tdq_cpu[i];
-			tdg = &tdq_groups[cpus];
-			/*
-			 * Setup a tdq group with one member.
-			 */
-			tdq->tdq_transferable = 0;
-			tdq->tdq_group = tdg;
-			tdg->tdg_cpus = 1;
-			tdg->tdg_idlemask = 0;
-			tdg->tdg_cpumask = tdg->tdg_mask = 1 << i;
-			tdg->tdg_load = 0;
-			tdg->tdg_transferable = 0;
-			LIST_INIT(&tdg->tdg_members);
-			LIST_INSERT_HEAD(&tdg->tdg_members, tdq, tdq_siblings);
-			cpus++;
-		}
-		tdg_maxid = cpus - 1;
-	} else {
-		struct tdq_group *tdg;
-		struct cpu_group *cg;

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list