Skip to content

Commit f8c423b

Browse files
jiajiehoherbertx
authored andcommitted
crypto: starfive - Use fallback for unaligned dma access
Dma address mapping fails on unaligned scatterlist offset. Use sw fallback for these cases. Signed-off-by: Jia Jie Ho <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent d7f0164 commit f8c423b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/crypto/starfive/jh7110-aes.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static int starfive_aes_read_authtag(struct starfive_cryp_ctx *ctx)
314314
cryp->total_in, cryp->authsize, 1);
315315
} else {
316316
if (crypto_memneq(cryp->tag_in, cryp->tag_out, cryp->authsize))
317-
return dev_err_probe(cryp->dev, -EBADMSG, "Failed tag verification\n");
317+
return -EBADMSG;
318318
}
319319

320320
return 0;
@@ -753,14 +753,16 @@ static bool starfive_aes_check_unaligned(struct starfive_cryp_dev *cryp,
753753
int i;
754754

755755
for_each_sg(src, tsg, sg_nents(src), i)
756-
if (!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) &&
757-
!sg_is_last(tsg))
756+
if (!IS_ALIGNED(tsg->offset, sizeof(u32)) ||
757+
(!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) &&
758+
!sg_is_last(tsg)))
758759
return true;
759760

760761
if (src != dst)
761762
for_each_sg(dst, tsg, sg_nents(dst), i)
762-
if (!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) &&
763-
!sg_is_last(tsg))
763+
if (!IS_ALIGNED(tsg->offset, sizeof(u32)) ||
764+
(!IS_ALIGNED(tsg->length, AES_BLOCK_SIZE) &&
765+
!sg_is_last(tsg)))
764766
return true;
765767

766768
return false;

0 commit comments

Comments
 (0)