svn commit: r282942 - head/sys/dev/sfxge

2015-05-15 Thread Andrew Rybchenko
Author: arybchik
Date: Fri May 15 06:50:59 2015
New Revision: 282942
URL: https://svnweb.freebsd.org/changeset/base/282942

Log:
  sfxge: split sfxge_tx_qdpl_put() into *_locked() and *_unlocked()
  
  It simplifies understanding of the sfxge_tx_packet_add() logic and
  avoids passing of 'locked' to called function.
  
  Reviewed by:gnn
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:  2 days
  Differential Revision: https://reviews.freebsd.org/D2547

Modified:
  head/sys/dev/sfxge/sfxge_tx.c
  head/sys/dev/sfxge/sfxge_tx.h

Modified: head/sys/dev/sfxge/sfxge_tx.c
==
--- head/sys/dev/sfxge/sfxge_tx.c   Fri May 15 06:49:43 2015
(r282941)
+++ head/sys/dev/sfxge/sfxge_tx.c   Fri May 15 06:50:59 2015
(r282942)
@@ -521,18 +521,10 @@ sfxge_tx_qdpl_service(struct sfxge_txq *
 }
 
 /*
- * Put a packet on the deferred packet list.
- *
- * If we are called with the txq lock held, we put the packet on the get
- * list, otherwise we atomically push it on the put list.  The swizzle
- * function takes care of ordering.
- *
- * The length of the put list is bounded by SFXGE_TX_MAX_DEFERRED.  We
- * overload the csum_data field in the mbuf to keep track of this length
- * because there is no cheap alternative to avoid races.
+ * Put a packet on the deferred packet get-list.
  */
 static int
