From patchwork Mon Oct 24 11:31:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9149 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp457514wru; Mon, 24 Oct 2022 06:36:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pODrV08EsVsO+NNMFldfNsT7GAtLBBQMj3bKbU59OslHMbBOGPJRUvj3y9AGtT42/gjuL X-Received: by 2002:a17:907:805:b0:782:1a0d:337f with SMTP id wv5-20020a170907080500b007821a0d337fmr27992196ejb.475.1666618568025; Mon, 24 Oct 2022 06:36:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618568; cv=none; d=google.com; s=arc-20160816; b=TVaP2syJJZ848lSXn38QE43ZeV66cBJJEDLQfDlXmuwiakCa/wNj/X2DOvQx9L1nsI +uem2gbxCy3waWZ+cLOZFfb+Iq22XPVReTPlkPk1M2Lhni7ZkAKZyGJ692NdqRQhL74J bo09eZm4qKOIhUGgg9lInJ6H5V3RS4OpytE2MrcpJPLk/aflHeqxVLIc5su43v19y5rt d83KShNKS7oBtxzTPa9C3HeEZlqTKXhrz4do1NheJUi9ZpFsEKAs+0C5g6BsFajG9Dir vHixomCcNPiH8YrSId4QQ5AlL7YkHP+1X1FWzJC/aZKr0q1owCY8lu5GaJBKxNdsi8gP lAIA== 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=Mo4IJ3sTZ/kYBywsE9tl0ck0M/dF0C0XoOuDb0D28YI=; b=qNY8uYIa2de0kMPylQZ9eDH8a0WwVYL8yV8IVgNyI6YyKydLRY0uYDf3JGUZGoWJJz w0rP/iMEGil5Af0FdF6pOBYdewCq2AkT8iZopsY2xGjNW/06tQO+OdSbvqIhhHWsQ5kI R2VHW8SqMDdZPYHag8Y6LlBlaqbeGdzzFCBfp3uwJi/3tWAPpOJBadBEernA8yaTqz8o ldds7Sqya/sDkmSAA2+Wi7/HDpv8uIz6uodI6dnb4pI6GVvFwqRfSgrGeXR02tYWgafe HzzVQQamOOKxp4XEKdy98QRQWelBK+R0mPD4/szRtSDeqT2JF2zolvGD/5eCC3puHHmz eAcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nQ+3/juH"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d6-20020a170906c20600b0078d27c1c8f4si22402284ejz.696.2022.10.24.06.35.27; Mon, 24 Oct 2022 06:36:08 -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="nQ+3/juH"; 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 S234591AbiJXNXC (ORCPT + 99 others); Mon, 24 Oct 2022 09:23:02 -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 X-Spam-Status: No, score=-7.6 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747576231358379819?= X-GMAIL-MSGID: =?utf-8?q?1747576231358379819?= 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 #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; @@ -641,9 +641,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); @@ -1042,10 +1042,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); @@ -1091,9 +1091,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); @@ -1454,7 +1454,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;