Commit c2a1b91e authored by Andre Przywara's avatar Andre Przywara Committed by Herbert Xu
Browse files

crypto: qat - replace get_current_node() with numa_node_id()



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: default avatarYoan Picchi <Yoan.Picchi@arm.com>
Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarYoan Picchi <yoan.picchi@arm.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent f145d411
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -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);

+2 −2
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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;