Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1907295pxx; Sat, 31 Oct 2020 02:09:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNuBqywcnBOWOL3BnM2/v4yXCQCgaRvZxHXEmjuoFrNaWZyf+vaMSjudM4IeO+Vjza4X4r X-Received: by 2002:a17:906:5e49:: with SMTP id b9mr6411180eju.436.1604135380681; Sat, 31 Oct 2020 02:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604135380; cv=none; d=google.com; s=arc-20160816; b=lP5sHFoRBVAFBVgryN0UN8cqY43vnLKuGy0Ygg/5jGxp2lBMwAWPFpLO9mV8FqLRXC q8XHZRL4JxsiGeh5x3rWjpp/hbHVmupVxV1+EcR9bx4JktvJ/UkNrakx7Welk8al/i5E o+wJKtX8UkdhRXvmt2UxMo+AGhlEhqdkL7xICNy7e0m8PAtpk2iKklfJMv9C3tzvXicP ZU5BUOG83oNc9i3zZbBpwFMDamUtR70vMlftQXypZhjF1i8SAy+q5JWWwQGmXp4KVdwE o6c74g2YVsxIvhcIYmuL2pqMvKsmYNYm4hUzL0eXpeJ1GIllRTL6ulRciMJ+Go1XHPkK kuGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=eeqSIZe1fus32fot7F9oXYpKizjK4RwRROmJ+M0Law8=; b=S3DY7fgJhBZHGGs6hKuiecLDLAQt0jJVmj3WPrzu2sXGRM3kDaW2upFbDXDBB1AmJQ bX+hkofO5Vqzvki2CSASVqK2JAFZjZyDb7GApbJodZycTLDurHaOdUtXSoq5Pm80bZ+9 cKB5XpYbCGTb+8aqLo5+D+yIpj3RqtY9c2Yn/3vtqjznHiTH0tPWobVW29h89qavcZ/w g8D0+TBAX/GIyiKzMfGNeLevWtmzh/V2A1yG8yOtoM7/TO2MBJ9R0dRfJwxAo1ejyzBO tCY7cQo1I2f5Y2JLgOu6eMe1KztPehzPlD+6LDC2rEVeT2QdsN1s7+s4wjeGPesUtFI1 ekJA== 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 g17si7425577ejr.134.2020.10.31.02.09.17; Sat, 31 Oct 2020 02:09:40 -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 S1726589AbgJaJIy (ORCPT + 99 others); Sat, 31 Oct 2020 05:08:54 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:7388 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgJaJIw (ORCPT ); Sat, 31 Oct 2020 05:08:52 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CNYJH0P8Dz70tb; Sat, 31 Oct 2020 17:08:47 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Sat, 31 Oct 2020 17:08:36 +0800 From: Weili Qian To: , CC: , , , Subject: [PATCH 8/8] crypto: hisilicon/qm - split 'hisi_qm_init' into smaller pieces Date: Sat, 31 Oct 2020 17:07:08 +0800 Message-ID: <1604135228-18410-9-git-send-email-qianweili@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1604135228-18410-1-git-send-email-qianweili@huawei.com> References: <1604135228-18410-1-git-send-email-qianweili@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 'hisi_qm_init' initializes configuration of QM. To improve code readability, split it into two pieces. Signed-off-by: Weili Qian Reviewed-by: Zhou Wang --- drivers/crypto/hisilicon/qm.c | 86 ++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 6e8d20d..f21ccae 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -2442,6 +2442,16 @@ static void hisi_qm_pre_init(struct hisi_qm *qm) qm->is_frozen = false; } +static void hisi_qm_pci_uninit(struct hisi_qm *qm) +{ + struct pci_dev *pdev = qm->pdev; + + pci_free_irq_vectors(pdev); + iounmap(qm->io_base); + pci_release_mem_regions(pdev); + pci_disable_device(pdev); +} + /** * hisi_qm_uninit() - Uninitialize qm. * @qm: The qm needed uninit. @@ -2460,9 +2470,6 @@ void hisi_qm_uninit(struct hisi_qm *qm) return; } - uacce_remove(qm->uacce); - qm->uacce = NULL; - hisi_qp_memory_uninit(qm, qm->qp_num); idr_destroy(&qm->qp_idr); @@ -2474,10 +2481,9 @@ void hisi_qm_uninit(struct hisi_qm *qm) } qm_irq_unregister(qm); - pci_free_irq_vectors(pdev); - iounmap(qm->io_base); - pci_release_mem_regions(pdev); - pci_disable_device(pdev); + hisi_qm_pci_uninit(qm); + uacce_remove(qm->uacce); + qm->uacce = NULL; up_write(&qm->qps_lock); } @@ -4038,34 +4044,22 @@ void hisi_qm_alg_unregister(struct hisi_qm *qm, struct hisi_qm_list *qm_list) } EXPORT_SYMBOL_GPL(hisi_qm_alg_unregister); -/** - * hisi_qm_init() - Initialize configures about qm. - * @qm: The qm needing init. - * - * This function init qm, then we can call hisi_qm_start to put qm into work. - */ -int hisi_qm_init(struct hisi_qm *qm) +static int hisi_qm_pci_init(struct hisi_qm *qm) { struct pci_dev *pdev = qm->pdev; struct device *dev = &pdev->dev; unsigned int num_vec; int ret; - hisi_qm_pre_init(qm); - - ret = qm_alloc_uacce(qm); - if (ret < 0) - dev_warn(&pdev->dev, "fail to alloc uacce (%d)\n", ret); - ret = pci_enable_device_mem(pdev); if (ret < 0) { - dev_err(&pdev->dev, "Failed to enable device mem!\n"); - goto err_remove_uacce; + dev_err(dev, "Failed to enable device mem!\n"); + return ret; } ret = pci_request_mem_regions(pdev, qm->dev_name); if (ret < 0) { - dev_err(&pdev->dev, "Failed to request mem regions!\n"); + dev_err(dev, "Failed to request mem regions!\n"); goto err_disable_pcidev; } @@ -4093,9 +4087,42 @@ int hisi_qm_init(struct hisi_qm *qm) goto err_iounmap; } + return 0; + +err_iounmap: + iounmap(qm->io_base); +err_release_mem_regions: + pci_release_mem_regions(pdev); +err_disable_pcidev: + pci_disable_device(pdev); + return ret; +} + +/** + * hisi_qm_init() - Initialize configures about qm. + * @qm: The qm needing init. + * + * This function init qm, then we can call hisi_qm_start to put qm into work. + */ +int hisi_qm_init(struct hisi_qm *qm) +{ + struct pci_dev *pdev = qm->pdev; + struct device *dev = &pdev->dev; + int ret; + + hisi_qm_pre_init(qm); + + ret = qm_alloc_uacce(qm); + if (ret < 0) + dev_warn(dev, "fail to alloc uacce (%d)\n", ret); + + ret = hisi_qm_pci_init(qm); + if (ret) + goto err_remove_uacce; + ret = qm_irq_register(qm); if (ret) - goto err_free_irq_vectors; + goto err_pci_uninit; if (qm->fun_type == QM_HW_VF && qm->ver != QM_HW_V1) { /* v2 starts to support get vft by mailbox */ @@ -4118,14 +4145,8 @@ int hisi_qm_init(struct hisi_qm *qm) err_irq_unregister: qm_irq_unregister(qm); -err_free_irq_vectors: - pci_free_irq_vectors(pdev); -err_iounmap: - iounmap(qm->io_base); -err_release_mem_regions: - pci_release_mem_regions(pdev); -err_disable_pcidev: - pci_disable_device(pdev); +err_pci_uninit: + hisi_qm_pci_uninit(qm); err_remove_uacce: uacce_remove(qm->uacce); qm->uacce = NULL; @@ -4133,7 +4154,6 @@ int hisi_qm_init(struct hisi_qm *qm) } EXPORT_SYMBOL_GPL(hisi_qm_init); - MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Zhou Wang "); MODULE_DESCRIPTION("HiSilicon Accelerator queue manager driver"); -- 2.8.1