CVS commit: src/sys

2012-07-21 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sun Jul 22 00:53:23 UTC 2012

Modified Files:
src/sys/fs/adosfs: adlookup.c
src/sys/fs/cd9660: cd9660_lookup.c
src/sys/fs/efs: efs_vnops.c
src/sys/fs/filecorefs: filecore_lookup.c
src/sys/fs/hfs: hfs_vnops.c
src/sys/fs/msdosfs: msdosfs_lookup.c
src/sys/fs/nilfs: nilfs_vnops.c
src/sys/fs/ntfs: ntfs_vnops.c
src/sys/fs/puffs: puffs_node.c puffs_vnops.c
src/sys/fs/smbfs: smbfs_vnops.c
src/sys/fs/tmpfs: tmpfs_vnops.c
src/sys/fs/udf: udf_vnops.c
src/sys/fs/unionfs: unionfs_vnops.c
src/sys/kern: vfs_cache.c
src/sys/nfs: nfs_vnops.c
src/sys/ufs/chfs: chfs_vnops.c
src/sys/ufs/ext2fs: ext2fs_lookup.c
src/sys/ufs/ufs: ufs_lookup.c

Log Message:
Move some the test for MAKEENTRY into the cache_enter(9).  Make some
variables in vfs_cache.c static, __read_mostly, etc.

No objection on tech-kern@.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/fs/adosfs/adlookup.c
cvs rdiff -u -r1.19 -r1.20 src/sys/fs/cd9660/cd9660_lookup.c
cvs rdiff -u -r1.25 -r1.26 src/sys/fs/efs/efs_vnops.c
cvs rdiff -u -r1.13 -r1.14 src/sys/fs/filecorefs/filecore_lookup.c
cvs rdiff -u -r1.25 -r1.26 src/sys/fs/hfs/hfs_vnops.c
cvs rdiff -u -r1.23 -r1.24 src/sys/fs/msdosfs/msdosfs_lookup.c
cvs rdiff -u -r1.17 -r1.18 src/sys/fs/nilfs/nilfs_vnops.c
cvs rdiff -u -r1.51 -r1.52 src/sys/fs/ntfs/ntfs_vnops.c
cvs rdiff -u -r1.24 -r1.25 src/sys/fs/puffs/puffs_node.c
cvs rdiff -u -r1.167 -r1.168 src/sys/fs/puffs/puffs_vnops.c
cvs rdiff -u -r1.79 -r1.80 src/sys/fs/smbfs/smbfs_vnops.c
cvs rdiff -u -r1.97 -r1.98 src/sys/fs/tmpfs/tmpfs_vnops.c
cvs rdiff -u -r1.71 -r1.72 src/sys/fs/udf/udf_vnops.c
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/unionfs/unionfs_vnops.c
cvs rdiff -u -r1.88 -r1.89 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.294 -r1.295 src/sys/nfs/nfs_vnops.c
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/chfs/chfs_vnops.c
cvs rdiff -u -r1.69 -r1.70 src/sys/ufs/ext2fs/ext2fs_lookup.c
cvs rdiff -u -r1.116 -r1.117 src/sys/ufs/ufs/ufs_lookup.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/adosfs/adlookup.c
diff -u src/sys/fs/adosfs/adlookup.c:1.15 src/sys/fs/adosfs/adlookup.c:1.16
--- src/sys/fs/adosfs/adlookup.c:1.15	Tue Nov 30 10:43:02 2010
+++ src/sys/fs/adosfs/adlookup.c	Sun Jul 22 00:53:18 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: adlookup.c,v 1.15 2010/11/30 10:43:02 dholland Exp $	*/
+/*	$NetBSD: adlookup.c,v 1.16 2012/07/22 00:53:18 rmind Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adlookup.c,v 1.15 2010/11/30 10:43:02 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adlookup.c,v 1.16 2012/07/22 00:53:18 rmind Exp $");
 
 #include 
 #include 
@@ -210,7 +210,7 @@ adosfs_lookup(void *v)
 #endif
 		return(EJUSTRETURN);
 	}
-	if ((cnp->cn_flags & MAKEENTRY) && nameiop != CREATE)
+	if (nameiop != CREATE)
 		cache_enter(vdp, NULL, cnp);
 #ifdef ADOSFS_DIAGNOSTIC
 	printf("ENOENT)");
@@ -240,7 +240,7 @@ found:
 	if (vdp == *vpp)
 		vref(vdp);
 found_lockdone:
-	if ((cnp->cn_flags & MAKEENTRY) && nocache == 0)
+	if (nocache == 0)
 		cache_enter(vdp, *vpp, cnp);
 
 #ifdef ADOSFS_DIAGNOSTIC

Index: src/sys/fs/cd9660/cd9660_lookup.c
diff -u src/sys/fs/cd9660/cd9660_lookup.c:1.19 src/sys/fs/cd9660/cd9660_lookup.c:1.20
--- src/sys/fs/cd9660/cd9660_lookup.c:1.19	Tue Sep 27 01:27:44 2011
+++ src/sys/fs/cd9660/cd9660_lookup.c	Sun Jul 22 00:53:18 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_lookup.c,v 1.19 2011/09/27 01:27:44 christos Exp $	*/
+/*	$NetBSD: cd9660_lookup.c,v 1.20 2012/07/22 00:53:18 rmind Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993, 1994
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cd9660_lookup.c,v 1.19 2011/09/27 01:27:44 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_lookup.c,v 1.20 2012/07/22 00:53:18 rmind Exp $");
 
 #include 
 #include 
@@ -336,11 +336,8 @@ notfound:
 	/*
 	 * Insert name into cache (as non-existent) if appropriate.
 	 */
