svn commit: r207812 - head/usr.sbin/bluetooth/bthidd

2010-05-09 Thread Kai Wang
Author: kaiw
Date: Sun May  9 09:20:25 2010
New Revision: 207812
URL: http://svn.freebsd.org/changeset/base/207812

Log:
  Catch up with libusbhid merge (rev 205728).
  
  hid_get_data() now expects that the hid data passed in always contains
  the report ID byte. Thus we should not skip the the report ID byte in
  hid_interrupt().  Also, if HUP_KEYBOARD usage is an array, do not try
  to modify the 'data' pointer, instead, increase the hid_item_t field
  'pos' by 'report_size' before calling hid_get_data() during each
  iteration.
  
  PR:   usb/146367
  Reported and tested by:   Alex Deiter
  Pointy hat to:kaiw
  Reviewed by:  emax

Modified:
  head/usr.sbin/bluetooth/bthidd/hid.c

Modified: head/usr.sbin/bluetooth/bthidd/hid.c
==
--- head/usr.sbin/bluetooth/bthidd/hid.cSun May  9 08:22:33 2010
(r207811)
+++ head/usr.sbin/bluetooth/bthidd/hid.cSun May  9 09:20:25 2010
(r207812)
@@ -130,7 +130,7 @@ hid_interrupt(bthid_session_p s, uint8_t
hid_item_t  h;
int32_t report_id, usage, page, val,
mouse_x, mouse_y, mouse_z, mouse_butt,
-   mevents, kevents;
+   mevents, kevents, i;
 
assert(s != NULL);
assert(s->srv != NULL);
@@ -150,8 +150,8 @@ hid_interrupt(bthid_session_p s, uint8_t
}
 
report_id = data[1];
-   data += 2;
-   len -= 2;
+   data ++;
+   len --;
 
hid_device = get_hid_device(&s->bdaddr);
assert(hid_device != NULL);
@@ -202,17 +202,11 @@ hid_interrupt(bthid_session_p s, uint8_t
if (val && val < kbd_maxkey())
bit_set(s->keys1, val);
 
-   data ++;
-   len --;
-
-   len = min(len, h.report_size);
-   while (len > 0) {
+   for (i = 1; i < h.report_count; i++) {
+   h.pos += h.report_size;
val = hid_get_data(data, &h);
if (val && val < kbd_maxkey())
bit_set(s->keys1, val);
-
-   data ++;
-   len --;
}
}
break;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r207816 - head/share/man/man3

2010-05-09 Thread Jilles Tjoelker
Author: jilles
Date: Sun May  9 14:21:34 2010
New Revision: 207816
URL: http://svn.freebsd.org/changeset/base/207816

Log:
  Document clock and pshared condvar attributes.
  
  Note: clock accepts CLOCK_VIRTUAL and CLOCK_PROF too, but this seems broken
  as it simply waits for the difference of the current and given value of the
  clock as if it were CLOCK_MONOTONIC. So document only CLOCK_REALTIME and
  CLOCK_MONOTONIC as allowed.
  
  MFC after:1 week

Modified:
  head/share/man/man3/Makefile
  head/share/man/man3/pthread_cond_timedwait.3
  head/share/man/man3/pthread_condattr.3

Modified: head/share/man/man3/Makefile
==
--- head/share/man/man3/MakefileSun May  9 12:36:51 2010
(r207815)
+++ head/share/man/man3/MakefileSun May  9 14:21:34 2010
(r207816)
@@ -251,7 +251,11 @@ PTHREAD_MLINKS+=pthread_barrierattr.3 pt
 PTHREAD_MLINKS+=pthread_barrier_destroy.3 pthread_barrier_init.3 \
pthread_barrier_destroy.3 pthread_barrier_wait.3
 PTHREAD_MLINKS+=pthread_condattr.3 pthread_condattr_destroy.3 \
-   pthread_condattr.3 pthread_condattr_init.3
+   pthread_condattr.3 pthread_condattr_init.3 \
+   pthread_condattr.3 pthread_condattr_getclock.3 \
+   pthread_condattr.3 pthread_condattr_setclock.3 \
+   pthread_condattr.3 pthread_condattr_getpshared.3 \
+   pthread_condattr.3 pthread_condattr_setpshared.3
 PTHREAD_MLINKS+=pthread_getconcurrency.3 pthread_setconcurrency.3
 PTHREAD_MLINKS+=pthread_multi_np.3 pthread_single_np.3
 PTHREAD_MLINKS+=pthread_mutexattr.3 pthread_mutexattr_destroy.3 \

Modified: head/share/man/man3/pthread_cond_timedwait.3
==
--- head/share/man/man3/pthread_cond_timedwait.3Sun May  9 12:36:51 
2010(r207815)
+++ head/share/man/man3/pthread_cond_timedwait.3Sun May  9 14:21:34 
2010(r207816)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 28, 1998
+.Dd May 9, 2010
 .Dt PTHREAD_COND_TIMEDWAIT 3
 .Os
 .Sh NAME
@@ -56,6 +56,11 @@ time specified in
 .Fa abstime ,
 and the current thread reacquires the lock on
 .Fa mutex .
+.Pp
+The clock used to measure
+.Fa abstime
+can be specified during creation of the condition variable using
+.Xr pthread_condattr_setclock 3 .
 .Sh RETURN VALUES
 If successful, the
 .Fn pthread_cond_timedwait
@@ -87,7 +92,8 @@ was not locked by the calling thread.
 .Xr pthread_cond_destroy 3 ,
 .Xr pthread_cond_init 3 ,
 .Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_wait 3
+.Xr pthread_cond_wait 3 ,
+.Xr pthread_condattr_setclock 3
 .Sh STANDARDS
 The
 .Fn pthread_cond_timedwait

Modified: head/share/man/man3/pthread_condattr.3
==
--- head/share/man/man3/pthread_condattr.3  Sun May  9 12:36:51 2010
(r207815)
+++ head/share/man/man3/pthread_condattr.3  Sun May  9 14:21:34 2010
(r207816)
@@ -26,12 +26,16 @@
 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
-.Dd April 28, 2000
+.Dd May 9, 2010
 .Dt PTHREAD_CONDATTR 3
 .Os
 .Sh NAME
 .Nm pthread_condattr_init ,
-.Nm pthread_condattr_destroy
+.Nm pthread_condattr_destroy ,
+.Nm pthread_condattr_getclock ,
+.Nm pthread_condattr_setclock ,
+.Nm pthread_condattr_getpshared ,
+.Nm pthread_condattr_setpshared ,
 .Nd condition attribute operations
 .Sh LIBRARY
 .Lb libpthread
@@ -41,14 +45,17 @@
 .Fn pthread_condattr_init "pthread_condattr_t *attr"
 .Ft int
 .Fn pthread_condattr_destroy "pthread_condattr_t *attr"
+.Ft int
+.Fn pthread_condattr_getclock "pthread_condattr_t * restrict attr" "clock_t * 
restrict clock_id"
+.Ft int
+.Fn pthread_condattr_setclock "pthread_condattr_t *attr" "clock_t clock_id"
+.Ft int
+.Fn pthread_condattr_getpshared "pthread_condattr_t * restrict attr" "int * 
restrict pshared"
+.Ft int
+.Fn pthread_condattr_setpshared "pthread_condattr_t *attr" "int pshared"
 .Sh DESCRIPTION
 Condition attribute objects are used to specify parameters to
 .Fn pthread_cond_init .
-.Fx Ns 's
-implementation of conditions does not support any non-default
-attributes, so these functions are not very useful, though they are required
-to be present by
-.Tn POSIX .
 .Pp
 The
 .Fn pthread_condattr_init
@@ -57,6 +64,52 @@ function initializes a condition attribu
 The
 .Fn pthread_condattr_destroy
 function destroys a condition attribute object.
+.Pp
+The
+.Fn pthread_condattr_getclock
+function will put the value of the clock attribute from
+.Fa attr
+into the memory area pointed to by
+.Fa clock_id .
+The
+.Fn pthread_condattr_setclock
+function will set the clock attribute of
+.Fa attr
+to the value specified in
+.Fa clock_id .
+The clock attribute affects the interpretation of
+.Fa abstime
+in
+.Xr pthread_cond_timedwait 3
+and may be set to
+.Dv CLOCK_REALTIME
+(default)
+or
+.Dv CLOCK_MONOTONIC .
+

svn commit: r207817 - head/share/man/man1

2010-05-09 Thread Jilles Tjoelker
Author: jilles
Date: Sun May  9 15:00:30 2010
New Revision: 207817
URL: http://svn.freebsd.org/changeset/base/207817

Log:
  builtin(1): sh has no @ builtin command.
  
  MFC after:1 week

Modified:
  head/share/man/man1/builtin.1

Modified: head/share/man/man1/builtin.1
==
--- head/share/man/man1/builtin.1   Sun May  9 14:21:34 2010
(r207816)
+++ head/share/man/man1/builtin.1   Sun May  9 15:00:30 2010
(r207817)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 25, 2010
+.Dd May 9, 2010
 .Dt BUILTIN 1
 .Os
 .Sh NAME
@@ -200,7 +200,7 @@ but are implemented as scripts using a b
 .It Ic % Ta \&No Ta Yes Ta \&No
 .It Ic \&. Ta \&No Ta \&No Ta Yes
 .It Ic \&: Ta \&No Ta Yes Ta Yes
-.It Ic @ Ta \&No Ta Yes Ta Yes
+.It Ic @ Ta \&No Ta Yes Ta \&No
 .It Ic \&[ Ta Yes Ta \&No Ta Yes
 .It Ic { Ta \&No Ta \&No Ta Yes
 .It Ic } Ta \&No Ta \&No Ta Yes
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r207820 - head/tools/regression/bin/sh/errors

2010-05-09 Thread Jilles Tjoelker
Author: jilles
Date: Sun May  9 16:04:32 2010
New Revision: 207820
URL: http://svn.freebsd.org/changeset/base/207820

Log:
  sh: Fix bug in assignment error test.
  
  The test failed if the command returned nonzero exit status, and it really
  should return that.

Modified:
  head/tools/regression/bin/sh/errors/assignment-error1.0

Modified: head/tools/regression/bin/sh/errors/assignment-error1.0
==
--- head/tools/regression/bin/sh/errors/assignment-error1.0 Sun May  9 
15:41:27 2010(r207819)
+++ head/tools/regression/bin/sh/errors/assignment-error1.0 Sun May  9 
16:04:32 2010(r207820)
@@ -26,5 +26,5 @@ do
 done
 
 # Other utilities must not abort; we currently still execute them.
-sh -c "readonly a=0; a=1 true; exit $a" 2>/dev/null || exit 1
-sh -c "readonly a=0; a=1 command :; exit $a" 2>/dev/null || exit 1
+sh -c 'readonly a=0; a=1 true; exit $a' 2>/dev/null || exit 1
+sh -c 'readonly a=0; a=1 command :; exit $a' 2>/dev/null || exit 1
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r207821 - in head/tools/regression: bin/sh/builtins lib/libc/gen

2010-05-09 Thread Jilles Tjoelker
Author: jilles
Date: Sun May  9 16:15:40 2010
New Revision: 207821
URL: http://svn.freebsd.org/changeset/base/207821

Log:
  Generate some tests for sh's case command from the fnmatch tests.
  
  I'm committing the generated files because I don't like a build dependency
  for the sh(1) tests, and they are small and will not change much.

Added:
  head/tools/regression/bin/sh/builtins/case2.0   (contents, props changed)
  head/tools/regression/bin/sh/builtins/case3.0   (contents, props changed)
Modified:
  head/tools/regression/lib/libc/gen/Makefile
  head/tools/regression/lib/libc/gen/test-fnmatch.c

Added: head/tools/regression/bin/sh/builtins/case2.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/case2.0   Sun May  9 16:15:40 
2010(r207821)
@@ -0,0 +1,106 @@
+# Generated by ./test-fnmatch -s 1, do not edit.
+# $FreeBSD$
+failures=
+failed() { printf '%s\n' "Failed: $1 '$2' '$3'"; failures=x$failures; }
+testmatch() { eval "case \$2 in ''$1) ;; *) failed testmatch \"\...@\";; 
esac"; }
+testnomatch() { eval "case \$2 in ''$1) failed testnomatch \"\...@\";; esac"; }
+testmatch '' ''
+testmatch 'a' 'a'
+testnomatch 'a' 'b'
+testnomatch 'a' 'A'
+testmatch '*' 'a'
+testmatch '*' 'aa'
+testmatch '*a' 'a'
+testnomatch '*a' 'b'
+testnomatch '*a*' 'b'
+testmatch '*a*b*' 'ab'
+testmatch '*a*b*' 'qaqbq'
+testmatch '*a*bb*' 'qaqbqbbq'
+testmatch '*a*bc*' 'qaqbqbcq'
+testmatch '*a*bb*' 'qaqbqbb'
+testmatch '*a*bc*' 'qaqbqbc'
+testmatch '*a*bb' 'qaqbqbb'
+testmatch '*a*bc' 'qaqbqbc'
+testnomatch '*a*bb' 'qaqbqbbq'
+testnomatch '*a*bc' 'qaqbqbcq'
+testnomatch '*a*a*a*a*a*a*a*a*a*a*' 'a'
+testmatch '*a*a*a*a*a*a*a*a*a*a*' 'aa'
+testmatch '*a*a*a*a*a*a*a*a*a*a*' 'aaa'
+testnomatch '.*.*.*.*.*.*.*.*.*.*' '.'
+testmatch '.*.*.*.*.*.*.*.*.*.*' '..'
+testmatch '.*.*.*.*.*.*.*.*.*.*' '...'
+testnomatch '*?*?*?*?*?*?*?*?*?*?*' '123456789'
+testnomatch '??*' '123456789'
+testnomatch '*??' '123456789'
+testmatch '*?*?*?*?*?*?*?*?*?*?*' '1234567890'
+testmatch '??*' '1234567890'
+testmatch '*??' '1234567890'
+testmatch '*?*?*?*?*?*?*?*?*?*?*' '12345678901'
+testmatch '??*' '12345678901'
+testmatch '*??' '12345678901'
+testmatch '[x]' 'x'
+testmatch '[*]' '*'
+testmatch '[?]' '?'
+testmatch '[' '['
+testmatch '[[]' '['
+testnomatch '[[]' 'x'
+testnomatch '[*]' ''
+testnomatch '[*]' 'x'
+testnomatch '[?]' 'x'
+testmatch '*[*]*' 'foo*foo'
+testnomatch '*[*]*' 'foo'
+testmatch '[0-9]' '0'
+testmatch '[0-9]' '5'
+testmatch '[0-9]' '9'
+testnomatch '[0-9]' '/'
+testnomatch '[0-9]' ':'
+testnomatch '[0-9]' '*'
+testnomatch '[!0-9]' '0'
+testnomatch '[!0-9]' '5'
+testnomatch '[!0-9]' '9'
+testmatch '[!0-9]' '/'
+testmatch '[!0-9]' ':'
+testmatch '[!0-9]' '*'
+testmatch '*[0-9]' 'a0'
+testmatch '*[0-9]' 'a5'
+testmatch '*[0-9]' 'a9'
+testnomatch '*[0-9]' 'a/'
+testnomatch '*[0-9]' 'a:'
+testnomatch '*[0-9]' 'a*'
+testnomatch '*[!0-9]' 'a0'
+testnomatch '*[!0-9]' 'a5'
+testnomatch '*[!0-9]' 'a9'
+testmatch '*[!0-9]' 'a/'
+testmatch '*[!0-9]' 'a:'
+testmatch '*[!0-9]' 'a*'
+testmatch '*[0-9]' 'a00'
+testmatch '*[0-9]' 'a55'
+testmatch '*[0-9]' 'a99'
+testmatch '*[0-9]' 'a0a0'
+testmatch '*[0-9]' 'a5a5'
+testmatch '*[0-9]' 'a9a9'
+testmatch '\*' '*'
+testmatch '\?' '?'
+testmatch '\[x]' '[x]'
+testmatch '\[' '['
+testmatch '\\' '\'
+testmatch '*\**' 'foo*foo'
+testnomatch '*\**' 'foo'
+testmatch '*\\*' 'foo\foo'
+testnomatch '*\\*' 'foo'
+testmatch '\(' '('
+testmatch '\a' 'a'
+testnomatch '\*' 'a'
+testnomatch '\?' 'a'
+testnomatch '\*' '\*'
+testnomatch '\?' '\?'
+testnomatch '\[x]' '\[x]'
+testnomatch '\[x]' '\x'
+testnomatch '\[' '\['
+testnomatch '\(' '\('
+testnomatch '\a' '\a'
+testmatch '.*' '.'
+testmatch '.*' '..'
+testmatch '.*' '.a'
+testmatch 'a*' 'a.'
+[ -z "$failures" ]

Added: head/tools/regression/bin/sh/builtins/case3.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/case3.0   Sun May  9 16:15:40 
2010(r207821)
@@ -0,0 +1,95 @@
+# Generated by ./test-fnmatch -s 2, do not edit.
+# $FreeBSD$
+failures=
+failed() { printf '%s\n' "Failed: $1 '$2' '$3'"; failures=x$failures; }
+# We do not treat a backslash specially in this case,
+# but this is not the case in all shells.
+netestmatch() { case $2 in $1) ;; *) failed netestmatch "$@";; esac; }
+netestnomatch() { case $2 in $1) failed netestnomatch "$@";; esac; }
+netestmatch '' ''
+netestmatch 'a' 'a'
+netestnomatch 'a' 'b'
+netestnomatch 'a' 'A'
+netestmatch '*' 'a'
+netestmatch '*' 'aa'
+netestmatch '*a' 'a'
+netestnomatch '*a' 'b'
+netestnomatch '*a*' 'b'
+netestmatch '*a*b*' 'ab'
+netestmatch '*a*b*' 'qaqbq'
+netestmatch '*a*bb*' 'qaqbqbbq'
+netestmatch '*a*bc*' 'qaqbqbcq'
+net

svn commit: r207822 - head/sys/vm

2010-05-09 Thread Alan Cox
Author: alc
Date: Sun May  9 16:27:42 2010
New Revision: 207822
URL: http://svn.freebsd.org/changeset/base/207822

Log:
  Call vm_page_deactivate() rather than vm_page_dontneed() in
  swp_pager_force_pagein().  By dirtying the page, swp_pager_force_pagein()
  forces vm_page_dontneed() to insert the page at the head of the inactive
  queue, just like vm_page_deactivate() does.  Moreover, because the page
  was invalid, it can't have been mapped, and thus the other effect of
  vm_page_dontneed(), clearing the page's reference bits has no effect.  In
  summary, there is no reason to call vm_page_dontneed() since its effect
  will be identical to calling the simpler vm_page_deactivate().

Modified:
  head/sys/vm/swap_pager.c

Modified: head/sys/vm/swap_pager.c
==
--- head/sys/vm/swap_pager.cSun May  9 16:15:40 2010(r207821)
+++ head/sys/vm/swap_pager.cSun May  9 16:27:42 2010(r207822)
@@ -1719,11 +1719,9 @@ swp_pager_force_pagein(vm_object_t objec
if (swap_pager_getpages(object, &m, 1, 0) != VM_PAGER_OK)
panic("swap_pager_force_pagein: read from swap failed");/*XXX*/
vm_object_pip_subtract(object, 1);
-   vm_page_lock(m);
-   vm_page_lock_queues();
vm_page_dirty(m);
-   vm_page_dontneed(m);
-   vm_page_unlock_queues();
+   vm_page_lock(m);
+   vm_page_deactivate(m);
vm_page_unlock(m);
vm_page_wakeup(m);
vm_pager_page_unswapped(m);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r207823 - head/sys/vm

2010-05-09 Thread Alan Cox
Author: alc
Date: Sun May  9 16:55:42 2010
New Revision: 207823
URL: http://svn.freebsd.org/changeset/base/207823

Log:
  Push down the acquisition of the page queues lock into vm_pageq_remove().
  (This eliminates a surprising number of page queues lock acquisitions by
  vm_fault() because the page's queue is PQ_NONE and thus the page queues
  lock is not needed to remove the page from a queue.)

Modified:
  head/sys/vm/vm_fault.c
  head/sys/vm/vm_page.c

Modified: head/sys/vm/vm_fault.c
==
--- head/sys/vm/vm_fault.c  Sun May  9 16:27:42 2010(r207822)
+++ head/sys/vm/vm_fault.c  Sun May  9 16:55:42 2010(r207823)
@@ -363,9 +363,7 @@ RetryFault:;
vm_object_deallocate(fs.first_object);
goto RetryFault;
}
-   vm_page_lock_queues();
vm_pageq_remove(fs.m);
-   vm_page_unlock_queues();
vm_page_unlock(fs.m);
 
/*

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Sun May  9 16:27:42 2010(r207822)
+++ head/sys/vm/vm_page.c   Sun May  9 16:55:42 2010(r207823)
@@ -169,6 +169,7 @@ TUNABLE_INT("vm.boot_pages", &boot_pages
 SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RD, &boot_pages, 0,
"number of pages allocated for bootstrapping the VM system");
 
+static void vm_page_queue_remove(int queue, vm_page_t m);
 static void vm_page_enqueue(int queue, vm_page_t m);
 
 /* Make sure that u_long is at least 64 bits when PAGE_SIZE is 32K. */
@@ -1328,24 +1329,43 @@ vm_page_requeue(vm_page_t m)
 }
 
 /*
+ * vm_page_queue_remove:
+ *
+ * Remove the given page from the specified queue.
+ *
+ * The page and page queues must be locked.
+ */
+static __inline void
+vm_page_queue_remove(int queue, vm_page_t m)
+{
+   struct vpgqueues *pq;
+
+   mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+   vm_page_lock_assert(m, MA_OWNED);
+   pq = &vm_page_queues[queue];
+   TAILQ_REMOVE(&pq->pl, m, pageq);
+   (*pq->cnt)--;
+}
+
+/*
  * vm_pageq_remove:
  *
  * Remove a page from its queue.
  *
- * The queue containing the given page must be locked.
+ * The given page must be locked.
  * This routine may not block.
  */
 void
 vm_pageq_remove(vm_page_t m)
 {
int queue = VM_PAGE_GETQUEUE(m);
-   struct vpgqueues *pq;
 
+   vm_page_lock_assert(m, MA_OWNED);
if (queue != PQ_NONE) {
+   vm_page_lock_queues();
VM_PAGE_SETQUEUE2(m, PQ_NONE);
-   pq = &vm_page_queues[queue];
-   TAILQ_REMOVE(&pq->pl, m, pageq);
-   (*pq->cnt)--;
+   vm_page_queue_remove(queue, m);
+   vm_page_unlock_queues();
}
 }
 
