aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoria Geantă <horia.geanta@nxp.com>2017-06-19 04:44:46 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2017-06-22 04:47:23 -0400
commit019d62db54017f4639fd7d4f6592f5a116a16695 (patch)
tree00eb5fd28c4f5da4ab8057f96852d48875951bff
parent42cfcafb91dabb0f9d9e08396c39824535948c67 (diff)
crypto: caam - fix gfp allocation flags (part II)
This is the 2nd part of fixing the usage of GFP_KERNEL for memory allocations, taking care off all the places that haven't caused a real problem / failure. Again, the issue being fixed is that GFP_KERNEL should be used only when MAY_SLEEP flag is set, i.e. MAY_BACKLOG flag usage is orthogonal. Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/caam/caamalg.c7
-rw-r--r--drivers/crypto/caam/caamalg_qi.c10
-rw-r--r--drivers/crypto/caam/caamhash.c32
-rw-r--r--drivers/crypto/caam/caampkc.c4
4 files changed, 25 insertions, 28 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 4ecf92e3b404..fde399c88779 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -1187,8 +1187,8 @@ static struct aead_edesc *aead_edesc_alloc(struct aead_request *req,
1187 struct crypto_aead *aead = crypto_aead_reqtfm(req); 1187 struct crypto_aead *aead = crypto_aead_reqtfm(req);
1188 struct caam_ctx *ctx = crypto_aead_ctx(aead); 1188 struct caam_ctx *ctx = crypto_aead_ctx(aead);
1189 struct device *jrdev = ctx->jrdev; 1189 struct device *jrdev = ctx->jrdev;
1190 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 1190 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1191 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 1191 GFP_KERNEL : GFP_ATOMIC;
1192 int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0; 1192 int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0;
1193 struct aead_edesc *edesc; 1193 struct aead_edesc *edesc;
1194 int sec4_sg_index, sec4_sg_len, sec4_sg_bytes; 1194 int sec4_sg_index, sec4_sg_len, sec4_sg_bytes;
@@ -1680,8 +1680,7 @@ static struct ablkcipher_edesc *ablkcipher_giv_edesc_alloc(
1680 struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req); 1680 struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
1681 struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher); 1681 struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher);
1682 struct device *jrdev = ctx->jrdev; 1682 struct device *jrdev = ctx->jrdev;
1683 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 1683 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1684 CRYPTO_TFM_REQ_MAY_SLEEP)) ?
1685 GFP_KERNEL : GFP_ATOMIC; 1684 GFP_KERNEL : GFP_ATOMIC;
1686 int src_nents, mapped_src_nents, dst_nents, mapped_dst_nents; 1685 int src_nents, mapped_src_nents, dst_nents, mapped_dst_nents;
1687 struct ablkcipher_edesc *edesc; 1686 struct ablkcipher_edesc *edesc;
diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c
index ea0e5b8b9171..78c4c0485c58 100644
--- a/drivers/crypto/caam/caamalg_qi.c
+++ b/drivers/crypto/caam/caamalg_qi.c
@@ -555,8 +555,8 @@ static struct aead_edesc *aead_edesc_alloc(struct aead_request *req,
555 struct caam_aead_alg *alg = container_of(crypto_aead_alg(aead), 555 struct caam_aead_alg *alg = container_of(crypto_aead_alg(aead),
556 typeof(*alg), aead); 556 typeof(*alg), aead);
557 struct device *qidev = ctx->qidev; 557 struct device *qidev = ctx->qidev;
558 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 558 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
559 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 559 GFP_KERNEL : GFP_ATOMIC;
560 int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0; 560 int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0;
561 struct aead_edesc *edesc; 561 struct aead_edesc *edesc;
562 dma_addr_t qm_sg_dma, iv_dma = 0; 562 dma_addr_t qm_sg_dma, iv_dma = 0;
@@ -808,8 +808,7 @@ static struct ablkcipher_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request
808 struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req); 808 struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
809 struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher); 809 struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher);
810 struct device *qidev = ctx->qidev; 810 struct device *qidev = ctx->qidev;
811 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 811 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
812 CRYPTO_TFM_REQ_MAY_SLEEP)) ?
813 GFP_KERNEL : GFP_ATOMIC; 812 GFP_KERNEL : GFP_ATOMIC;
814 int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0; 813 int src_nents, mapped_src_nents, dst_nents = 0, mapped_dst_nents = 0;
815 struct ablkcipher_edesc *edesc; 814 struct ablkcipher_edesc *edesc;
@@ -953,8 +952,7 @@ static struct ablkcipher_edesc *ablkcipher_giv_edesc_alloc(
953 struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req); 952 struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
954 struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher); 953 struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher);
955 struct device *qidev = ctx->qidev; 954 struct device *qidev = ctx->qidev;
956 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 955 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
957 CRYPTO_TFM_REQ_MAY_SLEEP)) ?
958 GFP_KERNEL : GFP_ATOMIC; 956 GFP_KERNEL : GFP_ATOMIC;
959 int src_nents, mapped_src_nents, dst_nents, mapped_dst_nents; 957 int src_nents, mapped_src_nents, dst_nents, mapped_dst_nents;
960 struct ablkcipher_edesc *edesc; 958 struct ablkcipher_edesc *edesc;
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index da4f94eab3da..7c44c90ad593 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -719,8 +719,8 @@ static int ahash_update_ctx(struct ahash_request *req)
719 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash); 719 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
720 struct caam_hash_state *state = ahash_request_ctx(req); 720 struct caam_hash_state *state = ahash_request_ctx(req);
721 struct device *jrdev = ctx->jrdev; 721 struct device *jrdev = ctx->jrdev;
722 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 722 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
723 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 723 GFP_KERNEL : GFP_ATOMIC;
724 u8 *buf = current_buf(state); 724 u8 *buf = current_buf(state);
725 int *buflen = current_buflen(state); 725 int *buflen = current_buflen(state);
726 u8 *next_buf = alt_buf(state); 726 u8 *next_buf = alt_buf(state);
@@ -849,8 +849,8 @@ static int ahash_final_ctx(struct ahash_request *req)
849 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash); 849 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
850 struct caam_hash_state *state = ahash_request_ctx(req); 850 struct caam_hash_state *state = ahash_request_ctx(req);
851 struct device *jrdev = ctx->jrdev; 851 struct device *jrdev = ctx->jrdev;
852 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 852 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
853 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 853 GFP_KERNEL : GFP_ATOMIC;
854 int buflen = *current_buflen(state); 854 int buflen = *current_buflen(state);
855 u32 *desc; 855 u32 *desc;
856 int sec4_sg_bytes, sec4_sg_src_index; 856 int sec4_sg_bytes, sec4_sg_src_index;
@@ -926,8 +926,8 @@ static int ahash_finup_ctx(struct ahash_request *req)
926 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash); 926 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
927 struct caam_hash_state *state = ahash_request_ctx(req); 927 struct caam_hash_state *state = ahash_request_ctx(req);
928 struct device *jrdev = ctx->jrdev; 928 struct device *jrdev = ctx->jrdev;
929 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 929 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
930 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 930 GFP_KERNEL : GFP_ATOMIC;
931 int buflen = *current_buflen(state); 931 int buflen = *current_buflen(state);
932 u32 *desc; 932 u32 *desc;
933 int sec4_sg_src_index; 933 int sec4_sg_src_index;
@@ -1013,8 +1013,8 @@ static int ahash_digest(struct ahash_request *req)
1013 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash); 1013 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
1014 struct caam_hash_state *state = ahash_request_ctx(req); 1014 struct caam_hash_state *state = ahash_request_ctx(req);
1015 struct device *jrdev = ctx->jrdev; 1015 struct device *jrdev = ctx->jrdev;
1016 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 1016 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1017 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 1017 GFP_KERNEL : GFP_ATOMIC;
1018 u32 *desc; 1018 u32 *desc;
1019 int digestsize = crypto_ahash_digestsize(ahash); 1019 int digestsize = crypto_ahash_digestsize(ahash);
1020 int src_nents, mapped_nents; 1020 int src_nents, mapped_nents;
@@ -1093,8 +1093,8 @@ static int ahash_final_no_ctx(struct ahash_request *req)
1093 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash); 1093 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
1094 struct caam_hash_state *state = ahash_request_ctx(req); 1094 struct caam_hash_state *state = ahash_request_ctx(req);
1095 struct device *jrdev = ctx->jrdev; 1095 struct device *jrdev = ctx->jrdev;
1096 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 1096 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1097 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 1097 GFP_KERNEL : GFP_ATOMIC;
1098 u8 *buf = current_buf(state); 1098 u8 *buf = current_buf(state);
1099 int buflen = *current_buflen(state); 1099 int buflen = *current_buflen(state);
1100 u32 *desc; 1100 u32 *desc;
@@ -1154,8 +1154,8 @@ static int ahash_update_no_ctx(struct ahash_request *req)
1154 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash); 1154 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
1155 struct caam_hash_state *state = ahash_request_ctx(req); 1155 struct caam_hash_state *state = ahash_request_ctx(req);
1156 struct device *jrdev = ctx->jrdev; 1156 struct device *jrdev = ctx->jrdev;
1157 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 1157 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1158 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 1158 GFP_KERNEL : GFP_ATOMIC;
1159 u8 *buf = current_buf(state); 1159 u8 *buf = current_buf(state);
1160 int *buflen = current_buflen(state); 1160 int *buflen = current_buflen(state);
1161 u8 *next_buf = alt_buf(state); 1161 u8 *next_buf = alt_buf(state);
@@ -1280,8 +1280,8 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
1280 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash); 1280 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
1281 struct caam_hash_state *state = ahash_request_ctx(req); 1281 struct caam_hash_state *state = ahash_request_ctx(req);
1282 struct device *jrdev = ctx->jrdev; 1282 struct device *jrdev = ctx->jrdev;
1283 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 1283 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1284 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 1284 GFP_KERNEL : GFP_ATOMIC;
1285 int buflen = *current_buflen(state); 1285 int buflen = *current_buflen(state);
1286 u32 *desc; 1286 u32 *desc;
1287 int sec4_sg_bytes, sec4_sg_src_index, src_nents, mapped_nents; 1287 int sec4_sg_bytes, sec4_sg_src_index, src_nents, mapped_nents;
@@ -1370,8 +1370,8 @@ static int ahash_update_first(struct ahash_request *req)
1370 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash); 1370 struct caam_hash_ctx *ctx = crypto_ahash_ctx(ahash);
1371 struct caam_hash_state *state = ahash_request_ctx(req); 1371 struct caam_hash_state *state = ahash_request_ctx(req);
1372 struct device *jrdev = ctx->jrdev; 1372 struct device *jrdev = ctx->jrdev;
1373 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 1373 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
1374 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 1374 GFP_KERNEL : GFP_ATOMIC;
1375 u8 *next_buf = alt_buf(state); 1375 u8 *next_buf = alt_buf(state);
1376 int *next_buflen = alt_buflen(state); 1376 int *next_buflen = alt_buflen(state);
1377 int to_hash; 1377 int to_hash;
diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c
index 49cbdcba7883..67df644bb96c 100644
--- a/drivers/crypto/caam/caampkc.c
+++ b/drivers/crypto/caam/caampkc.c
@@ -97,8 +97,8 @@ static struct rsa_edesc *rsa_edesc_alloc(struct akcipher_request *req,
97 struct caam_rsa_ctx *ctx = akcipher_tfm_ctx(tfm); 97 struct caam_rsa_ctx *ctx = akcipher_tfm_ctx(tfm);
98 struct device *dev = ctx->dev; 98 struct device *dev = ctx->dev;
99 struct rsa_edesc *edesc; 99 struct rsa_edesc *edesc;
100 gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG | 100 gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
101 CRYPTO_TFM_REQ_MAY_SLEEP)) ? GFP_KERNEL : GFP_ATOMIC; 101 GFP_KERNEL : GFP_ATOMIC;
102 int sgc; 102 int sgc;
103 int sec4_sg_index, sec4_sg_len = 0, sec4_sg_bytes; 103 int sec4_sg_index, sec4_sg_len = 0, sec4_sg_bytes;
104 int src_nents, dst_nents; 104 int src_nents, dst_nents;