From: Cyrille Pitchen <cyrille.pitchen@atmel.com> To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>, <nicolas.ferre@atmel.com> Cc: <linux-crypto@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, Cyrille Pitchen <cyrille.pitchen@atmel.com> Subject: [PATCH 07/24] crypto: atmel-aes: change atmel_aes_write_ctrl() signature Date: Thu, 17 Dec 2015 17:48:38 +0100 [thread overview] Message-ID: <034ee506976eb9e9f766cae62ccacf56d848f947.1450366831.git.cyrille.pitchen@atmel.com> (raw) In-Reply-To: <cover.1450366831.git.cyrille.pitchen@atmel.com> This patch changes the signature of atmel_aes_write_ctrl() to make it more generic. This will be used by future patches when implementing new block cipher modes such as GCM. Especially atmel_aes_hw_init() is now called outside atmel_aes_write_ctrl(): this allows to call atmel_aes_write_ctrl() many times, still initializing the hardware only once. Indeed, the support of GCM will require to update the Mode Register and the IV when processing a single request. Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com> --- drivers/crypto/atmel-aes.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c index 9a9e1b88a384..ccb8a8322bf7 100644 --- a/drivers/crypto/atmel-aes.c +++ b/drivers/crypto/atmel-aes.c @@ -496,16 +496,11 @@ static int atmel_aes_crypt_dma_start(struct atmel_aes_dev *dd) return err; } -static int atmel_aes_write_ctrl(struct atmel_aes_dev *dd) +static void atmel_aes_write_ctrl(struct atmel_aes_dev *dd, bool use_dma, + const u32 *iv) { - int err; u32 valcr = 0, valmr = 0; - err = atmel_aes_hw_init(dd); - - if (err) - return err; - /* MR register must be set before IV registers */ if (dd->ctx->keylen == AES_KEYSIZE_128) valmr |= AES_MR_KEYSIZE_128; @@ -539,7 +534,7 @@ static int atmel_aes_write_ctrl(struct atmel_aes_dev *dd) if (dd->flags & AES_FLAGS_ENCRYPT) valmr |= AES_MR_CYPHER_ENC; - if (dd->total > ATMEL_AES_DMA_THRESHOLD) { + if (use_dma) { valmr |= AES_MR_SMOD_IDATAR0; if (dd->caps.has_dualbuff) valmr |= AES_MR_DUALBUFF; @@ -555,11 +550,9 @@ static int atmel_aes_write_ctrl(struct atmel_aes_dev *dd) if (((dd->flags & AES_FLAGS_CBC) || (dd->flags & AES_FLAGS_CFB) || (dd->flags & AES_FLAGS_OFB) || (dd->flags & AES_FLAGS_CTR)) && - dd->req->info) { - atmel_aes_write_n(dd, AES_IVR(0), dd->req->info, 4); + iv) { + atmel_aes_write_n(dd, AES_IVR(0), iv, 4); } - - return 0; } static int atmel_aes_handle_queue(struct atmel_aes_dev *dd, @@ -570,6 +563,7 @@ static int atmel_aes_handle_queue(struct atmel_aes_dev *dd, struct atmel_aes_reqctx *rctx; unsigned long flags; int err, ret = 0; + bool use_dma; spin_lock_irqsave(&dd->lock, flags); if (req) @@ -607,9 +601,11 @@ static int atmel_aes_handle_queue(struct atmel_aes_dev *dd, dd->ctx = ctx; ctx->dd = dd; - err = atmel_aes_write_ctrl(dd); + err = atmel_aes_hw_init(dd); if (!err) { - if (dd->total > ATMEL_AES_DMA_THRESHOLD) + use_dma = (dd->total > ATMEL_AES_DMA_THRESHOLD); + atmel_aes_write_ctrl(dd, use_dma, req->info); + if (use_dma) err = atmel_aes_crypt_dma_start(dd); else err = atmel_aes_crypt_cpu_start(dd); -- 1.8.2.2
WARNING: multiple messages have this Message-ID (diff)
From: cyrille.pitchen@atmel.com (Cyrille Pitchen) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 07/24] crypto: atmel-aes: change atmel_aes_write_ctrl() signature Date: Thu, 17 Dec 2015 17:48:38 +0100 [thread overview] Message-ID: <034ee506976eb9e9f766cae62ccacf56d848f947.1450366831.git.cyrille.pitchen@atmel.com> (raw) In-Reply-To: <cover.1450366831.git.cyrille.pitchen@atmel.com> This patch changes the signature of atmel_aes_write_ctrl() to make it more generic. This will be used by future patches when implementing new block cipher modes such as GCM. Especially atmel_aes_hw_init() is now called outside atmel_aes_write_ctrl(): this allows to call atmel_aes_write_ctrl() many times, still initializing the hardware only once. Indeed, the support of GCM will require to update the Mode Register and the IV when processing a single request. Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com> --- drivers/crypto/atmel-aes.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c index 9a9e1b88a384..ccb8a8322bf7 100644 --- a/drivers/crypto/atmel-aes.c +++ b/drivers/crypto/atmel-aes.c @@ -496,16 +496,11 @@ static int atmel_aes_crypt_dma_start(struct atmel_aes_dev *dd) return err; } -static int atmel_aes_write_ctrl(struct atmel_aes_dev *dd) +static void atmel_aes_write_ctrl(struct atmel_aes_dev *dd, bool use_dma, + const u32 *iv) { - int err; u32 valcr = 0, valmr = 0; - err = atmel_aes_hw_init(dd); - - if (err) - return err; - /* MR register must be set before IV registers */ if (dd->ctx->keylen == AES_KEYSIZE_128) valmr |= AES_MR_KEYSIZE_128; @@ -539,7 +534,7 @@ static int atmel_aes_write_ctrl(struct atmel_aes_dev *dd) if (dd->flags & AES_FLAGS_ENCRYPT) valmr |= AES_MR_CYPHER_ENC; - if (dd->total > ATMEL_AES_DMA_THRESHOLD) { + if (use_dma) { valmr |= AES_MR_SMOD_IDATAR0; if (dd->caps.has_dualbuff) valmr |= AES_MR_DUALBUFF; @@ -555,11 +550,9 @@ static int atmel_aes_write_ctrl(struct atmel_aes_dev *dd) if (((dd->flags & AES_FLAGS_CBC) || (dd->flags & AES_FLAGS_CFB) || (dd->flags & AES_FLAGS_OFB) || (dd->flags & AES_FLAGS_CTR)) && - dd->req->info) { - atmel_aes_write_n(dd, AES_IVR(0), dd->req->info, 4); + iv) { + atmel_aes_write_n(dd, AES_IVR(0), iv, 4); } - - return 0; } static int atmel_aes_handle_queue(struct atmel_aes_dev *dd, @@ -570,6 +563,7 @@ static int atmel_aes_handle_queue(struct atmel_aes_dev *dd, struct atmel_aes_reqctx *rctx; unsigned long flags; int err, ret = 0; + bool use_dma; spin_lock_irqsave(&dd->lock, flags); if (req) @@ -607,9 +601,11 @@ static int atmel_aes_handle_queue(struct atmel_aes_dev *dd, dd->ctx = ctx; ctx->dd = dd; - err = atmel_aes_write_ctrl(dd); + err = atmel_aes_hw_init(dd); if (!err) { - if (dd->total > ATMEL_AES_DMA_THRESHOLD) + use_dma = (dd->total > ATMEL_AES_DMA_THRESHOLD); + atmel_aes_write_ctrl(dd, use_dma, req->info); + if (use_dma) err = atmel_aes_crypt_dma_start(dd); else err = atmel_aes_crypt_cpu_start(dd); -- 1.8.2.2
next prev parent reply other threads:[~2015-12-17 16:48 UTC|newest] Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-12-17 16:48 [PATCH 00/24] crypto: atmel-aes: global rework of the driver Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 01/24] crypto: atmel-aes: add new version Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 02/24] crypto: atmel-aes: constify value argument of atmel_aes_write_n() Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 03/24] crypto: atmel-aes: change algorithm priorities Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 04/24] crypto: atmel-aes: fix unregistration order of crypto algorithms Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 05/24] crypto: atmel-aes: remove unused header includes Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 06/24] crypto: atmel-aes: propagate error from atmel_aes_hw_version_init() Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen [this message] 2015-12-17 16:48 ` [PATCH 07/24] crypto: atmel-aes: change atmel_aes_write_ctrl() signature Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 08/24] crypto: atmel-aes: make crypto request queue management more generic Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 09/24] crypto: atmel-aes: remove useless write in the Control Register Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 10/24] crypto: atmel-aes: simplify the configuration of the AES IP Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 11/24] crypto: atmel-aes: rework crypto request completion Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 12/24] crypto: atmel-aes: remove unused 'err' member of struct atmel_aes_dev Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 13/24] crypto: atmel-aes: reduce latency of DMA completion Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 14/24] crypto: atmel-aes: remove useless AES_FLAGS_DMA flag Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 16:48 ` [PATCH 15/24] crypto: atmel-aes: fix atmel_aes_remove() Cyrille Pitchen 2015-12-17 16:48 ` Cyrille Pitchen 2015-12-17 17:13 ` [PATCH 16/24] crypto: atmel-aes: improve performances of data transfer Cyrille Pitchen 2015-12-17 17:13 ` Cyrille Pitchen 2015-12-17 17:13 ` [PATCH 17/24] crypto: atmel-aes: use SIZE_IN_WORDS() helper macro Cyrille Pitchen 2015-12-17 17:13 ` Cyrille Pitchen 2015-12-17 17:13 ` [PATCH 18/24] crypto: atmel-aes: fix typo and indentation Cyrille Pitchen 2015-12-17 17:13 ` Cyrille Pitchen 2015-12-17 17:13 ` [PATCH 19/24] crypto: atmel-aes: create sections to regroup functions by usage Cyrille Pitchen 2015-12-17 17:13 ` Cyrille Pitchen 2015-12-17 17:13 ` [PATCH 20/24] crypto: atmel-aes: fix atmel-ctr-aes driver for RFC 3686 Cyrille Pitchen 2015-12-17 17:13 ` Cyrille Pitchen 2015-12-17 17:13 ` [PATCH 21/24] crypto: atmel-aes: fix the counter overflow in CTR mode Cyrille Pitchen 2015-12-17 17:13 ` Cyrille Pitchen 2015-12-17 17:13 ` [PATCH 22/24] crypto: atmel-aes: change the DMA threshold Cyrille Pitchen 2015-12-17 17:13 ` Cyrille Pitchen 2015-12-17 17:13 ` [PATCH 23/24] crypto: atmel-aes: add support to GCM mode Cyrille Pitchen 2015-12-17 17:13 ` Cyrille Pitchen 2015-12-17 17:13 ` [PATCH 24/24] crypto: atmel-aes: add debug facilities to monitor register accesses Cyrille Pitchen 2015-12-17 17:13 ` Cyrille Pitchen 2015-12-23 10:24 ` [PATCH 00/24] crypto: atmel-aes: global rework of the driver Herbert Xu 2015-12-23 10:24 ` Herbert Xu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=034ee506976eb9e9f766cae62ccacf56d848f947.1450366831.git.cyrille.pitchen@atmel.com \ --to=cyrille.pitchen@atmel.com \ --cc=davem@davemloft.net \ --cc=herbert@gondor.apana.org.au \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-crypto@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=nicolas.ferre@atmel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.