]> git.baikalelectronics.ru Git - kernel.git/commit
carl9170: Fix wrong completion usage
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Thu, 18 Aug 2016 13:12:05 +0000 (15:12 +0200)
committerKalle Valo <kvalo@qca.qualcomm.com>
Fri, 9 Sep 2016 12:15:28 +0000 (15:15 +0300)
commitdc72ac19de50af13a84824e54f8a74dc93623c60
treea65d4d02671cfc506722ae2cb1d222ddf65b920c
parent15532a750f504c51a9d6cc117ea55bdf5712d981
carl9170: Fix wrong completion usage

carl9170_usb_stop() is used from several places to flush and cleanup any
pending work. The normal pattern is to send a request and wait for the
irq handler to call complete(). The completion is not reinitialized
during normal operation and as the old comment indicates it is important
to keep calls to wait_for_completion_timeout() and complete() balanced.

Calling complete_all() brings this equilibirum out of balance and needs
to be fixed by a reinit_completion(). But that opens a small race
window. It is possible that the sequence of complete_all(),
reinit_completion() is faster than the wait_for_completion_timeout() can
do its work. The wake up is not lost but the done counter test is after
reinit_completion() has been executed. The only reason we don't see
carl9170_exec_cmd() hang forever is we use the timeout version of
wait_for_copletion().

Let's fix this by reinitializing the completion (that is just setting
done counter to 0) just before we send out an request. Now,
carl9170_usb_stop() can be sure a complete() call is enough to make
progess since there is only one waiter at max. This is a common pattern
also seen in various drivers which use completion.

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/carl9170/usb.c