crypto: inside-secure - reset CDR and RDR rings on module removal
authorOfer Heifetz <oferh@marvell.com>
Thu, 28 Jun 2018 15:15:41 +0000 (17:15 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 8 Jul 2018 16:30:15 +0000 (00:30 +0800)
This patch adds extra steps in the module removal path, to reset the
command and result rings. The corresponding interrupts are cleared, and
the ring address configuration is reset.

Signed-off-by: Ofer Heifetz <oferh@marvell.com>
[Antoine: small reworks, commit message]
Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/inside-secure/safexcel.c

index b70694090353586384c5275a1a8ecb2c8bf384fa..5feb83c6238b889c464eee9fdec6ceb0018f777c 100644 (file)
@@ -1125,6 +1125,24 @@ err_core_clk:
        return ret;
 }
 
+static void safexcel_hw_reset_rings(struct safexcel_crypto_priv *priv)
+{
+       int i;
+
+       for (i = 0; i < priv->config.rings; i++) {
+               /* clear any pending interrupt */
+               writel(GENMASK(5, 0), EIP197_HIA_CDR(priv, i) + EIP197_HIA_xDR_STAT);
+               writel(GENMASK(7, 0), EIP197_HIA_RDR(priv, i) + EIP197_HIA_xDR_STAT);
+
+               /* Reset the CDR base address */
+               writel(0, EIP197_HIA_CDR(priv, i) + EIP197_HIA_xDR_RING_BASE_ADDR_LO);
+               writel(0, EIP197_HIA_CDR(priv, i) + EIP197_HIA_xDR_RING_BASE_ADDR_HI);
+
+               /* Reset the RDR base address */
+               writel(0, EIP197_HIA_RDR(priv, i) + EIP197_HIA_xDR_RING_BASE_ADDR_LO);
+               writel(0, EIP197_HIA_RDR(priv, i) + EIP197_HIA_xDR_RING_BASE_ADDR_HI);
+       }
+}
 
 static int safexcel_remove(struct platform_device *pdev)
 {
@@ -1132,6 +1150,8 @@ static int safexcel_remove(struct platform_device *pdev)
        int i;
 
        safexcel_unregister_algorithms(priv);
+       safexcel_hw_reset_rings(priv);
+
        clk_disable_unprepare(priv->clk);
 
        for (i = 0; i < priv->config.rings; i++)