Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp343495pxa; Tue, 4 Aug 2020 07:03:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybierVTPZV0+itdUjFCbj8+8aBCy0AGctYWyOohCjkdszzkErMA6kdnOzD7lFu7nSVR/CU X-Received: by 2002:a17:906:a153:: with SMTP id bu19mr4962988ejb.142.1596549810067; Tue, 04 Aug 2020 07:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596549810; cv=none; d=google.com; s=arc-20160816; b=BUmHUTM/UdJpLmouLDgUn1Z8Gi+APrqiqrRJR7mXFwbo4913p+0NQlJONQ+Rg41ojA 5OQai/urtkLU8j++N57J5A06WCcZPsh17IH3QbpiS8hCiMZABJb6+eAPEI1U+wFf/U/I OKoyhNEZwcAN7Wra6t58vpFCPQdsqiT/2QnSYyMB2hLSFltS/g4kC8Sysfew9NjFY+DJ A5InFcV69rqhWFn6y/dGlDauImwfkxZULySuYtkjZ0BNLB4SpMznbzi8DBfl+2WVHgcw t4HPxYwO/TCooHptmUGQanc7TllAVY2lVeW9GuU4gsOar9Bjt81mNiWYmTCABzCvD5TR AE5w== 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=cS0jmm8AcwL1EkZt8BLriakflpSCyQ42KHPEOLs5flw=; b=wDijLajO3TrfC1CCNsmjGHvuaFuoIfG8A//wpRnGBqoGWLSMQMDh0tHVgrdFXiDtAx PX/R6zZHHMvAw1H2Tl9qpdpLeEf0UPLX+3hocgAjd4CiNASzT5KvX9W7vqkeExS9xCqu jCm9bK9mVdSdC0QZ+PukXCT6ec7s5d+p66NdaGhD0ozD/7sZUvvNXFpUmCZRnzjjC2PY nhc5Tkm0VayAHapuQXL/l2TMJn+vvWV6YuVAMGUJPHeZc8deywrOl3sSkTGRXezMo0A4 Tov87SFvPeUleyxjNaGVe5qbrwBUSAslcVCFstgBsuqgj6aeWaRU31rrTn597b372U3G NfFQ== 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 d23si5435089edr.58.2020.08.04.07.02.56; Tue, 04 Aug 2020 07:03:30 -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 S1726948AbgHDOCM (ORCPT + 99 others); Tue, 4 Aug 2020 10:02:12 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:60920 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728794AbgHDOBE (ORCPT ); Tue, 4 Aug 2020 10:01:04 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D20F097400DE8FCBDE50; Tue, 4 Aug 2020 22:00:38 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Tue, 4 Aug 2020 22:00:32 +0800 From: Yang Shen To: , CC: , , , Subject: [PATCH v4 08/10] crypto: hisilicon/qm - register callback function to 'pci_driver.shutdown' Date: Tue, 4 Aug 2020 21:58:28 +0800 Message-ID: <1596549510-2373-9-git-send-email-shenyang39@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1596549510-2373-1-git-send-email-shenyang39@huawei.com> References: <1596549510-2373-1-git-send-email-shenyang39@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 Since the drivers such as HPRE/SEC/ZIP do not implement 'pci_driver.shutdow', a RAS will be triggered at OS rebooting or shutting down as the hardware device is processing request. The log looks like this: NOTICE: [NimbusSecNodeType1]:[2372L]This is sec, Base = 0x141800000 NOTICE: [NimbusSecHandle]:[2319L] SecIntSt = 0x3 NOTICE: [NimbusSecHandle]:[2320L] SecQmIntStatus = 0x2 NOTICE: [PrintSecurityType]:[344L] SecurityType is RECOVERABLE! This patch offers a new API in qm to shutdown devices, and add shutdown callbacks in ACC driver based on this new API. So the running devices will be stopped when the OS reboot or shutdown. Signed-off-by: Yang Shen Reviewed-by: Zhou Wang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 1 + drivers/crypto/hisilicon/qm.c | 17 +++++++++++++++++ drivers/crypto/hisilicon/qm.h | 1 + drivers/crypto/hisilicon/sec2/sec_main.c | 1 + drivers/crypto/hisilicon/zip/zip_main.c | 1 + 5 files changed, 21 insertions(+) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index b9e5214..bbf3efb 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -939,6 +939,7 @@ static struct pci_driver hpre_pci_driver = { .sriov_configure = IS_ENABLED(CONFIG_PCI_IOV) ? hisi_qm_sriov_configure : NULL, .err_handler = &hpre_err_handler, + .shutdown = hisi_qm_dev_shutdown, }; static void hpre_register_debugfs(void) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 914771f..03393dd 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -3836,6 +3836,23 @@ static int qm_irq_register(struct hisi_qm *qm) return ret; } +/** + * hisi_qm_dev_shutdown() - Shutdown device. + * @pdev: The device will be shutdown. + * + * This function will stop qm when OS shutdown or rebooting. + */ +void hisi_qm_dev_shutdown(struct pci_dev *pdev) +{ + struct hisi_qm *qm = pci_get_drvdata(pdev); + int ret; + + ret = hisi_qm_stop(qm, QM_NORMAL); + if (ret) + dev_err(&pdev->dev, "Fail to stop qm in shutdown!\n"); +} +EXPORT_SYMBOL_GPL(hisi_qm_dev_shutdown); + static void hisi_qm_controller_reset(struct work_struct *rst_work) { struct hisi_qm *qm = container_of(rst_work, struct hisi_qm, rst_work); diff --git a/drivers/crypto/hisilicon/qm.h b/drivers/crypto/hisilicon/qm.h index 9d6cf1d..5fc44cb 100644 --- a/drivers/crypto/hisilicon/qm.h +++ b/drivers/crypto/hisilicon/qm.h @@ -390,4 +390,5 @@ void hisi_acc_free_sgl_pool(struct device *dev, int hisi_qm_alloc_qps_node(struct hisi_qm_list *qm_list, int qp_num, u8 alg_type, int node, struct hisi_qp **qps); void hisi_qm_free_qps(struct hisi_qp **qps, int qp_num); +void hisi_qm_dev_shutdown(struct pci_dev *pdev); #endif diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index 5f1c870..8b388c4 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -950,6 +950,7 @@ static struct pci_driver sec_pci_driver = { .remove = sec_remove, .err_handler = &sec_err_handler, .sriov_configure = hisi_qm_sriov_configure, + .shutdown = hisi_qm_dev_shutdown, }; static void sec_register_debugfs(void) diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index 224041e..10d2108 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -866,6 +866,7 @@ static struct pci_driver hisi_zip_pci_driver = { .sriov_configure = IS_ENABLED(CONFIG_PCI_IOV) ? hisi_qm_sriov_configure : NULL, .err_handler = &hisi_zip_err_handler, + .shutdown = hisi_qm_dev_shutdown, }; static void hisi_zip_register_debugfs(void) -- 2.7.4