-	if (cnp->cn_flags & MAKEENTRY)
-		cache_enter(vdp, *vpp, cnp);
-	if (nameiop == CREATE || nameiop == RENAME)
-		return (EROFS);
-	return (ENOENT);
+	cache_enter(vdp, *vpp, cnp);
+	return (nameiop == CREATE || nameiop == RENAME) ? EROFS : ENOENT;
 
 found:
 	if (numdirpasses == 2)
@@ -402,9 +399,8 @@ found:
 	/*
 	 * Insert name into cache if appropriate.
 	 */
-	if (cnp->cn_flags & MAKEENTRY)
-		cache_enter(vdp, *vpp, cnp);
-	return (0);
+	cache_enter(vdp, *vpp, cnp);
+	return 0;
 }
 
 /*

Index: src/sys/fs/efs/efs_vnops.c
diff -u src/sys/fs/efs/efs_vnops.c:1.25 src/sys/fs/efs/efs_vnops.c:1.26
--- src/sys/fs/efs/efs_vnops.c:1.25	Tue Mar 13 18:40:36 2012
+++ src/sys/fs/efs/efs_vnops.c	Sun Jul 22 00:53:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: efs_vnops.c,v 1.25 2012/03/13 18:40:36 elad Exp $	*/
+/*	$NetBSD: efs_vnops.c,v 1.2

CVS commit: src/lib/libc/cdb

2012-07-21 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Jul 21 22:49:37 UTC 2012

Modified Files:
src/lib/libc/cdb: cdbw.c

Log Message:
Redo hashing, if two of the three individual hashes result in identical
hash modules. This is the trivial case for loops in the 3-graph and got
lost when adopting the nbperf code.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/cdb/cdbw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/cdb/cdbw.c
diff -u src/lib/libc/cdb/cdbw.c:1.4 src/lib/libc/cdb/cdbw.c:1.5
--- src/lib/libc/cdb/cdbw.c:1.4	Sun Jun  3 21:02:50 2012
+++ src/lib/libc/cdb/cdbw.c	Sat Jul 21 22:49:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cdbw.c,v 1.4 2012/06/03 21:02:50 joerg Exp $	*/
+/*	$NetBSD: cdbw.c,v 1.5 2012/07/21 22:49:37 joerg Exp $	*/
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -36,7 +36,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: cdbw.c,v 1.4 2012/06/03 21:02:50 joerg Exp $");
+__RCSID("$NetBSD: cdbw.c,v 1.5 2012/07/21 22:49:37 joerg Exp $");
 
 #include "namespace.h"
 
@@ -387,6 +387,13 @@ build_graph(struct cdbw *cdbw, struct st
 			e->middle = hashes[1] % state->entries;
 			e->right = hashes[2] % state->entries;
 
+			if (e->left == e->middle)
+return -1;
+			if (e->left == e->right)
+return -1;
+			if (e->middle == e->right)
+return -1;
+
 			++e;
 		}
 	}



CVS commit: src/regress/lib/libc/cdb

2012-07-21 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat Jul 21 22:22:55 UTC 2012

Added Files:
src/regress/lib/libc/cdb: cdb_test.c

