crypto: add support for Orion5X crypto engine
This is version two of the the driver. New things:
- aes-ecb passes selftests
- aes-cbc passes selftests
The driver still does memcpy() from/to sram. To solve this, a dma driver would be required but first I wanted to compare the performance between now and nothing/generic aes. However I managed to crash cryptsetup with luksOpen. Got look into this...
--- drivers/crypto/Kconfig | 9 + drivers/crypto/Makefile | 1 + drivers/crypto/mav_crypto.c | 724 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 734 insertions(+), 0 deletions(-) create mode 100644 drivers/crypto/mav_crypto.c
drivers/crypto/Kconfig +9 -0
@@ -157,6 +157,15 @@ config S390_PRNG ANSI X9.17 standard. The PRNG is usable via the char device /dev/prandom. +config CRYPTO_DEV_MARVELL_CRYPTO_ENGINE + tristate "Marvell's Cryptographic Engine" + depends on PLAT_ORION + select CRYPTO_ALGAPI + select CRYPTO_AES + help + This driver allows you utilize the cryptographic engine which can be + found on certain SoC like QNAP's TS-209. + config CRYPTO_DEV_HIFN_795X tristate "Driver HIFN 795x crypto accelerator chips" select CRYPTO_DES
drivers/crypto/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o obj-$(CONFIG_CRYPTO_DEV_PADLOCK_SHA) += padlock-sha.o obj-$(CONFIG_CRYPTO_DEV_GEODE) += geode-aes.o obj-$(CONFIG_CRYPTO_DEV_HIFN_795X) += hifn_795x.o +obj-$(CONFIG_CRYPTO_DEV_MARVELL_CRYPTO_ENGINE) += mav_crypto.o obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/
drivers/crypto/mav_crypto.c new file +724 -0
724 lines not on this page · raw message
Signature · 1 line
1.6.0.6
Hi.
Quoted 1 line · Sebastian Andrzej Siewior
+struct
crypto_priv{
Please use less generic names over the file.
Quoted 4 lines
drivers/crypto/mav_crypto.c new file +4
-0+void __iomem *reg; +void __iomem *sram; +int irq; +struct task_struct *queue_th;
drivers/crypto/mav_crypto.c line 54
Quoted 10 lines
drivers/crypto/mav_crypto.c new file +10
-0+ +spinlock_t lock; +struct crypto_queue queue; +enum engine_status eng_st; +struct ablkcipher_request *cur_req; +struct req_progress p; +}; + +static struct crypto_priv *cpg; +
This rises several questions: why some of its fields are accessed under the lock and others are modified without. Some of them are only used in the kernel thread, while others are used in request context. Please document locking bits in the code.
drivers/crypto/mav_crypto.c line 64
Quoted 10 lines
drivers/crypto/mav_crypto.c new file +10
-0+static void reg_write (void __iomem *mem,u32 val) +{ +__raw_writel (val, mem); +} + +static u32 reg_read (void __iomem *mem) +{ +return __raw_readl (mem); +} +
Seems like you do not like underscores otherwise you would use those functions directly.
drivers/crypto/mav_crypto.c line 248
Quoted 3 lines
drivers/crypto/mav_crypto.c new file +3
-0+ +#define MAX_REQ_SIZE (8000) +
Parentheses are not needed.
drivers/crypto/mav_crypto.c line 543
Quoted 7 lines
drivers/crypto/mav_crypto.c new file +7
-0+irqreturn_t crypto_int (int irq,void *priv) +{ +// struct crypto_priv *cp = priv; +u32 val; + + val =reg_read (cpg->reg +SEC_ACCEL_INT_STATUS ); +reg_write (cpg->reg +SEC_ACCEL_INT_MASK ,0 );
Why do you ack interrupt before checking if interrupt belongs to this driver?
Quoted 8 lines
drivers/crypto/mav_crypto.c new file +8
-0+if (!(val &SEC_INT_ACCEL0_DONE )) +return IRQ_NONE ; + +BUG_ON (cpg->eng_st != engine_busy); + cpg->eng_st = engine_w_dequeue; +wake_up_process (cpg->queue_th); +return IRQ_HANDLED ; +}
Signature · 1 line
Evgeniy Polyakov
Quoted 22 lines · Sebastian Andrzej Siewior
This is version two of the the driver. New things:
- aes-ecb passes selftests
- aes-cbc passes selftestsThe driver still does
memcpy()from/to sram. To solve this, a dma driver would be required but first I wanted to compare the performance between now and nothing/generic aes. However I managed to crash cryptsetup with luksOpen. Got look into this...Signed-off-by Sebastian Andrzej Siewior <[email protected]>--- drivers/crypto/Kconfig | 9 + drivers/crypto/Makefile | 1 + drivers/crypto/mav_crypto.c | 724 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 734 insertions(+), 0 deletions(-) create mode 100644 drivers/crypto/mav_crypto.cdrivers/crypto/Kconfig +0
-0
drivers/crypto/Kconfig config S390_PRNG · line 160
Quoted 4 lines
drivers/crypto/Kconfig +1
-0@@ -157,6 +157,15 @@ config S390_PRNG ANSI X9.17 standard. The PRNG is usable via the char device /dev/prandom. +config CRYPTO_DEV_MARVELL_CRYPTO_ENGINE
CRYPTO_DEV...CRYPTO_ENGINE
Maybe CRYPTO_DEV_MARVELL would be enough?
drivers/crypto/Kconfig config S390_PRNG · line 168
Quoted 8 lines
drivers/crypto/Kconfig +8
-0+ tristate "Marvell's Cryptographic Engine" + depends on PLAT_ORION + select CRYPTO_ALGAPI + select CRYPTO_AES + help + This driver allows you utilize the cryptographic engine which can be + found on certain SoC like QNAP's TS-209. +
-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel FAQ: http://www.arm.linux.org.uk/mailinglists/faq.php Etiquette: http://www.arm.linux.org.uk/mailinglists/etiquette.php
Quoted 4 lines · Paulius Zaleckas
Quoted 1 line
+config
CRYPTO_DEV_MARVELL_CRYPTO_ENGINECRYPTO_DEV...CRYPTO_ENGINE
MaybeCRYPTO_DEV_MARVELLwould be enough?
... and since we're talking about naming issues, I think you should replace "mav" with "mv" to be in line with other uses inside the kernel (e.g. sata-mv).
Thanks for working on this driver!
Signature · 2 lines
Martin Michlmayr http://www.cyrius.com/
Quoted 1 line · * Evgeniy Polyakov | 2009-03-18 01:42:43 [+0300]:
Hi.
Hi Evgeniy,
Quoted 4 lines · Sebastian Andrzej Siewior
Quoted 1 line
+struct
crypto_priv{Please use less generic names over the file.
will do.
Quoted 11 lines
Quoted 11 lines
drivers/crypto/mav_crypto.c new file +11
-0+void __iomem *reg; +void __iomem *sram; +int irq; +struct task_struct *queue_th; + +spinlock_t lock; +struct crypto_queue queue; +enum engine_status eng_st; +struct ablkcipher_request *cur_req; +struct req_progress p; +};
Quoted 8 lines
drivers/crypto/mav_crypto.c line 54
Quoted 3 lines
drivers/crypto/mav_crypto.c new file +3
-0+ +static struct crypto_priv *cpg; +This rises several questions: why some of its fields are accessed under the lock and others are modified without. Some of them are only used in the kernel thread, while others are used in request context. Please document locking bits in the code.
Will do. Right now, I could switch to the _bh spinlock since it is only required to access the queue. Earlier I planned to enqueue the first request directly on the hw but then I got into the scatter walk.....
Quoted 5 lines
Quoted 5 lines
drivers/crypto/mav_crypto.c new file +5
-0+static void reg_write (void __iomem *mem,u32 val) +{ +__raw_writel (val, mem); +} +
Quoted 8 lines
drivers/crypto/mav_crypto.c line 64
Quoted 5 lines
drivers/crypto/mav_crypto.c new file +5
-0+static u32 reg_read (void __iomem *mem) +{ +return __raw_readl (mem); +} +Seems like you do not like underscores otherwise you would use those functions directly.
Yes, I could do so. I wasn't sure whether those are the correct functions to access the memory. If there were for some reason I could replace them in one place. I switch to __.
Quoted 5 lines
drivers/crypto/mav_crypto.c line 248
Quoted 3 lines
drivers/crypto/mav_crypto.c new file +3
-0+ +#define MAX_REQ_SIZE (8000) +Parentheses are not needed.
yup.
Quoted 10 lines
drivers/crypto/mav_crypto.c line 543
Quoted 7 lines
drivers/crypto/mav_crypto.c new file +7
-0+irqreturn_t crypto_int (int irq,void *priv) +{ +// struct crypto_priv *cp = priv; +u32 val; + + val =reg_read (cpg->reg +SEC_ACCEL_INT_STATUS ); +reg_write (cpg->reg +SEC_ACCEL_INT_MASK ,0 );Why do you ack interrupt before checking if interrupt belongs to this driver?
I don't know. I better fix this.
Quoted 11 lines
Quoted 8 lines
drivers/crypto/mav_crypto.c new file +8
-0+if (!(val &SEC_INT_ACCEL0_DONE )) +return IRQ_NONE ; + +BUG_ON (cpg->eng_st != engine_busy); + cpg->eng_st = engine_w_dequeue; +wake_up_process (cpg->queue_th); +return IRQ_HANDLED ; +}Signature · 1 line
Evgeniy Polyakov
Thanks for looking over.
Sebastian