mmc: card: fix race with shutdown handler
There could be 2 different race conditions possible with current shutdown
handler:
1. Shutdown handler sees that there is no request in queue but mmc-cmdqd
might have fetched the request from queue and about to issue it to
driver.
2. Shutdown handler keeps looping in the while(1) loop as it sees request
being pending in the request queue. But mmc-cmdqd thread doesn't wake up
to fetch the requests from the request queue. mmc-cmdqd thread isn't
waking up because shutdown path has stopped queue and request came into
the queue after that. Once queue is stopped, block layer won't invoke
the queue's ->request_fn() callback to notify driver about pending
request.
Remedy to fix both these race condition is simple. In shutdown handler,
make sure that we drain (& complete) all the outstanding requests from the
queue and then don't allow any new requests to be queued. Block layer API
blk_cleanup_queue() precisely does what we want and this change basically
use the same API in shutdown handler.
Change-Id: I761ba6a2e2974d955bb72ff993b1cc2c32c9ec29
Signed-off-by:
Subhash Jadavani <subhashj@codeaurora.org>
Loading
Please register or sign in to comment