Log Message:
Add a simple test for cdb(5).


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/regress/lib/libc/cdb/cdb_test.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/regress/lib/libc/cdb/cdb_test.c
diff -u /dev/null src/regress/lib/libc/cdb/cdb_test.c:1.1
--- /dev/null	Sat Jul 21 22:22:55 2012
+++ src/regress/lib/libc/cdb/cdb_test.c	Sat Jul 21 22:22:55 2012
@@ -0,0 +1,90 @@
+/*	$NetBSD: cdb_test.c,v 1.1 2012/07/21 22:22:55 rmind Exp $	*/
+
+/*
+ * This file is in the Public Domain.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "cdbr.h"
+#include "cdbw.h"
+
+#define	CDB_FILE		"/tmp/test.cdb"
+
+#define DATASOURCE_SIZE		8192
+
+static uint64_t			k[DATASOURCE_SIZE];
+static uint64_t			d[DATASOURCE_SIZE];
+
+static void
+build_cdb(uint32_t (*seedgen)(void))
+{
+	struct cdbw *cdbw = cdbw_open();
+	int i, fd, ret;
+
+	for (i = 0; i < DATASOURCE_SIZE; i++) {
+		k[i] = ((uint64_t)i << 32UL) | random();
+		d[i] = random();
+		ret = cdbw_put(cdbw, &k[i], sizeof(k[0]), &d[i], sizeof(d[0]));
+		assert(ret == 0);
+	}
+
+	fd = open(CDB_FILE, O_RDWR | O_CREAT, 0644);
+	assert(fd > 0);
+
+	ret = cdbw_output(cdbw, fd, "test", seedgen);
+	assert(ret == 0);
+
+	cdbw_close(cdbw);
+	close(fd);
+}
+
+static void
+test_cdb(void)
+{
+	struct cdbr *cdbr = cdbr_open(CDB_FILE, CDBR_DEFAULT);
+	int i, ret;
+
+	assert(cdbr != NULL);
+	assert(cdbr_entries(cdbr) == DATASOURCE_SIZE);
+
+	for (i = 0; i < DATASOURCE_SIZE; i++) {
+		const void *val;
+		size_t len;
+
+		ret = cdbr_find(cdbr, &k[i], sizeof(k[0]), &val, &len);
+		assert(ret == 0);
+		assert(len == sizeof(uint64_t));
+
+		const uint64_t num = *(const uint64_t *)val;
+		if (d[i] == num) {
+			continue;
+		}
+		fprintf(stderr, "%d: 0x%"PRIu64" != 0x%"PRIu64"\n", i, d[i], num);
+		abort();
+	}
+	cdbr_close(cdbr);
+}
+
+int
+main(int argc, char **argv)
+{
+	int i;
+
+	srandom(time(NULL) ^ getpid());
+
+	for (i = 0; i < 64; i++) {
+		build_cdb((uint32_t (*)(void))random);
+		test_cdb();
+
+		build_cdb(cdbw_stable_seeder);
+		test_cdb();
+	}
+
+	return 0;
+}



CVS commit: src

2012-07-21 Thread Mindaugas Rasiukevicius
Module Name:src
Committed By:   rmind
Date:   Sat Jul 21 17:11:02 UTC 2012

Modified Files:
src/sys/net/npf: npf_inet.c npf_state.c npf_state_tcp.c
src/usr.sbin/npf/npftest: npfstream.c
src/usr.sbin/npf/npftest/libnpftest: npf_test_subr.c

Log Message:
- npf_fetch_tcpopts: fix off-by-one when validating TCP option length
  against the maximum allowed.
- npf_tcp_inwindow: be more liberal with npf_fetch_tcpopts().
- Few minor improvements to npftest.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/net/npf/npf_inet.c
cvs rdiff -u -r1.9 -r1.10 src/sys/net/npf/npf_state.c \
src/sys/net/npf/npf_state_tcp.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/npf/npftest/npfstream.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/npf/npftest/libnpftest/npf_test_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/npf/npf_inet.c
diff -u src/sys/net/npf/npf_inet.c:1.15 src/sys/net/npf/npf_inet.c:1.16
--- src/sys/net/npf/npf_inet.c:1.15	Thu Jul 19 21:52:29 2012
+++ src/sys/net/npf/npf_inet.c	Sat Jul 21 17:11:01 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_inet.c,v 1.15 2012/07/19 21:52:29 spz Exp $	*/
+/*	$NetBSD: npf_inet.c,v 1.16 2012/07/21 17:11:01 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2009-2012 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: npf_inet.c,v 1.15 2012/07/19 21:52:29 spz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_inet.c,v 1.16 2012/07/21 17:11:01 rmind Exp $");
 
 #include 
 #include 
@@ -277,7 +277,7 @@ next:
 		if (nbuf_advfetch(&nbuf, &n_ptr, 1, sizeof(val), &val)) {
 			return false;
 		}
-		if (val < 2 || val >= topts_len) {
+		if (val < 2 || val > topts_len) {
 			return false;
 		}
 		topts_len -= val;

Index: src/sys/net/npf/npf_state.c
diff -u src/sys/net/npf/npf_state.c:1.9 src/sys/net/npf/npf_state.c:1.10
--- src/sys/net/npf/npf_state.c:1.9	Sun Jul  1 23:21:06 2012
+++ src/sys/net/npf/npf_state.c	Sat Jul 21 17:11:01 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_state.c,v 1.9 2012/07/01 23:21:06 rmind Exp $	*/
+/*	$NetBSD: npf_state.c,v 1.10 2012/07/21 17:11:01 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2010-2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: npf_state.c,v 1.9 2012/07/01 23:21:06 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_state.c,v 1.10 2012/07/21 17:11:01 rmind Exp $");
 
 #include 
 #include 
@@ -107,6 +107,7 @@ npf_state_init(const npf_cache_t *npc, n
 	default:
 		ret = false;
 	}
+	NPF_TCP_STATE_SAMPLE(nst, ret);
 	return ret;
 }
 
Index: src/sys/net/npf/npf_state_tcp.c
diff -u src/sys/net/npf/npf_state_tcp.c:1.9 src/sys/net/npf/npf_state_tcp.c:1.10
--- src/sys/net/npf/npf_state_tcp.c:1.9	Sun Jul 15 00:23:00 2012
+++ src/sys/net/npf/npf_state_tcp.c	Sat Jul 21 17:11:02 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: npf_state_tcp.c,v 1.9 2012/07/15 00:23:00 rmind Exp $	*/
+/*	$NetBSD: npf_state_tcp.c,v 1.10 2012/07/21 17:11:02 rmind Exp $	*/
 
 /*-
  * Copyright (c) 2010-2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: npf_state_tcp.c,v 1.9 2012/07/15 00:23:00 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_state_tcp.c,v 1.10 2012/07/21 17:11:02 rmind Exp $");
 
 #include 
 #include 
@@ -300,7 +300,7 @@ npf_tcp_inwindow(const npf_cache_t *npc,
 	const struct tcphdr * const th = &npc->npc_l4.tcp;
 	const int tcpfl = th->th_flags;
 	npf_tcpstate_t *fstate, *tstate;
-	int tcpdlen, wscale, ackskew;
+	int tcpdlen, ackskew;
 	tcp_seq seq, ack, end;
 	uint32_t win;
 
@@ -359,11 +359,9 @@ npf_tcp_inwindow(const npf_cache_t *npc,
 		 * Handle TCP Window Scaling (RFC 1323).  Both sides may
 		 * send this option in their SYN packets.
 		 */
