Commit 5831fc1f authored by Longfang Liu's avatar Longfang Liu Committed by Herbert Xu

crypto: hisilicon/qm - fix PF queue parameter issue

If the queue isolation feature is enabled, the number of queues
supported by the device changes. When PF is enabled using the
current default number of queues, the default number of queues may
be greater than the number supported by the device. As a result,
the PF fails to be bound to the driver.

After modification, if queue isolation feature is enabled, when
the default queue parameter is greater than the number supported
by the device, the number of enabled queues will be changed to
the number supported by the device, so that the PF and driver
can be properly bound.

Fixes: 8bbecfb4 ("crypto: hisilicon/qm - add queue isolation support for Kunpeng930")
Signed-off-by: default avatarLongfang Liu <liulongfang@huawei.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent e12a68b3
...@@ -433,8 +433,11 @@ static u32 uacce_mode = UACCE_MODE_NOUACCE; ...@@ -433,8 +433,11 @@ static u32 uacce_mode = UACCE_MODE_NOUACCE;
module_param_cb(uacce_mode, &hpre_uacce_mode_ops, &uacce_mode, 0444); module_param_cb(uacce_mode, &hpre_uacce_mode_ops, &uacce_mode, 0444);
MODULE_PARM_DESC(uacce_mode, UACCE_MODE_DESC); MODULE_PARM_DESC(uacce_mode, UACCE_MODE_DESC);
static bool pf_q_num_flag;
static int pf_q_num_set(const char *val, const struct kernel_param *kp) static int pf_q_num_set(const char *val, const struct kernel_param *kp)
{ {
pf_q_num_flag = true;
return q_num_set(val, kp, PCI_DEVICE_ID_HUAWEI_HPRE_PF); return q_num_set(val, kp, PCI_DEVICE_ID_HUAWEI_HPRE_PF);
} }
...@@ -1157,6 +1160,8 @@ static int hpre_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) ...@@ -1157,6 +1160,8 @@ static int hpre_qm_init(struct hisi_qm *qm, struct pci_dev *pdev)
qm->qp_num = pf_q_num; qm->qp_num = pf_q_num;
qm->debug.curr_qm_qp_num = pf_q_num; qm->debug.curr_qm_qp_num = pf_q_num;
qm->qm_list = &hpre_devices; qm->qm_list = &hpre_devices;
if (pf_q_num_flag)
set_bit(QM_MODULE_PARAM, &qm->misc_ctl);
} }
ret = hisi_qm_init(qm); ret = hisi_qm_init(qm);
......
...@@ -206,8 +206,6 @@ ...@@ -206,8 +206,6 @@
#define WAIT_PERIOD 20 #define WAIT_PERIOD 20
#define REMOVE_WAIT_DELAY 10 #define REMOVE_WAIT_DELAY 10
#define QM_DRIVER_REMOVING 0
#define QM_RST_SCHED 1
#define QM_QOS_PARAM_NUM 2 #define QM_QOS_PARAM_NUM 2
#define QM_QOS_MAX_VAL 1000 #define QM_QOS_MAX_VAL 1000
#define QM_QOS_RATE 100 #define QM_QOS_RATE 100
...@@ -2824,7 +2822,6 @@ static void hisi_qm_pre_init(struct hisi_qm *qm) ...@@ -2824,7 +2822,6 @@ static void hisi_qm_pre_init(struct hisi_qm *qm)
mutex_init(&qm->mailbox_lock); mutex_init(&qm->mailbox_lock);
init_rwsem(&qm->qps_lock); init_rwsem(&qm->qps_lock);
qm->qp_in_used = 0; qm->qp_in_used = 0;
qm->misc_ctl = false;
if (test_bit(QM_SUPPORT_RPM, &qm->caps)) { if (test_bit(QM_SUPPORT_RPM, &qm->caps)) {
if (!acpi_device_power_manageable(ACPI_COMPANION(&pdev->dev))) if (!acpi_device_power_manageable(ACPI_COMPANION(&pdev->dev)))
dev_info(&pdev->dev, "_PS0 and _PR0 are not defined"); dev_info(&pdev->dev, "_PS0 and _PR0 are not defined");
...@@ -5093,6 +5090,7 @@ static int qm_irqs_register(struct hisi_qm *qm) ...@@ -5093,6 +5090,7 @@ static int qm_irqs_register(struct hisi_qm *qm)
static int qm_get_qp_num(struct hisi_qm *qm) static int qm_get_qp_num(struct hisi_qm *qm)
{ {
struct device *dev = &qm->pdev->dev;
bool is_db_isolation; bool is_db_isolation;
/* VF's qp_num assigned by PF in v2, and VF can get qp_num by vft. */ /* VF's qp_num assigned by PF in v2, and VF can get qp_num by vft. */
...@@ -5109,13 +5107,21 @@ static int qm_get_qp_num(struct hisi_qm *qm) ...@@ -5109,13 +5107,21 @@ static int qm_get_qp_num(struct hisi_qm *qm)
qm->max_qp_num = hisi_qm_get_hw_info(qm, qm_basic_info, qm->max_qp_num = hisi_qm_get_hw_info(qm, qm_basic_info,
QM_FUNC_MAX_QP_CAP, is_db_isolation); QM_FUNC_MAX_QP_CAP, is_db_isolation);
/* check if qp number is valid */ if (qm->qp_num <= qm->max_qp_num)
if (qm->qp_num > qm->max_qp_num) { return 0;
dev_err(&qm->pdev->dev, "qp num(%u) is more than max qp num(%u)!\n",
if (test_bit(QM_MODULE_PARAM, &qm->misc_ctl)) {
/* Check whether the set qp number is valid */
dev_err(dev, "qp num(%u) is more than max qp num(%u)!\n",
qm->qp_num, qm->max_qp_num); qm->qp_num, qm->max_qp_num);
return -EINVAL; return -EINVAL;
} }
dev_info(dev, "Default qp num(%u) is too big, reset it to Function's max qp num(%u)!\n",
qm->qp_num, qm->max_qp_num);
qm->qp_num = qm->max_qp_num;
qm->debug.curr_qm_qp_num = qm->qp_num;
return 0; return 0;
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#define QM_COMMON_H #define QM_COMMON_H
#define QM_DBG_READ_LEN 256 #define QM_DBG_READ_LEN 256
#define QM_RESETTING 2
struct qm_cqe { struct qm_cqe {
__le32 rsvd0; __le32 rsvd0;
......
...@@ -311,8 +311,11 @@ static int sec_diff_regs_show(struct seq_file *s, void *unused) ...@@ -311,8 +311,11 @@ static int sec_diff_regs_show(struct seq_file *s, void *unused)
} }
DEFINE_SHOW_ATTRIBUTE(sec_diff_regs); DEFINE_SHOW_ATTRIBUTE(sec_diff_regs);
static bool pf_q_num_flag;
static int sec_pf_q_num_set(const char *val, const struct kernel_param *kp) static int sec_pf_q_num_set(const char *val, const struct kernel_param *kp)
{ {
pf_q_num_flag = true;
return q_num_set(val, kp, PCI_DEVICE_ID_HUAWEI_SEC_PF); return q_num_set(val, kp, PCI_DEVICE_ID_HUAWEI_SEC_PF);
} }
...@@ -1120,6 +1123,8 @@ static int sec_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) ...@@ -1120,6 +1123,8 @@ static int sec_qm_init(struct hisi_qm *qm, struct pci_dev *pdev)
qm->qp_num = pf_q_num; qm->qp_num = pf_q_num;
qm->debug.curr_qm_qp_num = pf_q_num; qm->debug.curr_qm_qp_num = pf_q_num;
qm->qm_list = &sec_devices; qm->qm_list = &sec_devices;
if (pf_q_num_flag)
set_bit(QM_MODULE_PARAM, &qm->misc_ctl);
} else if (qm->fun_type == QM_HW_VF && qm->ver == QM_HW_V1) { } else if (qm->fun_type == QM_HW_VF && qm->ver == QM_HW_V1) {
/* /*
* have no way to get qm configure in VM in v1 hardware, * have no way to get qm configure in VM in v1 hardware,
......
...@@ -364,8 +364,11 @@ static u32 uacce_mode = UACCE_MODE_NOUACCE; ...@@ -364,8 +364,11 @@ static u32 uacce_mode = UACCE_MODE_NOUACCE;
module_param_cb(uacce_mode, &zip_uacce_mode_ops, &uacce_mode, 0444); module_param_cb(uacce_mode, &zip_uacce_mode_ops, &uacce_mode, 0444);
MODULE_PARM_DESC(uacce_mode, UACCE_MODE_DESC); MODULE_PARM_DESC(uacce_mode, UACCE_MODE_DESC);
static bool pf_q_num_flag;
static int pf_q_num_set(const char *val, const struct kernel_param *kp) static int pf_q_num_set(const char *val, const struct kernel_param *kp)
{ {
pf_q_num_flag = true;
return q_num_set(val, kp, PCI_DEVICE_ID_HUAWEI_ZIP_PF); return q_num_set(val, kp, PCI_DEVICE_ID_HUAWEI_ZIP_PF);
} }
...@@ -1139,6 +1142,8 @@ static int hisi_zip_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) ...@@ -1139,6 +1142,8 @@ static int hisi_zip_qm_init(struct hisi_qm *qm, struct pci_dev *pdev)
qm->qp_num = pf_q_num; qm->qp_num = pf_q_num;
qm->debug.curr_qm_qp_num = pf_q_num; qm->debug.curr_qm_qp_num = pf_q_num;
qm->qm_list = &zip_devices; qm->qm_list = &zip_devices;
if (pf_q_num_flag)
set_bit(QM_MODULE_PARAM, &qm->misc_ctl);
} else if (qm->fun_type == QM_HW_VF && qm->ver == QM_HW_V1) { } else if (qm->fun_type == QM_HW_VF && qm->ver == QM_HW_V1) {
/* /*
* have no way to get qm configure in VM in v1 hardware, * have no way to get qm configure in VM in v1 hardware,
......
...@@ -144,6 +144,13 @@ enum qm_vf_state { ...@@ -144,6 +144,13 @@ enum qm_vf_state {
QM_NOT_READY, QM_NOT_READY,
}; };
enum qm_misc_ctl_bits {
QM_DRIVER_REMOVING = 0x0,
QM_RST_SCHED,
QM_RESETTING,
QM_MODULE_PARAM,
};
enum qm_cap_bits { enum qm_cap_bits {
QM_SUPPORT_DB_ISOLATION = 0x0, QM_SUPPORT_DB_ISOLATION = 0x0,
QM_SUPPORT_FUNC_QOS, QM_SUPPORT_FUNC_QOS,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment