Commit dff36801 authored by Andrey Smirnov's avatar Andrey Smirnov Committed by Herbert Xu

crypto: caam - don't hardcode inpentry size

Using dma_addr_t for elements of JobR input ring is not appropriate on
all 64-bit SoCs, some of which, like i.MX8MQ, use only 32-bit wide
pointers there. Convert all of the code to use explicit helper
function that can be later extended to support i.MX8MQ. No functional
change intended.
Signed-off-by: default avatarAndrey Smirnov <andrew.smirnov@gmail.com>
Cc: Chris Spencer <christopher.spencer@sea.co.uk>
Cc: Cory Tusar <cory.tusar@zii.aero>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Horia Geantă <horia.geanta@nxp.com>
Cc: Aymen Sghaier <aymen.sghaier@nxp.com>
Cc: Leonard Crestez <leonard.crestez@nxp.com>
Cc: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 6c5f898f
...@@ -55,7 +55,8 @@ struct caam_drv_private_jr { ...@@ -55,7 +55,8 @@ struct caam_drv_private_jr {
spinlock_t inplock ____cacheline_aligned; /* Input ring index lock */ spinlock_t inplock ____cacheline_aligned; /* Input ring index lock */
u32 inpring_avail; /* Number of free entries in input ring */ u32 inpring_avail; /* Number of free entries in input ring */
int head; /* entinfo (s/w ring) head index */ int head; /* entinfo (s/w ring) head index */
dma_addr_t *inpring; /* Base of input ring, alloc DMA-safe */ void *inpring; /* Base of input ring, alloc
* DMA-safe */
int out_ring_read_index; /* Output index "tail" */ int out_ring_read_index; /* Output index "tail" */
int tail; /* entinfo (s/w ring) tail index */ int tail; /* entinfo (s/w ring) tail index */
void *outring; /* Base of output ring, DMA-safe */ void *outring; /* Base of output ring, DMA-safe */
......
...@@ -388,7 +388,7 @@ int caam_jr_enqueue(struct device *dev, u32 *desc, ...@@ -388,7 +388,7 @@ int caam_jr_enqueue(struct device *dev, u32 *desc,
head_entry->cbkarg = areq; head_entry->cbkarg = areq;
head_entry->desc_addr_dma = desc_dma; head_entry->desc_addr_dma = desc_dma;
jrp->inpring[head] = cpu_to_caam_dma(desc_dma); jr_inpentry_set(jrp->inpring, head, cpu_to_caam_dma(desc_dma));
/* /*
* Guarantee that the descriptor's DMA address has been written to * Guarantee that the descriptor's DMA address has been written to
...@@ -434,7 +434,7 @@ static int caam_jr_init(struct device *dev) ...@@ -434,7 +434,7 @@ static int caam_jr_init(struct device *dev)
if (error) if (error)
return error; return error;
jrp->inpring = dmam_alloc_coherent(dev, sizeof(*jrp->inpring) * jrp->inpring = dmam_alloc_coherent(dev, SIZEOF_JR_INPENTRY *
JOBR_DEPTH, &inpbusaddr, JOBR_DEPTH, &inpbusaddr,
GFP_KERNEL); GFP_KERNEL);
if (!jrp->inpring) if (!jrp->inpring)
......
...@@ -244,6 +244,15 @@ static inline u32 jr_outentry_jrstatus(void *outring, int hw_idx) ...@@ -244,6 +244,15 @@ static inline u32 jr_outentry_jrstatus(void *outring, int hw_idx)
return jrstatus; return jrstatus;
} }
static inline void jr_inpentry_set(void *inpring, int hw_idx, dma_addr_t val)
{
dma_addr_t *inpentry = inpring;
inpentry[hw_idx] = val;
}
#define SIZEOF_JR_INPENTRY caam_ptr_sz
/* Version registers (Era 10+) e80-eff */ /* Version registers (Era 10+) e80-eff */
struct version_regs { struct version_regs {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment