crypto: msm: Use scnprintf() instead of snprintf()

snprintf can return more than the size of buffer, which is not
expected here, obviously. Use scnprintf instead.

Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
crypto: msm: Add debug log

Add MACRO for writel_relaxed that output register
settings.

Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
crypto: msm: Add aead hmac-sha256 support

Add support for authenc(hmac(sha256), cbc(des)) and authenc(hmac(sha256),
cbc(aes)) and authenc(hmac(sha256), cbc(des3_ede))

Remove dead code of #ifdef CRYPTO_AEAD_AES_CTR #endif
block in qcrypto and AEAD aes/des/3des ECB mode in qce50. They will
never happen for aead operations.

Stats are cleaned up. Three groups of stats for ABLK, AEAD, and AHASH
operations are managed, and displayed in each group.

Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
crypto: msm: fix aes counter issue

Counter Mask registers are not initialized for 128 bits of counter.
As the result, some test vector of aes(ctr) may fail.

Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
crypto: msm: Fix Crypto BAM issue for 64bit

Fixes the crypto BAM issue while running the qcedev_test from usersapce.
BAM command descriptors opcode wrongly going to Crypto BAM hardware. This
patch corrects the issue by seting the opcode to zero.

Also fixes CMAC IOCTL definition with proper struct type.

Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
crypto: msm: Check the return value of cmdlistinfo

The functions _ce_get_cipher_cmdlistinfo() and _ce_get_hash_cmdlistinfo()
may return NULL and dereferencing it. This patch fixes the issue with the
proper checks in the driver.

Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
crypto: msm: Add ablkcipher fallback for aes ctr, ecb, and cbc mode

Add ablkcipher fallback for aes ctr,ecb,cbc mode. Crypto 5 does
not support aes 192.

Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
crypto: msm: Remove bw_reaper_timer while in suspend mode

Remove bw_reaper_timer timer while in suspend mode. Otherwise, it
may cause power regression than normal.

Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: William Clark <wclark@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
crypto: msm: change timer operation to fix timer list corruption

remove the dulplicate init_timer operation in _qcrypto_resume and
replace add_timer with mod_timer to resolve timer list corruption.

Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
crypto: msm: Don't enable crypto clock in PM resume

If a PM suspend happens right after resume, crypto driver returns
-EBUSY, since reaper worker thread has not kicked in. The suspend
can only succeed after timer kicks in to disable crypto clock and
free bus.
The solution is as the following. Don't enable crypto
clock and allocate bus bandwidth when entering resume if
there is no outstanding crypto requests. The next crypto
operation will enable crypto clock then. Further more, this patch
shortens the reaper timer from 1 second to 200 ms.

Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>