Re: [PATCH v3 7/7] crypto: omap_sham: Remove usage of private DMA API

2012-11-13 Thread Kasatkin, Dmitry
On Fri, Nov 9, 2012 at 9:17 AM, Mark A. Greer  wrote:
> On Fri, Nov 09, 2012 at 06:28:16PM +0200, Kasatkin, Dmitry wrote:
>> On Wed, Nov 7, 2012 at 4:57 AM, Mark A. Greer  wrote:
>> > From: "Mark A. Greer" 
>> >
>> > Remove usage of the private OMAP DMA API.
>> > The dmaengine API will be used instead.
>> >
>> > CC: Russell King 
>> > CC: Dmitry Kasatkin 
>> > Signed-off-by: Mark A. Greer 
>> > ---
>> >  drivers/crypto/omap-sham.c | 117 
>> > -
>> >  1 file changed, 117 deletions(-)
>> >
>> > diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
>> > index b57277c..ebb5255 100644
>> > --- a/drivers/crypto/omap-sham.c
>> > +++ b/drivers/crypto/omap-sham.c
>
>> > @@ -807,18 +762,6 @@ static int omap_sham_handle_queue(struct 
>> > omap_sham_dev *dd,
>> > if (err)
>> > goto err1;
>> >
>> > -#ifdef OMAP_SHAM_DMA_PRIVATE
>> > -   omap_set_dma_dest_params(dd->dma_lch, 0,
>> > -   OMAP_DMA_AMODE_CONSTANT,
>> > -   dd->phys_base + SHA_REG_DIN(0), 0, 16);
>> > -
>> > -   omap_set_dma_dest_burst_mode(dd->dma_lch,
>> > -   OMAP_DMA_DATA_BURST_16);
>> > -
>> > -   omap_set_dma_src_burst_mode(dd->dma_lch,
>> > -   OMAP_DMA_DATA_BURST_4);
>>
>> Burst mode significantly improves performance.
>> How do you configure burst mode with new API?
>
> This is (or should be) taken care of by the dmaengine infrastructure.
> I've noted that there's an issue and there is a discussion about it
> here:
>
> http://www.spinics.net/lists/linux-omap/msg79855.html
>
> We probably need to extend the dmaengine API to allow API-users to
> request specific tweaks/optimizations/whatever but that's MHO.
>

Hello,

I am in favor of new APIs.
The only my concern is that it performs worse..

Is it possible to keep burst mode setting there?

- Dmitry

> Mark
> --
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 5/7] crypto: omap-sham: Convert to use pm_runtime API

2012-11-13 Thread Kevin Hilman
Hi Mark,

"Mark A. Greer"  writes:

> From: "Mark A. Greer" 
>
> Convert the omap-sham crypto driver to use the
> pm_runtime API instead of the clk API.
>
> CC: Kevin Hilman 
> CC: Paul Walmsley 
> CC: Dmitry Kasatkin 
> Signed-off-by: Mark A. Greer 

Acked-by: Kevin Hilman 

This looks much better and is more obviously a straight forward clock
API --> runtime PM conversion.

Thanks,

Kevin

