Commit 18e0e95b authored by Ofer Heifetz's avatar Ofer Heifetz Committed by Herbert Xu

crypto: inside-secure - dynamic ring configuration allocation

The Inside Secure SafeXcel driver currently uses 4 rings, but the
eip197d engines has 8 of them. This patch updates the driver so that
rings are allocated dynamically based on the number of available rings
supported by a given engine.
Signed-off-by: default avatarOfer Heifetz <oferh@marvell.com>
Signed-off-by: default avatarAntoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 53c83e91
...@@ -981,6 +981,13 @@ static int safexcel_probe(struct platform_device *pdev) ...@@ -981,6 +981,13 @@ static int safexcel_probe(struct platform_device *pdev)
safexcel_configure(priv); safexcel_configure(priv);
priv->ring = devm_kzalloc(dev, priv->config.rings * sizeof(*priv->ring),
GFP_KERNEL);
if (!priv->ring) {
ret = -ENOMEM;
goto err_reg_clk;
}
for (i = 0; i < priv->config.rings; i++) { for (i = 0; i < priv->config.rings; i++) {
char irq_name[6] = {0}; /* "ringX\0" */ char irq_name[6] = {0}; /* "ringX\0" */
char wq_name[9] = {0}; /* "wq_ringX\0" */ char wq_name[9] = {0}; /* "wq_ringX\0" */
......
...@@ -487,7 +487,7 @@ enum eip197_fw { ...@@ -487,7 +487,7 @@ enum eip197_fw {
FW_NB FW_NB
}; };
struct safexcel_ring { struct safexcel_desc_ring {
void *base; void *base;
void *base_end; void *base_end;
dma_addr_t base_dma; dma_addr_t base_dma;
...@@ -528,6 +528,35 @@ struct safexcel_work_data { ...@@ -528,6 +528,35 @@ struct safexcel_work_data {
int ring; int ring;
}; };
struct safexcel_ring {
spinlock_t lock;
spinlock_t egress_lock;
struct list_head list;
struct workqueue_struct *workqueue;
struct safexcel_work_data work_data;
/* command/result rings */
struct safexcel_desc_ring cdr;
struct safexcel_desc_ring rdr;
/* queue */
struct crypto_queue queue;
spinlock_t queue_lock;
/* Number of requests in the engine. */
int requests;
/* The ring is currently handling at least one request */
bool busy;
/* Store for current requests when bailing out of the dequeueing
* function when no enough resources are available.
*/
struct crypto_async_request *req;
struct crypto_async_request *backlog;
};
enum safexcel_eip_version { enum safexcel_eip_version {
EIP97IES = BIT(0), EIP97IES = BIT(0),
EIP197B = BIT(1), EIP197B = BIT(1),
...@@ -566,34 +595,7 @@ struct safexcel_crypto_priv { ...@@ -566,34 +595,7 @@ struct safexcel_crypto_priv {
atomic_t ring_used; atomic_t ring_used;
struct { struct safexcel_ring *ring;
spinlock_t lock;
spinlock_t egress_lock;
struct list_head list;
struct workqueue_struct *workqueue;
struct safexcel_work_data work_data;
/* command/result rings */
struct safexcel_ring cdr;
struct safexcel_ring rdr;
/* queue */
struct crypto_queue queue;
spinlock_t queue_lock;
/* Number of requests in the engine. */
int requests;
/* The ring is currently handling at least one request */
bool busy;
/* Store for current requests when bailing out of the dequeueing
* function when no enough resources are available.
*/
struct crypto_async_request *req;
struct crypto_async_request *backlog;
} ring[EIP197_MAX_RINGS];
}; };
struct safexcel_context { struct safexcel_context {
...@@ -651,13 +653,13 @@ int safexcel_invalidate_cache(struct crypto_async_request *async, ...@@ -651,13 +653,13 @@ int safexcel_invalidate_cache(struct crypto_async_request *async,
dma_addr_t ctxr_dma, int ring, dma_addr_t ctxr_dma, int ring,
struct safexcel_request *request); struct safexcel_request *request);
int safexcel_init_ring_descriptors(struct safexcel_crypto_priv *priv, int safexcel_init_ring_descriptors(struct safexcel_crypto_priv *priv,
struct safexcel_ring *cdr, struct safexcel_desc_ring *cdr,
struct safexcel_ring *rdr); struct safexcel_desc_ring *rdr);
int safexcel_select_ring(struct safexcel_crypto_priv *priv); int safexcel_select_ring(struct safexcel_crypto_priv *priv);
void *safexcel_ring_next_rptr(struct safexcel_crypto_priv *priv, void *safexcel_ring_next_rptr(struct safexcel_crypto_priv *priv,
struct safexcel_ring *ring); struct safexcel_desc_ring *ring);
void safexcel_ring_rollback_wptr(struct safexcel_crypto_priv *priv, void safexcel_ring_rollback_wptr(struct safexcel_crypto_priv *priv,
struct safexcel_ring *ring); struct safexcel_desc_ring *ring);
struct safexcel_command_desc *safexcel_add_cdesc(struct safexcel_crypto_priv *priv, struct safexcel_command_desc *safexcel_add_cdesc(struct safexcel_crypto_priv *priv,
int ring_id, int ring_id,
bool first, bool last, bool first, bool last,
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#include "safexcel.h" #include "safexcel.h"
int safexcel_init_ring_descriptors(struct safexcel_crypto_priv *priv, int safexcel_init_ring_descriptors(struct safexcel_crypto_priv *priv,
struct safexcel_ring *cdr, struct safexcel_desc_ring *cdr,
struct safexcel_ring *rdr) struct safexcel_desc_ring *rdr)
{ {
cdr->offset = sizeof(u32) * priv->config.cd_offset; cdr->offset = sizeof(u32) * priv->config.cd_offset;
cdr->base = dmam_alloc_coherent(priv->dev, cdr->base = dmam_alloc_coherent(priv->dev,
...@@ -46,7 +46,7 @@ inline int safexcel_select_ring(struct safexcel_crypto_priv *priv) ...@@ -46,7 +46,7 @@ inline int safexcel_select_ring(struct safexcel_crypto_priv *priv)
} }
static void *safexcel_ring_next_wptr(struct safexcel_crypto_priv *priv, static void *safexcel_ring_next_wptr(struct safexcel_crypto_priv *priv,
struct safexcel_ring *ring) struct safexcel_desc_ring *ring)
{ {
void *ptr = ring->write; void *ptr = ring->write;
...@@ -62,7 +62,7 @@ static void *safexcel_ring_next_wptr(struct safexcel_crypto_priv *priv, ...@@ -62,7 +62,7 @@ static void *safexcel_ring_next_wptr(struct safexcel_crypto_priv *priv,
} }
void *safexcel_ring_next_rptr(struct safexcel_crypto_priv *priv, void *safexcel_ring_next_rptr(struct safexcel_crypto_priv *priv,
struct safexcel_ring *ring) struct safexcel_desc_ring *ring)
{ {
void *ptr = ring->read; void *ptr = ring->read;
...@@ -78,7 +78,7 @@ void *safexcel_ring_next_rptr(struct safexcel_crypto_priv *priv, ...@@ -78,7 +78,7 @@ void *safexcel_ring_next_rptr(struct safexcel_crypto_priv *priv,
} }
void safexcel_ring_rollback_wptr(struct safexcel_crypto_priv *priv, void safexcel_ring_rollback_wptr(struct safexcel_crypto_priv *priv,
struct safexcel_ring *ring) struct safexcel_desc_ring *ring)
{ {
if (!ring->nr) if (!ring->nr)
return; return;
......
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