Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp116151ybk; Fri, 8 May 2020 20:43:10 -0700 (PDT) X-Google-Smtp-Source: APiQypK/4mJrrx0/AoAhNvmG5l1ZdRwhKBaNzFHGmDJx5ndr1ixWNExeILDzalPdG3oX8tyxHM86 X-Received: by 2002:a17:907:11de:: with SMTP id va30mr4706839ejb.121.1588995789928; Fri, 08 May 2020 20:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588995789; cv=none; d=google.com; s=arc-20160816; b=uH3B5voQlXVmAFBhHCajc3a1euTCwaR//4Mob0KEMGLSlCpZcw8FpQ2u6ADHv+RBWY kGSb9AZ/Yj9IfyLZjK58xo2MB0P8bFvTj7P2yhf28RG8OHdIr1GV9JIdWv2xBMsUtkRW MoQ2bKZR8fdisCR7vgNUF5VGODCdjUzNgZHTeuS0S9HfkYnPvs0h88Q0BIBXTXC7ZBe0 tIqO99VwWNx3HMrGFUpcgfyN0YzJC1mYTmhy4yT4jSHVE3kn+unuhHlKUuTHnIsNYrpT SLSv1jvUhbpgXE174Djs/7zKDQPuzjTAFqOBcFKm4gh8uzOzQdx5ikE6vVglUh7pxT7a fapA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=PXVuNfjPLV8ykMhBLR5UJamDyGfpOKQ9FKeT0IrNGJg=; b=JnUAFJLxJg3t0IzsfyqN486ybXKxrWTcKBLGwGI/b6jGdOucJYy8g5MhqA3Yk+ajTy AGmO7SzuzJdPYZptdcbs5Ryn2H4H9+8c2jRT2HsFBPXSMk1p3WSPOgaJmjLOiBIS997R QDVXAOcq5XlPZNTzFAyq1ZB9YN12acvwM73PZ2ldyR9Apj2bfupJLIRqPplZwrcIdnMk 6sYbPF9uO4fk+a9FBHZYJbSyK6O0mL3mv3XFCbuh1uZirntIndi6ebI7/KiWZnHWLrFB YB7f9QFstxaqiMaL+R1k9FVQqqZUrbT8dUaFT49elY8pISOCVO5z0YAqZl/yDvwux7OG AfgA== 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 f12si2168743eja.218.2020.05.08.20.42.40; Fri, 08 May 2020 20:43:09 -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 S1728353AbgEIDmQ convert rfc822-to-8bit (ORCPT + 99 others); Fri, 8 May 2020 23:42:16 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:2128 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726415AbgEIDmQ (ORCPT ); Fri, 8 May 2020 23:42:16 -0400 Received: from dggemi405-hub.china.huawei.com (unknown [172.30.72.57]) by Forcepoint Email with ESMTP id B8176AE831D12A79E648; Sat, 9 May 2020 11:42:13 +0800 (CST) Received: from DGGEMI525-MBS.china.huawei.com ([169.254.6.251]) by dggemi405-hub.china.huawei.com ([10.3.17.143]) with mapi id 14.03.0487.000; Sat, 9 May 2020 11:42:04 +0800 From: Song Bao Hua To: "tanshukun (A)" , "herbert@gondor.apana.org.au" , "davem@davemloft.net" CC: "linux-crypto@vger.kernel.org" , Xu Zaibo , "Wangzhou (B)" Subject: RE: [PATCH 12/13] crypto: hisilicon/zip - Use temporary sqe when doing work Thread-Topic: [PATCH 12/13] crypto: hisilicon/zip - Use temporary sqe when doing work Thread-Index: AQHWJQZAcAZApu4+hkePZFWlj8fJQ6ifGvTA Date: Sat, 9 May 2020 03:42:04 +0000 Message-ID: References: <1588921068-20739-1-git-send-email-tanshukun1@huawei.com> <1588921068-20739-13-git-send-email-tanshukun1@huawei.com> In-Reply-To: <1588921068-20739-13-git-send-email-tanshukun1@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.126.201.87] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org > -----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. 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? > 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