-		if (npf_fetch_tcpopts(npc, nbuf, NULL, &wscale)) {
-			fstate->nst_wscale = wscale;
-		} else {
-			fstate->nst_wscale = 0;
-		}
+		fstate->nst_wscale = 0;
+		(void)npf_fetch_tcpopts(npc, nbuf, NULL, &fstate->nst_wscale);
+
 		tstate->nst_wscale = 0;
 
 		/* Done. */
@@ -377,12 +375,12 @@ npf_tcp_inwindow(const npf_cache_t *npc,
 		fstate->nst_end = end;
 		fstate->nst_maxend = end + 1;
 		fstate->nst_maxwin = win;
+		fstate->nst_wscale = 0;
 
 		/* Handle TCP Window Scaling (must be ignored if no SYN). */
 		if (tcpfl & TH_SYN) {
-			fstate->nst_wscale =
-			npf_fetch_tcpopts(npc, nbuf, NULL, &wscale) ?
-			wscale : 0;
+			(void)npf_fetch_tcpopts(npc, nbuf, NULL,
+			&fstate->nst_wscale);
 		}
 	}
 

Index: src/usr.sbin/npf/npftest/npfstream.c
diff -u src/usr.sbin/npf/npftest/npfstream.c:1.1 src/usr.sbin/npf/npftest/npfstream.c:1.2
--- src/usr.sbin/npf/npftest/npfstream.c:1.1	Wed May 30 21:38:04 2012
+++ src/usr.sbin/npf/npftest/npfstream.c	Sat Jul 21 17:11:02 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: npfstream.c,v 1.1 2012/05/30 21:38:04 rmind Exp $	*/
+/*	$NetBSD: npfstream.c,v 1.2 2012/07/21 17:11:02 rmind Exp $	*/
 
 /*
  * NPF stream processor.
@@ -67,7 +67,7 @@ process_tcpip(con

CVS commit: src/sys/dev/sdmmc

2012-07-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul 21 16:14:05 UTC 2012

Modified Files:
src/sys/dev/sdmmc: sdhc.c sdhcvar.h

Log Message:
Provide a method for attachments to specify capabilites.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/dev/sdmmc/sdhc.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/sdmmc/sdhcvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.23 src/sys/dev/sdmmc/sdhc.c:1.24
--- src/sys/dev/sdmmc/sdhc.c:1.23	Fri Jul 20 02:04:13 2012
+++ src/sys/dev/sdmmc/sdhc.c	Sat Jul 21 16:14:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc.c,v 1.23 2012/07/20 02:04:13 matt Exp $	*/
+/*	$NetBSD: sdhc.c,v 1.24 2012/07/21 16:14:05 skrll Exp $	*/
 /*	$OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.23 2012/07/20 02:04:13 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.24 2012/07/21 16:14:05 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -292,9 +292,13 @@ sdhc_host_found(struct sdhc_softc *sc, b
 	(void)sdhc_host_reset(hp);
 
 	/* Determine host capabilities. */
-	mutex_enter(&hp->host_mtx);
-	caps = HREAD4(hp, SDHC_CAPABILITIES);
-	mutex_exit(&hp->host_mtx);
+	if (ISSET(sc->sc_flags, SDHC_FLAG_HOSTCAPS)) {
+		caps = sc->sc_caps;
+	} else {
+		mutex_enter(&hp->host_mtx);
+		caps = HREAD4(hp, SDHC_CAPABILITIES);
+		mutex_exit(&hp->host_mtx);
+	}
 
 	/* Use DMA if the host system and the controller support it. */
 	if (ISSET(sc->sc_flags, SDHC_FLAG_FORCE_DMA)

Index: src/sys/dev/sdmmc/sdhcvar.h
diff -u src/sys/dev/sdmmc/sdhcvar.h:1.7 src/sys/dev/sdmmc/sdhcvar.h:1.8
--- src/sys/dev/sdmmc/sdhcvar.h:1.7	Thu Jul 12 03:05:49 2012
+++ src/sys/dev/sdmmc/sdhcvar.h	Sat Jul 21 16:14:05 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhcvar.h,v 1.7 2012/07/12 03:05:49 matt Exp $	*/
+/*	$NetBSD: sdhcvar.h,v 1.8 2012/07/21 16:14:05 skrll Exp $	*/
 /*	$OpenBSD: sdhcvar.h,v 1.3 2007/09/06 08:01:01 jsg Exp $	*/
 
 /*
@@ -44,7 +44,10 @@ struct sdhc_softc {
 #define	SDHC_FLAG_8BIT_MODE	0x0040	/* MMC 8bit mode is supported */
 #define	SDHC_FLAG_HAVE_CGM	0x0080	/* Netlogic XLP */
 #define	SDHC_FLAG_NO_LED_ON	0x0100	/* LED_ON unsupported in HOST_CTL */
+#define	SDHC_FLAG_HOSTCAPS	0x0200	/* No device provided capabilities */
+
 	uint32_t		sc_clkbase;
+	uint32_t		sc_caps;/* attachment provided capabilities */
 };
 
 /* Host controller functions called by the attachment driver. */



