Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4683385ybl; Wed, 22 Jan 2020 02:47:18 -0800 (PST) X-Google-Smtp-Source: APXvYqzh/bm2kTj5V1XOPBkp2bVVhnq9YL1CANrqVhUSbiUuBTXBPL31Ud4GDDuA04mnDD9tcg/n X-Received: by 2002:a05:6830:1188:: with SMTP id u8mr6916886otq.274.1579690038595; Wed, 22 Jan 2020 02:47:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579690038; cv=none; d=google.com; s=arc-20160816; b=wbHz75AtqwBsuLwrtbt6xB/65wuZpdWuRV4IF456iT15ci6OrKw7VZEldfv0rv+AX1 py0MsjbtutA3GUV5UCJpf0Bg6KEvyL1deqfU3Ek28S5sH6vW0YT4Od90qbNLZIvobZjz tngvJ2+mJD6nFrhWn40tFrWzIjTGTH6FpFGgE+kVEJt7erLh1l37XYjm+WIXRJAE4+/5 tF8W77kMJSX5zzpSpxYDu9hvAVQuDG+cigWOfklpHvGq1+ef/BxfnjIWbrSHxCFyaVG7 zeqs0kQjd8tAkyCKVRryym0O1zyyuyGnN6RlVjAM9xSamfw2BP6XiGoTha24eg12tAEv RLkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lo8LLHFbuM7TeGYDeTlQoBN8WOd2hUEZekUpabEc1mM=; b=EGFcLDiLiKOaeJrMa3r9KKqbV6+7gdINHr6gdA3j7bG8gDfPZDLIXB4BjcvmU5+Ja6 QdShqGWqV44zjNPRuL9o5hT58QLZI1Cb2yZxTdNZyo1a5ljG83JdonYge3qv0DWZoTDk F1gbEWGsbM+yy2gmHo8Hhu1g230rS80FMnor+KbPgw++Ed75PXVSSfyOqpoFzuTKJ4q3 xL8yJ5pigYuQsmn/ad065SqNKfCEXdgp2N5sKcJKCOKsfmLsrVztq44ewakStfJanR+A 7AWCuAZh+db2yCuZdUYtiRZWdXHUFBsndw3erRunI46k3u/yYQNo49dhzQz1kwLb4Uuo y/Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gY97jhBx; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3si22964568otr.57.2020.01.22.02.47.07; Wed, 22 Jan 2020 02:47:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gY97jhBx; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729592AbgAVKpm (ORCPT + 99 others); Wed, 22 Jan 2020 05:45:42 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36348 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729578AbgAVKpm (ORCPT ); Wed, 22 Jan 2020 05:45:42 -0500 Received: by mail-wr1-f67.google.com with SMTP id z3so6746551wru.3; Wed, 22 Jan 2020 02:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lo8LLHFbuM7TeGYDeTlQoBN8WOd2hUEZekUpabEc1mM=; b=gY97jhBxzfGaSoSJe/9DJBRMWHpcwm2pHDbhJbZ5+5w49H5BCpCkqHYZwE1vo8tDnt bpNKVku2NGfETc/ThU4Sf5qw6sbYIP7ndKZm7JEw3KE3mY14jO1zcipE/+V6fIkB+Zc3 t0z4/Th/wP+oUvshpss+455rUZGXGelGdf/W++RDJoqlmIwGmLjYRgE3V48yyng4q5z8 NwZYiLZ/LFp91vIAWzQvCLPji0AZjRVfXKWoUdQgOsCy41402wg0mwK3AHWpNyWfzgt3 8xPncSZ5Zzc337KUWJC/dwoeVjEWa548Zs872YwKEh9NIB7yjGbA83TfhohB5xzkK7M4 F6Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lo8LLHFbuM7TeGYDeTlQoBN8WOd2hUEZekUpabEc1mM=; b=MRJpBvHrJh43J6X0H0yDoy1nTblSqvi7o4fQrPbfPkN5w0HCFCLCpg7nc+ggsEfD6Q RUrWV6qeOZPCNKfZeXbcQyPVhaSw6m7BxcLHbosZ0STaMw0dHSd8A0vdMTBUkU+tJAKL Y4qnXicRUStavgivWHiQktF0YWOtOTYKyn1LzczCSbFmS16t+CMGCADUcSEN/CQPGgjn C2ckzfBfUrbnvxAeqilkhSlEdRYjOgfr3OPkKDocP9LRhfXhdktZI/m2+Y9qFyatZQBS hIpkVy5+1BOFQdPCnc6kh0JnHbBR0asZuQPO+Gv4TMCacxVT9U7WGhwZpu0lqw4eUdZQ EbJA== X-Gm-Message-State: APjAAAWKMKwYo9IIUBFot2x39Iug5RxM5JNDVZYiN/C31s/tt/qwdO88 /Kzf6U00elF0IdELiD9U5qQ= X-Received: by 2002:a5d:49c7:: with SMTP id t7mr10174792wrs.369.1579689940777; Wed, 22 Jan 2020 02:45:40 -0800 (PST) Received: from Red.localdomain ([2a01:cb1d:3d5:a100:2e56:dcff:fed2:c6d6]) by smtp.googlemail.com with ESMTPSA id n3sm3443953wmc.27.2020.01.22.02.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 02:45:40 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, herbert@gondor.apana.org.au, mripard@kernel.org, wens@csie.org, iuliana.prodan@nxp.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH 1/9] crypto: engine: workqueue can only be processed one by one Date: Wed, 22 Jan 2020 11:45:20 +0100 Message-Id: <20200122104528.30084-2-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200122104528.30084-1-clabbe.montjoie@gmail.com> References: <20200122104528.30084-1-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Some bykeshedding are unnecessary since a workqueue can only be executed one by one. This behaviour is documented in: - kernel/kthread.c: comment of kthread_worker_fn() - Documentation/core-api/workqueue.rst: the functions associated with the work items one after the other Signed-off-by: Corentin Labbe --- crypto/crypto_engine.c | 13 ------------- include/crypto/engine.h | 2 -- 2 files changed, 15 deletions(-) diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c index eb029ff1e05a..feb0d82dd454 100644 --- a/crypto/crypto_engine.c +++ b/crypto/crypto_engine.c @@ -73,16 +73,6 @@ static void crypto_pump_requests(struct crypto_engine *engine, spin_lock_irqsave(&engine->queue_lock, flags); - /* Make sure we are not already running a request */ - if (engine->cur_req) - goto out; - - /* If another context is idling then defer */ - if (engine->idling) { - kthread_queue_work(engine->kworker, &engine->pump_requests); - goto out; - } - /* Check if the engine queue is idle */ if (!crypto_queue_len(&engine->queue) || !engine->running) { if (!engine->busy) @@ -96,7 +86,6 @@ static void crypto_pump_requests(struct crypto_engine *engine, } engine->busy = false; - engine->idling = true; spin_unlock_irqrestore(&engine->queue_lock, flags); if (engine->unprepare_crypt_hardware && @@ -104,7 +93,6 @@ static void crypto_pump_requests(struct crypto_engine *engine, dev_err(engine->dev, "failed to unprepare crypt hardware\n"); spin_lock_irqsave(&engine->queue_lock, flags); - engine->idling = false; goto out; } @@ -410,7 +398,6 @@ struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt) engine->rt = rt; engine->running = false; engine->busy = false; - engine->idling = false; engine->cur_req_prepared = false; engine->priv_data = dev; snprintf(engine->name, sizeof(engine->name), diff --git a/include/crypto/engine.h b/include/crypto/engine.h index e29cd67f93c7..7e7cbd9ca3b5 100644 --- a/include/crypto/engine.h +++ b/include/crypto/engine.h @@ -21,7 +21,6 @@ /* * struct crypto_engine - crypto hardware engine * @name: the engine name - * @idling: the engine is entering idle state * @busy: request pump is busy * @running: the engine is on working * @cur_req_prepared: current request is prepared @@ -42,7 +41,6 @@ */ struct crypto_engine { char name[ENGINE_NAME_LEN]; - bool idling; bool busy; bool running; bool cur_req_prepared; -- 2.24.1