Date: Tue, 15 Jan 2008 22:30:26 +0200 From: Stefan Lambrev <stefan.lambrev@moneybookers.com> To: Hans Petter Selasky <hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: [SOLVED] Re: Problem with usb4bsd rev566 Message-ID: <478D17E2.5000908@moneybookers.com> In-Reply-To: <200801152048.54719.hselasky@c2i.net> References: <477BC1A3.5080406@moneybookers.com> <478CE165.7060001@moneybookers.com> <478CFBBB.20905@moneybookers.com> <200801152048.54719.hselasky@c2i.net>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------050706000207050002030200 Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit 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 --------------050706000207050002030200 Content-Type: text/x-patch; name="usb_transfer.c.new.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="usb_transfer.c.new.diff" --- 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 { --------------050706000207050002030200--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?478D17E2.5000908>