Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3402012rwa; Tue, 23 Aug 2022 04:17:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR7PMUMGMb9+BW8lmT2us+FjBPrlWwXXpS/qtWLPCIYsSdeBL8ORnPYsBieicoyGuvQlK8M8 X-Received: by 2002:a17:90b:1189:b0:1f5:1311:cd89 with SMTP id gk9-20020a17090b118900b001f51311cd89mr2801733pjb.181.1661253476585; Tue, 23 Aug 2022 04:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253476; cv=none; d=google.com; s=arc-20160816; b=RzPJjTnmi1bP/SLVUlrwYFmwMelIP6QXyuLTj7mx3lFgnKHc9czOmwQo/+UIsLsOcD 85gQ0hlpDpf0IH0s9W6AkUP8RWJWwevoOgaNGRU2ySBqxS/nr5n/MJfi7rkHvlPAhqr0 l3xQHNtD8P2wdSE9+hR6LotvalBCv0rRRNsllqjBemqHLi1FYgJV7WHWXxtgsUz5daxv h62OsuIZskwyVkQTRtCIZGn9ncAoPcBoNzjYWDveVlIPim2yrPDcN0MfyzcNU3eMLuHf hgUgNWz6Ihbe7/4fOi4M6fIWgEv273uCvyvqroXYIrq+VtAaFKZ8V9ByFwCHsoggl3dO 1xxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hM85LJlIE3BQmlpBaCUd7bOsLrMtKtxbK31JVQbhWRE=; b=0GogtdHj3SW2PzzXs1Eln8w/kJpG2LEKI0UlokxCWYMoy+dU1oDUTh3W5O4S4hXWqq CIFNkLPrx5B0J3bDuOGO//BGJP0HFMiVDRoZFsOv1T2J/iCNB0ASHDC1HDwllXuSxLQD ZnjB7nVAm7Nh86KgNiOus5kJzfAV2J6iKGg5GumrAtrOXU4Ob4faUagtf0Cox2L64Vmg z0lRSBRlfc1KKTQX1vNMEEiUfKqCVrjc6TJEWcMv0ohL/LadafmeovbTd6iw4vRo3wMS BxoXv5PAHEHAuIEZYGnU1OVNKiwYQWE8Ef+7lqEqKyeCbip4RnE8X6MNkfG/8HxOiKzX K7yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Fti1pRgA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a2-20020a63cd42000000b004292e659b6fsi15714695pgj.123.2022.08.23.04.17.45; Tue, 23 Aug 2022 04:17:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Fti1pRgA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355323AbiHWKiS (ORCPT + 99 others); Tue, 23 Aug 2022 06:38:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355160AbiHWKXD (ORCPT ); Tue, 23 Aug 2022 06:23:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FF0189929; Tue, 23 Aug 2022 02:04:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B1243B81C65; Tue, 23 Aug 2022 09:04:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D96FC433D7; Tue, 23 Aug 2022 09:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245451; bh=rK2GHts97T+cgSqgvSvFBdvim0m1FZpcglrP9sZr150=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fti1pRgAjfIqHxiDqBiXin4rW78+Z9bZcmCFYTV3iX3GpyHmZofcLOtH29yRnpH2j Xz6g5qXGOZE/ZRQP2zlDo82jzbp2u3QaxdX51inPu1cude/PlwsTMh40dCFO9NQ/2j M1GE7yFwGWaS1GgUuiMkXdFoD2MUszMyVO1HEQwc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhengchao Shao , Herbert Xu , Sasha Levin Subject: [PATCH 4.19 083/287] crypto: hisilicon - Kunpeng916 crypto driver dont sleep when in softirq Date: Tue, 23 Aug 2022 10:24:12 +0200 Message-Id: <20220823080103.080573227@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Zhengchao Shao [ Upstream commit 68740ab505431f268dc1ee26a54b871e75f0ddaa ] When kunpeng916 encryption driver is used to deencrypt and decrypt packets during the softirq, it is not allowed to use mutex lock. Fixes: 915e4e8413da ("crypto: hisilicon - SEC security accelerator driver") Signed-off-by: Zhengchao Shao Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- 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 3e3cc28d5cfe..f672dc1ecfac 100644 --- a/drivers/crypto/hisilicon/sec/sec_algs.c +++ b/drivers/crypto/hisilicon/sec/sec_algs.c @@ -457,7 +457,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: @@ -517,7 +517,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); @@ -806,7 +806,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: @@ -822,15 +822,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; @@ -889,7 +889,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 2d2f186674ba..ddc5d6bd7574 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.35.1