From fe4ec71117c34f6e4b3b31b55dfbd528ca518955 Mon Sep 17 00:00:00 2001 From: Yongxin Liu Date: Tue, 31 Mar 2020 22:11:02 +0800 Subject: qat: Make it compatible with kernel 5.6 Add qat17_4.7.0-00006-make-it-compitable-with-kernel-5.6.patch when compiling qat with kernel 5.6. In the patch, replace struct timespec with y2038 safe struct timespec64. And add definition of CRYPTO_TFM_RES_BAD_KEY_LEN back for qat driver. Signed-off-by: Yongxin Liu Signed-off-by: Anuj Mittal --- ...-00006-make-it-compatible-with-kernel-5.6.patch | 96 ++++++++++++++++++++++ recipes-extended/qat/qat17_4.7.0-00006.bb | 9 ++ 2 files changed, 105 insertions(+) create mode 100644 recipes-extended/qat/files/qat17_4.7.0-00006-make-it-compatible-with-kernel-5.6.patch diff --git a/recipes-extended/qat/files/qat17_4.7.0-00006-make-it-compatible-with-kernel-5.6.patch b/recipes-extended/qat/files/qat17_4.7.0-00006-make-it-compatible-with-kernel-5.6.patch new file mode 100644 index 0000000..0851724 --- /dev/null +++ b/recipes-extended/qat/files/qat17_4.7.0-00006-make-it-compatible-with-kernel-5.6.patch @@ -0,0 +1,96 @@ +From 75fe2382f42ac42333a28445bb54132afd9a27a1 Mon Sep 17 00:00:00 2001 +From: Yongxin Liu +Date: Tue, 31 Mar 2020 19:44:25 +0000 +Subject: [PATCH] qat17: make it compatible with kernel 5.6 + +1) In kernel commit c766d1472c70 ("y2038: hide timeval/timespec/itimerval +/itimerspec types"), timespec was hiden, so change timespec to timespec64. + +2) CRYPTO_TFM_RES_BAD_KEY_LEN was removed in kernel commit 674f368a952c +("crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN"). Add it back, since qat driver +needs it. + +Upstream-Status: Inappropriate [Code released in tarball form only] + +Signed-off-by: Yongxin Liu +--- + .../drivers/crypto/qat/qat_common/adf_clock.c | 18 +++++++++--------- + .../drivers/crypto/qat/qat_common/qat_algs.c | 2 ++ + 2 files changed, 11 insertions(+), 9 deletions(-) + +diff --git a/quickassist/qat/drivers/crypto/qat/qat_common/adf_clock.c b/quickassist/qat/drivers/crypto/qat/qat_common/adf_clock.c +index 8785f67..be3d9b8 100644 +--- a/quickassist/qat/drivers/crypto/qat/qat_common/adf_clock.c ++++ b/quickassist/qat/drivers/crypto/qat/qat_common/adf_clock.c +@@ -113,7 +113,7 @@ int adf_clock_debugfs_add(struct adf_accel_dev *accel_dev) + #endif + EXPORT_SYMBOL_GPL(adf_clock_debugfs_add); + +-static inline s64 timespec_to_us(const struct timespec *ts) ++static inline s64 timespec_to_us(const struct timespec64 *ts) + { + return ((s64)ts->tv_sec * USEC_PER_SEC + + (ts->tv_nsec + NSEC_PER_USEC / 2) / NSEC_PER_USEC); +@@ -129,10 +129,10 @@ static inline s64 timespec_to_us(const struct timespec *ts) + static int measure_clock(struct adf_accel_dev *accel_dev, + u32 *frequency) + { +- struct timespec ts1; +- struct timespec ts2; +- struct timespec ts3; +- struct timespec ts4; ++ struct timespec64 ts1; ++ struct timespec64 ts2; ++ struct timespec64 ts3; ++ struct timespec64 ts4; + u64 delta_us = 0; + u64 timestamp1 = 0; + u64 timestamp2 = 0; +@@ -143,13 +143,13 @@ static int measure_clock(struct adf_accel_dev *accel_dev, + return -EIO; + + do { +- getnstimeofday(&ts1); ++ ktime_get_real_ts64(&ts1); + if (adf_get_fw_timestamp(accel_dev, ×tamp1)) { + dev_err(&GET_DEV(accel_dev), + "Failed to get fw timestamp\n"); + return -EIO; + } +- getnstimeofday(&ts2); ++ ktime_get_real_ts64(&ts2); + delta_us = timespec_to_us(&ts2) - timespec_to_us(&ts1); + } while (delta_us > MEASURE_CLOCK_DELTA_THRESHOLD && + ++tries < MEASURE_CLOCK_RETRIES); +@@ -162,13 +162,13 @@ static int measure_clock(struct adf_accel_dev *accel_dev, + + tries = 0; + do { +- getnstimeofday(&ts3); ++ ktime_get_real_ts64(&ts3); + if (adf_get_fw_timestamp(accel_dev, ×tamp2)) { + dev_err(&GET_DEV(accel_dev), + "Failed to get fw timestamp\n"); + return -EIO; + } +- getnstimeofday(&ts4); ++ ktime_get_real_ts64(&ts4); + delta_us = timespec_to_us(&ts4) - timespec_to_us(&ts3); + } while (delta_us > MEASURE_CLOCK_DELTA_THRESHOLD && + ++tries < MEASURE_CLOCK_RETRIES); +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 c4edb3c..b509dca 100644 +--- a/quickassist/qat/drivers/crypto/qat/qat_common/qat_algs.c ++++ b/quickassist/qat/drivers/crypto/qat/qat_common/qat_algs.c +@@ -73,6 +73,8 @@ + ICP_QAT_HW_CIPHER_KEY_CONVERT, \ + ICP_QAT_HW_CIPHER_DECRYPT) + ++#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000 ++ + static DEFINE_MUTEX(algs_lock); + static unsigned int active_devs; + +-- +2.24.1 + diff --git a/recipes-extended/qat/qat17_4.7.0-00006.bb b/recipes-extended/qat/qat17_4.7.0-00006.bb index a77f4c0..2f783f5 100644 --- a/recipes-extended/qat/qat17_4.7.0-00006.bb +++ b/recipes-extended/qat/qat17_4.7.0-00006.bb @@ -22,6 +22,7 @@ SRC_URI = "https://01.org/sites/default/files/downloads/qat1.7.l.4.7.0-00006.tar file://qat17_4.7.0-00006-Link-driver-with-object-files.patch \ file://qat17_4.7.0-00006-Drop-pr_warning-definition.patch \ file://qat17_4.7.0-00006-Switch-to-skcipher-API.patch;apply=0 \ + file://qat17_4.7.0-00006-make-it-compatible-with-kernel-5.6.patch;apply=0 \ " do_patch[depends] += "virtual/kernel:do_shared_workdir" @@ -29,6 +30,8 @@ do_patch[depends] += "virtual/kernel:do_shared_workdir" do_patch_append () { if d.getVar("KERNEL_VERSION") >= "5.5%": bb.build.exec_func('do_switch_to_skcipher_api', d) + if d.getVar("KERNEL_VERSION") >= "5.6%": + bb.build.exec_func('do_patch_for_kernel_5_6', d) } do_switch_to_skcipher_api () { @@ -36,6 +39,12 @@ do_switch_to_skcipher_api () { patch -p1 < "${WORKDIR}/qat17_4.7.0-00006-Switch-to-skcipher-API.patch" } +do_patch_for_kernel_5_6 () { + cd "${S}" + patch -p1 < "${WORKDIR}/qat17_4.7.0-00006-make-it-compatible-with-kernel-5.6.patch" +} + + SRC_URI[md5sum] = "ac939b51cc8836c182e31e309c065002" SRC_URI[sha256sum] = "5c8bdc35fd7a42f212f1f87eb9e3d8584df7af56dae366debc487981e531fa5c" -- cgit v1.2.3-54-g00ecf