Index: branches/reconfiguration/modules/vci_local_crossbar/caba/source/src/vci_local_crossbar.cpp
===================================================================
--- branches/reconfiguration/modules/vci_local_crossbar/caba/source/src/vci_local_crossbar.cpp	(revision 1011)
+++ branches/reconfiguration/modules/vci_local_crossbar/caba/source/src/vci_local_crossbar.cpp	(revision 1013)
@@ -78,5 +78,7 @@
     const void* 	        m_lt;           // locality table if cmd / id_locality table if rsp
     const bool              m_is_cmd;       // cmd crossbar when true
-    bool                    m_barrier;      // barrier in the global interface is enabled
+
+    bool                    m_barrier;         // barrier in the global interface is enabled
+    bool                    m_barrier_release; // request to release the barrier
 
     sc_signal<bool>*		r_allocated;	// for each output port: allocation state 
@@ -92,5 +94,6 @@
 	                void*   rt,             // routing table 
 	                void*   lt,             // locality table
-                    bool    is_cmd )
+                    bool    is_cmd,
+                    bool    barrier = false)
 	: m_cluster_id( cluster_id ),
       m_in_size( in_size ),
@@ -99,5 +102,6 @@
 	  m_lt( lt ),
       m_is_cmd( is_cmd ),
-      m_barrier( false )
+      m_barrier( barrier ),
+      m_barrier_release( false )
 	{
 	    r_allocated = new sc_signal<bool>[out_size];
@@ -108,7 +112,13 @@
 
     //////////////////////////////////
-    void setBarrier(const bool &value)
+    inline void setBarrier(const bool &value)
     {
         m_barrier = value;
+    }
+
+    //////////////////////////////////
+    inline void releaseBarrier()
+    {
+        m_barrier_release = true;
     }
 
@@ -288,4 +298,14 @@
             }
         }
+
+        // release the barrier if there is no pending global-to-local
+        // request. This avoid a race condition situation between a
+        // global-to-local request and the release of the barrier. In
+        // such situation, for multi-flit packets, some flits may be
+        // dropped and others not.
+        if (m_barrier && m_barrier_release && !input_port[m_in_size-1]->getVal())
+        {
+            m_barrier = false;
+        }
     } // end transition
 
@@ -310,8 +330,10 @@
                 // incoming packet (send the acknowledgement to the input port)
                 // and resetting the cmdval signal to the upper network level.
+                // When there is a barrier release request, local-to-global
+                // request are allowed.
                 bool read = output_port[out]->getAck();
                 if (out == (m_out_size - 1)) {
-                    read = read || m_barrier;
-                    tmp.set_val(tmp.val() && !m_barrier);
+                    read = read || (m_barrier && !m_barrier_release);
+                    tmp.set_val(tmp.val() && (!m_barrier || m_barrier_release));
                 }
 
@@ -362,9 +384,11 @@
     }
 
-    if (p_barrier_enable != NULL)
-    {
-        const bool enable = (p_barrier_enable->read() != 0xFFFFFFFF);
-        m_cmd_crossbar->setBarrier(enable);
-        m_rsp_crossbar->setBarrier(enable);
+    if ( p_barrier_enable != NULL )
+    {
+        if ( p_barrier_enable->read() == 0xFFFFFFFF )
+        {
+            m_cmd_crossbar->releaseBarrier();
+            m_rsp_crossbar->releaseBarrier();
+        }
     }
     m_cmd_crossbar->transition( m_ports_to_initiator, m_ports_to_target );
@@ -432,5 +456,6 @@
                          (void*)(&m_cmd_rt),
                          (void*)(&m_cmd_lt),
-                         true );
+                         true,
+                         hardware_barrier );
 
 	m_rsp_crossbar = new SimpleCrossbar<VciRspBuffer<vci_param> >(
@@ -440,5 +465,6 @@
                          (void*)(&m_rsp_rt),
                          (void*)(&m_rsp_lt),
-                         false );
+                         false,
+                         hardware_barrier );
 
     m_ports_to_initiator = new VciTarget<vci_param>*[nb_attached_initiators+1];
