From patchwork Mon Oct 24 11:31:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10378 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp689478wru; Mon, 24 Oct 2022 15:53:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BfSF/qAFfP/aWCyXBnQIa7J/+YjtN63/Ab/0mZS4kvMh2mWJp2F1UJaplJ0SIWxdTpxn1 X-Received: by 2002:a17:90b:4c92:b0:213:13d2:381f with SMTP id my18-20020a17090b4c9200b0021313d2381fmr7639265pjb.219.1666652024642; Mon, 24 Oct 2022 15:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666652024; cv=none; d=google.com; s=arc-20160816; b=qHLxz/CqEO0kQ0NSObuE+EjoUOhF41zn8CmxPBvrXZFhYoo/OeyhrEKGgIu9WTWHzS jzPQZNOMPi96n39bCRHBJZsnsZxK+vI/kBWMrtwnnAUoYAf4H4b38Bi9Yoo8TZvqbv9M AchGqFT6vdu23V82yGl6T7eNwVwiGGDhAMIl0JHGPWBegeXs4clmupf4U16AWy8PI8FB JGyD9VnG1aamV9J/G6iBqhcUqd9FVHyRTlbJqYbZ85QCU2iH2axfkmTA3p4eMrWQALe8 /WmyrJWzP7brAxNOiq9RUWutL8nDaaRXTswhvL4Q5P4ux8bLsBpWn6fIEF4kSZfiqY88 II4g== 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=UEO+oNG77D8xiG4sXBbnP7UW19d3K3GcgGAIyJy7JOvUVh/+vulqvLSyFYi4/OBOjR 0opZyN4oKOZzoNKuRa8a69fpAIU3aD8xeo88u75WpW0hCncRYn7VpIKEdwr4tIEAdJYG +0lEwIjTGYLEinXBZnuhnyhXlIgClIsLMZS2p3rXlAe0meej9wz9Q2MbvbaHWD8Yj2zX yCTEx8xpFHeBPxFgHoMVu87o+mzuAIkO8/lJcngOEBfk/7GyANULa0W7yU4Gi2Z4mXQu vMrG5jDTel68HVN3oyPJwVOgTyIkc3eM4n506MUVQsozU/DMyDqo0LFDRc8jmvFzufsy bSWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1X264bYK; 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 z6-20020a170902d54600b0017f75ce8a2esi760511plf.575.2022.10.24.15.53.31; Mon, 24 Oct 2022 15:53:44 -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=1X264bYK; 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 S231671AbiJXWxI (ORCPT + 99 others); Mon, 24 Oct 2022 18:53:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231641AbiJXWwl (ORCPT ); Mon, 24 Oct 2022 18:52:41 -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 556D57C779; Mon, 24 Oct 2022 14:14:22 -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 662E560E7F; Mon, 24 Oct 2022 12:49:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53B02C433D6; Mon, 24 Oct 2022 12:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615758; bh=oi1CZUVpo8tc5lnU4a5h7UpgZgb2bjuEFwx20nMrjHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1X264bYKZl13qxeEOyVb/43PnGY42lLOlkHX3sQaOa7KwlqoxSLDUql6zIOBMQmfv ZlqhzQsf9ugZGQibmszxLLZds4whyc7D0r1yRePfrX2Vgk239LQy5vGj1wA6u5KBZD WEp5EgsHbxK+MkanbLS+7RvIb4gPn9+m1zywHKyE= 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.15 373/530] crypto: sahara - dont sleep when in softirq Date: Mon, 24 Oct 2022 13:31:57 +0200 Message-Id: <20221024113101.919603892@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747611313257861628?= X-GMAIL-MSGID: =?utf-8?q?1747611313257861628?= 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;