aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/talitos.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/crypto/talitos.c')
-rw-r--r--drivers/crypto/talitos.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index dc641c796526..921039e56f87 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -124,6 +124,9 @@ struct talitos_private {
124 void __iomem *reg; 124 void __iomem *reg;
125 int irq[2]; 125 int irq[2];
126 126
127 /* SEC global registers lock */
128 spinlock_t reg_lock ____cacheline_aligned;
129
127 /* SEC version geometry (from device tree node) */ 130 /* SEC version geometry (from device tree node) */
128 unsigned int num_channels; 131 unsigned int num_channels;
129 unsigned int chfifo_len; 132 unsigned int chfifo_len;
@@ -412,6 +415,7 @@ static void talitos_done_##name(unsigned long data) \
412{ \ 415{ \
413 struct device *dev = (struct device *)data; \ 416 struct device *dev = (struct device *)data; \
414 struct talitos_private *priv = dev_get_drvdata(dev); \ 417 struct talitos_private *priv = dev_get_drvdata(dev); \
418 unsigned long flags; \
415 \ 419 \
416 if (ch_done_mask & 1) \ 420 if (ch_done_mask & 1) \
417 flush_channel(dev, 0, 0, 0); \ 421 flush_channel(dev, 0, 0, 0); \
@@ -427,8 +431,10 @@ static void talitos_done_##name(unsigned long data) \
427out: \ 431out: \
428 /* At this point, all completed channels have been processed */ \ 432 /* At this point, all completed channels have been processed */ \
429 /* Unmask done interrupts for channels completed later on. */ \ 433 /* Unmask done interrupts for channels completed later on. */ \
434 spin_lock_irqsave(&priv->reg_lock, flags); \
430 setbits32(priv->reg + TALITOS_IMR, ch_done_mask); \ 435 setbits32(priv->reg + TALITOS_IMR, ch_done_mask); \
431 setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT); \ 436 setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT); \
437 spin_unlock_irqrestore(&priv->reg_lock, flags); \
432} 438}
433DEF_TALITOS_DONE(4ch, TALITOS_ISR_4CHDONE) 439DEF_TALITOS_DONE(4ch, TALITOS_ISR_4CHDONE)
434DEF_TALITOS_DONE(ch0_2, TALITOS_ISR_CH_0_2_DONE) 440DEF_TALITOS_DONE(ch0_2, TALITOS_ISR_CH_0_2_DONE)
@@ -619,22 +625,28 @@ static irqreturn_t talitos_interrupt_##name(int irq, void *data) \
619 struct device *dev = data; \ 625 struct device *dev = data; \
620 struct talitos_private *priv = dev_get_drvdata(dev); \ 626 struct talitos_private *priv = dev_get_drvdata(dev); \
621 u32 isr, isr_lo; \ 627 u32 isr, isr_lo; \
628 unsigned long flags; \
622 \ 629 \
630 spin_lock_irqsave(&priv->reg_lock, flags); \
623 isr = in_be32(priv->reg + TALITOS_ISR); \ 631 isr = in_be32(priv->reg + TALITOS_ISR); \
624 isr_lo = in_be32(priv->reg + TALITOS_ISR_LO); \ 632 isr_lo = in_be32(priv->reg + TALITOS_ISR_LO); \
625 /* Acknowledge interrupt */ \ 633 /* Acknowledge interrupt */ \
626 out_be32(priv->reg + TALITOS_ICR, isr & (ch_done_mask | ch_err_mask)); \ 634 out_be32(priv->reg + TALITOS_ICR, isr & (ch_done_mask | ch_err_mask)); \
627 out_be32(priv->reg + TALITOS_ICR_LO, isr_lo); \ 635 out_be32(priv->reg + TALITOS_ICR_LO, isr_lo); \
628 \ 636 \
629 if (unlikely((isr & ~TALITOS_ISR_4CHDONE) & ch_err_mask || isr_lo)) \ 637 if (unlikely(isr & ch_err_mask || isr_lo)) { \
630 talitos_error(dev, isr, isr_lo); \ 638 spin_unlock_irqrestore(&priv->reg_lock, flags); \
631 else \ 639 talitos_error(dev, isr & ch_err_mask, isr_lo); \
640 } \
641 else { \
632 if (likely(isr & ch_done_mask)) { \ 642 if (likely(isr & ch_done_mask)) { \
633 /* mask further done interrupts. */ \ 643 /* mask further done interrupts. */ \
634 clrbits32(priv->reg + TALITOS_IMR, ch_done_mask); \ 644 clrbits32(priv->reg + TALITOS_IMR, ch_done_mask); \
635 /* done_task will unmask done interrupts at exit */ \ 645 /* done_task will unmask done interrupts at exit */ \
636 tasklet_schedule(&priv->done_task[tlet]); \ 646 tasklet_schedule(&priv->done_task[tlet]); \
637 } \ 647 } \
648 spin_unlock_irqrestore(&priv->reg_lock, flags); \
649 } \
638 \ 650 \
639 return (isr & (ch_done_mask | ch_err_mask) || isr_lo) ? IRQ_HANDLED : \ 651 return (isr & (ch_done_mask | ch_err_mask) || isr_lo) ? IRQ_HANDLED : \
640 IRQ_NONE; \ 652 IRQ_NONE; \
@@ -2719,6 +2731,8 @@ static int talitos_probe(struct platform_device *ofdev)
2719 2731
2720 priv->ofdev = ofdev; 2732 priv->ofdev = ofdev;
2721 2733
2734 spin_lock_init(&priv->reg_lock);
2735
2722 err = talitos_probe_irq(ofdev); 2736 err = talitos_probe_irq(ofdev);
2723 if (err) 2737 if (err)
2724 goto err_out; 2738 goto err_out;