Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp913468rdb; Wed, 6 Dec 2023 03:46:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXYwsBQKAy//6qNl1UZNZlmfDxqcptDKLKueARyiP049SbWynodBq5QFNVTc43frehQNu0 X-Received: by 2002:a05:6870:3326:b0:1fb:1dfe:290 with SMTP id x38-20020a056870332600b001fb1dfe0290mr822837oae.21.1701863163293; Wed, 06 Dec 2023 03:46:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701863163; cv=none; d=google.com; s=arc-20160816; b=TTse191G5XatyVKPCelgltwpjSNLuqjLsyaDtFT/h1XSsCBEHcnix1wldTXCXfzF+u a1eni62XQXpt5i5oIPs3RHHPXcyMkmcOSQe5tUEIqn8dF4owy9XoSdOnyJU6wDWGMGre 3hYxpD1nIMKgT/eR6iVMEHcVy6C9Oz193adosy499lGosoDWuqv7H9uU9F5anwQVJqUd uJptK0H4dVci5pvSGRy+x6u+yFjJMs8dtAYMNr6UoDmmQuqMwiaBWhkGr3aFsmLM89di iB3+Na1cOArvzWGPjN2n602QcqR4JukEplXI2VTLQBaffbDeOpwHUJ/CKkk/VYVhAoKS 1JXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence: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=ZQc994XJ/IDJ1BbhuVTyA9K2S/UUq9ABRACw8iX5CRg=; fh=qWiZG4mPppoTOFMesptsQB/QIvvL2KxTUddArP7SiGs=; b=fQBh84aVY7B3TvRN2jZZQGdA6okRWIrELbrWq+4jKqfx763+IaKOhFhujNMA8EQXPt os/I0rhaUq62lCbWqY+dBKNpCeyNPO+Z2VegKwhNrfxIMyQj3/X2/B2292TYTQyEbKKZ qjycK7w7P6cvYJpH0PuoFIU7P/SjQv/ZbicWG//3nT2H3wBo5RcO0knwuWyhVyONWAlW alpD6JretmIKpfhhB2lmTLiX0bKut8IoXQQgiLhgn5lP4PHjVyBw0Sls2YqNcsh+cvOR vC2TfkOnd3Ao5gmtjGYLTQB7oFMJhQz2okDqAFic7r7QLpzjnXkjFEfh8kKnVrmMbC7r +42A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t2-20020a63f342000000b005b92d41764dsi11012125pgj.794.2023.12.06.03.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 03:46:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5C6538075919; Wed, 6 Dec 2023 03:45:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377858AbjLFLpV convert rfc822-to-8bit (ORCPT + 99 others); Wed, 6 Dec 2023 06:45:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377732AbjLFLpT (ORCPT ); Wed, 6 Dec 2023 06:45:19 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBD17137; Wed, 6 Dec 2023 03:45:24 -0800 (PST) Received: from kwepemi500024.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SlbDB3WcwzvRfF; Wed, 6 Dec 2023 19:44:42 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by kwepemi500024.china.huawei.com (7.221.188.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 6 Dec 2023 19:45:21 +0800 Received: from dggpemm500006.china.huawei.com ([7.185.36.236]) by dggpemm500006.china.huawei.com ([7.185.36.236]) with mapi id 15.01.2507.035; Wed, 6 Dec 2023 19:45:21 +0800 From: "Gonglei (Arei)" To: "Michael S. Tsirkin" CC: Herbert Xu , "linux-crypto@vger.kernel.org" , Halil Pasic , Jason Wang , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , wangyangxin Subject: RE: [PATCH] crypto: virtio-crypto: Handle dataq logic with tasklet Thread-Topic: [PATCH] crypto: virtio-crypto: Handle dataq logic with tasklet Thread-Index: Adobp2Ma20NfNCVRS52WT53esc9NTAIe2VGAAQWnuTA= Date: Wed, 6 Dec 2023 11:45:21 +0000 Message-ID: <790734f7c6144b3aa1ee16ed1cc02b2c@huawei.com> References: <20231201095024-mutt-send-email-mst@kernel.org> In-Reply-To: <20231201095024-mutt-send-email-mst@kernel.org> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.149.11] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 06 Dec 2023 03:45:39 -0800 (PST) > -----Original Message----- > From: Michael S. Tsirkin [mailto:mst@redhat.com] > Sent: Friday, December 1, 2023 10:51 PM > To: Gonglei (Arei) > Cc: Herbert Xu ; linux-crypto@vger.kernel.org; > Halil Pasic ; Jason Wang ; > virtualization@lists.linux-foundation.org; linux-kernel@vger.kernel.org; > wangyangxin > Subject: Re: [PATCH] crypto: virtio-crypto: Handle dataq logic with tasklet > > On Mon, Nov 20, 2023 at 11:49:45AM +0000, Gonglei (Arei) wrote: > > Doing ipsec produces a spinlock recursion warning. > > This is due to crypto_finalize_request() being called in the upper half. > > Move virtual data queue processing of virtio-crypto driver to tasklet. > > > > Fixes: dbaf0624ffa57 ("crypto: add virtio-crypto driver") > > Reported-by: Halil Pasic > > Signed-off-by: wangyangxin > > Signed-off-by: Gonglei > > --- > > drivers/crypto/virtio/virtio_crypto_common.h | 2 ++ > > drivers/crypto/virtio/virtio_crypto_core.c | 23 +++++++++++++---------- > > 2 files changed, 15 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/crypto/virtio/virtio_crypto_common.h > > b/drivers/crypto/virtio/virtio_crypto_common.h > > index 59a4c02..5c17c6e 100644 > > --- a/drivers/crypto/virtio/virtio_crypto_common.h > > +++ b/drivers/crypto/virtio/virtio_crypto_common.h > > @@ -10,6 +10,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -28,6 +29,7 @@ struct data_queue { > > char name[32]; > > > > struct crypto_engine *engine; > > + struct tasklet_struct done_task; > > }; > > > > struct virtio_crypto { > > diff --git a/drivers/crypto/virtio/virtio_crypto_core.c > > b/drivers/crypto/virtio/virtio_crypto_core.c > > index 1198bd3..e747f4f 100644 > > --- a/drivers/crypto/virtio/virtio_crypto_core.c > > +++ b/drivers/crypto/virtio/virtio_crypto_core.c > > @@ -72,27 +72,28 @@ int virtio_crypto_ctrl_vq_request(struct virtio_crypto > *vcrypto, struct scatterl > > return 0; > > } > > > > -static void virtcrypto_dataq_callback(struct virtqueue *vq) > > +static void virtcrypto_done_task(unsigned long data) > > { > > - struct virtio_crypto *vcrypto = vq->vdev->priv; > > + struct data_queue *data_vq = (struct data_queue *)data; > > + struct virtqueue *vq = data_vq->vq; > > struct virtio_crypto_request *vc_req; > > - unsigned long flags; > > unsigned int len; > > - unsigned int qid = vq->index; > > > > - spin_lock_irqsave(&vcrypto->data_vq[qid].lock, flags); > > do { > > virtqueue_disable_cb(vq); > > while ((vc_req = virtqueue_get_buf(vq, &len)) != NULL) { > > - spin_unlock_irqrestore( > > - &vcrypto->data_vq[qid].lock, flags); > > if (vc_req->alg_cb) > > vc_req->alg_cb(vc_req, len); > > - spin_lock_irqsave( > > - &vcrypto->data_vq[qid].lock, flags); > > } > > } while (!virtqueue_enable_cb(vq)); > > - spin_unlock_irqrestore(&vcrypto->data_vq[qid].lock, flags); > > +} > > + > > +static void virtcrypto_dataq_callback(struct virtqueue *vq) { > > + struct virtio_crypto *vcrypto = vq->vdev->priv; > > + struct data_queue *dq = &vcrypto->data_vq[vq->index]; > > + > > + tasklet_schedule(&dq->done_task); > > } > > > > Don't we then need to wait for tasklet to complete on device remove? > > Yes, we should do it. V2 will be sent soon. Regards, -Gonglei > > static int virtcrypto_find_vqs(struct virtio_crypto *vi) @@ -150,6 > > +151,8 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi) > > ret = -ENOMEM; > > goto err_engine; > > } > > + tasklet_init(&vi->data_vq[i].done_task, virtcrypto_done_task, > > + (unsigned long)&vi->data_vq[i]); > > } > > > > kfree(names); > > -- > > 1.8.3.1 > > > > >