@@ -1380,18 +1400,20 @@ vm_page_enqueue(int queue, vm_page_t m)
 void
 vm_page_activate(vm_page_t m)
 {
+   int queue;
 
vm_page_lock_assert(m, MA_OWNED);
-   if (VM_PAGE_GETKNOWNQUEUE2(m) != PQ_ACTIVE) {
+   if ((queue = VM_PAGE_GETKNOWNQUEUE2(m)) != PQ_ACTIVE) {
if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) {
if (m->act_count < ACT_INIT)
m->act_count = ACT_INIT;
vm_page_lock_queues();
-   vm_pageq_remove(m);
+   if (queue != PQ_NONE)
+   vm_page_queue_remove(queue, m);
vm_page_enqueue(PQ_ACTIVE, m);
vm_page_unlock_queues();
} else
-   KASSERT(m->queue == PQ_NONE,
+   KASSERT(queue == PQ_NONE,
("vm_page_activate: wired page %p is queued", m));
} else {
if (m->act_count < ACT_INIT)
@@ -1472,11 +1494,8 @@ vm_page_free_toq(vm_page_t m)
 * callback routine until after we've put the page on the
 * appropriate free queue.
 */
-   if (VM_PAGE_GETQUEUE(m) != PQ_NONE) {
-   vm_page_lock_queues();
+   if ((m->flags & PG_UNMANAGED) == 0)
vm_pageq_remove(m);
-   vm_page_unlock_queues();
-   }
vm_page_remove(m);
 
/*
@@ -1554,11 +1573,8 @@ vm_page_wire(vm_page_t m)
if (m->flags & PG_FICTITIOUS)
return;
if (m->wire_count == 0) {
-   if ((m->flags & PG_UNMANAGED) == 0) {
-   vm_page_lock_queues();
+   if ((m->flags & PG_UNMANAGED) == 0)
vm_pageq_remove(m);
-   vm_page_unlock_queues();
-   }
atomic_add_int(&cnt.v_wire_count, 1);
}
m->wire_count++;
@@ -1633,22 +1649,26 @@ vm_page_unwire(vm_page

Re: svn commit: r206878 - head/sys/kern

2010-05-09 Thread Marius Strobl
On Mon, Apr 19, 2010 at 11:27:54PM +, Attilio Rao wrote:
> Author: attilio
> Date: Mon Apr 19 23:27:54 2010
> New Revision: 206878
> URL: http://svn.freebsd.org/changeset/base/206878
> 
> Log:
>   Fix a deadlock in the shutdown code:
>   When performing a smp_rendezvous() or more likely, on amd64 and i386,
>   a smp_tlb_shootdown() the caller will end up with the smp_ipi_mtx
>   spinlock held, busy-waiting for other CPUs to acknowledge the operation.
>   As long as CPUs are suspended (via cpu_reset()) between the active mask
>   read and IPI sending there can be a deadlock where the caller will wait
>   forever for a dead CPU to acknowledge the operation.
>   Please note that on CPU0 that is going to be someway heavier because of
>   the spinlocks being disabled earlier than quitting the machine.
>   
>   Fix this bug by calling cpu_reset() with the smp_ipi_mtx held.
>   Note that it is very likely that a saner offline/online CPUs mechanism
>   will help heavilly in fixing similar cases as it is likely more bugs
>   of this type may arise in the future.
>   

This change causes a hang for me when running an SMP kernel on an
UP machine or an MP machine with SMP disabled as in these cases
smp_ipi_mtx isn't initialized (see mp_start()). The below patch
fixes this for me.

Marius

Index: kern_shutdown.c
===
--- kern_shutdown.c (revision 207463)
+++ kern_shutdown.c (working copy)
@@ -491,8 +491,8 @@ shutdown_reset(void *junk, int howto)
/*
 * Acquiring smp_ipi_mtx here has a double effect:
 * - it disables interrupts avoiding CPU0 preemption
-*   by fast handlers (thus deadlocking  against other CPUs)
-* - it avoids deadlocks against smp_rendezvous() or, more 
+*   by fast handlers (thus deadlocking against other CPUs)
+* - it avoids deadlocks against smp_rendezvous() or, more
 *   generally, threads busy-waiting, with this spinlock held,
 *   and waiting for responses by threads on other CPUs
 *   (ie. smp_tlb_shootdown()).
@@ -500,9 +500,11 @@ shutdown_reset(void *junk, int howto)
 * For the !SMP case it just needs to handle the former problem.
 */
 #ifdef SMP
-   mtx_lock_spin(&smp_ipi_mtx);
+   if (mtx_initialized(&smp_ipi_mtx) != 0)
+   mtx_lock_spin(&smp_ipi_mtx);
+   else
 #else
-   spinlock_enter();
+   spinlock_enter();
 #endif
 
/* cpu_boot(howto); */ /* doesn't do anything at the moment */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r207824 - head/tools/regression/bin/sh/parser

2010-05-09 Thread Jilles Tjoelker
Author: jilles
Date: Sun May  9 17:10:50 2010
New Revision: 207824
URL: http://svn.freebsd.org/changeset/base/207824

Log:
  sh: Add some parser tests.
  
  case1.0 tests POSIX requirements and one more for keywords in case
  statements. The others test very special cases of command substitution.
  
  These also work on stable/8.

Added:
  head/tools/regression/bin/sh/parser/case1.0   (contents, props changed)
  head/tools/regression/bin/sh/parser/case2.0   (contents, props changed)
  head/tools/regression/bin/sh/parser/heredoc3.0   (contents, props changed)

Added: head/tools/regression/bin/sh/parser/case1.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/parser/case1.0 Sun May  9 17:10:50 2010
(r207824)
@@ -0,0 +1,14 @@
+# $FreeBSD$
+
+keywords='if then else elif fi while until for do done { } case esac ! in'
+
+# Keywords can be used unquoted in case statements, except the keyword
+# esac as the first pattern of a '|' alternation without a starting '('.
+# (POSIX doesn't seem to require (esac) to work.)
+for k in $keywords; do
+   eval "case $k in (foo|$k) ;; *) echo bad ;; esac"
+   eval "case $k in ($k) ;; *) echo bad ;; esac"
+   eval "case $k in foo|$k) ;; *) echo bad ;; esac"
+   [ "$k" = esac ] && continue
+   eval "case $k in $k) ;; *) echo bad ;; esac"
+done

Added: head/tools/regression/bin/sh/parser/case2.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/parser/case2.0 Sun May  9 17:10:50 2010
(r207824)
@@ -0,0 +1,32 @@
+# $FreeBSD$
+
+# Pretty much only ash derivatives can parse all of this.
+
+f1() {
+   x=$(case x in
+   (x|esac) ;;
+   (*) echo bad >&2 ;;
+   esac)
+}
+f1
+f2() {
+   x=$(case x in
+   (x|esac) ;;
+   (*) echo bad >&2
+   esac)
+}
+f2
+f3() {
+   x=$(case x in
+   x|esac) ;;
+   *) echo bad >&2 ;;
+   esac)
+}
+f3
+f4() {
+   x=$(case x in
+   x|esac) ;;
+   *) echo bad >&2
+   esac)
+}
+f4

