Code cleanup:
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 8 Apr 2007 09:41:41 +0000 (09:41 +0000)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 8 Apr 2007 09:41:41 +0000 (09:41 +0000)
commitbd137025b150a2500d2ecb995c6cb94b960e5809
treec36cdc45fc48740011ace9633d69b66e47851a15
parent5a45598c2c3b39d071ba626ab142a8ef72e50949
Code cleanup:
- Nuke commented out spl*() and function declaration.
- Break long comment lines in rum_ioctl().
- Nuke unnecessary NULL node check in rum_start().

Resource alloc/free fixes and cleanup:
- Fix several resource leakages:
  o  In rum_start(), decrease node refcnt on error handling path.
  o  In rum_stop(), free rum_softc.stats_xfer.
  o  In rum_tx_free_list(), free possible pending TX mbuf.
- In rum_tx_data(), if usbd_transfer() fails, clear rum_tx_data.m and
  rum_tx_data.ni, so later resource free routine will not double free
  them.
- Change the redundant resource free code in rum_detach() into assertion
  to make sure everything are clear.
- In rum_alloc_{tx,rx}_list(), don't call rum_free_{tx,rx}_list, if
  error happens, since caller will do that in rum_stop().

Rest of changes are used to fix following problems:
1) Random system hanging if following script is excuted:
   #!/bin/csh
   while (1)
     ifconfig rum0 up
     ifconfig rum0 down
   end
2) Random system hanging during 'ifconfig rum0 down', if rum(4) is
   attached to uhci/ohci.
3) Promised system hanging if wpa_supplicant(8) is used and killed after
   connection to AP is established, and rum(4) is attached to uhci/ohci.
4) Random serializer recursive assertion, if rum(4) is under heavy load
   and brought down.

- In rum_stop(), turn on RUM_FLAG_STOPPED, so USB transanction will
  not be restarted in rum_rxeof() and rum_stats_timeout() during device
  halting.
- In rum_stop(), release ifnet.if_serializer before aborting RX/TX pipe.
  This make sure serializer will not be recursive held,
  e.g. abort RX pipe -> rum_rxeof().
- Don't turn off TSF sync, when 802.11 state transits to INIT.  Since
  o  Chip will be reset immediately after INIT state transition, so
     turning off TSF sync does not make much sense.
  o  If rum(4) is under heavy RX/TX load, turning off TSF sync will
     stall various USB operations, thus hang the whole system.
- After above change, perform INIT state transition in rum_newstate(),
  so that 802.11 state machine is promised to be halted during detach
  and stop routine.
- Use critical section and RUM_FLAG_CONFIG to protect various USB operation
  sequences, which are not intended to be interfered.
sys/dev/netif/rum/if_rum.c
sys/dev/netif/rum/if_rumvar.h