From patchwork Wed Oct 19 08:31:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5147 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp253285wrs; Wed, 19 Oct 2022 03:56:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5JNJXc46WTjvYtj17k1NRX+SRgqF9DDcsXCEzPaYLDH76Af/jGEEUcBSsF5xev55Q+i9p7 X-Received: by 2002:a05:6402:164c:b0:459:1e2e:e742 with SMTP id s12-20020a056402164c00b004591e2ee742mr6710737edx.125.1666177017129; Wed, 19 Oct 2022 03:56:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666177017; cv=none; d=google.com; s=arc-20160816; b=THyDiiRekULq0+BkBrTNehnbvAg1XJ57CJ8dKm+y+vs8b7I660ZkOLivm2DNgiaYU3 Wtlix0PhMOYuB16AhhSN3UQoW9H0Xxmd/sqLSiGEiO0l9qa4JzOAKGfrfT8xWhlKVH8D KaXxC0P4lp0YiO+kuhvSXda/lkIsrBIROEG3f4h0aWJtoqbk+EloQXpT9NQIUvRXU6bt G0MGjTTDGJ6GTKecdVzemcW8aLlTaD2pLFq4xv6dMohjgtbbSb2m9D8KO6Lt5JyUxLM+ YXZzb3bNfKvIDndBaFNq+MnKnPN4WOz5NZDf6cwB3ql13h2TR7lb8rdOxnDRtVtkKfgO sBeA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne22-20020a1709077b9600b007701a050273si15770236ejc.942.2022.10.19.03.56.30; Wed, 19 Oct 2022 03:56:57 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747113232037246621?= X-GMAIL-MSGID: =?utf-8?q?1747113232037246621?= 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;