Added: head/tools/regression/bin/sh/parser/heredoc3.0
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/parser/heredoc3.0  Sun May  9 17:10:50 
2010(r207824)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+# This may be expected to work, but pretty much only ash derivatives allow it.
+
+test "$(cat 

svn commit: r207825 - head/tools/regression/bin/sh/builtins

2010-05-09 Thread Jilles Tjoelker
Author: jilles
Date: Sun May  9 17:15:26 2010
New Revision: 207825
URL: http://svn.freebsd.org/changeset/base/207825

Log:
  Fix error in comment.

Modified:
  head/tools/regression/bin/sh/builtins/var-assign2.0

Modified: head/tools/regression/bin/sh/builtins/var-assign2.0
==
--- head/tools/regression/bin/sh/builtins/var-assign2.0 Sun May  9 17:10:50 
2010(r207824)
+++ head/tools/regression/bin/sh/builtins/var-assign2.0 Sun May  9 17:15:26 
2010(r207825)
@@ -40,7 +40,7 @@ UTILS="alias,\
 
 set -e
 
-# With 'command', variable assignments affect the shell environment.
+# With 'command', variable assignments do not affect the shell environment.
 
 set -- ${SPECIAL}
 for cmd in "$@"
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r207828 - head/sys/netinet6

2010-05-09 Thread Kip Macy
Author: kmacy
Date: Sun May  9 20:32:00 2010
New Revision: 207828
URL: http://svn.freebsd.org/changeset/base/207828

