Commit 64ce56cb authored by Russell King's avatar Russell King Committed by Herbert Xu

crypto: caam - incorporate job descriptor into struct ahash_edesc

Rather than giving the descriptor as hw_desc[0], give it's real size.
All places where we allocate an ahash_edesc incorporate DESC_JOB_IO_LEN
bytes of job descriptor.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent e11793f5
...@@ -604,7 +604,7 @@ struct ahash_edesc { ...@@ -604,7 +604,7 @@ struct ahash_edesc {
int src_nents; int src_nents;
int sec4_sg_bytes; int sec4_sg_bytes;
struct sec4_sg_entry *sec4_sg; struct sec4_sg_entry *sec4_sg;
u32 hw_desc[0]; u32 hw_desc[DESC_JOB_IO_LEN / sizeof(u32)];
}; };
static inline void ahash_unmap(struct device *dev, static inline void ahash_unmap(struct device *dev,
...@@ -815,8 +815,8 @@ static int ahash_update_ctx(struct ahash_request *req) ...@@ -815,8 +815,8 @@ static int ahash_update_ctx(struct ahash_request *req)
* allocate space for base edesc and hw desc commands, * allocate space for base edesc and hw desc commands,
* link tables * link tables
*/ */
edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + edesc = kzalloc(sizeof(*edesc) + sec4_sg_bytes,
sec4_sg_bytes, GFP_DMA | flags); GFP_DMA | flags);
if (!edesc) { if (!edesc) {
dev_err(jrdev, dev_err(jrdev,
"could not allocate extended descriptor\n"); "could not allocate extended descriptor\n");
...@@ -825,8 +825,7 @@ static int ahash_update_ctx(struct ahash_request *req) ...@@ -825,8 +825,7 @@ static int ahash_update_ctx(struct ahash_request *req)
edesc->src_nents = src_nents; edesc->src_nents = src_nents;
edesc->sec4_sg_bytes = sec4_sg_bytes; edesc->sec4_sg_bytes = sec4_sg_bytes;
edesc->sec4_sg = (void *)edesc + sizeof(struct ahash_edesc) + edesc->sec4_sg = (void *)(edesc + 1);
DESC_JOB_IO_LEN;
ret = ctx_map_to_sec4_sg(desc, jrdev, state, ctx->ctx_len, ret = ctx_map_to_sec4_sg(desc, jrdev, state, ctx->ctx_len,
edesc->sec4_sg, DMA_BIDIRECTIONAL); edesc->sec4_sg, DMA_BIDIRECTIONAL);
...@@ -925,8 +924,7 @@ static int ahash_final_ctx(struct ahash_request *req) ...@@ -925,8 +924,7 @@ static int ahash_final_ctx(struct ahash_request *req)
sec4_sg_bytes = sec4_sg_src_index * sizeof(struct sec4_sg_entry); sec4_sg_bytes = sec4_sg_src_index * sizeof(struct sec4_sg_entry);
/* allocate space for base edesc and hw desc commands, link tables */ /* allocate space for base edesc and hw desc commands, link tables */
edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + sec4_sg_bytes, edesc = kzalloc(sizeof(*edesc) + sec4_sg_bytes, GFP_DMA | flags);
GFP_DMA | flags);
if (!edesc) { if (!edesc) {
dev_err(jrdev, "could not allocate extended descriptor\n"); dev_err(jrdev, "could not allocate extended descriptor\n");
return -ENOMEM; return -ENOMEM;
...@@ -937,8 +935,7 @@ static int ahash_final_ctx(struct ahash_request *req) ...@@ -937,8 +935,7 @@ static int ahash_final_ctx(struct ahash_request *req)
init_job_desc_shared(desc, ptr, sh_len, HDR_SHARE_DEFER | HDR_REVERSE); init_job_desc_shared(desc, ptr, sh_len, HDR_SHARE_DEFER | HDR_REVERSE);
edesc->sec4_sg_bytes = sec4_sg_bytes; edesc->sec4_sg_bytes = sec4_sg_bytes;
edesc->sec4_sg = (void *)edesc + sizeof(struct ahash_edesc) + edesc->sec4_sg = (void *)(edesc + 1);
DESC_JOB_IO_LEN;
edesc->src_nents = 0; edesc->src_nents = 0;
ret = ctx_map_to_sec4_sg(desc, jrdev, state, ctx->ctx_len, ret = ctx_map_to_sec4_sg(desc, jrdev, state, ctx->ctx_len,
...@@ -1016,8 +1013,7 @@ static int ahash_finup_ctx(struct ahash_request *req) ...@@ -1016,8 +1013,7 @@ static int ahash_finup_ctx(struct ahash_request *req)
sizeof(struct sec4_sg_entry); sizeof(struct sec4_sg_entry);
/* allocate space for base edesc and hw desc commands, link tables */ /* allocate space for base edesc and hw desc commands, link tables */
edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + sec4_sg_bytes, edesc = kzalloc(sizeof(*edesc) + sec4_sg_bytes, GFP_DMA | flags);
GFP_DMA | flags);
if (!edesc) { if (!edesc) {
dev_err(jrdev, "could not allocate extended descriptor\n"); dev_err(jrdev, "could not allocate extended descriptor\n");
return -ENOMEM; return -ENOMEM;
...@@ -1029,8 +1025,7 @@ static int ahash_finup_ctx(struct ahash_request *req) ...@@ -1029,8 +1025,7 @@ static int ahash_finup_ctx(struct ahash_request *req)
edesc->src_nents = src_nents; edesc->src_nents = src_nents;
edesc->sec4_sg_bytes = sec4_sg_bytes; edesc->sec4_sg_bytes = sec4_sg_bytes;
edesc->sec4_sg = (void *)edesc + sizeof(struct ahash_edesc) + edesc->sec4_sg = (void *)(edesc + 1);
DESC_JOB_IO_LEN;
ret = ctx_map_to_sec4_sg(desc, jrdev, state, ctx->ctx_len, ret = ctx_map_to_sec4_sg(desc, jrdev, state, ctx->ctx_len,
edesc->sec4_sg, DMA_TO_DEVICE); edesc->sec4_sg, DMA_TO_DEVICE);
...@@ -1106,14 +1101,12 @@ static int ahash_digest(struct ahash_request *req) ...@@ -1106,14 +1101,12 @@ static int ahash_digest(struct ahash_request *req)
sec4_sg_bytes = 0; sec4_sg_bytes = 0;
/* allocate space for base edesc and hw desc commands, link tables */ /* allocate space for base edesc and hw desc commands, link tables */
edesc = kzalloc(sizeof(*edesc) + sec4_sg_bytes + DESC_JOB_IO_LEN, edesc = kzalloc(sizeof(*edesc) + sec4_sg_bytes, GFP_DMA | flags);
GFP_DMA | flags);
if (!edesc) { if (!edesc) {
dev_err(jrdev, "could not allocate extended descriptor\n"); dev_err(jrdev, "could not allocate extended descriptor\n");
return -ENOMEM; return -ENOMEM;
} }
edesc->sec4_sg = (void *)edesc + sizeof(struct ahash_edesc) + edesc->sec4_sg = (void *)(edesc + 1);
DESC_JOB_IO_LEN;
edesc->sec4_sg_bytes = sec4_sg_bytes; edesc->sec4_sg_bytes = sec4_sg_bytes;
edesc->src_nents = src_nents; edesc->src_nents = src_nents;
...@@ -1179,7 +1172,7 @@ static int ahash_final_no_ctx(struct ahash_request *req) ...@@ -1179,7 +1172,7 @@ static int ahash_final_no_ctx(struct ahash_request *req)
int sh_len; int sh_len;
/* allocate space for base edesc and hw desc commands, link tables */ /* allocate space for base edesc and hw desc commands, link tables */
edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN, GFP_DMA | flags); edesc = kzalloc(sizeof(*edesc), GFP_DMA | flags);
if (!edesc) { if (!edesc) {
dev_err(jrdev, "could not allocate extended descriptor\n"); dev_err(jrdev, "could not allocate extended descriptor\n");
return -ENOMEM; return -ENOMEM;
...@@ -1261,8 +1254,8 @@ static int ahash_update_no_ctx(struct ahash_request *req) ...@@ -1261,8 +1254,8 @@ static int ahash_update_no_ctx(struct ahash_request *req)
* allocate space for base edesc and hw desc commands, * allocate space for base edesc and hw desc commands,
* link tables * link tables
*/ */
edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + edesc = kzalloc(sizeof(*edesc) + sec4_sg_bytes,
sec4_sg_bytes, GFP_DMA | flags); GFP_DMA | flags);
if (!edesc) { if (!edesc) {
dev_err(jrdev, dev_err(jrdev,
"could not allocate extended descriptor\n"); "could not allocate extended descriptor\n");
...@@ -1271,8 +1264,7 @@ static int ahash_update_no_ctx(struct ahash_request *req) ...@@ -1271,8 +1264,7 @@ static int ahash_update_no_ctx(struct ahash_request *req)
edesc->src_nents = src_nents; edesc->src_nents = src_nents;
edesc->sec4_sg_bytes = sec4_sg_bytes; edesc->sec4_sg_bytes = sec4_sg_bytes;
edesc->sec4_sg = (void *)edesc + sizeof(struct ahash_edesc) + edesc->sec4_sg = (void *)(edesc + 1);
DESC_JOB_IO_LEN;
edesc->dst_dma = 0; edesc->dst_dma = 0;
state->buf_dma = buf_map_to_sec4_sg(jrdev, edesc->sec4_sg, state->buf_dma = buf_map_to_sec4_sg(jrdev, edesc->sec4_sg,
...@@ -1371,8 +1363,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req) ...@@ -1371,8 +1363,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
sizeof(struct sec4_sg_entry); sizeof(struct sec4_sg_entry);
/* allocate space for base edesc and hw desc commands, link tables */ /* allocate space for base edesc and hw desc commands, link tables */
edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + sec4_sg_bytes, edesc = kzalloc(sizeof(*edesc) + sec4_sg_bytes, GFP_DMA | flags);
GFP_DMA | flags);
if (!edesc) { if (!edesc) {
dev_err(jrdev, "could not allocate extended descriptor\n"); dev_err(jrdev, "could not allocate extended descriptor\n");
return -ENOMEM; return -ENOMEM;
...@@ -1384,8 +1375,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req) ...@@ -1384,8 +1375,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
edesc->src_nents = src_nents; edesc->src_nents = src_nents;
edesc->sec4_sg_bytes = sec4_sg_bytes; edesc->sec4_sg_bytes = sec4_sg_bytes;
edesc->sec4_sg = (void *)edesc + sizeof(struct ahash_edesc) + edesc->sec4_sg = (void *)(edesc + 1);
DESC_JOB_IO_LEN;
state->buf_dma = try_buf_map_to_sec4_sg(jrdev, edesc->sec4_sg, buf, state->buf_dma = try_buf_map_to_sec4_sg(jrdev, edesc->sec4_sg, buf,
state->buf_dma, buflen, state->buf_dma, buflen,
...@@ -1470,8 +1460,8 @@ static int ahash_update_first(struct ahash_request *req) ...@@ -1470,8 +1460,8 @@ static int ahash_update_first(struct ahash_request *req)
* allocate space for base edesc and hw desc commands, * allocate space for base edesc and hw desc commands,
* link tables * link tables
*/ */
edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + edesc = kzalloc(sizeof(*edesc) + sec4_sg_bytes,
sec4_sg_bytes, GFP_DMA | flags); GFP_DMA | flags);
if (!edesc) { if (!edesc) {
dev_err(jrdev, dev_err(jrdev,
"could not allocate extended descriptor\n"); "could not allocate extended descriptor\n");
...@@ -1480,8 +1470,7 @@ static int ahash_update_first(struct ahash_request *req) ...@@ -1480,8 +1470,7 @@ static int ahash_update_first(struct ahash_request *req)
edesc->src_nents = src_nents; edesc->src_nents = src_nents;
edesc->sec4_sg_bytes = sec4_sg_bytes; edesc->sec4_sg_bytes = sec4_sg_bytes;
edesc->sec4_sg = (void *)edesc + sizeof(struct ahash_edesc) + edesc->sec4_sg = (void *)(edesc + 1);
DESC_JOB_IO_LEN;
edesc->dst_dma = 0; edesc->dst_dma = 0;
if (src_nents > 1) { if (src_nents > 1) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment