Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp533122iog; Thu, 30 Jun 2022 05:41:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u6NUeBg/xdxy2jx6qZKgpAqoImlXbfkty1j9tQKP4VdPhOQ/jge7DQHINn8R9bwnuBAWC3 X-Received: by 2002:a63:6d8b:0:b0:40d:a35:13ed with SMTP id i133-20020a636d8b000000b0040d0a3513edmr7724228pgc.615.1656592893248; Thu, 30 Jun 2022 05:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656592893; cv=none; d=google.com; s=arc-20160816; b=gEqlVNPD+eXZ7DgpfUZH/qgK0xxkkoALKc87dOVvoCAoNMqRH2sOadoaQa/2rW5HV+ SOxEnnT20No4UFpeXtLlz1h5gjva7UVeLRwctE6Ma/bmVZP0ziAPCkvu/CdB3qzzedP8 8juD8eH4/gSDHNKkqFF6oxCgbpmZozyxlVs3zLPe4EjOSysFBj1WPu7b+K5Xt9ffs8mF zgPE3EaPi04+LQWDyswI+/3/uGFp/klaPuSGjOnP1v2jBfFSSd4Llha874XDsI/mWp2W GO4tXKR7cwkWxGN3yZuB6VOwjDBVS/DgfVfW8UhPY2jF/xoORLwAv8FW1o636sNznZkd 1SCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=HaaXLJmNfxMFTm8DJfWZv35gON5BA8pDQKbXEXGCoBI=; b=cQ/CcosKgw0mh8KgXFRiTKNBAeTFl4456+ib1Tl9BbQyf8ZrePsrOxHb/l0tU3JIj8 kjale/nPBuDY5DSs4zSlP7ldulWL5aoaEIAnRBAgjx9XhyKhPWO7L4zy7Lx+qTWuj+CJ Pv6xHJY4T7HPoOhnpI8M6nhyjOhjzrQX0EEEl8hbDYKufR2SB8HM+3TaDIWC/SySObwb +qFiFhoBLUI4/e2SoZKXEMedlNaUWxm1bYPgeVHO5vMzdAseXUWDQblm9aWfpm21Ecel t+BqafQQKbzPmfJB4OkK3ONQRG5xckBED3AJ1aHXKIHNE7rjVW91FcVC5LhhEEBGIlX0 GZcQ== 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 n3-20020a170902f60300b0016758d47029si604447plg.518.2022.06.30.05.41.13; Thu, 30 Jun 2022 05:41:33 -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 S234975AbiF3Mhb (ORCPT + 99 others); Thu, 30 Jun 2022 08:37:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234603AbiF3Mh0 (ORCPT ); Thu, 30 Jun 2022 08:37:26 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E51F4396B1; Thu, 30 Jun 2022 05:37:24 -0700 (PDT) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LYd8835prz1L8kb; Thu, 30 Jun 2022 20:35:04 +0800 (CST) Received: from huawei.com (10.175.101.6) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 30 Jun 2022 20:37:21 +0800 From: Zhengchao Shao To: , , , CC: , , Subject: [PATCH v2] crypto: hisilicon - Kunpeng916 crypto driver don't sleep when in softirq Date: Thu, 30 Jun 2022 20:42:30 +0800 Message-ID: <20220630124230.56265-1-shaozhengchao@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500026.china.huawei.com (7.185.36.106) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 kunpeng916 encryption driver is used to deencrypt and decrypt packets during the softirq, it is not allowed to use mutex lock. v1: use spin_lock will cause soft lockup Signed-off-by: Zhengchao Shao --- drivers/crypto/hisilicon/sec/sec_algs.c | 14 +++++++------- drivers/crypto/hisilicon/sec/sec_drv.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/hisilicon/sec/sec_algs.c b/drivers/crypto/hisilicon/sec/sec_algs.c index 0a3c8f019b02..490e1542305e 100644 --- a/drivers/crypto/hisilicon/sec/sec_algs.c +++ b/drivers/crypto/hisilicon/sec/sec_algs.c @@ -449,7 +449,7 @@ static void sec_skcipher_alg_callback(struct sec_bd_info *sec_resp, */ } - mutex_lock(&ctx->queue->queuelock); + spin_lock_bh(&ctx->queue->queuelock); /* Put the IV in place for chained cases */ switch (ctx->cipher_alg) { case SEC_C_AES_CBC_128: @@ -509,7 +509,7 @@ static void sec_skcipher_alg_callback(struct sec_bd_info *sec_resp, list_del(&backlog_req->backlog_head); } } - mutex_unlock(&ctx->queue->queuelock); + spin_unlock_bh(&ctx->queue->queuelock); mutex_lock(&sec_req->lock); list_del(&sec_req_el->head); @@ -798,7 +798,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq, */ /* Grab a big lock for a long time to avoid concurrency issues */ - mutex_lock(&queue->queuelock); + spin_lock_bh(&queue->queuelock); /* * Can go on to queue if we have space in either: @@ -814,15 +814,15 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq, ret = -EBUSY; if ((skreq->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) { list_add_tail(&sec_req->backlog_head, &ctx->backlog); - mutex_unlock(&queue->queuelock); + spin_unlock_bh(&queue->queuelock); goto out; } - mutex_unlock(&queue->queuelock); + spin_unlock_bh(&queue->queuelock); goto err_free_elements; } ret = sec_send_request(sec_req, queue); - mutex_unlock(&queue->queuelock); + spin_unlock_bh(&queue->queuelock); if (ret) goto err_free_elements; @@ -881,7 +881,7 @@ static int sec_alg_skcipher_init(struct crypto_skcipher *tfm) if (IS_ERR(ctx->queue)) return PTR_ERR(ctx->queue); - mutex_init(&ctx->queue->queuelock); + spin_lock_init(&ctx->queue->queuelock); ctx->queue->havesoftqueue = false; return 0; diff --git a/drivers/crypto/hisilicon/sec/sec_drv.h b/drivers/crypto/hisilicon/sec/sec_drv.h index 179a8250d691..e2a50bf2234b 100644 --- a/drivers/crypto/hisilicon/sec/sec_drv.h +++ b/drivers/crypto/hisilicon/sec/sec_drv.h @@ -347,7 +347,7 @@ struct sec_queue { DECLARE_BITMAP(unprocessed, SEC_QUEUE_LEN); DECLARE_KFIFO_PTR(softqueue, typeof(struct sec_request_el *)); bool havesoftqueue; - struct mutex queuelock; + spinlock_t queuelock; void *shadow[SEC_QUEUE_LEN]; }; -- 2.17.1