Subject: CVS commit: src/sys/dev/ic
To: None <source-changes@NetBSD.org>
From: David Young <dyoung@netbsd.org>
List: source-changes
Date: 12/13/2004 17:55:28
Module Name:	src
Committed By:	dyoung
Date:		Mon Dec 13 17:55:28 UTC 2004

Modified Files:
	src/sys/dev/ic: wi.c wivar.h

Log Message:
Bug fix: synchronize Transmit commands with all other commands.

Following Charles Hannum's wi(4) optimizations, there could be a
Transmit command outstanding after wi_tx_intr or wi_start returns.
The driver would blithely issue a second command [*] before the
first command was finished, taking the first command's WI_EV_CMD
indication to mean the second command had finished.  The driver
would be dreadfully confused when the second command's results did
not meet its expectations (e.g., a RID mismatch error would occur).
The packet transmit section of the code would never read the
WI_EV_CMD it expected, so transmissions would cease.

This patch counts the outstanding transmit commands (there can be
only one) and, if a transmit command is outstanding at the top of
wi_cmd(), wi_cmd waits for the command to complete.  If there was
a transmit command outstanding when wi_cmd begins, it calls
wi_cmd_intr() on its way out.

I have tested this on an Orinoco card.  Previously, the card would
stop transmitting or the kernel would panic as desynchronization
occurred.  Now it works beautifully.

[*] A second command could be issued by wi_ioctl or else by
    wi_intr->wi_info_intr->wi_newstate->wi_read_xrid->wi_read_rid.


To generate a diff of this commit:
cvs rdiff -r1.191 -r1.192 src/sys/dev/ic/wi.c
cvs rdiff -r1.52 -r1.53 src/sys/dev/ic/wivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.