upgrade qat from 4.12.0-00011 to 4.14.0-00031 adjust patch index and add a patch to fix deadlock issue.
Signed-off-by: Liwei Song <[email protected]> --- ...-mutex_lock-to-mutex_trylock-to-avio.patch | 104 ++++++++++++++++++ ...at-add-install-target-and-add-folder.patch | 16 +-- ...-qat17-use-namespace-CRYPTO_INTERNAL.patch | 40 +++++-- ..._4.12.0-00011.bb => qat17_4.14.0-00031.bb} | 13 +-- 4 files changed, 147 insertions(+), 26 deletions(-) create mode 100644 recipes-extended/qat/files/0001-usdm_drv-convert-mutex_lock-to-mutex_trylock-to-avio.patch rename recipes-extended/qat/{qat17_4.12.0-00011.bb => qat17_4.14.0-00031.bb} (92%) diff --git a/recipes-extended/qat/files/0001-usdm_drv-convert-mutex_lock-to-mutex_trylock-to-avio.patch b/recipes-extended/qat/files/0001-usdm_drv-convert-mutex_lock-to-mutex_trylock-to-avio.patch new file mode 100644 index 000000000000..04ff59e75319 --- /dev/null +++ b/recipes-extended/qat/files/0001-usdm_drv-convert-mutex_lock-to-mutex_trylock-to-avio.patch @@ -0,0 +1,104 @@ +From acf49dcacc450830bf9ccad5dcd895ce1b8ba786 Mon Sep 17 00:00:00 2001 +From: Liwei Song <[email protected]> +Date: Thu, 22 Jul 2021 08:09:05 +0000 +Subject: [PATCH] usdm_drv: convert mutex_lock to mutex_trylock to aviod + deadlock + +exist the following deadlock when run cpa_sample_code: + +====================================================== +WARNING: possible circular locking dependency detected +5.10.47-yocto-standard #1 Tainted: G O +------------------------------------------------------ + +cpa_sample_code/2144 is trying to acquire lock: +ffffffffc04883d0 (&dev_mem_lock +============================= +){+.+.}-{3:3}, at: mem_mmap+0x32/0x160 [usdm_drv] + +but task is already holding lock: +ff1ab034bf111278 (&mm->mmap_lock#2){++++}-{3:3}, at: vm_mmap_pgoff+0x99/0x100 + +which lock already depends on the new lock. + +the existing dependency chain (in reverse order) is: + +-> #1 (&mm->mmap_lock#2){++++}-{3:3}: + __lock_acquire+0x4be/0x980 + lock_acquire+0xe1/0x2f0 +WARNING: suspicious RCU usage + __might_fault+0x5e/0x80 + _copy_to_user+0x23/0xa0 + mem_ioctl+0x2ed/0x3b5 [usdm_drv] + __x64_sys_ioctl+0x91/0xc0 + do_syscall_64+0x38/0x50 + entry_SYSCALL_64_after_hwframe+0x44/0xa9 +5.10.47-yocto-standard #1 Tainted: G O + +-> #0 (&dev_mem_lock){+.+.}-{3:3}: + check_prev_add+0x95/0xc00 + validate_chain+0x723/0xaa0 + __lock_acquire+0x4be/0x980 + lock_acquire+0xe1/0x2f0 + __mutex_lock+0x97/0x960 + mutex_lock_nested+0x1b/0x20 + mem_mmap+0x32/0x160 [usdm_drv] +----------------------------- + mmap_region+0x423/0x6b0 + do_mmap+0x46a/0x5e0 + vm_mmap_pgoff+0xc5/0x100 + ksys_mmap_pgoff+0x1d0/0x230 + __x64_sys_mmap+0x33/0x40 + do_syscall_64+0x38/0x50 + entry_SYSCALL_64_after_hwframe+0x44/0xa9 +kernel/sched/core.c:7263 Illegal context switch in RCU-bh read-side critical section! + +other info that might help us debug this: + + Possible unsafe locking scenario: + + CPU0 CPU1 + ---- ---- + lock(&mm->mmap_lock#2); + lock(&dev_mem_lock); + lock(&mm->mmap_lock#2); + lock(&dev_mem_lock); + + *** DEADLOCK *** + +convert mutex_lock to mutex_trylock which will return without wait. + +Upstream-Status: Inappropriate + +Signed-off-by: Liwei Song <[email protected]> +--- + .../utilities/libusdm_drv/linux/kernel_space/qae_mem_drv.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/quickassist/utilities/libusdm_drv/linux/kernel_space/qae_mem_drv.c b/quickassist/utilities/libusdm_drv/linux/kernel_space/qae_mem_drv.c +index e404647aafb2..2a4de14a0300 100644 +--- a/quickassist/utilities/libusdm_drv/linux/kernel_space/qae_mem_drv.c ++++ b/quickassist/utilities/libusdm_drv/linux/kernel_space/qae_mem_drv.c +@@ -87,6 +87,7 @@ + #include <linux/uaccess.h> + #include <linux/version.h> + #include <linux/hugetlb.h> ++#include <linux/delay.h> + + #include "qae_mem_utils.h" + +@@ -975,7 +976,10 @@ mem_mmap(struct file *fp, struct vm_area_struct *vma) + unsigned long size = vma->vm_end - vma->vm_start; + id = vma->vm_pgoff << PAGE_SHIFT; + +- mutex_lock(&dev_mem_lock); ++ while(!mutex_trylock(&dev_mem_lock)){ ++ udelay(5); ++ } ++ + kmem = userMemGetInfo(fp, id); + if (!kmem) + { +-- +2.29.2 + diff --git a/recipes-extended/qat/files/0006-qat-add-install-target-and-add-folder.patch b/recipes-extended/qat/files/0006-qat-add-install-target-and-add-folder.patch index 62d25e0ba978..9d92f834e7c0 100644 --- a/recipes-extended/qat/files/0006-qat-add-install-target-and-add-folder.patch +++ b/recipes-extended/qat/files/0006-qat-add-install-target-and-add-folder.patch @@ -1,4 +1,4 @@ -From fc2ae28063d10721282a4e6009cec9143ce37c80 Mon Sep 17 00:00:00 2001 +From b6f1c6465ce5d9d3792b8e00fe0a94ddd2724b91 Mon Sep 17 00:00:00 2001 From: "Tan, Raymond" <[email protected]> Date: Mon, 4 Jun 2018 09:26:33 +0800 Subject: [PATCH 06/11] qat-add-install-target-and-add-folder @@ -13,18 +13,18 @@ Signed-off-by: Tan, Raymond <[email protected]> 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/quickassist/Makefile b/quickassist/Makefile -index 558f85d..4cc0f2b 100644 +index 34aaae021a40..292a19921832 100644 --- a/quickassist/Makefile +++ b/quickassist/Makefile -@@ -96,6 +96,7 @@ ICP_BUILD_OUTPUT?=build_$(DATE) - ICP_TOP_ENV=$(ICP_BUILDSYSTEM_PATH)/build_files/env_files/ - export ICP_ACCEL_INC=YES +@@ -98,6 +98,7 @@ export ICP_ACCEL_INC=YES + export ICP_PARAM_CHECK ?= y + export CNV_STRICT_MODE ?= 1 LAC_LIB_DIR=$(LAC_PATH)/build/libs +MODULE_INSTALLPATH=$(SAMPLE_BUILD_OUTPUT)/lib/modules/$(QAT_KERNEL_VER)/updates/drivers/crypto/qat #Release Package build steps ALL_TARGETS = lac_user lac_kernel -@@ -113,10 +114,14 @@ all: $(ALL_TARGETS) +@@ -115,10 +116,14 @@ all: $(ALL_TARGETS) user: lac_lib_dir libosal_user lac_user @@ -41,7 +41,7 @@ index 558f85d..4cc0f2b 100644 # # Common memory driver -@@ -199,8 +204,22 @@ ifeq ($(ICP_NO_CLEAN),) +@@ -201,8 +206,22 @@ ifeq ($(ICP_NO_CLEAN),) endif @@ -66,5 +66,5 @@ index 558f85d..4cc0f2b 100644 lac_lib_dir: clean test -d $(LAC_LIB_DIR) || mkdir -p $(LAC_LIB_DIR); -- -2.14.5 +2.29.2 diff --git a/recipes-extended/qat/files/0011-qat17-use-namespace-CRYPTO_INTERNAL.patch b/recipes-extended/qat/files/0011-qat17-use-namespace-CRYPTO_INTERNAL.patch index 1a7a647d6961..c9eb5c3ab4da 100644 --- a/recipes-extended/qat/files/0011-qat17-use-namespace-CRYPTO_INTERNAL.patch +++ b/recipes-extended/qat/files/0011-qat17-use-namespace-CRYPTO_INTERNAL.patch @@ -1,4 +1,4 @@ -From 9b2b7a79fc9d9323fe9ec44de7619ea175c45bc1 Mon Sep 17 00:00:00 2001 +From 6a1fa62ffa4acd6e8e4d4f648e19363a2ed5ef74 Mon Sep 17 00:00:00 2001 From: Yongxin Liu <[email protected]> Date: Tue, 23 Mar 2021 09:31:25 +0000 Subject: [PATCH 11/11] qat17: use namespace CRYPTO_INTERNAL @@ -11,12 +11,13 @@ Upstream-Status: Inappropriate [Code released in tarball form only] Signed-off-by: Yongxin Liu <[email protected]> --- - quickassist/lookaside/access_layer/src/linux/icp_qa_module.c | 3 +++ - .../utilities/osal/src/linux/kernel_space/OsalCryptoInterface.c | 5 +++++ - 2 files changed, 8 insertions(+) + quickassist/lookaside/access_layer/src/linux/icp_qa_module.c | 3 +++ + quickassist/qat/drivers/crypto/qat/qat_common/qat_algs.c | 5 +++++ + .../osal/src/linux/kernel_space/OsalCryptoInterface.c | 5 +++++ + 3 files changed, 13 insertions(+) diff --git a/quickassist/lookaside/access_layer/src/linux/icp_qa_module.c b/quickassist/lookaside/access_layer/src/linux/icp_qa_module.c -index 413eb07..f3a371e 100644 +index db51add84592..209b3054aa8c 100644 --- a/quickassist/lookaside/access_layer/src/linux/icp_qa_module.c +++ b/quickassist/lookaside/access_layer/src/linux/icp_qa_module.c @@ -120,3 +120,6 @@ module_exit(kapi_mod_exit); @@ -26,14 +27,31 @@ index 413eb07..f3a371e 100644 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0)) +MODULE_IMPORT_NS(CRYPTO_INTERNAL); +#endif +diff --git a/quickassist/qat/drivers/crypto/qat/qat_common/qat_algs.c b/quickassist/qat/drivers/crypto/qat/qat_common/qat_algs.c +index 23249de3db39..0e61954c0150 100644 +--- a/quickassist/qat/drivers/crypto/qat/qat_common/qat_algs.c ++++ b/quickassist/qat/drivers/crypto/qat/qat_common/qat_algs.c +@@ -8,7 +8,12 @@ + #include <crypto/internal/aead.h> + #include <crypto/internal/skcipher.h> + #include <crypto/aes.h> ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0)) ++#include <crypto/sha1.h> ++#include <crypto/sha2.h> ++#else + #include <crypto/sha.h> ++#endif + #include <crypto/hash.h> + #include <crypto/algapi.h> + #include <crypto/authenc.h> diff --git a/quickassist/utilities/osal/src/linux/kernel_space/OsalCryptoInterface.c b/quickassist/utilities/osal/src/linux/kernel_space/OsalCryptoInterface.c -index de24fa0..96c29c0 100644 +index ec536607989a..9d62bb8749d5 100644 --- a/quickassist/utilities/osal/src/linux/kernel_space/OsalCryptoInterface.c +++ b/quickassist/utilities/osal/src/linux/kernel_space/OsalCryptoInterface.c -@@ -75,6 +75,11 @@ - #else - #include <crypto/sha.h> - #endif +@@ -76,6 +76,11 @@ + #endif /* end of 5.11.0, 2.6.29 checks */ + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) + #include <crypto/internal/hash.h> +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0)) +#include <crypto/internal/cipher.h> +#include <linux/module.h> @@ -43,5 +61,5 @@ index de24fa0..96c29c0 100644 #define OSAL_MAX_SHASH_DECSIZE 512 -- -2.14.5 +2.29.2 diff --git a/recipes-extended/qat/qat17_4.12.0-00011.bb b/recipes-extended/qat/qat17_4.14.0-00031.bb similarity index 92% rename from recipes-extended/qat/qat17_4.12.0-00011.bb rename to recipes-extended/qat/qat17_4.14.0-00031.bb index 28bcad794a52..d27d9333f41c 100644 --- a/recipes-extended/qat/qat17_4.12.0-00011.bb +++ b/recipes-extended/qat/qat17_4.14.0-00031.bb @@ -7,12 +7,12 @@ LIC_FILES_CHKSUM = "\ file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 \ file://${COMMON_LICENSE_DIR}/BSD;md5=3775480a712fc46a69647678acb234cb \ " -DEPENDS += "boost udev zlib openssl" +DEPENDS += "boost udev zlib openssl yasm-native" PROVIDES += "virtual/qat" TARGET_CC_ARCH += "${LDFLAGS}" -SRC_URI = "https://01.org/sites/default/files/downloads//qat1.7.l.4.12.0-00011.tar.gz;subdir=qat17 \ +SRC_URI = "https://downloadmirror.intel.com/30178/eng/QAT1.7.L.4.14.0-00031.tar.gz;subdir=qat17 \ file://0001-qat-fix-for-cross-compilation-issue.patch \ file://0002-qat-remove-local-path-from-makefile.patch \ file://0003-qat-override-CC-LD-AR-only-when-it-is-not-define.patch \ @@ -20,16 +20,15 @@ SRC_URI = "https://01.org/sites/default/files/downloads//qat1.7.l.4.12.0-00011.t file://0005-Added-include-dir-path.patch \ file://0006-qat-add-install-target-and-add-folder.patch \ file://0007-qat-use-static-lib-for-linking-under-cpa-sample-code.patch \ - file://0008-qat-overwrite-KBUILD_BUILTIN-in-kernel-s-Makefile.patch \ file://0009-crypto-qat-Silence-smp_processor_id-warning.patch \ - file://0010-qat-include-sha1.h-and-sha2.h-instead-of-sha.h-in-ke.patch \ file://0011-qat17-use-namespace-CRYPTO_INTERNAL.patch \ + file://0001-usdm_drv-convert-mutex_lock-to-mutex_trylock-to-avio.patch \ " do_configure[depends] += "virtual/kernel:do_shared_workdir" -SRC_URI[md5sum] = "23d962944ae22ef14ff880fdbff4223b" -SRC_URI[sha256sum] = "6b8d643780b2640d084f5bd50546c8dae4ae9ec50cf167660a0ebdc55619eb2e" +SRC_URI[md5sum] = "a6ff665184159583542dac89b9226f09" +SRC_URI[sha256sum] = "a68dfaea4308e0bb5f350b7528f1a076a0c6ba3ec577d60d99dc42c49307b76e" COMPATIBLE_MACHINE = "null" COMPATIBLE_HOST_x86-x32 = 'null' @@ -145,7 +144,7 @@ do_install() { install -m 0755 ${S}/quickassist/lookaside/access_layer/src/sample_code/performance/compression/canterbury ${D}${nonarch_base_libdir}/firmware #install qat source - cp ${DL_DIR}/qat1.7.l.${PV}.tar.gz ${D}${prefix}/src/qat/ + cp ${DL_DIR}/QAT1.7.L.${PV}.tar.gz ${D}${prefix}/src/qat/ } PACKAGES += "${PN}-app" -- 2.17.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#7165): https://lists.yoctoproject.org/g/meta-intel/message/7165 Mute This Topic: https://lists.yoctoproject.org/mt/84474231/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/meta-intel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
