openbmc.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH u-boot v2019.04-aspeed-openbmc] aspeed/hace: Reset when error occurs
@ 2021-07-15  4:52 Joel Stanley
  2021-07-16 14:54 ` Adriana Kobylak
  0 siblings, 1 reply; 2+ messages in thread
From: Joel Stanley @ 2021-07-15  4:52 UTC (permalink / raw)
  To: openbmc; +Cc: Andrew Jeffery, Adriana Kobylak

Some hasing operations have been triggering an error state.

This can be reproduced on the u-boot command line:

hash sha512 83000128 3762a8

This completes, and the hash is correct. However HACE1C, the status
register, shows an error bit is set 0x00800000.

$ bitfield HACE1C 0x00800000 |grep 0x1
                 Hash input data buffer overflow: 0x1

The next operation is queued, and this never completes. The status
register shows 0x00c00001

$ bitfield HACE1C 0x00c00001 |grep 0x1
                 Hash input data buffer overflow: 0x1
                 Hash input rorate data overflow: 0x1
                                Hash engine busy: 0x1

A HACE reset will clear this state:

mw.l 0x1e6e2040 0x10
mw.l 0x1e6e2044 0x10

Adding code to do this if any error bits are set in the status register
is a workaround for the issue while further debugging is done.

Another workaround is to do an operation before running the problematic
operation. This sequence succeeds:

hash sha512 83000000 10
hash sha512 83000128 3762a8

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 drivers/crypto/aspeed_hace.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/aspeed_hace.c b/drivers/crypto/aspeed_hace.c
index a99fb7c249be..f40779c08816 100644
--- a/drivers/crypto/aspeed_hace.c
+++ b/drivers/crypto/aspeed_hace.c
@@ -100,9 +100,18 @@ static int digest_object(const void *src, unsigned int length, void *digest,
 	writel(HACE_SHA_BE_EN | method, base + ASPEED_HACE_HASH_CMD);
 
 	/* SHA512 hashing appears to have a througput of about 12MB/s */
-	return aspeed_hace_wait_completion(base + ASPEED_HACE_STS,
-			HACE_HASH_ISR,
-			1000 + (length >> 3));
+	aspeed_hace_wait_completion(base + ASPEED_HACE_STS, HACE_HASH_ISR,
+				    1000 + (length >> 3));
+
+	if (readl(base + ASPEED_HACE_STS)) {
+		debug("\nHACE error 0x%08x, resetting\n", readl(base + 0x1c));
+
+		writel(0x10, 0x1e6e2040);
+		mdelay(5);
+		writel(0x10, 0x1e6e2044);
+	}
+
+	return 0;
 }
 
 void hw_sha1(const unsigned char *pbuf, unsigned int buf_len,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-16 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15  4:52 [PATCH u-boot v2019.04-aspeed-openbmc] aspeed/hace: Reset when error occurs Joel Stanley
2021-07-16 14:54 ` Adriana Kobylak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).