crypto: hisilicon/zip - permit users to specify NUMA node
authorBarry Song <song.bao.hua@hisilicon.com>
Sun, 5 Jul 2020 09:18:59 +0000 (21:18 +1200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 9 Jul 2020 08:25:23 +0000 (18:25 +1000)
If users don't specify NUMA node, the driver will use the ZIP module near
the CPU allocating acomp. Otherwise, it uses the ZIP module according to
the requirement of users.

Cc: Zhou Wang <wangzhou1@hisilicon.com>
Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/hisilicon/zip/zip.h
drivers/crypto/hisilicon/zip/zip_crypto.c
drivers/crypto/hisilicon/zip/zip_main.c

index f3ed4c0..4484be1 100644 (file)
@@ -76,7 +76,7 @@ struct hisi_zip_sqe {
        u32 rsvd1[4];
 };
 
-int zip_create_qps(struct hisi_qp **qps, int ctx_num);
+int zip_create_qps(struct hisi_qp **qps, int ctx_num, int node);
 int hisi_zip_register_to_crypto(void);
 void hisi_zip_unregister_from_crypto(void);
 #endif
index c73707c..01fd6a7 100644 (file)
@@ -158,13 +158,13 @@ static void hisi_zip_release_qp(struct hisi_zip_qp_ctx *ctx)
        hisi_qm_release_qp(ctx->qp);
 }
 
-static int hisi_zip_ctx_init(struct hisi_zip_ctx *hisi_zip_ctx, u8 req_type)
+static int hisi_zip_ctx_init(struct hisi_zip_ctx *hisi_zip_ctx, u8 req_type, int node)
 {
        struct hisi_qp *qps[HZIP_CTX_Q_NUM] = { NULL };
        struct hisi_zip *hisi_zip;
        int ret, i, j;
 
-       ret = zip_create_qps(qps, HZIP_CTX_Q_NUM);
+       ret = zip_create_qps(qps, HZIP_CTX_Q_NUM, node);
        if (ret) {
                pr_err("Can not create zip qps!\n");
                return -ENODEV;
@@ -379,7 +379,7 @@ static int hisi_zip_acomp_init(struct crypto_acomp *tfm)
        struct hisi_zip_ctx *ctx = crypto_tfm_ctx(&tfm->base);
        int ret;
 
-       ret = hisi_zip_ctx_init(ctx, COMP_NAME_TO_TYPE(alg_name));
+       ret = hisi_zip_ctx_init(ctx, COMP_NAME_TO_TYPE(alg_name), tfm->base.node);
        if (ret)
                return ret;
 
index 2229a21..e2845b2 100644 (file)
@@ -234,9 +234,10 @@ static const struct pci_device_id hisi_zip_dev_ids[] = {
 };
 MODULE_DEVICE_TABLE(pci, hisi_zip_dev_ids);
 
-int zip_create_qps(struct hisi_qp **qps, int qp_num)
+int zip_create_qps(struct hisi_qp **qps, int qp_num, int node)
 {
-       int node = cpu_to_node(smp_processor_id());
+       if (node == NUMA_NO_NODE)
+               node = cpu_to_node(smp_processor_id());
 
        return hisi_qm_alloc_qps_node(&zip_devices, qp_num, 0, node, qps);
 }