crypto: chacha20-simd - Use generic code for small requests
authorHerbert Xu <herbert@gondor.apana.org.au>
Mon, 20 Jun 2016 05:19:17 +0000 (13:19 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 23 Jun 2016 10:13:58 +0000 (18:13 +0800)
On 16-byte requests the optimised version is actually slower than
the generic code, so we should simply use that instead.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cheers,

arch/x86/crypto/chacha20_glue.c

index 2d5c2e0..f910d1d 100644 (file)
@@ -70,7 +70,7 @@ static int chacha20_simd(struct blkcipher_desc *desc, struct scatterlist *dst,
        struct blkcipher_walk walk;
        int err;
 
-       if (!may_use_simd())
+       if (nbytes <= CHACHA20_BLOCK_SIZE || !may_use_simd())
                return crypto_chacha20_crypt(desc, dst, src, nbytes);
 
        state = (u32 *)roundup((uintptr_t)state_buf, CHACHA20_STATE_ALIGN);