From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10338 invoked by alias); 16 Feb 2006 16:15:29 -0000 Received: (qmail 10330 invoked by uid 22791); 16 Feb 2006 16:15:28 -0000 X-Spam-Check-By: sourceware.org Received: from tomts43-srv.bellnexxia.net (HELO tomts43-srv.bellnexxia.net) (209.226.175.110) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 16 Feb 2006 16:15:27 +0000 Received: from derekwin ([69.159.205.41]) by tomts43-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20060216161521.EVVS4713.tomts43-srv.bellnexxia.net@derekwin>; Thu, 16 Feb 2006 11:15:21 -0500 From: "Derek Bouius" To: , Cc: Date: Thu, 16 Feb 2006 16:15:00 -0000 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0018_01C632EA.490C8090" Message-Id: <20060216161521.EVVS4713.tomts43-srv.bellnexxia.net@derekwin> Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: [ECOS] How to debug synchronisation in the usbs.c in a new usb-driver for the ARM at91sam7s... X-SW-Source: 2006-02/txt/msg00156.txt.bz2 ------=_NextPart_000_0018_01C632EA.490C8090 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Content-length: 296 I am not registered for the mailing list, but peruse it once in a while, so I am not sure if my mail will go through to it. Feel free to repost it if it doesn't. What we did to fix the locking issue was change the mutex to a semaphore. See the patch. It seems to work reliably. Cheers, Derek ------=_NextPart_000_0018_01C632EA.490C8090 Content-Type: application/octet-stream; name="usbs.c.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="usbs.c.patch" Content-length: 3179 --- usbs_orig.c 2006-02-16 10:41:13.000000000 -0500=0A= +++ usbs.c 2006-02-06 13:28:12.000000000 -0500=0A= @@ -70,17 +70,17 @@=0A= typedef struct usbs_callback_data {=0A= bool completed;=0A= int result;=0A= - cyg_drv_mutex_t lock;=0A= - cyg_drv_cond_t signal;=0A= + cyg_sem_t sem;=0A= } usbs_callback_data;=0A= =20=0A= +=0A= static void=0A= usbs_devtab_callback(void* arg, int result)=0A= {=0A= usbs_callback_data* callback_data =3D (usbs_callback_data*) arg;=0A= callback_data->result =3D result;=0A= callback_data->completed =3D true;=0A= - cyg_drv_cond_signal(&(callback_data->signal));=0A= + cyg_semaphore_post(&(callback_data->sem));=0A= }=0A= =20=20=20=20=20=0A= Cyg_ErrNo=0A= @@ -94,8 +94,7 @@=0A= CYG_REPORT_FUNCTION();=0A= =20=20=20=20=20=0A= wait.completed =3D 0;=0A= - cyg_drv_mutex_init(&wait.lock);=0A= - cyg_drv_cond_init(&wait.signal, &wait.lock);=0A= + cyg_semaphore_init(&wait.sem, 0);=0A= =20=0A= devtab_entry =3D (cyg_devtab_entry_t*) handle;=0A= CYG_CHECK_DATA_PTR( devtab_entry, "A valid endpoint must be supplied")= ;=0A= @@ -110,19 +109,16 @@=0A= endpoint->complete_data =3D (void*) &wait;=0A= (*endpoint->start_tx_fn)(endpoint);=0A= =20=20=20=20=20=0A= - cyg_drv_mutex_lock(&wait.lock);=0A= while (!wait.completed) {=0A= - cyg_drv_cond_wait(&wait.signal);=0A= + cyg_semaphore_wait(&wait.sem);=0A= }=0A= - cyg_drv_mutex_unlock(&wait.lock);=0A= if (wait.result < 0) {=0A= result =3D wait.result;=0A= } else {=0A= *size =3D wait.result;=0A= }=0A= =20=20=20=20=20=0A= - cyg_drv_cond_destroy(&wait.signal);=0A= - cyg_drv_mutex_destroy(&wait.lock);=0A= + cyg_semaphore_destroy(&wait.sem);=0A= =20=0A= CYG_REPORT_RETURN();=0A= return result;=0A= @@ -139,8 +135,7 @@=0A= CYG_REPORT_FUNCTION();=0A= =20=20=20=20=20=0A= wait.completed =3D 0;=0A= - cyg_drv_mutex_init(&wait.lock);=0A= - cyg_drv_cond_init(&wait.signal, &wait.lock);=0A= + cyg_semaphore_init(&wait.sem, 0);=0A= =20=0A= devtab_entry =3D (cyg_devtab_entry_t*) handle;=0A= CYG_CHECK_DATA_PTR( devtab_entry, "A valid endpoint must be supplied")= ;=0A= @@ -153,20 +148,18 @@=0A= endpoint->buffer_size =3D (int) *size;=0A= endpoint->complete_fn =3D &usbs_devtab_callback;=0A= endpoint->complete_data =3D (void*) &wait;=0A= +=0A= (*endpoint->start_rx_fn)(endpoint);=0A= - cyg_drv_mutex_lock(&wait.lock);=0A= while (!wait.completed) {=0A= - cyg_drv_cond_wait(&wait.signal);=0A= + cyg_semaphore_wait(&wait.sem);=0A= }=0A= - cyg_drv_mutex_unlock(&wait.lock);=0A= if (wait.result < 0) {=0A= result =3D wait.result;=0A= } else {=0A= *size =3D wait.result;=0A= }=0A= =20=20=20=20=20=0A= - cyg_drv_cond_destroy(&wait.signal);=0A= - cyg_drv_mutex_destroy(&wait.lock);=0A= + cyg_semaphore_destroy(&wait.sem);=0A= =20=0A= CYG_REPORT_RETURN();=0A= return result;=0A= @@ -409,6 +402,64 @@=0A= }=0A= }=0A= =20=0A= =0A= ------=_NextPart_000_0018_01C632EA.490C8090 Content-Type: text/plain; charset=us-ascii Content-length: 148 -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ------=_NextPart_000_0018_01C632EA.490C8090--