From nobody Fri Dec 19 18:41:46 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 501DFECAAA1 for ; Mon, 24 Oct 2022 13:23:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235578AbiJXNXG (ORCPT ); Mon, 24 Oct 2022 09:23:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232767AbiJXNWJ (ORCPT ); Mon, 24 Oct 2022 09:22:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 376E41A5; Mon, 24 Oct 2022 05:29:41 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 53E65612A1; Mon, 24 Oct 2022 12:27:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6851FC433D6; Mon, 24 Oct 2022 12:27:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614465; bh=wq/nKH4U/hcOoZ8jQjN/KSVSJfCus0aPmsR5bOW/2xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nQ+3/juHrRKDOH9xaZ38qjRkE0aDBVQdN3bHKf7C+ZiRI2gpQ6OqKA00qaYdX7XZg TbjexPOOfSDVhASnZabtgMzCrNPNNy38/Gb357xcOqjLl2SWVAZHfVMDCaqjtrAlBG ULNn4C1bkkId7pW7AgEr1eOj3YSQq1NakU/EggUs= 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 5.10 271/390] crypto: sahara - dont sleep when in softirq Date: Mon, 24 Oct 2022 13:31:08 +0200 Message-Id: <20221024113034.469304263@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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 d60679c79822..2043dd061121 100644 --- a/drivers/crypto/sahara.c +++ b/drivers/crypto/sahara.c @@ -25,10 +25,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 @@ -195,7 +195,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 @@ -641,9 +641,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 @@ -1042,10 +1042,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); @@ -1091,9 +1091,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 @@ -1454,7 +1454,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