-sfxge_tx_qdpl_put(struct sfxge_txq *txq, struct mbuf *mbuf, int locked)
+sfxge_tx_qdpl_put_locked(struct sfxge_txq *txq, struct mbuf *mbuf)
 {
struct sfxge_tx_dpl *stdp;
 
@@ -540,52 +532,66 @@ sfxge_tx_qdpl_put(struct sfxge_txq *txq,
 
KASSERT(mbuf-m_nextpkt == NULL, (mbuf-m_nextpkt != NULL));
 
-   if (locked) {
-   SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
-
-   sfxge_tx_qdpl_swizzle(txq);
+   SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
 
-   if (stdp-std_get_count = stdp-std_get_max) {
-   txq-get_overflow++;
+   if (stdp-std_get_count = stdp-std_get_max) {
+   txq-get_overflow++;
+   return (ENOBUFS);
+   }
+   if (sfxge_is_mbuf_non_tcp(mbuf)) {
+   if (stdp-std_get_non_tcp_count =
+   stdp-std_get_non_tcp_max) {
+   txq-get_non_tcp_overflow++;
return (ENOBUFS);
}
-   if (sfxge_is_mbuf_non_tcp(mbuf)) {
-   if (stdp-std_get_non_tcp_count =
-   stdp-std_get_non_tcp_max) {
-   txq-get_non_tcp_overflow++;
-   return (ENOBUFS);
-   }
-   stdp-std_get_non_tcp_count++;
-   }
-
-   *(stdp-std_getp) = mbuf;
-   stdp-std_getp = mbuf-m_nextpkt;
-   stdp-std_get_count++;
-   } else {
-   volatile uintptr_t *putp;
-   uintptr_t old;
-   uintptr_t new;
-   unsigned old_len;
-
-   putp = stdp-std_put;
-   new = (uintptr_t)mbuf;
-
-   do {
-   old = *putp;
-   if (old != 0) {
-   struct mbuf *mp = (struct mbuf *)old;
-   old_len = mp-m_pkthdr.csum_data;
-   } else
-   old_len = 0;
-   if (old_len = stdp-std_put_max) {
-   atomic_add_long(txq-put_overflow, 1);
-   return (ENOBUFS);
-   }
-   mbuf-m_pkthdr.csum_data = old_len + 1;
-   mbuf-m_nextpkt = (void *)old;
-   } while (atomic_cmpset_ptr(putp, old, new) == 0);
+   stdp-std_get_non_tcp_count++;
}
 
+   *(stdp-std_getp) = mbuf;
+   stdp-std_getp = mbuf-m_nextpkt;
+   stdp-std_get_count++;
+
+   return (0);
+}
+
+/*
+ * Put a packet on the deferred packet put-list.
+ *
+ * We overload the csum_data field in the mbuf to keep track of this length
+ * because there is no cheap alternative to avoid races.
+ */
+static int
+sfxge_tx_qdpl_put_unlocked(struct sfxge_txq *txq, struct mbuf *mbuf)
+{
+   struct sfxge_tx_dpl *stdp;
+   volatile uintptr_t *putp;
+   uintptr_t old;
+   uintptr_t new;
+   unsigned old_len;
+
+   KASSERT(mbuf-m_nextpkt == NULL, (mbuf-m_nextpkt != NULL));
+
+   SFXGE_TXQ_LOCK_ASSERT_NOTOWNED(txq);
+
+   stdp = txq-dpl;
+   putp = stdp-std_put;
+   new = (uintptr_t)mbuf;
+
+   do {
+   old = *putp;
+   if (old != 0) {
+   struct mbuf *mp = (struct mbuf *)old;
+   old_len = mp-m_pkthdr.csum_data;
+   } else
+   old_len = 0;
+   if (old_len = stdp-std_put_max) {
+   atomic_add_long(txq-put_overflow, 1);

svn commit: r282948 - head/lib/libthr/thread

2015-05-15 Thread Konstantin Belousov
Author: kib
Date: Fri May 15 08:40:17 2015
New Revision: 282948
URL: https://svnweb.freebsd.org/changeset/base/282948

Log:
  Some third-party malloc(3) implementations use pthread_setspecific(3)
  to handle per-thread information.  Since our pthread_setspecific()
  implementation calls calloc(3) to allocate per-thread specific data
  storage, things get complicated.
  
  Switch the allocator to use bare mmap(2).  There is some loss of the
  allocated page, since e.g. on amd64, PTHREAD_KEYS_MAX * sizeof(struct
  pthread_specific_elem) is 3K (it actually spans whole page due to
  padding), but I believe it is more acceptable than additional code for
  specialized allocator().
  
  The alternatives would either to make the specific data array be part of
  the struct thread, or use internal bindings to call the libc malloc,
  avoiding interposing.
  
  Also do the style pass over the thr_spec.c, esp. simplify the
  conditionals nesting by returning early when an error detected.
  Remove trivial comments.
  
  Found by: y...@rawbw.com
  PR:   200138
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/lib/libthr/thread/thr_spec.c

Modified: head/lib/libthr/thread/thr_spec.c
==
--- head/lib/libthr/thread/thr_spec.c   Fri May 15 08:30:29 2015
(r282947)
+++ head/lib/libthr/thread/thr_spec.c   Fri May 15 08:40:17 2015
(r282948)
@@ -30,6 +30,7 @@
  */
 
 #include namespace.h
+#include sys/mman.h
 #include signal.h
 #include stdlib.h
 #include string.h
@@ -40,7 +41,6 @@
 
 #include thr_private.h
 
-/* Static variables: */
 struct pthread_key _thread_keytable[PTHREAD_KEYS_MAX];
 
 __weak_reference(_pthread_key_create, pthread_key_create);
@@ -50,7 +50,7 @@ __weak_reference(_pthread_setspecific, p
 
 
 int
-_pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
+_pthread_key_create(pthread_key_t *key, void (*destructor)(void *))
 {
struct pthread *curthread;
int i;
@@ -59,7 +59,6 @@ _pthread_key_create(pthread_key_t *key, 
 
curthread = _get_curthread();
 
-   /* Lock the key table: */
THR_LOCK_ACQUIRE(curthread, _keytable_lock);
for (i = 0; i  PTHREAD_KEYS_MAX; i++) {
 
@@ -68,14 +67,12 @@ _pthread_key_create(pthread_key_t *key, 
_thread_keytable[i].destructor = destructor;
_thread_keytable[i].seqno++;
 
-   /* Unlock the key table: */
THR_LOCK_RELEASE(curthread, _keytable_lock);
*key = i + 1;
return (0);
}
 
}
-   /* Unlock the key table: */
THR_LOCK_RELEASE(curthread, _keytable_lock);
return (EAGAIN);
 }
@@ -83,44 +80,40 @@ _pthread_key_create(pthread_key_t *key, 
 int
 _pthread_key_delete(pthread_key_t userkey)
 {
-   struct pthread *curthread = _get_curthread();
-   int key = userkey - 1;
-   int ret = 0;
-
-   if ((unsigned int)key  PTHREAD_KEYS_MAX) {
-   /* Lock the key table: */
-   THR_LOCK_ACQUIRE(curthread, _keytable_lock);
-
-   if (_thread_keytable[key].allocated)
-   _thread_keytable[key].allocated = 0;
-   else
-   ret = EINVAL;
-
-   /* Unlock the key table: */
-   THR_LOCK_RELEASE(curthread, _keytable_lock);
-   } else
+   struct pthread *curthread;
+   int key, ret;
+
+   key = userkey - 1;
+   if ((unsigned int)key = PTHREAD_KEYS_MAX)
+   return (EINVAL);
+   curthread = _get_curthread();
+   THR_LOCK_ACQUIRE(curthread, _keytable_lock);
+   if (_thread_keytable[key].allocated) {
+   _thread_keytable[key].allocated = 0;
+   ret = 0;
+   } else {
ret = EINVAL;
+   }
+   THR_LOCK_RELEASE(curthread, _keytable_lock);
return (ret);
 }
 
 void 
 _thread_cleanupspecific(void)
 {
-   struct pthread  *curthread = _get_curthread();
-   void(*destructor)( void *);
-   const void  *data = NULL;
-   int key;
-   int i;
+   struct pthread *curthread;
+   void (*destructor)(void *);
+   const void *data;
+   int i, key;
 
+   curthread = _get_curthread();
if (curthread-specific == NULL)
return;
-
-   /* Lock the key table: */
THR_LOCK_ACQUIRE(curthread, _keytable_lock);
-   for (i = 0; (i  PTHREAD_DESTRUCTOR_ITERATIONS) 
-   (curthread-specific_data_count  0); i++) {
-   for (key = 0; (key  PTHREAD_KEYS_MAX) 
-   (curthread-specific_data_count  0); key++) {
+   for (i = 0; i  PTHREAD_DESTRUCTOR_ITERATIONS 
+   curthread-specific_data_count  0; i++) {
+   for (key = 0; key  PTHREAD_KEYS_MAX 
+   curthread-specific_data_count  0; key++) 

svn commit: r282945 - head/sys/amd64/amd64

2015-05-15 Thread Konstantin Belousov
Author: kib
Date: Fri May 15 07:57:47 2015
New Revision: 282945
URL: https://svnweb.freebsd.org/changeset/base/282945

Log:
  Implement the support for PCID in UP kernels.
  
  Requested by: alc
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:3 weeks

Modified:
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Fri May 15 07:54:31 2015(r282944)
+++ head/sys/amd64/amd64/pmap.c Fri May 15 07:57:47 2015(r282945)
@@ -909,11 +909,7 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
 * pc_pcid_next and pc_pcid_gen are initialized by AP
 * during pcpu setup.
 */
-#ifdef SMP
load_cr4(rcr4() | CR4_PCIDE);
-#else
-   pmap_pcid_enabled = 0;
-#endif
} else {
pmap_pcid_enabled = 0;
}
@@ -1559,61 +1555,79 @@ pmap_update_pde(pmap_t pmap, vm_offset_t
 #else /* !SMP */
 /*
  * Normal, non-SMP, invalidation functions.
- * We inline these within pmap.c for speed.
  */
-PMAP_INLINE void
+void
 pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
 {
 
-   switch (pmap-pm_type) {
-   case PT_X86:
-   if (pmap == kernel_pmap || !CPU_EMPTY(pmap-pm_active))
-   invlpg(va);
-   break;
-   case PT_RVI:
-   case PT_EPT:
+   if (pmap-pm_type == PT_RVI || pmap-pm_type == PT_EPT) {
pmap-pm_eptgen++;
-   break;
-   default:
-   panic(pmap_invalidate_page: unknown type: %d, pmap-pm_type);
+   return;
}
+   KASSERT(pmap-pm_type == PT_X86,
+   (pmap_invalidate_range: unknown type %d, pmap-pm_type));
+
+   if (pmap == kernel_pmap || pmap == PCPU_GET(curpmap))
+   invlpg(va);
+   else if (pmap_pcid_enabled)
+   pmap-pm_pcids[0].pm_gen = 0;
 }
 
-PMAP_INLINE void
+void
 pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
 {
vm_offset_t addr;
 
-   switch (pmap-pm_type) {
-   case PT_X86:
-   if (pmap == kernel_pmap || !CPU_EMPTY(pmap-pm_active))
-   for (addr = sva; addr  eva; addr += PAGE_SIZE)
-   invlpg(addr);
-   break;
-   case PT_RVI:
-   case PT_EPT:
+   if (pmap-pm_type == PT_RVI || pmap-pm_type == PT_EPT) {
pmap-pm_eptgen++;
-   break;
-   default:
-   panic(pmap_invalidate_range: unknown type: %d, pmap-pm_type);
+   return;
+   }
+   KASSERT(pmap-pm_type == PT_X86,
+   (pmap_invalidate_range: unknown type %d, pmap-pm_type));
+
+   if (pmap == kernel_pmap || pmap == PCPU_GET(curpmap)) {
+   for (addr = sva; addr  eva; addr += PAGE_SIZE)
+   invlpg(addr);
+   } else if (pmap_pcid_enabled) {
+   pmap-pm_pcids[0].pm_gen = 0;
}
 }
 
-PMAP_INLINE void
+void
 pmap_invalidate_all(pmap_t pmap)
 {
+   struct invpcid_descr d;
 
-   switch (pmap-pm_type) {
-   case PT_X86:
-   if (pmap == kernel_pmap || !CPU_EMPTY(pmap-pm_active))
-   invltlb();
-   break;
-   case PT_RVI:
-   case PT_EPT:
+   if (pmap-pm_type == PT_RVI || pmap-pm_type == PT_EPT) {
pmap-pm_eptgen++;
-   break;
-   default:
-   panic(pmap_invalidate_all: unknown type %d, pmap-pm_type);
+   return;
+   }
+   KASSERT(pmap-pm_type == PT_X86,
+   (pmap_invalidate_all: unknown type %d, pmap-pm_type));
+
+   if (pmap == kernel_pmap) {
+   if (pmap_pcid_enabled  invpcid_works) {
+   bzero(d, sizeof(d));
+   invpcid(d, INVPCID_CTXGLOB);
+   } else {
+   invltlb_globpcid();
+   }
+   } else if (pmap == PCPU_GET(curpmap)) {
+   if (pmap_pcid_enabled) {
+   if (invpcid_works) {
+   d.pcid = pmap-pm_pcids[0].pm_pcid;
+   d.pad = 0;
+   d.addr = 0;
+   invpcid(d, INVPCID_CTX);
+   } else {
+   load_cr3(pmap-pm_cr3 | pmap-pm_pcids[0].
+   pm_pcid);
+   }
+   } else {
+   invltlb();
+   }
+   } else if (pmap_pcid_enabled) {
+   pmap-pm_pcids[0].pm_gen = 0;
}
 }
 
@@ -1629,10 +1643,10 @@ pmap_update_pde(pmap_t pmap, vm_offset_t
 {
 
pmap_update_pde_store(pmap, pde, newpde);
-   if (pmap == kernel_pmap || !CPU_EMPTY(pmap-pm_active))
+   if (pmap == kernel_pmap || pmap == PCPU_GET(curpmap))
pmap_update_pde_invalidate(pmap, va, newpde);

svn commit: r282944 - in head/sys: kern sys

2015-05-15 Thread Konstantin Belousov
Author: kib
Date: Fri May 15 07:54:31 2015
New Revision: 282944
URL: https://svnweb.freebsd.org/changeset/base/282944

Log:
  Right now, the process' p_boundary_count counter is decremented by the
  suspended thread itself, on the return path from
  thread_suspend_check().  A consequence is that return from
  thread_single_end(SINGLE_BOUNDARY) may leave p_boundary_count
  non-zero, it might be even equal to the threads count.
  
  Now, assume that we have two threads in the process, both calling
  execve(2).  Suppose that the first thread won the race to be the
  suspension thread, and that afterward its exec failed for any reason.
  After the first thread did thread_single_end(SINGLE_BOUNDARY), second
  thread becomes the process suspension thread and checks
  p_boundary_count.  The non-zero value of the count allows the
  suspension loop to finish without actually suspending some threads.
  In other words, we enter exec code with some threads not suspended.
  
  Fix this by decrementing p_boundary_count in the
  thread_single_end()-thread_unsuspend_one() during marking the thread
  as runnable.  This way, a return from thread_single_end() guarantees
  that the counter is cleared.  We do not care whether the unsuspended
  thread has a chance to run.
  
  Add some asserts to ensure the state of the process when single
  boundary suspension is lifted.  Also make thread_unuspend_one()
  static.
  
  In collaboration with:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/kern/kern_thread.c
  head/sys/sys/proc.h

Modified: head/sys/kern/kern_thread.c
==
--- head/sys/kern/kern_thread.c Fri May 15 07:07:37 2015(r282943)
+++ head/sys/kern/kern_thread.c Fri May 15 07:54:31 2015(r282944)
@@ -74,6 +74,8 @@ static struct mtx zombie_lock;
 MTX_SYSINIT(zombie_lock, zombie_lock, zombie lock, MTX_SPIN);
 
 static void thread_zombie(struct thread *);
+static int thread_unsuspend_one(struct thread *td, struct proc *p,
+bool boundary);
 
 #define TID_BUFFER_SIZE1024
 
@@ -445,7 +447,7 @@ thread_exit(void)
if (p-p_numthreads == p-p_suspcount) {
thread_lock(p-p_singlethread);
wakeup_swapper = thread_unsuspend_one(
-   p-p_singlethread, p);
+   p-p_singlethread, p, false);
thread_unlock(p-p_singlethread);
if (wakeup_swapper)
kick_proc0();
@@ -603,19 +605,19 @@ weed_inhib(int mode, struct thread *td2,
switch (mode) {
case SINGLE_EXIT:
if (TD_IS_SUSPENDED(td2))
-   wakeup_swapper |= thread_unsuspend_one(td2, p);
+   wakeup_swapper |= thread_unsuspend_one(td2, p, true);
if (TD_ON_SLEEPQ(td2)  (td2-td_flags  TDF_SINTR) != 0)
wakeup_swapper |= sleepq_abort(td2, EINTR);
break;
case SINGLE_BOUNDARY:
if (TD_IS_SUSPENDED(td2)  (td2-td_flags  TDF_BOUNDARY) == 0)
-   wakeup_swapper |= thread_unsuspend_one(td2, p);
+   wakeup_swapper |= thread_unsuspend_one(td2, p, false);
if (TD_ON_SLEEPQ(td2)  (td2-td_flags  TDF_SINTR) != 0)
wakeup_swapper |= sleepq_abort(td2, ERESTART);
break;
case SINGLE_NO_EXIT:
if (TD_IS_SUSPENDED(td2)  (td2-td_flags  TDF_BOUNDARY) == 0)
-   wakeup_swapper |= thread_unsuspend_one(td2, p);
+   wakeup_swapper |= thread_unsuspend_one(td2, p, false);
if (TD_ON_SLEEPQ(td2)  (td2-td_flags  TDF_SINTR) != 0)
wakeup_swapper |= sleepq_abort(td2, ERESTART);
break;
@@ -630,7 +632,7 @@ weed_inhib(int mode, struct thread *td2,
 */
if (TD_IS_SUSPENDED(td2)  (td2-td_flags  (TDF_BOUNDARY |
TDF_ALLPROCSUSP)) == 0)
-   wakeup_swapper |= thread_unsuspend_one(td2, p);
+   wakeup_swapper |= thread_unsuspend_one(td2, p, false);
if (TD_ON_SLEEPQ(td2)  (td2-td_flags  TDF_SINTR) != 0) {
if ((td2-td_flags  TDF_SBDRY) == 0) {
thread_suspend_one(td2);
@@ -898,8 +900,8 @@ thread_suspend_check(int return_instead)
if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE) {
if (p-p_numthreads == p-p_suspcount + 1) {
thread_lock(p-p_singlethread);
-   wakeup_swapper =
-   thread_unsuspend_one(p-p_singlethread, p);
+   

svn commit: r282939 - head/sys/dev/ixl

2015-05-15 Thread Marcelo Araujo
Author: araujo (ports committer)
Date: Fri May 15 06:11:47 2015
New Revision: 282939
URL: https://svnweb.freebsd.org/changeset/base/282939

Log:
  Free vsi-queues after use.
  
  Differential Revision:D2344
  Reviewed by:  erj

Modified:
  head/sys/dev/ixl/if_ixlv.c

Modified: head/sys/dev/ixl/if_ixlv.c
==
--- head/sys/dev/ixl/if_ixlv.c  Fri May 15 06:05:30 2015(r282938)
+++ head/sys/dev/ixl/if_ixlv.c  Fri May 15 06:11:47 2015(r282939)
@@ -1693,7 +1693,6 @@ ixlv_setup_queues(struct ixlv_sc *sc)
return (0);
 
 fail:
-   free(vsi-queues, M_DEVBUF);
for (int i = 0; i  vsi-num_queues; i++) {
que = vsi-queues[i];
rxr = que-rxr;
@@ -1703,6 +1702,7 @@ fail:
if (txr-base)
i40e_free_dma_mem(sc-hw, txr-dma);
}
+   free(vsi-queues, M_DEVBUF);
 
 early:
return (error);
___
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: r282940 - head/sys/dev/sfxge

2015-05-15 Thread Andrew Rybchenko
Author: arybchik
Date: Fri May 15 06:48:36 2015
New Revision: 282940
URL: https://svnweb.freebsd.org/changeset/base/282940

Log:
  sfxge: LRO may be done only if checksums are OK
  
  Also it is cheaper to check Rx descriptor flags than TCP protocol in IP
  header.
  
  Reviewed by:gnn
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:  2 days
  Differential Revision: https://reviews.freebsd.org/D2542

Modified:
  head/sys/dev/sfxge/sfxge_rx.c

Modified: head/sys/dev/sfxge/sfxge_rx.c
==
--- head/sys/dev/sfxge/sfxge_rx.c   Fri May 15 06:11:47 2015
(r282939)
+++ head/sys/dev/sfxge/sfxge_rx.c   Fri May 15 06:48:36 2015
(r282940)
@@ -688,15 +688,18 @@ sfxge_lro(struct sfxge_rxq *rxq, struct 
 */
if (l3_proto == htons(ETHERTYPE_IP)) {
struct ip *iph = nh;
-   if ((iph-ip_p - IPPROTO_TCP) |
-   (iph-ip_hl - (sizeof(*iph)  2u)) |
+
+   KASSERT(iph-ip_p == IPPROTO_TCP,
+   (IPv4 protocol is not TCP, but packet marker is set));
+   if ((iph-ip_hl - (sizeof(*iph)  2u)) |
(iph-ip_off  htons(IP_MF | IP_OFFMASK)))
goto deliver_now;
th = (struct tcphdr *)(iph + 1);
} else if (l3_proto == htons(ETHERTYPE_IPV6)) {
struct ip6_hdr *iph = nh;
-   if (iph-ip6_nxt != IPPROTO_TCP)
-   goto deliver_now;
+
+   KASSERT(iph-ip6_nxt == IPPROTO_TCP,
+   (IPv6 next header is not TCP, but packet marker is set));
l2_id |= SFXGE_LRO_L2_ID_IPV6;
th = (struct tcphdr *)(iph + 1);
} else {
@@ -841,7 +844,9 @@ sfxge_rx_qcomplete(struct sfxge_rxq *rxq
 
/* Pass packet up the stack or into LRO (pipelined) */
if (prev != NULL) {
-   if (lro_enabled)
+   if (lro_enabled 
+   ((prev-flags  (EFX_PKT_TCP | EFX_CKSUM_TCPUDP)) ==
+(EFX_PKT_TCP | EFX_CKSUM_TCPUDP)))
sfxge_lro(rxq, prev);
else
sfxge_rx_deliver(sc, prev);
@@ -860,7 +865,9 @@ discard:
 
/* Pass last packet up the stack or into LRO */
if (prev != NULL) {
-   if (lro_enabled)
+   if (lro_enabled 
+   ((prev-flags  (EFX_PKT_TCP | EFX_CKSUM_TCPUDP)) ==
+(EFX_PKT_TCP | EFX_CKSUM_TCPUDP)))
sfxge_lro(rxq, prev);
else
sfxge_rx_deliver(sc, prev);
___
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: r282941 - head/sys/dev/sfxge

2015-05-15 Thread Andrew Rybchenko
Author: arybchik
Date: Fri May 15 06:49:43 2015
New Revision: 282941
URL: https://svnweb.freebsd.org/changeset/base/282941

Log:
  sfxge: do not change CSUM_TSO when IFCAP_TSOx is changed
  
  It is simply not required since the kernel checks corresponding
  IFCAP_TSOx capability and CSUM_TSO in hw-assisted offloads.
  Note that CSUM_TSO is two bits (CSUM_IP_TSO|CSUM_IP6_TSO) and both bits
  are set in IPv4 and IPv6 mbufs.
  
  Reviewed by:gnn
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:  2 days
  Differential Revision: https://reviews.freebsd.org/D2546

Modified:
  head/sys/dev/sfxge/sfxge.c

Modified: head/sys/dev/sfxge/sfxge.c
==
--- head/sys/dev/sfxge/sfxge.c  Fri May 15 06:48:36 2015(r282940)
+++ head/sys/dev/sfxge/sfxge.c  Fri May 15 06:49:43 2015(r282941)
@@ -282,10 +282,14 @@ sfxge_if_ioctl(struct ifnet *ifp, unsign
ifp-if_hwassist |= (CSUM_TCP_IPV6 | CSUM_UDP_IPV6);
else
ifp-if_hwassist = ~(CSUM_TCP_IPV6 | CSUM_UDP_IPV6);
-   if (ifp-if_capenable  IFCAP_TSO)
-   ifp-if_hwassist |= CSUM_TSO;
-   else
-   ifp-if_hwassist = ~CSUM_TSO;
+
+   /*
+* The kernel takes both IFCAP_TSOx and CSUM_TSO into
+* account before using TSO. So, we do not touch
+* checksum flags when IFCAP_TSOx is modified.
+* Note that CSUM_TSO is (CSUM_IP_TSO|CSUM_IP6_TSO),
+* but both bits are set in IPv4 and IPv6 mbufs.
+*/
 
SFXGE_ADAPTER_UNLOCK(sc);
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: r282947 - in head/sys: amd64/amd64 kern

2015-05-15 Thread Konstantin Belousov
Author: kib
Date: Fri May 15 08:30:29 2015
New Revision: 282947
URL: https://svnweb.freebsd.org/changeset/base/282947

Log:
  On amd64, make proc0 pmap initialization slightly more correct.  In
  particular, switch to the proc0 pmap to have expected %cr3 and PCID
  for the thread0 during initialization, and the up to date pm_active
  mask.
  
  pmap_pinit0() should be done after proc0-p_vmspace is assigned so
  that the amd64 pmap_activate() find the correct curproc pmap.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:3 weeks

Modified:
  head/sys/amd64/amd64/pmap.c
  head/sys/kern/init_main.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Fri May 15 08:29:24 2015(r282946)
+++ head/sys/amd64/amd64/pmap.c Fri May 15 08:30:29 2015(r282947)
@@ -2129,7 +2129,6 @@ pmap_pinit0(pmap_t pmap)
pmap-pm_cr3 = KPML4phys;
pmap-pm_root.rt_root = 0;
CPU_ZERO(pmap-pm_active);
-   PCPU_SET(curpmap, pmap);
TAILQ_INIT(pmap-pm_pvchunk);
bzero(pmap-pm_stats, sizeof pmap-pm_stats);
pmap-pm_flags = pmap_flags;
@@ -2137,6 +2136,9 @@ pmap_pinit0(pmap_t pmap)
pmap-pm_pcids[i].pm_pcid = PMAP_PCID_NONE;
pmap-pm_pcids[i].pm_gen = 0;
}
+   PCPU_SET(curpmap, kernel_pmap);
+   pmap_activate(curthread);
+   CPU_FILL(kernel_pmap-pm_active);
 }
 
 /*

Modified: head/sys/kern/init_main.c
==
--- head/sys/kern/init_main.c   Fri May 15 08:29:24 2015(r282946)
+++ head/sys/kern/init_main.c   Fri May 15 08:30:29 2015(r282947)
@@ -561,9 +561,9 @@ proc0_init(void *dummy __unused)
p-p_stats = pstats_alloc();
 
/* Allocate a prototype map so we have something to fork. */
-   pmap_pinit0(vmspace_pmap(vmspace0));
p-p_vmspace = vmspace0;
vmspace0.vm_refcnt = 1;
+   pmap_pinit0(vmspace_pmap(vmspace0));
 
/*
 * proc0 is not expected to enter usermode, so there is no special
___
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: r282907 - head/sys/sys

2015-05-15 Thread Tijl Coosemans
On Thu, 14 May 2015 15:49:49 + (UTC) Pedro F. Giffuni p...@freebsd.org 
wrote:
 Author: pfg
 Date: Thu May 14 15:49:48 2015
 New Revision: 282907
 URL: https://svnweb.freebsd.org/changeset/base/282907
 
 Log:
   Add new __unreachable() builtin
   
   This is one of the few post gcc4.2 builtins that has been implemented by
   clang:
   
   __builtin_unreachable is used to indicate that a specific point in the
   program cannot be reached, even if the compiler might otherwise think it
   can. This is useful to improve optimization and eliminates certain
   warnings.
   
   Hinted by:  NetBSD
   Differential Revision:  https://reviews.freebsd.org/D2536
 
 Modified:
   head/sys/sys/cdefs.h
 
 Modified: head/sys/sys/cdefs.h
 ==
 --- head/sys/sys/cdefs.h  Thu May 14 15:14:03 2015(r282906)
 +++ head/sys/sys/cdefs.h  Thu May 14 15:49:48 2015(r282907)
 @@ -388,6 +388,12 @@
  #define  __alloc_size(x)
  #endif
  
 +#if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ__(4, 6)
 +#define  __unreachable() __builtin_unreachable()
 +#else
 +#define  __unreachable() do {} while (/*CONSTCOND*/0)

__builtin_unreachable() can be used in expressions so I think it's better
to replace do-while with ((void)0).  You can then do things like this:

#define assume(e)  ((e) ? (void)0 : __unreachable())
(like assert(e) but without error)
___
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: r282965 - in head: sbin/ifconfig sys/net sys/netinet sys/netinet6

2015-05-15 Thread Andrey V. Elsukov
Author: ae
Date: Fri May 15 12:19:45 2015
New Revision: 282965
URL: https://svnweb.freebsd.org/changeset/base/282965

Log:
  Add an ability accept encapsulated packets from different sources by one
  gif(4) interface. Add new option ignore_source for gif(4) interface.
  When it is enabled, gif's encapcheck function requires match only for
  packet's destination address.
  
  Differential Revision:https://reviews.freebsd.org/D2004
  Obtained from:Yandex LLC
  MFC after:2 weeks
  Sponsored by: Yandex LLC

Modified:
  head/sbin/ifconfig/ifconfig.8
  head/sbin/ifconfig/ifgif.c
  head/sys/net/if_gif.h
  head/sys/netinet/in_gif.c
  head/sys/netinet6/in6_gif.c

Modified: head/sbin/ifconfig/ifconfig.8
==
--- head/sbin/ifconfig/ifconfig.8   Fri May 15 12:07:43 2015
(r282964)
+++ head/sbin/ifconfig/ifconfig.8   Fri May 15 12:19:45 2015
(r282965)
@@ -28,7 +28,7 @@
 .\ From: @(#)ifconfig.8   8.3 (Berkeley) 1/5/94
 .\ $FreeBSD$
 .\
-.Dd May 12, 2015
+.Dd May 15, 2015
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -2428,6 +2428,14 @@ This is for backward compatibility with
 .It Cm -accept_rev_ethip_ver
 Clear a flag
 .Cm accept_rev_ethip_ver .
+.It Cm ignore_source
+Set a flag to accept encapsulated packets destined to this host
+independently from source address.
+This may be useful for hosts, that receive encapsulated packets
+from the load balancers.
+.It Cm -ignore_source
+Clear a flag
+.Cm ignore_source .
 .It Cm send_rev_ethip_ver
 Set a flag to send EtherIP packets with reversed version
 field intentionally.

Modified: head/sbin/ifconfig/ifgif.c
==
--- head/sbin/ifconfig/ifgif.c  Fri May 15 12:07:43 2015(r282964)
+++ head/sbin/ifconfig/ifgif.c  Fri May 15 12:19:45 2015(r282965)
@@ -51,7 +51,7 @@ static const char rcsid[] =
 
 #include ifconfig.h
 
-#defineGIFBITS \020\1ACCEPT_REV_ETHIP_VER\5SEND_REV_ETHIP_VER
+#defineGIFBITS 
\020\1ACCEPT_REV_ETHIP_VER\2IGNORE_SOURCE\5SEND_REV_ETHIP_VER
 
 static voidgif_status(int);
 
@@ -95,6 +95,8 @@ setgifopts(const char *val,
 static struct cmd gif_cmds[] = {
DEF_CMD(accept_rev_ethip_ver, GIF_ACCEPT_REVETHIP,setgifopts),
DEF_CMD(-accept_rev_ethip_ver,-GIF_ACCEPT_REVETHIP,   setgifopts),
+   DEF_CMD(ignore_source,GIF_IGNORE_SOURCE,  setgifopts),
+   DEF_CMD(-ignore_source,   -GIF_IGNORE_SOURCE, setgifopts),
DEF_CMD(send_rev_ethip_ver,   GIF_SEND_REVETHIP,  setgifopts),
DEF_CMD(-send_rev_ethip_ver,  -GIF_SEND_REVETHIP, setgifopts),
 };

Modified: head/sys/net/if_gif.h
==
--- head/sys/net/if_gif.h   Fri May 15 12:07:43 2015(r282964)
+++ head/sys/net/if_gif.h   Fri May 15 12:19:45 2015(r282965)
@@ -127,7 +127,9 @@ int in6_gif_attach(struct gif_softc *);
 #define GIFSOPTS   _IOW('i', 151, struct ifreq)
 
 #defineGIF_ACCEPT_REVETHIP 0x0001
+#defineGIF_IGNORE_SOURCE   0x0002
 #defineGIF_SEND_REVETHIP   0x0010
-#defineGIF_OPTMASK (GIF_ACCEPT_REVETHIP|GIF_SEND_REVETHIP)
+#defineGIF_OPTMASK (GIF_ACCEPT_REVETHIP|GIF_SEND_REVETHIP| 
\
+GIF_IGNORE_SOURCE)
 
 #endif /* _NET_IF_GIF_H_ */

Modified: head/sys/netinet/in_gif.c
==
--- head/sys/netinet/in_gif.c   Fri May 15 12:07:43 2015(r282964)
+++ head/sys/netinet/in_gif.c   Fri May 15 12:19:45 2015(r282965)
@@ -168,13 +168,19 @@ in_gif_input(struct mbuf **mp, int *offp
 static int
 gif_validate4(const struct ip *ip, struct gif_softc *sc, struct ifnet *ifp)
 {
+   int ret;
 
GIF_RLOCK_ASSERT(sc);
 
/* check for address match */
-   if (sc-gif_iphdr-ip_src.s_addr != ip-ip_dst.s_addr ||
-   sc-gif_iphdr-ip_dst.s_addr != ip-ip_src.s_addr)
+   if (sc-gif_iphdr-ip_src.s_addr != ip-ip_dst.s_addr)
return (0);
+   ret = 32;
+   if (sc-gif_iphdr-ip_dst.s_addr != ip-ip_src.s_addr) {
+   if ((sc-gif_options  GIF_IGNORE_SOURCE) == 0)
+   return (0);
+   } else
+   ret += 32;
 
/* martian filters on outer source - NOT done in ip_input! */
if (IN_MULTICAST(ntohl(ip-ip_src.s_addr)))
@@ -205,7 +211,7 @@ gif_validate4(const struct ip *ip, struc
}
RTFREE_LOCKED(rt);
}
-   return (32 * 2);
+   return (ret);
 }
 
 /*

Modified: head/sys/netinet6/in6_gif.c
==
--- head/sys/netinet6/in6_gif.c Fri May 15 12:07:43 2015(r282964)
+++ head/sys/netinet6/in6_gif.c Fri May 15 12:19:45 2015(r282965)
@@ -180,6 +180,7 @@ static int
 gif_validate6(const 

svn commit: r282967 - head/sbin/ifconfig

2015-05-15 Thread Alexander V. Chernikov
Author: melifaro
Date: Fri May 15 12:32:17 2015
New Revision: 282967
URL: https://svnweb.freebsd.org/changeset/base/282967

Log:
  Simplify i2c reader: we don't need per-NIC handler anymore.
  Make code use read_i2c() function instead of callback.
  Simplifydocument struct i2c_info.
  Consistently use uint8_t to read from i2c.

Modified:
  head/sbin/ifconfig/sfp.c

Modified: head/sbin/ifconfig/sfp.c
==
--- head/sbin/ifconfig/sfp.cFri May 15 12:28:17 2015(r282966)
+++ head/sbin/ifconfig/sfp.cFri May 15 12:32:17 2015(r282967)
@@ -48,25 +48,16 @@ static const char rcsid[] =
 
 #include ifconfig.h
 
-struct i2c_info;
-typedef int (read_i2c)(struct i2c_info *ii, uint8_t addr, uint8_t off,
-uint8_t len, caddr_t buf);
-
 struct i2c_info {
-   int s;
-   int error;
-   int bshift;
-   int qsfp;
-   int do_diag;
-   struct ifreq *ifr;
-   read_i2c *f;
-   char *textbuf;
-   size_t bufsize;
-   int cfd;
-   int port_id;
-   int chip_id;
+   int fd; /* fd to issue SIOCGI2C */
+   int error;  /* Store first error */
+   int qsfp;   /* True if transceiver is QSFP */
+   int do_diag;/* True if we need to request DDM */
+   struct ifreq *ifr;  /* Pointer to pre-filled ifreq */
 };
 
+static int read_i2c(struct i2c_info *ii, uint8_t addr, uint8_t off,
+uint8_t len, uint8_t *buf);
 static void dump_i2c_data(struct i2c_info *ii, uint8_t addr, uint8_t off,
 uint8_t len);
 
@@ -259,7 +250,7 @@ get_sfp_identifier(struct i2c_info *ii, 
 {
uint8_t data;
 
-   ii-f(ii, SFF_8472_BASE, SFF_8472_ID, 1, (caddr_t)data);
+   read_i2c(ii, SFF_8472_BASE, SFF_8472_ID, 1, data);
convert_sff_identifier(buf, size, data);
 }
 
@@ -268,7 +259,7 @@ get_sfp_connector(struct i2c_info *ii, c
 {
uint8_t data;
 
-   ii-f(ii, SFF_8472_BASE, SFF_8472_CONNECTOR, 1, (caddr_t)data);
+   read_i2c(ii, SFF_8472_BASE, SFF_8472_CONNECTOR, 1, data);
convert_sff_connector(buf, size, data);
 }
 
@@ -277,7 +268,7 @@ get_qsfp_identifier(struct i2c_info *ii,
 {
uint8_t data;
 
-   ii-f(ii, SFF_8436_BASE, SFF_8436_ID, 1, (caddr_t)data);
+   read_i2c(ii, SFF_8436_BASE, SFF_8436_ID, 1, data);
convert_sff_identifier(buf, size, data);
 }
 
@@ -286,7 +277,7 @@ get_qsfp_connector(struct i2c_info *ii, 
 {
uint8_t data;
 
-   ii-f(ii, SFF_8436_BASE, SFF_8436_CONNECTOR, 1, (caddr_t)data);
+   read_i2c(ii, SFF_8436_BASE, SFF_8436_CONNECTOR, 1, data);
convert_sff_connector(buf, size, data);
 }
 
@@ -303,7 +294,7 @@ printf_sfp_transceiver_descr(struct i2c_
tech_speed = NULL;
 
/* Read bytes 3-10 at once */
-   ii-f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, xbuf[3]);
+   read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, xbuf[3]);
 
/* Check 10G ethernet first */
tech_class = find_zero_bit(eth_10g, xbuf[3], 1);
@@ -331,14 +322,14 @@ get_sfp_transceiver_class(struct i2c_inf
uint8_t code;
 
unsigned char qbuf[8];
-   ii-f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, (caddr_t)qbuf);
+   read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, (uint8_t *)qbuf);
 
/* Check 10G Ethernet/IB first */
-   ii-f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 1, (caddr_t)code);
+   read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 1, code);
tech_class = find_zero_bit(eth_10g, code, 1);
if (tech_class == NULL) {
/* No match. Try Ethernet 1G */
-   ii-f(ii, SFF_8472_BASE, SFF_8472_TRANS_START + 3,
+   read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START + 3,
1, (caddr_t)code);
tech_class = find_zero_bit(eth_compat, code, 1);
}
@@ -356,7 +347,7 @@ get_qsfp_transceiver_class(struct i2c_in
uint8_t code;
 
/* Check 10/40G Ethernet class only */
-   ii-f(ii, SFF_8436_BASE, SFF_8436_CODE_E1040G, 1, (caddr_t)code);
+   read_i2c(ii, SFF_8436_BASE, SFF_8436_CODE_E1040G, 1, code);
tech_class = find_zero_bit(eth_1040g, code, 1);
if (tech_class == NULL)
tech_class = Unknown;
@@ -393,7 +384,7 @@ get_sfp_vendor_name(struct i2c_info *ii,
char xbuf[17];
 
memset(xbuf, 0, sizeof(xbuf));
-   ii-f(ii, SFF_8472_BASE, SFF_8472_VENDOR_START, 16, xbuf);
+   read_i2c(ii, SFF_8472_BASE, SFF_8472_VENDOR_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
 }
 
@@ -403,7 +394,7 @@ get_sfp_vendor_pn(struct i2c_info *ii, c
char xbuf[17];
 
memset(xbuf, 0, sizeof(xbuf));
-   ii-f(ii, SFF_8472_BASE, SFF_8472_PN_START, 16, xbuf);
+   read_i2c(ii, SFF_8472_BASE, SFF_8472_PN_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
 }
 
@@ -413,7 +404,7 @@ get_sfp_vendor_sn(struct i2c_info *ii, c
   

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

2015-05-15 Thread Jason A. Harmening
Author: jah
Date: Fri May 15 12:28:17 2015
New Revision: 282966
URL: https://svnweb.freebsd.org/changeset/base/282966

Log:
  Update iic(4) man page to reflect recent changes
  
  Differential Revision:https://reviews.freebsd.org/D2461
  Reviewed by:  wblock
  Approved by:  kib (mentor)

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

Modified: head/share/man/man4/iic.4
==
--- head/share/man/man4/iic.4   Fri May 15 12:19:45 2015(r282965)
+++ head/share/man/man4/iic.4   Fri May 15 12:28:17 2015(r282966)
@@ -54,10 +54,12 @@ element to the bus.
 The
 .Va slave
 element consists of a 7-bit address and a read/write bit
-(i.e., 7-bit address  1 | r/w).
-If the read/write bit is set a read operation is initiated, if the read/write
-bit is cleared a write operation is initiated.
+(that is, a 7-bit address  1 | r/w).
+A read operation is initiated when the read/write bit is set, or a write
+operation when it is cleared.
 All other elements are ignored.
+If successful, the file descriptor receives exclusive
+ownership of the underlying iicbus instance.
 .It Dv I2CRPTSTART
 .Pq Vt struct iiccmd
 Sends the repeated start condition to the slave specified by the
@@ -66,19 +68,33 @@ element to the bus.
 The slave address should be specified as in
 .Dv I2CSTART .
 All other elements are ignored.
+.Dv I2CSTART
+must have previously been issued on the same file descriptor.
 .It Dv I2CSTOP
 No argument is passed.
 Sends the stop condition to the bus.
-This terminates the current transaction.
+If
+.Dv I2CSTART
+was previously issued on the file descriptor, the current transaction is
+terminated and exclusive ownership of the underlying iicbus instance is
+released.
+Otherwise, no action is performed.
 .It Dv I2CRSTCARD
 .Pq Vt struct iiccmd
 Resets the bus.
 The argument is completely ignored.
+This command does not require
+.Dv I2CSTART
+to have been previously issued on the file descriptor.
+If it was previously issued, exclusive ownership of the underlying iicbus
+instance is released.
 .It Dv I2CWRITE
 .Pq Vt struct iiccmd
 Writes data to the
 .Xr iicbus 4 .
-The bus should already be started.
+The bus must already be started by a previous
+.Dv I2CSTART
+on the file descriptor.
 The
 .Va slave
 element is ignored.
@@ -96,7 +112,9 @@ element is a pointer to the data to writ
 .Pq Vt struct iiccmd
 Reads data from the
 .Xr iicbus 4 .
-The bus should already be started.
+The bus must already be started by a previous
+.Dv I2CSTART
+on the file descriptor.
 The
 .Va slave
 element is ignored.
@@ -116,6 +134,15 @@ Short reads on the bus produce undefined
 Generic read/write interface.
 Allows for an arbitrary number of commands to be sent to
 an arbitrary number of devices on the bus.
+Any previous transaction started by
+.Dv I2CSTART
+must be terminated by
+.Dv I2CSTOP
+or
+.Dv I2CRSTCARD
+before
+.Dv I2CRDWR
+can be issued on the same file descriptor.
 A read transfer is specified if
 .Dv IIC_M_RD
 is set in
@@ -138,6 +165,17 @@ element is a buffer for that data.
 This ioctl is intended to be
 .Tn Linux
 compatible.
+.It Dv I2CSADDR
+.Pq Vt uint8_t
+Associate the specified address with the file descriptor for use by
+subsequent
+.Xr read 2
+or
+.Xr write 2
+calls.
+The argument is an 8-bit address (that is, a 7-bit address  1).
+The read/write bit in the least-significant position is ignored.
+Any subsequent read or write operation will set or clear that bit as needed.
 .El
 .Pp
 The following data structures are defined in
@@ -156,7 +194,10 @@ struct iic_msg
 {
uint16_tslave;
uint16_tflags;
-#define IIC_M_RD   0x0001  /* read vs write */
+#defineIIC_M_WR0   /* Fake flag for write */
+#defineIIC_M_RD0x0001  /* read vs write */
+#defineIIC_M_NOSTOP0x0002  /* do not send a I2C stop after message 
*/
+#defineIIC_M_NOSTART   0x0004  /* do not send a I2C start before 
message */
uint16_tlen;/* msg length */
uint8_t *   buf;
 };
@@ -167,15 +208,37 @@ struct iic_rdwr_data {
 };
 .Ed
 .Pp
-It is also possible to use read/write routines, then I2C start/stop handshake 
is
-managed by the
-.Xr iicbus 4
-system.
-However, the address used for the read/write routines is the one
-passed to last
+It is also possible to use
+.Xr read 2
+or
+.Xr write 2 ,
+in which case the I2C start/stop handshake is managed by
+.Xr iicbus 4 .
+The address used for the read/write operation is the one passed to the most
+recent
 .Dv I2CSTART
 .Xr ioctl 2
-to this device.
+or
+.Dv I2CSADDR
+.Xr ioctl 2
+on the open
+.Pa /dev/iic?
+file descriptor.
+Closing the file descriptor clears any addressing state established by a
+previous
+.Dv I2CSTART
+or
+.Dv I2CSADDR ,
+stops any transaction established by a not-yet-terminated
+.Dv I2CSTART ,
+and releases iicbus ownership.
+Because addressing state is stored on a per-file-descriptor basis, it is

svn commit: r282971 - in head/sys: kern sys

2015-05-15 Thread John Baldwin
Author: jhb
Date: Fri May 15 13:50:37 2015
New Revision: 282971
URL: https://svnweb.freebsd.org/changeset/base/282971

Log:
  Previously, cv_waiters was only updated by cv_signal or cv_wait. If a
  thread awakened due to a time out, then cv_waiters was not decremented.
  If INT_MAX threads timed out on a cv without an intervening cv_broadcast,
  then cv_waiters could overflow. To fix this, have each sleeping thread
  decrement cv_waiters when it resumes.
  
  Note that previously cv_waiters was protected by the sleepq chain lock.
  However, that lock is not held when threads resume from sleep. In
  addition, the interlock is also not always reacquired after resuming
  (cv_wait_unlock), nor is it always held by callers of cv_signal() or
  cv_broadcast(). Instead, use atomic ops to update cv_waiters. Since
  the sleepq chain lock is still held on every increment, it should
  still be safe to compare cv_waiters against zero while holding the
  lock in the wakeup routines as the only way the race should be lost
  would result in extra calls to sleepq_signal() or sleepq_broadcast().
  
  Differential Revision:https://reviews.freebsd.org/D2427
  Reviewed by:  benno
  Reported by:  benno (wrap of cv_waiters in the field)
  MFC after:2 weeks

Modified:
  head/sys/kern/kern_condvar.c
  head/sys/sys/condvar.h

Modified: head/sys/kern/kern_condvar.c
==
--- head/sys/kern/kern_condvar.cFri May 15 13:36:50 2015
(r282970)
+++ head/sys/kern/kern_condvar.cFri May 15 13:50:37 2015
(r282971)
@@ -122,7 +122,7 @@ _cv_wait(struct cv *cvp, struct lock_obj
 
sleepq_lock(cvp);
 
-   cvp-cv_waiters++;
+   atomic_add_int(cvp-cv_waiters, 1);
if (lock == Giant.lock_object)
mtx_assert(Giant, MA_OWNED);
DROP_GIANT();
@@ -137,6 +137,7 @@ _cv_wait(struct cv *cvp, struct lock_obj
sleepq_lock(cvp);
}
sleepq_wait(cvp, 0);
+   atomic_subtract_int(cvp-cv_waiters, 1);
 
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
@@ -184,7 +185,7 @@ _cv_wait_unlock(struct cv *cvp, struct l
 
sleepq_lock(cvp);
 
-   cvp-cv_waiters++;
+   atomic_add_int(cvp-cv_waiters, 1);
DROP_GIANT();
 
sleepq_add(cvp, lock, cvp-cv_description, SLEEPQ_CONDVAR, 0);
@@ -194,6 +195,7 @@ _cv_wait_unlock(struct cv *cvp, struct l
if (class-lc_flags  LC_SLEEPABLE)
sleepq_lock(cvp);
sleepq_wait(cvp, 0);
+   atomic_subtract_int(cvp-cv_waiters, 1);
 
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
@@ -240,7 +242,7 @@ _cv_wait_sig(struct cv *cvp, struct lock
 
sleepq_lock(cvp);
 
-   cvp-cv_waiters++;
+   atomic_add_int(cvp-cv_waiters, 1);
if (lock == Giant.lock_object)
mtx_assert(Giant, MA_OWNED);
DROP_GIANT();
@@ -256,6 +258,7 @@ _cv_wait_sig(struct cv *cvp, struct lock
sleepq_lock(cvp);
}
rval = sleepq_wait_sig(cvp, 0);
+   atomic_subtract_int(cvp-cv_waiters, 1);
 
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
@@ -307,7 +310,7 @@ _cv_timedwait_sbt(struct cv *cvp, struct
 
sleepq_lock(cvp);
 
-   cvp-cv_waiters++;
+   atomic_add_int(cvp-cv_waiters, 1);
if (lock == Giant.lock_object)
mtx_assert(Giant, MA_OWNED);
DROP_GIANT();
@@ -323,6 +326,7 @@ _cv_timedwait_sbt(struct cv *cvp, struct
sleepq_lock(cvp);
}
rval = sleepq_timedwait(cvp, 0);
+   atomic_subtract_int(cvp-cv_waiters, 1);
 
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
@@ -376,7 +380,7 @@ _cv_timedwait_sig_sbt(struct cv *cvp, st
 
sleepq_lock(cvp);
 
-   cvp-cv_waiters++;
+   atomic_add_int(cvp-cv_waiters, 1);
if (lock == Giant.lock_object)
mtx_assert(Giant, MA_OWNED);
DROP_GIANT();
@@ -393,6 +397,7 @@ _cv_timedwait_sig_sbt(struct cv *cvp, st
sleepq_lock(cvp);
}
rval = sleepq_timedwait_sig(cvp, 0);
+   atomic_subtract_int(cvp-cv_waiters, 1);
 
 #ifdef KTRACE
if (KTRPOINT(td, KTR_CSW))
@@ -421,10 +426,8 @@ cv_signal(struct cv *cvp)
 
wakeup_swapper = 0;
sleepq_lock(cvp);
-   if (cvp-cv_waiters  0) {
-   cvp-cv_waiters--;
+   if (cvp-cv_waiters  0)
wakeup_swapper = sleepq_signal(cvp, SLEEPQ_CONDVAR, 0, 0);
-   }
sleepq_release(cvp);
if (wakeup_swapper)
kick_proc0();
@@ -447,10 +450,8 @@ cv_broadcastpri(struct cv *cvp, int pri)
if (pri == -1)
pri = 0;
sleepq_lock(cvp);
-   if (cvp-cv_waiters  0) {
-   cvp-cv_waiters = 0;
+   if (cvp-cv_waiters  0)
wakeup_swapper = sleepq_broadcast(cvp, SLEEPQ_CONDVAR, pri, 0);
-   }
sleepq_release(cvp);
if (wakeup_swapper)
kick_proc0();


svn commit: r282970 - head/sys/dev/iscsi

2015-05-15 Thread Alexander Motin
Author: mav
Date: Fri May 15 13:36:50 2015
New Revision: 282970
URL: https://svnweb.freebsd.org/changeset/base/282970

Log:
  Close some potential races around socket start/close.
  
  There are some reports about panics on ic-ic_socket NULL derefence.
  This kind of races is the only way I can imagine it to happen.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/iscsi/icl_soft.c

Modified: head/sys/dev/iscsi/icl_soft.c
==
--- head/sys/dev/iscsi/icl_soft.c   Fri May 15 13:04:14 2015
(r282969)
+++ head/sys/dev/iscsi/icl_soft.c   Fri May 15 13:36:50 2015
(r282970)
@@ -773,10 +773,6 @@ icl_receive_thread(void *arg)
ic = arg;
so = ic-ic_socket;
 
-   ICL_CONN_LOCK(ic);
-   ic-ic_receive_running = true;
-   ICL_CONN_UNLOCK(ic);
-
for (;;) {
if (ic-ic_disconnecting) {
//ICL_DEBUG(terminating);
@@ -998,8 +994,6 @@ icl_send_thread(void *arg)
STAILQ_INIT(queue);
 
ICL_CONN_LOCK(ic);
-   ic-ic_send_running = true;
-
for (;;) {
for (;;) {
/*
@@ -1275,35 +1269,45 @@ icl_conn_start(struct icl_conn *ic)
}
 
/*
+* Register socket upcall, to get notified about incoming PDUs
+* and free space to send outgoing ones.
+*/
+   SOCKBUF_LOCK(ic-ic_socket-so_snd);
+   soupcall_set(ic-ic_socket, SO_SND, icl_soupcall_send, ic);
+   SOCKBUF_UNLOCK(ic-ic_socket-so_snd);
+   SOCKBUF_LOCK(ic-ic_socket-so_rcv);
+   soupcall_set(ic-ic_socket, SO_RCV, icl_soupcall_receive, ic);
+   SOCKBUF_UNLOCK(ic-ic_socket-so_rcv);
+
+   /*
 * Start threads.
 */
+   ICL_CONN_LOCK(ic);
+   ic-ic_send_running = ic-ic_receive_running = true;
+   ICL_CONN_UNLOCK(ic);
error = kthread_add(icl_send_thread, ic, NULL, NULL, 0, 0, %stx,
ic-ic_name);
if (error != 0) {
ICL_WARN(kthread_add(9) failed with error %d, error);
+   ICL_CONN_LOCK(ic);
+   ic-ic_send_running = ic-ic_receive_running = false;
+   cv_signal(ic-ic_send_cv);
+   ICL_CONN_UNLOCK(ic);
icl_soft_conn_close(ic);
return (error);
}
-
error = kthread_add(icl_receive_thread, ic, NULL, NULL, 0, 0, %srx,
ic-ic_name);
if (error != 0) {
ICL_WARN(kthread_add(9) failed with error %d, error);
+   ICL_CONN_LOCK(ic);
+   ic-ic_receive_running = false;
+   cv_signal(ic-ic_send_cv);
+   ICL_CONN_UNLOCK(ic);
icl_soft_conn_close(ic);
return (error);
}
 
-   /*
-* Register socket upcall, to get notified about incoming PDUs
-* and free space to send outgoing ones.
-*/
-   SOCKBUF_LOCK(ic-ic_socket-so_snd);
-   soupcall_set(ic-ic_socket, SO_SND, icl_soupcall_send, ic);
-   SOCKBUF_UNLOCK(ic-ic_socket-so_snd);
-   SOCKBUF_LOCK(ic-ic_socket-so_rcv);
-   soupcall_set(ic-ic_socket, SO_RCV, icl_soupcall_receive, ic);
-   SOCKBUF_UNLOCK(ic-ic_socket-so_rcv);
-
return (0);
 }
 
@@ -1357,46 +1361,42 @@ void
 icl_soft_conn_close(struct icl_conn *ic)
 {
struct icl_pdu *pdu;
+   struct socket *so;
 
-   ICL_CONN_LOCK_ASSERT_NOT(ic);
-
-   ICL_CONN_LOCK(ic);
-   if (ic-ic_socket == NULL) {
-   ICL_CONN_UNLOCK(ic);
-   return;
-   }
-
-   /*
-* Deregister socket upcalls.
-*/
-   ICL_CONN_UNLOCK(ic);
-   SOCKBUF_LOCK(ic-ic_socket-so_snd);
-   if (ic-ic_socket-so_snd.sb_upcall != NULL)
-   soupcall_clear(ic-ic_socket, SO_SND);
-   SOCKBUF_UNLOCK(ic-ic_socket-so_snd);
-   SOCKBUF_LOCK(ic-ic_socket-so_rcv);
-   if (ic-ic_socket-so_rcv.sb_upcall != NULL)
-   soupcall_clear(ic-ic_socket, SO_RCV);
-   SOCKBUF_UNLOCK(ic-ic_socket-so_rcv);
ICL_CONN_LOCK(ic);
 
-   ic-ic_disconnecting = true;
-
/*
 * Wake up the threads, so they can properly terminate.
 */
+   ic-ic_disconnecting = true;
while (ic-ic_receive_running || ic-ic_send_running) {
-   //ICL_DEBUG(waiting for send/receive threads to terminate);
cv_signal(ic-ic_receive_cv);
cv_signal(ic-ic_send_cv);
cv_wait(ic-ic_send_cv, ic-ic_lock);
}
-   //ICL_DEBUG(send/receive threads terminated);
 
+   /* Some other thread could close the connection same time. */
+   so = ic-ic_socket;
+   if (so == NULL) {
+   ICL_CONN_UNLOCK(ic);
+   return;
+   }
+   ic-ic_socket = NULL;
+
+   /*
+* Deregister socket upcalls.
+*/
ICL_CONN_UNLOCK(ic);
-   soclose(ic-ic_socket);
+   SOCKBUF_LOCK(so-so_snd);
+   if 

svn commit: r282972 - in head/sys: dev/fdt dev/gpio dev/ofw mips/beri powerpc/ofw powerpc/pseries

2015-05-15 Thread Ruslan Bukin
Author: br
Date: Fri May 15 13:55:18 2015
New Revision: 282972
URL: https://svnweb.freebsd.org/changeset/base/282972

Log:
  Provide the number of interrupt resources added to the list
  by using extra argument, so caller will know that.

Modified:
  head/sys/dev/fdt/simplebus.c
  head/sys/dev/gpio/ofw_gpiobus.c
  head/sys/dev/ofw/ofw_bus_subr.c
  head/sys/dev/ofw/ofw_bus_subr.h
  head/sys/dev/ofw/ofw_iicbus.c
  head/sys/mips/beri/beri_simplebus.c
  head/sys/powerpc/ofw/ofw_pcibus.c
  head/sys/powerpc/pseries/vdevice.c

Modified: head/sys/dev/fdt/simplebus.c
==
--- head/sys/dev/fdt/simplebus.cFri May 15 13:50:37 2015
(r282971)
+++ head/sys/dev/fdt/simplebus.cFri May 15 13:55:18 2015
(r282972)
@@ -251,7 +251,7 @@ simplebus_setup_dinfo(device_t dev, phan
 
resource_list_init(ndi-rl);
ofw_bus_reg_to_rl(dev, node, sc-acells, sc-scells, ndi-rl);
-   ofw_bus_intr_to_rl(dev, node, ndi-rl);
+   ofw_bus_intr_to_rl(dev, node, ndi-rl, NULL);
 
return (ndi);
 }

Modified: head/sys/dev/gpio/ofw_gpiobus.c
==
--- head/sys/dev/gpio/ofw_gpiobus.c Fri May 15 13:50:37 2015
(r282971)
+++ head/sys/dev/gpio/ofw_gpiobus.c Fri May 15 13:55:18 2015
(r282972)
@@ -147,7 +147,7 @@ ofw_gpiobus_setup_devinfo(device_t bus, 
}
free(pins, M_DEVBUF);
/* Parse the interrupt resources. */
-   if (ofw_bus_intr_to_rl(bus, node, dinfo-opd_dinfo.rl) != 0) {
+   if (ofw_bus_intr_to_rl(bus, node, dinfo-opd_dinfo.rl, NULL) != 0) {
ofw_gpiobus_destroy_devinfo(bus, dinfo);
return (NULL);
}

Modified: head/sys/dev/ofw/ofw_bus_subr.c
==
--- head/sys/dev/ofw/ofw_bus_subr.c Fri May 15 13:50:37 2015
(r282971)
+++ head/sys/dev/ofw/ofw_bus_subr.c Fri May 15 13:55:18 2015
(r282972)
@@ -430,7 +430,8 @@ ofw_bus_reg_to_rl(device_t dev, phandle_
 }
 
 int
-ofw_bus_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl)
+ofw_bus_intr_to_rl(device_t dev, phandle_t node,
+struct resource_list *rl, int *rlen)
 {
phandle_t iparent;
uint32_t icells, *intr;
@@ -495,6 +496,8 @@ ofw_bus_intr_to_rl(device_t dev, phandle
irqnum = ofw_bus_map_intr(dev, iparent, icells, intr[i]);
resource_list_add(rl, SYS_RES_IRQ, rid++, irqnum, irqnum, 1);
}
+   if (rlen != NULL)
+   *rlen = rid;
free(intr, M_OFWPROP);
return (err);
 }

Modified: head/sys/dev/ofw/ofw_bus_subr.h
==
--- head/sys/dev/ofw/ofw_bus_subr.h Fri May 15 13:50:37 2015
(r282971)
+++ head/sys/dev/ofw/ofw_bus_subr.h Fri May 15 13:55:18 2015
(r282972)
@@ -75,7 +75,7 @@ int   ofw_bus_search_intrmap(void *, int, 
 /* Routines for parsing device-tree data into resource lists. */
 int ofw_bus_reg_to_rl(device_t, phandle_t, pcell_t, pcell_t,
 struct resource_list *);
-int ofw_bus_intr_to_rl(device_t, phandle_t, struct resource_list *);
+int ofw_bus_intr_to_rl(device_t, phandle_t, struct resource_list *, int *);
 
 /* Helper to get device status property */
 const char *ofw_bus_get_status(device_t dev);

Modified: head/sys/dev/ofw/ofw_iicbus.c
==
--- head/sys/dev/ofw/ofw_iicbus.c   Fri May 15 13:50:37 2015
(r282971)
+++ head/sys/dev/ofw/ofw_iicbus.c   Fri May 15 13:55:18 2015
(r282972)
@@ -156,7 +156,8 @@ ofw_iicbus_attach(device_t dev)
 
childdev = device_add_child(dev, NULL, -1);
resource_list_init(dinfo-opd_dinfo.rl);
-   ofw_bus_intr_to_rl(childdev, child, dinfo-opd_dinfo.rl);
+   ofw_bus_intr_to_rl(childdev, child,
+   dinfo-opd_dinfo.rl, NULL);
device_set_ivars(childdev, dinfo);
}
 

Modified: head/sys/mips/beri/beri_simplebus.c
==
--- head/sys/mips/beri/beri_simplebus.c Fri May 15 13:50:37 2015
(r282971)
+++ head/sys/mips/beri/beri_simplebus.c Fri May 15 13:55:18 2015
(r282972)
@@ -198,7 +198,7 @@ simplebus_attach(device_t dev)
continue;
}
 
-   if (ofw_bus_intr_to_rl(dev, dt_child, di-di_res)) {
+   if (ofw_bus_intr_to_rl(dev, dt_child, di-di_res, NULL)) {
device_printf(dev, %s: could not process 
'interrupts' property\n, di-di_ofw.obd_name);
resource_list_free(di-di_res);

Modified: head/sys/powerpc/ofw/ofw_pcibus.c

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

2015-05-15 Thread Jason A. Harmening
Author: jah
Date: Fri May 15 13:04:14 2015
New Revision: 282969
URL: https://svnweb.freebsd.org/changeset/base/282969

Log:
  Bump date for iic.4

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

Modified: head/share/man/man4/iic.4
==
--- head/share/man/man4/iic.4   Fri May 15 12:35:18 2015(r282968)
+++ head/share/man/man4/iic.4   Fri May 15 13:04:14 2015(r282969)
@@ -25,7 +25,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd June 24, 2014
+.Dd May 15, 2015
 .Dt IIC 4
 .Os
 .Sh NAME
___
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: r282978 - head/sys/dev/netmap

2015-05-15 Thread Patrick Kelsey
Author: pkelsey
Date: Fri May 15 15:36:57 2015
New Revision: 282978
URL: https://svnweb.freebsd.org/changeset/base/282978

Log:
  When a netmap process terminates without the full set of buffers it
  was granted via rings and ni_bufs_list_head represented in those rings
  and lists (e.g., via SIGKILL), those buffers are no longer available
  for subsequent users for the lifetime of the system. To mitigate this
  resource leak, reset the allocator state when the last ref to that
  allocator is released.
  
  Note that this only recovers leaked resources for an allocator when
  there are no longer any users of that allocator, so there remain
  circumstances in which leaked allocator resources may not ever be
  recovered - consider a set of multiple netmap processes that are all
  using the same allocator (say, the global allocator) where members of
  that set may be killed and restarted over time but at any given point
  there is one member of that set running.
  
  Based on intial work by adrian@.
  
  Reviewed by: Giuseppe Lettieri (g.letti...@iet.unipi.it), luigi
  Approved by: jmallett (mentor)
  MFC after: 1 week
  Sponsored by: Norse Corp, Inc.

Modified:
  head/sys/dev/netmap/netmap_mem2.c

Modified: head/sys/dev/netmap/netmap_mem2.c
==
--- head/sys/dev/netmap/netmap_mem2.c   Fri May 15 15:13:51 2015
(r282977)
+++ head/sys/dev/netmap/netmap_mem2.c   Fri May 15 15:36:57 2015
(r282978)
@@ -130,9 +130,9 @@ struct netmap_mem_d {
/* the three allocators */
struct netmap_obj_pool pools[NETMAP_POOLS_NR];
 
-   netmap_mem_config_t   config;
-   netmap_mem_finalize_t finalize;
-   netmap_mem_deref_tderef;
+   netmap_mem_config_t   config;   /* called with NMA_LOCK held */
+   netmap_mem_finalize_t finalize; /* called with NMA_LOCK held */
+   netmap_mem_deref_tderef;/* called with NMA_LOCK held */
 
nm_memid_t nm_id;   /* allocator identifier */
int nm_grp; /* iommu groupd id */
@@ -751,6 +751,12 @@ netmap_reset_obj_allocator(struct netmap
u_int i;
size_t sz = p-_clustsize;
 
+   /*
+* Free each cluster allocated in
+* netmap_finalize_obj_allocator().  The cluster start
+* addresses are stored at multiples of p-_clusterentries
+* in the lut.
+*/
for (i = 0; i  p-objtotal; i += p-_clustentries) {
if (p-lut[i].vaddr)
contigfree(p-lut[i].vaddr, sz, M_NETMAP);
@@ -929,6 +935,7 @@ netmap_finalize_obj_allocator(struct net
if (i % p-_clustentries == 0  
p-lut[i].vaddr)
contigfree(p-lut[i].vaddr,
n, M_NETMAP);
+   p-lut[i].vaddr = NULL;
}
out:
p-objtotal = i;
@@ -936,6 +943,17 @@ netmap_finalize_obj_allocator(struct net
p-numclusters = (i + p-_clustentries - 1) / 
p-_clustentries;
break;
}
+   /*
+* Set bitmap and lut state for all buffers in the current
+* cluster.
+*
+* [i, lim) is the set of buffer indexes that cover the
+* current cluster.
+*
+* 'clust' is really the address of the current buffer in
+* the current cluster as we index through it with a stride
+* of p-_objsize.
+*/
for (; i  lim; i++, clust += p-_objsize) {
p-bitmap[ (i5) ] |=  ( 1  (i  31) );
p-lut[i].vaddr = clust;
@@ -1092,10 +1110,8 @@ static int
 netmap_mem_private_finalize(struct netmap_mem_d *nmd)
 {
int err;
-   NMA_LOCK(nmd);
nmd-refcount++;
err = netmap_mem_finalize_all(nmd);
-   NMA_UNLOCK(nmd);
return err;
 
 }
@@ -1103,10 +1119,8 @@ netmap_mem_private_finalize(struct netma
 static void
 netmap_mem_private_deref(struct netmap_mem_d *nmd)
 {
-   NMA_LOCK(nmd);
if (--nmd-refcount = 0)
netmap_mem_reset_all(nmd);
-   NMA_UNLOCK(nmd);
 }
 
 
@@ -1242,10 +1256,7 @@ static int
 netmap_mem_global_finalize(struct netmap_mem_d *nmd)
 {
int err;
-
-   NMA_LOCK(nmd);
-
-
+   
/* update configuration if changed */
if (netmap_mem_global_config(nmd))
goto out;
@@ -1268,8 +1279,6 @@ out:
nmd-refcount--;
err = nmd-lasterr;
 
-   NMA_UNLOCK(nmd);
-
return err;
 
 }
@@ -1518,7 +1527,6 @@ netmap_mem_if_delete(struct netmap_adapt
 static void
 netmap_mem_global_deref(struct netmap_mem_d *nmd)
 {
-   NMA_LOCK(nmd);
 

svn commit: r282980 - head/usr.bin/man

2015-05-15 Thread Baptiste Daroussin
Author: bapt
Date: Fri May 15 15:56:28 2015
New Revision: 282980
URL: https://svnweb.freebsd.org/changeset/base/282980

Log:
  Allow MANWIDTH to work with mandoc(1)
  
  Reported by:  bdrewery

Modified:
  head/usr.bin/man/man.sh

Modified: head/usr.bin/man/man.sh
==
--- head/usr.bin/man/man.sh Fri May 15 15:49:24 2015(r282979)
+++ head/usr.bin/man/man.sh Fri May 15 15:56:28 2015(r282980)
@@ -311,8 +311,11 @@ man_display_page() {
return
fi
 
+   if [ -n $use_width ]; then
+   mandoc_args=-O width=${use_width}
+   fi
testline=mandoc -Tlint -Wunsupp 2/dev/null
-   pipeline=mandoc | $MANPAGER
+   pipeline=mandoc $mandoc_args | $MANPAGER
 
if ! eval $cattool $manpage | $testline ;then
if which -s groff; then
___
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: r282971 - in head/sys: kern sys

2015-05-15 Thread John Baldwin
On Friday, May 15, 2015 01:50:38 PM John Baldwin wrote:
 Author: jhb
 Date: Fri May 15 13:50:37 2015
 New Revision: 282971
 URL: https://svnweb.freebsd.org/changeset/base/282971
 
 Log:
   Previously, cv_waiters was only updated by cv_signal or cv_wait. If a
   thread awakened due to a time out, then cv_waiters was not decremented.
   If INT_MAX threads timed out on a cv without an intervening cv_broadcast,
   then cv_waiters could overflow. To fix this, have each sleeping thread
   decrement cv_waiters when it resumes.
   
   Note that previously cv_waiters was protected by the sleepq chain lock.
   However, that lock is not held when threads resume from sleep. In
   addition, the interlock is also not always reacquired after resuming
   (cv_wait_unlock), nor is it always held by callers of cv_signal() or
   cv_broadcast(). Instead, use atomic ops to update cv_waiters. Since
   the sleepq chain lock is still held on every increment, it should
   still be safe to compare cv_waiters against zero while holding the
   lock in the wakeup routines as the only way the race should be lost
   would result in extra calls to sleepq_signal() or sleepq_broadcast().
   
   Differential Revision:  https://reviews.freebsd.org/D2427
   Reviewed by:benno
   Reported by:benno (wrap of cv_waiters in the field)
   MFC after:  2 weeks

With the additional overhead of the atomic ops it might be worth running
some benchmarks to compare this with removing cv_waiters entirely.  The
theoretical gain from cv_waiters is avoiding looking in the hash table for
a matching sleepqueue when there are no waiters.  When cv_waiters was
a simple integer the cost of having it around was very small, so even a
tiny gain was worth having.  (It is worth noting that in pre-SMPng code it
was fairly common practice to keep a WANTED flag around that was set by
waiters and would result in wakeup() being skipped if it wasn't set.  These
flags were maintained by each caller, not centrally.  cv_waiters makes this
sort of thing centrally maintained rather than something that each caller
has to do.)  Now that cv_waiters is updated with atomics, the cost is not
quite as small.

-- 
John Baldwin
___
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: r282994 - head/tools/build

2015-05-15 Thread Dimitry Andric
Author: dim
Date: Fri May 15 22:19:35 2015
New Revision: 282994
URL: https://svnweb.freebsd.org/changeset/base/282994

Log:
  Provide reallocarray() in -legacy, if needed, to allow building head on
  previous releases.
  
  Also add a stdlib.h wrapper, which declares the function, otherwise the
  compiler may assume it returns int, which can cause segfaults on LP64
  architectures.
  
  Reviewed by: bapt
  Differential Revision: https://reviews.freebsd.org/D2558

Added:
  head/tools/build/stdlib.h   (contents, props changed)
Modified:
  head/tools/build/Makefile

Modified: head/tools/build/Makefile
==
--- head/tools/build/Makefile   Fri May 15 22:14:42 2015(r282993)
+++ head/tools/build/Makefile   Fri May 15 22:19:35 2015(r282994)
@@ -25,6 +25,14 @@ CFLAGS+= -I${.CURDIR}/../../contrib/libc
-I${.CURDIR}/../../lib/libc/include
 .endif
 
+_WITH_REALLOCARRAY!= grep -c reallocarray /usr/include/stdlib.h || true
+.if ${_WITH_REALLOCARRAY} == 0
+.PATH: ${.CURDIR}/../../lib/libc/stdlib
+INCS+= stdlib.h
+SRCS+= reallocarray.c
+CFLAGS+=   -I${.CURDIR}/../../lib/libc/include
+.endif
+
 .if empty(SRCS)
 SRCS=  dummy.c
 .endif

Added: head/tools/build/stdlib.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/build/stdlib.h   Fri May 15 22:19:35 2015(r282994)
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2015 Dimitry Andric d...@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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LEGACY_STDLIB_H_
+#define_LEGACY_STDLIB_H_
+
+#include_next stdlib.h
+
+__BEGIN_DECLS
+   
+#if __BSD_VISIBLE
+void   *reallocarray(void *, size_t, size_t);
+#endif /* __BSD_VISIBLE */
+
+__END_DECLS
+
+#endif /* !_LEGACY_STDLIB_H_ */
___
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: r282973 - in head: gnu/lib tools/build/mk

2015-05-15 Thread Ed Maste
Author: emaste
Date: Fri May 15 14:22:33 2015
New Revision: 282973
URL: https://svnweb.freebsd.org/changeset/base/282973

Log:
  Build libgomp only if we're also building base system GCC
  
  Clang's OpenMP support will emit Intel OpenMP API library calls,
  and will therefore require libiomp (or whatever name is settled on).
  An up-to-date version of libgomp is included in ports or pkg GCC.
  Thus, there is no reason to build base libgomp without base system GCC.
  
  PR:   199979 (exp-run)
  Reviewed by:  pfg
  Relnotes: Yes
  Sponsored by: The FreeBSD Foundation
  Differential Revision: https://reviews.freebsd.org/D2459

Modified:
  head/gnu/lib/Makefile
  head/tools/build/mk/OptionalObsoleteFiles.inc

Modified: head/gnu/lib/Makefile
==
--- head/gnu/lib/Makefile   Fri May 15 13:55:18 2015(r282972)
+++ head/gnu/lib/Makefile   Fri May 15 14:22:33 2015(r282973)
@@ -2,7 +2,11 @@
 
 .include src.opts.mk
 
-SUBDIR= csu libgcc libgcov libdialog libgomp libregex libreadline
+SUBDIR= csu libgcc libgcov libdialog libregex libreadline
+
+.if ${MK_GCC} != no
+SUBDIR+= libgomp
+.endif
 
 .if ${MK_SSP} != no
 SUBDIR+= libssp

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Fri May 15 13:55:18 
2015(r282972)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Fri May 15 14:22:33 
2015(r282973)
@@ -1743,6 +1743,11 @@ OLD_FILES+=usr/include/gcc/4.2/altivec.h
 OLD_FILES+=usr/include/gcc/4.2/ppc-asm.h
 OLD_FILES+=usr/include/gcc/4.2/spe.h
 .endif
+OLD_FILES+=usr/include/omp.h
+OLD_FILES+=usr/lib/libgomp.a
+OLD_FILES+=usr/lib/libgomp.so
+OLD_FILES+=usr/lib/libgomp.so.1
+OLD_FILES+=usr/lib/libgomp_p.a
 OLD_FILES+=usr/libexec/cc1
 OLD_FILES+=usr/libexec/cc1plus
 OLD_FILES+=usr/share/info/cpp.info.gz
___
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: r282998 - head/sys/dev/sfxge

2015-05-15 Thread Andrew Rybchenko
Author: arybchik
Date: Sat May 16 05:43:20 2015
New Revision: 282998
URL: https://svnweb.freebsd.org/changeset/base/282998

Log:
  sfxge: move mbuf free to sfxge_if_transmit()
  
  It is a preparation to the next patch which will service packet queue even
  if packet addtion fails.
  
  Reviewed by:gnn
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:  2 days
  Differential Revision: https://reviews.freebsd.org/D2552

Modified:
  head/sys/dev/sfxge/sfxge_tx.c

Modified: head/sys/dev/sfxge/sfxge_tx.c
==
--- head/sys/dev/sfxge/sfxge_tx.c   Sat May 16 05:37:47 2015
(r282997)
+++ head/sys/dev/sfxge/sfxge_tx.c   Sat May 16 05:43:20 2015
(r282998)
@@ -605,9 +605,8 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
int rc;
 
if (!SFXGE_LINK_UP(txq-sc)) {
-   rc = ENETDOWN;
atomic_add_long(txq-netdown_drops, 1);
-   goto fail;
+   return (ENETDOWN);
}
 
/*
@@ -622,7 +621,7 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
rc = sfxge_tx_qdpl_put_locked(txq, m);
if (rc != 0) {
SFXGE_TXQ_UNLOCK(txq);
-   goto fail;
+   return (rc);
}
 
/* Try to service the list. */
@@ -631,7 +630,7 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
} else {
rc = sfxge_tx_qdpl_put_unlocked(txq, m);
if (rc != 0)
-   goto fail;
+   return (rc);
 
/*
 * Try to grab the lock again.
@@ -649,10 +648,6 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
SFXGE_TXQ_LOCK_ASSERT_NOTOWNED(txq);
 
return (0);
-
-fail:
-   m_freem(m);
-   return (rc);
 }
 
 static void
@@ -730,6 +725,8 @@ sfxge_if_transmit(struct ifnet *ifp, str
}
 
rc = sfxge_tx_packet_add(txq, m);
+   if (rc != 0)
+   m_freem(m);
 
return (rc);
 }
___
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: r282948 - head/lib/libthr/thread

2015-05-15 Thread Rui Paulo
On Friday 15 May 2015 08:40:17 Konstantin Belousov wrote:
 Author: kib
 Date: Fri May 15 08:40:17 2015
 New Revision: 282948
 URL: https://svnweb.freebsd.org/changeset/base/282948
 
 Log:
   Some third-party malloc(3) implementations use pthread_setspecific(3)
   to handle per-thread information.  Since our pthread_setspecific()
   implementation calls calloc(3) to allocate per-thread specific data
   storage, things get complicated.
 
   Switch the allocator to use bare mmap(2).  There is some loss of the
   allocated page, since e.g. on amd64, PTHREAD_KEYS_MAX * sizeof(struct
   pthread_specific_elem) is 3K (it actually spans whole page due to
   padding), but I believe it is more acceptable than additional code for
   specialized allocator().
 
   The alternatives would either to make the specific data array be part of
   the struct thread, or use internal bindings to call the libc malloc,
   avoiding interposing.
 
   Also do the style pass over the thr_spec.c, esp. simplify the
   conditionals nesting by returning early when an error detected.
   Remove trivial comments.
 
   Found by:   y...@rawbw.com
   PR: 200138
   Sponsored by:   The FreeBSD Foundation
   MFC after:  2 weeks

Thanks!  I think umem might be affected as well.

-- 
Rui Paulo
___
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: r282996 - head/sys/dev/sfxge

2015-05-15 Thread Andrew Rybchenko
Author: arybchik
Date: Sat May 16 05:36:40 2015
New Revision: 282996
URL: https://svnweb.freebsd.org/changeset/base/282996

Log:
  sfxge: support Rx checksum offloads disabling
  
  We can't disable it in HW, but we can ignore result.
  Discard Rx descriptor checksum flags if Rx checksum offload is off.
  
  Reviewed by:gnn
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:  2 days
  Differential Revision: https://reviews.freebsd.org/D2544

Modified:
  head/sys/dev/sfxge/sfxge.c
  head/sys/dev/sfxge/sfxge_rx.c

Modified: head/sys/dev/sfxge/sfxge.c
==
--- head/sys/dev/sfxge/sfxge.c  Sat May 16 01:13:37 2015(r282995)
+++ head/sys/dev/sfxge/sfxge.c  Sat May 16 05:36:40 2015(r282996)
@@ -65,8 +65,7 @@ __FBSDID($FreeBSD$);
   IFCAP_JUMBO_MTU | IFCAP_LRO |\
   IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWSTATS)
 #defineSFXGE_CAP_ENABLE SFXGE_CAP
-#defineSFXGE_CAP_FIXED (IFCAP_VLAN_MTU | IFCAP_RXCSUM | 
IFCAP_VLAN_HWCSUM | \
-IFCAP_RXCSUM_IPV6 |\
+#defineSFXGE_CAP_FIXED (IFCAP_VLAN_MTU | IFCAP_VLAN_HWCSUM |   
\
 IFCAP_JUMBO_MTU | IFCAP_LINKSTATE | IFCAP_HWSTATS)
 
 MALLOC_DEFINE(M_SFXGE, sfxge, Solarflare 10GigE driver);

Modified: head/sys/dev/sfxge/sfxge_rx.c
==
--- head/sys/dev/sfxge/sfxge_rx.c   Sat May 16 01:13:37 2015
(r282995)
+++ head/sys/dev/sfxge/sfxge_rx.c   Sat May 16 05:36:40 2015
(r282996)
@@ -795,7 +795,8 @@ void
 sfxge_rx_qcomplete(struct sfxge_rxq *rxq, boolean_t eop)
 {
struct sfxge_softc *sc = rxq-sc;
-   int lro_enabled = sc-ifnet-if_capenable  IFCAP_LRO;
+   int if_capenable = sc-ifnet-if_capenable;
+   int lro_enabled = if_capenable  IFCAP_LRO;
unsigned int index;
struct sfxge_evq *evq;
unsigned int completed;
@@ -825,21 +826,37 @@ sfxge_rx_qcomplete(struct sfxge_rxq *rxq
 
prefetch_read_many(mtod(m, caddr_t));
 
-   /* Check for loopback packets */
-   if (!(rx_desc-flags  EFX_PKT_IPV4) 
-   !(rx_desc-flags  EFX_PKT_IPV6)) {
-   struct ether_header *etherhp;
-
-   /*LINTED*/
-   etherhp = mtod(m, struct ether_header *);
-
-   if (etherhp-ether_type ==
-   htons(SFXGE_ETHERTYPE_LOOPBACK)) {
-   EFSYS_PROBE(loopback);
-
-   rxq-loopback++;
-   goto discard;
+   switch (rx_desc-flags  (EFX_PKT_IPV4 | EFX_PKT_IPV6)) {
+   case EFX_PKT_IPV4:
+   if (~if_capenable  IFCAP_RXCSUM)
+   rx_desc-flags =
+   ~(EFX_CKSUM_IPV4 | EFX_CKSUM_TCPUDP);
+   break;
+   case EFX_PKT_IPV6:
+   if (~if_capenable  IFCAP_RXCSUM_IPV6)
+   rx_desc-flags = ~EFX_CKSUM_TCPUDP;
+   break;
+   case 0:
+   /* Check for loopback packets */
+   {
+   struct ether_header *etherhp;
+
+   /*LINTED*/
+   etherhp = mtod(m, struct ether_header *);
+
+   if (etherhp-ether_type ==
+   htons(SFXGE_ETHERTYPE_LOOPBACK)) {
+   EFSYS_PROBE(loopback);
+
+   rxq-loopback++;
+   goto discard;
+   }
}
+   break;
+   default:
+   KASSERT(B_FALSE,
+   (Rx descriptor with both IPv4 and IPv6 flags));
+   goto discard;
}
 
/* Pass packet up the stack or into LRO (pipelined) */
___
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: r282997 - head/sys/dev/sfxge

2015-05-15 Thread Andrew Rybchenko
Author: arybchik
Date: Sat May 16 05:37:47 2015
New Revision: 282997
URL: https://svnweb.freebsd.org/changeset/base/282997

Log:
  sfxge: get rid of locked variable in sfxge_tx_packet_add()
  
  Now each branch has one and only one possible TxQ lock state.
  It simplifies understanding of the code.
  
  Reviewed by:gnn
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:  2 days
  Differential Revision: https://reviews.freebsd.org/D2551

Modified:
  head/sys/dev/sfxge/sfxge_tx.c

Modified: head/sys/dev/sfxge/sfxge_tx.c
==
--- head/sys/dev/sfxge/sfxge_tx.c   Sat May 16 05:36:40 2015
(r282996)
+++ head/sys/dev/sfxge/sfxge_tx.c   Sat May 16 05:37:47 2015
(r282997)
@@ -602,7 +602,6 @@ sfxge_tx_qdpl_put_unlocked(struct sfxge_
 int
 sfxge_tx_packet_add(struct sfxge_txq *txq, struct mbuf *m)
 {
-   int locked;
int rc;
 
if (!SFXGE_LINK_UP(txq-sc)) {
@@ -616,9 +615,7 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
 * the packet will be appended to the get list of the deferred
 * packet list.  Otherwise, it will be pushed on the put list.
 */
-   locked = SFXGE_TXQ_TRYLOCK(txq);
-
-   if (locked) {
+   if (SFXGE_TXQ_TRYLOCK(txq)) {
/* First swizzle put-list to get-list to keep order */
sfxge_tx_qdpl_swizzle(txq);
 
@@ -627,6 +624,10 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
SFXGE_TXQ_UNLOCK(txq);
goto fail;
}
+
+   /* Try to service the list. */
+   sfxge_tx_qdpl_service(txq);
+   /* Lock has been dropped. */
} else {
rc = sfxge_tx_qdpl_put_unlocked(txq, m);
if (rc != 0)
@@ -639,14 +640,13 @@ sfxge_tx_packet_add(struct sfxge_txq *tx
 * the deferred packet list.  If we are not able to get
 * the lock, another thread is processing the list.
 */
-   locked = SFXGE_TXQ_TRYLOCK(txq);
+   if (SFXGE_TXQ_TRYLOCK(txq)) {
+   sfxge_tx_qdpl_service(txq);
+   /* Lock has been dropped. */
+   }
}
 
-   if (locked) {
-   /* Try to service the list. */
-   sfxge_tx_qdpl_service(txq);
-   /* Lock has been dropped. */
-   }
+   SFXGE_TXQ_LOCK_ASSERT_NOTOWNED(txq);
 
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


svn commit: r282986 - head/share/mk

2015-05-15 Thread Cy Schubert
Author: cy
Date: Fri May 15 19:37:17 2015
New Revision: 282986
URL: https://svnweb.freebsd.org/changeset/base/282986

Log:
  Correct location for libntpevent.a.

Modified:
  head/share/mk/src.libnames.mk

Modified: head/share/mk/src.libnames.mk
==
--- head/share/mk/src.libnames.mk   Fri May 15 18:25:48 2015
(r282985)
+++ head/share/mk/src.libnames.mk   Fri May 15 19:37:17 2015
(r282986)
@@ -340,7 +340,7 @@ LIBNTPDIR=  ${ROOTOBJDIR}/usr.sbin/ntp/li
 LIBNTP?=   ${LIBNTPDIR}/libntp.a
 
 LIBNTPEVENTDIR=${ROOTOBJDIR}/usr.sbin/ntp/libntpevent
-LIBNTPEVENT?=  ${LIBNTPDIR}/libntpevent.a
+LIBNTPEVENT?=  ${LIBNTPEVENTDIR}/libntpevent.a
 
 LIBOPTSDIR=${ROOTOBJDIR}/usr.sbin/ntp/libopts
 LIBOTPS?=  ${LIBOPTSDIR}/libopts.a
___
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: r282987 - head/sys/sys

2015-05-15 Thread Pedro F. Giffuni
Author: pfg
Date: Fri May 15 19:51:05 2015
New Revision: 282987
URL: https://svnweb.freebsd.org/changeset/base/282987

Log:
  Break apart the gnu_inline attribute and use artificial if available.
  
  In general it is bad practice to use the gnu_inline attribute but we
  will need it in special cases like FORTIFY_SOURCE. In this specific
  case it is also useful to have the artificial attribute:
  
  This attribute is useful for small inline wrappers which if possible
  should appear during debugging as a unit, depending on the debug info
  format it will either mean marking the function as artificial or using the
  caller location for all instructions within the inlined body.
  
  This attribute appears to be currently implemented only in GCC. Use it
  only in conjuntion with gnu_inline in the cases where it is available,
  which is similar in spirit in how it's used in glibc.

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hFri May 15 19:37:17 2015(r282986)
+++ head/sys/sys/cdefs.hFri May 15 19:51:05 2015(r282987)
@@ -375,10 +375,8 @@
 #endif
 
 #if __GNUC_PREREQ__(4, 1)
-#define__gnu_inline__attribute__((__gnu_inline__))
 #define__returns_twice __attribute__((__returns_twice__))
 #else
-#define__gnu_inline
 #define__returns_twice
 #endif
 
@@ -538,6 +536,21 @@
__attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
 #endif
 
+/*
+ * FORTIFY_SOURCE, and perhaps other compiler-specific features, require
+ * the use of non-standard inlining.  In general we should try to avoid
+ * using these but GCC-compatible compilers tend to support the extensions
+ * well enough to use them in limited cases.
+ */ 
+#if __GNUC_PREREQ__(4, 1)
+#if __has_attribute(artificial) || __GNUC_PREREQ__(4, 3)
+#define__gnu_inline__attribute__((__gnu_inline__, __artificial__))
+#else
+#define__gnu_inline__attribute__((__gnu_inline__))
+#else
+#define__gnu_inline
+#endif
+
 /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
 #if defined(__FreeBSD_cc_version)  __FreeBSD_cc_version = 31  \
 defined(__GNUC__)  !defined(__INTEL_COMPILER)
___
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: r282985 - in head/sys: arm/annapurna arm/annapurna/alpine arm/annapurna/alpine/hal arm/conf boot/fdt/dts/arm

2015-05-15 Thread Zbigniew Bodek
Author: zbb
Date: Fri May 15 18:25:48 2015
New Revision: 282985
URL: https://svnweb.freebsd.org/changeset/base/282985

Log:
  Introduce support for the Alpine PoC from Annapurna Labs
  
  The Alpine Platform-On-Chip offers multicore processing
  (quad ARM Cortex-A15), 1/10Gb Ethernet, SATA 3, PCI-E 3,
  DMA engines, Virtualization, Advanced Power Management and other.
  
  This code drop involves basic platform support including:
  SMP, IRQs, SerDes, SATA. As of now it is missing the PCIe support.
  Part of the functionality is provided by the low-level code (HAL)
  delivered by the chip vendor (Annapurna Labs) and is a subject to
  change in the future (is planned to be moved to sys/contrib directory).
  
  The review log for this commit is available here:
  https://reviews.freebsd.org/D2340
  
  Reviewed by:andrew, ian, imp
  Obtained from:  Semihalf
  Sponsored by:   Annapurna Labs

Added:
  head/sys/arm/annapurna/
  head/sys/arm/annapurna/alpine/
  head/sys/arm/annapurna/alpine/alpine_machdep.c   (contents, props changed)
  head/sys/arm/annapurna/alpine/alpine_machdep_mp.c   (contents, props changed)
  head/sys/arm/annapurna/alpine/common.c   (contents, props changed)
  head/sys/arm/annapurna/alpine/files.alpine   (contents, props changed)
  head/sys/arm/annapurna/alpine/hal/
  head/sys/arm/annapurna/alpine/hal/al_hal_common.h   (contents, props changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_iofic.h   (contents, props changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_iofic_regs.h   (contents, props 
changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_nb_regs.h   (contents, props changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_pbs_regs.h   (contents, props 
changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_pcie.c   (contents, props changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_pcie.h   (contents, props changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_pcie_axi_reg.h   (contents, props 
changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_pcie_interrupts.h   (contents, props 
changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_pcie_regs.h   (contents, props 
changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_pcie_w_reg.h   (contents, props 
changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_plat_services.h   (contents, props 
changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_plat_types.h   (contents, props 
changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_reg_utils.h   (contents, props 
changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_types.h   (contents, props changed)
  head/sys/arm/annapurna/alpine/hal/al_hal_unit_adapter_regs.h   (contents, 
props changed)
  head/sys/arm/annapurna/alpine/std.alpine   (contents, props changed)
  head/sys/arm/conf/ALPINE   (contents, props changed)
  head/sys/boot/fdt/dts/arm/annapurna-alpine.dts   (contents, props changed)

Added: head/sys/arm/annapurna/alpine/alpine_machdep.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/annapurna/alpine/alpine_machdep.c  Fri May 15 18:25:48 
2015(r282985)
@@ -0,0 +1,148 @@
+/*-
+ * Copyright (c) 2013 Ruslan Bukin b...@bsdpad.com
+ * Copyright (c) 2015 Semihalf
+ * 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$);
+
+#define _ARM32_BUS_DMA_PRIVATE
+#include sys/param.h
+#include sys/systm.h
+#include sys/bus.h
+#include sys/lock.h
+#include sys/mutex.h
+
+#include vm/vm.h
+#include vm/pmap.h
+
+#include machine/bus.h
+#include machine/frame.h /* For trapframe_t, used in machine/machdep.h */
+#include machine/machdep.h
+#include machine/pmap.h
+#include 

svn commit: r282983 - head/sys/arm/arm

2015-05-15 Thread Ian Lepore
Author: ian
Date: Fri May 15 18:07:58 2015
New Revision: 282983
URL: https://svnweb.freebsd.org/changeset/base/282983

Log:
  Retrieve the cache parms in the proper arch-specific way.
  
  Submitted by: Michal Meloun mel...@miracle.cz

Modified:
  head/sys/arm/arm/cpuinfo.c

Modified: head/sys/arm/arm/cpuinfo.c
==
--- head/sys/arm/arm/cpuinfo.c  Fri May 15 18:04:49 2015(r282982)
+++ head/sys/arm/arm/cpuinfo.c  Fri May 15 18:07:58 2015(r282983)
@@ -131,8 +131,17 @@ cpuinfo_init(void)
cpuinfo.security_ext = (cpuinfo.id_pfr1  4)  0xF;
 
/* L1 Cache sizes */
-   cpuinfo.dcache_line_size = 1  (CPU_CT_DMINLINE(cpuinfo.ctr ) + 2);
+   if (CPU_CT_FORMAT(cpuinfo.ctr) == CPU_CT_ARMV7) {
+   cpuinfo.dcache_line_size =
+   1  (CPU_CT_DMINLINE(cpuinfo.ctr) + 2);
+   cpuinfo.icache_line_size =
+   1  (CPU_CT_IMINLINE(cpuinfo.ctr) + 2);
+   } else {
+   cpuinfo.dcache_line_size =
+   1  (CPU_CT_xSIZE_LEN(CPU_CT_DSIZE(cpuinfo.ctr)) + 3);
+   cpuinfo.icache_line_size =
+   1  (CPU_CT_xSIZE_LEN(CPU_CT_ISIZE(cpuinfo.ctr)) + 3);
+   }
cpuinfo.dcache_line_mask = cpuinfo.dcache_line_size - 1;
-   cpuinfo.icache_line_size= 1  (CPU_CT_IMINLINE(cpuinfo.ctr ) + 2);
cpuinfo.icache_line_mask = cpuinfo.icache_line_size - 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: r282989 - head/sys/sys

2015-05-15 Thread Pedro F. Giffuni
Author: pfg
Date: Fri May 15 20:47:25 2015
New Revision: 282989
URL: https://svnweb.freebsd.org/changeset/base/282989

Log:
  Break apart the gnu_inline attribute and use artificial if available.
  
  Missing #endif
  
  Reported by:  jhb, jenkins
  Pointed hat:  me

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hFri May 15 20:43:37 2015(r282988)
+++ head/sys/sys/cdefs.hFri May 15 20:47:25 2015(r282989)
@@ -550,6 +550,7 @@
 #else
 #define__gnu_inline
 #endif
+#endif
 
 /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
 #if defined(__FreeBSD_cc_version)  __FreeBSD_cc_version = 31  \
___
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: r282990 - head/sys/sys

2015-05-15 Thread Pedro F. Giffuni
Author: pfg
Date: Fri May 15 20:53:43 2015
New Revision: 282990
URL: https://svnweb.freebsd.org/changeset/base/282990

Log:
  Break apart the gnu_inline attribute and use artificial if available.
  
  Missing #endif (in wrong place)
  
  Pointed hat:  me

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hFri May 15 20:47:25 2015(r282989)
+++ head/sys/sys/cdefs.hFri May 15 20:53:43 2015(r282990)
@@ -547,10 +547,10 @@
 #define__gnu_inline__attribute__((__gnu_inline__, __artificial__))
 #else
 #define__gnu_inline__attribute__((__gnu_inline__))
+#endif /* artificial */
 #else
 #define__gnu_inline
 #endif
-#endif
 
 /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
 #if defined(__FreeBSD_cc_version)  __FreeBSD_cc_version = 31  \
___
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: r282987 - head/sys/sys

2015-05-15 Thread Pedro Giffuni



On 05/15/15 15:35, John Baldwin wrote:

On Friday, May 15, 2015 07:51:06 PM Pedro F. Giffuni wrote:

Author: pfg
Date: Fri May 15 19:51:05 2015
New Revision: 282987
URL: https://svnweb.freebsd.org/changeset/base/282987

Log:
   Break apart the gnu_inline attribute and use artificial if available.
   
   In general it is bad practice to use the gnu_inline attribute but we

   will need it in special cases like FORTIFY_SOURCE. In this specific
   case it is also useful to have the artificial attribute:
   
   This attribute is useful for small inline wrappers which if possible

   should appear during debugging as a unit, depending on the debug info
   format it will either mean marking the function as artificial or using the
   caller location for all instructions within the inlined body.
   
   This attribute appears to be currently implemented only in GCC. Use it

   only in conjuntion with gnu_inline in the cases where it is available,
   which is similar in spirit in how it's used in glibc.

Modified:
   head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hFri May 15 19:37:17 2015(r282986)
+++ head/sys/sys/cdefs.hFri May 15 19:51:05 2015(r282987)
@@ -375,10 +375,8 @@
  #endif
  
  #if __GNUC_PREREQ__(4, 1)

-#define__gnu_inline__attribute__((__gnu_inline__))
  #define   __returns_twice __attribute__((__returns_twice__))
  #else
-#define__gnu_inline
  #define   __returns_twice
  #endif
  
@@ -538,6 +536,21 @@

__attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
  #endif
  
+/*

+ * FORTIFY_SOURCE, and perhaps other compiler-specific features, require
+ * the use of non-standard inlining.  In general we should try to avoid
+ * using these but GCC-compatible compilers tend to support the extensions
+ * well enough to use them in limited cases.
+ */
+#if __GNUC_PREREQ__(4, 1)
+#if __has_attribute(artificial) || __GNUC_PREREQ__(4, 3)
+#define__gnu_inline__attribute__((__gnu_inline__, __artificial__))
+#else
+#define__gnu_inline__attribute__((__gnu_inline__))

 missing an #endif here?

I'm getting this error from buildworld:

/usr/obj/usr/src/tmp/usr/include/sys/cdefs.h:550:2: error: #else after #else
#else
  ^
/usr/obj/usr/src/tmp/usr/include/sys/cdefs.h:36:2: error: unterminated 
conditional directive
#ifndef _SYS_CDEFS_H_
  ^
14 errors generated.
mkdep: compile failed


(Bah... you guys beat my tinderbox.)

Fixed sorry.

Pedro.

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

2015-05-15 Thread John Baldwin
On Friday, May 15, 2015 07:51:06 PM Pedro F. Giffuni wrote:
 Author: pfg
 Date: Fri May 15 19:51:05 2015
 New Revision: 282987
 URL: https://svnweb.freebsd.org/changeset/base/282987
 
 Log:
   Break apart the gnu_inline attribute and use artificial if available.
   
   In general it is bad practice to use the gnu_inline attribute but we
   will need it in special cases like FORTIFY_SOURCE. In this specific
   case it is also useful to have the artificial attribute:
   
   This attribute is useful for small inline wrappers which if possible
   should appear during debugging as a unit, depending on the debug info
   format it will either mean marking the function as artificial or using the
   caller location for all instructions within the inlined body.
   
   This attribute appears to be currently implemented only in GCC. Use it
   only in conjuntion with gnu_inline in the cases where it is available,
   which is similar in spirit in how it's used in glibc.
 
 Modified:
   head/sys/sys/cdefs.h
 
 Modified: head/sys/sys/cdefs.h
 ==
 --- head/sys/sys/cdefs.h  Fri May 15 19:37:17 2015(r282986)
 +++ head/sys/sys/cdefs.h  Fri May 15 19:51:05 2015(r282987)
 @@ -375,10 +375,8 @@
  #endif
  
  #if __GNUC_PREREQ__(4, 1)
 -#define  __gnu_inline__attribute__((__gnu_inline__))
  #define  __returns_twice __attribute__((__returns_twice__))
  #else
 -#define  __gnu_inline
  #define  __returns_twice
  #endif
  
 @@ -538,6 +536,21 @@
   __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
  #endif
  
 +/*
 + * FORTIFY_SOURCE, and perhaps other compiler-specific features, require
 + * the use of non-standard inlining.  In general we should try to avoid
 + * using these but GCC-compatible compilers tend to support the extensions
 + * well enough to use them in limited cases.
 + */ 
 +#if __GNUC_PREREQ__(4, 1)
 +#if __has_attribute(artificial) || __GNUC_PREREQ__(4, 3)
 +#define  __gnu_inline__attribute__((__gnu_inline__, __artificial__))
 +#else
 +#define  __gnu_inline__attribute__((__gnu_inline__))

 missing an #endif here?

I'm getting this error from buildworld:

/usr/obj/usr/src/tmp/usr/include/sys/cdefs.h:550:2: error: #else after #else
#else
 ^
/usr/obj/usr/src/tmp/usr/include/sys/cdefs.h:36:2: error: unterminated 
conditional directive
#ifndef _SYS_CDEFS_H_
 ^
14 errors generated.
mkdep: compile failed

-- 
John Baldwin
___
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: r282907 - head/sys/sys

2015-05-15 Thread Pedro Giffuni



On 05/15/15 05:33, Tijl Coosemans wrote:

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hThu May 14 15:14:03 2015(r282906)
+++ head/sys/sys/cdefs.hThu May 14 15:49:48 2015(r282907)
@@ -388,6 +388,12 @@
  #define   __alloc_size(x)
  #endif
  
+#if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ__(4, 6)

+#define__unreachable() __builtin_unreachable()
+#else
+#define__unreachable() do {} while (/*CONSTCOND*/0)
__builtin_unreachable() can be used in expressions so I think it's better
to replace do-while with ((void)0).  You can then do things like this:

#define assume(e)  ((e) ? (void)0 : __unreachable())
(like assert(e) but without error)

Looks reasonable, thanks!

FWIW, there was some discussion about having a debugging
macro that warns when such unreachable code is reached.
We are just not sure where such a macro belongs, probably
not in cdefs.

Pedro.
___
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: r282981 - head/sys/sys

2015-05-15 Thread Pedro F. Giffuni
Author: pfg
Date: Fri May 15 17:51:03 2015
New Revision: 282981
URL: https://svnweb.freebsd.org/changeset/base/282981

Log:
  Replace a CONSTCOND for a void value as a replacement for __unreachable 
builtin
  
  This only applies if we are not using clang or gcc but it lets us use the
  __unreachable() buitin in expressions.
  
  Suggested by: tijl

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hFri May 15 15:56:28 2015(r282980)
+++ head/sys/sys/cdefs.hFri May 15 17:51:03 2015(r282981)
@@ -391,7 +391,7 @@
 #if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ__(4, 6)
 #define__unreachable() __builtin_unreachable()
 #else
-#define__unreachable() do {} while (/*CONSTCOND*/0)
+#define__unreachable() ((void)0)
 #endif
 
 #if __has_attribute(alloc_align) || __GNUC_PREREQ__(4, 9)
___
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: r282982 - head/sys/netipsec

2015-05-15 Thread George V. Neville-Neil
Author: gnn
Date: Fri May 15 18:04:49 2015
New Revision: 282982
URL: https://svnweb.freebsd.org/changeset/base/282982

Log:
  Summary: Remove spurious, extra, next header comments.
  Correct the name of the pad length field.

Modified:
  head/sys/netipsec/esp.h

Modified: head/sys/netipsec/esp.h
==
--- head/sys/netipsec/esp.h Fri May 15 17:51:03 2015(r282981)
+++ head/sys/netipsec/esp.h Fri May 15 18:04:49 2015(r282982)
@@ -42,8 +42,7 @@ struct esp {
/*variable size, 32bit bound*/  /* Initialization Vector */
/*variable size*/   /* Payload data */
/*variable size*/   /* padding */
-   /*8bit*//* pad size */
-   /*8bit*//* next header */
+   /*8bit*//* pad length */
/*8bit*//* next header */
/*variable size, 32bit bound*/  /* Authentication data (new IPsec) */
 };
@@ -53,8 +52,7 @@ struct newesp {
u_int32_t   esp_seq;/* Sequence number */
/*variable size*/   /* (IV and) Payload data */
/*variable size*/   /* padding */
-   /*8bit*//* pad size */
-   /*8bit*//* next header */
+   /*8bit*//* pad length */
/*8bit*//* next header */
/*variable size, 32bit bound*/  /* Authentication 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


svn commit: r282984 - head/sys/arm/include

2015-05-15 Thread Ian Lepore
Author: ian
Date: Fri May 15 18:10:00 2015
New Revision: 282984
URL: https://svnweb.freebsd.org/changeset/base/282984

Log:
  Add assertions that the addresses passed to tlb maintenance are page-aligned.
  
  Perform cache writebacks and invalidations in the correct (inner to outer
  or vice versa) order, and add comments that explain that.
  
  Consistantly use 'va' as the variable name for virtual addresses.
  
  Submitted by: Michal Meloun mel...@miracle.cz

Modified:
  head/sys/arm/include/cpu-v6.h

Modified: head/sys/arm/include/cpu-v6.h
==
--- head/sys/arm/include/cpu-v6.h   Fri May 15 18:07:58 2015
(r282983)
+++ head/sys/arm/include/cpu-v6.h   Fri May 15 18:10:00 2015
(r282984)
@@ -39,7 +39,6 @@
 #include machine/cpuinfo.h
 #include machine/sysreg.h
 
-
 #define CPU_ASID_KERNEL 0
 
 vm_offset_t dcache_wb_pou_checked(vm_offset_t, vm_size_t);
@@ -281,24 +280,29 @@ tlb_flush_all_ng_local(void)
 
 /* Flush single TLB entry (even global). */
 static __inline void
-tlb_flush_local(vm_offset_t sva)
+tlb_flush_local(vm_offset_t va)
 {
 
+   KASSERT((va  PAGE_MASK) == 0, (%s: va %#x not aligned, __func__, 
va));
+
dsb();
-   _CP15_TLBIMVA((sva  ~PAGE_MASK ) | CPU_ASID_KERNEL);
+   _CP15_TLBIMVA(va | CPU_ASID_KERNEL);
dsb();
 }
 
 /* Flush range of TLB entries (even global). */
 static __inline void
-tlb_flush_range_local(vm_offset_t sva, vm_size_t size)
+tlb_flush_range_local(vm_offset_t va, vm_size_t size)
 {
-   vm_offset_t va;
-   vm_offset_t eva = sva + size;
+   vm_offset_t eva = va + size;
+
+   KASSERT((va  PAGE_MASK) == 0, (%s: va %#x not aligned, __func__, 
va));
+   KASSERT((size  PAGE_MASK) == 0, (%s: size %#x not aligned, __func__,
+   size));
 
dsb();
-   for (va = sva; va  eva; va += PAGE_SIZE)
-   _CP15_TLBIMVA((va  ~PAGE_MASK ) | CPU_ASID_KERNEL);
+   for (; va  eva; va += PAGE_SIZE)
+   _CP15_TLBIMVA(va | CPU_ASID_KERNEL);
dsb();
 }
 
@@ -324,22 +328,27 @@ tlb_flush_all_ng(void)
 }
 
 static __inline void
-tlb_flush(vm_offset_t sva)
+tlb_flush(vm_offset_t va)
 {
 
+   KASSERT((va  PAGE_MASK) == 0, (%s: va %#x not aligned, __func__, 
va));
+
dsb();
-   _CP15_TLBIMVAAIS(sva);
+   _CP15_TLBIMVAAIS(va);
dsb();
 }
 
 static __inline void
-tlb_flush_range(vm_offset_t sva,  vm_size_t size)
+tlb_flush_range(vm_offset_t va,  vm_size_t size)
 {
-   vm_offset_t va;
-   vm_offset_t eva = sva + size;
+   vm_offset_t eva = va + size;
+
+   KASSERT((va  PAGE_MASK) == 0, (%s: va %#x not aligned, __func__, 
va));
+   KASSERT((size  PAGE_MASK) == 0, (%s: size %#x not aligned, __func__,
+   size));
 
dsb();
-   for (va = sva; va  eva; va += PAGE_SIZE)
+   for (; va  eva; va += PAGE_SIZE)
_CP15_TLBIMVAAIS(va);
dsb();
 }
@@ -347,8 +356,8 @@ tlb_flush_range(vm_offset_t sva,  vm_siz
 
 #define tlb_flush_all()tlb_flush_all_local()
 #define tlb_flush_all_ng() tlb_flush_all_ng_local()
-#define tlb_flush(sva) tlb_flush_local(sva)
-#define tlb_flush_range(sva, size) tlb_flush_range_local(sva, size)
+#define tlb_flush(va)  tlb_flush_local(va)
+#define tlb_flush_range(va, size)  tlb_flush_range_local(va, size)
 
 #endif /* SMP */
 
@@ -358,13 +367,13 @@ tlb_flush_range(vm_offset_t sva,  vm_siz
 
 /*  Sync I and D caches to PoU */
 static __inline void
-icache_sync(vm_offset_t sva, vm_size_t size)
+icache_sync(vm_offset_t va, vm_size_t size)
 {
-   vm_offset_t va;
-   vm_offset_t eva = sva + size;
+   vm_offset_t eva = va + size;
 
dsb();
-   for (va = sva; va  eva; va += cpuinfo.dcache_line_size) {
+   va = ~cpuinfo.dcache_line_mask;
+   for ( ; va  eva; va += cpuinfo.dcache_line_size) {
 #if __ARM_ARCH = 7  defined SMP
_CP15_DCCMVAU(va);
 #else
@@ -409,13 +418,13 @@ bpb_inv_all(void)
 
 /* Write back D-cache to PoU */
 static __inline void
-dcache_wb_pou(vm_offset_t sva, vm_size_t size)
+dcache_wb_pou(vm_offset_t va, vm_size_t size)
 {
-   vm_offset_t va;
-   vm_offset_t eva = sva + size;
+   vm_offset_t eva = va + size;
 
dsb();
-   for (va = sva; va  eva; va += cpuinfo.dcache_line_size) {
+   va = ~cpuinfo.dcache_line_mask;
+   for ( ; va  eva; va += cpuinfo.dcache_line_size) {
 #if __ARM_ARCH = 7  defined SMP
_CP15_DCCMVAU(va);
 #else
@@ -425,40 +434,46 @@ dcache_wb_pou(vm_offset_t sva, vm_size_t
dsb();
 }
 
-/* Invalidate D-cache to PoC */
+/*
+ * Invalidate D-cache to PoC
+ *
+ * Caches are invalidated from outermost to innermost as fresh cachelines
+ * flow in this direction. In given range, if there was no dirty cacheline
+ * in any cache before, no stale cacheline should remain in them after this
+ * operation finishes.
+ */
 static 

svn commit: r282991 - head/sys/x86/acpica

2015-05-15 Thread Adrian Chadd
Author: adrian
Date: Fri May 15 21:33:19 2015
New Revision: 282991
URL: https://svnweb.freebsd.org/changeset/base/282991

Log:
  Update the comments to match what the code ended up becoming.
  
  -1 is now no locality information available.
  
  Sponsored by: Norse Corp, Inc.

Modified:
  head/sys/x86/acpica/srat.c

Modified: head/sys/x86/acpica/srat.c
==
--- head/sys/x86/acpica/srat.c  Fri May 15 20:53:43 2015(r282990)
+++ head/sys/x86/acpica/srat.c  Fri May 15 21:33:19 2015(r282991)
@@ -428,7 +428,7 @@ init_mem_locality(void)
int i;
 
/*
-* For now, assume 255 == no locality information for
+* For now, assume -1 == no locality information for
 * this pairing.
 */
for (i = 0; i  MAXMEMDOM * MAXMEMDOM; i++)
___
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