diff --git a/1005-qat_dev_process-add-userspace-request-logic.patch b/1005-qat_dev_process-add-userspace-request-logic.patch new file mode 100644 index 0000000000000000000000000000000000000000..c45f32c490e8e93b8f0d78e6953f03bb64498a26 --- /dev/null +++ b/1005-qat_dev_process-add-userspace-request-logic.patch @@ -0,0 +1,157 @@ +From 2187431dbab7d2f8763f7e4a64231fb3830e293a Mon Sep 17 00:00:00 2001 +From: Xingrui Yi +Date: Mon, 21 Aug 2023 17:01:51 +0800 +Subject: [PATCH] qat_dev_process: add userspace request logic + +Signed-off-by: Xingrui Yi +--- + .../crypto/qat/qat_common/adf_cfg_common.h | 7 ++ + .../crypto/qat/qat_common/adf_dev_processes.c | 76 ++++++++++++++----- + 2 files changed, 65 insertions(+), 18 deletions(-) + +diff --git a/quickassist/qat/drivers/crypto/qat/qat_common/adf_cfg_common.h b/quickassist/qat/drivers/crypto/qat/qat_common/adf_cfg_common.h +index 1d50fdf..e8f9c29 100644 +--- a/quickassist/qat/drivers/crypto/qat/qat_common/adf_cfg_common.h ++++ b/quickassist/qat/drivers/crypto/qat/qat_common/adf_cfg_common.h +@@ -143,6 +143,13 @@ struct adf_dev_miscellaneous_stats { + u64 misc_counter; + }; + ++struct adf_dev_tableList { ++ u32 table[ADF_MAX_DEVICES]; ++ u16 num_instance; ++ char name[ADF_CFG_MAX_SECTION_LEN_IN_BYTES]; ++ size_t name_len; ++}; ++ + #ifdef QAT_ERR_INJECTION_SIM + struct adf_pmisc_write_info { + u32 accel_id; +diff --git a/quickassist/qat/drivers/crypto/qat/qat_common/adf_dev_processes.c b/quickassist/qat/drivers/crypto/qat/qat_common/adf_dev_processes.c +index 1e1d38f..a4d0f2a 100644 +--- a/quickassist/qat/drivers/crypto/qat/qat_common/adf_dev_processes.c ++++ b/quickassist/qat/drivers/crypto/qat/qat_common/adf_dev_processes.c +@@ -139,21 +139,33 @@ static int adf_processes_open(struct inode *inp, struct file *fp) + return 0; + } + +-static struct adf_accel_dev *adf_get_first_started_dev(void) ++static struct adf_accel_dev *adf_get_first_started_dev(struct adf_dev_tableList *tbl_list) + { + int i = 0; + struct adf_accel_dev *accel_dev = NULL; + +- for (i = 0; i < ADF_MAX_DEVICES; i++) { +- accel_dev = adf_devmgr_get_dev_by_id(i); +- if (!accel_dev) +- continue; +- if (adf_dev_started(accel_dev) && +- (accel_dev->is_vf || +- (!accel_dev->is_vf && !accel_dev->pf.vf_info))) +- return accel_dev; ++ if (tbl_list->num_instance > ADF_MAX_DEVICES) { ++ for (i = 0; i < ADF_MAX_DEVICES; i++) { ++ accel_dev = adf_devmgr_get_dev_by_id(i); ++ if (!accel_dev) ++ continue; ++ if (adf_dev_started(accel_dev) && ++ (accel_dev->is_vf || ++ (!accel_dev->is_vf && !accel_dev->pf.vf_info))) ++ return accel_dev; ++ } ++ } ++ else { ++ for (i = 0; i < tbl_list->num_instance; i++) { ++ accel_dev = adf_devmgr_get_dev_by_id(tbl_list->table[i]); ++ if (!accel_dev) ++ continue; ++ if (adf_dev_started(accel_dev) && ++ (accel_dev->is_vf || ++ (!accel_dev->is_vf && !accel_dev->pf.vf_info))) ++ return accel_dev; ++ } + } +- + return NULL; + } + +@@ -178,9 +190,10 @@ static ssize_t adf_processes_write(struct file *fp, const char __user *buf, + { + struct adf_processes_priv_data *prv_data = NULL; + struct adf_processes_priv_data *pdata = NULL; +- int dev_num = 0, pr_num = 0; ++ int dev_index = 0, dev_num = 0, pr_num = 0; + struct list_head *lpos = NULL; +- char usr_name[ADF_CFG_MAX_SECTION_LEN_IN_BYTES] = {0}; ++ struct adf_dev_tableList *tbl_list = kmalloc(sizeof(struct adf_dev_tableList), GFP_KERNEL); ++ char *usr_name = NULL; + char val[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = {0}; + struct adf_accel_dev *accel_dev = NULL; + struct adf_cfg_section *section_ptr = NULL; +@@ -198,14 +211,30 @@ static ssize_t adf_processes_write(struct file *fp, const char __user *buf, + pr_err("QAT: can only write once\n"); + return -EBADF; + } +- if (count <= 0 || count > ADF_CFG_MAX_SECTION_LEN_IN_BYTES) { ++ if (count <= 0) { + pr_err("QAT: wrong size %d\n", (int)count); + return -EIO; + } + +- if (copy_from_user(usr_name, buf, count)) { +- pr_err("QAT: can't copy data\n"); +- return -EIO; ++ if (count <= ADF_CFG_MAX_SECTION_LEN_IN_BYTES) { ++ usr_name = kmalloc(sizeof(char) * ADF_CFG_MAX_SECTION_LEN_IN_BYTES, GFP_KERNEL); ++ if (copy_from_user(usr_name, buf, count)) { ++ pr_err("QAT: can't copy data\n"); ++ return -EIO; ++ } ++ usr_name[count] = '\0'; ++ tbl_list->num_instance = ADF_MAX_DEVICES + 1; ++ } ++ else { ++ if (copy_from_user(tbl_list, buf, count)) { ++ pr_err("QAT: can't copy data\n"); ++ return -EIO; ++ } ++ if (tbl_list->num_instance > ADF_MAX_DEVICES) { ++ pr_err("QAT: wrong tbl input num\n"); ++ return -EIO; ++ } ++ usr_name = tbl_list->name; + } + + /* Lock other processes and try to find out the process name */ +@@ -214,7 +243,7 @@ static ssize_t adf_processes_write(struct file *fp, const char __user *buf, + return -EBADF; + } + +- accel_dev = adf_get_first_started_dev(); ++ accel_dev = adf_get_first_started_dev(tbl_list); + if (!accel_dev) { + pr_err("QAT: could not find started device\n"); + up(&processes_list_sema); +@@ -255,7 +284,18 @@ static ssize_t adf_processes_write(struct file *fp, const char __user *buf, + + /* If there are processes running then search for a first free name */ + adf_devmgr_get_num_dev(&num_accel_devs); +- for (dev_num = 0; dev_num < num_accel_devs; dev_num++) { ++ ++ if (tbl_list->num_instance <= ADF_MAX_DEVICES) { ++ num_accel_devs = num_accel_devs < tbl_list->num_instance ? ++ num_accel_devs : tbl_list->num_instance; ++ } ++ ++ for (dev_index = 0; dev_index < num_accel_devs; dev_index++) { ++ if (tbl_list->num_instance > ADF_MAX_DEVICES) ++ dev_num = dev_index; ++ else ++ dev_num = tbl_list->table[dev_index]; ++ + accel_dev = adf_devmgr_get_dev_by_id(dev_num); + if (!accel_dev) + continue; +-- +2.31.1 + diff --git a/kmod-intel-QAT20.spec b/kmod-intel-QAT20.spec index e3cfba7e6a0b51fc02e8b6bd445ff31da7eb26cc..4b43d608dce12df181475090266262ac56bfc111 100644 --- a/kmod-intel-QAT20.spec +++ b/kmod-intel-QAT20.spec @@ -1,4 +1,4 @@ -%define anolis_release 10 +%define anolis_release 11 %define debug_package %{nil} %global kernel_version %(rpm -qa kernel-devel | sed -e 's/kernel-devel-//g') %define QAT_release 00004 @@ -9,12 +9,14 @@ Version: L.0.9.4 Release: %{QAT_release}.%{anolis_release}%{dist} Group: QAT/Base License: BSD and (BSD or GPLv2) +URL: https://www.intel.com/content/www/us/en/download/19081/intel-quickassist-technology-intel-qat-driver-for-linux-for-intel-server-boards-and-systems-based-on-intel-62x-chipset.html Source: %{name}-%{version}-%{QAT_release}.tar.gz Patch1000: 1000-bugfix-support-5.10.patch Patch1001: 1001-bugfix-split-qat-vdcm-module.patch Patch1002: 1002-bugfix-crash-of-rmmod-vdcm.patch Patch1003: 1003-src-fix-warning-when-compiling.patch Patch1004: 1004-bugfix-ring-pair-reset-failure.patch +Patch1005: 1005-qat_dev_process-add-userspace-request-logic.patch BuildRequires: gcc gcc-c++ make systemd-devel openssl-devel zlib-devel yasm BuildRequires: libudev-devel >= 1.47 @@ -87,6 +89,9 @@ ${ECHO} "%{name}-driver-%{version}-%{release} is installed!"; depmod -a %changelog +* Mon Aug 28 2023 Guanjun -0.9.4-00004.11 +- Add userspace request logic + * Wed Aug 16 2023 Guanjun -0.9.4-00004.10 - Rebuild for kernel