CVS commit: src/sys/netinet6

2012-07-21 Thread Greg Troxel
Module Name:src
Committed By:   gdt
Date:   Sat Jul 21 14:52:40 UTC 2012

Modified Files:
src/sys/netinet6: ip6_output.c

Log Message:
Add comments describing parameter handling for ip6_insertfraghdr.

Depending on compiler options, this code can be involved in an
(apparently) spurious compiler warning.  However, it was not
immediately obvious the the compiler was wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/sys/netinet6/ip6_output.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet6/ip6_output.c
diff -u src/sys/netinet6/ip6_output.c:1.149 src/sys/netinet6/ip6_output.c:1.150
--- src/sys/netinet6/ip6_output.c:1.149	Mon Jun 25 15:28:40 2012
+++ src/sys/netinet6/ip6_output.c	Sat Jul 21 14:52:40 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_output.c,v 1.149 2012/06/25 15:28:40 christos Exp $	*/
+/*	$NetBSD: ip6_output.c,v 1.150 2012/07/21 14:52:40 gdt Exp $	*/
 /*	$KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.149 2012/06/25 15:28:40 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.150 2012/07/21 14:52:40 gdt Exp $");
 
 #include "opt_inet.h"
 #include "opt_inet6.h"
@@ -1147,6 +1147,10 @@ ip6_insert_jumboopt(struct ip6_exthdrs *
 
 /*
  * Insert fragment header and copy unfragmentable header portions.
+ * 
+ * *frghdrp will not be read, and it is guaranteed that either an
+ * error is returned or that *frghdrp will point to space allocated
+ * for the fragment header.
  */
 static int
 ip6_insertfraghdr(struct mbuf *m0, struct mbuf *m, int hlen, 



CVS commit: src/tests/usr.bin/cc

2012-07-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jul 21 12:30:55 UTC 2012

Modified Files:
src/tests/usr.bin/cc: t_hello.sh

Log Message:
Add a test case that (if gcc supports it on the current arch) to compile
a PIE binary and see if we can run it.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/cc/t_hello.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/cc/t_hello.sh
diff -u src/tests/usr.bin/cc/t_hello.sh:1.1 src/tests/usr.bin/cc/t_hello.sh:1.2
--- src/tests/usr.bin/cc/t_hello.sh:1.1	Sat Mar 17 17:15:29 2012
+++ src/tests/usr.bin/cc/t_hello.sh	Sat Jul 21 12:30:55 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: t_hello.sh,v 1.1 2012/03/17 17:15:29 jruoho Exp $
+#	$NetBSD: t_hello.sh,v 1.2 2012/07/21 12:30:55 martin Exp $
 #
 # Copyright (c) 2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -37,6 +37,12 @@ hello_pic_head() {
 	atf_set "require.progs" "cc"
 }
 
+atf_test_case hello_pie
+hello_pie_head() {
+	atf_set "descr" "compile and run position independend (PIE) \"hello world\""
+	atf_set "require.progs" "cc"
+}
+
 atf_test_case hello32
 hello32_head() {
 	atf_set "descr" "compile and run \"hello world\" for/in netbsd32 emulation"
@@ -72,6 +78,20 @@ EOF
 	atf_check -s exit:0 -o inline:"hello world\n" ./hello
 }
 
+hello_pie_body() {
+	# check whether this arch supports -pie
+	if ! cc -pie -dM -E - < /dev/null 2>/dev/null >/dev/null; then
+		atf_skip "cc -pie not supported on this architecture"
+	fi
+	cat > test.c << EOF
+#include 
+#include 
+int main(void) {printf("hello world\n");exit(0);}
+EOF
+	atf_check -s exit:0 -o ignore -e ignore cc -fpie -pie -o hello test.c
+	atf_check -s exit:0 -o inline:"hello world\n" ./hello
+}
+
 hello32_body() {
 	# check whether this arch is 64bit
 	if ! cc -dM -E - < /dev/null | fgrep -q _LP64; then
@@ -119,5 +139,6 @@ atf_init_test_cases()
 
 	atf_add_test_case hello
 	atf_add_test_case hello_pic
+	atf_add_test_case hello_pie
 	atf_add_test_case hello32
 }



