svn commit: r242300 - head/sys/vm

2012-10-29 Thread Alan Cox
Author: alc
Date: Mon Oct 29 06:15:04 2012
New Revision: 242300
URL: http://svn.freebsd.org/changeset/base/242300

Log:
  Replace the page hold queue, PQ_HOLD, by a new page flag, PG_UNHOLDFREE,
  because the queue itself serves no purpose.  When a held page is freed,
  inserting the page into the hold queue has the side effect of setting the
  page's queue field to PQ_HOLD.  Later, when the page is unheld, it will
  be freed because the queue field is PQ_HOLD.  In other words, PQ_HOLD is
  used as a flag, not a queue.  So, this change replaces it with a flag.
  
  To accomodate the new page flag, make the page's flags field wider and
  oflags field narrower.
  
  Reviewed by:  kib

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

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Mon Oct 29 04:51:51 2012(r242299)
+++ head/sys/vm/vm_page.c   Mon Oct 29 06:15:04 2012(r242300)
@@ -308,7 +308,6 @@ vm_page_startup(vm_offset_t vaddr)
TAILQ_INIT(vm_page_queues[i].pl);
vm_page_queues[PQ_INACTIVE].cnt = cnt.v_inactive_count;
vm_page_queues[PQ_ACTIVE].cnt = cnt.v_active_count;
-   vm_page_queues[PQ_HOLD].cnt = cnt.v_active_count;
 
/*
 * Allocate memory for use when boot strapping the kernel memory
@@ -540,7 +539,7 @@ vm_page_unhold(vm_page_t mem)
vm_page_lock_assert(mem, MA_OWNED);
--mem-hold_count;
KASSERT(mem-hold_count = 0, (vm_page_unhold: hold count  0!!!));
-   if (mem-hold_count == 0  mem-queue == PQ_HOLD)
+   if (mem-hold_count == 0  (mem-flags  PG_UNHOLDFREE) != 0)
vm_page_free_toq(mem);
 }
 
@@ -2042,9 +2041,9 @@ vm_page_free_toq(vm_page_t m)
panic(vm_page_free: freeing wired page %p, m);
if (m-hold_count != 0) {
m-flags = ~PG_ZERO;
-   vm_page_lock_queues();
-   vm_page_enqueue(PQ_HOLD, m);
-   vm_page_unlock_queues();
+   KASSERT((m-flags  PG_UNHOLDFREE) == 0,
+   (vm_page_free: freeing PG_UNHOLDFREE page %p, m));
+   m-flags |= PG_UNHOLDFREE;
} else {
/*
 * Restore the default memory attribute to the page.

Modified: head/sys/vm/vm_page.h
==
--- head/sys/vm/vm_page.h   Mon Oct 29 04:51:51 2012(r242299)
+++ head/sys/vm/vm_page.h   Mon Oct 29 06:15:04 2012(r242300)
@@ -145,8 +145,8 @@ struct vm_page {
u_short cow;/* page cow mapping count (P) */
u_int wire_count;   /* wired down maps refs (P) */
uint8_t aflags; /* access is atomic */
-   uint8_t flags;  /* see below, often immutable after 
alloc */
-   u_short oflags; /* page flags (O) */
+   uint8_t oflags; /* page VPO_* flags (O) */
+   uint16_t flags; /* page PG_* flags (P) */
u_char  act_count;  /* page usage count (O) */
u_char  busy;   /* page busy count (O) */
/* NOTE that these must support one bit per DEV_BSIZE in a page!!! */
@@ -169,17 +169,16 @@ struct vm_page {
  *  mappings, and such pages are also not on any PQ queue.
  *
  */
-#defineVPO_BUSY0x0001  /* page is in transit */
-#defineVPO_WANTED  0x0002  /* someone is waiting for page */
-#defineVPO_UNMANAGED   0x0004  /* No PV management for page */
-#defineVPO_SWAPINPROG  0x0200  /* swap I/O in progress on page */
-#defineVPO_NOSYNC  0x0400  /* do not collect for syncer */
+#defineVPO_BUSY0x01/* page is in transit */
+#defineVPO_WANTED  0x02/* someone is waiting for page 
*/
+#defineVPO_UNMANAGED   0x04/* no PV management for page */
+#defineVPO_SWAPINPROG  0x08/* swap I/O in progress on page 
*/
+#defineVPO_NOSYNC  0x10/* do not collect for syncer */
 
 #definePQ_NONE 255
 #definePQ_INACTIVE 0
 #definePQ_ACTIVE   1
-#definePQ_HOLD 2
-#definePQ_COUNT3
+#definePQ_COUNT2
 
 struct vpgqueues {
struct pglist pl;
@@ -263,14 +262,15 @@ extern struct vpglocks pa_lock[];
  * Page flags.  If changed at any other time than page allocation or
  * freeing, the modification must be protected by the vm_page lock.
  */
-#definePG_CACHED   0x01/* page is cached */
-#definePG_FREE 0x02/* page is free */
-#definePG_FICTITIOUS   0x04/* physical page doesn't exist 
*/
-#definePG_ZERO 0x08/* page is zeroed */
-#definePG_MARKER   0x10/* special 

svn commit: r242301 - head/etc/rc.d

2012-10-29 Thread Hiroki Sato
Author: hrs
Date: Mon Oct 29 06:31:51 2012
New Revision: 242301
URL: http://svn.freebsd.org/changeset/base/242301

Log:
  Load ipdivert.ko when natd_enable=YES.
  
  PR:   conf/167566

Modified:
  head/etc/rc.d/ipfw

Modified: head/etc/rc.d/ipfw
==
--- head/etc/rc.d/ipfw  Mon Oct 29 06:15:04 2012(r242300)
+++ head/etc/rc.d/ipfw  Mon Oct 29 06:31:51 2012(r242301)
@@ -25,11 +25,11 @@ ipfw_prestart()
if checkyesno dummynet_enable; then
required_modules=$required_modules dummynet
fi
-
+   if checkyesno natd_enable; then
+   required_modules=$required_modules ipdivert
+   fi
if checkyesno firewall_nat_enable; then
-   if ! checkyesno natd_enable; then
-   required_modules=$required_modules ipfw_nat
-   fi
+   required_modules=$required_modules ipfw_nat
fi
 }
 
___
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


Re: svn commit: r242276 - head/sys/mips/cavium

2012-10-29 Thread Bruce Evans

On Mon, 29 Oct 2012, Juli Mallett wrote:


Log:
 Wrap some long lines and display board serial numbers at boot.


Any chance of using FreeBSD style instead of gnu style for the wrapping?


Modified: head/sys/mips/cavium/octeon_machdep.c
==
--- head/sys/mips/cavium/octeon_machdep.c   Mon Oct 29 01:51:24 2012
(r242275)
+++ head/sys/mips/cavium/octeon_machdep.c   Mon Oct 29 02:10:20 2012
(r242276)
@@ -512,14 +512,19 @@ octeon_process_app_desc_ver_6(void)
octeon_bootinfo-board_rev_major,
octeon_bootinfo-board_rev_minor,
octeon_bootinfo-eclock_hz);


This old wrapping uses gnu style (indent -lp).

The struct member names in it are verbose, but not verbose enough to have
normal style with a struct-dependent prefix.


-   memcpy(cvmx_sysinfo_get()-mac_addr_base, 
octeon_bootinfo-mac_addr_base, 6);
+   memcpy(cvmx_sysinfo_get()-mac_addr_base,
+  octeon_bootinfo-mac_addr_base, 6);


This new wrapping is in gnu style.  FreeBSD style is indent -ci4.


cvmx_sysinfo_get()-mac_addr_count = octeon_bootinfo-mac_addr_count;
cvmx_sysinfo_get()-compact_flash_common_base_addr =
octeon_bootinfo-compact_flash_common_base_addr;
cvmx_sysinfo_get()-compact_flash_attribute_base_addr =
octeon_bootinfo-compact_flash_attribute_base_addr;


The last 2 wrappings aren't in either gnu style or FreeBSD style.  FreeBSD
style is indent -ci4 again.  Gnu style is to put the operator on the new
line, and IIRC, line up the operator with the variable, resulting in no
indentation for the operator.  This has the FreeBSD style for the operator,
but a contination indent of 8.


cvmx_sysinfo_get()-core_mask = octeon_bootinfo-core_mask;
-   cvmx_sysinfo_get()-led_display_base_addr = 
octeon_bootinfo-led_display_base_addr;
+   cvmx_sysinfo_get()-led_display_base_addr =
+   octeon_bootinfo-led_display_base_addr;


This matches the above for neither gnu not FreeBSD style.


+   memcpy(cvmx_sysinfo_get()-board_serial_number,
+  octeon_bootinfo-board_serial_number,
+  sizeof cvmx_sysinfo_get()-board_serial_number);


This matches the above for the gnu style of the indentation.

