crypto: caam/qi2 - add support for dpseci_reset()
authorAndrei Botila <andrei.botila@nxp.com>
Wed, 3 Jun 2020 08:47:04 +0000 (11:47 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 18 Jun 2020 07:19:45 +0000 (17:19 +1000)
Add support for dpseci_reset() command for DPSECI objects.
For DPSECI DPAA2 objects with version lower than v5.4 reset command
was broken in MC f/w.

Signed-off-by: Andrei Botila <andrei.botila@nxp.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg_qi2.c
drivers/crypto/caam/dpseci.c
drivers/crypto/caam/dpseci.h
drivers/crypto/caam/dpseci_cmd.h

index 28669cb..35fbb3a 100644 (file)
@@ -4697,6 +4697,13 @@ static void dpaa2_dpseci_free(struct dpaa2_caam_priv *priv)
 {
        struct device *dev = priv->dev;
        struct fsl_mc_device *ls_dev = to_fsl_mc_device(dev);
+       int err;
+
+       if (DPSECI_VER(priv->major_ver, priv->minor_ver) > DPSECI_VER(5, 3)) {
+               err = dpseci_reset(priv->mc_io, 0, ls_dev->mc_handle);
+               if (err)
+                       dev_err(dev, "dpseci_reset() failed\n");
+       }
 
        dpaa2_dpseci_congestion_free(priv);
        dpseci_close(priv->mc_io, 0, ls_dev->mc_handle);
@@ -4894,6 +4901,14 @@ static int __cold dpaa2_dpseci_setup(struct fsl_mc_device *ls_dev)
 
        dev_info(dev, "dpseci v%d.%d\n", priv->major_ver, priv->minor_ver);
 
+       if (DPSECI_VER(priv->major_ver, priv->minor_ver) > DPSECI_VER(5, 3)) {
+               err = dpseci_reset(priv->mc_io, 0, ls_dev->mc_handle);
+               if (err) {
+                       dev_err(dev, "dpseci_reset() failed\n");
+                       goto err_get_vers;
+               }
+       }
+
        err = dpseci_get_attributes(priv->mc_io, 0, ls_dev->mc_handle,
                                    &priv->dpseci_attr);
        if (err) {
index 8a68531..039df6c 100644 (file)
@@ -104,6 +104,24 @@ int dpseci_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
 }
 
 /**
+ * dpseci_reset() - Reset the DPSECI, returns the object to initial state
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:     Token of DPSECI object
+ *
+ * Return:     '0' on success, error code otherwise
+ */
+int dpseci_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token)
+{
+       struct fsl_mc_command cmd = { 0 };
+
+       cmd.header = mc_encode_cmd_header(DPSECI_CMDID_RESET,
+                                         cmd_flags,
+                                         token);
+       return mc_send_command(mc_io, &cmd);
+}
+
+/**
  * dpseci_is_enabled() - Check if the DPSECI is enabled.
  * @mc_io:     Pointer to MC portal's I/O object
  * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
index 4550e13..6dcd9be 100644 (file)
@@ -59,6 +59,8 @@ int dpseci_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
 
 int dpseci_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
 
+int dpseci_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
+
 int dpseci_is_enabled(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
                      int *en);
 
index 6ab77ea..71a007c 100644 (file)
@@ -33,6 +33,7 @@
 #define DPSECI_CMDID_ENABLE                            DPSECI_CMD_V1(0x002)
 #define DPSECI_CMDID_DISABLE                           DPSECI_CMD_V1(0x003)
 #define DPSECI_CMDID_GET_ATTR                          DPSECI_CMD_V1(0x004)
+#define DPSECI_CMDID_RESET                             DPSECI_CMD_V1(0x005)
 #define DPSECI_CMDID_IS_ENABLED                                DPSECI_CMD_V1(0x006)
 
 #define DPSECI_CMDID_SET_RX_QUEUE                      DPSECI_CMD_V1(0x194)