> ---
>  drivers/crypto/omap-sham.c | 28 +++-
>  1 file changed, 11 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
> index a3fd6fc..85d43b2 100644
> --- a/drivers/crypto/omap-sham.c
> +++ b/drivers/crypto/omap-sham.c
> @@ -22,12 +22,12 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -141,7 +141,6 @@ struct omap_sham_dev {
>   struct device   *dev;
>   void __iomem*io_base;
>   int irq;
> - struct clk  *iclk;
>   spinlock_t  lock;
>   int err;
>   int dma;
> @@ -238,7 +237,7 @@ static void omap_sham_copy_ready_hash(struct 
> ahash_request *req)
>  
>  static int omap_sham_hw_init(struct omap_sham_dev *dd)
>  {
> - clk_enable(dd->iclk);
> + pm_runtime_get_sync(dd->dev);
>  
>   if (!test_bit(FLAGS_INIT, &dd->flags)) {
>   omap_sham_write_mask(dd, SHA_REG_MASK,
> @@ -653,7 +652,8 @@ static void omap_sham_finish_req(struct ahash_request 
> *req, int err)
>   /* atomic operation is not needed here */
>   dd->flags &= ~(BIT(FLAGS_BUSY) | BIT(FLAGS_FINAL) | BIT(FLAGS_CPU) |
>   BIT(FLAGS_DMA_READY) | BIT(FLAGS_OUTPUT_READY));
> - clk_disable(dd->iclk);
> +
> + pm_runtime_put_sync(dd->dev);
>  
>   if (req->base.complete)
>   req->base.complete(&req->base, err);
> @@ -1198,14 +1198,6 @@ static int __devinit omap_sham_probe(struct 
> platform_device *pdev)
>   if (err)
>   goto dma_err;
>  
> - /* Initializing the clock */
> - dd->iclk = clk_get(dev, "ick");
> - if (IS_ERR(dd->iclk)) {
> - dev_err(dev, "clock intialization failed.\n");
> - err = PTR_ERR(dd->iclk);
> - goto clk_err;
> - }
> -
>   dd->io_base = ioremap(dd->phys_base, SZ_4K);
>   if (!dd->io_base) {
>   dev_err(dev, "can't ioremap\n");
> @@ -1213,11 +1205,14 @@ static int __devinit omap_sham_probe(struct 
> platform_device *pdev)
>   goto io_err;
>   }
>  
> - clk_enable(dd->iclk);
> + pm_runtime_enable(dev);
> + pm_runtime_get_sync(dev);
> +
>   dev_info(dev, "hw accel on OMAP rev %u.%u\n",
>   (omap_sham_read(dd, SHA_REG_REV) & SHA_REG_REV_MAJOR) >> 4,
>   omap_sham_read(dd, SHA_REG_REV) & SHA_REG_REV_MINOR);
> - clk_disable(dd->iclk);
> +
> + pm_runtime_put_sync(&pdev->dev);
>  
>   spin_lock(&sham.lock);
>   list_add_tail(&dd->list, &sham.dev_list);
> @@ -1235,9 +1230,8 @@ err_algs:
>   for (j = 0; j < i; j++)
>   crypto_unregister_ahash(&algs[j]);
>   iounmap(dd->io_base);
> + pm_runtime_disable(dev);
>  io_err:
> - clk_put(dd->iclk);
> -clk_err:
>   omap_sham_dma_cleanup(dd);
>  dma_err:
>   if (dd->irq >= 0)
> @@ -1266,7 +1260,7 @@ static int __devexit omap_sham_remove(struct 
> platform_device *pdev)
>   crypto_unregister_ahash(&algs[i]);
>   tasklet_kill(&dd->done_task);
>   iounmap(dd->io_base);
> - clk_put(dd->iclk);
> + pm_runtime_disable(&pdev->dev);
>   omap_sham_dma_cleanup(dd);
>   if (dd->irq >= 0)
>   free_irq(dd->irq, dd);
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Announce loop-AES-v3.6f file/swap crypto package

2012-11-13 Thread Jari Ruusu
loop-AES changes since previous release:
- Worked around block layer interface changes on 3.7-rc kernels.
- Fixed bug that caused loop device to report un-optimal I/O size on some
  backing devices. This bug caused bad performance.
- Fixed bug that assumed /bin/sh -> bash. For /bin/sh -> dash case some
  auto-detections failed.

bzip2 compressed tarball is here:

http://loop-aes.sourceforge.net/loop-AES/loop-AES-v3.6f.tar.bz2
md5sum 0b5bfe4538fd8439b84c586846726507

http://loop-aes.sourceforge.net/loop-AES/loop-AES-v3.6f.tar.bz2.sign

-- 
Jari Ruusu  1024R/3A220F51 5B 4B F9 BB D3 3F 52 E9  DB 1D EB E3 24 0E A9 DD
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: cast5/cast6 - move lookup tables to shared module

2012-11-13 Thread David Miller
From: Jussi Kivilinna 
Date: Tue, 13 Nov 2012 21:50:20 +0200

> Quoting David Miller :
> 
>> From: Jussi Kivilinna 
>> Date: Tue, 13 Nov 2012 11:43:14 +0200
>>
>>> CAST5 and CAST6 both use same lookup tables, which can be moved shared
>>> module
>>> 'cast_common'.
>>>
>>> Signed-off-by: Jussi Kivilinna 
>>
>> Does this work if you make CAST5 modular and CAST6 static, or vice
>> versa?
>>
> 
> Yes, dependencies force common module to be built-in/static in both
> cases and will be build as module only if both cast5 and cast6 are
> also.

Fair enough:

Acked-by: David S. Miller 
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: cast5/cast6 - move lookup tables to shared module

2012-11-13 Thread Jussi Kivilinna

Quoting David Miller :


From: Jussi Kivilinna 
Date: Tue, 13 Nov 2012 11:43:14 +0200

CAST5 and CAST6 both use same lookup tables, which can be moved  
shared module

'cast_common'.

Signed-off-by: Jussi Kivilinna 


Does this work if you make CAST5 modular and CAST6 static, or vice
versa?



Yes, dependencies force common module to be built-in/static in both  
cases and will be build as module only if both cast5 and cast6 are also.


--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: testmgr - add larger crc32c test vector to test FPU path in crc32c_intel

2012-11-13 Thread David Miller
From: Jussi Kivilinna 
Date: Tue, 13 Nov 2012 12:02:30 +0200

> Signed-off-by: Jussi Kivilinna 

Acked-by: David S. Miller 
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] crypto: testmgr - clean alg_test_null entries in alg_test_descs[]

2012-11-13 Thread David Miller
From: Jussi Kivilinna 
Date: Tue, 13 Nov 2012 11:47:37 +0200

> Currently alg_test_null entries set .suite values to zero, which is unneeded.
> So perform clean-up of null test entries.
> 
> Signed-off-by: Jussi Kivilinna 

Acked-by: David S. Miller 
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] crypto: testmgr - remove fips_allowed flag from camellia-aesni null-tests

2012-11-13 Thread David Miller
From: Jussi Kivilinna 
Date: Tue, 13 Nov 2012 11:47:32 +0200

> Remove incorrect fips_allowed from camellia null-test entries. Caused by
> incorrect copy-paste of aes-aesni null-tests into camellia-aesni null-tests.
> 
> Signed-off-by: Jussi Kivilinna 

Acked-by: David S. Miller 
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto: cast5/cast6 - move lookup tables to shared module

2012-11-13 Thread David Miller
From: Jussi Kivilinna 
Date: Tue, 13 Nov 2012 11:43:14 +0200

> CAST5 and CAST6 both use same lookup tables, which can be moved shared module
> 'cast_common'.
> 
> Signed-off-by: Jussi Kivilinna 

Does this work if you make CAST5 modular and CAST6 static, or vice
versa?
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] crypto: testmgr - add larger crc32c test vector to test FPU path in crc32c_intel

2012-11-13 Thread Jussi Kivilinna
Signed-off-by: Jussi Kivilinna 
---
 crypto/testmgr.h |  267 +-
 1 file changed, 264 insertions(+), 3 deletions(-)

diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 17db4a9..189aeb6 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -41,7 +41,7 @@ struct hash_testvec {
char *plaintext;
char *digest;
unsigned char tap[MAX_TAP];
-   unsigned char psize;
+   unsigned short psize;
unsigned char np;
unsigned char ksize;
 };
@@ -25214,7 +25214,7 @@ static struct hash_testvec michael_mic_tv_template[] = {
 /*
  * CRC32C test vectors
  */
-#define CRC32C_TEST_VECTORS 14
+#define CRC32C_TEST_VECTORS 15
 
 static struct hash_testvec crc32c_tv_template[] = {
{
@@ -25385,7 +25385,268 @@ static struct hash_testvec crc32c_tv_template[] = {
.digest = "\x75\xd3\xc5\x24",
.np = 2,
.tap = { 31, 209 }
-   },
+   }, {
+   .key = "\xff\xff\xff\xff",
+   .ksize = 4,
+   .plaintext ="\x6e\x05\x79\x10\xa7\x1b\xb2\x49"
+   "\xe0\x54\xeb\x82\x19\x8d\x24\xbb"
+   "\x2f\xc6\x5d\xf4\x68\xff\x96\x0a"
+   "\xa1\x38\xcf\x43\xda\x71\x08\x7c"
+   "\x13\xaa\x1e\xb5\x4c\xe3\x57\xee"
+   "\x85\x1c\x90\x27\xbe\x32\xc9\x60"
+   "\xf7\x6b\x02\x99\x0d\xa4\x3b\xd2"
+   "\x46\xdd\x74\x0b\x7f\x16\xad\x21"
+   "\xb8\x4f\xe6\x5a\xf1\x88\x1f\x93"
+   "\x2a\xc1\x35\xcc\x63\xfa\x6e\x05"
+   "\x9c\x10\xa7\x3e\xd5\x49\xe0\x77"
+   "\x0e\x82\x19\xb0\x24\xbb\x52\xe9"
+   "\x5d\xf4\x8b\x22\x96\x2d\xc4\x38"
+   "\xcf\x66\xfd\x71\x08\x9f\x13\xaa"
+   "\x41\xd8\x4c\xe3\x7a\x11\x85\x1c"
+   "\xb3\x27\xbe\x55\xec\x60\xf7\x8e"
+   "\x02\x99\x30\xc7\x3b\xd2\x69\x00"
+   "\x74\x0b\xa2\x16\xad\x44\xdb\x4f"
+   "\xe6\x7d\x14\x88\x1f\xb6\x2a\xc1"
+   "\x58\xef\x63\xfa\x91\x05\x9c\x33"
+   "\xca\x3e\xd5\x6c\x03\x77\x0e\xa5"
+   "\x19\xb0\x47\xde\x52\xe9\x80\x17"
+   "\x8b\x22\xb9\x2d\xc4\x5b\xf2\x66"
+   "\xfd\x94\x08\x9f\x36\xcd\x41\xd8"
+   "\x6f\x06\x7a\x11\xa8\x1c\xb3\x4a"
+   "\xe1\x55\xec\x83\x1a\x8e\x25\xbc"
+   "\x30\xc7\x5e\xf5\x69\x00\x97\x0b"
+   "\xa2\x39\xd0\x44\xdb\x72\x09\x7d"
+   "\x14\xab\x1f\xb6\x4d\xe4\x58\xef"
+   "\x86\x1d\x91\x28\xbf\x33\xca\x61"
+   "\xf8\x6c\x03\x9a\x0e\xa5\x3c\xd3"
+   "\x47\xde\x75\x0c\x80\x17\xae\x22"
+   "\xb9\x50\xe7\x5b\xf2\x89\x20\x94"
+   "\x2b\xc2\x36\xcd\x64\xfb\x6f\x06"
+   "\x9d\x11\xa8\x3f\xd6\x4a\xe1\x78"
+   "\x0f\x83\x1a\xb1\x25\xbc\x53\xea"
+   "\x5e\xf5\x8c\x00\x97\x2e\xc5\x39"
+   "\xd0\x67\xfe\x72\x09\xa0\x14\xab"
+   "\x42\xd9\x4d\xe4\x7b\x12\x86\x1d"
+   "\xb4\x28\xbf\x56\xed\x61\xf8\x8f"
+   "\x03\x9a\x31\xc8\x3c\xd3\x6a\x01"
+   "\x75\x0c\xa3\x17\xae\x45\xdc\x50"
+   "\xe7\x7e\x15\x89\x20\xb7\x2b\xc2"
+   "\x59\xf0\x64\xfb\x92\x06\x9d\x34"
+   "\xcb\x3f\xd6\x6d\x04\x78\x0f\xa6"
+   "\x1a\xb1\x48\xdf\x53\xea\x81\x18"
+   "\x8c\x23\xba\x2e\xc5\x5c\xf3\x67"
+   "\xfe\x95\x09\xa0\x37\xce\x42\xd9"
+   "\x70\x07\x7b\x12\xa9\x1d\xb4\x4b"
+   "\xe2\x56\xed\x84\x1b\x8f\x26\xbd"
+   "\x31\xc8\x5f\xf6\x6a\x01\x98\x0c"
+   "\xa3\x3a\xd1\x45\xdc\x73\x0a\x7e"
+   "\x15\xac\x20\xb7\x4e\xe5\x59\xf0"
+   "\x87\x1e\x92\x29\xc0\x34\xcb\x62"
+   "\xf9\x6d\x04\x9b\x0f\xa6\x3d\xd4"
+   "\x48\xdf\x76\x0d\x81\x18\xaf\x23"
+   "\xba\x51\xe8\x5c\xf3\x8a\x21\x95"
+   "\x2c\xc3\x37\xce\x65\xfc\x70\x07"
+   "\x9e\x12\xa9\x40\xd7\x4b

[PATCH 2/2] crypto: testmgr - clean alg_test_null entries in alg_test_descs[]

2012-11-13 Thread Jussi Kivilinna
Currently alg_test_null entries set .suite values to zero, which is unneeded.
So perform clean-up of null test entries.

Signed-off-by: Jussi Kivilinna 
---
 crypto/testmgr.c |  372 --
 1 file changed, 372 deletions(-)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index b8695bf..37b4c07 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -1638,300 +1638,66 @@ static const struct alg_test_desc alg_test_descs[] = {
{
.alg = "__cbc-cast5-avx",
.test = alg_test_null,
-   .suite = {
-   .cipher = {
-   .enc = {
-   .vecs = NULL,
-   .count = 0
-   },
-   .dec = {
-   .vecs = NULL,
-   .count = 0
-   }
-   }
-   }
}, {
.alg = "__cbc-cast6-avx",
.test = alg_test_null,
-   .suite = {
-   .cipher = {
-   .enc = {
-   .vecs = NULL,
-   .count = 0
-   },
-   .dec = {
-   .vecs = NULL,
-   .count = 0
-   }
-   }
-   }
}, {
.alg = "__cbc-serpent-avx",
.test = alg_test_null,
-   .suite = {
-   .cipher = {
-   .enc = {
-   .vecs = NULL,
-   .count = 0
-   },
-   .dec = {
-   .vecs = NULL,
-   .count = 0
-   }
-   }
-   }
}, {
.alg = "__cbc-serpent-sse2",
.test = alg_test_null,
-   .suite = {
-   .cipher = {
-   .enc = {
-   .vecs = NULL,
-   .count = 0
-   },
-   .dec = {
-   .vecs = NULL,
-   .count = 0
-   }
-   }
-   }
}, {
.alg = "__cbc-twofish-avx",
.test = alg_test_null,
-   .suite = {
-   .cipher = {
-   .enc = {
-   .vecs = NULL,
-   .count = 0
-   },
-   .dec = {
-   .vecs = NULL,
-   .count = 0
-   }
-   }
-   }
}, {
.alg = "__driver-cbc-aes-aesni",
.test = alg_test_null,
.fips_allowed = 1,
-   .suite = {
-   .cipher = {
-   .enc = {
-   .vecs = NULL,
-   .count = 0
-   },
-   .dec = {
-   .vecs = NULL,
-   .count = 0
-   }
-   }
-   }
}, {
.alg = "__driver-cbc-camellia-aesni",
.test = alg_test_null,
-   .suite = {
-   .cipher = {
-   .enc = {
-   .vecs = NULL,
-   .count = 0
-   },
-   .dec = {
-   .vecs = NULL,
-   .count = 0
-   }
-   }
-   }
}, {
.alg = "__driver-cbc-cast5-avx",
.test = alg_test_null,
-   .suite = {
-   .cipher = {
-   .enc = {
-   .vecs = NULL,
-   .count = 0
-   },
-   .dec = {
-   .vecs = NULL,
-   .count = 0
-   }
-

[PATCH 1/2] crypto: testmgr - remove fips_allowed flag from camellia-aesni null-tests

2012-11-13 Thread Jussi Kivilinna
Remove incorrect fips_allowed from camellia null-test entries. Caused by
incorrect copy-paste of aes-aesni null-tests into camellia-aesni null-tests.

Signed-off-by: Jussi Kivilinna 
---
 crypto/testmgr.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 3933241..b8695bf 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -2175,7 +2175,6 @@ static const struct alg_test_desc alg_test_descs[] = {
}, {
.alg = "cryptd(__driver-cbc-camellia-aesni)",
.test = alg_test_null,
-   .fips_allowed = 1,
.suite = {
.cipher = {
.enc = {
@@ -2207,7 +2206,6 @@ static const struct alg_test_desc alg_test_descs[] = {
}, {
.alg = "cryptd(__driver-ecb-camellia-aesni)",
.test = alg_test_null,
-   .fips_allowed = 1,
.suite = {
.cipher = {
.enc = {

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] crypto: cast5/cast6 - move lookup tables to shared module

2012-11-13 Thread Jussi Kivilinna
CAST5 and CAST6 both use same lookup tables, which can be moved shared module
'cast_common'.

Signed-off-by: Jussi Kivilinna 
---
 arch/x86/crypto/cast5-avx-x86_64-asm_64.S |   16 +-
 arch/x86/crypto/cast6-avx-x86_64-asm_64.S |   16 +-
 crypto/Kconfig|   10 +
 crypto/Makefile   |1 
 crypto/cast5_generic.c|  277 
 crypto/cast6_generic.c|  280 
 crypto/cast_common.c  |  290 +
 include/crypto/cast5.h|6 -
 include/crypto/cast6.h|6 -
 include/crypto/cast_common.h  |9 +
 10 files changed, 336 insertions(+), 575 deletions(-)
 create mode 100644 crypto/cast_common.c
 create mode 100644 include/crypto/cast_common.h

diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S 
b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
index 12478e4..15b00ac 100644
--- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
+++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
@@ -25,10 +25,10 @@
 
 .file "cast5-avx-x86_64-asm_64.S"
 
-.extern cast5_s1
-.extern cast5_s2
-.extern cast5_s3
-.extern cast5_s4
+.extern cast_s1
+.extern cast_s2
+.extern cast_s3
+.extern cast_s4
 
 /* structure of crypto context */
 #define km 0
@@ -36,10 +36,10 @@
 #define rr ((16*4)+16)
 
 /* s-boxes */
-#define s1 cast5_s1
-#define s2 cast5_s2
-#define s3 cast5_s3
-#define s4 cast5_s4
+#define s1 cast_s1
+#define s2 cast_s2
+#define s3 cast_s3
+#define s4 cast_s4
 
 /**
   16-way AVX cast5
diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S 
b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
index 83a5381..2569d0d 100644
--- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
+++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
@@ -27,20 +27,20 @@
 
 .file "cast6-avx-x86_64-asm_64.S"
 
-.extern cast6_s1
-.extern cast6_s2
-.extern cast6_s3
-.extern cast6_s4
+.extern cast_s1
+.extern cast_s2
+.extern cast_s3
+.extern cast_s4
 
 /* structure of crypto context */
 #define km 0
 #define kr (12*4*4)
 
 /* s-boxes */
-#define s1 cast6_s1
-#define s2 cast6_s2
-#define s3 cast6_s3
-#define s4 cast6_s4
+#define s1 cast_s1
+#define s2 cast_s2
+#define s3 cast_s3
+#define s4 cast_s4
 
 /**
   8-way AVX cast6
diff --git a/crypto/Kconfig b/crypto/Kconfig
index c226b2c..4641d95 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -841,9 +841,16 @@ config CRYPTO_CAMELLIA_SPARC64
  See also:
  
 
+config CRYPTO_CAST_COMMON
+   tristate
+   help
+ Common parts of the CAST cipher algorithms shared by the
+ generic c and the assembler implementations.
+
 config CRYPTO_CAST5
tristate "CAST5 (CAST-128) cipher algorithm"
select CRYPTO_ALGAPI
+   select CRYPTO_CAST_COMMON
help
  The CAST5 encryption algorithm (synonymous with CAST-128) is
  described in RFC2144.
@@ -854,6 +861,7 @@ config CRYPTO_CAST5_AVX_X86_64
select CRYPTO_ALGAPI
select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86
+   select CRYPTO_CAST_COMMON
select CRYPTO_CAST5
help
  The CAST5 encryption algorithm (synonymous with CAST-128) is
@@ -865,6 +873,7 @@ config CRYPTO_CAST5_AVX_X86_64
 config CRYPTO_CAST6
tristate "CAST6 (CAST-256) cipher algorithm"
select CRYPTO_ALGAPI
+   select CRYPTO_CAST_COMMON
help
  The CAST6 encryption algorithm (synonymous with CAST-256) is
  described in RFC2612.
@@ -876,6 +885,7 @@ config CRYPTO_CAST6_AVX_X86_64
select CRYPTO_CRYPTD
select CRYPTO_ABLK_HELPER_X86
select CRYPTO_GLUE_HELPER_X86
+   select CRYPTO_CAST_COMMON
select CRYPTO_CAST6
select CRYPTO_LRW
select CRYPTO_XTS
diff --git a/crypto/Makefile b/crypto/Makefile
index 8cf61ff..d59dec7 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -68,6 +68,7 @@ obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
 obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
 obj-$(CONFIG_CRYPTO_AES) += aes_generic.o
 obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
+obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o
 obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
 obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
 obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
diff --git a/crypto/cast5_generic.c b/crypto/cast5_generic.c
index bc525db..5558f63 100644
--- a/crypto/cast5_generic.c
+++ b/crypto/cast5_generic.c
@@ -30,275 +30,6 @@
 #include 
 #include 
 
-
-const u32 cast5_s1[256] = {
-   0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f,
-   0x9c004dd3, 0x6003e540, 0xcf9fc949,
-   0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d