crypto: caam - don't hardcode inpentry size
authorAndrey Smirnov <andrew.smirnov@gmail.com>
Tue, 20 Aug 2019 20:23:58 +0000 (13:23 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 30 Aug 2019 08:05:30 +0000 (18:05 +1000)
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: Andrey 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: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/intern.h
drivers/crypto/caam/jr.c
drivers/crypto/caam/regs.h

index 081805c0f88b6de56b4f3ac08d8b83a396b0692c..c00c7c84ec8452b119c10194e0e5a58e3f47079b 100644 (file)
@@ -55,7 +55,8 @@ struct caam_drv_private_jr {
        spinlock_t inplock ____cacheline_aligned; /* Input ring index lock */
        u32 inpring_avail;      /* Number of free entries in input ring */
        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 tail;                       /* entinfo (s/w ring) tail index */
        void *outring;                  /* Base of output ring, DMA-safe */
index 6c91f38862e4b99cc265bca3952def0011672f0c..417ad52615c6a388f01520eaf05c05b74d7ed7a9 100644 (file)
@@ -388,7 +388,7 @@ int caam_jr_enqueue(struct device *dev, u32 *desc,
        head_entry->cbkarg = areq;
        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
@@ -434,7 +434,7 @@ static int caam_jr_init(struct device *dev)
        if (error)
                return error;
 
-       jrp->inpring = dmam_alloc_coherent(dev, sizeof(*jrp->inpring) *
+       jrp->inpring = dmam_alloc_coherent(dev, SIZEOF_JR_INPENTRY *
                                           JOBR_DEPTH, &inpbusaddr,
                                           GFP_KERNEL);
        if (!jrp->inpring)
index cf73015b3be0d35f984f96f5eeaaff5d916e97a1..6dbb269a3e7e20cedd5fe8e6833787d9d89fc67f 100644 (file)
@@ -244,6 +244,15 @@ static inline u32 jr_outentry_jrstatus(void *outring, int hw_idx)
        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 */
 struct version_regs {