Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1087934rdb; Fri, 1 Dec 2023 06:51:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUQ2cUrnSq9Wy2/hkl8WAkQ++u9yyhjv8dx4YIua9CDMVmgEXp5z5JOIzAUfjoVOHkl0Dz X-Received: by 2002:a05:6358:52cf:b0:16b:fcd3:a3ed with SMTP id z15-20020a05635852cf00b0016bfcd3a3edmr32041250rwz.24.1701442290535; Fri, 01 Dec 2023 06:51:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701442290; cv=none; d=google.com; s=arc-20160816; b=sFqnOkDBOEhCqNgD9D4t3LJDyoiIehHZxwMrWo/aEl23BZzSk2xnHv7gU0xRbBYOgs mU9Xipz3oSPwqrfuDxjTheafJjBAoPy8xrI5cA13GYQKS8LMeyIaXhgvCuoGxLZ+s/A2 iET8tTw6+cumOYa7mmjnX1mwpH+B5Cjix2u4VtuEfcXojpJ80cPkzmJq5XblP+86dV4u vQKVKGpntyMaCjjT2H2aD9ixxyxYEREzDvkOgqY4KYImhRfV/0CZDYlBDACzBQCjO4nn wtTYMbiOOj9WK7xPGI9b/HYd7UwaFRBu+xLZKMgJ6uZK9nQI7mRfyBbxuDvN8pA7XKwi FCgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=F6+fTNyVfQbvpv0mXBsvFlerCoSqluEuKgG50iz8c2Q=; fh=/wmwi4LuwspsKgXG91ybkfJcFycrygsf4G9YRkHWLgQ=; b=o54UXnrgKcVMJDSnSPQlNkYvJhmRbCBcwyZ1u+DZSppxG53+/2X6bJjIi8yWm+qnSD JuxXDDdVexXCRDri8jZe9x9VN1UqXB9t13KnnDWUOEBgsEcCI4B8Xft4slJzZT1OTs0A ZAtS6PdF4lU8IGQbN0+NByE0ItuXJuJUgwMB4MV20Zfg2XP9Fz2XH9bH1kqv5pUJYTT6 C4uvNSvAPLxz1REJXEz4zYDezcBRlPdPkJ9iQEZQrmbdxeLOREl7sV4azqcb8Amfs10e 4bB6yrbtOyCRlgqPOwmXFb11i0W9Waa//hac8kB3G5KZKciROuhMaRBf606zVRAn8GXa r52A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gtOBrj03; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y191-20020a638ac8000000b005b9b68add9asi3342520pgd.255.2023.12.01.06.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 06:51:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gtOBrj03; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4D62E81068CF; Fri, 1 Dec 2023 06:51:29 -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 S1379227AbjLAOvT (ORCPT + 99 others); Fri, 1 Dec 2023 09:51:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379195AbjLAOvS (ORCPT ); Fri, 1 Dec 2023 09:51:18 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 369ED10F4 for ; Fri, 1 Dec 2023 06:51:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701442283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=F6+fTNyVfQbvpv0mXBsvFlerCoSqluEuKgG50iz8c2Q=; b=gtOBrj030a1bxEoGeAchjZY27qCQK/ybYlFg4niH4lNwrYB17XEuu4UgxXA4LEAxC2cIqj XX2fGP2pi9Eduhj8F+817l4hxNspdOHrlOpWPhrI8cAW3J427BJ3DX0rRcDHsJQZYBiK5q vn1DN9EloXkJEtivEiEiY5Q4moU1nUI= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-G7vM5W9LMUqUb3y1aux6-A-1; Fri, 01 Dec 2023 09:51:22 -0500 X-MC-Unique: G7vM5W9LMUqUb3y1aux6-A-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-40b3d81399dso15124175e9.1 for ; Fri, 01 Dec 2023 06:51:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701442281; x=1702047081; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=F6+fTNyVfQbvpv0mXBsvFlerCoSqluEuKgG50iz8c2Q=; b=qHcLiRx0Wejcgsv1K/sdEl7E811ds/npOBAurI/rlnR5gYIiGMfnu0Lj9SPPowY954 05L4YDPYTlLCuRmFGME3iqNNyy64vIvHZoOaivZu19X6JbSfXWCW/WjEf6rWNzcpz1+W R56xcJ6kvx9m/RPLhyE2cJs0DSfpsn0SCeGhF/VsO7uSWWr8/lAmfYmYCMcFlN7Z9sr6 9a+WMlXNsX6Rw6e6dy1IIIXQ1ATsBHYDvfRR41eR8yodk588YpYCIQFNuESoVq0XQ0u2 ocioagj8kh9kufThJvvuOPwdSMtxi1FLvIJIDOPCdPyf2ZLrJV0bUYK1RnEp0EAOf6D0 c9IA== X-Gm-Message-State: AOJu0Yyi7TWUacEwZ5v4x1VHhYbxdJbervGR7P4E+lNYYdfv5bqJt+ch ZMe79a6St+oQYlXh3ZbyHjZZ9QvET0So1VJHPIrgUYlgx+0HVaDG0GfWUECTv+saG2TEzthGBHD vi8lhMpf09rFsRm/AJN81N8MP X-Received: by 2002:a05:600c:20cb:b0:40b:5e59:f747 with SMTP id y11-20020a05600c20cb00b0040b5e59f747mr254913wmm.185.1701442281102; Fri, 01 Dec 2023 06:51:21 -0800 (PST) X-Received: by 2002:a05:600c:20cb:b0:40b:5e59:f747 with SMTP id y11-20020a05600c20cb00b0040b5e59f747mr254905wmm.185.1701442280788; Fri, 01 Dec 2023 06:51:20 -0800 (PST) Received: from redhat.com ([2a06:c701:73e1:6f00:c7ce:b553:4096:d504]) by smtp.gmail.com with ESMTPSA id fs20-20020a05600c3f9400b0040b5517ae31sm8521738wmb.6.2023.12.01.06.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 06:51:19 -0800 (PST) Date: Fri, 1 Dec 2023 09:51:17 -0500 From: "Michael S. Tsirkin" 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 Message-ID: <20231201095024-mutt-send-email-mst@kernel.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,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]); Fri, 01 Dec 2023 06:51:29 -0800 (PST) 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? > 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 > >