Skip to content

Commit 2786cee

Browse files
Romain Perierherbertx
authored andcommitted
crypto: marvell - Move SRAM I/O operations to step functions
Currently the crypto requests were sent to engines sequentially. This commit moves the SRAM I/O operations from the prepare to the step functions. It provides flexibility for future works and allow to prepare a request while the engine is running. Signed-off-by: Romain Perier <romain.perier@free-electrons.com> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 1bf6682 commit 2786cee

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

drivers/crypto/marvell/cipher.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ static void mv_cesa_ablkcipher_std_step(struct ablkcipher_request *req)
8989
size_t len = min_t(size_t, req->nbytes - sreq->offset,
9090
CESA_SA_SRAM_PAYLOAD_SIZE);
9191

92+
mv_cesa_adjust_op(engine, &sreq->op);
93+
memcpy_toio(engine->sram, &sreq->op, sizeof(sreq->op));
94+
9295
len = sg_pcopy_to_buffer(req->src, creq->src_nents,
9396
engine->sram + CESA_SA_DATA_SRAM_OFFSET,
9497
len, sreq->offset);
@@ -177,12 +180,9 @@ mv_cesa_ablkcipher_std_prepare(struct ablkcipher_request *req)
177180
{
178181
struct mv_cesa_ablkcipher_req *creq = ablkcipher_request_ctx(req);
179182
struct mv_cesa_ablkcipher_std_req *sreq = &creq->std;
180-
struct mv_cesa_engine *engine = creq->base.engine;
181183

182184
sreq->size = 0;
183185
sreq->offset = 0;
184-
mv_cesa_adjust_op(engine, &sreq->op);
185-
memcpy_toio(engine->sram, &sreq->op, sizeof(sreq->op));
186186
}
187187

188188
static inline void mv_cesa_ablkcipher_prepare(struct crypto_async_request *req,

drivers/crypto/marvell/hash.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ static void mv_cesa_ahash_std_step(struct ahash_request *req)
162162
unsigned int new_cache_ptr = 0;
163163
u32 frag_mode;
164164
size_t len;
165+
unsigned int digsize;
166+
int i;
167+
168+
mv_cesa_adjust_op(engine, &creq->op_tmpl);
169+
memcpy_toio(engine->sram, &creq->op_tmpl, sizeof(creq->op_tmpl));
170+
171+
digsize = crypto_ahash_digestsize(crypto_ahash_reqtfm(req));
172+
for (i = 0; i < digsize / 4; i++)
173+
writel_relaxed(creq->state[i], engine->regs + CESA_IVDIG(i));
165174

166175
if (creq->cache_ptr)
167176
memcpy_toio(engine->sram + CESA_SA_DATA_SRAM_OFFSET,
@@ -265,11 +274,8 @@ static void mv_cesa_ahash_std_prepare(struct ahash_request *req)
265274
{
266275
struct mv_cesa_ahash_req *creq = ahash_request_ctx(req);
267276
struct mv_cesa_ahash_std_req *sreq = &creq->req.std;
268-
struct mv_cesa_engine *engine = creq->base.engine;
269277

270278
sreq->offset = 0;
271-
mv_cesa_adjust_op(engine, &creq->op_tmpl);
272-
memcpy_toio(engine->sram, &creq->op_tmpl, sizeof(creq->op_tmpl));
273279
}
274280

275281
static void mv_cesa_ahash_step(struct crypto_async_request *req)
@@ -336,19 +342,13 @@ static void mv_cesa_ahash_prepare(struct crypto_async_request *req,
336342
{
337343
struct ahash_request *ahashreq = ahash_request_cast(req);
338344
struct mv_cesa_ahash_req *creq = ahash_request_ctx(ahashreq);
339-
unsigned int digsize;
340-
int i;
341345

342346
creq->base.engine = engine;
343347

344348
if (mv_cesa_req_get_type(&creq->base) == CESA_DMA_REQ)
345349
mv_cesa_ahash_dma_prepare(ahashreq);
346350
else
347351
mv_cesa_ahash_std_prepare(ahashreq);
348-
349-
digsize = crypto_ahash_digestsize(crypto_ahash_reqtfm(ahashreq));
350-
for (i = 0; i < digsize / 4; i++)
351-
writel_relaxed(creq->state[i], engine->regs + CESA_IVDIG(i));
352352
}
353353

354354
static void mv_cesa_ahash_req_cleanup(struct crypto_async_request *req)

0 commit comments

Comments
 (0)