CVS commit: src/sys/arch/arm

2012-07-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul 21 12:19:15 UTC 2012

Modified Files:
src/sys/arch/arm/arm: cpufunc.c cpufunc_asm_arm1136.S
src/sys/arch/arm/conf: files.arm
src/sys/arch/arm/include: cpufunc.h
Added Files:
src/sys/arch/arm/arm: cpufunc_asm_arm11x6.S

Log Message:
Add support for the ARM1176JZS


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/arm/arm/cpufunc.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/arm/cpufunc_asm_arm1136.S
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/arm/cpufunc_asm_arm11x6.S
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/arm/conf/files.arm
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/arm/include/cpufunc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/arm/cpufunc.c
diff -u src/sys/arch/arm/arm/cpufunc.c:1.107 src/sys/arch/arm/arm/cpufunc.c:1.108
--- src/sys/arch/arm/arm/cpufunc.c:1.107	Sat Jul 14 12:59:55 2012
+++ src/sys/arch/arm/arm/cpufunc.c	Sat Jul 21 12:19:15 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.107 2012/07/14 12:59:55 hans Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.108 2012/07/21 12:19:15 skrll Exp $	*/
 
 /*
  * arm7tdmi support code Copyright (c) 2001 John Fremlin
@@ -49,7 +49,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.107 2012/07/14 12:59:55 hans Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.108 2012/07/21 12:19:15 skrll Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_cpuoptions.h"
@@ -747,7 +747,7 @@ struct cpu_functions arm1136_cpufuncs = 
 
 	.cf_control		= cpufunc_control,
 	.cf_domains		= cpufunc_domains,
-	.cf_setttb		= arm1136_setttb,
+	.cf_setttb		= arm11x6_setttb,
 	.cf_faultstatus		= cpufunc_faultstatus,
 	.cf_faultaddress	= cpufunc_faultaddress,
 
@@ -762,25 +762,25 @@ struct cpu_functions arm1136_cpufuncs = 
 
 	/* Cache operations */
 
-	.cf_icache_sync_all	= arm1136_icache_sync_all,	/* 411920 */
-	.cf_icache_sync_range	= arm1136_icache_sync_range,	/* 371025 */
+	.cf_icache_sync_all	= arm11x6_icache_sync_all,	/* 411920 */
+	.cf_icache_sync_range	= arm11x6_icache_sync_range,	/* 371025 */
 
-	.cf_dcache_wbinv_all	= arm1136_dcache_wbinv_all,	/* 411920 */
+	.cf_dcache_wbinv_all	= arm11x6_dcache_wbinv_all,	/* 411920 */
 	.cf_dcache_wbinv_range	= armv6_dcache_wbinv_range,
 	.cf_dcache_inv_range	= armv6_dcache_inv_range,
 	.cf_dcache_wb_range	= armv6_dcache_wb_range,
 
-	.cf_idcache_wbinv_all	= arm1136_idcache_wbinv_all,	/* 411920 */
-	.cf_idcache_wbinv_range = arm1136_idcache_wbinv_range,	/* 371025 */
+	.cf_idcache_wbinv_all	= arm11x6_idcache_wbinv_all,	/* 411920 */
+	.cf_idcache_wbinv_range = arm11x6_idcache_wbinv_range,	/* 371025 */
 
 	/* Other functions */
 
-	.cf_flush_prefetchbuf	= arm1136_flush_prefetchbuf,
+	.cf_flush_prefetchbuf	= arm11x6_flush_prefetchbuf,
 	.cf_drain_writebuf	= arm11_drain_writebuf,
 	.cf_flush_brnchtgt_C	= cpufunc_nullop,
 	.cf_flush_brnchtgt_E	= (void *)cpufunc_nullop,
 
-	.cf_sleep		= arm11_sleep,
+	.cf_sleep		= arm11_sleep,	/* arm1136_sleep_rev0 */
 
 	/* Soft functions */
 
@@ -789,11 +789,70 @@ struct cpu_functions arm1136_cpufuncs = 
 
 	.cf_context_switch	= arm11_context_switch,
 
-	.cf_setup		= arm1136_setup
+	.cf_setup		= arm11x6_setup
 
 };
 #endif /* CPU_ARM1136 */
 
