Skip to content

Commit be75969

Browse files
committed
crypto: keembay - Set DMA alignment explicitly
This driver has been implicitly relying on kmalloc alignment to be sufficient for DMA. This may no longer be the case with upcoming arm64 changes. This patch changes it to explicitly request DMA alignment from the Crypto API. Signed-off-by: Herbert Xu <[email protected]>
1 parent b2e2e2d commit be75969

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

drivers/crypto/keembay/keembay-ocs-hcu-core.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ static void kmb_ocs_hcu_dma_cleanup(struct ahash_request *req,
226226
*/
227227
static int kmb_ocs_dma_prepare(struct ahash_request *req)
228228
{
229-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
229+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
230230
struct device *dev = rctx->hcu_dev->dev;
231231
unsigned int remainder = 0;
232232
unsigned int total;
@@ -356,7 +356,7 @@ static int kmb_ocs_dma_prepare(struct ahash_request *req)
356356

357357
static void kmb_ocs_hcu_secure_cleanup(struct ahash_request *req)
358358
{
359-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
359+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
360360

361361
/* Clear buffer of any data. */
362362
memzero_explicit(rctx->buffer, sizeof(rctx->buffer));
@@ -374,7 +374,7 @@ static int kmb_ocs_hcu_handle_queue(struct ahash_request *req)
374374

375375
static int prepare_ipad(struct ahash_request *req)
376376
{
377-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
377+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
378378
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
379379
struct ocs_hcu_ctx *ctx = crypto_ahash_ctx(tfm);
380380
int i;
@@ -414,7 +414,7 @@ static int kmb_ocs_hcu_do_one_request(struct crypto_engine *engine, void *areq)
414414
base);
415415
struct ocs_hcu_dev *hcu_dev = kmb_ocs_hcu_find_dev(req);
416416
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
417-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
417+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
418418
struct ocs_hcu_ctx *tctx = crypto_ahash_ctx(tfm);
419419
int rc;
420420
int i;
@@ -561,7 +561,7 @@ static int kmb_ocs_hcu_do_one_request(struct crypto_engine *engine, void *areq)
561561
static int kmb_ocs_hcu_init(struct ahash_request *req)
562562
{
563563
struct ocs_hcu_dev *hcu_dev = kmb_ocs_hcu_find_dev(req);
564-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
564+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
565565
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
566566
struct ocs_hcu_ctx *ctx = crypto_ahash_ctx(tfm);
567567

@@ -614,7 +614,7 @@ static int kmb_ocs_hcu_init(struct ahash_request *req)
614614

615615
static int kmb_ocs_hcu_update(struct ahash_request *req)
616616
{
617-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
617+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
618618
int rc;
619619

620620
if (!req->nbytes)
@@ -650,7 +650,7 @@ static int kmb_ocs_hcu_update(struct ahash_request *req)
650650
/* Common logic for kmb_ocs_hcu_final() and kmb_ocs_hcu_finup(). */
651651
static int kmb_ocs_hcu_fin_common(struct ahash_request *req)
652652
{
653-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
653+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
654654
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
655655
struct ocs_hcu_ctx *ctx = crypto_ahash_ctx(tfm);
656656
int rc;
@@ -687,7 +687,7 @@ static int kmb_ocs_hcu_fin_common(struct ahash_request *req)
687687

688688
static int kmb_ocs_hcu_final(struct ahash_request *req)
689689
{
690-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
690+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
691691

692692
rctx->sg_data_total = 0;
693693
rctx->sg_data_offset = 0;
@@ -698,7 +698,7 @@ static int kmb_ocs_hcu_final(struct ahash_request *req)
698698

699699
static int kmb_ocs_hcu_finup(struct ahash_request *req)
700700
{
701-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
701+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
702702

703703
rctx->sg_data_total = req->nbytes;
704704
rctx->sg_data_offset = 0;
@@ -726,7 +726,7 @@ static int kmb_ocs_hcu_digest(struct ahash_request *req)
726726

727727
static int kmb_ocs_hcu_export(struct ahash_request *req, void *out)
728728
{
729-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
729+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
730730

731731
/* Intermediate data is always stored and applied per request. */
732732
memcpy(out, rctx, sizeof(*rctx));
@@ -736,7 +736,7 @@ static int kmb_ocs_hcu_export(struct ahash_request *req, void *out)
736736

737737
static int kmb_ocs_hcu_import(struct ahash_request *req, const void *in)
738738
{
739-
struct ocs_hcu_rctx *rctx = ahash_request_ctx(req);
739+
struct ocs_hcu_rctx *rctx = ahash_request_ctx_dma(req);
740740

741741
/* Intermediate data is always stored and applied per request. */
742742
memcpy(rctx, in, sizeof(*rctx));
@@ -822,8 +822,8 @@ static int kmb_ocs_hcu_setkey(struct crypto_ahash *tfm, const u8 *key,
822822
/* Set request size and initialize tfm context. */
823823
static void __cra_init(struct crypto_tfm *tfm, struct ocs_hcu_ctx *ctx)
824824
{
825-
crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
826-
sizeof(struct ocs_hcu_rctx));
825+
crypto_ahash_set_reqsize_dma(__crypto_ahash_cast(tfm),
826+
sizeof(struct ocs_hcu_rctx));
827827

828828
/* Init context to 0. */
829829
memzero_explicit(ctx, sizeof(*ctx));

0 commit comments

Comments
 (0)