Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2344359rwp; Fri, 14 Jul 2023 04:59:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlENpUR8tHZdm0ggBnfM4XIIB6K1iUN8k1wGdKnk+Wxbdrg8mi4M2bfNnkm5CMmz9PcL5p5m X-Received: by 2002:a17:906:274e:b0:975:63f4:4b with SMTP id a14-20020a170906274e00b0097563f4004bmr3867881ejd.36.1689335964262; Fri, 14 Jul 2023 04:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689335964; cv=none; d=google.com; s=arc-20160816; b=ukIOK6wgt9VuclJpxwUk8eHoG5Bg0O68kHaORujwcFvGDSbaheAaDe9fm9dhBOA5kF zyXcKVeJomHSIvMZ1w81hE89lp0EPMSRlFOjPAwe0ud5Xr0n4HBkvalDpwy77jUQtmK3 D8749n4/+nocFfcJ4mSrGM36fWm7jxa8YFvEMrj76/lPnH02BUG1EVf4LP/zr+2N1Q5F cWdrcYIwX5qeyK8S9ScJiF9EKJLIizsJeUWlevrYI3uzJHQD91umqWm+nX6ngC+nJfKJ kpxm7pFZgCPz2+m/JwWjoGpuzMCBI7ILxZcll4BzEfYnJmD7YzqqT4YB7I3VcvQUsgJ0 CHQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=htUJX4vk1HDCw5GHHPbMDIi6Dh7QRwSrFWIuQDoyJag=; fh=5KOsK5hFKXUJvlj0mfSujp2NvbiBqICq6lLfqSU043c=; b=BSIUum6iCrtW+ezsfyM0NtGM7FplKuRGzqsYRF609Cq+7NHG7GfkZv1SI91xTvd/5+ xCe1qRisPVh+5fLJHlonc3ulAwXHOgCxZdLKZUQ2pZxfMAwG1/y+sNiEPmHw/nSpZGMq +QKp55tlJhyTivXREjrRqEhjB+sT5QHZMGHbKYgHN9sMNx3jlZGBlEGl0UHDdauell5F 8+4y8qoSSsf9FXF01qLBplKABlUgzOeImTzzNq4qTZzWBTnUZXfSiYFYhM5c3lAhH2At 3/m3yXSdgxy7O0EHtZyBN1fKAo/8SeYJSiSGaq70/WSrTK0Nmi+pF+Zy5EQb8UG7F2Ai O+mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jo2-20020a170906f6c200b00992b32e3e3esi8623507ejb.468.2023.07.14.04.59.00; Fri, 14 Jul 2023 04:59:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235396AbjGNLoO (ORCPT + 99 others); Fri, 14 Jul 2023 07:44:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235151AbjGNLoN (ORCPT ); Fri, 14 Jul 2023 07:44:13 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C12992D41; Fri, 14 Jul 2023 04:44:11 -0700 (PDT) Received: from kwepemm600009.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4R2V3m0xWyz18Lqp; Fri, 14 Jul 2023 19:43:32 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 14 Jul 2023 19:44:09 +0800 From: Weili Qian To: CC: , , Subject: [PATCH 2/4] crypto: hisilicon/qm - stop function and write data to memory Date: Fri, 14 Jul 2023 19:41:36 +0800 Message-ID: <20230714114138.1582-3-qianweili@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230714114138.1582-1-qianweili@huawei.com> References: <20230714114138.1582-1-qianweili@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org When the system is shut down, the process is killed, but the accelerator device does not stop executing the tasks. If the accelerator device still accesses the memory and writes back data to the memory after the memory is reclaimed by the system, an NFE error may occur. Therefore, before the system is shut down, the driver needs to stop the device and write data back to the memory. Signed-off-by: Weili Qian --- drivers/crypto/hisilicon/qm.c | 14 ++++++++------ include/linux/hisi_acc_qm.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 81c21ca40375..fdff87c09aaf 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -1002,7 +1002,7 @@ static void qm_reset_function(struct hisi_qm *qm) return; } - ret = hisi_qm_stop(qm, QM_FLR); + ret = hisi_qm_stop(qm, QM_DOWN); if (ret) { dev_err(dev, "failed to stop qm when reset function\n"); goto clear_bit; @@ -3251,7 +3251,7 @@ int hisi_qm_stop(struct hisi_qm *qm, enum qm_stop_reason r) } if (qm->status.stop_reason == QM_SOFT_RESET || - qm->status.stop_reason == QM_FLR) { + qm->status.stop_reason == QM_DOWN) { hisi_qm_set_hw_reset(qm, QM_RESET_STOP_TX_OFFSET); ret = qm_stop_started_qp(qm); if (ret < 0) { @@ -4547,11 +4547,11 @@ void hisi_qm_reset_prepare(struct pci_dev *pdev) if (qm->fun_type == QM_HW_PF) qm_cmd_uninit(qm); - ret = qm_try_stop_vfs(qm, QM_PF_FLR_PREPARE, QM_FLR); + ret = qm_try_stop_vfs(qm, QM_PF_FLR_PREPARE, QM_DOWN); if (ret) pci_err(pdev, "failed to stop vfs by pf in FLR.\n"); - ret = hisi_qm_stop(qm, QM_FLR); + ret = hisi_qm_stop(qm, QM_DOWN); if (ret) { pci_err(pdev, "Failed to stop QM, ret = %d.\n", ret); hisi_qm_set_hw_reset(qm, QM_RESET_STOP_TX_OFFSET); @@ -4649,9 +4649,11 @@ 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); + ret = hisi_qm_stop(qm, QM_DOWN); if (ret) dev_err(&pdev->dev, "Fail to stop qm in shutdown!\n"); + + hisi_qm_cache_wb(qm); } EXPORT_SYMBOL_GPL(hisi_qm_dev_shutdown); @@ -4815,7 +4817,7 @@ static void qm_handle_cmd_msg(struct hisi_qm *qm, u32 fun_num) cmd = msg & QM_MB_CMD_DATA_MASK; switch (cmd) { case QM_PF_FLR_PREPARE: - qm_pf_reset_vf_process(qm, QM_FLR); + qm_pf_reset_vf_process(qm, QM_DOWN); break; case QM_PF_SRST_PREPARE: qm_pf_reset_vf_process(qm, QM_SOFT_RESET); diff --git a/include/linux/hisi_acc_qm.h b/include/linux/hisi_acc_qm.h index a7d54d4d41fd..39fbfb4be944 100644 --- a/include/linux/hisi_acc_qm.h +++ b/include/linux/hisi_acc_qm.h @@ -104,7 +104,7 @@ enum qm_stop_reason { QM_NORMAL, QM_SOFT_RESET, - QM_FLR, + QM_DOWN, }; enum qm_state { -- 2.33.0