Log:
  Add flowtable support to IPv6
  
  Tested by: qingli@
  
  Reviewed by:  qingli@
  MFC after:3 days

Modified:
  head/sys/netinet6/in6_proto.c
  head/sys/netinet6/ip6_input.c
  head/sys/netinet6/ip6_output.c
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/netinet6/in6_proto.c
==
--- head/sys/netinet6/in6_proto.c   Sun May  9 19:32:37 2010
(r207827)
+++ head/sys/netinet6/in6_proto.c   Sun May  9 20:32:00 2010
(r207828)
@@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
 #include "opt_carp.h"
 #include "opt_sctp.h"
 #include "opt_mpath.h"
+#include "opt_route.h"
 
 #include 
 #include 
@@ -130,6 +131,10 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#ifdef FLOWTABLE
+#include 
+#endif
+
 /*
  * TCP/IP protocol family: IP6, ICMP6, UDP, TCP.
  */
@@ -569,6 +574,16 @@ SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_
&VNET_NAME(ip6stealth), 0, "");
 #endif
 
+#ifdef FLOWTABLE
+VNET_DEFINE(int, ip6_output_flowtable_size) = 2048;
+VNET_DEFINE(struct flowtable *, ip6_ft);
+#defineV_ip6_output_flowtable_size VNET(ip6_output_flowtable_size)
+
+SYSCTL_VNET_INT(_net_inet6_ip6, OID_AUTO, output_flowtable_size, CTLFLAG_RDTUN,
+&VNET_NAME(ip6_output_flowtable_size), 2048,
+"number of entries in the per-cpu output flow caches");
+#endif
+
 /* net.inet6.icmp6 */
 SYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, rediraccept,
