From patchwork Sat Oct 22 07:26:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1105895wrr; Sat, 22 Oct 2022 01:36:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68PpOeZdN8rxr4e3Y1ncGdfbe1uLfJ20y3+vgRlVkm2xpJl/F9wr8sH+maJb41ox4cRle5 X-Received: by 2002:a17:902:cf08:b0:17d:46b6:25f9 with SMTP id i8-20020a170902cf0800b0017d46b625f9mr23332133plg.67.1666427777444; Sat, 22 Oct 2022 01:36:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427777; cv=none; d=google.com; s=arc-20160816; b=VJSPwyqHmzyAsMVHytl1DHZXCPbQTZEw6HCT/YKZvateGdj73aiGR2nvB+DcSKk5c2 zhWmiQOecvZGYkrtbVK1bvp+A8gWy3n+jC7p2GlGrrJ5Vua/2Nq37WH5D7RKdYN2H/Zq 4yfn8yUX/NKCLkwkzq1l4gZlJ89Y7uB2/6Chx4Yv1DSHClPbrqT/8Ar0GL2oOP4jBo9k RobSM2z6Qj+MHuf1c8j53YsLqshBXp95X2egZQW30K8GzOiL8Iy86g0mgR46ALKg42LV sNqve6YdchweQDViQPwRAoEC6CBYNsn2+Zcao7xPVrIgtnBqm7Emy865z5T3PMmzGCzF 2oVg== 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=miu9Rs5hmUNaISztg0/mscEYx7lPM/kFrv+o2dUZJT4gl5P4IKcC2tsKCW+be1e44y ve11TYYkgOGxT7xMNj1hXBhSdoOfQ55VOow3ycXmWbruE2riOYsxws6eFW2QU0aOoquo mDYYP3WEtTIymUYa2PPMOgxLBq2S2fHE3CvCAJXx4m3PVAdUlzoaufiZ9IidybZtBxWn O8BfrYysEB3ZfOVg+cQXtm+wAHHrPFUhkefUvnOmMP64AB3Wa5yq2VtGHWSGJ2OisgDn AQdGs5bxBZLcH8lMKhrpjz+PGPd/XHye1QFUCwmasyr9o50cfMHbpk9f6luX6HOFGXtR kNXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jngscZb+; 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 pi5-20020a17090b1e4500b00212ca8e7457si6151053pjb.133.2022.10.22.01.36.01; Sat, 22 Oct 2022 01:36:17 -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=jngscZb+; 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 S230064AbiJVIZm (ORCPT + 99 others); Sat, 22 Oct 2022 04:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233801AbiJVIXW (ORCPT ); Sat, 22 Oct 2022 04:23:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C053D14D1FC; Sat, 22 Oct 2022 00:59:06 -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 4527060B98; Sat, 22 Oct 2022 07:57:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27C96C433D6; Sat, 22 Oct 2022 07:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425453; bh=oi1CZUVpo8tc5lnU4a5h7UpgZgb2bjuEFwx20nMrjHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jngscZb+xOMQNYZ0vtw2v5WsEn30LuT6De/DVsTLrmX9j6pXWDmrMbVCWQ1TwgMXL kAHoN3vRe6OGcKyq7rGhglqVqCpMJ2yL5ZLg1KPgcNCwkMs1SNh4744IHj/UKLfb2n ftjjfUZfW9j4XBLthLyj2c6OxA4eHpB5jKQ89C5c= 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.19 507/717] crypto: sahara - dont sleep when in softirq Date: Sat, 22 Oct 2022 09:26:26 +0200 Message-Id: <20221022072520.688358442@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747376172737342771?= X-GMAIL-MSGID: =?utf-8?q?1747376172737342771?= 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;