It also doesn't follow FreeBSD style for the explicit sizeof is not
followed by a space or the implicit sizeof is followed by a left
parentheses (without a space).  The former implies the latter, because
the identifiers would coalesce without the space.  My normal style would
omit the parentheses for `sizeof object' and everywhere else possible,
but here they are needed for another reason for people who like
excessive parentheses: the pointer is returned by a function so it
has parentheses in it, so it is not as clear as usual what the object
is.

Bruce
___
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: r242302 - head/sys/mips/cavium

2012-10-29 Thread Juli Mallett
Author: jmallett
Date: Mon Oct 29 07:06:23 2012
New Revision: 242302
URL: http://svn.freebsd.org/changeset/base/242302

Log:
  Add a sysctl to change the LED display.

Modified:
  head/sys/mips/cavium/octeon_machdep.c

Modified: head/sys/mips/cavium/octeon_machdep.c
==
--- head/sys/mips/cavium/octeon_machdep.c   Mon Oct 29 06:31:51 2012
(r242301)
+++ head/sys/mips/cavium/octeon_machdep.c   Mon Oct 29 07:06:23 2012
(r242302)
@@ -45,6 +45,7 @@ __FBSDID($FreeBSD$);
 #include sys/ptrace.h
 #include sys/reboot.h
 #include sys/signalvar.h
+#include sys/sysctl.h
 #include sys/sysent.h
 #include sys/sysproto.h
 #include sys/time.h
@@ -366,6 +367,46 @@ octeon_get_timecount(struct timecounter 
return ((unsigned)octeon_get_ticks());
 }
 
+static int
+sysctl_machdep_led_display(SYSCTL_HANDLER_ARGS)
+{
+   size_t buflen;
+   char buf[9];
+   int error;
+
+   if (req-newptr == NULL)
+   return (EINVAL);
+
+   if (cvmx_sysinfo_get()-led_display_base_addr == 0)
+   return (ENODEV);
+
+   /*
+* Revision 1.x of the EBT3000 only supports 4 characters, but
+* other devices support 8.
+*/
+   if (cvmx_sysinfo_get()-board_type == CVMX_BOARD_TYPE_EBT3000 
+   cvmx_sysinfo_get()-board_rev_major == 1)
+   buflen = 4;
+   else
+   buflen = 8;
+
+   if (req-newlen  buflen)
+   return (E2BIG);
+
+   error = SYSCTL_IN(req, buf, req-newlen);
+   if (error != 0)
+   return (error);
+
+   buf[req-newlen] = '\0';
+   ebt3000_str_write(buf);
+
+   return (0);
+}
+
+SYSCTL_PROC(_machdep, OID_AUTO, led_display, CTLTYPE_STRING | CTLFLAG_WR,
+NULL, 0, sysctl_machdep_led_display, A,
+String to display on LED display);
+
 /**
  * version of printf that works better in exception context.
  *
___
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


Re: svn commit: r242161 - in head/sys: net netinet netpfil/pf

2012-10-29 Thread Andre Oppermann

On 29.10.2012 22:40, YongHyeon PYUN wrote:

On Mon, Oct 29, 2012 at 09:21:00AM +0400, Gleb Smirnoff wrote:

On Mon, Oct 29, 2012 at 01:41:04PM -0700, YongHyeon PYUN wrote:
Y On Sun, Oct 28, 2012 at 02:01:37AM +0400, Gleb Smirnoff wrote:
Y  On Sat, Oct 27, 2012 at 12:58:52PM +0200, Andre Oppermann wrote:
Y  A On 26.10.2012 23:06, Gleb Smirnoff wrote:
Y  A  Author: glebius
Y  A  Date: Fri Oct 26 21:06:33 2012
Y  A  New Revision: 242161
Y  A  URL: http://svn.freebsd.org/changeset/base/242161
Y  A 
Y  A  Log:
Y  A o Remove last argument to ip_fragment(), and obtain all needed 
information
Y  A   on checksums directly from mbuf flags. This simplifies code.
Y  A o Clear CSUM_IP from the mbuf in ip_fragment() if we did checksums 
in
Y
Y I'm not sure whether ti(4)'s checksum offloading for IP fragmented
Y packets(CSUM_IP_FRAGS) still works after this change.  ti(4)
Y requires CSUM_IP should be set for IP fragmented packets. Not sure
Y whether it's a bug or not. I have a ti(4) controller but I don't
Y remember where I can find it and don't have a link
Y parter(1000baseSX) to test it. :-(

ti(4) declares both CSUM_IP and CSUM_IP_FRAGS, so ip_fragment() won't do


Because it supports both CSUM_IP and CSUM_IP_FRAGS. Probably ti(4)
is the only controller that supports TCP/UDP checksum offloading
for an IP fragmented packet.


This is a bit weird if it doesn't do the fragmentation itself.
Computing the IP header checksum doesn't differ for normal and
fragmented packets.  The protocol checksum (TCP or UDP) stays
the same for in the case of IP level fragmentation.  It is only
visible in the first fragment which includes the protocol header.


software checksums, and thus won't clear these flags.

Potentially a driver that announces one flag in if_hwassist but relies on
couple of flags to be set on mbuf is not correct. If a driver can't do single
checksum  processing independently from others, then it should set or clear
appropriate flags in if_hwassist as a group.


Hmm, then what would be best way to achieve CSUM_IP_FRAGS in
driver? I don't have clear idea how to utilize the hardware
feature. The stack should tell that the mbuf needs TCP/UDP checksum
offloading for IP fragmented packet(i.e. CSUM_IP_FRAGS is not set by
upper stack).


As I said there can't be fragment checksumming without hardware
based fragmentation.  We have three cases here:

 1. TSO where the hardware does the segmentation, TCP and IP header
checksums for each generated packet.
 2. IP packet fragmentation where a packet is split, the IP header
checksum is recomputed for each fragment, but the protocol csum
stays the same and is not modified.
 3. UDP fragmentation where a large packet is sent to the hardware
and it generates first the UDP checksum and then splits it into
IP fragments each with its own IP header checksum.

So we end up with these possible large send hardware offload capabilities:
 TSO: including IPv4hdr and TCP checksumming
 UDP fragmentation: including IPv4hdr and UDP checksumming
 IP fragmentation: including IPv4hdr checksumming

Besides that we have the packet = MTU sized offload capabilities:
 TCP checksumming
 UDP checksumming
 SCTP checksumming
 IPv4hdr checksumming


Y  A   hardware. Some driver may not announce CSUM_IP in theur 
if_hwassist,


Oh, that was a typo! Software was meant.


That explains quite a bit of confusion.

--
Andre

___
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: r242304 - head/sys/kern

2012-10-29 Thread Kevin Lo
Author: kevlo
Date: Mon Oct 29 10:04:28 2012
New Revision: 242304
URL: http://svn.freebsd.org/changeset/base/242304

Log:
  Since the macro dtom() has been removed, fix comments about the dtom.
  
  Reviewed by:  glebius

Modified:
  head/sys/kern/kern_mbuf.c
  head/sys/kern/uipc_mbuf.c

Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c   Mon Oct 29 08:16:31 2012(r242303)
+++ head/sys/kern/kern_mbuf.c   Mon Oct 29 10:04:28 2012(r242304)
@@ -244,7 +244,7 @@ static void mb_reclaim(void *);
 static voidmbuf_init(void *);
 static void*mbuf_jumbo_alloc(uma_zone_t, int, uint8_t *, int);
 
-/* Ensure that MSIZE doesn't break dtom() - it must be a power of 2 */
+/* Ensure that MSIZE must be a power of 2. */
 CTASSERTMSIZE - 1) ^ MSIZE) + 1)  1 == MSIZE);
 
 /*

Modified: head/sys/kern/uipc_mbuf.c
==
--- head/sys/kern/uipc_mbuf.c   Mon Oct 29 08:16:31 2012(r242303)
+++ head/sys/kern/uipc_mbuf.c   Mon Oct 29 10:04:28 2012(r242304)
@@ -1000,8 +1000,8 @@ m_adj(struct mbuf *mp, int req_len)
 
 /*
  * Rearange an mbuf chain so that len bytes are contiguous
- * and in the data area of an mbuf (so that mtod and dtom
- * will work for a structure of size len).  Returns the resulting
+ * and in the data area of an mbuf (so that mtod will work
+ * for a structure of size len).  Returns the resulting
  * mbuf chain on success, frees it and returns null on failure.
  * If there is room, it will add up to max_protohdr-len extra bytes to the
  * contiguous region in an attempt to avoid being called next time.
___
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: r242305 - head/sys/dev/acpi_support

2012-10-29 Thread Baptiste Daroussin
Author: bapt
Date: Mon Oct 29 10:22:00 2012
New Revision: 242305
URL: http://svn.freebsd.org/changeset/base/242305

Log:
  add support for newer Lenovo ThinkPads to acpi_ibm
  
  PR:   kern/164538
  Submitted by: Pierre Imai pie...@imai.at
  MFC after:2 weeks

Modified:
  head/sys/dev/acpi_support/acpi_ibm.c

Modified: head/sys/dev/acpi_support/acpi_ibm.c
==
--- head/sys/dev/acpi_support/acpi_ibm.cMon Oct 29 10:04:28 2012
(r242304)
+++ head/sys/dev/acpi_support/acpi_ibm.cMon Oct 29 10:22:00 2012
(r242305)
@@ -317,7 +317,7 @@ static devclass_t acpi_ibm_devclass;
 DRIVER_MODULE(acpi_ibm, acpi, acpi_ibm_driver, acpi_ibm_devclass,
  0, 0);
 MODULE_DEPEND(acpi_ibm, acpi, 1, 1, 1);
-static char*ibm_ids[] = {IBM0068, NULL};
+static char*ibm_ids[] = {IBM0068, LEN0068, NULL};
 
 static void
 ibm_led(void *softc, int onoff)
___
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: r242306 - head/sys/kern

2012-10-29 Thread Andre Oppermann
Author: andre
Date: Mon Oct 29 12:14:57 2012
New Revision: 242306
URL: http://svn.freebsd.org/changeset/base/242306

Log:
  Add logging for socket attach failures in sonewconn() during accept(2).
  Include the pointer to the PCB so it can be attributed to a particular
  application by corresponding it to netstat -A output.
  
  MFC after:2 weeks

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==
--- head/sys/kern/uipc_socket.c Mon Oct 29 10:22:00 2012(r242305)
+++ head/sys/kern/uipc_socket.c Mon Oct 29 12:14:57 2012(r242306)
@@ -135,6 +135,7 @@ __FBSDID($FreeBSD$);
 #include sys/sysctl.h
 #include sys/uio.h
 #include sys/jail.h
+#include sys/syslog.h
 
 #include net/vnet.h
 
@@ -500,16 +501,24 @@ sonewconn(struct socket *head, int conns
over = (head-so_qlen  3 * head-so_qlimit / 2);
ACCEPT_UNLOCK();
 #ifdef REGRESSION
-   if (regression_sonewconn_earlytest  over)
+   if (regression_sonewconn_earlytest  over) {
 #else
-   if (over)
+   if (over) {
 #endif
+   log(LOG_DEBUG, %s: pcb %p: Listen queue overflow: 
+   %i already in queue awaiting acceptance\n,
+   __func__, head-so_pcb, over);
return (NULL);
+   }
VNET_ASSERT(head-so_vnet != NULL, (%s:%d so_vnet is NULL, head=%p,
__func__, __LINE__, head));
so = soalloc(head-so_vnet);
-   if (so == NULL)
+   if (so == NULL) {
+   log(LOG_DEBUG, %s: pcb %p: New socket allocation failure: 
+   limit reached or out of memory\n,
+   __func__, head-so_pcb);
return (NULL);
+   }
if ((head-so_options  SO_ACCEPTFILTER) != 0)
connstatus = 0;
so-so_head = head;
@@ -526,9 +535,16 @@ sonewconn(struct socket *head, int conns
knlist_init_mtx(so-so_rcv.sb_sel.si_note, SOCKBUF_MTX(so-so_rcv));
knlist_init_mtx(so-so_snd.sb_sel.si_note, SOCKBUF_MTX(so-so_snd));
VNET_SO_ASSERT(head);
-   if (soreserve(so, head-so_snd.sb_hiwat, head-so_rcv.sb_hiwat) ||
-   (*so-so_proto-pr_usrreqs-pru_attach)(so, 0, NULL)) {
+   if (soreserve(so, head-so_snd.sb_hiwat, head-so_rcv.sb_hiwat)) {
+   sodealloc(so);
+   log(LOG_DEBUG, %s: pcb %p: soreserve() failed\n,
+   __func__, head-so_pcb);
+   return (NULL);
+   }
+   if ((*so-so_proto-pr_usrreqs-pru_attach)(so, 0, NULL)) {
sodealloc(so);
+   log(LOG_DEBUG, %s: pcb %p: pru_attach() failed\n,
+   __func__, head-so_pcb);
return (NULL);
}
so-so_rcv.sb_lowat = head-so_rcv.sb_lowat;
___
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: r242308 - head/sys/netinet

2012-10-29 Thread Andre Oppermann
Author: andre
Date: Mon Oct 29 12:17:02 2012
New Revision: 242308
URL: http://svn.freebsd.org/changeset/base/242308

Log:
  Define the delayed ACK timeout value directly as hz/10 instead of
  obfuscating it by going through PR_FASTHZ.  No functional change.
  
  MFC after:2 weeks

Modified:
  head/sys/netinet/tcp_timer.h

Modified: head/sys/netinet/tcp_timer.h
==
--- head/sys/netinet/tcp_timer.hMon Oct 29 12:16:19 2012
(r242307)
+++ head/sys/netinet/tcp_timer.hMon Oct 29 12:17:02 2012
(r242308)
@@ -118,7 +118,7 @@
 
 #defineTCP_MAXRXTSHIFT 12  /* maximum retransmits 
*/
 
-#defineTCPTV_DELACK(hz / PR_FASTHZ / 2)/* 100ms timeout */
+#defineTCPTV_DELACK( hz/10 )   /* 100ms timeout */
 
 #ifdef TCPTIMERS
 static const char *tcptimers[] =
___
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


Re: svn commit: r242274 - head/sys/sys

2012-10-29 Thread Attilio Rao
On 10/29/12, Gleb Smirnoff gleb...@freebsd.org wrote:
 On Mon, Oct 29, 2012 at 01:35:17AM +, Attilio Rao wrote:
 A Author: attilio
 A Date: Mon Oct 29 01:35:17 2012
 A New Revision: 242274
 A URL: http://svn.freebsd.org/changeset/base/242274
 A
 A Log:
 A   Compiler have a precise knowledge of the content of sched_pin() and
 A   sched_unpin() as they are functions static and inline.  This way it
 A   can do two dangerous things:
 A   - Reorder instructions around both of them, taking out from the safe
 A path operations that are supposed to be (ie. per-cpu accesses)
 A   - Cache the value of td_pinned in CPU registers not making visible
 A in kernel context to the scheduler once it is scanning the runqueue,
 A as td_pinned is not marked volatile.
 A
 A   In order to avoid both possible bugs explicitly, protect the safe path
 A   with compiler memory barriers. This will prevent reordering and
 caching
 A   by the compiler about td_pinned operations.
 A
 A   Generally this could lead to suboptimal code traversing the pinnings
 A   but this is not the case as can be easilly verified:
 A
 http://lists.freebsd.org/pipermail/svn-src-projects/2012-October/005797.html

 Now __compiler_membar() can be removed from kern_rmlock.c:360

No, they are there to protect td_critnest which has nothing to do with
sched_pin().

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


svn commit: r242311 - head/sys/netinet

2012-10-29 Thread Andre Oppermann
Author: andre
Date: Mon Oct 29 13:16:33 2012
New Revision: 242311
URL: http://svn.freebsd.org/changeset/base/242311

Log:
  Forced commit to provide the correct commit message to r242251:
  
Defer sending an independent window update if a delayed ACK is pending
saving a packet.  The window update then gets piggy-backed on the next
already scheduled ACK.
  
  Added grammar fixes as well.
  
  MFC after:2 weeks

Modified:
  head/sys/netinet/tcp_output.c

Modified: head/sys/netinet/tcp_output.c
==
--- head/sys/netinet/tcp_output.c   Mon Oct 29 12:37:39 2012
(r242310)
+++ head/sys/netinet/tcp_output.c   Mon Oct 29 13:16:33 2012
(r242311)
@@ -547,13 +547,13 @@ after_sack_rexmit:
/*
 * Sending of standalone window updates.
 *
-* Window updates important when we close our window due to a full
-* socket buffer and are opening it again after the application
+* Window updates are important when we close our window due to a
+* full socket buffer and are opening it again after the application
 * reads data from it.  Once the window has opened again and the
 * remote end starts to send again the ACK clock takes over and
 * provides the most current window information.
 *
-* We must avoid to the silly window syndrome whereas every read
+* We must avoid the silly window syndrome whereas every read
 * from the receive buffer, no matter how small, causes a window
 * update to be sent.  We also should avoid sending a flurry of
 * window updates when the socket buffer had queued a lot of data
___
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


Re: svn commit: r242251 - head/sys/netinet

2012-10-29 Thread Andre Oppermann

On 28.10.2012 18:30, Andre Oppermann wrote:

Author: andre
Date: Sun Oct 28 17:30:28 2012
New Revision: 242251
URL: http://svn.freebsd.org/changeset/base/242251

Log:
   When SYN or SYN/ACK had to be retransmitted RFC5681 requires us to
   reduce the initial CWND to one segment.  This reduction got lost
   some time ago due to a change in initialization ordering.

   Additionally in tcp_timer_rexmt() avoid entering fast recovery when
   we're still in TCPS_SYN_SENT state.


Oops, this was the wrong commit message for this change.  Here is the
correct one:

  Defer sending an independent window update if a delayed ACK is pending
  saving a packet.  The window update then gets piggy-backed on the next
  already scheduled ACK.

I've forced commit r242311 with some grammar fixes to provide this information.

--
Andre


   MFC after:   2 weeks

Modified:
   head/sys/netinet/tcp_output.c

Modified: head/sys/netinet/tcp_output.c
==
--- head/sys/netinet/tcp_output.c   Sun Oct 28 17:25:08 2012
(r242250)
+++ head/sys/netinet/tcp_output.c   Sun Oct 28 17:30:28 2012
(r242251)
@@ -551,10 +551,14 @@ after_sack_rexmit:
 * max size segments, or at least 50% of the maximum possible
 * window, then want to send a window update to peer.
 * Skip this if the connection is in T/TCP half-open state.
-* Don't send pure window updates when the peer has closed
-* the connection and won't ever send more data.
+*
+* Don't send an independent window update if a delayed
+* ACK is pending (it will get piggy-backed on it) or the
+* remote side already has done a half-close and won't send
+* more data.
 */
if (recwin  0  !(tp-t_flags  TF_NEEDSYN) 
+   !(tp-t_flags  TF_DELACK) 
!TCPS_HAVERCVDFIN(tp-t_state)) {
/*
 * adv is the amount we can increase the window,




___
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: r242314 - head/sys/geom/raid

2012-10-29 Thread Alexander Motin
Author: mav
Date: Mon Oct 29 14:18:54 2012
New Revision: 242314
URL: http://svn.freebsd.org/changeset/base/242314

Log:
  Make GEOM RAID more aggressive in marking volumes as clean on shutdown
  and move that action from shutdown_pre_sync to shutdown_post_sync stage
  to avoid extra flapping.
  
  ZFS tends to not close devices on shutdown, that doesn't allow GEOM RAID
  to shutdown gracefully.  To handle that, mark volume as clean just when
  shutdown time comes and there are no active writes.
  
  MFC after:2 weeks

Modified:
  head/sys/geom/raid/g_raid.c

Modified: head/sys/geom/raid/g_raid.c
==
--- head/sys/geom/raid/g_raid.c Mon Oct 29 13:58:11 2012(r242313)
+++ head/sys/geom/raid/g_raid.c Mon Oct 29 14:18:54 2012(r242314)
@@ -108,8 +108,9 @@ LIST_HEAD(, g_raid_tr_class) g_raid_tr_c
 LIST_HEAD(, g_raid_volume) g_raid_volumes =
 LIST_HEAD_INITIALIZER(g_raid_volumes);
 
-static eventhandler_tag g_raid_pre_sync = NULL;
+static eventhandler_tag g_raid_post_sync = NULL;
 static int g_raid_started = 0;
+static int g_raid_shutdown = 0;
 
 static int g_raid_destroy_geom(struct gctl_req *req, struct g_class *mp,
 struct g_geom *gp);
@@ -881,7 +882,7 @@ g_raid_orphan(struct g_consumer *cp)
G_RAID_EVENT_DISK);
 }
 
-static int
+static void
 g_raid_clean(struct g_raid_volume *vol, int acw)
 {
struct g_raid_softc *sc;
@@ -892,22 +893,21 @@ g_raid_clean(struct g_raid_volume *vol, 
sx_assert(sc-sc_lock, SX_XLOCKED);
 
 // if ((sc-sc_flags  G_RAID_DEVICE_FLAG_NOFAILSYNC) != 0)
-// return (0);
+// return;
if (!vol-v_dirty)
-   return (0);
+   return;
if (vol-v_writes  0)
-   return (0);
+   return;
if (acw  0 || (acw == -1 
vol-v_provider != NULL  vol-v_provider-acw  0)) {
timeout = g_raid_clean_time - (time_uptime - vol-v_last_write);
-   if (timeout  0)
-   return (timeout);
+   if (!g_raid_shutdown  timeout  0)
+   return;
}
vol-v_dirty = 0;
G_RAID_DEBUG1(1, sc, Volume %s marked as clean.,
vol-v_name);
g_raid_write_metadata(sc, vol, NULL, NULL);
-   return (0);
 }
 
 static void
@@ -1520,8 +1520,7 @@ process:
g_raid_disk_done_request(bp);
} else if (rv == EWOULDBLOCK) {
TAILQ_FOREACH(vol, sc-sc_volumes, v_next) {
-   if (vol-v_writes == 0  vol-v_dirty)
-   g_raid_clean(vol, -1);
+   g_raid_clean(vol, -1);
if (bioq_first(vol-v_inflight) == NULL 
vol-v_tr) {
t.tv_sec = g_raid_idle_threshold / 
100;
@@ -1783,7 +1782,7 @@ g_raid_access(struct g_provider *pp, int
error = ENXIO;
goto out;
}
-   if (dcw == 0  vol-v_dirty)
+   if (dcw == 0)
g_raid_clean(vol, dcw);
vol-v_provider_open += acr + acw + ace;
/* Handle delayed node destruction. */
@@ -2379,21 +2378,25 @@ g_raid_dumpconf(struct sbuf *sb, const c
 }
 
 static void
-g_raid_shutdown_pre_sync(void *arg, int howto)
+g_raid_shutdown_post_sync(void *arg, int howto)
 {
struct g_class *mp;
struct g_geom *gp, *gp2;
struct g_raid_softc *sc;
+   struct g_raid_volume *vol;
int error;
 
mp = arg;
DROP_GIANT();
g_topology_lock();
+   g_raid_shutdown = 1;
LIST_FOREACH_SAFE(gp, mp-geom, geom, gp2) {
if ((sc = gp-softc) == NULL)
continue;
g_topology_unlock();
sx_xlock(sc-sc_lock);
+   TAILQ_FOREACH(vol, sc-sc_volumes, v_next)
+   g_raid_clean(vol, -1);
g_cancel_event(sc);
error = g_raid_destroy(sc, G_RAID_DESTROY_DELAYED);
if (error != 0)
@@ -2408,9 +2411,9 @@ static void
 g_raid_init(struct g_class *mp)
 {
 
-   g_raid_pre_sync = EVENTHANDLER_REGISTER(shutdown_pre_sync,
-   g_raid_shutdown_pre_sync, mp, SHUTDOWN_PRI_FIRST);
-   if (g_raid_pre_sync == NULL)
+   g_raid_post_sync = EVENTHANDLER_REGISTER(shutdown_post_sync,
+   g_raid_shutdown_post_sync, mp, SHUTDOWN_PRI_FIRST);
+   if (g_raid_post_sync == NULL)
G_RAID_DEBUG(0, Warning! Cannot register shutdown event.);
g_raid_started = 1;
 }
@@ -2419,8 +2422,8 @@ static void
 g_raid_fini(struct g_class *mp)
 {
 
-   if (g_raid_pre_sync != NULL)
-   EVENTHANDLER_DEREGISTER(shutdown_pre_sync, g_raid_pre_sync);
+   if (g_raid_post_sync != NULL)
+   EVENTHANDLER_DEREGISTER(shutdown_post_sync, g_raid_post_sync);
 

svn commit: r242315 - head/sys/powerpc/powermac

2012-10-29 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Oct 29 14:27:28 2012
New Revision: 242315
URL: http://svn.freebsd.org/changeset/base/242315

Log:
  Work around broken device tree on last-generation PowerPC iMacs
  (PowerMac12,1), which have a mac-io MPIC cell that indifies itself
  as the root PIC despite the actual root PIC being on the northbridge.
  No CPC945 systems have a mac-io PIC that does anything so just don't
  attach on CPC945 (U4) systems.
  
  MFC after:3 days

Modified:
  head/sys/powerpc/powermac/openpic_macio.c

Modified: head/sys/powerpc/powermac/openpic_macio.c
==
--- head/sys/powerpc/powermac/openpic_macio.c   Mon Oct 29 14:18:54 2012
(r242314)
+++ head/sys/powerpc/powermac/openpic_macio.c   Mon Oct 29 14:27:28 2012
(r242315)
@@ -94,6 +94,10 @@ openpic_macio_probe(device_t dev)
if (strcmp(type, open-pic) != 0)
 return (ENXIO);
 
+   /* On some U4 systems, there is a phantom MPIC in the mac-io cell */
+   if (OF_finddevice(/u4) != (phandle_t)-1)
+   return (ENXIO);
+
device_set_desc(dev, OPENPIC_DEVSTR);
return (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


Re: svn commit: r242314 - head/sys/geom/raid

2012-10-29 Thread Andriy Gapon
on 29/10/2012 16:18 Alexander Motin said the following:
 Author: mav
 Date: Mon Oct 29 14:18:54 2012
 New Revision: 242314
 URL: http://svn.freebsd.org/changeset/base/242314
 
 Log:
   Make GEOM RAID more aggressive in marking volumes as clean on shutdown
   and move that action from shutdown_pre_sync to shutdown_post_sync stage
   to avoid extra flapping.
   
   ZFS tends to not close devices on shutdown, that doesn't allow GEOM RAID
   to shutdown gracefully.  To handle that, mark volume as clean just when
   shutdown time comes and there are no active writes.

Perhaps something like what zfs_modevent(MOD_UNLOAD) does should also be done in
one of the shutdown hooks?
Maybe at the start of shutdown_post_sync (so that it is run before the hooks of
lower level drivers like graid)?

-- 
Andriy Gapon
___
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


Re: svn commit: r242314 - head/sys/geom/raid

2012-10-29 Thread Alexander Motin

On 29.10.2012 16:27, Andriy Gapon wrote:

on 29/10/2012 16:18 Alexander Motin said the following:

Author: mav
Date: Mon Oct 29 14:18:54 2012
New Revision: 242314
URL: http://svn.freebsd.org/changeset/base/242314

Log:
   Make GEOM RAID more aggressive in marking volumes as clean on shutdown
   and move that action from shutdown_pre_sync to shutdown_post_sync stage
   to avoid extra flapping.

   ZFS tends to not close devices on shutdown, that doesn't allow GEOM RAID
   to shutdown gracefully.  To handle that, mark volume as clean just when
   shutdown time comes and there are no active writes.


Perhaps something like what zfs_modevent(MOD_UNLOAD) does should also be done in
one of the shutdown hooks?


May be, but I don't know ZFS very good.


Maybe at the start of shutdown_post_sync (so that it is run before the hooks of
lower level drivers like graid)?


graid would be happy if device would be closed at any point of time, 
either before or after. But before is preferable to avoid some flapping 
between dirtying and added here cleaning.


--
Alexander Motin
___
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: r242319 - head/lib/libutil

2012-10-29 Thread Baptiste Daroussin
Author: bapt
Date: Mon Oct 29 17:19:43 2012
New Revision: 242319
URL: http://svn.freebsd.org/changeset/base/242319

Log:
  make pw_init and gr_init fail if the specified master password or group file 
is
  a directory.
  
  MFC after:1 month

Modified:
  head/lib/libutil/gr_util.c
  head/lib/libutil/pw_util.c

Modified: head/lib/libutil/gr_util.c
==
--- head/lib/libutil/gr_util.c  Mon Oct 29 16:58:45 2012(r242318)
+++ head/lib/libutil/gr_util.c  Mon Oct 29 17:19:43 2012(r242319)
@@ -63,6 +63,8 @@ static const char group_line_format[] = 
 int
 gr_init(const char *dir, const char *group)
 {
+   struct stat st;
+
if (dir == NULL) {
strcpy(group_dir, _PATH_ETC);
} else {
@@ -88,6 +90,15 @@ gr_init(const char *dir, const char *gro
}
strcpy(group_file, group);
}
+
+   if (stat(group_file, st) == -1)
+   return (-1);
+
+   if (S_ISDIR(st.st_mode)) {
+   errno = EISDIR;
+   return (-1);
+   }
+
initialized = 1;
return (0);
 }

Modified: head/lib/libutil/pw_util.c
==
--- head/lib/libutil/pw_util.c  Mon Oct 29 16:58:45 2012(r242318)
+++ head/lib/libutil/pw_util.c  Mon Oct 29 17:19:43 2012(r242319)
@@ -96,6 +96,7 @@ pw_init(const char *dir, const char *mas
 #if 0
struct rlimit rlim;
 #endif
+   struct stat st;
 
if (dir == NULL) {
strcpy(passwd_dir, _PATH_ETC);
@@ -123,6 +124,14 @@ pw_init(const char *dir, const char *mas
strcpy(masterpasswd, master);
}
 
+   if (stat(masterpasswd, st) == -1)
+   return (-1);
+
+   if (S_ISDIR(st.st_mode)) {
+   errno = EISDIR;
+   return (-1);
+   }
+
/*
 * The code that follows is extremely disruptive to the calling
 * process, and is therefore disabled until someone can conceive
___
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: r242320 - head/sys/dev/sdhci

2012-10-29 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Oct 29 17:21:58 2012
New Revision: 242320
URL: http://svn.freebsd.org/changeset/base/242320

Log:
  Add new quirks:
- Data timeout is broken
- Data timeout uses SD clock
- Capabilities register is unavailable
  
  Add calculations for clock divisor for SDHCI 3.0

Modified:
  head/sys/dev/sdhci/sdhci.c
  head/sys/dev/sdhci/sdhci.h

Modified: head/sys/dev/sdhci/sdhci.c
==
--- head/sys/dev/sdhci/sdhci.c  Mon Oct 29 17:19:43 2012(r242319)
+++ head/sys/dev/sdhci/sdhci.c  Mon Oct 29 17:21:58 2012(r242320)
@@ -221,6 +221,7 @@ sdhci_set_clock(struct sdhci_slot *slot,
 {
uint32_t res;
uint16_t clk;
+   uint16_t div;
int timeout;
 
if (clock == slot-clock)
@@ -232,17 +233,39 @@ sdhci_set_clock(struct sdhci_slot *slot,
/* If no clock requested - left it so. */
if (clock == 0)
return;
-   /* Looking for highest freq = clock. */
-   res = slot-max_clk;
-   for (clk = 1; clk  256; clk = 1) {
-   if (res = clock)
-   break;
-   res = 1;
+   if (slot-version  SDHCI_SPEC_300) {
+   /* Looking for highest freq = clock. */
+   res = slot-max_clk;
+   for (div = 1; div  256; div = 1) {
+   if (res = clock)
+   break;
+   res = 1;
+   }
+   /* Divider 1:1 is 0x00, 2:1 is 0x01, 256:1 is 0x80 ... */
+   div = 1;
+   }
+   else {
+   /* Version 3.0 divisors are multiples of two up to 1023*2 */
+   if (clock  slot-max_clk)
+   div = 2;
+   else {
+   for (div = 2; div  1023*2; div += 2) {
+   if ((slot-max_clk / div) = clock) 
+   break;
+   }
+   }
+   div = 1;
}
-   /* Divider 1:1 is 0x00, 2:1 is 0x01, 256:1 is 0x80 ... */
-   clk = 1;
+
+   if (bootverbose || sdhci_debug)
+   slot_printf(slot, Divider %d for freq %d (max %d)\n, 
+   div, clock, slot-max_clk);
+
/* Now we have got divider, set it. */
-   clk = SDHCI_DIVIDER_SHIFT;
+   clk = (div  SDHCI_DIVIDER_MASK)  SDHCI_DIVIDER_SHIFT;
+   clk |= ((div  SDHCI_DIVIDER_MASK_LEN)  SDHCI_DIVIDER_HI_MASK)
+SDHCI_DIVIDER_HI_SHIFT;
+
WR2(slot, SDHCI_CLOCK_CONTROL, clk);
/* Enable clock. */
clk |= SDHCI_CLOCK_INT_EN;
@@ -488,7 +511,10 @@ sdhci_init_slot(device_t dev, struct sdh
sdhci_init(slot);
slot-version = (RD2(slot, SDHCI_HOST_VERSION) 
 SDHCI_SPEC_VER_SHIFT)  SDHCI_SPEC_VER_MASK;
-   caps = RD4(slot, SDHCI_CAPABILITIES);
+   if (slot-quirks  SDHCI_QUIRK_MISSING_CAPS)
+   caps = slot-caps;
+   else
+   caps = RD4(slot, SDHCI_CAPABILITIES);
/* Calculate base clock frequency. */
slot-max_clk =
(caps  SDHCI_CLOCK_BASE_MASK)  SDHCI_CLOCK_BASE_SHIFT;
@@ -499,14 +525,19 @@ sdhci_init_slot(device_t dev, struct sdh
}
slot-max_clk *= 100;
/* Calculate timeout clock frequency. */
-   slot-timeout_clk =
-   (caps  SDHCI_TIMEOUT_CLK_MASK)  SDHCI_TIMEOUT_CLK_SHIFT;
+   if (slot-quirks  SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) {
+   slot-timeout_clk = slot-max_clk / 1000;
+   } else {
+   slot-timeout_clk =
+   (caps  SDHCI_TIMEOUT_CLK_MASK)  
SDHCI_TIMEOUT_CLK_SHIFT;
+   if (caps  SDHCI_TIMEOUT_CLK_UNIT)
+   slot-timeout_clk *= 1000;
+   }
+
if (slot-timeout_clk == 0) {
device_printf(dev, Hardware doesn't specify timeout clock 
frequency.\n);
}
-   if (caps  SDHCI_TIMEOUT_CLK_UNIT)
-   slot-timeout_clk *= 1000;
 
slot-host.f_min = slot-max_clk / 256;
slot-host.f_max = slot-max_clk;
@@ -815,6 +846,8 @@ sdhci_start_data(struct sdhci_slot *slot
slot_printf(slot, Timeout too large!\n);
div = 0xE;
}
+   if (slot-quirks  SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
+   div = 0xE;
WR1(slot, SDHCI_TIMEOUT_CONTROL, div);
 
if (data == NULL)

Modified: head/sys/dev/sdhci/sdhci.h
==
--- head/sys/dev/sdhci/sdhci.h  Mon Oct 29 17:19:43 2012(r242319)
+++ head/sys/dev/sdhci/sdhci.h  Mon Oct 29 17:21:58 2012(r242320)
@@ -51,12 +51,16 @@
 #define SDHCI_QUIRK_BROKEN_TIMINGS (18)
 /* Controller needs lowered frequency */
 #defineSDHCI_QUIRK_LOWER_FREQUENCY (19)
-
+/* Data timeout is invalid, should use SD clock */
+#define 

svn commit: r242321 - in head/sys: arm/broadcom/bcm2835 arm/conf dev/mmc

2012-10-29 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Mon Oct 29 17:23:45 2012
New Revision: 242321
URL: http://svn.freebsd.org/changeset/base/242321

Log:
  Add BCM2835 SDHCI driver and enable it in Raspberry Pi config

Added:
  head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c   (contents, props changed)
Modified:
  head/sys/arm/broadcom/bcm2835/files.bcm2835
  head/sys/arm/conf/RPI-B
  head/sys/dev/mmc/mmc.c

Added: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c   Mon Oct 29 17:23:45 
2012(r242321)
@@ -0,0 +1,364 @@
+/*-
+ * Copyright (c) 2012 Oleksandr Tymoshenko go...@freebsd.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include sys/cdefs.h
+__FBSDID($FreeBSD$);
+
+#include sys/param.h
+#include sys/systm.h
+#include sys/bio.h
+#include sys/bus.h
+#include sys/conf.h
+#include sys/endian.h
+#include sys/kernel.h
+#include sys/kthread.h
+#include sys/lock.h
+#include sys/malloc.h
+#include sys/module.h
+#include sys/mutex.h
+#include sys/queue.h
+#include sys/resource.h
+#include sys/rman.h
+#include sys/taskqueue.h
+#include sys/time.h
+#include sys/timetc.h
+#include sys/watchdog.h
+
+#include sys/kdb.h
+
+#include machine/bus.h
+#include machine/cpu.h
+#include machine/cpufunc.h
+#include machine/resource.h
+#include machine/frame.h
+#include machine/intr.h
+
+#include dev/ofw/ofw_bus.h
+#include dev/ofw/ofw_bus_subr.h
+
+#include dev/mmc/bridge.h
+#include dev/mmc/mmcreg.h
+#include dev/mmc/mmcbrvar.h
+
+#include dev/sdhci/sdhci.h
+#include sdhci_if.h
+
+#defineDEBUG
+
+#ifdef DEBUG
+#define dprintf(fmt, args...) do { printf(%s(): , __func__);   \
+printf(fmt,##args); } while (0)
+#else
+#define dprintf(fmt, args...)
+#endif
+
+struct bcm_sdhci_dmamap_arg {
+   bus_addr_t  sc_dma_busaddr;
+};
+
+struct bcm_sdhci_softc {
+   device_tsc_dev;
+   struct mtx  sc_mtx;
+   struct resource *   sc_mem_res;
+   struct resource *   sc_irq_res;
+   bus_space_tag_t sc_bst;
+   bus_space_handle_t  sc_bsh;
+   void *  sc_intrhand;
+   struct mmc_request *sc_req;
+   struct mmc_data *   sc_data;
+   uint32_tsc_flags;
+#defineLPC_SD_FLAGS_IGNORECRC  (1  0)
+   int sc_xfer_direction;
+#defineDIRECTION_READ  0
+#defineDIRECTION_WRITE 1
+   int sc_xfer_done;
+   int sc_bus_busy;
+   struct sdhci_slot   sc_slot;
+};
+
+#defineSD_MAX_BLOCKSIZE1024
+/* XXX */
+
+static int bcm_sdhci_probe(device_t);
+static int bcm_sdhci_attach(device_t);
+static int bcm_sdhci_detach(device_t);
+static void bcm_sdhci_intr(void *);
+
+static int bcm_sdhci_get_ro(device_t, device_t);
+
+#definebcm_sdhci_lock(_sc) 
\
+mtx_lock(_sc-sc_mtx);
+#definebcm_sdhci_unlock(_sc)   
\
+mtx_unlock(_sc-sc_mtx);
+
+static int
+bcm_sdhci_probe(device_t dev)
+{
+   if (!ofw_bus_is_compatible(dev, broadcom,bcm2835-sdhci))
+   return (ENXIO);
+
+   device_set_desc(dev, Broadcom 2708 SDHCI controller);
+   return (BUS_PROBE_DEFAULT);
+}
+
+static int
+bcm_sdhci_attach(device_t dev)
+{
+   struct bcm_sdhci_softc *sc = device_get_softc(dev);
+   int rid, err;
+
+   sc-sc_dev = dev;
+   sc-sc_req = NULL;
+
+   mtx_init(sc-sc_mtx, bcm sdhci, sdhci, MTX_DEF);
+
+   rid = 

svn commit: r242322 - in head/sys: cam/scsi geom

2012-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Oct 29 17:52:43 2012
New Revision: 242322
URL: http://svn.freebsd.org/changeset/base/242322

Log:
  Fix locking problem in disk_resize(); previously it would run without
  topology lock, resulting in assertion when running with DIAGNOSTIC.
  
  Reviewed by:  mav (earlier version)

Modified:
  head/sys/cam/scsi/scsi_da.c
  head/sys/geom/geom_disk.c
  head/sys/geom/geom_disk.h

Modified: head/sys/cam/scsi/scsi_da.c
==
--- head/sys/cam/scsi/scsi_da.c Mon Oct 29 17:23:45 2012(r242321)
+++ head/sys/cam/scsi/scsi_da.c Mon Oct 29 17:52:43 2012(r242322)
@@ -2673,6 +2673,7 @@ dasetgeom(struct cam_periph *periph, uin
struct da_softc *softc;
struct disk_params *dp;
u_int lbppbe, lalba;
+   int error;
 
softc = (struct da_softc *)periph-softc;
 
@@ -2779,10 +2780,9 @@ dasetgeom(struct cam_periph *periph, uin
else
softc-disk-d_flags = ~DISKFLAG_CANDELETE;
 
-/* Currently as of 6/13/2012, panics if DIAGNOSTIC is set */
-#ifndefDIAGNOSTIC
-   disk_resize(softc-disk);
-#endif
+   error = disk_resize(softc-disk, M_NOWAIT);
+   if (error != 0)
+   xpt_print(periph-path, disk_resize(9) failed, error = %d\n, 
error);
 }
 
 static void

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Mon Oct 29 17:23:45 2012(r242321)
+++ head/sys/geom/geom_disk.c   Mon Oct 29 17:52:43 2012(r242322)
@@ -48,7 +48,6 @@ __FBSDID($FreeBSD$);
 #include sys/malloc.h
 #include sys/sbuf.h
 #include sys/sysctl.h
-#include sys/taskqueue.h
 #include sys/devicestat.h
 #include machine/md_var.h
 
@@ -66,7 +65,6 @@ struct g_disk_softc {
struct sysctl_oid   *sysctl_tree;
charled[64];
uint32_tstate;
-   struct task resize_task;
 };
 
 static struct mtx g_disk_done_mtx;
@@ -443,17 +441,22 @@ g_disk_dumpconf(struct sbuf *sb, const c
 }
 
 static void
-g_disk_resize_task(void *context, int pending)
+g_disk_resize(void *ptr, int flag)
 {
+   struct disk *dp;
struct g_geom *gp;
struct g_provider *pp;
-   struct disk *dp;
-   struct g_disk_softc *sc;
 
-   sc = (struct g_disk_softc *)context;
-   dp = sc-dp;
+   if (flag == EV_CANCEL)
+   return;
+   g_topology_assert();
+
+   dp = ptr;
gp = dp-d_geom;
 
+   if (dp-d_destroyed || gp == NULL)
+   return;
+
LIST_FOREACH(pp, gp-provider, provider) {
if (pp-sectorsize != 0 
pp-sectorsize != dp-d_sectorsize)
@@ -501,7 +504,6 @@ g_disk_create(void *arg, int flag)
CTLFLAG_RW | CTLFLAG_TUN, sc-led, sizeof(sc-led),
LED name);
}
-   TASK_INIT(sc-resize_task, 0, g_disk_resize_task, sc);
pp-private = sc;
dp-d_geom = gp;
g_error_provider(pp, 0);
@@ -684,22 +686,14 @@ disk_media_gone(struct disk *dp, int fla
}
 }
 
-void
-disk_resize(struct disk *dp)
+int
+disk_resize(struct disk *dp, int flag)
 {
-   struct g_geom *gp;
-   struct g_disk_softc *sc;
-   int error;
 
-   gp = dp-d_geom;
-
-   if (gp == NULL)
-   return;
-
-   sc = gp-softc;
+   if (dp-d_destroyed || dp-d_geom == NULL)
+   return (0);
 
-   error = taskqueue_enqueue(taskqueue_thread, sc-resize_task);
-   KASSERT(error == 0, (taskqueue_enqueue(9) failed.));
+   return (g_post_event(g_disk_resize, dp, flag, NULL));
 }
 
 static void

Modified: head/sys/geom/geom_disk.h
==
--- head/sys/geom/geom_disk.h   Mon Oct 29 17:23:45 2012(r242321)
+++ head/sys/geom/geom_disk.h   Mon Oct 29 17:52:43 2012(r242322)
@@ -111,7 +111,7 @@ void disk_gone(struct disk *disk);
 void disk_attr_changed(struct disk *dp, const char *attr, int flag);
 void disk_media_changed(struct disk *dp, int flag);
 void disk_media_gone(struct disk *dp, int flag);
-void disk_resize(struct disk *dp);
+int disk_resize(struct disk *dp, int flag);
 
 #define DISK_VERSION_000x58561059
 #define DISK_VERSION_010x5856105a
___
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: r242323 - head/sys/geom/raid

2012-10-29 Thread Alexander Motin
Author: mav
Date: Mon Oct 29 18:04:38 2012
New Revision: 242323
URL: http://svn.freebsd.org/changeset/base/242323

Log:
  Add basic BIO_DELETE support to GEOM RAID class for all RAID levels.
  
  If at least one subdisk in the volume supports it, BIO_DELETE requests
  will be propagated down.  Unfortunatelly, for RAID levels with redundancy
  unmapped blocks will be mapped back during first rebuild/resync process.
  
  Sponsored by: iXsystems, Inc.
  MFC after:1 month

Modified:
  head/sys/geom/raid/g_raid.c
  head/sys/geom/raid/g_raid.h
  head/sys/geom/raid/md_ddf.c
  head/sys/geom/raid/md_intel.c
  head/sys/geom/raid/md_jmicron.c
  head/sys/geom/raid/md_nvidia.c
  head/sys/geom/raid/md_promise.c
  head/sys/geom/raid/md_sii.c
  head/sys/geom/raid/tr_concat.c
  head/sys/geom/raid/tr_raid0.c
  head/sys/geom/raid/tr_raid1.c
  head/sys/geom/raid/tr_raid1e.c

Modified: head/sys/geom/raid/g_raid.c
==
--- head/sys/geom/raid/g_raid.c Mon Oct 29 17:52:43 2012(r242322)
+++ head/sys/geom/raid/g_raid.c Mon Oct 29 18:04:38 2012(r242323)
@@ -499,6 +499,34 @@ g_raid_get_diskname(struct g_raid_disk *
 }
 
 void
+g_raid_get_disk_info(struct g_raid_disk *disk)
+{
+   struct g_consumer *cp = disk-d_consumer;
+   int error, len;
+
+   /* Read kernel dumping information. */
+   disk-d_kd.offset = 0;
+   disk-d_kd.length = OFF_MAX;
+   len = sizeof(disk-d_kd);
+   error = g_io_getattr(GEOM::kerneldump, cp, len, disk-d_kd);
+   if (error)
+   disk-d_kd.di.dumper = NULL;
+   if (disk-d_kd.di.dumper == NULL)
+   G_RAID_DEBUG1(2, disk-d_softc,
+   Dumping not supported by %s: %d., 
+   cp-provider-name, error);
+
+   /* Read BIO_DELETE support. */
+   error = g_getattr(GEOM::candelete, cp, disk-d_candelete);
+   if (error)
+   disk-d_candelete = 0;
+   if (!disk-d_candelete)
+   G_RAID_DEBUG1(2, disk-d_softc,
+   BIO_DELETE not supported by %s: %d., 
+   cp-provider-name, error);
+}
+
+void
 g_raid_report_disk_state(struct g_raid_disk *disk)
 {
struct g_raid_subdisk *sd;
@@ -1052,6 +1080,31 @@ g_raid_kerneldump(struct g_raid_softc *s
 }
 
 static void
+g_raid_candelete(struct g_raid_softc *sc, struct bio *bp)
+{
+   struct g_provider *pp;
+   struct g_raid_volume *vol;
+   struct g_raid_subdisk *sd;
+   int *val;
+   int i;
+
+   val = (int *)bp-bio_data;
+   pp = bp-bio_to;
+   vol = pp-private;
+   *val = 0;
+   for (i = 0; i  vol-v_disks_count; i++) {
+   sd = vol-v_subdisks[i];
+   if (sd-sd_state == G_RAID_SUBDISK_S_NONE)
+   continue;
+   if (sd-sd_disk-d_candelete) {
+   *val = 1;
+   break;
+   }
+   }
+   g_io_deliver(bp, 0);
+}
+
+static void
 g_raid_start(struct bio *bp)
 {
struct g_raid_softc *sc;
@@ -1073,7 +1126,9 @@ g_raid_start(struct bio *bp)
case BIO_FLUSH:
break;
case BIO_GETATTR:
-   if (!strcmp(bp-bio_attribute, GEOM::kerneldump))
+   if (!strcmp(bp-bio_attribute, GEOM::candelete))
+   g_raid_candelete(sc, bp);
+   else if (!strcmp(bp-bio_attribute, GEOM::kerneldump))
g_raid_kerneldump(sc, bp);
else
g_io_deliver(bp, EOPNOTSUPP);

Modified: head/sys/geom/raid/g_raid.h
==
--- head/sys/geom/raid/g_raid.h Mon Oct 29 17:52:43 2012(r242322)
+++ head/sys/geom/raid/g_raid.h Mon Oct 29 18:04:38 2012(r242323)
@@ -153,6 +153,7 @@ struct g_raid_disk {
struct g_consumer   *d_consumer;/* GEOM disk consumer. */
void*d_md_data; /* Disk's metadata storage. */
struct g_kerneldump  d_kd;  /* Kernel dumping method/args. 
*/
+   int  d_candelete;   /* BIO_DELETE supported. */
uint64_t d_flags;   /* Additional flags. */
u_intd_state;   /* Disk state. */
u_intd_load;/* Disk average load. */
@@ -418,6 +419,7 @@ struct g_raid_volume * g_raid_create_vol
 const char *name, int id);
 struct g_raid_disk * g_raid_create_disk(struct g_raid_softc *sc);
 const char * g_raid_get_diskname(struct g_raid_disk *disk);
+void g_raid_get_disk_info(struct g_raid_disk *disk);
 
 int g_raid_start_volume(struct g_raid_volume *vol);
 

Modified: head/sys/geom/raid/md_ddf.c
==
--- head/sys/geom/raid/md_ddf.c Mon Oct 29 17:52:43 2012(r242322)
+++ head/sys/geom/raid/md_ddf.c Mon Oct 29 18:04:38 2012(r242323)
@@ 

svn commit: r242324 - head/lib/libutil

2012-10-29 Thread Baptiste Daroussin
Author: bapt
Date: Mon Oct 29 18:06:09 2012
New Revision: 242324
URL: http://svn.freebsd.org/changeset/base/242324

Log:
  backout r242319, racy and not done in the right place
  
  Reported by:  Garrett Cooper  yaneg...@gmail.com

Modified:
  head/lib/libutil/gr_util.c
  head/lib/libutil/pw_util.c

Modified: head/lib/libutil/gr_util.c
==
--- head/lib/libutil/gr_util.c  Mon Oct 29 18:04:38 2012(r242323)
+++ head/lib/libutil/gr_util.c  Mon Oct 29 18:06:09 2012(r242324)
@@ -63,7 +63,6 @@ static const char group_line_format[] = 
 int
 gr_init(const char *dir, const char *group)
 {
-   struct stat st;
 
if (dir == NULL) {
strcpy(group_dir, _PATH_ETC);
@@ -91,14 +90,6 @@ gr_init(const char *dir, const char *gro
strcpy(group_file, group);
}
 
-   if (stat(group_file, st) == -1)
-   return (-1);
-
-   if (S_ISDIR(st.st_mode)) {
-   errno = EISDIR;
-   return (-1);
-   }
-
initialized = 1;
return (0);
 }

Modified: head/lib/libutil/pw_util.c
==
--- head/lib/libutil/pw_util.c  Mon Oct 29 18:04:38 2012(r242323)
+++ head/lib/libutil/pw_util.c  Mon Oct 29 18:06:09 2012(r242324)
@@ -96,7 +96,6 @@ pw_init(const char *dir, const char *mas
 #if 0
struct rlimit rlim;
 #endif
-   struct stat st;
 
if (dir == NULL) {
strcpy(passwd_dir, _PATH_ETC);
@@ -124,14 +123,6 @@ pw_init(const char *dir, const char *mas
strcpy(masterpasswd, master);
}
 
-   if (stat(masterpasswd, st) == -1)
-   return (-1);
-
-   if (S_ISDIR(st.st_mode)) {
-   errno = EISDIR;
-   return (-1);
-   }
-
/*
 * The code that follows is extremely disruptive to the calling
 * process, and is therefore disabled until someone can conceive
___
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: r242325 - head/sys/netinet

2012-10-29 Thread Michael Tuexen
Author: tuexen
Date: Mon Oct 29 20:42:48 2012
New Revision: 242325
URL: http://svn.freebsd.org/changeset/base/242325

Log:
  Use ntohs() and htons() in correct order. However, this doesn't change
  functionality.

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Mon Oct 29 18:06:09 2012(r242324)
+++ head/sys/netinet/sctputil.c Mon Oct 29 20:42:48 2012(r242325)
@@ -6821,7 +6821,7 @@ sctp_recv_udp_tunneled_packet(struct mbu
switch (iph-ip_v) {
 #ifdef INET
case IPVERSION:
-   iph-ip_len = ntohs(htons(iph-ip_len) - sizeof(struct udphdr));
+   iph-ip_len = htons(ntohs(iph-ip_len) - sizeof(struct udphdr));
sctp_input_with_port(m, off, port);
break;
 #endif
___
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: r242326 - head/sys/netinet

2012-10-29 Thread Michael Tuexen
Author: tuexen
Date: Mon Oct 29 20:44:29 2012
New Revision: 242326
URL: http://svn.freebsd.org/changeset/base/242326

Log:
  Add braces (as used elsewhere in the SCTP code).

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Mon Oct 29 20:42:48 2012
(r242325)
+++ head/sys/netinet/sctp_output.c  Mon Oct 29 20:44:29 2012
(r242326)
@@ -3981,9 +3981,9 @@ sctp_lowlevel_chunk_output(struct sctp_i
}
if ((nofragment_flag)  (port == 0)) {
ip-ip_off = htons(IP_DF);
-   } else
+   } else {
ip-ip_off = htons(0);
-
+   }
/* FreeBSD has a function for ip_id's */
ip-ip_id = ip_newid();
 
___
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: r242327 - in head/sys: netinet netinet6

2012-10-29 Thread Michael Tuexen
Author: tuexen
Date: Mon Oct 29 20:47:32 2012
New Revision: 242327
URL: http://svn.freebsd.org/changeset/base/242327

Log:
  Whitespace changes due to upstream integration of SCTP changes in the
  FreeBSD code base.

Modified:
  head/sys/netinet/sctp_uio.h
  head/sys/netinet/sctp_var.h
  head/sys/netinet6/sctp6_var.h

Modified: head/sys/netinet/sctp_uio.h
==
--- head/sys/netinet/sctp_uio.h Mon Oct 29 20:44:29 2012(r242326)
+++ head/sys/netinet/sctp_uio.h Mon Oct 29 20:47:32 2012(r242327)
@@ -1278,33 +1278,39 @@ void sctp_freeladdrs(struct sockaddr *);
 int sctp_opt_info(int, sctp_assoc_t, int, void *, socklen_t *);
 
 /* deprecated */
-ssize_t sctp_sendmsg 
-(int, const void *, size_t, const struct sockaddr *,
+ssize_t 
+sctp_sendmsg(int, const void *, size_t, const struct sockaddr *,
 socklen_t, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t);
 
 /* deprecated */
-   ssize_t sctp_send(int, const void *, size_t,
-  const struct sctp_sndrcvinfo *, int);
+ssize_t 
+sctp_send(int, const void *, size_t,
+const struct sctp_sndrcvinfo *, int);
 
 /* deprecated */
-   ssize_t sctp_sendx(int, const void *, size_t, struct sockaddr *,
-   int, struct sctp_sndrcvinfo *, int);
+ssize_t 
+sctp_sendx(int, const void *, size_t, struct sockaddr *,
+int, struct sctp_sndrcvinfo *, int);
 
 /* deprecated */
-   ssize_t sctp_sendmsgx(int sd, const void *, size_t, struct sockaddr *,
-  int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t);
+ssize_t 
+sctp_sendmsgx(int sd, const void *, size_t, struct sockaddr *,
+int, uint32_t, uint32_t, uint16_t, uint32_t, uint32_t);
 
-   sctp_assoc_t sctp_getassocid(int, struct sockaddr *);
+sctp_assoc_t sctp_getassocid(int, struct sockaddr *);
 
 /* deprecated */
-   ssize_t sctp_recvmsg(int, void *, size_t, struct sockaddr *, socklen_t 
*,
- struct sctp_sndrcvinfo *, int *);
-
-   ssize_t sctp_sendv(int, const struct iovec *, int, struct sockaddr *,
-   int, void *, socklen_t, unsigned int, int);
-
-   ssize_t sctp_recvv(int, const struct iovec *, int, struct sockaddr *,
-   socklen_t *, void *, socklen_t *, unsigned int *, int *);
+ssize_t 
+sctp_recvmsg(int, void *, size_t, struct sockaddr *, socklen_t *,
+struct sctp_sndrcvinfo *, int *);
+
+ssize_t 
+sctp_sendv(int, const struct iovec *, int, struct sockaddr *,
+int, void *, socklen_t, unsigned int, int);
+
+ssize_t 
+sctp_recvv(int, const struct iovec *, int, struct sockaddr *,
+socklen_t *, void *, socklen_t *, unsigned int *, int *);
 
 __END_DECLS
 

Modified: head/sys/netinet/sctp_var.h
==
--- head/sys/netinet/sctp_var.h Mon Oct 29 20:44:29 2012(r242326)
+++ head/sys/netinet/sctp_var.h Mon Oct 29 20:47:32 2012(r242327)
@@ -321,48 +321,34 @@ struct sctphdr;
 
 void sctp_close(struct socket *so);
 int sctp_disconnect(struct socket *so);
-
 void sctp_ctlinput(int, struct sockaddr *, void *);
 int sctp_ctloutput(struct socket *, struct sockopt *);
 
 #ifdef INET
 void sctp_input_with_port(struct mbuf *, int, uint16_t);
-
-#endif
-#ifdef INET
 void sctp_input(struct mbuf *, int);
 
 #endif
 void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t);
 void sctp_drain(void);
 void sctp_init(void);
-
 void sctp_finish(void);
-
 int sctp_flush(struct socket *, int);
 int sctp_shutdown(struct socket *);
-void sctp_notify 
-(struct sctp_inpcb *, struct ip *ip, struct sctphdr *,
+void 
+sctp_notify(struct sctp_inpcb *, struct ip *ip, struct sctphdr *,
 struct sockaddr *, struct sctp_tcb *,
 struct sctp_nets *);
-
-   int sctp_bindx(struct socket *, int, struct sockaddr_storage *,
-int, int, struct proc *);
+int 
+sctp_bindx(struct socket *, int, struct sockaddr_storage *,
+int, int, struct proc *);
 
 /* can't use sctp_assoc_t here */
-   int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *);
-
-   int sctp_ingetaddr(struct socket *,
-struct sockaddr **
-);
-
-   int sctp_peeraddr(struct socket *,
-struct sockaddr **
-);
-
-   int sctp_listen(struct socket *, int, struct thread *);
-
-   int sctp_accept(struct socket *, struct sockaddr **);
+int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *);
+int sctp_ingetaddr(struct socket *, struct sockaddr **);
+int sctp_peeraddr(struct socket *, struct sockaddr **);
+int sctp_listen(struct socket *, int, struct thread *);
+int sctp_accept(struct socket *, struct sockaddr **);
 
 #endif /* _KERNEL */
 

Modified: head/sys/netinet6/sctp6_var.h
==
--- head/sys/netinet6/sctp6_var.h   Mon Oct 29 20:44:29 2012
(r242326)
+++ head/sys/netinet6/sctp6_var.h   Mon Oct 29 20:47:32 2012  

svn commit: r242328 - head/sys/geom/raid

2012-10-29 Thread Alexander Motin
Author: mav
Date: Mon Oct 29 21:08:06 2012
New Revision: 242328
URL: http://svn.freebsd.org/changeset/base/242328

Log:
  Minor addition to r242323:
  Alike to BIO_WRITE, report success if at least one subdisk succeeded with
  BIO_DELETE.  But unlike BIO_WRITE don't fail disk on BIO_DELETE error.
  
  Sponsored by: iXsystems, Inc.
  MFC after:1 month

Modified:
  head/sys/geom/raid/tr_raid1.c
  head/sys/geom/raid/tr_raid1e.c

Modified: head/sys/geom/raid/tr_raid1.c
==
--- head/sys/geom/raid/tr_raid1.c   Mon Oct 29 20:47:32 2012
(r242327)
+++ head/sys/geom/raid/tr_raid1.c   Mon Oct 29 21:08:06 2012
(r242328)
@@ -891,10 +891,10 @@ rebuild_round_done:
g_raid_unlock_range(sd-sd_volume, bp-bio_offset,
bp-bio_length);
}
-   if (pbp-bio_cmd == BIO_WRITE) {
+   if (pbp-bio_cmd != BIO_READ) {
if (pbp-bio_inbed == 1 || pbp-bio_error != 0)
pbp-bio_error = bp-bio_error;
-   if (bp-bio_error != 0) {
+   if (pbp-bio_cmd == BIO_WRITE  bp-bio_error != 0) {
G_RAID_LOGREQ(0, bp, Write failed: failing subdisk.);
g_raid_tr_raid1_fail_disk(sd-sd_softc, sd, 
sd-sd_disk);
}

Modified: head/sys/geom/raid/tr_raid1e.c
==
--- head/sys/geom/raid/tr_raid1e.c  Mon Oct 29 20:47:32 2012
(r242327)
+++ head/sys/geom/raid/tr_raid1e.c  Mon Oct 29 21:08:06 2012
(r242328)
@@ -1118,10 +1118,10 @@ rebuild_round_done:
G_RAID_LOGREQ(2, bp, REMAP done %d., bp-bio_error);
g_raid_unlock_range(sd-sd_volume, virtual, bp-bio_length);
}
-   if (pbp-bio_cmd == BIO_WRITE) {
+   if (pbp-bio_cmd != BIO_READ) {
if (pbp-bio_inbed == 1 || pbp-bio_error != 0)
pbp-bio_error = bp-bio_error;
-   if (bp-bio_error != 0) {
+   if (pbp-bio_cmd == BIO_WRITE  bp-bio_error != 0) {
G_RAID_LOGREQ(0, bp, Write failed: failing subdisk.);
g_raid_tr_raid1e_fail_disk(sd-sd_softc, sd, 
sd-sd_disk);
}
___
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: r242332 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2012-10-29 Thread Xin LI
Author: delphij
Date: Tue Oct 30 01:29:45 2012
New Revision: 242332
URL: http://svn.freebsd.org/changeset/base/242332

Log:
  s/dettach/detach/g
  
  Approved by:  pjd
  MFC after:1 month

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Mon Oct 
29 23:58:15 2012(r242331)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Tue Oct 
30 01:29:45 2012(r242332)
@@ -332,7 +332,7 @@ vdev_geom_attach_taster(struct g_consume
 }
 
 static void
-vdev_geom_dettach_taster(struct g_consumer *cp)
+vdev_geom_detach_taster(struct g_consumer *cp)
 {
g_access(cp, -1, 0, 0);
g_detach(cp);
@@ -373,7 +373,7 @@ vdev_geom_read_pool_label(const char *na
g_topology_unlock();
error = vdev_geom_read_config(zcp, vdev_cfg);
g_topology_lock();
-   vdev_geom_dettach_taster(zcp);
+   vdev_geom_detach_taster(zcp);
if (error)
continue;
ZFS_LOG(1, successfully read vdev config);
@@ -442,7 +442,7 @@ vdev_geom_attach_by_guid(uint64_t guid)
g_topology_unlock();
pguid = vdev_geom_read_guid(zcp);
g_topology_lock();
-   vdev_geom_dettach_taster(zcp);
+   vdev_geom_detach_taster(zcp);
if (pguid != guid)
continue;
cp = vdev_geom_attach(pp);
___
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: r242333 - head/sys/dev/uart

2012-10-29 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Oct 30 01:52:49 2012
New Revision: 242333
URL: http://svn.freebsd.org/changeset/base/242333

Log:
  Separate interrupts enable/disable logic from setting port parameters.
  Otherwise setting baud rate in TTY mode effectively disables TX/RX
  interrupts and renders port unusable.

Modified:
  head/sys/dev/uart/uart_dev_pl011.c

Modified: head/sys/dev/uart/uart_dev_pl011.c
==
--- head/sys/dev/uart/uart_dev_pl011.c  Tue Oct 30 01:29:45 2012
(r242332)
+++ head/sys/dev/uart/uart_dev_pl011.c  Tue Oct 30 01:52:49 2012
(r242333)
@@ -120,16 +120,12 @@ uart_pl011_probe(struct uart_bas *bas)
 }
 
 static void
-uart_pl011_init(struct uart_bas *bas, int baudrate, int databits, int stopbits,
+uart_pl011_param(struct uart_bas *bas, int baudrate, int databits, int 
stopbits,
 int parity)
 {
uint32_t ctrl, line;
uint32_t baud;
 
-   /* Mask all interrupts */
-   __uart_setreg(bas, UART_IMSC, __uart_getreg(bas, UART_IMSC) 
-   ~IMSC_MASK_ALL);
-
/*
 * Zero all settings to make sure
 * UART is disabled and not configured
@@ -179,6 +175,17 @@ uart_pl011_init(struct uart_bas *bas, in
 }
 
 static void
+uart_pl011_init(struct uart_bas *bas, int baudrate, int databits, int stopbits,
+int parity)
+{
+   /* Mask all interrupts */
+   __uart_setreg(bas, UART_IMSC, __uart_getreg(bas, UART_IMSC) 
+   ~IMSC_MASK_ALL);
+   
+   uart_pl011_param(bas, baudrate, databits, stopbits, parity);
+}
+
+static void
 uart_pl011_term(struct uart_bas *bas)
 {
 }
@@ -358,7 +365,7 @@ uart_pl011_bus_param(struct uart_softc *
 {
 
uart_lock(sc-sc_hwmtx);
-   uart_pl011_init(sc-sc_bas, baudrate, databits, stopbits, parity);
+   uart_pl011_param(sc-sc_bas, baudrate, databits, stopbits, parity);
uart_unlock(sc-sc_hwmtx);
 
return (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


Re: svn commit: r242161 - in head/sys: net netinet netpfil/pf

2012-10-29 Thread YongHyeon PYUN
On Mon, Oct 29, 2012 at 09:20:59AM +0100, Andre Oppermann wrote:
 On 29.10.2012 22:40, YongHyeon PYUN wrote:
 On Mon, Oct 29, 2012 at 09:21:00AM +0400, Gleb Smirnoff wrote:
 On Mon, Oct 29, 2012 at 01:41:04PM -0700, YongHyeon PYUN wrote:
 Y On Sun, Oct 28, 2012 at 02:01:37AM +0400, Gleb Smirnoff wrote:
 Y  On Sat, Oct 27, 2012 at 12:58:52PM +0200, Andre Oppermann wrote:
 Y  A On 26.10.2012 23:06, Gleb Smirnoff wrote:
 Y  A  Author: glebius
 Y  A  Date: Fri Oct 26 21:06:33 2012
 Y  A  New Revision: 242161
 Y  A  URL: http://svn.freebsd.org/changeset/base/242161
 Y  A 
 Y  A  Log:
 Y  A o Remove last argument to ip_fragment(), and obtain all 
 needed information
 Y  A   on checksums directly from mbuf flags. This simplifies 
 code.
 Y  A o Clear CSUM_IP from the mbuf in ip_fragment() if we did 
 checksums in
 Y
 Y I'm not sure whether ti(4)'s checksum offloading for IP fragmented
 Y packets(CSUM_IP_FRAGS) still works after this change.  ti(4)
 Y requires CSUM_IP should be set for IP fragmented packets. Not sure
 Y whether it's a bug or not. I have a ti(4) controller but I don't
 Y remember where I can find it and don't have a link
 Y parter(1000baseSX) to test it. :-(
 
 ti(4) declares both CSUM_IP and CSUM_IP_FRAGS, so ip_fragment() won't do
 
 Because it supports both CSUM_IP and CSUM_IP_FRAGS. Probably ti(4)
 is the only controller that supports TCP/UDP checksum offloading
 for an IP fragmented packet.
 
 This is a bit weird if it doesn't do the fragmentation itself.
 Computing the IP header checksum doesn't differ for normal and
 fragmented packets.  The protocol checksum (TCP or UDP) stays
 the same for in the case of IP level fragmentation.  It is only
 visible in the first fragment which includes the protocol header.

My interpretation for CSUM_IP_FRAGS works like the following.
 - Only peuso header checksum for TCP/UDP is computed by upper
   stack.
 - Controller has no ability to fragment the packet so it should
   done in upper stack(i.e. ip_output()).
 - When ip_output() has to fragment the packet, it just fragments
   the packet without completing TCP/UDP and IP checksum. If
   controller does not support CSUM_IP_FRAGS feature, ip_output()
   can't delay TCP/UDP checksum in this stage.
 - The fragmented packets are sent to driver. Driver sets
   appropriate bits of DMA descriptor based on fragmentation field
   of mbuf(M_FRAG, M_LASTFRAG) and issue the frame to controller.
 - The firmware of controller queues the fragmented frames up in
   its internal memory and hold off sending out the frames since it
   has to compute TCP/UDP checksum. When it sees a frame which
   indicates the end of fragmented frame it finally computes
   TCP/UDP checksum and send each frame out to wire by computing
   IP checksum on the fly.
The difference is which one(upper stack vs. controller) computes
TCP/UDP/IP checksum.

 
 software checksums, and thus won't clear these flags.
 
 Potentially a driver that announces one flag in if_hwassist but relies on
 couple of flags to be set on mbuf is not correct. If a driver can't do 
 single
 checksum  processing independently from others, then it should set or 
 clear
 appropriate flags in if_hwassist as a group.
 
 Hmm, then what would be best way to achieve CSUM_IP_FRAGS in
 driver? I don't have clear idea how to utilize the hardware
 feature. The stack should tell that the mbuf needs TCP/UDP checksum
 offloading for IP fragmented packet(i.e. CSUM_IP_FRAGS is not set by
 upper stack).
 
 As I said there can't be fragment checksumming without hardware

It's up to controller's firmware. It does not send the fragmented
frame until it computes TCP/UDP checksum.

 based fragmentation.  We have three cases here:
 
  1. TSO where the hardware does the segmentation, TCP and IP header
 checksums for each generated packet.
  2. IP packet fragmentation where a packet is split, the IP header
 checksum is recomputed for each fragment, but the protocol csum
 stays the same and is not modified.
  3. UDP fragmentation where a large packet is sent to the hardware
 and it generates first the UDP checksum and then splits it into
 IP fragments each with its own IP header checksum.
 
 So we end up with these possible large send hardware offload capabilities:
  TSO: including IPv4hdr and TCP checksumming
  UDP fragmentation: including IPv4hdr and UDP checksumming
  IP fragmentation: including IPv4hdr checksumming
 
 Besides that we have the packet = MTU sized offload capabilities:
  TCP checksumming
  UDP checksumming
  SCTP checksumming
  IPv4hdr checksumming
 
 Y  A   hardware. Some driver may not announce CSUM_IP in theur 
 if_hwassist,
 
 
 Oh, that was a typo! Software was meant.
 
 That explains quite a bit of confusion.
 
 -- 
 Andre
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to