libwd/0029-uadk-wd_alg-check-whether-the-platform-supports-SVE.patch
JangShui Yang e072f742a4 libwd: update the source code
(cherry picked from commit dc42b3a676205c1a1c922628a993887e1ad2988f)
2024-04-07 18:59:45 +08:00

50 lines
1.3 KiB
Diff

From 4163f4f6ff8534b171c8b1b044452b930629576d Mon Sep 17 00:00:00 2001
From: Weili Qian <qianweili@huawei.com>
Date: Sat, 23 Mar 2024 17:54:16 +0800
Subject: [PATCH 29/44] uadk/wd_alg: check whether the platform supports SVE
If the algorithm uses the SVE instruction, check whether
the platform supports SVE before algorithm driver registration.
If the platform does not support SVE, do not register the algorithm.
Signed-off-by: Weili Qian <qianweili@huawei.com>
---
wd_alg.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/wd_alg.c b/wd_alg.c
index f34a407..de352d7 100644
--- a/wd_alg.c
+++ b/wd_alg.c
@@ -109,6 +109,19 @@ static bool wd_check_ce_support(const char *dev_name)
return false;
}
+static bool wd_check_sve_support(void)
+{
+ unsigned long hwcaps = 0;
+
+ #if defined(__aarch64__)
+ hwcaps = getauxval(AT_HWCAP);
+ #endif
+ if (hwcaps & HWCAP_SVE)
+ return true;
+
+ return false;
+}
+
static bool wd_alg_check_available(int calc_type, const char *dev_name)
{
bool ret = false;
@@ -122,6 +135,7 @@ static bool wd_alg_check_available(int calc_type, const char *dev_name)
break;
/* Should find the CPU if not support SVE */
case UADK_ALG_SVE_INSTR:
+ ret = wd_check_sve_support();
break;
/* Check if the current driver has device support */
case UADK_ALG_HW:
--
2.25.1