Index: uspace/lib/usb/include/usb/pipes.h
===================================================================
--- uspace/lib/usb/include/usb/pipes.h	(revision a546687aac830d43eba7e840773f61e4c01e5a31)
+++ uspace/lib/usb/include/usb/pipes.h	(revision d48fcc00df46e4e3afbc3f5b4f3a2ca8ae0495cc)
@@ -60,6 +60,14 @@
  * This endpoint must be bound with existing usb_device_connection_t
  * (i.e. the wire to send data over).
+ *
+ * Locking order: if you want to lock both mutexes
+ * (@c guard and @c hc_phone_mutex), lock @c guard first.
+ * It is not necessary to lock @c guard if you want to lock @c hc_phone_mutex
+ * only.
  */
 typedef struct {
+	/** Guard of the whole pipe. */
+	fibril_mutex_t guard;
+
 	/** The connection used for sending the data. */
 	usb_device_connection_t *wire;
@@ -79,4 +87,8 @@
 	/** Phone to the host controller.
 	 * Negative when no session is active.
+	 * It is an error to access this member without @c hc_phone_mutex
+	 * being locked.
+	 * If call over the phone is to be made, it must be preceeded by
+	 * call to pipe_add_ref() [internal libusb function].
 	 */
 	int hc_phone;
Index: uspace/lib/usb/src/pipepriv.c
===================================================================
--- uspace/lib/usb/src/pipepriv.c	(revision a546687aac830d43eba7e840773f61e4c01e5a31)
+++ uspace/lib/usb/src/pipepriv.c	(revision d48fcc00df46e4e3afbc3f5b4f3a2ca8ae0495cc)
@@ -42,5 +42,5 @@
  * @param pipe Pipe to be exclusively accessed.
  */
-void pipe_acquire(usb_pipe_t *pipe)
+void pipe_start_transaction(usb_pipe_t *pipe)
 {
 	fibril_mutex_lock(&pipe->hc_phone_mutex);
@@ -51,7 +51,25 @@
  * @param pipe Pipe to be released from exclusive usage.
  */
+void pipe_end_transaction(usb_pipe_t *pipe)
+{
+	fibril_mutex_unlock(&pipe->hc_phone_mutex);
+}
+
+/** Ensure exclusive access to the pipe as a whole.
+ *
+ * @param pipe Pipe to be exclusively accessed.
+ */
+void pipe_acquire(usb_pipe_t *pipe)
+{
+	fibril_mutex_lock(&pipe->guard);
+}
+
+/** Terminate exclusive access to the pipe as a whole.
+ *
+ * @param pipe Pipe to be released from exclusive usage.
+ */
 void pipe_release(usb_pipe_t *pipe)
 {
-	fibril_mutex_unlock(&pipe->hc_phone_mutex);
+	fibril_mutex_unlock(&pipe->guard);
 }
 
@@ -76,4 +94,8 @@
 			goto another_try;
 		}
+		/*
+		 * No locking is needed, refcount is zero and whole pipe
+		 * mutex is locked.
+		 */
 		pipe->hc_phone = phone;
 	}
Index: uspace/lib/usb/src/pipepriv.h
===================================================================
--- uspace/lib/usb/src/pipepriv.h	(revision a546687aac830d43eba7e840773f61e4c01e5a31)
+++ uspace/lib/usb/src/pipepriv.h	(revision d48fcc00df46e4e3afbc3f5b4f3a2ca8ae0495cc)
@@ -41,4 +41,7 @@
 void pipe_release(usb_pipe_t *);
 
+void pipe_start_transaction(usb_pipe_t *);
+void pipe_end_transaction(usb_pipe_t *);
+
 int pipe_add_ref(usb_pipe_t *);
 void pipe_drop_ref(usb_pipe_t *);
Index: uspace/lib/usb/src/pipesinit.c
===================================================================
--- uspace/lib/usb/src/pipesinit.c	(revision a546687aac830d43eba7e840773f61e4c01e5a31)
+++ uspace/lib/usb/src/pipesinit.c	(revision d48fcc00df46e4e3afbc3f5b4f3a2ca8ae0495cc)
@@ -356,4 +356,5 @@
 	assert(connection);
 
+	fibril_mutex_initialize(&pipe->guard);
 	pipe->wire = connection;
 	pipe->hc_phone = -1;
Index: uspace/lib/usb/src/pipesio.c
===================================================================
--- uspace/lib/usb/src/pipesio.c	(revision a546687aac830d43eba7e840773f61e4c01e5a31)
+++ uspace/lib/usb/src/pipesio.c	(revision d48fcc00df46e4e3afbc3f5b4f3a2ca8ae0495cc)
@@ -80,5 +80,5 @@
 
 	/* Ensure serialization over the phone. */
-	pipe_acquire(pipe);
+	pipe_start_transaction(pipe);
 
 	/*
@@ -91,5 +91,5 @@
 	    NULL);
 	if (opening_request == 0) {
-		pipe_release(pipe);
+		pipe_end_transaction(pipe);
 		return ENOMEM;
 	}
@@ -106,5 +106,5 @@
 	 * without breaking the transfer IPC protocol.
 	 */
-	pipe_release(pipe);
+	pipe_end_transaction(pipe);
 
 	if (data_request == 0) {
@@ -227,5 +227,5 @@
 
 	/* Ensure serialization over the phone. */
-	pipe_acquire(pipe);
+	pipe_start_transaction(pipe);
 
 	/*
@@ -238,5 +238,5 @@
 	    NULL);
 	if (opening_request == 0) {
-		pipe_release(pipe);
+		pipe_end_transaction(pipe);
 		return ENOMEM;
 	}
@@ -251,5 +251,5 @@
 	 * without breaking the transfer IPC protocol.
 	 */
-	pipe_release(pipe);
+	pipe_end_transaction(pipe);
 
 	if (rc != EOK) {
@@ -326,5 +326,5 @@
 {
 	/* Ensure serialization over the phone. */
-	pipe_acquire(pipe);
+	pipe_start_transaction(pipe);
 
 	/*
@@ -346,5 +346,5 @@
 	    setup_buffer, setup_buffer_size);
 	if (rc != EOK) {
-		pipe_release(pipe);
+		pipe_end_transaction(pipe);
 		async_wait_for(opening_request, NULL);
 		return rc;
@@ -363,5 +363,5 @@
 	 * without breaking the transfer IPC protocol.
 	 */
-	pipe_release(pipe);
+	pipe_end_transaction(pipe);
 
 
@@ -468,5 +468,5 @@
 {
 	/* Ensure serialization over the phone. */
-	pipe_acquire(pipe);
+	pipe_start_transaction(pipe);
 
 	/*
@@ -480,5 +480,5 @@
 	    NULL);
 	if (opening_request == 0) {
-		pipe_release(pipe);
+		pipe_end_transaction(pipe);
 		return ENOMEM;
 	}
@@ -490,5 +490,5 @@
 	    setup_buffer, setup_buffer_size);
 	if (rc != EOK) {
-		pipe_release(pipe);
+		pipe_end_transaction(pipe);
 		async_wait_for(opening_request, NULL);
 		return rc;
@@ -503,5 +503,5 @@
 
 		/* All data sent, pipe can be released. */
-		pipe_release(pipe);
+		pipe_end_transaction(pipe);
 
 		if (rc != EOK) {
@@ -511,5 +511,5 @@
 	} else {
 		/* No data to send, we can release the pipe for others. */
-		pipe_release(pipe);
+		pipe_end_transaction(pipe);
 	}
 
