diff options
author | Aymen Sghaier <aymen.sghaier@nxp.com> | 2018-06-08 09:19:22 +0200 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | ae65d4006668474839b3cc6742d3a3038b345f9b (patch) | |
tree | f7d6906349b391250735b205a5169b02a4d54ae5 /drivers/crypto/caam | |
parent | d8a9c074d6f105dba2d4f75e23126de0afd17c6e (diff) |
MLK-17233: Fix CAAM pointer size error for i.MX8
While crypto manager tests some descriptors are malformed due to
pointer size not coherent with CAAM specific dma address size
Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
Diffstat (limited to 'drivers/crypto/caam')
-rw-r--r-- | drivers/crypto/caam/desc_constr.h | 36 | ||||
-rw-r--r-- | drivers/crypto/caam/intern.h | 9 | ||||
-rw-r--r-- | drivers/crypto/caam/pdb.h | 18 | ||||
-rw-r--r-- | drivers/crypto/caam/regs.h | 20 |
4 files changed, 49 insertions, 34 deletions
diff --git a/drivers/crypto/caam/desc_constr.h b/drivers/crypto/caam/desc_constr.h index ec5674b5d1a7..5d252de83d37 100644 --- a/drivers/crypto/caam/desc_constr.h +++ b/drivers/crypto/caam/desc_constr.h @@ -2,7 +2,7 @@ * caam descriptor construction helper functions * * Copyright 2008-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP */ #include "desc.h" @@ -10,8 +10,7 @@ #define IMMEDIATE (1 << 23) #define CAAM_CMD_SZ sizeof(u32) -/* CAAM Pointer Size in MCFGR[PS] is 0 by default (32bits) */ -#define CAAM_PTR_SZ sizeof(u32) +#define CAAM_PTR_SZ sizeof(caam_dma_addr_t) #define CAAM_DESC_BYTES_MAX (CAAM_CMD_SZ * MAX_CAAM_DESCSIZE) #define DESC_JOB_IO_LEN (CAAM_CMD_SZ * 5 + CAAM_PTR_SZ * 3) @@ -86,9 +85,9 @@ static inline void init_job_desc_pdb(u32 *desc, u32 options, size_t pdb_bytes) init_job_desc(desc, (((pdb_len + 1) << HDR_START_IDX_SHIFT)) | options); } -static inline void append_ptr(u32 *desc, u32 ptr) +static inline void append_ptr(u32 *desc, caam_dma_addr_t ptr) { - u32 *offset = (u32 *)desc_end(desc); + caam_dma_addr_t *offset = (caam_dma_addr_t *)desc_end(desc); *offset = cpu_to_caam_dma(ptr); @@ -96,8 +95,8 @@ static inline void append_ptr(u32 *desc, u32 ptr) CAAM_PTR_SZ / CAAM_CMD_SZ); } -static inline void init_job_desc_shared(u32 *desc, u32 ptr, int len, - u32 options) +static inline void init_job_desc_shared(u32 *desc, caam_dma_addr_t ptr, + int len, u32 options) { PRINT_POS; init_job_desc(desc, HDR_SHARED | options | @@ -151,7 +150,7 @@ static inline u32 *write_cmd(u32 *desc, u32 command) return desc + 1; } -static inline void append_cmd_ptr(u32 *desc, u32 ptr, int len, +static inline void append_cmd_ptr(u32 *desc, caam_dma_addr_t ptr, int len, u32 command) { append_cmd(desc, command | len); @@ -159,7 +158,7 @@ static inline void append_cmd_ptr(u32 *desc, u32 ptr, int len, } /* Write length after pointer, rather than inside command */ -static inline void append_cmd_ptr_extlen(u32 *desc, u32 ptr, +static inline void append_cmd_ptr_extlen(u32 *desc, caam_dma_addr_t ptr, unsigned int len, u32 command) { append_cmd(desc, command); @@ -222,8 +221,8 @@ APPEND_CMD_LEN(seq_fifo_load, SEQ_FIFO_LOAD) APPEND_CMD_LEN(seq_fifo_store, SEQ_FIFO_STORE) #define APPEND_CMD_PTR(cmd, op) \ -static inline void append_##cmd(u32 *desc, u32 ptr, unsigned int len, \ - u32 options) \ +static inline void append_##cmd(u32 *desc, caam_dma_addr_t ptr, \ + unsigned int len, u32 options) \ { \ PRINT_POS; \ append_cmd_ptr(desc, ptr, len, CMD_##op | options); \ @@ -233,8 +232,8 @@ APPEND_CMD_PTR(load, LOAD) APPEND_CMD_PTR(fifo_load, FIFO_LOAD) APPEND_CMD_PTR(fifo_store, FIFO_STORE) -static inline void append_store(u32 *desc, u32 ptr, unsigned int len, - u32 options) +static inline void append_store(u32 *desc, caam_dma_addr_t ptr, + unsigned int len, u32 options) { u32 cmd_src; @@ -251,9 +250,10 @@ static inline void append_store(u32 *desc, u32 ptr, unsigned int len, } #define APPEND_SEQ_PTR_INTLEN(cmd, op) \ -static inline void append_seq_##cmd##_ptr_intlen(u32 *desc, u32 ptr, \ - unsigned int len, \ - u32 options) \ +static inline void append_seq_##cmd##_ptr_intlen(u32 *desc, \ + caam_dma_addr_t ptr, \ + unsigned int len, \ + u32 options) \ { \ PRINT_POS; \ if (options & (SQIN_RTO | SQIN_PRE)) \ @@ -275,7 +275,7 @@ APPEND_CMD_PTR_TO_IMM(load, LOAD); APPEND_CMD_PTR_TO_IMM(fifo_load, FIFO_LOAD); #define APPEND_CMD_PTR_EXTLEN(cmd, op) \ -static inline void append_##cmd##_extlen(u32 *desc, u32 ptr, \ +static inline void append_##cmd##_extlen(u32 *desc, caam_dma_addr_t ptr, \ unsigned int len, u32 options) \ { \ PRINT_POS; \ @@ -289,7 +289,7 @@ APPEND_CMD_PTR_EXTLEN(seq_out_ptr, SEQ_OUT_PTR) * the size of its type */ #define APPEND_CMD_PTR_LEN(cmd, op, type) \ -static inline void append_##cmd(u32 *desc, u32 ptr, \ +static inline void append_##cmd(u32 *desc, caam_dma_addr_t ptr, \ type len, u32 options) \ { \ PRINT_POS; \ diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index 81d9bbf53a5c..ccddfd688908 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -3,12 +3,13 @@ * Private/internal definitions between modules * * Copyright 2008-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * */ #ifndef INTERN_H #define INTERN_H +#include "regs.h" /* Currently comes from Kconfig param as a ^2 (driver-required) */ #define JOBR_DEPTH (1 << CONFIG_CRYPTO_DEV_FSL_CAAM_RINGSIZE) @@ -35,8 +36,7 @@ struct caam_jrentry_info { void (*callbk)(struct device *dev, u32 *desc, u32 status, void *arg); void *cbkarg; /* Argument per ring entry */ u32 *desc_addr_virt; /* Stored virt addr for postprocessing */ - /* CAAM Pointer Size in MCFGR[PS] is 0 by default (32bits) */ - u32 desc_addr_dma; /* Stored bus addr for done matching */ + caam_dma_addr_t desc_addr_dma; /* Stored bus addr for done matching */ u32 desc_size; /* Stored size for postprocessing, header derived */ }; @@ -58,8 +58,7 @@ struct caam_drv_private_jr { spinlock_t inplock ____cacheline_aligned; /* Input ring index lock */ int inp_ring_write_index; /* Input index "tail" */ int head; /* entinfo (s/w ring) head index */ - /* CAAM Pointer Size in MCFGR[PS] is 0 by default (32bits) */ - u32 *inpring; /* Base of input ring, alloc DMA-safe */ + caam_dma_addr_t *inpring; /* Base of input ring, alloc DMA-safe */ spinlock_t outlock ____cacheline_aligned; /* Output ring index lock */ int out_ring_read_index; /* Output index "tail" */ int tail; /* entinfo (s/w ring) tail index */ diff --git a/drivers/crypto/caam/pdb.h b/drivers/crypto/caam/pdb.h index aaa00dd1c601..63a6ae6de83a 100644 --- a/drivers/crypto/caam/pdb.h +++ b/drivers/crypto/caam/pdb.h @@ -2,12 +2,14 @@ * CAAM Protocol Data Block (PDB) definition header file * * Copyright 2008-2016 Freescale Semiconductor, Inc. + * Copyright 2018 NXP * */ #ifndef CAAM_PDB_H #define CAAM_PDB_H #include "compat.h" +#include "regs.h" /* * PDB- IPSec ESP Header Modification Options @@ -502,10 +504,10 @@ struct dsa_verify_pdb { */ struct rsa_pub_pdb { u32 sgf; - dma_addr_t f_dma; - dma_addr_t g_dma; - dma_addr_t n_dma; - dma_addr_t e_dma; + caam_dma_addr_t f_dma; + caam_dma_addr_t g_dma; + caam_dma_addr_t n_dma; + caam_dma_addr_t e_dma; u32 f_len; } __packed; @@ -519,10 +521,10 @@ struct rsa_pub_pdb { */ struct rsa_priv_f1_pdb { u32 sgf; - dma_addr_t g_dma; - dma_addr_t f_dma; - dma_addr_t n_dma; - dma_addr_t d_dma; + caam_dma_addr_t g_dma; + caam_dma_addr_t f_dma; + caam_dma_addr_t n_dma; + caam_dma_addr_t d_dma; } __packed; #endif diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index df1e0dede8d3..aa296862ce06 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -2,7 +2,7 @@ * CAAM hardware register-level view * * Copyright 2008-2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP */ #ifndef REGS_H @@ -206,12 +206,26 @@ static inline u64 rd_reg64(void __iomem *reg) #endif /* + * On i.MX8 boards the arch is arm64 but the CAAM dma address size is + * 32 bits on 8MQ and 36 bits on 8QM and 8QX. + * For 8QM and 8QM there is a configurable field PS called pointer size + * in the MCFGR register to switch between 32 and 64 (default 32) + * But this register is only accessible by the SECO and is left to its + * default value. + * Here we set the CAAM dma address size to 32 bits for all i.MX8 + */ +#ifdef CONFIG_HAVE_IMX8_SOC +#define caam_dma_addr_t u32 +#else +#define caam_dma_addr_t dma_addr_t +#endif + +/* * jr_outentry * Represents each entry in a JobR output ring */ struct jr_outentry { - /* CAAM Pointer Size in MCFGR[PS] is 0 by default (32bits) */ - u32 desc;/* Pointer to completed descriptor */ + caam_dma_addr_t desc;/* Pointer to completed descriptor */ u32 jrstatus; /* Status for completed descriptor */ } __packed; |