diff options
author | Cyrille Pitchen <cyrille.pitchen@atmel.com> | 2016-01-15 15:49:32 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-01-25 22:42:07 +0800 |
commit | f56809c3c6059327aad3e0718bca9c6c756386f6 (patch) | |
tree | 2b756764948336a43aa0b387435d8578fbfa5e6f /drivers/rtc | |
parent | 1900c583c8e24df9d07282598166279187dce832 (diff) | |
download | linux-stable-f56809c3c6059327aad3e0718bca9c6c756386f6.tar.gz linux-stable-f56809c3c6059327aad3e0718bca9c6c756386f6.tar.bz2 linux-stable-f56809c3c6059327aad3e0718bca9c6c756386f6.zip |
crypto: atmel-sha - fix a race between the 'done' tasklet and the crypto client
The 'done' tasklet handler used to check the 'BUSY' flag to either
finalize the processing of a crypto request which had just completed or
manage the crypto queue to start the next crypto request.
On request R1 completion, the driver calls atmel_sha_finish_req(), which:
1 - clears the 'BUSY' flag since the hardware is no longer used and is
ready again to process new crypto requests.
2 - notifies the above layer (the client) about the completion of the
asynchronous crypto request R1 by calling its base.complete()
callback.
3 - schedules the 'done' task to check the crypto queue and start to
process the next crypto request (the 'BUSY' flag is supposed to be
cleared at that moment) if such a pending request exists.
However step 2 might wake the client up so it can now ask our driver to
process a new crypto request R2. This request is enqueued by calling the
atmel_sha_handle_queue() function, which sets the 'BUSY' flags then
starts to process R2.
If the 'done' tasklet, scheduled by step 3, runs just after, it would see
that the 'BUSY' flag is set then understand that R2 has just completed,
which is wrong!
So the state of 'BUSY' flag is not a proper way to detect and handle
crypto request completion.
This patch fixes this race condition by using two different tasklets, one
to handle the crypto request completion events, the other to manage the
crypto queue if needed.
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/rtc')
0 files changed, 0 insertions, 0 deletions