linux-stable/drivers/crypto
Krzysztof Kozlowski 79152e8d08 crypto: s5p-sss - Fix missed interrupts when working with 8 kB blocks
The tcrypt testing module on Exynos5422-based Odroid XU3/4 board failed on
testing 8 kB size blocks:

	$ sudo modprobe tcrypt sec=1 mode=500
	testing speed of async ecb(aes) (ecb-aes-s5p) encryption
	test 0 (128 bit key, 16 byte blocks): 21971 operations in 1 seconds (351536 bytes)
	test 1 (128 bit key, 64 byte blocks): 21731 operations in 1 seconds (1390784 bytes)
	test 2 (128 bit key, 256 byte blocks): 21932 operations in 1 seconds (5614592 bytes)
	test 3 (128 bit key, 1024 byte blocks): 21685 operations in 1 seconds (22205440 bytes)
	test 4 (128 bit key, 8192 byte blocks):

This was caused by a race issue of missed BRDMA_DONE ("Block cipher
Receiving DMA") interrupt. Device starts processing the data in DMA mode
immediately after setting length of DMA block: receiving (FCBRDMAL) or
transmitting (FCBTDMAL). The driver sets these lengths from interrupt
handler through s5p_set_dma_indata() function (or xxx_setdata()).

However the interrupt handler was first dealing with receive buffer
(dma-unmap old, dma-map new, set receive block length which starts the
operation), then with transmit buffer and finally was clearing pending
interrupts (FCINTPEND). Because of the time window between setting
receive buffer length and clearing pending interrupts, the operation on
receive buffer could end already and driver would miss new interrupt.

User manual for Exynos5422 confirms in example code that setting DMA
block lengths should be the last operation.

The tcrypt hang could be also observed in following blocked-task dmesg:

INFO: task modprobe:258 blocked for more than 120 seconds.
      Not tainted 4.6.0-rc4-next-20160419-00005-g9eac8b7b7753-dirty #42
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
modprobe        D c06b09d8     0   258    256 0x00000000
[<c06b09d8>] (__schedule) from [<c06b0f24>] (schedule+0x40/0xac)
[<c06b0f24>] (schedule) from [<c06b49f8>] (schedule_timeout+0x124/0x178)
[<c06b49f8>] (schedule_timeout) from [<c06b17fc>] (wait_for_common+0xb8/0x144)
[<c06b17fc>] (wait_for_common) from [<bf0013b8>] (test_acipher_speed+0x49c/0x740 [tcrypt])
[<bf0013b8>] (test_acipher_speed [tcrypt]) from [<bf003e8c>] (do_test+0x2240/0x30ec [tcrypt])
[<bf003e8c>] (do_test [tcrypt]) from [<bf008048>] (tcrypt_mod_init+0x48/0xa4 [tcrypt])
[<bf008048>] (tcrypt_mod_init [tcrypt]) from [<c010177c>] (do_one_initcall+0x3c/0x16c)
[<c010177c>] (do_one_initcall) from [<c0191ff0>] (do_init_module+0x5c/0x1ac)
[<c0191ff0>] (do_init_module) from [<c0185610>] (load_module+0x1a30/0x1d08)
[<c0185610>] (load_module) from [<c0185ab0>] (SyS_finit_module+0x8c/0x98)
[<c0185ab0>] (SyS_finit_module) from [<c01078c0>] (ret_fast_syscall+0x0/0x3c)

Fixes: a49e490c7a ("crypto: s5p-sss - add S5PV210 advanced crypto engine support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2016-04-25 19:14:54 +08:00
..
amcc crypto4xx: integrate ppc4xx-rng into crypto4xx 2016-04-20 17:50:02 +08:00
caam crypto: caam - Staticize caam_jr_shutdown() 2016-02-17 04:07:52 +08:00
ccp crypto: ccp - Ensure all dependencies are specified 2016-04-25 19:14:51 +08:00
marvell crypto: marvell/cesa - Improving code readability 2016-04-20 17:50:07 +08:00
nx Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2016-03-17 21:38:27 -07:00
qat crypto: qat - fix section mismatch warning 2016-04-18 18:49:52 +08:00
qce crypto: qce - check return value of sg_nents_for_len 2015-11-17 22:00:36 +08:00
rockchip crypto: rockchip - add hash support for crypto engine in rk3288 2016-02-28 03:26:29 +08:00
sunxi-ss crypto: sun4i-ss - Replace spinlock_bh by spin_lock_irq{save|restore} 2016-04-05 20:35:53 +08:00
ux500 crypto: ux500 - fix checks of error code returned by devm_ioremap_resource() 2016-03-11 21:19:20 +08:00
vmx powerpc updates for 4.5 2016-01-15 13:18:47 -08:00
atmel-aes-regs.h crypto: atmel-aes - add support to GCM mode 2015-12-23 18:19:58 +08:00
atmel-aes.c Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2016-03-17 11:22:54 -07:00
atmel-sha-regs.h crypto: atmel-sha - fix context switches 2016-01-25 22:42:07 +08:00
atmel-sha.c Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2016-03-17 11:22:54 -07:00
atmel-tdes-regs.h crypto: atmel-tdes - add support for latest release of the IP (0x700) 2013-03-10 16:46:42 +08:00
atmel-tdes.c crypto: atmel - fix checks of error code returned by devm_ioremap_resource() 2016-03-11 21:19:19 +08:00
bfin_crc.c crypto: bfin_crc - replace sg_count by sg_nents 2015-09-21 23:05:53 +08:00
bfin_crc.h crypto: bfin_crc - access crc registers by readl and writel functions 2014-04-16 20:40:15 +08:00
geode-aes.c crypto: geode - Don't use tfm->__crt_alg->cra_name directly 2014-05-22 21:03:13 +08:00
geode-aes.h crypto: geode - Consistently use AES_KEYSIZE_128 2014-05-22 21:03:12 +08:00
hifn_795x.c crypto: hifn_795x, picoxcell - use ablkcipher_request_cast 2015-12-29 21:32:44 +08:00
img-hash.c crypto: img-hash - fix spelling mistake in dev_err error message 2015-08-04 17:41:31 +08:00
ixp4xx_crypto.c crypto: ixp4xx - Fix false lastlen uninitialised warning 2016-01-25 22:42:09 +08:00
Kconfig crypto4xx: integrate ppc4xx-rng into crypto4xx 2016-04-20 17:50:02 +08:00
Makefile crypto: mxc-scc - add basic driver for the MXC SCC 2016-04-15 22:36:35 +08:00
mv_cesa.c crypto: marvell/cesa - another fix up for of_get_named_gen_pool() rename 2015-07-03 11:37:02 -07:00
mv_cesa.h crypto: mv_cesa - Add missing #define 2014-08-29 21:46:36 +08:00
mxc-scc.c crypto: mxc-scc - fix unwinding in mxc_scc_crypto_register() 2016-04-25 19:14:53 +08:00
mxs-dcp.c crypto: mxs-dcp - fix type of ret for wait_for_completion_timeout 2015-02-28 23:31:36 +13:00
n2_asm.S
n2_core.c crypto: n2 - Remove return statement from void function 2016-04-05 20:35:44 +08:00
n2_core.h
omap-aes.c crypto: omap-aes - Support crypto engine framework 2016-02-01 22:27:04 +08:00
omap-des.c crypto: omap - Removed unused variable "err" 2015-12-17 16:42:13 +08:00
omap-sham.c crypto/omap-sham: remove an open coded access to ->page_link 2015-08-17 08:12:57 -06:00
padlock-aes.c Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2016-01-12 18:51:14 -08:00
padlock-sha.c x86/cpufeature: Remove unused and seldomly used cpu_has_xx macros 2015-12-19 11:49:55 +01:00
picoxcell_crypto.c crypto: hifn_795x, picoxcell - use ablkcipher_request_cast 2015-12-29 21:32:44 +08:00
picoxcell_crypto_regs.h
s5p-sss.c crypto: s5p-sss - Fix missed interrupts when working with 8 kB blocks 2016-04-25 19:14:54 +08:00
sahara.c crypto: sahara - fill the statesize field 2016-02-06 15:33:29 +08:00
talitos.c crypto: talitos - fix ahash algorithms registration 2016-04-25 19:14:52 +08:00
talitos.h crypto: talitos - add new crypto modes 2015-12-04 22:29:56 +08:00