CTLFLAG_RW, &VNET_NAME(icmp6_rediraccept), 0, "");

Modified: head/sys/netinet6/ip6_input.c
==
--- head/sys/netinet6/ip6_input.c   Sun May  9 19:32:37 2010
(r207827)
+++ head/sys/netinet6/ip6_input.c   Sun May  9 20:32:00 2010
(r207828)
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_ipsec.h"
+#include "opt_route.h"
 
 #include 
 #include 
@@ -113,6 +114,12 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#ifdef FLOWTABLE
+#include 
+extern VNET_DEFINE(int, ip6_output_flowtable_size);
+#defineV_ip6_output_flowtable_size VNET(ip6_output_flowtable_size)
+#endif
+
 extern struct domain inet6domain;
 
 u_char ip6_protox[IPPROTO_MAX];
@@ -169,6 +176,12 @@ ip6_init(void)
nd6_init();
frag6_init();
 
+#ifdef FLOWTABLE
+   TUNABLE_INT_FETCH("net.inet6.ip6.output_flowtable_size",
+   &V_ip6_output_flowtable_size);
+   V_ip6_ft = flowtable_alloc("ipv6", V_ip6_output_flowtable_size, 
FL_PCPU);
+#endif 
+   
V_ip6_desync_factor = arc4random() % MAX_TEMP_DESYNC_FACTOR;
 
