Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp282507ybk; Sat, 9 May 2020 02:46:13 -0700 (PDT) X-Google-Smtp-Source: APiQypJIuiZIn8lNyxNF76TVSwD30jyyvHGfhZGnoW/6LE5uC0EoTU/AyHLENBFbs9RdVBRO7FIw X-Received: by 2002:a17:906:1ccb:: with SMTP id i11mr5313501ejh.101.1589017573289; Sat, 09 May 2020 02:46:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589017573; cv=none; d=google.com; s=arc-20160816; b=N0ysAXZa52qO/l49YQ6KEk5UUq9zD+t5T7Ir7ISzJxP1+FsQGTsPWBpskfs5tRuNgE DNi5hhgmldU1FJybPURk1k59FSbDC+h5GOCQyib2l4odu/jNqKJDBV3pkEY2Dgx5knwv v+BIXrpIgUQGXVnpq1ZJmcF9GXRgl/IXIFmoU22cwtc1AvGvB4AGaHablo0lvKTFY3AS CVuwK+dyQjhZkWGUIaQOjetqn0PqYrBk/y/3VQl+iw3lY1GMAUayFmV3tglrYeoUFuHQ l0bfcJJzcrBABNQSi5BmP2DqiVlTCKkyGXaLAi9QgCtL/sO8WPwVmW1PlvA8zo6Tbyea wnLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ODvMomikj7fDF44J/F9OdgOVTWfr2oTGdjMnkuAHvSE=; b=o6XVfbIOEV2S7vFCVThcW9PonfSFB5akSthl4E8QLfX2/uuADxvrDVGQu9Zuva2mMU Gdt+QBPeyZ7N9+58FSjxgBw+N5kZd/q/Q7HynDNJo8DHc3XjgbBocycs6LwteKzK8P38 kpt9Wf79j3I7WpuuHDSAOlN9AH+X07V8I1OJNx9sTv3D3crA5riGcwxTUBIRNMx/s79v xst0+xE+Q5Htp0mPhRJ+Eapb/p3c4smXPYidZMQxM5jflAcYL54iHFdb2o0DilE0S/Bv DlaPqazUQ8Y5vUuzb7kZu4J93M8kjj/70BpB8KYe4nLEKmjlHfgGPgJZPdP+8tuzzO2Z ufWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b23si2472269edx.520.2020.05.09.02.45.49; Sat, 09 May 2020 02:46:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728108AbgEIJpZ (ORCPT + 99 others); Sat, 9 May 2020 05:45:25 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4316 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728182AbgEIJpW (ORCPT ); Sat, 9 May 2020 05:45:22 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 72102D5E54DF7FC4B3B1; Sat, 9 May 2020 17:45:19 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Sat, 9 May 2020 17:45:10 +0800 From: Shukun Tan To: , CC: , , Subject: [PATCH v2 01/12] crypto: hisilicon/sec2 - modify the SEC probe process Date: Sat, 9 May 2020 17:43:54 +0800 Message-ID: <1589017445-15514-2-git-send-email-tanshukun1@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589017445-15514-1-git-send-email-tanshukun1@huawei.com> References: <1589017445-15514-1-git-send-email-tanshukun1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Longfang Liu Adjust the position of SMMU status check and SEC queue initialization in SEC probe Signed-off-by: Longfang Liu Signed-off-by: Zaibo Xu Signed-off-by: Shukun Tan Reviewed-by: Zhou Wang --- drivers/crypto/hisilicon/sec2/sec_main.c | 67 ++++++++++++++------------------ 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index 07a5f4e..ea029e3 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -765,6 +765,21 @@ static int sec_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) qm->dev_name = sec_name; qm->fun_type = (pdev->device == SEC_PF_PCI_DEVICE_ID) ? QM_HW_PF : QM_HW_VF; + if (qm->fun_type == QM_HW_PF) { + qm->qp_base = SEC_PF_DEF_Q_BASE; + qm->qp_num = pf_q_num; + qm->debug.curr_qm_qp_num = pf_q_num; + qm->qm_list = &sec_devices; + } 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, + * so currently force PF to uses SEC_PF_DEF_Q_NUM, and force + * to trigger only one VF in v1 hardware. + * v2 hardware has no such problem. + */ + qm->qp_base = SEC_PF_DEF_Q_NUM; + qm->qp_num = SEC_QUEUE_NUM_V1 - SEC_PF_DEF_Q_NUM; + } qm->use_dma_api = true; return hisi_qm_init(qm); @@ -775,8 +790,9 @@ static void sec_qm_uninit(struct hisi_qm *qm) hisi_qm_uninit(qm); } -static int sec_probe_init(struct hisi_qm *qm, struct sec_dev *sec) +static int sec_probe_init(struct sec_dev *sec) { + struct hisi_qm *qm = &sec->qm; int ret; /* @@ -793,40 +809,18 @@ static int sec_probe_init(struct hisi_qm *qm, struct sec_dev *sec) return -ENOMEM; } - if (qm->fun_type == QM_HW_PF) { - qm->qp_base = SEC_PF_DEF_Q_BASE; - qm->qp_num = pf_q_num; - qm->debug.curr_qm_qp_num = pf_q_num; - qm->qm_list = &sec_devices; - + if (qm->fun_type == QM_HW_PF) ret = sec_pf_probe_init(sec); - if (ret) - goto err_probe_uninit; - } else if (qm->fun_type == QM_HW_VF) { - /* - * have no way to get qm configure in VM in v1 hardware, - * so currently force PF to uses SEC_PF_DEF_Q_NUM, and force - * to trigger only one VF in v1 hardware. - * v2 hardware has no such problem. - */ - if (qm->ver == QM_HW_V1) { - qm->qp_base = SEC_PF_DEF_Q_NUM; - qm->qp_num = SEC_QUEUE_NUM_V1 - SEC_PF_DEF_Q_NUM; - } else if (qm->ver == QM_HW_V2) { - /* v2 starts to support get vft by mailbox */ - ret = hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num); - if (ret) - goto err_probe_uninit; - } - } else { - ret = -ENODEV; - goto err_probe_uninit; + else if (qm->fun_type == QM_HW_VF && qm->ver == QM_HW_V2) + /* v2 starts to support get vft by mailbox */ + ret = hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num); + + if (ret) { + destroy_workqueue(qm->wq); + return ret; } return 0; -err_probe_uninit: - destroy_workqueue(qm->wq); - return ret; } static void sec_probe_uninit(struct hisi_qm *qm) @@ -865,18 +859,17 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_set_drvdata(pdev, sec); - sec->ctx_q_num = ctx_q_num; - sec_iommu_used_check(sec); - qm = &sec->qm; - ret = sec_qm_init(qm, pdev); if (ret) { - pci_err(pdev, "Failed to pre init qm!\n"); + pci_err(pdev, "Failed to init SEC QM (%d)!\n", ret); return ret; } - ret = sec_probe_init(qm, sec); + sec->ctx_q_num = ctx_q_num; + sec_iommu_used_check(sec); + + ret = sec_probe_init(sec); if (ret) { pci_err(pdev, "Failed to probe!\n"); goto err_qm_uninit; -- 2.7.4