From nobody Fri Oct 17 12:01:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4391EC4332F for ; Wed, 19 Oct 2022 10:55:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234464AbiJSKzw (ORCPT ); Wed, 19 Oct 2022 06:55:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235038AbiJSKy6 (ORCPT ); Wed, 19 Oct 2022 06:54:58 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58D7B8E9B5; Wed, 19 Oct 2022 03:26:30 -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 sin.source.kernel.org (Postfix) with ESMTPS id 44D6ECE217E; Wed, 19 Oct 2022 09:05:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E8F8C433D6; Wed, 19 Oct 2022 09:05:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170356; bh=oi1CZUVpo8tc5lnU4a5h7UpgZgb2bjuEFwx20nMrjHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xhPxnjLkc7erG8eJFfz04vGAE821sOJ3FrWwV95jaVxXuDQWJQD3t0gHJR6RJs92g eTCdm2h4tXbCOO6p9EHIq22IRn2ZKo45QQghhJUGM780Npng2upeFUuJNhPF9JwOIO NxlFlUHTSuJCbq3ivPFR2n9CokYUjog0Yp7ktCJM= 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 6.0 624/862] crypto: sahara - dont sleep when in softirq Date: Wed, 19 Oct 2022 10:31:51 +0200 Message-Id: <20221019083317.505592707@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Zhengchao Shao [ Upstream commit 108586eba094b318e6a831f977f4ddcc403a15da ] Function of sahara_aes_crypt maybe could be called by function of crypto_skcipher_encrypt during the rx softirq, so it is not allowed to use mutex lock. Fixes: c0c3c89ae347 ("crypto: sahara - replace tasklets with...") Signed-off-by: Zhengchao Shao Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/sahara.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c index 457084b344c1..b07ae4ba165e 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c @@ -26,10 +26,10 @@ #include #include #include -#include #include #include #include +#include =20 #define SHA_BUFFER_LEN PAGE_SIZE #define SAHARA_MAX_SHA_BLOCK_SIZE SHA256_BLOCK_SIZE @@ -196,7 +196,7 @@ struct sahara_dev { void __iomem *regs_base; struct clk *clk_ipg; struct clk *clk_ahb; - struct mutex queue_mutex; + spinlock_t queue_spinlock; struct task_struct *kthread; struct completion dma_completion; =20 @@ -642,9 +642,9 @@ static int sahara_aes_crypt(struct skcipher_request *re= q, unsigned long mode) =20 rctx->mode =3D mode; =20 - mutex_lock(&dev->queue_mutex); + spin_lock_bh(&dev->queue_spinlock); err =3D crypto_enqueue_request(&dev->queue, &req->base); - mutex_unlock(&dev->queue_mutex); + spin_unlock_bh(&dev->queue_spinlock); =20 wake_up_process(dev->kthread); =20 @@ -1043,10 +1043,10 @@ static int sahara_queue_manage(void *data) do { __set_current_state(TASK_INTERRUPTIBLE); =20 - mutex_lock(&dev->queue_mutex); + spin_lock_bh(&dev->queue_spinlock); backlog =3D crypto_get_backlog(&dev->queue); async_req =3D crypto_dequeue_request(&dev->queue); - mutex_unlock(&dev->queue_mutex); + spin_unlock_bh(&dev->queue_spinlock); =20 if (backlog) backlog->complete(backlog, -EINPROGRESS); @@ -1092,9 +1092,9 @@ static int sahara_sha_enqueue(struct ahash_request *r= eq, int last) rctx->first =3D 1; } =20 - mutex_lock(&dev->queue_mutex); + spin_lock_bh(&dev->queue_spinlock); ret =3D crypto_enqueue_request(&dev->queue, &req->base); - mutex_unlock(&dev->queue_mutex); + spin_unlock_bh(&dev->queue_spinlock); =20 wake_up_process(dev->kthread); =20 @@ -1449,7 +1449,7 @@ static int sahara_probe(struct platform_device *pdev) =20 crypto_init_queue(&dev->queue, SAHARA_QUEUE_LENGTH); =20 - mutex_init(&dev->queue_mutex); + spin_lock_init(&dev->queue_spinlock); =20 dev_ptr =3D dev; =20 --=20 2.35.1