From patchwork Wed Jan 3 09:50:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13509816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4914BC3DA6E for ; Wed, 3 Jan 2024 09:50:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C91ED8D005D; Wed, 3 Jan 2024 04:50:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C3F298D0053; Wed, 3 Jan 2024 04:50:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB8148D005D; Wed, 3 Jan 2024 04:50:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 92DDC8D0053 for ; Wed, 3 Jan 2024 04:50:36 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6AB85402EF for ; Wed, 3 Jan 2024 09:50:36 +0000 (UTC) X-FDA: 81637530072.23.28062EB Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) by imf28.hostedemail.com (Postfix) with ESMTP id A6A35C000C for ; Wed, 3 Jan 2024 09:50:34 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="aj1St0G/"; spf=pass (imf28.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.219.174 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704275434; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HwysZAJ6ghv3K37MmkiHDv50fMbQAcaQTVa/Nper+78=; b=VCYKURuDL+UhHL+/StWU4ULBIUTWrNfjXf436EaVr2QXoQUVCypBEPkCxMz9PCCdkvj2Io o0w5mRIbA+Lx5OZBg8mG5/DbOLO2zNH1BhxrrSrNeFMnm6V/pmZ5wAkrBqOUpFKO/iwzwS EqOg2aZfC4m/0swAdpj0ozUq93IiV5U= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="aj1St0G/"; spf=pass (imf28.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.219.174 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704275434; a=rsa-sha256; cv=none; b=kvrODMcy80xjBUWCjU5ppbcFcuL6oeeP+iTjmprEwyf5wsIzlDQ2+C35j30DYbZ6BJD3DJ iRGV0gi1XB/35s3JhnmQlVfCzXmrLFsE3YVpCtwhFxgIzozE5YIiDWmdvGLi0UXSa0Lfqh b1qU22R9GKKrCnmAkxDRbl8B63rcEv0= Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-dbdc52f2359so6298844276.3 for ; Wed, 03 Jan 2024 01:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704275434; x=1704880234; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HwysZAJ6ghv3K37MmkiHDv50fMbQAcaQTVa/Nper+78=; b=aj1St0G/AOOoWvejimT4eGzvAtG/XwQ97ODDZ2fROYJalSN9ZJdX6UodEQr3yZzrFh I27yRArnqWsrJaHAQl5CMQ1VFvdYL3EnkR8koKmjJ/7jRSBnHosjRaq+jTuDlX3QY3Mr 8q9UlQois/0zDvKw1IOIHdm5wUVEVVXWDzYZqDlemoTJ1qi/TP8X4N4cUI8JS1FuCLBg e6ukdGHrw8E9bo+jJ4U/Oc6K5PrjXyV2jEV/e++CP3z/M0GbnnakyuGlEGLb7P9uo88q Wy5QE7P1tW7V8iPoyU/va2LJYV5Feru6DEVBT9d81K16dplLclXt+YCPSWFGvEWXLSr/ 8Gwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704275434; x=1704880234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HwysZAJ6ghv3K37MmkiHDv50fMbQAcaQTVa/Nper+78=; b=RPzRuQ95ICqXDk7+YfLWapcHuMqVO5UILHlWwvRfl0aE8QAiqDwmuDlmZurW4xvI66 i9dvwZajmVFbE0z/KqMKbKOCVykE0otwV2I3j2xHEjuO7Lo7lwXxXL4YCvUoxRJuWmK1 nqf7truo92YzolxMOPt/vpab/Es/xyT5SKCx9l8bWbLIzo1/zE5toc4pgt7uY30RvMrg JdKPNdykKSZgbqmI7HGoa/oTvEEoZlFnx3T7n3GZ06R6Lxw3MVYVb/KfIGkuhbYuN8B/ bfw3tiOmmZQqr4y2wGnwPhqj66nWxGnChs77xjpxjoWCN5jV6rT/0npKzZAVhrnJ1vJp U/Og== X-Gm-Message-State: AOJu0YwFLs3P7tg0sScoT2E1pH3gCPDfdk1lNjFmkk2kBbaqiB0bCT8j pydde9C8OeHZKhhACKSfqPo= X-Google-Smtp-Source: AGHT+IH42YZIV6OEBL93QwLYO40q0ASQ2KNUbZP1KhhoeQJlaCT6y4cGhqSERL4Av/vp/qrwoEL/nA== X-Received: by 2002:a25:b8b:0:b0:db5:4ece:ad01 with SMTP id 133-20020a250b8b000000b00db54ecead01mr8579026ybl.25.1704275433672; Wed, 03 Jan 2024 01:50:33 -0800 (PST) Received: from barry-desktop.hub ([2407:7000:8942:5500:a7d6:f37a:9130:cd96]) by smtp.gmail.com with ESMTPSA id a34-20020a631a22000000b005c65e82a0cbsm21823483pga.17.2024.01.03.01.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 01:50:33 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: herbert@gondor.apana.org.au, davem@davemloft.net, akpm@linux-foundation.org, ddstreet@ieee.org, sjenning@redhat.com, vitaly.wool@konsulko.com, linux-crypto@vger.kernel.org Cc: chriscli@google.com, chrisl@kernel.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, nphamcs@gmail.com, yosryahmed@google.com, zhouchengming@bytedance.com, Barry Song Subject: [PATCH 1/3] crypto: introduce acomp_is_async to expose if a acomp has a scomp backend Date: Wed, 3 Jan 2024 22:50:04 +1300 Message-Id: <20240103095006.608744-2-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240103095006.608744-1-21cnbao@gmail.com> References: <20240103095006.608744-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: A6A35C000C X-Rspam-User: X-Stat-Signature: bayr7mu7riic1tqkyuqfme61ig1dkbuw X-Rspamd-Server: rspam01 X-HE-Tag: 1704275434-953079 X-HE-Meta: U2FsdGVkX18Mo9GF021+KawjF6an9p1CrRYB6bGwOE4fQch2X69ijQs4bW8Sv08IKQ3DfzIOzi4KxKtmNnC69LITg8dQW6ZQBpquT8k/o9a2j8VigER43bmt6kXLGzfkZv2cfi0qwIbI6+ugFysgHFD1zF1NI6orZI0CedA8hPGe2RqCHqn2QPpJOBO3ftgCaE+/+k2HnXy1wm0takacWESWFs7mzyBhDEi1JjcJZfp6Fwx8q3cceCfHm9L8YsxOLpQzmY4BE/u+PkD5In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mfBWaGyPjPwV49i4m37wSWjMxPOwmKZbU5FbLMfi6e4n9vLtBbmFUSAJ25H6A31a3OXFMIa90gCQpMQbRYPaAbbZyTiMFB+H/UiZZOCfP17Djv7uD3xENsxazzkPKu8nx1JgEi7N5EwdmDWuXpztjaoZe5cvg4Giyxgf3TCOvh+MM43QkrGkNYckch/csx+mG8AXQ+heKX88eTcfwm3ZEDqP63nUGwk4VnQKk9OsdLc3clW4Q+Z65jplzOYLzfZNv6/LfSnh/EXTHc6Vwb9V/X9UnDPs2Rg1Q7V+rnHuZmm9Rac6m/yIFQi X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Barry Song Almost all CPU-based compressors/decompressors are actually synchronous though they support acomp APIs. While some hardware has hardware-based accelerators to offload CPU's work such as hisilicon and intel/qat/, their drivers are working in async mode. Letting acomp's users know exactly if the acomp is really async will help users know if the compression and decompression procedure can sleep. Signed-off-by: Barry Song Tested-by: Chengming Zhou --- crypto/acompress.c | 8 ++++++++ include/crypto/acompress.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/crypto/acompress.c b/crypto/acompress.c index 1c682810a484..99118e879a4a 100644 --- a/crypto/acompress.c +++ b/crypto/acompress.c @@ -152,6 +152,14 @@ struct crypto_acomp *crypto_alloc_acomp_node(const char *alg_name, u32 type, } EXPORT_SYMBOL_GPL(crypto_alloc_acomp_node); +bool acomp_is_async(struct crypto_acomp *acomp) +{ + struct crypto_tfm *tfm = crypto_acomp_tfm(acomp); + + return tfm->__crt_alg->cra_type == &crypto_acomp_type; +} +EXPORT_SYMBOL_GPL(acomp_is_async); + struct acomp_req *acomp_request_alloc(struct crypto_acomp *acomp) { struct crypto_tfm *tfm = crypto_acomp_tfm(acomp); diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h index 574cffc90730..d91830c2d442 100644 --- a/include/crypto/acompress.h +++ b/include/crypto/acompress.h @@ -204,6 +204,15 @@ struct acomp_req *acomp_request_alloc(struct crypto_acomp *tfm); */ void acomp_request_free(struct acomp_req *req); +/** + * acomp_is_async() -- check if an acomp is asynchronous(can sleep) + * + * @tfm: ACOMPRESS tfm handle allocated with crypto_alloc_acomp() + * + * Return: true if the acomp is asynchronous, otherwise, false + */ +bool acomp_is_async(struct crypto_acomp *tfm); + /** * acomp_request_set_callback() -- Sets an asynchronous callback *