Commit bdb6cf9f authored by Corentin LABBE's avatar Corentin LABBE Committed by Herbert Xu

crypto: sun4i-ss - Replace spinlock_bh by spin_lock_irq{save|restore}

The current sun4i-ss driver could generate data corruption when ciphering/deciphering.
It occurs randomly on end of handled data.
No root cause have been found and the only way to remove it is to replace
all spin_lock_bh by their irq counterparts.

Fixes: 6298e948 ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator")
Signed-off-by: default avatarLABBE Corentin <clabbe.montjoie@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 738f9823
...@@ -35,6 +35,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) ...@@ -35,6 +35,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
unsigned int todo; unsigned int todo;
struct sg_mapping_iter mi, mo; struct sg_mapping_iter mi, mo;
unsigned int oi, oo; /* offset for in and out */ unsigned int oi, oo; /* offset for in and out */
unsigned long flags;
if (areq->nbytes == 0) if (areq->nbytes == 0)
return 0; return 0;
...@@ -49,7 +50,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) ...@@ -49,7 +50,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
return -EINVAL; return -EINVAL;
} }
spin_lock_bh(&ss->slock); spin_lock_irqsave(&ss->slock, flags);
for (i = 0; i < op->keylen; i += 4) for (i = 0; i < op->keylen; i += 4)
writel(*(op->key + i / 4), ss->base + SS_KEY0 + i); writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
...@@ -117,7 +118,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) ...@@ -117,7 +118,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
sg_miter_stop(&mi); sg_miter_stop(&mi);
sg_miter_stop(&mo); sg_miter_stop(&mo);
writel(0, ss->base + SS_CTL); writel(0, ss->base + SS_CTL);
spin_unlock_bh(&ss->slock); spin_unlock_irqrestore(&ss->slock, flags);
return err; return err;
} }
...@@ -149,6 +150,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq) ...@@ -149,6 +150,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
unsigned int ob = 0; /* offset in buf */ unsigned int ob = 0; /* offset in buf */
unsigned int obo = 0; /* offset in bufo*/ unsigned int obo = 0; /* offset in bufo*/
unsigned int obl = 0; /* length of data in bufo */ unsigned int obl = 0; /* length of data in bufo */
unsigned long flags;
if (areq->nbytes == 0) if (areq->nbytes == 0)
return 0; return 0;
...@@ -181,7 +183,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq) ...@@ -181,7 +183,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
if (no_chunk == 1) if (no_chunk == 1)
return sun4i_ss_opti_poll(areq); return sun4i_ss_opti_poll(areq);
spin_lock_bh(&ss->slock); spin_lock_irqsave(&ss->slock, flags);
for (i = 0; i < op->keylen; i += 4) for (i = 0; i < op->keylen; i += 4)
writel(*(op->key + i / 4), ss->base + SS_KEY0 + i); writel(*(op->key + i / 4), ss->base + SS_KEY0 + i);
...@@ -307,7 +309,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq) ...@@ -307,7 +309,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
sg_miter_stop(&mi); sg_miter_stop(&mi);
sg_miter_stop(&mo); sg_miter_stop(&mo);
writel(0, ss->base + SS_CTL); writel(0, ss->base + SS_CTL);
spin_unlock_bh(&ss->slock); spin_unlock_irqrestore(&ss->slock, flags);
return err; return err;
} }
......
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