Exynos: Add hardware accelerated SHA256 and SHA1
PATCH v7 1/4 Exynos: Add hardware accelerated SHA256 and SHA1
Hi Kim,
Quoted 13 lines
Quoted 7 lines · On Mon, 18 Mar 2013 02:06:15 -0400 Akshay Saraswat <[email protected]> wrote:
SHA-256 and SHA-1 accelerated using ACE hardware.
Signed-off-by ARUN MANKUZHI <[email protected]>Signed-off-by Akshay Saraswat <[email protected]>Acked-by Simon Glass <[email protected]>---
+++b/arch/arm/include/asm/arch-exynos/ace_sha.h
ace_sha.hbelongs indrivers/crypto/
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+#define ACE_FC_SELBC_AES (0 << 2) /* AES */ +#define ACE_FC_SELBC_DES (1 << 2) /* DES */nit: comments seem a bit redundant
Few comments look same but they differ.
For example:
"Feed control - BTDMA control" and "Feed control - BRDMA control"
Quoted 53 lines
Review
Quoted 8 lines
(quoted diff) +7
-0+#define ACE_FC_BRDMACARPROT_OFS (2) +#define ACE_FC_BRDMACARCACHE_OFS (5) +#define ACE_FC_BTDMACAWPROT_OFS (2) +#define ACE_FC_BTDMACAWCACHE_OFS (5) +#define ACE_FC_HRDMACARPROT_OFS (2) +#define ACE_FC_HRDMACARCACHE_OFS (5) +#define ACE_FC_SRAMOFFSET_MASK (0xfff)no parens.
Quoted 11 lines
+/**
+ * Computes hash value of input pbuf using ACE
+ *
+ * @paramin_addrA pointer to the input buffer
+ * @param bufleni Byte length of input buffer
+ * @paramout_addrA pointer to the output buffer. When complete
+ * 32 bytes are copied to pout[0]...pout[31]. Thus, a user
+ * should allocate at least 32 bytes at pOut in advance.
+ * @paramhash_typeSHA1 or SHA256
+ *
+ * @return 0 on Success, -1 on Failure (Timeout)...
Review
Quoted 1 line
(quoted diff) +1
-0+ /* Check if status changes within given time limit */leftovers from timeout implementation?
Review
Quoted 11 lines
(quoted diff) +11
-0+ while ((readl(&ace_sha_reg->hash_status) & ACE_HASH_MSGDONE_MASK) == + ACE_HASH_MSGDONE_OFF) { + /* + * PRNG error bit goes HIGH if a PRNG request occurs without + * a complete seed setup. We are using this bit to check h/w + * because proper setup is not expected in that case. + */ + if ((readl(&ace_sha_reg->hash_status) + & ACE_HASH_PRNGERROR_MASK) == ACE_HASH_PRNGERROR_ON) + break; + }so we have:
whilst (
not_done)if (PRNGERROR_ON) break;...and then success-assuming code flow continues after this. What value is this check for
PRNGERROR_ON, if the code isn't going to do anything differently? And what does the status of the RNG have to do with keyless hashing? It sounds like a check for proper initialization (RNG got seeded) is in order here, but only if it's required for the given hash operations (I doubt it, but the h/w might be fussy).
Quoted 2 lines
Kim
PRNG ERROR means setup was not proper which should be the case when h/w is faulty because driver does everything in order. Earlier break was happening which was not correct so changing it to "return -EBUSY" which means code flow should not be the same as the one being successfull.
Regards,
Akshay Saraswat
PATCH v7 1/4 Exynos: Add hardware accelerated SHA256 and SHA1
Quoted 29 lines · On Thu, 21 Mar 2013 03:12:54 -0400 Akshay Saraswat <[email protected]> wrote:
Quoted 21 lines
Review
Quoted 11 lines · On Mon, 18 Mar 2013 02:06:15 -0400 Akshay Saraswat <[email protected]> wrote:
(quoted diff) +11
-0+ while ((readl(&ace_sha_reg->hash_status) & ACE_HASH_MSGDONE_MASK) == + ACE_HASH_MSGDONE_OFF) { + /* + * PRNG error bit goes HIGH if a PRNG request occurs without + * a complete seed setup. We are using this bit to check h/w + * because proper setup is not expected in that case. + */ + if ((readl(&ace_sha_reg->hash_status) + & ACE_HASH_PRNGERROR_MASK) == ACE_HASH_PRNGERROR_ON) + break; + }so we have:
whilst (
not_done)if (PRNGERROR_ON) break;Quoted 7 lines
...and then success-assuming code flow continues after this. What value is this check for
PRNGERROR_ON, if the code isn't going to do anything differently? And what does the status of the RNG have to do with keyless hashing? It sounds like a check for proper initialization (RNG got seeded) is in order here, but only if it's required for the given hash operations (I doubt it, but the h/w might be fussy).
Quoted 2 lines
PRNG ERROR means setup was not proper which should be the case when h/w is faulty because driver does everything in order.
The comment above says:
"PRNG error bit goes HIGH if a PRNG request occurs without a complete seed setup"
But a SHA request isn't a PRNG request. The h/w shouldn't need the PRNG at all to perform a simple SHA.
If this is a general initialization/"setup" check, then do it then. If not, can you do it immediately prior to the wait-for-done after the "setup"? A PRNG error shouldn't be going off in the middle of the wait-for-done loop for a SHA.
Quoted 3 lines
Earlier break was happening which was not correct so changing it to "return
-EBUSY" which means code flow should not be the same as the one being successfull.
-EBUSY? that means the h/w was busy, and carries a "try again" implication (much like -EAGAIN) - I doubt that's what's intended here.
What happened to reverting to s/w, btw?
Kim