+#ifdef CPU_ARM1176
+struct cpu_functions arm1176_cpufuncs = {
+	/* CPU functions */
+
+	.cf_id			= cpufunc_id,
+	.cf_cpwait		= cpufunc_nullop,
+
+	/* MMU functions */
+
+	.cf_control		= cpufunc_control,
+	.cf_domains		= cpufunc_domains,
+	.cf_setttb		= arm11x6_setttb,
+	.cf_faultstatus		= cpufunc_faultstatus,
+	.cf_faultaddress	= cpufunc_faultaddress,
+
+	/* TLB functions */
+
+	.cf_tlb_flushID		= arm11_tlb_flushID,
+	.cf_tlb_flushID_SE	= arm11_tlb_flushID_SE,
+	.cf_tlb_flushI		= arm11_tlb_flushI,
+	.cf_tlb_flushI_SE	= arm11_tlb_flushI_SE,
+	.cf_tlb_flushD		= arm11_tlb_flushD,
+	.cf_tlb_flushD_SE	= arm11_tlb_flushD_SE,
+
+	/* Cache operations */
+
+	.cf_icache_sync_all	= arm11x6_icache_sync_all,	/* 415045 */
+	.cf_icache_sync_range	= arm11x6_icache_sync_range,	/* 371367 */
+
+	.cf_dcache_wbinv_all	= arm11x6_dcache_wbinv_all,	/* 415045 */
+	.cf_dcache_wbinv_range	= armv6_dcache_wbinv_range,
+	.cf_dcache_inv_range	= armv6_dcache_inv_range,
+	.cf_dcache_wb_range	= armv6_dcache_wb_range,
+
+	.cf_idcache_wbinv_all	= arm11x6_idcache_wbinv_all,	/* 415045 */
+	.cf_idcache_wbinv_range = arm11x6_idcache_wbinv_range,	/* 371367 */
+
+	/* Other functions */
+
+	.cf_flush_prefetchbuf	= arm11x6_flush_prefetchbuf,
+	.cf_drain_writebuf	= arm11_drain_writebuf,
+	.cf_flush_brnchtgt_C	= cpufunc_nullop,
+	.cf_flush_brnchtgt_E	= (void *)cpufunc_nullop,
+
+	.cf_sleep		= arm11x6_sleep,		/* no ref. */
+
+	/* Soft functions */
+
+	.cf_dataabt_fixup	= cpufunc_null_fixup,
+	.cf_prefetchabt_fixup	= cpufunc_null_fixup,
+
+	.cf_context_switch	= arm11_context_switch,
+
+	.cf_setup		= arm11x6_setup
+
+};
+#endif /* CPU_ARM1176 */
+
+
 #ifdef CPU_ARM11MPCORE
 struct cpu_fun

CVS commit: src/sys/kern

2012-07-21 Thread Lars Heidieker
Module Name:src
Committed By:   para
Date:   Sat Jul 21 11:45:04 UTC 2012

Modified Files:
src/sys/kern: subr_kmem.c

Log Message:
split allocation lookup table to decrease overall memory used
making allocator more flexible for allocations larger then 4kb
move the encoded "size" under DEBUG back to the begining of allocated chunk

no objections on tech-kern@


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/kern/subr_kmem.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_kmem.c
diff -u src/sys/kern/subr_kmem.c:1.45 src/sys/kern/subr_kmem.c:1.46
--- src/sys/kern/subr_kmem.c:1.45	Sun Apr 15 19:07:40 2012
+++ src/sys/kern/subr_kmem.c	Sat Jul 21 11:45:04 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_kmem.c,v 1.45 2012/04/15 19:07:40 martin Exp $	*/
+/*	$NetBSD: subr_kmem.c,v 1.46 2012/07/21 11:45:04 para Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.45 2012/04/15 19:07:40 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,v 1.46 2012/07/21 11:45:04 para Exp $");
 
 #include 
 #include 
@@ -77,10 +77,12 @@ __KERNEL_RCSID(0, "$NetBSD: subr_kmem.c,
 
 #include 
 
-static const struct kmem_cache_info {
+struct kmem_cache_info {
 	size_t		kc_size;
 	const char *	kc_name;
-} kmem_cache_sizes[] = {
+};
+
+static const struct kmem_cache_info kmem_cache_sizes[] = {
 	{  8, "kmem-8" },
 	{ 16, "kmem-16" },
 	{ 24, "kmem-24" },
@@ -103,24 +105,39 @@ static const struct kmem_cache_info {
 	{ 512, "kmem-512" },
 	{ 768, "kmem-768" },
 	{ 1024, "kmem-1024" },
+	{ 0, NULL }
+};
+
+static const struct kmem_cache_info kmem_cache_big_sizes[] = {
 	{ 2048, "kmem-2048" },
 	{ 4096, "kmem-4096" },
+	{ 8192, "kmem-8192" },
+	{ 16384, "kmem-16384" },
 	{ 0, NULL }
 };
 
 /*
  * KMEM_ALIGN is the smallest guaranteed alignment and also the
- * smallest allocateable quantum.  Every cache size is a multiply
- * of CACHE_LINE_SIZE and gets CACHE_LINE_SIZE alignment.
+ * smallest allocateable quantum.
+ * Every cache size >= CACHE_LINE_SIZE gets CACHE_LINE_SIZE alignment.
  */
 #define	KMEM_ALIGN		8
 #define	KMEM_SHIFT		3
-#define	KMEM_MAXSIZE		4096
+#define	KMEM_MAXSIZE		1024
 #define	KMEM_CACHE_COUNT	(KMEM_MAXSIZE >> KMEM_SHIFT)
 
 static pool_cache_t kmem_cache[KMEM_CACHE_COUNT] __cacheline_aligned;
 static size_t kmem_cache_maxidx __read_mostly;
 
