From owner-freebsd-usb@FreeBSD.ORG Sun Feb 1 18:58:43 2009 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 88C44106566C; Sun, 1 Feb 2009 18:58:43 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe12.tele2.se [212.247.155.97]) by mx1.freebsd.org (Postfix) with ESMTP id BB0688FC25; Sun, 1 Feb 2009 18:58:42 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=udjUD6xBrwDHYV7nuwMA:9 a=OGzQZI-EeMsMZk_S9PgA:7 a=ci9iTQ_1ku-QdqMyLcObrxoMfO0A:4 a=50e4U0PicR4A:10 Received: from [85.19.218.115] (account mc467741@c2i.net HELO [10.37.1.92]) by mailfe12.swip.net (CommuniGate Pro SMTP 5.2.6) with ESMTPA id 1016887440; Sun, 01 Feb 2009 19:58:40 +0100 From: Hans Petter Selasky To: freebsd-usb@freebsd.org Date: Sun, 1 Feb 2009 20:01:05 +0100 User-Agent: KMail/1.9.7 References: <200902011220.18745.hselasky@c2i.net> <20090201.112756.1320088159.imp@bsdimp.com> <200902011938.48670.hselasky@c2i.net> In-Reply-To: <200902011938.48670.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200902012001.06914.hselasky@c2i.net> Cc: thompsa@freebsd.org Subject: Re: USB2 patches 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: Sun, 01 Feb 2009 18:58:43 -0000 Hi Andrew, Regarding using taskqueues. Yes - USB2 can use taskqueues, but I would very much like to have the original queueing mechanism intact. How about: struct task * tasqueue_enqueue_pair(struct taskqueue *queue, struct task *t0, struct task *t1); Which does something similar to this: void * usb2_proc_msignal(struct usb2_process *up, void *_pm0, void *_pm1) { struct usb2_proc_msg *pm0 = _pm0; struct usb2_proc_msg *pm1 = _pm1; struct usb2_proc_msg *pm2; uint32_t d; uint8_t t; mtx_assert(up->up_mtx, MA_OWNED); t = 0; if (pm0->pm_qentry.tqe_prev) { t |= 1; } if (pm1->pm_qentry.tqe_prev) { t |= 2; } if (t == 0) { /* * No entries are queued. Queue "pm0" and use the existing * message number. */ pm2 = pm0; } else if (t == 1) { /* Check if we need to increment the message number. */ if (pm0->pm_num == up->up_msg_num) { up->up_msg_num++; } pm2 = pm1; } else if (t == 2) { /* Check if we need to increment the message number. */ if (pm1->pm_num == up->up_msg_num) { up->up_msg_num++; } pm2 = pm0; } else if (t == 3) { /* * Both entries are queued. Re-queue the entry closest to * the end. */ d = (pm1->pm_num - pm0->pm_num); /* Check sign after subtraction */ if (d & 0x80000000) { pm2 = pm0; } else { pm2 = pm1; } TAILQ_REMOVE(&up->up_qhead, pm2, pm_qentry); } else { pm2 = NULL; /* panic - should not happen */ } DPRINTF(" t=%u, num=%u\n", t, up->up_msg_num); /* Put message last on queue */ pm2->pm_num = up->up_msg_num; TAILQ_INSERT_TAIL(&up->up_qhead, pm2, pm_qentry); /* Check if we need to wakeup the USB process. */ if (up->up_msleep) { up->up_msleep = 0; /* save "cv_signal()" calls */ usb2_cv_signal(&up->up_cv); } return (pm2); } --HPS