/* Skip global initialization stuff for non-default instances. */

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Sun May  9 19:32:37 2010
(r207827)
+++ head/sys/netinet6/ip6_output.c  Sun May  9 20:32:00 2010
(r207828)
@@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
 #include "opt_inet6.h"
 #include "opt_ipsec.h"
 #include "opt_sctp.h"
+#include "opt_route.h"
 
 #include 
 #include 
@@ -111,6 +112,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#ifdef FLOWTABLE
+#include 
+#endif
+
 extern int in6_mcast_loop;
 
 struct ip6_exthdrs {
@@ -211,6 +216,7 @@ ip6_output(struct mbuf *m0, struct ip6_p
struct in6_addr finaldst, src0, dst0;
u_int32_t zone;
struct route_in6 *ro_pmtu = NULL;
+   int flevalid = 0;
int hdrsplit = 0;
int needipsec = 0;
 #ifdef SCTP
@@ -231,9 +237,7 @@ ip6_output(struct mbuf *m0, struct ip6_p
}
 
finaldst = ip6->ip6_dst;
-
bzero(&exthdrs, sizeof(exthdrs));
-
if (opt) {
/* Hop-by-Hop options header */
MAKE_EXTHDR(opt->ip6po_hbh, &exthdrs.ip6e_hbh);
@@ -470,7 +474,22 @@ skip_ipsec2:;
if (opt && opt->ip6po_rthdr)
ro = &opt->ip6po_route;
dst = (struct sockaddr_in6 *)&ro->ro_dst;
-
+#ifdef FLOWTABLE
+   if (ro == &ip6route) {
+   struct flentry *fle;
+   
+   /*
+* The flow table returns route entries valid for up to 30
+* seconds; we rely on the remainder of ip_output() taking no
+* longer than that long for the stability of ro_rt.  The
+* flow ID assignment must have happened before this point.
+*/
+   if ((fle = flowtable_lookup_mbuf(V_ip6_ft, m, AF_INET6)) != 
NULL) {
+   flow_to_route_in6(fle, ro);
+   flevalid = 1;
+   }
+   }
+#endif 
 again:
/*
 * if specified, try to fill in the traffic class field.
@@ -576,7 +595,10 @@ again:
dst_sa.sin6_family = AF_INET6;
dst_sa.sin6_len = sizeof(dst_sa)

svn commit: r207829 - head/share/man/man4

2010-05-09 Thread Christian Brueffer
Author: brueffer
Date: Sun May  9 21:34:05 2010
New Revision: 207829
URL: http://svn.freebsd.org/changeset/base/207829

Log:
  Various wording, spelling and markup fixes.
  
  PR:   145251
  Submitted by: Hywel Mallett  (partly)
  MFC after:3 week

Modified:
  head/share/man/man4/iscsi_initiator.4

Modified: head/share/man/man4/iscsi_initiator.4
==
--- head/share/man/man4/iscsi_initiator.4   Sun May  9 20:32:00 2010
(r207828)
+++ head/share/man/man4/iscsi_initiator.4   Sun May  9 21:34:05 2010
(r207829)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 23, 2007
+.Dd May 9, 2010
 .Dt ISCSI_INITIATOR 4
 .Os
 .Sh NAME
@@ -48,34 +48,39 @@ iscsi_initiator_load="YES"
 The
 .Nm
 implements the kernel side of the Internet SCSI (iSCSI) network
-protocol standard, the user land companion is
+protocol standard.
+The userland companion is
 .Xr iscontrol 8 ,
 and permits access to remote
 .Em virtual
 SCSI devices via
 .Xr cam 4 .
 .Sh SYSCTL VARIABLES
-.Bl -tag -width ".Va net.iscsi.n.targeaddress"
+.Bl -tag -width "net.iscsi.n.targedaddress"
 .It Va debug.iscsi_initiator
 set the debug-level, 0 means no debugging, 9 for maximum.
 .It Va net.iscsi.isid
 the initiator part of the Session Identifier.
-.It "the following are informative only:"
+.El
+.Pp
+The following are informative only:
+.Pp
+.Bl -tag -width "net.iscsi.n.targedaddress"
 .It Va net.iscsi.driver_version
 the current version of the driver.
 .It Va net.iscsi.sessions
 the number of current active sessions.
 .It Va net.iscsi.n.targetname
-is the targe name of session
+the target name of session
 .Em n .
-.It Va net.iscsi.n.targeaddress
-is the IP address of the target of session
+.It Va net.iscsi.n.targedaddress
+the IP address of the target of session
 .Em n .
 .It Va net.iscsi.n.stats
-are some statistics for session
+statistics for session
 .Em n
 .It Va net.iscsi.n.pid
-is the 
+the 
 .Em "process id"
 of the userland side of session
 .Em n ,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r207830 - head/lib/libc/stdtime

2010-05-09 Thread Edwin Groothuis
Author: edwin
Date: Sun May  9 22:01:35 2010
New Revision: 207830
URL: http://svn.freebsd.org/changeset/base/207830

Log:
  strptime(3) confused July with June with the fr_FR locale.
  
  When parsing the month "juillet" (abbr "jul"), %B recognized it as
  "juin" (abbr "jui") because the full name of the month names is
  checked at the same time as the abbrevation.
  
  The new behaviour checks the full names first before checking the
  abbrevation names.
  
  PR:   kern/141939
  Submitted by: Denis Chatelain 
  MFC after:1 week

Modified:
  head/lib/libc/stdtime/strptime.c

Modified: head/lib/libc/stdtime/strptime.c
==
--- head/lib/libc/stdtime/strptime.cSun May  9 21:34:05 2010
(r207829)
+++ head/lib/libc/stdtime/strptime.cSun May  9 22:01:35 2010
(r207830)
@@ -408,6 +408,14 @@ label:
if (strncasecmp(buf, tptr->month[i],
len) == 0)
break;
+   }
+   }
+   /*
+* Try the abbreviated month name if the full name
+* wasn't found and Oalternative was not requested.
+*/
+   if (i == asizeof(tptr->month) && !Oalternative) {
+   for (i = 0; i < asizeof(tptr->month); i++) {
len = strlen(tptr->mon[i]);
if (strncasecmp(buf, tptr->mon[i],
len) == 0)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r207831 - head/bin/sh

2010-05-09 Thread Jilles Tjoelker
Author: jilles
Date: Sun May  9 22:03:18 2010
New Revision: 207831
URL: http://svn.freebsd.org/changeset/base/207831

Log:
  sh(1): Fix "reserved word" vs "keyword" inconsistency.
  Use "keyword" everywhere, like the output of the 'type' builtin, and only
  mention "reserved word" once to say it is the same thing.

Modified:
  head/bin/sh/sh.1

Modified: head/bin/sh/sh.1
==
--- head/bin/sh/sh.1Sun May  9 22:01:35 2010(r207830)
+++ head/bin/sh/sh.1Sun May  9 22:03:18 2010(r207831)
@@ -32,7 +32,7 @@
 .\"from: @(#)sh.1  8.6 (Berkeley) 5/4/95
 .\" $FreeBSD$
 .\"
-.Dd April 5, 2010
+.Dd May 9, 2010
 .Dt SH 1
 .Os
 .Sh NAME
@@ -415,11 +415,11 @@ character, with the exception of the new
 .Pq Ql \en .
 A backslash preceding a newline is treated as a line continuation.
 .El
-.Ss Reserved Words
-Reserved words are words that have special meaning to the
+.Ss Keywords
+Keywords or reserved words are words that have special meaning to the
 shell and are recognized at the beginning of a line and
 after a control operator.
-The following are reserved words:
+The following are keywords:
 .Bl -column "doneXX" "elifXX" "elseXX" "untilXX" "whileX" -offset center
 .It Li \&! Ta { Ta } Ta Ic case Ta Ic do
 .It Ic done Ta Ic elif Ta Ic else Ta Ic esac Ta Ic fi
@@ -429,8 +429,8 @@ The following are reserved words:
 An alias is a name and corresponding value set using the
 .Ic alias
 built-in command.
-Whenever a reserved word may occur (see above),
-and after checking for reserved words, the shell
+Whenever a keyword may occur (see above),
+and after checking for keywords, the shell
 checks the word to see if it matches an alias.
 If it does, it replaces it in the input stream with its value.
 For example, if there is an alias called
@@ -469,7 +469,7 @@ of this man page (refer to the BNF in th
 document).
 Essentially though, a line is read and if
 the first word of the line (or after a control operator)
-is not a reserved word, then the shell has recognized a
+is not a keyword, then the shell has recognized a
 simple command.
 Otherwise, a complex command or some
 other special construct may have been recognized.
@@ -695,7 +695,7 @@ Signal numbers are defined in the header
 .In sys/signal.h .
 .Ss Complex Commands
 Complex commands are combinations of simple commands
-with control operators or reserved words, together creating a larger complex
+with control operators or keywords, together creating a larger complex
 command.
 More generally, a command is one of the following:
 .Bl -item -offset indent
@@ -739,7 +739,7 @@ operators that are part of the command.
 If the pipeline is not in the background (discussed later),
 the shell waits for all commands to complete.
 .Pp
-If the reserved word
+If the keyword
 .Ic !\&
 does not precede the pipeline, the
 exit status is the exit status of the last command specified
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r207832 - head/sys/dev/fxp

2010-05-09 Thread Pyun YongHyeon
Author: yongari
Date: Sun May  9 22:16:15 2010
New Revision: 207832
URL: http://svn.freebsd.org/changeset/base/207832

Log:
  Export hardware MAC statistics through sysctl node. Previously
  fxp(4) already used to extract most hardware MAC statistics but it
  didn't show them. With this change, all MAC statistics counters
  are exported. Because there are a couple of new counters for 82558
  and 82559, enable extended MAC statistics functionality to get
  these counters. Accoring to public data sheet, 82559 MAC statistics
  return 24 DWORD counters(3 counters are unknown at this moment) so
  increase MAC counter structure to meet the MAC statistics block size.
  The completion of MAC counter dump is now checked against
  FXP_STATS_DR_COMPLETE status code which is appended at the end of
  status block. Previously fxp(4) ignored the status of the
  FXP_SCB_COMMAND_CU_DUMPRESET command. fxp(4) does not wait for the
  completion of pending command before issuing
  FXP_SCB_COMMAND_CU_DUMPRESET. Instead it skips the command and try
  it next time. This scheme may show better performance but there is
  chance to loose updated counters after stopping controller. So make
  sure to update MAC statistics in fxp_stop().
  While I'm here move sysctl node creation to fxp_sysctl_node().
  
  Tested by:Larry Baird < lab <> gta dot com >

Modified:
  head/sys/dev/fxp/if_fxp.c
  head/sys/dev/fxp/if_fxpreg.h
  head/sys/dev/fxp/if_fxpvar.h

Modified: head/sys/dev/fxp/if_fxp.c
==
--- head/sys/dev/fxp/if_fxp.c   Sun May  9 22:03:18 2010(r207831)
+++ head/sys/dev/fxp/if_fxp.c   Sun May  9 22:16:15 2010(r207832)
@@ -262,6 +262,8 @@ static int  fxp_miibus_readreg(device_t 
 static int fxp_miibus_writereg(device_t dev, int phy, int reg,
int value);
 static voidfxp_load_ucode(struct fxp_softc *sc);
+static voidfxp_update_stats(struct fxp_softc *sc);
+static voidfxp_sysctl_node(struct fxp_softc *sc);
 static int sysctl_int_range(SYSCTL_HANDLER_ARGS,
int low, int high);
 static int sysctl_hw_fxp_bundle_max(SYSCTL_HANDLER_ARGS);
@@ -537,39 +539,7 @@ fxp_attach(device_t dev)
&& (data & FXP_PHY_SERIAL_ONLY))
sc->flags |= FXP_FLAG_SERIAL_MEDIA;
 
-   SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-   SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-   OID_AUTO, "int_delay", CTLTYPE_INT | CTLFLAG_RW,
-   &sc->tunable_int_delay, 0, sysctl_hw_fxp_int_delay, "I",
-   "FXP driver receive interrupt microcode bundling delay");
-   SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
-   SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-   OID_AUTO, "bundle_max", CTLTYPE_INT | CTLFLAG_RW,
-   &sc->tunable_bundle_max, 0, sysctl_hw_fxp_bundle_max, "I",
-   "FXP driver receive interrupt microcode bundle size limit");
-   SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
-   SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-   OID_AUTO, "rnr", CTLFLAG_RD, &sc->rnr, 0,
-   "FXP RNR events");
-   SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
-   SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
-   OID_AUTO, "noflow", CTLFLAG_RW, &sc->tunable_noflow, 0,
-   "FXP flow control disabled");
-
-   /*
-* Pull in device tunables.
-*/
-   sc->tunable_int_delay = TUNABLE_INT_DELAY;
-   sc->tunable_bundle_max = TUNABLE_BUNDLE_MAX;
-   sc->tunable_noflow = 1;
-   (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
-   "int_delay", &sc->tunable_int_delay);
-   (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
-   "bundle_max", &sc->tunable_bundle_max);
-   (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
-   "noflow", &sc->tunable_noflow);
-   sc->rnr = 0;
-
+   fxp_sysctl_node(sc);
/*
 * Enable workarounds for certain chip revision deficiencies.
 *
@@ -2020,6 +1990,81 @@ fxp_intr_body(struct fxp_softc *sc, stru
return (rx_npkts);
 }
 
+static void
+fxp_update_stats(struct fxp_softc *sc)
+{
+   struct ifnet *ifp = sc->ifp;
+   struct fxp_stats *sp = sc->fxp_stats;
+   struct fxp_hwstats *hsp;
+   uint32_t *status;
+
+   FXP_LOCK_ASSERT(sc, MA_OWNED);
+
+   bus_dmamap_sync(sc->fxp_stag, sc->fxp_smap,
+   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+   /* Update statistical counters. */
+   if (sc->revision >= FXP_REV_82559_A0)
+   status = &sp->completion_status;
+   else if (sc->revision >= FXP_REV_82558_A4)
+   status = (uint32_t *)&sp->tx_tco;
+   else
+   status = &sp->tx_pause;
+   if (*status == htole32(FXP_STATS_DR_COMPLETE)) {
+   hsp = &sc->fxp

Re: svn commit: r206878 - head/sys/kern

2010-05-09 Thread Attilio Rao
2010/5/9 Marius Strobl :
> On Mon, Apr 19, 2010 at 11:27:54PM +, Attilio Rao wrote:
>> Author: attilio
>> Date: Mon Apr 19 23:27:54 2010
>> New Revision: 206878
>> URL: http://svn.freebsd.org/changeset/base/206878
>>
>> Log:
>>   Fix a deadlock in the shutdown code:
>>   When performing a smp_rendezvous() or more likely, on amd64 and i386,
>>   a smp_tlb_shootdown() the caller will end up with the smp_ipi_mtx
>>   spinlock held, busy-waiting for other CPUs to acknowledge the operation.
>>   As long as CPUs are suspended (via cpu_reset()) between the active mask
>>   read and IPI sending there can be a deadlock where the caller will wait
>>   forever for a dead CPU to acknowledge the operation.
>>   Please note that on CPU0 that is going to be someway heavier because of
>>   the spinlocks being disabled earlier than quitting the machine.
>>
>>   Fix this bug by calling cpu_reset() with the smp_ipi_mtx held.
>>   Note that it is very likely that a saner offline/online CPUs mechanism
>>   will help heavilly in fixing similar cases as it is likely more bugs
>>   of this type may arise in the future.
>>
>
> This change causes a hang for me when running an SMP kernel on an
> UP machine or an MP machine with SMP disabled as in these cases
> smp_ipi_mtx isn't initialized (see mp_start()). The below patch
> fixes this for me.

Marius,
thanks a lot for reporting this.
However, I think that a better fix is to always initialize the mutex.
Do you think the following patch is fine for you?:
http://www.freebsd.org/~attilio/smpipi_fixup.diff

Thanks,
Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"