RT73 ARM LINUX freeze up in RTUSBDequeueRxPackets

Live forum: http://rt2x00.serialmonkey.com/viewtopic.php?t=5131


19-12-2008 11:48:14

I am porting the rx2000's rt73 driver to ARM Linux 2.6.20 version, using rt73-cvs-2008093011 version.

I fixed some algnment issues in that cvs version and get it work on OPEN network. But on WEP network ,Linux still freezed up in function RTUSBDequeueRxPackets.

In RTUSBDequeueRxPackets, below condition checking is used.
if (atomic_read(&pRxContext->IrpLock) != IRPLOCK_COMPLETED[/color2958of51] ||pRxContext->InUse == FALSE[/color2958of51])
In my understanding, "break" should be call only for such condition if URB is submitted and not completed yet, then while loop should break and wait for the URB's completion.

RTUSBBulkReceive tells that these 2 condition checking can not be true at the same time
atomic_set(&pRxContext->IrpLock, IRPLOCK_CANCELABLE);
if((ret = rtusb_submit_urb(pUrb)) == 0) {
pRxContext->InUse = TRUE;
pAd->NextRxBulkInIndex = (pAd->NextRxBulkInIndex+1) % RX_RING_SIZE;
else { // -EPIPE -> disconnected
atomic_set(&pRxContext->IrpLock, IRPLOCK_COMPLETED);

But acctually I found that both of these two conditions can be true at the same time. When IrpLock!=IRPLOCK_COMPLETED, InUse still can be false!!! What does this mean? And how could this happen?

Why don't we use
if (atomic_read(&pRxContext->IrpLock) != IRPLOCK_COMPLETED &&[/color2958of51]pRxContext->InUse == TRUE[/color2958of51])

Maybe I have not understand the code very well yet.
I found when using "&&" here, Linux will not freeze up any more. But I trace out the root cause.

Thanks if anybody could help me.


20-12-2008 17:19:13

Hi cholottoboy,

Reviewed the code, and as far as I can tell, it looks OK. (Doesn't mean it is OK, just that it looks OK to me.) The InUse flag is set and cleared only - mostly - by functions which are called from the handler thread (but see RTUSBBulkRxComplete()). SMP safety is provided by a semaphore that is set prior to the calls, thereby serializing them.

Could you compile and run with debug enabled, then attach a gzipped copy of /var/log/kern.log for the interval in which the freeze up happens to a post here?