Skip to content

Commit

Permalink
Revert "crypto: talitos - use kzalloc instead of kmalloc"
Browse files Browse the repository at this point in the history
This reverts commit aacb9e6d6046b2ad02bc7817e3b520886008e27b.

[#127255]
  • Loading branch information
chleroy committed Oct 6, 2017
1 parent 4b643ca commit beaeb34
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion drivers/crypto/talitos.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static void to_talitos_ptr_len(struct talitos_ptr *ptr, unsigned int len,
bool is_sec1)
{
if (is_sec1) {
ptr->res = 0;
ptr->len1 = cpu_to_be16(len);
} else {
ptr->len = cpu_to_be16(len);
Expand Down Expand Up @@ -117,6 +118,7 @@ static void map_single_talitos_ptr(struct device *dev,

to_talitos_ptr_len(ptr, len, is_sec1);
to_talitos_ptr(ptr, dma_addr, is_sec1);
to_talitos_ptr_ext_set(ptr, 0, is_sec1);
}

/*
Expand Down Expand Up @@ -285,6 +287,7 @@ int talitos_submit(struct device *dev, int ch, struct talitos_desc *desc,
/* map descriptor and save caller data */
if (is_sec1) {
desc->hdr1 = desc->hdr;
desc->next_desc = 0;
request->dma_desc = dma_map_single(dev, &desc->hdr1,
TALITOS_DESC_SIZE,
DMA_BIDIRECTIONAL);
Expand Down Expand Up @@ -1096,6 +1099,7 @@ static int sg_to_link_tbl_offset(struct scatterlist *sg, int sg_count,
to_talitos_ptr(link_tbl_ptr + count,
sg_dma_address(sg) + offset, 0);
to_talitos_ptr_len(link_tbl_ptr + count, len, 0);
to_talitos_ptr_ext_set(link_tbl_ptr + count, 0, 0);
count++;
cryptlen -= len;
offset = 0;
Expand All @@ -1121,6 +1125,7 @@ int talitos_sg_map(struct device *dev, struct scatterlist *src,
bool is_sec1 = has_ftr_sec1(priv);

to_talitos_ptr_len(ptr, len, is_sec1);
to_talitos_ptr_ext_set(ptr, 0, is_sec1);

if (sg_count == 1) {
to_talitos_ptr(ptr, sg_dma_address(src) + offset, is_sec1);
Expand Down Expand Up @@ -1192,9 +1197,11 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
if (desc->hdr & DESC_HDR_TYPE_IPSEC_ESP) {
to_talitos_ptr(&desc->ptr[2], edesc->iv_dma, is_sec1);
to_talitos_ptr_len(&desc->ptr[2], ivsize, is_sec1);
to_talitos_ptr_ext_set(&desc->ptr[2], 0, is_sec1);
} else {
to_talitos_ptr(&desc->ptr[3], edesc->iv_dma, is_sec1);
to_talitos_ptr_len(&desc->ptr[3], ivsize, is_sec1);
to_talitos_ptr_ext_set(&desc->ptr[3], 0, is_sec1);
}

/* cipher key */
Expand All @@ -1214,6 +1221,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
* typically 12 for ipsec
*/
to_talitos_ptr_len(&desc->ptr[4], cryptlen, is_sec1);
to_talitos_ptr_ext_set(&desc->ptr[4], 0, is_sec1);

sg_link_tbl_len = cryptlen;

Expand Down Expand Up @@ -1267,6 +1275,8 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
to_talitos_ptr(tbl_ptr, edesc->dma_link_tbl + offset,
is_sec1);
}
} else {
edesc->icv_ool = false;
}

/* ICV data */
Expand Down Expand Up @@ -1376,7 +1386,7 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
alloc_len += icv_stashing ? authsize : 0;
}

edesc = kzalloc(alloc_len, GFP_DMA | flags);
edesc = kmalloc(alloc_len, GFP_DMA | flags);
if (!edesc) {
dev_err(dev, "could not allocate edescriptor\n");
err = ERR_PTR(-ENOMEM);
Expand Down Expand Up @@ -1457,6 +1467,7 @@ static int aead_decrypt(struct aead_request *req)
DESC_HDR_MODE1_MDEU_CICV;

/* reset integrity check result bits */
edesc->desc.hdr_lo = 0;

return ipsec_esp(edesc, req, ipsec_esp_decrypt_hwauth_done);
}
Expand Down Expand Up @@ -1543,10 +1554,12 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
bool is_sec1 = has_ftr_sec1(priv);

/* first DWORD empty */
desc->ptr[0] = zero_entry;

/* cipher iv */
to_talitos_ptr(&desc->ptr[1], edesc->iv_dma, is_sec1);
to_talitos_ptr_len(&desc->ptr[1], ivsize, is_sec1);
to_talitos_ptr_ext_set(&desc->ptr[1], 0, is_sec1);

/* cipher key */
map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen,
Expand Down Expand Up @@ -1585,6 +1598,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
DMA_FROM_DEVICE);

/* last DWORD empty */
desc->ptr[6] = zero_entry;

if (sync_needed)
dma_sync_single_for_device(dev, edesc->dma_link_tbl,
Expand Down Expand Up @@ -1730,6 +1744,7 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
int sg_count;

/* first DWORD empty */
desc->ptr[0] = zero_entry;

/* hash context in */
if (!req_ctx->first || req_ctx->swinit) {
Expand All @@ -1738,6 +1753,8 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
(char *)req_ctx->hw_context,
DMA_TO_DEVICE);
req_ctx->swinit = 0;
} else {
desc->ptr[1] = zero_entry;
}
/* Indicate next op is not the first. */
req_ctx->first = 0;
Expand All @@ -1746,6 +1763,8 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
if (ctx->keylen)
map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen,
(char *)&ctx->key, DMA_TO_DEVICE);
else
desc->ptr[2] = zero_entry;

sg_count = edesc->src_nents ?: 1;
if (is_sec1 && sg_count > 1)
Expand All @@ -1762,6 +1781,7 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
sync_needed = true;

/* fifth DWORD empty */
desc->ptr[4] = zero_entry;

/* hash/HMAC out -or- hash context out */
if (req_ctx->last)
Expand All @@ -1774,6 +1794,7 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
req_ctx->hw_context, DMA_FROM_DEVICE);

/* last DWORD empty */
desc->ptr[6] = zero_entry;

if (is_sec1 && from_talitos_ptr_len(&desc->ptr[3], true) == 0)
talitos_handle_buggy_hash(ctx, edesc, &desc->ptr[3]);
Expand Down
2 changes: 2 additions & 0 deletions drivers/crypto/talitos.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ struct talitos_ptr {
__be32 ptr; /* address */
};

static const struct talitos_ptr zero_entry;

/* descriptor */
struct talitos_desc {
__be32 hdr; /* header high bits */
Expand Down

0 comments on commit beaeb34

Please sign in to comment.