Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp876319rwi; Wed, 19 Oct 2022 04:12:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4iZiIOmt5WLyyY/pWwCJIhA3aubULowHB6RHI4RQtDbJvXeNbjfA/3v8s19j3Pl4/wjoKi X-Received: by 2002:a17:902:e952:b0:17c:2eee:c0ce with SMTP id b18-20020a170902e95200b0017c2eeec0cemr7803039pll.145.1666177910023; Wed, 19 Oct 2022 04:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666177910; cv=none; d=google.com; s=arc-20160816; b=orsJmSXnptXxfunkFuLocU5ChiMfJSNMHQWyoJeWlSRbdehVCG79qap1z2NWlxdLdQ ZajCPaiGSzi1mJLbOzohYrLIB6HXLvD6PMrSK/yV+jwJo0Y16TKksBLM+cAdHKsAzo0o o3T05mXXK9v78rnTufsdhWglMXRtol27Ccht4qyAa7dzUXA8pdUFDxxM+Ie0afeCBt0N M+78Ed81dcvSnm1mmTqaZ3T7koGY8CHr4Wa9yOqW7KhUgzz9+lfMjNsj7ggMb2rvwy8y 0/Yn5TRCigq5/me7MovgmuOLriS2d4e0hpZv2By5bkMvxQbYjlehFpJhI1yYpB2ssYKW NwRw== 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=UeXMP0V5EKhvdGZgYYTjnp6nrp2m6DpWou5AFJKNcsQ=; b=tNsDWvf/UXwGYypl04Mfn8UUbqv9W11oCrQRy+UgtApNkC/Hym3Xir4M8MDpPzrcBs WXPa9JN82KkaguZhFgjYBkcoRzrKsyQoL/iJK90k6Pjvcq8gXMUeHYJkdQPY4c3HHaDV fCiZ3vdXRB39cVm2ImdAurbhlLTmygOair++YRJMCjKKM6G9Scr6AMgKFEEC4hXuWmmK jzfcX5CFziD5WFXgAGqSMxD4VQeHLPScMKMp5wlJCqyfSHiPjL7favTNGDaVU1CxVceO 4XoSMse4FeQS0WjhImRZuOQ+Qck5FiWBfhVUayTfOtDrsb66gW9huPMaXTTkbnUidmxf Qdhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xhPxnjLk; 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 x70-20020a638649000000b00458085e9e70si17649753pgd.577.2022.10.19.04.11.34; Wed, 19 Oct 2022 04:11:50 -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=xhPxnjLk; 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 S234460AbiJSKzt (ORCPT + 99 others); Wed, 19 Oct 2022 06:55:49 -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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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 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 #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; @@ -642,9 +642,9 @@ static int sahara_aes_crypt(struct skcipher_request *req, unsigned long mode) rctx->mode = mode; - mutex_lock(&dev->queue_mutex); + spin_lock_bh(&dev->queue_spinlock); err = crypto_enqueue_request(&dev->queue, &req->base); - mutex_unlock(&dev->queue_mutex); + spin_unlock_bh(&dev->queue_spinlock); wake_up_process(dev->kthread); @@ -1043,10 +1043,10 @@ static int sahara_queue_manage(void *data) do { __set_current_state(TASK_INTERRUPTIBLE); - mutex_lock(&dev->queue_mutex); + spin_lock_bh(&dev->queue_spinlock); backlog = crypto_get_backlog(&dev->queue); async_req = crypto_dequeue_request(&dev->queue); - mutex_unlock(&dev->queue_mutex); + spin_unlock_bh(&dev->queue_spinlock); if (backlog) backlog->complete(backlog, -EINPROGRESS); @@ -1092,9 +1092,9 @@ static int sahara_sha_enqueue(struct ahash_request *req, int last) rctx->first = 1; } - mutex_lock(&dev->queue_mutex); + spin_lock_bh(&dev->queue_spinlock); ret = crypto_enqueue_request(&dev->queue, &req->base); - mutex_unlock(&dev->queue_mutex); + spin_unlock_bh(&dev->queue_spinlock); wake_up_process(dev->kthread); @@ -1449,7 +1449,7 @@ static int sahara_probe(struct platform_device *pdev) crypto_init_queue(&dev->queue, SAHARA_QUEUE_LENGTH); - mutex_init(&dev->queue_mutex); + spin_lock_init(&dev->queue_spinlock); dev_ptr = dev; -- 2.35.1