From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D3F8C28CBC for ; Sat, 9 May 2020 06:49:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07C45217BA for ; Sat, 9 May 2020 06:49:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728888AbgEIGts (ORCPT ); Sat, 9 May 2020 02:49:48 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4311 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728818AbgEIGts (ORCPT ); Sat, 9 May 2020 02:49:48 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F2BE9253CB718FD44F48; Sat, 9 May 2020 14:49:46 +0800 (CST) Received: from [10.63.139.185] (10.63.139.185) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Sat, 9 May 2020 14:49:37 +0800 Subject: Re: [PATCH 12/13] crypto: hisilicon/zip - Use temporary sqe when doing work To: Song Bao Hua , "tanshukun (A)" , "herbert@gondor.apana.org.au" , "davem@davemloft.net" References: <1588921068-20739-1-git-send-email-tanshukun1@huawei.com> <1588921068-20739-13-git-send-email-tanshukun1@huawei.com> CC: "linux-crypto@vger.kernel.org" , Xu Zaibo From: Zhou Wang Message-ID: <5EB6526A.20804@hisilicon.com> Date: Sat, 9 May 2020 14:49:14 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.63.139.185] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 2020/5/9 11:42, Song Bao Hua wrote: >> -----Original Message----- >> From: linux-crypto-owner@vger.kernel.org [mailto:linux-crypto-owner@vger.kernel.org] On Behalf Of Shukun Tan >> Sent: Friday, May 8, 2020 6:58 PM >> To: herbert@gondor.apana.org.au; davem@davemloft.net >> Cc: linux-crypto@vger.kernel.org; Xu Zaibo ; Wangzhou (B) >> Subject: [PATCH 12/13] crypto: hisilicon/zip - Use temporary sqe when doing work > >> From: Zhou Wang > >> Currently zip sqe is stored in hisi_zip_qp_ctx, which will bring corruption with multiple parallel users of the crypto tfm. > >> This patch removes the zip_sqe in hisi_zip_qp_ctx and uses a temporary sqe instead. > > This looks like a quite correct fix as in the old code, the 2nd request will overwrite the zip_sqe of the 1st request if we send the 2nd request before the 1st one is completed. > So this will lead to the mistakes of both request1 and request2. Yes. > > unfortunately, it seems the hang issue can still be reproduced with this patch applied if we ask multi-threads running on multi-cores to send requests in parallel. Maybe something more needs fix? Currently we do not support multi-threads using one crypto_acomp in this driver. If you tested like this, it may go wrong, as we do not protect queue which is in zip ctx. Best, Zhou > >> Signed-off-by: Zhou Wang >> Signed-off-by: Jonathan Cameron >> Signed-off-by: Shukun Tan >> --- >> drivers/crypto/hisilicon/zip/zip_crypto.c | 11 +++++------ >> 1 file changed, 5 insertions(+), 6 deletions(-) > >> diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c >> index 369ec32..5fb9d4b 100644 >> --- a/drivers/crypto/hisilicon/zip/zip_crypto.c >> +++ b/drivers/crypto/hisilicon/zip/zip_crypto.c >> @@ -64,7 +64,6 @@ struct hisi_zip_req_q { >> >> struct hisi_zip_qp_ctx { >> struct hisi_qp *qp; >> - struct hisi_zip_sqe zip_sqe; >> struct hisi_zip_req_q req_q; >> struct hisi_acc_sgl_pool *sgl_pool; >> struct hisi_zip *zip_dev; >> @@ -484,11 +483,11 @@ static struct hisi_zip_req *hisi_zip_create_req(struct acomp_req *req, static int hisi_zip_do_work(struct hisi_zip_req *req, >> struct hisi_zip_qp_ctx *qp_ctx) >> { >> - struct hisi_zip_sqe *zip_sqe = &qp_ctx->zip_sqe; >> struct acomp_req *a_req = req->req; >> struct hisi_qp *qp = qp_ctx->qp; >> struct device *dev = &qp->qm->pdev->dev; >> struct hisi_acc_sgl_pool *pool = qp_ctx->sgl_pool; >> + struct hisi_zip_sqe zip_sqe; >> dma_addr_t input; >> dma_addr_t output; >> int ret; >> @@ -511,13 +510,13 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, >> } >> req->dma_dst = output; >> >> - hisi_zip_fill_sqe(zip_sqe, qp->req_type, input, output, a_req->slen, >> + hisi_zip_fill_sqe(&zip_sqe, qp->req_type, input, output, a_req->slen, >> a_req->dlen, req->sskip, req->dskip); >> - hisi_zip_config_buf_type(zip_sqe, HZIP_SGL); >> - hisi_zip_config_tag(zip_sqe, req->req_id); >> + hisi_zip_config_buf_type(&zip_sqe, HZIP_SGL); >> + hisi_zip_config_tag(&zip_sqe, req->req_id); >> >> /* send command to start a task */ >> - ret = hisi_qp_send(qp, zip_sqe); >> + ret = hisi_qp_send(qp, &zip_sqe); >> if (ret < 0) >> goto err_unmap_output; >> > > Best Regards > Barry > > . >