Skip to content

Commit

Permalink
crypto: stm32 - CRC use relaxed function
Browse files Browse the repository at this point in the history
In case of arm soc support, readl and writel will
be optimized using relaxed functions

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Reviewed-by: Fabien Dessenne <fabien.dessenne@st.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
lionel.debieve@st.com authored and Herbert Xu committed Jul 28, 2017
1 parent 430f133 commit 3917751
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/crypto/stm32/stm32_crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ static int stm32_crc_init(struct shash_desc *desc)
spin_unlock_bh(&crc_list.lock);

/* Reset, set key, poly and configure in bit reverse mode */
writel(bitrev32(mctx->key), ctx->crc->regs + CRC_INIT);
writel(bitrev32(mctx->poly), ctx->crc->regs + CRC_POL);
writel(CRC_CR_RESET | CRC_CR_REVERSE, ctx->crc->regs + CRC_CR);
writel_relaxed(bitrev32(mctx->key), ctx->crc->regs + CRC_INIT);
writel_relaxed(bitrev32(mctx->poly), ctx->crc->regs + CRC_POL);
writel_relaxed(CRC_CR_RESET | CRC_CR_REVERSE, ctx->crc->regs + CRC_CR);

/* Store partial result */
ctx->partial = readl(ctx->crc->regs + CRC_DR);
ctx->partial = readl_relaxed(ctx->crc->regs + CRC_DR);
ctx->crc->nb_pending_bytes = 0;

return 0;
Expand All @@ -135,18 +135,19 @@ static int stm32_crc_update(struct shash_desc *desc, const u8 *d8,

if (crc->nb_pending_bytes == sizeof(u32)) {
/* Process completed pending data */
writel(*(u32 *)crc->pending_data, crc->regs + CRC_DR);
writel_relaxed(*(u32 *)crc->pending_data,
crc->regs + CRC_DR);
crc->nb_pending_bytes = 0;
}
}

d32 = (u32 *)d8;
for (i = 0; i < length >> 2; i++)
/* Process 32 bits data */
writel(*(d32++), crc->regs + CRC_DR);
writel_relaxed(*(d32++), crc->regs + CRC_DR);

/* Store partial result */
ctx->partial = readl(crc->regs + CRC_DR);
ctx->partial = readl_relaxed(crc->regs + CRC_DR);

/* Check for pending data (non 32 bits) */
length &= 3;
Expand Down

0 comments on commit 3917751

Please sign in to comment.