Hi Hans,

Thanks for your response.
I'm little puzzled right now :)

I'm looking at i4b/trunk/i4b/src/sys/dev/usb/usb_transfer.c
The logic in rev 566 in case 4 is to call
               usbd_callback_wrapper(xfer[0], info, USBD_CONTEXT_CALLBACK);
               usbd_callback_wrapper(xfer[1], info, USBD_CONTEXT_CALLBACK);
               usbd_callback_wrapper(xfer[2], info, USBD_CONTEXT_CALLBACK);
               usbd_callback_wrapper(xfer[3], info, USBD_CONTEXT_CALLBACK);

not just: usbd_callback_wrapper(xfer[3], info, USBD_CONTEXT_CALLBACK);

Am I right?

If yes please consider the attached patch (the patch is against rev 566) - it will remove lockcheck_0/1 lables, all "goto" to them and uint8_t dropcount; is not not needed (less needed memory?)

Also for i4b/trunk/i4b/src/sys/dev/usb/usb_port.h
#define thread_lock(td) mtx_lock_spin(&sched_lock)
#define thread_unlock(td) mtx_unlock_spin(&sched_lock)

Those should not be defined as they are already defined in sys/sys/mutex.h - Revision 1.96 (which is part of RELENG_7 and RELENG_7_0) and the code will not compile, thus the need of special case for versions >= 700000 and < 800000

Hans Petter Selasky wrote:
Hi Stefan,

Your patches have been committed with some modifications. Please check if the code compiles now. Thanks for reporting!

--HPS

--

Best Wishes,
Stefan Lambrev
ICQ# 24134177

--- i4b/trunk/i4b/src/sys/dev/usb/usb_transfer.c	2008-01-15 19:47:11.000000000 +0200
+++ 566/i4b/trunk/i4b/src/sys/dev/usb/usb_transfer.c	2008-01-15 21:53:16.000000000 +0200
@@ -2093,7 +2093,7 @@
 	struct usbd_memory_info *info = arg;
 	struct usbd_xfer *xfer[4];
 	struct thread *td;
-	uint8_t dropcount;
+//	uint8_t dropcount;
 
 	/* adjust priority */
 	td = curthread;
@@ -2114,54 +2114,56 @@
 		xfer[0]->done_list.le_prev = NULL;
 		xfer[1] = LIST_FIRST(&(info->done_head));
 		if (xfer[1] == NULL) {
-			dropcount = 1;
-			goto lockchange_0;
+//			dropcount = 1;
+			mtx_unlock(info->usb_mtx);
+			mtx_lock(info->priv_mtx);
+			usbd_callback_wrapper(xfer[0], info, USBD_CONTEXT_CALLBACK);
+			mtx_unlock(info->priv_mtx);
+			mtx_lock(info->usb_mtx);
+			info->memory_refcount -= 1;
+			goto repeat;
 		}
 		LIST_REMOVE(xfer[1], done_list);
 		xfer[1]->done_list.le_prev = NULL;
 		xfer[2] = LIST_FIRST(&(info->done_head));
 		if (xfer[2] == NULL) {
-			dropcount = 2;
-			goto lockchange_0;
+//			dropcount = 2;
+			mtx_unlock(info->usb_mtx);
+			mtx_lock(info->priv_mtx);
+			usbd_callback_wrapper(xfer[0], info, USBD_CONTEXT_CALLBACK);
+			usbd_callback_wrapper(xfer[1], info, USBD_CONTEXT_CALLBACK);
+			mtx_unlock(info->priv_mtx);
+			mtx_lock(info->usb_mtx);
+			info->memory_refcount -= 2;
+			goto repeat;
 		}
 		LIST_REMOVE(xfer[2], done_list);
 		xfer[2]->done_list.le_prev = NULL;
 		xfer[3] = LIST_FIRST(&(info->done_head));
 		if (xfer[3] == NULL) {
-			dropcount = 3;
-			goto lockchange_0;
+//			dropcount = 3;
+			mtx_unlock(info->usb_mtx);
+			mtx_lock(info->priv_mtx);
+			usbd_callback_wrapper(xfer[0], info, USBD_CONTEXT_CALLBACK);
+			usbd_callback_wrapper(xfer[1], info, USBD_CONTEXT_CALLBACK);
+			usbd_callback_wrapper(xfer[2], info, USBD_CONTEXT_CALLBACK);
+			mtx_unlock(info->priv_mtx);
+			mtx_lock(info->usb_mtx);
+			info->memory_refcount -= 3;
+			goto repeat;
 		}
 		LIST_REMOVE(xfer[3], done_list);
 		xfer[3]->done_list.le_prev = NULL;
-		dropcount = 4;
-lockchange_0:
+//		dropcount = 4;
 		mtx_unlock(info->usb_mtx);
-
-		/*
-		 * we exploit the fact that the mutex is the same for
-		 * all callbacks
-		 */
 		mtx_lock(info->priv_mtx);
-
-		/* call callback(s) */
 		usbd_callback_wrapper(xfer[0], info, USBD_CONTEXT_CALLBACK);
-		if (xfer[1] == NULL) {
-			goto lockchange_1;
-		}
 		usbd_callback_wrapper(xfer[1], info, USBD_CONTEXT_CALLBACK);
-		if (xfer[2] == NULL) {
-			goto lockchange_1;
-		}
 		usbd_callback_wrapper(xfer[2], info, USBD_CONTEXT_CALLBACK);
-		if (xfer[3] == NULL) {
-			goto lockchange_1;
-		}
 		usbd_callback_wrapper(xfer[3], info, USBD_CONTEXT_CALLBACK);
-lockchange_1:
 		mtx_unlock(info->priv_mtx);
-
 		mtx_lock(info->usb_mtx);
-		info->memory_refcount -= dropcount;
+		info->memory_refcount -= 4;
 		goto repeat;
 
 	} else {
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to