+#define	KMEM_BIG_ALIGN		2048
+#define	KMEM_BIG_SHIFT		11
+#define	KMEM_BIG_MAXSIZE	16384
+#define	KMEM_CACHE_BIG_COUNT	(KMEM_BIG_MAXSIZE >> KMEM_BIG_SHIFT)
+
+static pool_cache_t kmem_cache_big[KMEM_CACHE_BIG_COUNT] __cacheline_aligned;
+static size_t kmem_cache_big_maxidx __read_mostly;
+
+
 #if defined(DEBUG) && defined(_HARDKERNEL)
 #ifndef KMEM_GUARD_DEPTH
 #define KMEM_GUARD_DEPTH 0
@@ -163,6 +180,10 @@ static void kmem_size_check(void *, size
 CTASSERT(KM_SLEEP == PR_WAITOK);
 CTASSERT(KM_NOSLEEP == PR_NOWAIT);
 
+/*
+ * kmem_intr_alloc: allocate wired memory.
+ */
+
 void *
 kmem_intr_alloc(size_t size, km_flag_t kmflags)
 {
@@ -178,28 +199,41 @@ kmem_intr_alloc(size_t size, km_flag_t k
 		(kmflags & KM_SLEEP) != 0);
 	}
 #endif
-	allocsz = kmem_roundup_size(size) + REDZONE_SIZE + SIZE_SIZE;
-	index = (allocsz - 1) >> KMEM_SHIFT;
+	size = kmem_roundup_size(size);
+	allocsz = size + REDZONE_SIZE + SIZE_SIZE;
 
-	if (index >= kmem_cache_maxidx) {
+	if ((index = ((allocsz -1) >> KMEM_SHIFT))
+	< kmem_cache_maxidx) {
+		pc = kmem_cache[index];
+	} else if ((index = ((allocsz - 1) >> KMEM_BIG_SHIFT))
+< kmem_cache_big_maxidx) {
+		pc = kmem_cache_big[index];
+	} else {	
 		int ret = uvm_km_kmem_alloc(kmem_va_arena,
 		(vsize_t)round_page(size),
 		((kmflags & KM_SLEEP) ? VM_SLEEP : VM_NOSLEEP)
 		 | VM_INSTANTFIT, (vmem_addr_t *)&p);
-		return ret ? NULL : p;
+		if (ret) {
+			return NULL;
+		}
+		FREECHECK_OUT(&kmem_freecheck, p);
+		return p;
 	}
 
-	pc = kmem_cache[index];
 	p = pool_cache_get(pc, kmflags);
 
 	if (__predict_true(p != NULL)) {
-		kmem_poison_check(p, kmem_roundup_size(size));
+		kmem_poison_check(p, size);
 		FREECHECK_OUT(&kmem_freecheck, p);
-		kmem_size_set(p, allocsz);
+		kmem_size_set(p, size);
 	}
-	return p;
+	return p + SIZE_SIZE;
 }
 
+/*
+ * kmem_intr_zalloc: allocate zeroed wired memory.
+ */
+
 void *
 kmem_intr_zalloc(size_t size, km_flag_t kmflags)
 {
@@ -212,6 +246,10 @@ kmem_intr_zalloc(size_t size, km_flag_t 
 	return p;
 }
 
+/*
+ * kmem_intr_free: free wired memory allocated by kmem_alloc.
+ */
+
 void
 kmem_intr_free(void *p, size_t size)
 {
@@ -227,22 +265,30 @@ kmem_intr_free(void *p, size_t size)
 		return;
 	}
 #endif
-	allocsz = kmem_roundup_size(size) + REDZONE_SIZE + SIZE_SIZE;
-	index = (allocsz - 1) >> KMEM_SHIFT;
+	size = kmem_roundup_size(size);
+	allocsz = size + REDZONE_SIZE + SIZE_SIZE;
 
-	if (index >= kmem_cache_maxidx) {
+	if ((index = ((allocsz -1) >> KME

CVS commit: xsrc/external/mit/xf86-input-keyboard/dist/src

2012-07-21 Thread Izumi Tsutsui
Module Name:xsrc
Committed By:   tsutsui
Date:   Sat Jul 21 10:19:40 UTC 2012

Modified Files:
xsrc/external/mit/xf86-input-keyboard/dist/src: bsd_kbd.c

Log Message:
Don't return FALSE in OpenKeyboard() even if wskbd type is unknown
so that we can still setup keyboard map manually by xmodmap(1) etc.
on poor Tier II machines.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c
diff -u xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c:1.15 xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c:1.16
--- xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c:1.15	Mon Jul 16 12:50:25 2012
+++ xsrc/external/mit/xf86-input-keyboard/dist/src/bsd_kbd.c	Sat Jul 21 10:19:40 2012
@@ -432,10 +432,10 @@ OpenKeyboard(InputInfoPtr pInfo)
break;
 #endif
default:
-   xf86Msg(X_ERROR, "%s: Unsupported wskbd type \"%d\"",
-pInfo->name, pKbd->wsKbdType);
-   close(pInfo->fd);
-   return FALSE;
+   xf86Msg(X_WARNING, "%s: Unsupported wskbd type \"%d\"\n",
+  pInfo->name, pKbd->wsKbdType);
+   printWsType("Unknown wskbd", pInfo->name);
+   break;
}
 }
 #endif