From owner-freebsd-usb@FreeBSD.ORG Tue Jan 15 20:30:31 2008 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4E4F816A480 for ; Tue, 15 Jan 2008 20:30:31 +0000 (UTC) (envelope-from stefan.lambrev@moneybookers.com) Received: from blah.sun-fish.com (blah.sun-fish.com [217.18.249.150]) by mx1.freebsd.org (Postfix) with ESMTP id E726313C4D5 for ; Tue, 15 Jan 2008 20:30:30 +0000 (UTC) (envelope-from stefan.lambrev@moneybookers.com) Received: by blah.sun-fish.com (Postfix, from userid 1002) id 473E71B10EF4; Tue, 15 Jan 2008 21:30:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on blah.cmotd.com X-Spam-Level: X-Spam-Status: No, score=-10.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, J_CHICKENPOX_33 autolearn=no version=3.2.3 Received: from hater.haters.org (unknown [192.168.25.10]) by blah.sun-fish.com (Postfix) with ESMTP id 799951B10EA4; Tue, 15 Jan 2008 21:30:26 +0100 (CET) Message-ID: <478D17E2.5000908@moneybookers.com> Date: Tue, 15 Jan 2008 22:30:26 +0200 From: Stefan Lambrev User-Agent: Thunderbird 2.0.0.9 (X11/20071120) MIME-Version: 1.0 To: Hans Petter Selasky References: <477BC1A3.5080406@moneybookers.com> <478CE165.7060001@moneybookers.com> <478CFBBB.20905@moneybookers.com> <200801152048.54719.hselasky@c2i.net> In-Reply-To: <200801152048.54719.hselasky@c2i.net> Content-Type: multipart/mixed; boundary="------------050706000207050002030200" X-Virus-Scanned: ClamAV 0.91.2/5483/Mon Jan 14 15:45:01 2008 on blah.cmotd.com X-Virus-Status: Clean Cc: freebsd-usb@freebsd.org Subject: Re: [SOLVED] Re: Problem with usb4bsd rev566 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2008 20:30:31 -0000 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--