Skip to content

Commit

Permalink
crypto: caam - treat SGT address pointer as u64
Browse files Browse the repository at this point in the history
Even for i.MX, CAAM is able to use address pointers greater than
32 bits, the address pointer field being interpreted as a double word.
Enforce u64 address pointer in the sec4_sg_entry struct.

This patch fixes the SGT address pointer endianness issue for
32bit platforms where core endianness != caam endianness.

Signed-off-by: Tudor Ambarus <tudor-dan.ambarus@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Tudor Ambarus authored and Herbert Xu committed Oct 2, 2016
1 parent 81422ba commit f97581c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 0 additions & 6 deletions drivers/crypto/caam/desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@
#define SEC4_SG_OFFSET_MASK 0x00001fff

struct sec4_sg_entry {
#if !defined(CONFIG_ARCH_DMA_ADDR_T_64BIT) && \
defined(CONFIG_CRYPTO_DEV_FSL_CAAM_IMX)
u32 rsvd1;
dma_addr_t ptr;
#else
u64 ptr;
#endif /* CONFIG_CRYPTO_DEV_FSL_CAAM_IMX */
u32 len;
u32 bpid_offset;
};
Expand Down
8 changes: 8 additions & 0 deletions drivers/crypto/caam/regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ static inline u64 rd_reg64(void __iomem *reg)
#define caam_dma_to_cpu(value) caam32_to_cpu(value)
#endif /* CONFIG_ARCH_DMA_ADDR_T_64BIT */

#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_IMX
#define cpu_to_caam_dma64(value) \
(((u64)cpu_to_caam32(lower_32_bits(value)) << 32) | \
(u64)cpu_to_caam32(upper_32_bits(value)))
#else
#define cpu_to_caam_dma64(value) cpu_to_caam64(value)
#endif

/*
* jr_outentry
* Represents each entry in a JobR output ring
Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/caam/sg_sw_sec4.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct sec4_sg_entry;
static inline void dma_to_sec4_sg_one(struct sec4_sg_entry *sec4_sg_ptr,
dma_addr_t dma, u32 len, u16 offset)
{
sec4_sg_ptr->ptr = cpu_to_caam_dma(dma);
sec4_sg_ptr->ptr = cpu_to_caam_dma64(dma);
sec4_sg_ptr->len = cpu_to_caam32(len);
sec4_sg_ptr->bpid_offset = cpu_to_caam32(offset & SEC4_SG_OFFSET_MASK);
#ifdef DEBUG
Expand Down

0 comments on commit f97581c

Please sign in to comment.