]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: hisilicon - add ZIP device using mode parameter
authorKai Ye <yekai13@huawei.com>
Tue, 5 Jan 2021 06:16:42 +0000 (14:16 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 14 Jan 2021 06:10:26 +0000 (17:10 +1100)
Add 'uacce_mode' parameter for ZIP, which can be set as 0(default) or 1.
'0' means ZIP is only registered to kernel crypto, and '1' means it's
registered to both kernel crypto and UACCE.

Signed-off-by: Kai Ye <yekai13@huawei.com>
Reviewed-by: Zhou Wang <wangzhou1@hisilicon.com>
Reviewed-by: Zaibo Xu <xuzaibo@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/hisilicon/qm.c
drivers/crypto/hisilicon/qm.h
drivers/crypto/hisilicon/zip/zip_main.c

index 10a04ab15570e0b16c42c82d32f5fbb4a191806b..904b99a2244271e06734e5bbcafd57431e7b5c59 100644 (file)
@@ -2206,7 +2206,7 @@ static int qm_alloc_uacce(struct hisi_qm *qm)
        if (IS_ERR(uacce))
                return PTR_ERR(uacce);
 
-       if (uacce->flags & UACCE_DEV_SVA) {
+       if (uacce->flags & UACCE_DEV_SVA && qm->mode == UACCE_MODE_SVA) {
                qm->use_sva = true;
        } else {
                /* only consider sva case */
index 8624d1288afe58b2d74198810a9009a32caed1bb..c1dd0fcf5beb0c9d414f49213a4a6c676139272c 100644 (file)
 /* page number for queue file region */
 #define QM_DOORBELL_PAGE_NR            1
 
+/* uacce mode of the driver */
+#define UACCE_MODE_NOUACCE             0 /* don't use uacce */
+#define UACCE_MODE_SVA                 1 /* use uacce sva mode */
+#define UACCE_MODE_DESC        "0(default) means only register to crypto, 1 means both register to crypto and uacce"
+
 enum qm_stop_reason {
        QM_NORMAL,
        QM_SOFT_RESET,
@@ -249,6 +254,7 @@ struct hisi_qm {
        resource_size_t phys_base;
        resource_size_t phys_size;
        struct uacce_device *uacce;
+       int mode;
 };
 
 struct hisi_qp_status {
@@ -333,6 +339,27 @@ static inline int vfs_num_set(const char *val, const struct kernel_param *kp)
        return param_set_int(val, kp);
 }
 
+static inline int mode_set(const char *val, const struct kernel_param *kp)
+{
+       u32 n;
+       int ret;
+
+       if (!val)
+               return -EINVAL;
+
+       ret = kstrtou32(val, 10, &n);
+       if (ret != 0 || (n != UACCE_MODE_SVA &&
+                        n != UACCE_MODE_NOUACCE))
+               return -EINVAL;
+
+       return param_set_int(val, kp);
+}
+
+static inline int uacce_mode_set(const char *val, const struct kernel_param *kp)
+{
+       return mode_set(val, kp);
+}
+
 static inline void hisi_qm_init_list(struct hisi_qm_list *qm_list)
 {
        INIT_LIST_HEAD(&qm_list->list);
index 4fb5a32bf830f9d387b5ce32ce98f4b0895bd8ba..9cdecff01bcbe477839e63dcd2b2c29895a9bbab 100644 (file)
@@ -211,6 +211,19 @@ static const struct debugfs_reg32 hzip_dfx_regs[] = {
        {"HZIP_DECOMP_LZ77_CURR_ST       ",  0x9cull},
 };
 
+static const struct kernel_param_ops zip_uacce_mode_ops = {
+       .set = uacce_mode_set,
+       .get = param_get_int,
+};
+
+/*
+ * uacce_mode = 0 means zip only register to crypto,
+ * uacce_mode = 1 means zip both register to crypto and uacce.
+ */
+static u32 uacce_mode = UACCE_MODE_NOUACCE;
+module_param_cb(uacce_mode, &zip_uacce_mode_ops, &uacce_mode, 0444);
+MODULE_PARM_DESC(uacce_mode, UACCE_MODE_DESC);
+
 static int pf_q_num_set(const char *val, const struct kernel_param *kp)
 {
        return q_num_set(val, kp, PCI_DEVICE_ID_ZIP_PF);
@@ -752,6 +765,7 @@ static int hisi_zip_qm_init(struct hisi_qm *qm, struct pci_dev *pdev)
        qm->pdev = pdev;
        qm->ver = pdev->revision;
        qm->algs = "zlib\ngzip";
+       qm->mode = uacce_mode;
        qm->sqe_size = HZIP_SQE_SIZE;
        qm->dev_name = hisi_zip_name;