Commit 87421984 authored by Ryder Lee's avatar Ryder Lee Committed by Herbert Xu

crypto: mediatek - rework crypto request completion

This patch introduces a new callback 'resume' in the struct mtk_aes_rec.
This callback is run to resume/complete the processing of the crypto
request when woken up by AES interrupts when DMA completion.

This callback will help implementing the GCM mode support in further
patches.
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 382ae57d
...@@ -406,6 +406,15 @@ static int mtk_aes_handle_queue(struct mtk_cryp *cryp, u8 id, ...@@ -406,6 +406,15 @@ static int mtk_aes_handle_queue(struct mtk_cryp *cryp, u8 id,
return ctx->start(cryp, aes); return ctx->start(cryp, aes);
} }
static int mtk_aes_complete(struct mtk_cryp *cryp, struct mtk_aes_rec *aes)
{
aes->flags &= ~AES_FLAGS_BUSY;
aes->areq->complete(aes->areq, 0);
/* Handle new request */
return mtk_aes_handle_queue(cryp, aes->id, NULL);
}
static int mtk_aes_start(struct mtk_cryp *cryp, struct mtk_aes_rec *aes) static int mtk_aes_start(struct mtk_cryp *cryp, struct mtk_aes_rec *aes)
{ {
struct ablkcipher_request *req = ablkcipher_request_cast(aes->areq); struct ablkcipher_request *req = ablkcipher_request_cast(aes->areq);
...@@ -416,6 +425,8 @@ static int mtk_aes_start(struct mtk_cryp *cryp, struct mtk_aes_rec *aes) ...@@ -416,6 +425,8 @@ static int mtk_aes_start(struct mtk_cryp *cryp, struct mtk_aes_rec *aes)
rctx->mode &= AES_FLAGS_MODE_MSK; rctx->mode &= AES_FLAGS_MODE_MSK;
aes->flags = (aes->flags & ~AES_FLAGS_MODE_MSK) | rctx->mode; aes->flags = (aes->flags & ~AES_FLAGS_MODE_MSK) | rctx->mode;
aes->resume = mtk_aes_complete;
err = mtk_aes_map(cryp, aes, req->src, req->dst, req->nbytes); err = mtk_aes_map(cryp, aes, req->src, req->dst, req->nbytes);
if (err) if (err)
return err; return err;
...@@ -458,16 +469,6 @@ static void mtk_aes_unmap(struct mtk_cryp *cryp, struct mtk_aes_rec *aes) ...@@ -458,16 +469,6 @@ static void mtk_aes_unmap(struct mtk_cryp *cryp, struct mtk_aes_rec *aes)
aes->buf, aes->total); aes->buf, aes->total);
} }
static inline void mtk_aes_complete(struct mtk_cryp *cryp,
struct mtk_aes_rec *aes)
{
aes->flags &= ~AES_FLAGS_BUSY;
aes->areq->complete(aes->areq, 0);
/* Handle new request */
mtk_aes_handle_queue(cryp, aes->id, NULL);
}
/* Check and set the AES key to transform state buffer */ /* Check and set the AES key to transform state buffer */
static int mtk_aes_setkey(struct crypto_ablkcipher *tfm, static int mtk_aes_setkey(struct crypto_ablkcipher *tfm,
const u8 *key, u32 keylen) const u8 *key, u32 keylen)
...@@ -591,7 +592,7 @@ static void mtk_aes_enc_task(unsigned long data) ...@@ -591,7 +592,7 @@ static void mtk_aes_enc_task(unsigned long data)
struct mtk_aes_rec *aes = cryp->aes[0]; struct mtk_aes_rec *aes = cryp->aes[0];
mtk_aes_unmap(cryp, aes); mtk_aes_unmap(cryp, aes);
mtk_aes_complete(cryp, aes); aes->resume(cryp, aes);
} }
static void mtk_aes_dec_task(unsigned long data) static void mtk_aes_dec_task(unsigned long data)
...@@ -600,7 +601,7 @@ static void mtk_aes_dec_task(unsigned long data) ...@@ -600,7 +601,7 @@ static void mtk_aes_dec_task(unsigned long data)
struct mtk_aes_rec *aes = cryp->aes[1]; struct mtk_aes_rec *aes = cryp->aes[1];
mtk_aes_unmap(cryp, aes); mtk_aes_unmap(cryp, aes);
mtk_aes_complete(cryp, aes); aes->resume(cryp, aes);
} }
static irqreturn_t mtk_aes_enc_irq(int irq, void *dev_id) static irqreturn_t mtk_aes_enc_irq(int irq, void *dev_id)
......
...@@ -131,6 +131,7 @@ typedef int (*mtk_aes_fn)(struct mtk_cryp *cryp, struct mtk_aes_rec *aes); ...@@ -131,6 +131,7 @@ typedef int (*mtk_aes_fn)(struct mtk_cryp *cryp, struct mtk_aes_rec *aes);
* @dst: the structure that holds destination sg list info * @dst: the structure that holds destination sg list info
* @aligned_sg: the scatter list is use to alignment * @aligned_sg: the scatter list is use to alignment
* @real_dst: pointer to the destination sg list * @real_dst: pointer to the destination sg list
* @resume: pointer to resume function
* @total: request buffer length * @total: request buffer length
* @buf: pointer to page buffer * @buf: pointer to page buffer
* @id: record identification * @id: record identification
...@@ -150,6 +151,8 @@ struct mtk_aes_rec { ...@@ -150,6 +151,8 @@ struct mtk_aes_rec {
struct scatterlist aligned_sg; struct scatterlist aligned_sg;
struct scatterlist *real_dst; struct scatterlist *real_dst;
mtk_aes_fn resume;
size_t total; size_t total;
void *buf; void *buf;
......
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