crypto: qat - replace get_current_node() with numa_node_id()
authorAndre Przywara <andre.przywara@arm.com>
Fri, 17 Jun 2022 09:59:44 +0000 (09:59 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 24 Jun 2022 09:12:29 +0000 (17:12 +0800)
Currently the QAT driver code uses a self-defined wrapper function
called get_current_node() when it wants to learn the current NUMA node.
This implementation references the topology_physical_package_id[] array,
which more or less coincidentally contains the NUMA node id, at least
on x86.

Because this is not universal, and Linux offers a direct function to
learn the NUMA node ID, replace that function with a call to
numa_node_id(), which would work everywhere.

This fixes the QAT driver operation on arm64 machines.

Reported-by: Yoan Picchi <Yoan.Picchi@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Yoan Picchi <yoan.picchi@arm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qat/qat_common/adf_common_drv.h
drivers/crypto/qat/qat_common/qat_algs.c
drivers/crypto/qat/qat_common/qat_asym_algs.c

index 0464fa2..b364bc0 100644 (file)
@@ -49,11 +49,6 @@ struct service_hndl {
        struct list_head list;
 };
 
-static inline int get_current_node(void)
-{
-       return topology_physical_package_id(raw_smp_processor_id());
-}
-
 int adf_service_register(struct service_hndl *service);
 int adf_service_unregister(struct service_hndl *service);
 
index 148edbe..fb45fa8 100644 (file)
@@ -605,7 +605,7 @@ static int qat_alg_aead_newkey(struct crypto_aead *tfm, const u8 *key,
 {
        struct qat_alg_aead_ctx *ctx = crypto_aead_ctx(tfm);
        struct qat_crypto_instance *inst = NULL;
-       int node = get_current_node();
+       int node = numa_node_id();
        struct device *dev;
        int ret;
 
@@ -1065,7 +1065,7 @@ static int qat_alg_skcipher_newkey(struct qat_alg_skcipher_ctx *ctx,
 {
        struct qat_crypto_instance *inst = NULL;
        struct device *dev;
-       int node = get_current_node();
+       int node = numa_node_id();
        int ret;
 
        inst = qat_crypto_get_instance_node(node);
index 16d97db..095ed2a 100644 (file)
@@ -489,7 +489,7 @@ static int qat_dh_init_tfm(struct crypto_kpp *tfm)
 {
        struct qat_dh_ctx *ctx = kpp_tfm_ctx(tfm);
        struct qat_crypto_instance *inst =
-                       qat_crypto_get_instance_node(get_current_node());
+                       qat_crypto_get_instance_node(numa_node_id());
 
        if (!inst)
                return -EINVAL;
@@ -1225,7 +1225,7 @@ static int qat_rsa_init_tfm(struct crypto_akcipher *tfm)
 {
        struct qat_rsa_ctx *ctx = akcipher_tfm_ctx(tfm);
        struct qat_crypto_instance *inst =
-                       qat_crypto_get_instance_node(get_current_node());
+                       qat_crypto_get_instance_node(numa_node_id());
 
        if (!inst)
                return -EINVAL;