Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1711880 > unrolled thread
| Started by | Gilad Ben-Yossef <gilad@benyossef.com> |
|---|---|
| First post | 2017-08-15 08:30 +0200 |
| Last post | 2017-08-17 00:20 +0200 |
| Articles | 7 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v3 00/22] staging: ccree: fixes and simplifications Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-15 08:30 +0200
[PATCH v3 09/22] staging: ccree: Fix format/argument mismatches Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-15 08:30 +0200
[PATCH v3 08/22] staging: ccree: remove m32r as supported platform Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-15 08:30 +0200
[PATCH v3 22/22] staging: ccree: remove BUG macro usage Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-15 08:30 +0200
[PATCH v3 10/22] staging: ccree: rewrite GET_DMA_BUFFER_TYPE as func Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-15 08:40 +0200
[PATCH v3 07/22] staging: ccree: remove unused completion Gilad Ben-Yossef <gilad@benyossef.com> - 2017-08-15 08:40 +0200
Re: [PATCH v3 00/22] staging: ccree: fixes and simplifications Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-17 00:20 +0200
| From | Gilad Ben-Yossef <gilad@benyossef.com> |
|---|---|
| Date | 2017-08-15 08:30 +0200 |
| Subject | [PATCH v3 00/22] staging: ccree: fixes and simplifications |
| Message-ID | <ueDwt-6d6-3@gated-at.bofh.it> |
The series includes various bug fixes, code simplification and style
cleanups.
Changer from v2:
- Drop M32R as supported architecture, which resolve the kbuild bot
warnings on Joe Perches patch.
- Bug fix that properly saves last bytes of ciphertext for CTS in
skcipher
- Even more coding style fixes
Changes from v1:
- Rebase on top of current staging-next.
- Added resource release on error simplification patch suggested by
Dan C. as part of the review.
Based on top of staging-next commit 0116ced91d3a
("staging: fsl-mc: add explicit dependencies for compile-tested arches")
Gilad Ben-Yossef (18):
staging: ccree: fix split strings
staging: ccree: kmalloc by sizeof var not type
staging: ccree: simplify resource release on error
staging: ccree: remove unused completion
staging: ccree: remove m32r as supported platform
staging: ccree: rewrite GET_DMA_BUFFER_TYPE as func
staging: ccree: fix line indentation and breaks
staging: ccree: align box comment correctly
staging: ccree: fix line indentation and breaks
staging: ccree: fix struct init braces
staging: ccree: fix line indentation and breaks
staging: ccree: fix spelling mistakes
staging: ccree: clean up comments
staging: ccree: move over to BIT macro for bit defines
staging: ccree: fix code indent
staging: ccree: replace noop macro with inline
staging: ccree: save ciphertext for CTS IV
staging: ccree: remove BUG macro usage
Joe Perches (1):
staging: ccree: Fix format/argument mismatches
Suniel Mahesh (3):
staging: ccree: Replace kzalloc with devm_kzalloc
staging: ccree: Convert to devm_ioremap_resource for map, unmap
staging: ccree: Use platform_get_irq and devm_request_irq
drivers/staging/ccree/Kconfig | 2 +-
drivers/staging/ccree/ssi_aead.c | 1076 ++++++++++++++++---------------
drivers/staging/ccree/ssi_aead.h | 47 +-
drivers/staging/ccree/ssi_buffer_mgr.c | 216 ++++---
drivers/staging/ccree/ssi_buffer_mgr.h | 6 +-
drivers/staging/ccree/ssi_cipher.c | 88 ++-
drivers/staging/ccree/ssi_cipher.h | 10 +-
drivers/staging/ccree/ssi_config.h | 7 +-
drivers/staging/ccree/ssi_driver.c | 306 +++++----
drivers/staging/ccree/ssi_driver.h | 26 +-
drivers/staging/ccree/ssi_hash.c | 598 +++++++++--------
drivers/staging/ccree/ssi_hash.h | 12 +-
drivers/staging/ccree/ssi_ivgen.c | 19 +-
drivers/staging/ccree/ssi_ivgen.h | 3 +-
drivers/staging/ccree/ssi_pm.c | 3 +-
drivers/staging/ccree/ssi_request_mgr.c | 75 ++-
drivers/staging/ccree/ssi_request_mgr.h | 2 +-
drivers/staging/ccree/ssi_sysfs.c | 13 +-
18 files changed, 1364 insertions(+), 1145 deletions(-)
--
2.1.4
[toc] | [next] | [standalone]
| From | Gilad Ben-Yossef <gilad@benyossef.com> |
|---|---|
| Date | 2017-08-15 08:30 +0200 |
| Subject | [PATCH v3 09/22] staging: ccree: Fix format/argument mismatches |
| Message-ID | <ueDww-6d6-47@gated-at.bofh.it> |
| In reply to | #1711880 |
From: Joe Perches <joe@perches.com>
By default, debug logging is disabled by CC_DEBUG not being defined.
Convert SSI_LOG_DEBUG to use no_printk instead of an empty define
to validate formats and arguments.
Fix fallout.
Miscellanea:
o One of the conversions now uses %pR instead of multiple uses of %pad
Signed-off-by: Joe Perches <joe@perches.com>
[ gby: rebase on top of latest changes ]
Acked-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
drivers/staging/ccree/ssi_aead.c | 8 ++++----
drivers/staging/ccree/ssi_buffer_mgr.c | 29 +++++++++++++---------------
drivers/staging/ccree/ssi_cipher.c | 10 +++++-----
drivers/staging/ccree/ssi_driver.c | 10 ++++------
drivers/staging/ccree/ssi_driver.h | 2 +-
drivers/staging/ccree/ssi_hash.c | 34 ++++++++++++++++-----------------
drivers/staging/ccree/ssi_request_mgr.c | 6 +++---
7 files changed, 47 insertions(+), 52 deletions(-)
diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c
index 66eedbe..03533c8 100644
--- a/drivers/staging/ccree/ssi_aead.c
+++ b/drivers/staging/ccree/ssi_aead.c
@@ -103,7 +103,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
if (ctx->enckey) {
dma_free_coherent(dev, AES_MAX_KEY_SIZE, ctx->enckey, ctx->enckey_dma_addr);
SSI_LOG_DEBUG("Freed enckey DMA buffer enckey_dma_addr=%pad\n",
- ctx->enckey_dma_addr);
+ &ctx->enckey_dma_addr);
ctx->enckey_dma_addr = 0;
ctx->enckey = NULL;
}
@@ -117,7 +117,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
xcbc->xcbc_keys_dma_addr);
}
SSI_LOG_DEBUG("Freed xcbc_keys DMA buffer xcbc_keys_dma_addr=%pad\n",
- xcbc->xcbc_keys_dma_addr);
+ &xcbc->xcbc_keys_dma_addr);
xcbc->xcbc_keys_dma_addr = 0;
xcbc->xcbc_keys = NULL;
} else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC auth. */
@@ -128,7 +128,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
hmac->ipad_opad,
hmac->ipad_opad_dma_addr);
SSI_LOG_DEBUG("Freed ipad_opad DMA buffer ipad_opad_dma_addr=%pad\n",
- hmac->ipad_opad_dma_addr);
+ &hmac->ipad_opad_dma_addr);
hmac->ipad_opad_dma_addr = 0;
hmac->ipad_opad = NULL;
}
@@ -137,7 +137,7 @@ static void ssi_aead_exit(struct crypto_aead *tfm)
hmac->padded_authkey,
hmac->padded_authkey_dma_addr);
SSI_LOG_DEBUG("Freed padded_authkey DMA buffer padded_authkey_dma_addr=%pad\n",
- hmac->padded_authkey_dma_addr);
+ &hmac->padded_authkey_dma_addr);
hmac->padded_authkey_dma_addr = 0;
hmac->padded_authkey = NULL;
}
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c
index d7ce293..0b81fd5 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -14,6 +14,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <linux/kernel.h>
#include <linux/crypto.h>
#include <linux/version.h>
#include <crypto/algapi.h>
@@ -33,14 +34,10 @@
#include "ssi_hash.h"
#include "ssi_aead.h"
-#ifdef CC_DEBUG
#define GET_DMA_BUFFER_TYPE(buff_type) ( \
((buff_type) == SSI_DMA_BUF_NULL) ? "BUF_NULL" : \
((buff_type) == SSI_DMA_BUF_DLLI) ? "BUF_DLLI" : \
((buff_type) == SSI_DMA_BUF_MLLI) ? "BUF_MLLI" : "BUF_INVALID")
-#else
-#define GET_DMA_BUFFER_TYPE(buff_type)
-#endif
enum dma_buffer_type {
DMA_NULL_TYPE = -1,
@@ -260,7 +257,7 @@ static int ssi_buffer_mgr_generate_mlli(
mlli_params->mlli_len = (total_nents * LLI_ENTRY_BYTE_SIZE);
SSI_LOG_DEBUG("MLLI params: virt_addr=%pK dma_addr=%pad mlli_len=0x%X\n",
- mlli_params->mlli_virt_addr, mlli_params->mlli_dma_addr,
+ mlli_params->mlli_virt_addr, &mlli_params->mlli_dma_addr,
mlli_params->mlli_len);
build_mlli_exit:
@@ -275,7 +272,7 @@ static inline void ssi_buffer_mgr_add_buffer_entry(
unsigned int index = sgl_data->num_of_buffers;
SSI_LOG_DEBUG("index=%u single_buff=%pad buffer_len=0x%08X is_last=%d\n",
- index, buffer_dma, buffer_len, is_last_entry);
+ index, &buffer_dma, buffer_len, is_last_entry);
sgl_data->nents[index] = 1;
sgl_data->entry[index].buffer_dma = buffer_dma;
sgl_data->offset[index] = 0;
@@ -358,7 +355,7 @@ static int ssi_buffer_mgr_map_scatterlist(
}
SSI_LOG_DEBUG("Mapped sg: dma_address=%pad page=%p addr=%pK offset=%u "
"length=%u\n",
- sg_dma_address(sg),
+ &sg_dma_address(sg),
sg_page(sg),
sg_virt(sg),
sg->offset, sg->length);
@@ -420,7 +417,7 @@ ssi_aead_handle_config_buf(struct device *dev,
}
SSI_LOG_DEBUG("Mapped curr_buff: dma_address=%pad page=%p addr=%pK "
"offset=%u length=%u\n",
- sg_dma_address(&areq_ctx->ccm_adata_sg),
+ &sg_dma_address(&areq_ctx->ccm_adata_sg),
sg_page(&areq_ctx->ccm_adata_sg),
sg_virt(&areq_ctx->ccm_adata_sg),
areq_ctx->ccm_adata_sg.offset,
@@ -451,7 +448,7 @@ static inline int ssi_ahash_handle_curr_buf(struct device *dev,
}
SSI_LOG_DEBUG("Mapped curr_buff: dma_address=%pad page=%p addr=%pK "
"offset=%u length=%u\n",
- sg_dma_address(areq_ctx->buff_sg),
+ &sg_dma_address(areq_ctx->buff_sg),
sg_page(areq_ctx->buff_sg),
sg_virt(areq_ctx->buff_sg),
areq_ctx->buff_sg->offset,
@@ -476,7 +473,7 @@ void ssi_buffer_mgr_unmap_blkcipher_request(
if (likely(req_ctx->gen_ctx.iv_dma_addr != 0)) {
SSI_LOG_DEBUG("Unmapped iv: iv_dma_addr=%pad iv_size=%u\n",
- req_ctx->gen_ctx.iv_dma_addr,
+ &req_ctx->gen_ctx.iv_dma_addr,
ivsize);
dma_unmap_single(dev, req_ctx->gen_ctx.iv_dma_addr,
ivsize,
@@ -537,7 +534,7 @@ int ssi_buffer_mgr_map_blkcipher_request(
}
SSI_LOG_DEBUG("Mapped iv %u B at va=%pK to dma=%pad\n",
ivsize, info,
- req_ctx->gen_ctx.iv_dma_addr);
+ &req_ctx->gen_ctx.iv_dma_addr);
} else {
req_ctx->gen_ctx.iv_dma_addr = 0;
}
@@ -667,7 +664,7 @@ void ssi_buffer_mgr_unmap_aead_request(
*/
if (areq_ctx->mlli_params.curr_pool) {
SSI_LOG_DEBUG("free MLLI buffer: dma=%pad virt=%pK\n",
- areq_ctx->mlli_params.mlli_dma_addr,
+ &areq_ctx->mlli_params.mlli_dma_addr,
areq_ctx->mlli_params.mlli_virt_addr);
dma_pool_free(areq_ctx->mlli_params.curr_pool,
areq_ctx->mlli_params.mlli_virt_addr,
@@ -786,7 +783,7 @@ static inline int ssi_buffer_mgr_aead_chain_iv(
SSI_LOG_DEBUG("Mapped iv %u B at va=%pK to dma=%pad\n",
hw_iv_size, req->iv,
- areq_ctx->gen_ctx.iv_dma_addr);
+ &areq_ctx->gen_ctx.iv_dma_addr);
if (do_chain && areq_ctx->plaintext_authenticate_only) { // TODO: what about CTR?? ask Ron
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
unsigned int iv_size_to_authenc = crypto_aead_ivsize(tfm);
@@ -1711,7 +1708,7 @@ void ssi_buffer_mgr_unmap_hash_request(
*/
if (areq_ctx->mlli_params.curr_pool) {
SSI_LOG_DEBUG("free MLLI buffer: dma=%pad virt=%pK\n",
- areq_ctx->mlli_params.mlli_dma_addr,
+ &areq_ctx->mlli_params.mlli_dma_addr,
areq_ctx->mlli_params.mlli_virt_addr);
dma_pool_free(areq_ctx->mlli_params.curr_pool,
areq_ctx->mlli_params.mlli_virt_addr,
@@ -1721,7 +1718,7 @@ void ssi_buffer_mgr_unmap_hash_request(
if ((src) && likely(areq_ctx->in_nents != 0)) {
SSI_LOG_DEBUG("Unmapped sg src: virt=%pK dma=%pad len=0x%X\n",
sg_virt(src),
- sg_dma_address(src),
+ &sg_dma_address(src),
sg_dma_len(src));
dma_unmap_sg(dev, src,
areq_ctx->in_nents, DMA_TO_DEVICE);
@@ -1730,7 +1727,7 @@ void ssi_buffer_mgr_unmap_hash_request(
if (*prev_len != 0) {
SSI_LOG_DEBUG("Unmapped buffer: areq_ctx->buff_sg=%pK dma=%pad len 0x%X\n",
sg_virt(areq_ctx->buff_sg),
- sg_dma_address(areq_ctx->buff_sg),
+ &sg_dma_address(areq_ctx->buff_sg),
sg_dma_len(areq_ctx->buff_sg));
dma_unmap_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE);
if (!do_revert) {
diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c
index 712b21d..8d65e97 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -212,7 +212,7 @@ static int ssi_blkcipher_init(struct crypto_tfm *tfm)
}
SSI_LOG_DEBUG("Mapped key %u B at va=%pK to dma=%pad\n",
max_key_buf_size, ctx_p->user.key,
- ctx_p->user.key_dma_addr);
+ &ctx_p->user.key_dma_addr);
if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) {
/* Alloc hash tfm for essiv */
@@ -245,7 +245,7 @@ static void ssi_blkcipher_exit(struct crypto_tfm *tfm)
dma_unmap_single(dev, ctx_p->user.key_dma_addr, max_key_buf_size,
DMA_TO_DEVICE);
SSI_LOG_DEBUG("Unmapped key buffer key_dma_addr=%pad\n",
- ctx_p->user.key_dma_addr);
+ &ctx_p->user.key_dma_addr);
/* Free key buffer in context */
kfree(ctx_p->user.key);
@@ -621,9 +621,9 @@ ssi_blkcipher_create_data_desc(
/* Process */
if (likely(req_ctx->dma_buf_type == SSI_DMA_BUF_DLLI)) {
SSI_LOG_DEBUG(" data params addr %pad length 0x%X\n",
- sg_dma_address(src), nbytes);
+ &sg_dma_address(src), nbytes);
SSI_LOG_DEBUG(" data params addr %pad length 0x%X\n",
- sg_dma_address(dst), nbytes);
+ &sg_dma_address(dst), nbytes);
hw_desc_init(&desc[*seq_size]);
set_din_type(&desc[*seq_size], DMA_DLLI, sg_dma_address(src),
nbytes, NS_BIT);
@@ -637,7 +637,7 @@ ssi_blkcipher_create_data_desc(
} else {
/* bypass */
SSI_LOG_DEBUG(" bypass params addr %pad length 0x%X addr 0x%08X\n",
- req_ctx->mlli_params.mlli_dma_addr,
+ &req_ctx->mlli_params.mlli_dma_addr,
req_ctx->mlli_params.mlli_len,
(unsigned int)ctx_p->drvdata->mlli_sram_addr);
hw_desc_init(&desc[*seq_size]);
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 928c988..81cb63d 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -244,6 +244,7 @@ static int init_cc_resources(struct platform_device *plat_dev)
/* Get device resources */
/* First CC registers space */
req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0);
+
/* Map registers space */
new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev,
req_mem_cc_regs);
@@ -253,12 +254,9 @@ static int init_cc_resources(struct platform_device *plat_dev)
goto post_drvdata_err;
}
- SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n",
- req_mem_cc_regs->name,
- req_mem_cc_regs->start,
- req_mem_cc_regs->end);
- SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n",
- &req_mem_cc_regs->start, new_drvdata->cc_base);
+ SSI_LOG_DEBUG("Got MEM resource (%s): %pR\n", req_mem_cc_regs->name,
+ req_mem_cc_regs);
+ SSI_LOG_DEBUG("CC registers mapped to 0x%p\n", new_drvdata->cc_base);
cc_base = new_drvdata->cc_base;
diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h
index 9b6476d..47c648a 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -100,7 +100,7 @@
#ifdef CC_DEBUG
#define SSI_LOG_DEBUG(format, ...) SSI_LOG(KERN_DEBUG, format, ##__VA_ARGS__)
#else /* Debug log messages are removed at compile time for non-DEBUG config. */
-#define SSI_LOG_DEBUG(format, ...) do {} while (0)
+#define SSI_LOG_DEBUG(format, ...) no_printk(format, ##__VA_ARGS__)
#endif
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index 3e7873c..b7d6586 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -1,4 +1,4 @@
-/*
+ /*
* Copyright (C) 2012-2017 ARM Limited or its affiliates.
*
* This program is free software; you can redistribute it and/or modify
@@ -140,7 +140,7 @@ static int ssi_hash_map_result(struct device *dev,
}
SSI_LOG_DEBUG("Mapped digest result buffer %u B at va=%pK to dma=%pad\n",
digestsize, state->digest_result_buff,
- state->digest_result_dma_addr);
+ &state->digest_result_dma_addr);
return 0;
}
@@ -204,7 +204,7 @@ static int ssi_hash_map_request(struct device *dev,
}
SSI_LOG_DEBUG("Mapped digest %d B at va=%pK to dma=%pad\n",
ctx->inter_digestsize, state->digest_buff,
- state->digest_buff_dma_addr);
+ &state->digest_buff_dma_addr);
if (is_hmac) {
dma_sync_single_for_cpu(dev, ctx->digest_buff_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL);
@@ -253,7 +253,7 @@ static int ssi_hash_map_request(struct device *dev,
}
SSI_LOG_DEBUG("Mapped digest len %u B at va=%pK to dma=%pad\n",
HASH_LEN_SIZE, state->digest_bytes_len,
- state->digest_bytes_len_dma_addr);
+ &state->digest_bytes_len_dma_addr);
} else {
state->digest_bytes_len_dma_addr = 0;
}
@@ -268,7 +268,7 @@ static int ssi_hash_map_request(struct device *dev,
}
SSI_LOG_DEBUG("Mapped opad digest %d B at va=%pK to dma=%pad\n",
ctx->inter_digestsize, state->opad_digest_buff,
- state->opad_digest_dma_addr);
+ &state->opad_digest_dma_addr);
} else {
state->opad_digest_dma_addr = 0;
}
@@ -316,21 +316,21 @@ static void ssi_hash_unmap_request(struct device *dev,
dma_unmap_single(dev, state->digest_buff_dma_addr,
ctx->inter_digestsize, DMA_BIDIRECTIONAL);
SSI_LOG_DEBUG("Unmapped digest-buffer: digest_buff_dma_addr=%pad\n",
- state->digest_buff_dma_addr);
+ &state->digest_buff_dma_addr);
state->digest_buff_dma_addr = 0;
}
if (state->digest_bytes_len_dma_addr != 0) {
dma_unmap_single(dev, state->digest_bytes_len_dma_addr,
HASH_LEN_SIZE, DMA_BIDIRECTIONAL);
SSI_LOG_DEBUG("Unmapped digest-bytes-len buffer: digest_bytes_len_dma_addr=%pad\n",
- state->digest_bytes_len_dma_addr);
+ &state->digest_bytes_len_dma_addr);
state->digest_bytes_len_dma_addr = 0;
}
if (state->opad_digest_dma_addr != 0) {
dma_unmap_single(dev, state->opad_digest_dma_addr,
ctx->inter_digestsize, DMA_BIDIRECTIONAL);
SSI_LOG_DEBUG("Unmapped opad-digest: opad_digest_dma_addr=%pad\n",
- state->opad_digest_dma_addr);
+ &state->opad_digest_dma_addr);
state->opad_digest_dma_addr = 0;
}
@@ -353,7 +353,7 @@ static void ssi_hash_unmap_result(struct device *dev,
DMA_BIDIRECTIONAL);
SSI_LOG_DEBUG("unmpa digest result buffer va (%pK) pa (%pad) len %u\n",
state->digest_result_buff,
- state->digest_result_dma_addr,
+ &state->digest_result_dma_addr,
digestsize);
memcpy(result,
state->digest_result_buff,
@@ -997,7 +997,7 @@ static int ssi_hash_setkey(void *hash,
return -ENOMEM;
}
SSI_LOG_DEBUG("mapping key-buffer: key_dma_addr=%pad keylen=%u\n",
- ctx->key_params.key_dma_addr,
+ &ctx->key_params.key_dma_addr,
ctx->key_params.keylen);
if (keylen > blocksize) {
@@ -1141,7 +1141,7 @@ static int ssi_hash_setkey(void *hash,
ctx->key_params.key_dma_addr,
ctx->key_params.keylen, DMA_TO_DEVICE);
SSI_LOG_DEBUG("Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n",
- ctx->key_params.key_dma_addr,
+ &ctx->key_params.key_dma_addr,
ctx->key_params.keylen);
}
return rc;
@@ -1179,7 +1179,7 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash,
return -ENOMEM;
}
SSI_LOG_DEBUG("mapping key-buffer: key_dma_addr=%pad keylen=%u\n",
- ctx->key_params.key_dma_addr,
+ &ctx->key_params.key_dma_addr,
ctx->key_params.keylen);
ctx->is_hmac = true;
@@ -1227,7 +1227,7 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash,
ctx->key_params.key_dma_addr,
ctx->key_params.keylen, DMA_TO_DEVICE);
SSI_LOG_DEBUG("Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n",
- ctx->key_params.key_dma_addr,
+ &ctx->key_params.key_dma_addr,
ctx->key_params.keylen);
return rc;
@@ -1282,7 +1282,7 @@ static void ssi_hash_free_ctx(struct ssi_hash_ctx *ctx)
dma_unmap_single(dev, ctx->digest_buff_dma_addr,
sizeof(ctx->digest_buff), DMA_BIDIRECTIONAL);
SSI_LOG_DEBUG("Unmapped digest-buffer: digest_buff_dma_addr=%pad\n",
- ctx->digest_buff_dma_addr);
+ &ctx->digest_buff_dma_addr);
ctx->digest_buff_dma_addr = 0;
}
if (ctx->opad_tmp_keys_dma_addr != 0) {
@@ -1290,7 +1290,7 @@ static void ssi_hash_free_ctx(struct ssi_hash_ctx *ctx)
sizeof(ctx->opad_tmp_keys_buff),
DMA_BIDIRECTIONAL);
SSI_LOG_DEBUG("Unmapped opad-digest: opad_tmp_keys_dma_addr=%pad\n",
- ctx->opad_tmp_keys_dma_addr);
+ &ctx->opad_tmp_keys_dma_addr);
ctx->opad_tmp_keys_dma_addr = 0;
}
@@ -1311,7 +1311,7 @@ static int ssi_hash_alloc_ctx(struct ssi_hash_ctx *ctx)
}
SSI_LOG_DEBUG("Mapped digest %zu B at va=%pK to dma=%pad\n",
sizeof(ctx->digest_buff), ctx->digest_buff,
- ctx->digest_buff_dma_addr);
+ &ctx->digest_buff_dma_addr);
ctx->opad_tmp_keys_dma_addr = dma_map_single(dev, (void *)ctx->opad_tmp_keys_buff, sizeof(ctx->opad_tmp_keys_buff), DMA_BIDIRECTIONAL);
if (dma_mapping_error(dev, ctx->opad_tmp_keys_dma_addr)) {
@@ -1322,7 +1322,7 @@ static int ssi_hash_alloc_ctx(struct ssi_hash_ctx *ctx)
}
SSI_LOG_DEBUG("Mapped opad_tmp_keys %zu B at va=%pK to dma=%pad\n",
sizeof(ctx->opad_tmp_keys_buff), ctx->opad_tmp_keys_buff,
- ctx->opad_tmp_keys_dma_addr);
+ &ctx->opad_tmp_keys_dma_addr);
ctx->is_hmac = false;
return 0;
diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c
index cae9904..27324bb 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -323,9 +323,9 @@ int send_request(
if (ssi_req->ivgen_dma_addr_len > 0) {
SSI_LOG_DEBUG("Acquire IV from pool into %d DMA addresses %pad, %pad, %pad, IV-size=%u\n",
ssi_req->ivgen_dma_addr_len,
- ssi_req->ivgen_dma_addr[0],
- ssi_req->ivgen_dma_addr[1],
- ssi_req->ivgen_dma_addr[2],
+ &ssi_req->ivgen_dma_addr[0],
+ &ssi_req->ivgen_dma_addr[1],
+ &ssi_req->ivgen_dma_addr[2],
ssi_req->ivgen_size);
/* Acquire IV from pool */
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Gilad Ben-Yossef <gilad@benyossef.com> |
|---|---|
| Date | 2017-08-15 08:30 +0200 |
| Subject | [PATCH v3 08/22] staging: ccree: remove m32r as supported platform |
| Message-ID | <ueDww-6d6-51@gated-at.bofh.it> |
| In reply to | #1711880 |
M32R requires special handling due due to how it has implemented ioread32. It is also an orphaned arch on Linux and doesn't seem to be worth the trouble. So until we have a real user, remove support for it. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> --- drivers/staging/ccree/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ccree/Kconfig b/drivers/staging/ccree/Kconfig index 0b3092b..89af1c5 100644 --- a/drivers/staging/ccree/Kconfig +++ b/drivers/staging/ccree/Kconfig @@ -1,6 +1,6 @@ config CRYPTO_DEV_CCREE tristate "Support for ARM TrustZone CryptoCell C7XX family of Crypto accelerators" - depends on CRYPTO && CRYPTO_HW && OF && HAS_DMA + depends on CRYPTO && CRYPTO_HW && OF && HAS_DMA && !M32R default n select CRYPTO_HASH select CRYPTO_BLKCIPHER -- 2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Gilad Ben-Yossef <gilad@benyossef.com> |
|---|---|
| Date | 2017-08-15 08:30 +0200 |
| Subject | [PATCH v3 22/22] staging: ccree: remove BUG macro usage |
| Message-ID | <ueDww-6d6-49@gated-at.bofh.it> |
| In reply to | #1711880 |
Replace BUG() macro usage that crash the kernel with alternatives
that signal error and/or try to recover.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
drivers/staging/ccree/ssi_buffer_mgr.c | 14 ++++++--------
drivers/staging/ccree/ssi_cipher.c | 1 -
drivers/staging/ccree/ssi_pm.c | 3 ++-
drivers/staging/ccree/ssi_request_mgr.c | 23 +++++++++++++++++------
4 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c
index 051d948..6d5af50 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -86,11 +86,6 @@ static unsigned int ssi_buffer_mgr_get_sgl_nents(
unsigned int nents = 0;
while (nbytes != 0) {
- if (sg_is_chain(sg_list)) {
- SSI_LOG_ERR("Unexpected chained entry in sg (entry =0x%X)\n",
- nents);
- BUG();
- }
if (sg_list->length != 0) {
nents++;
/* get the number of bytes in the last entry */
@@ -861,7 +856,8 @@ static inline int ssi_buffer_mgr_aead_chain_assoc(
* unexpected
*/ if (!current_sg) {
SSI_LOG_ERR("reached end of sg list. unexpected\n");
- BUG();
+ rc = -EINVAL;
+ goto chain_assoc_exit;
}
sg_index += current_sg->length;
mapped_nents++;
@@ -1163,7 +1159,8 @@ static inline int ssi_buffer_mgr_aead_chain_data(
//if have reached the end of the sgl, then this is unexpected
if (!areq_ctx->src_sgl) {
SSI_LOG_ERR("reached end of sg list. unexpected\n");
- BUG();
+ return -EINVAL;
+ goto chain_data_exit;
}
sg_index += areq_ctx->src_sgl->length;
src_mapped_nents--;
@@ -1207,7 +1204,8 @@ static inline int ssi_buffer_mgr_aead_chain_data(
//if have reached the end of the sgl, then this is unexpected
if (!areq_ctx->dst_sgl) {
SSI_LOG_ERR("reached end of sg list. unexpected\n");
- BUG();
+ rc = -EINVAL;
+ goto chain_data_exit;
}
sg_index += areq_ctx->dst_sgl->length;
dst_mapped_nents--;
diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c
index cc550b5..73ba4eb 100644
--- a/drivers/staging/ccree/ssi_cipher.c
+++ b/drivers/staging/ccree/ssi_cipher.c
@@ -543,7 +543,6 @@ ssi_blkcipher_create_setup_desc(
break;
default:
SSI_LOG_ERR("Unsupported cipher mode (%d)\n", cipher_mode);
- BUG();
}
}
diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c
index 31325e6..a50671a 100644
--- a/drivers/staging/ccree/ssi_pm.c
+++ b/drivers/staging/ccree/ssi_pm.c
@@ -109,7 +109,8 @@ int ssi_power_mgr_runtime_put_suspend(struct device *dev)
rc = pm_runtime_put_autosuspend(dev);
} else {
/* Something wrong happens*/
- BUG();
+ SSI_LOG_ERR("request to suspend already suspended queue");
+ rc = -EBUSY;
}
return rc;
}
diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c
index b671eff..8bf72e7 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -366,11 +366,16 @@ int send_request(
enqueue_seq(cc_base, &req_mgr_h->compl_desc, (is_dout ? 0 : 1));
if (unlikely(req_mgr_h->q_free_slots < total_seq_len)) {
- /*This means that there was a problem with the resume*/
- BUG();
+ /* This situation should never occur. Maybe indicating problem
+ * with resuming power. Set the free slot count to 0 and hope
+ * for the best.
+ */
+ SSI_LOG_ERR("HW free slot count mismatch.");
+ req_mgr_h->q_free_slots = 0;
+ } else {
+ /* Update the free slots in HW queue */
+ req_mgr_h->q_free_slots -= total_seq_len;
}
- /* Update the free slots in HW queue */
- req_mgr_h->q_free_slots -= total_seq_len;
spin_unlock_bh(&req_mgr_h->hw_lock);
@@ -459,8 +464,13 @@ static void proc_completions(struct ssi_drvdata *drvdata)
/* Dequeue request */
if (unlikely(request_mgr_handle->req_queue_head == request_mgr_handle->req_queue_tail)) {
- SSI_LOG_ERR("Request queue is empty req_queue_head==req_queue_tail==%u\n", request_mgr_handle->req_queue_head);
- BUG();
+ /* We are supposed to handle a completion but our
+ * queue is empty. This is not normal. Return and
+ * hope for the best.
+ */
+ SSI_LOG_ERR("Request queue is empty head == tail %u\n",
+ request_mgr_handle->req_queue_head);
+ goto out;
}
ssi_req = &request_mgr_handle->req_queue[request_mgr_handle->req_queue_tail];
@@ -486,6 +496,7 @@ static void proc_completions(struct ssi_drvdata *drvdata)
request_mgr_handle->req_queue_tail = (request_mgr_handle->req_queue_tail + 1) & (MAX_REQUEST_QUEUE_SIZE - 1);
SSI_LOG_DEBUG("Dequeue request tail=%u\n", request_mgr_handle->req_queue_tail);
SSI_LOG_DEBUG("Request completed. axi_completed=%d\n", request_mgr_handle->axi_completed);
+out:
#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
rc = ssi_power_mgr_runtime_put_suspend(&plat_dev->dev);
if (rc != 0)
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Gilad Ben-Yossef <gilad@benyossef.com> |
|---|---|
| Date | 2017-08-15 08:40 +0200 |
| Subject | [PATCH v3 10/22] staging: ccree: rewrite GET_DMA_BUFFER_TYPE as func |
| Message-ID | <ueDGa-6fY-15@gated-at.bofh.it> |
| In reply to | #1711880 |
The GET_DMA_BUFFER_TYPE macro was triggering a macro argument reuse
warning from checkpatch. Rewrite the macro as inline function instead
to avoid risk of unintended side effects.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
drivers/staging/ccree/ssi_buffer_mgr.c | 26 +++++++++++++++++---------
drivers/staging/ccree/ssi_buffer_mgr.h | 6 ++++--
2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c
index 0b81fd5..4be7b51 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.c
+++ b/drivers/staging/ccree/ssi_buffer_mgr.c
@@ -34,11 +34,6 @@
#include "ssi_hash.h"
#include "ssi_aead.h"
-#define GET_DMA_BUFFER_TYPE(buff_type) ( \
- ((buff_type) == SSI_DMA_BUF_NULL) ? "BUF_NULL" : \
- ((buff_type) == SSI_DMA_BUF_DLLI) ? "BUF_DLLI" : \
- ((buff_type) == SSI_DMA_BUF_MLLI) ? "BUF_MLLI" : "BUF_INVALID")
-
enum dma_buffer_type {
DMA_NULL_TYPE = -1,
DMA_SGL_TYPE = 1,
@@ -65,6 +60,19 @@ struct buffer_array {
u32 *mlli_nents[MAX_NUM_OF_BUFFERS_IN_MLLI];
};
+static const char *dma_buf_types[SSI_DMA_BUF_TYPE_MAX] = {
+ "BUF_NULL",
+ "BUF_DLLI",
+ "BUF_MLLI"
+ "BUF_INVALID"
+};
+
+static inline const char *dma_buf_type_str(enum ssi_req_dma_buf_type type)
+{
+ type = (type < SSI_DMA_BUF_INVL) ? type : SSI_DMA_BUF_INVL;
+ return dma_buf_types[type];
+}
+
/**
* ssi_buffer_mgr_get_sgl_nents() - Get scatterlist number of entries.
*
@@ -597,7 +605,7 @@ int ssi_buffer_mgr_map_blkcipher_request(
}
SSI_LOG_DEBUG("areq_ctx->dma_buf_type = %s\n",
- GET_DMA_BUFFER_TYPE(req_ctx->dma_buf_type));
+ dma_buf_type_str(req_ctx->dma_buf_type));
return 0;
@@ -827,7 +835,7 @@ static inline int ssi_buffer_mgr_aead_chain_assoc(
areq_ctx->assoc.nents = 0;
areq_ctx->assoc.mlli_nents = 0;
SSI_LOG_DEBUG("Chain assoc of length 0: buff_type=%s nents=%u\n",
- GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type),
+ dma_buf_type_str(areq_ctx->assoc_buff_type),
areq_ctx->assoc.nents);
goto chain_assoc_exit;
}
@@ -879,7 +887,7 @@ static inline int ssi_buffer_mgr_aead_chain_assoc(
if (unlikely((do_chain) ||
(areq_ctx->assoc_buff_type == SSI_DMA_BUF_MLLI))) {
SSI_LOG_DEBUG("Chain assoc: buff_type=%s nents=%u\n",
- GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type),
+ dma_buf_type_str(areq_ctx->assoc_buff_type),
areq_ctx->assoc.nents);
ssi_buffer_mgr_add_scatterlist_entry(
sg_data, areq_ctx->assoc.nents,
@@ -1555,7 +1563,7 @@ int ssi_buffer_mgr_map_hash_request_final(
/* change the buffer index for the unmap function */
areq_ctx->buff_index = (areq_ctx->buff_index ^ 1);
SSI_LOG_DEBUG("areq_ctx->data_dma_buf_type = %s\n",
- GET_DMA_BUFFER_TYPE(areq_ctx->data_dma_buf_type));
+ dma_buf_type_str(areq_ctx->data_dma_buf_type));
return 0;
fail_unmap_din:
diff --git a/drivers/staging/ccree/ssi_buffer_mgr.h b/drivers/staging/ccree/ssi_buffer_mgr.h
index 41f5223..93972fd 100644
--- a/drivers/staging/ccree/ssi_buffer_mgr.h
+++ b/drivers/staging/ccree/ssi_buffer_mgr.h
@@ -28,8 +28,10 @@
enum ssi_req_dma_buf_type {
SSI_DMA_BUF_NULL = 0,
- SSI_DMA_BUF_DLLI,
- SSI_DMA_BUF_MLLI
+ SSI_DMA_BUF_DLLI = 1,
+ SSI_DMA_BUF_MLLI = 2,
+ SSI_DMA_BUF_INVL = 3,
+ SSI_DMA_BUF_TYPE_MAX = 4
};
enum ssi_sg_cpy_direct {
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Gilad Ben-Yossef <gilad@benyossef.com> |
|---|---|
| Date | 2017-08-15 08:40 +0200 |
| Subject | [PATCH v3 07/22] staging: ccree: remove unused completion |
| Message-ID | <ueDGa-6fY-19@gated-at.bofh.it> |
| In reply to | #1711880 |
icache_setup_completion is no longer used. Remove it.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
drivers/staging/ccree/ssi_driver.c | 2 --
drivers/staging/ccree/ssi_driver.h | 1 -
2 files changed, 3 deletions(-)
diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c
index 1b95f90..928c988 100644
--- a/drivers/staging/ccree/ssi_driver.c
+++ b/drivers/staging/ccree/ssi_driver.c
@@ -279,8 +279,6 @@ static int init_cc_resources(struct platform_device *plat_dev)
}
SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq);
- init_completion(&new_drvdata->icache_setup_completion);
-
rc = cc_clk_on(new_drvdata);
if (rc)
goto post_drvdata_err;
diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h
index 88ef370..9b6476d 100644
--- a/drivers/staging/ccree/ssi_driver.h
+++ b/drivers/staging/ccree/ssi_driver.h
@@ -138,7 +138,6 @@ struct ssi_drvdata {
u32 monitor_null_cycles;
struct platform_device *plat_dev;
ssi_sram_addr_t mlli_sram_addr;
- struct completion icache_setup_completion;
void *buff_mgr_handle;
void *hash_handle;
void *aead_handle;
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-08-17 00:20 +0200 |
| Message-ID | <ufePo-4ml-9@gated-at.bofh.it> |
| In reply to | #1711880 |
On Tue, Aug 15, 2017 at 09:26:28AM +0300, Gilad Ben-Yossef wrote: > The series includes various bug fixes, code simplification and style > cleanups. > > Changer from v2: > - Drop M32R as supported architecture, which resolve the kbuild bot > warnings on Joe Perches patch. > - Bug fix that properly saves last bytes of ciphertext for CTS in > skcipher > - Even more coding style fixes This patch series didn't apply at all, please fix up and resend. thanks, greg k-h
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web