Skip to content

Commit

Permalink
drivers: crypto: hash: add cache invalidate after HW triggered
Browse files Browse the repository at this point in the history
Add cache invalidate after HW triggered to insure getting
correct data from DRAM.

Signed-off-by: Neal Liu <neal_liu@aspeedtech.com>
Change-Id: Iec324686e381445c63eb9d12de269a9fb17c4728
  • Loading branch information
Neal-liu committed Oct 13, 2023
1 parent 12c55bf commit b3f9eed
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/crypto/hash_aspeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <crypto/hash.h>
#include <logging/log.h>
#include <sys/byteorder.h>
#include <cache.h>

#include "hace_aspeed.h"
#include "hash_aspeed_priv.h"
Expand Down Expand Up @@ -105,6 +106,7 @@ static void aspeed_ahash_fill_padding(struct aspeed_hash_ctx *ctx,
static int hash_trigger(struct aspeed_hash_ctx *data, int len)
{
struct hace_register_s *hace_register = hace_eng.base;
int ret;

if (hace_register->hace_sts.fields.hash_engine_sts) {
LOG_ERR("HACE error: engine busy\n");
Expand All @@ -124,7 +126,11 @@ static int hash_trigger(struct aspeed_hash_ctx *data, int len)
hace_register->hash_data_len.value = len;
hace_register->hash_cmd_reg.value = data->method;

return aspeed_hash_wait_completion(3000);
ret = aspeed_hash_wait_completion(3000);

cache_data_range(data->digest, 64, K_CACHE_INVD);

return ret;
}

static int aspeed_hash_update(struct hash_ctx *ctx, struct hash_pkt *pkt)
Expand Down

0 comments on commit b3f9eed

Please sign in to comment.