Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: hisilicon/qm - increase wait time for mailbox

The device requires more time to process queue stop and function stop
mailbox commands compared to other mailbox commands . In the current
driver, the mailbox processing wait time for queue stop and function
stop is less than the device timeout, which may cause the driver to
incorrectly assume that the mailbox processing has failed. Therefore,
the driver wait time for queue stop and function stop should be set to
be greater than the device timeout. And PF and VF communication
relies on mailbox, the communication wait time should also be modified.

Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Weili Qian and committed by
Herbert Xu
6d0de601 3296992f

+24 -10
+24 -10
drivers/crypto/hisilicon/qm.c
··· 32 32 #define QM_MB_PING_ALL_VFS 0xffff 33 33 #define QM_MB_STATUS_MASK GENMASK(12, 9) 34 34 #define QM_MB_BUSY_MASK BIT(13) 35 + #define QM_MB_MAX_WAIT_TIMEOUT USEC_PER_SEC 36 + #define QM_MB_MAX_STOP_TIMEOUT (5 * USEC_PER_SEC) 35 37 36 38 /* sqc shift */ 37 39 #define QM_SQ_HOP_NUM_SHIFT 0 ··· 191 189 #define QM_IFC_INT_DISABLE BIT(0) 192 190 #define QM_IFC_INT_STATUS_MASK BIT(0) 193 191 #define QM_IFC_INT_SET_MASK BIT(0) 194 - #define QM_WAIT_DST_ACK 10 195 - #define QM_MAX_PF_WAIT_COUNT 10 192 + #define QM_WAIT_DST_ACK 1000 193 + #define QM_MAX_PF_WAIT_COUNT 20 196 194 #define QM_MAX_VF_WAIT_COUNT 40 197 195 #define QM_VF_RESET_WAIT_US 20000 198 196 #define QM_VF_RESET_WAIT_CNT 3000 ··· 647 645 } 648 646 EXPORT_SYMBOL_GPL(hisi_qm_wait_mb_ready); 649 647 650 - static int qm_wait_mb_finish(struct hisi_qm *qm, struct qm_mailbox *mailbox) 648 + static int qm_wait_mb_finish(struct hisi_qm *qm, struct qm_mailbox *mailbox, u32 wait_timeout) 651 649 { 652 650 struct device *dev = &qm->pdev->dev; 653 651 int ret; 654 652 655 653 ret = read_poll_timeout(qm_mb_read, *mailbox, 656 654 !(le16_to_cpu(mailbox->w0) & QM_MB_BUSY_MASK), 657 - POLL_PERIOD, POLL_TIMEOUT, 655 + POLL_PERIOD, wait_timeout, 658 656 true, qm); 659 657 if (ret) { 660 658 dev_err(dev, "QM mailbox operation timeout!\n"); ··· 669 667 return 0; 670 668 } 671 669 672 - static int qm_mb_nolock(struct hisi_qm *qm, struct qm_mailbox *mailbox) 670 + static int qm_mb_nolock(struct hisi_qm *qm, struct qm_mailbox *mailbox, u32 wait_timeout) 673 671 { 674 672 int ret; 675 673 ··· 679 677 680 678 qm_mb_write(qm, mailbox); 681 679 682 - ret = qm_wait_mb_finish(qm, mailbox); 680 + ret = qm_wait_mb_finish(qm, mailbox, wait_timeout); 683 681 if (ret) 684 682 goto mb_err_cnt_increase; 685 683 ··· 694 692 bool op) 695 693 { 696 694 struct qm_mailbox mailbox; 695 + u32 wait_timeout; 697 696 int ret; 697 + 698 + if (cmd == QM_MB_CMD_STOP_QP || cmd == QM_MB_CMD_FLUSH_QM) 699 + wait_timeout = QM_MB_MAX_STOP_TIMEOUT; 700 + else 701 + wait_timeout = QM_MB_MAX_WAIT_TIMEOUT; 702 + 703 + /* No need to judge if master OOO is blocked. */ 704 + if (qm_check_dev_error(qm)) { 705 + dev_err(&qm->pdev->dev, "QM mailbox operation failed since qm is stop!\n"); 706 + return -EIO; 707 + } 698 708 699 709 qm_mb_pre_init(&mailbox, cmd, dma_addr, queue, op); 700 710 701 711 mutex_lock(&qm->mailbox_lock); 702 - ret = qm_mb_nolock(qm, &mailbox); 712 + ret = qm_mb_nolock(qm, &mailbox, wait_timeout); 703 713 mutex_unlock(&qm->mailbox_lock); 704 714 705 715 return ret; ··· 725 711 726 712 qm_mb_pre_init(&mailbox, cmd, 0, queue, 1); 727 713 mutex_lock(&qm->mailbox_lock); 728 - ret = qm_mb_nolock(qm, &mailbox); 714 + ret = qm_mb_nolock(qm, &mailbox, QM_MB_MAX_WAIT_TIMEOUT); 729 715 mutex_unlock(&qm->mailbox_lock); 730 716 if (ret) 731 717 return ret; ··· 783 769 memcpy(tmp_xqc, xqc, size); 784 770 785 771 qm_mb_pre_init(&mailbox, cmd, xqc_dma, qp_id, op); 786 - ret = qm_mb_nolock(qm, &mailbox); 772 + ret = qm_mb_nolock(qm, &mailbox, QM_MB_MAX_WAIT_TIMEOUT); 787 773 if (!ret && op) 788 774 memcpy(xqc, tmp_xqc, size); 789 775 ··· 1911 1897 1912 1898 qm_mb_pre_init(&mailbox, QM_MB_CMD_SRC, msg, fun_num, 0); 1913 1899 mutex_lock(&qm->mailbox_lock); 1914 - return qm_mb_nolock(qm, &mailbox); 1900 + return qm_mb_nolock(qm, &mailbox, QM_MB_MAX_WAIT_TIMEOUT); 1915 1901 } 1916 1902 1917 1903 static void qm_set_ifc_end_v3(struct hisi_qm *qm)