From patchwork Fri Oct 18 06:40:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13841228 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 A7A19D3C54C for ; Fri, 18 Oct 2024 06:41:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39F286B0085; Fri, 18 Oct 2024 02:41:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 329046B008A; Fri, 18 Oct 2024 02:41:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01E946B0088; Fri, 18 Oct 2024 02:41:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D41456B0085 for ; Fri, 18 Oct 2024 02:41:06 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 014B1C173E for ; Fri, 18 Oct 2024 06:40:53 +0000 (UTC) X-FDA: 82685775270.08.1031922 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by imf27.hostedemail.com (Postfix) with ESMTP id 9621940005 for ; Fri, 18 Oct 2024 06:40:53 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=T6RzztvN; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf27.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.15 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729233545; a=rsa-sha256; cv=none; b=BXRmj6V3obXnAFbFjdzFFFJrK8swgqHMpc9CTBLOQj60+4h2zeOgbnKwtWbq6NTa4gjRwF KUAvsT1uROoz810DijEn4HMfpMhdljXY6yJYdbIbp4C+sshKWZ7/MzhQFczr00v3ufHadM KG3B0ycPqKVsSAo7DlUlbVUZKP8qKBc= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=T6RzztvN; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf27.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.15 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729233545; 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=5uPDs9Ny1P2DVNOPHwMNKagj/oUSxXThkw3t9wLua2A=; b=3BqmMAUKhDtt2u1bgCpalglmCWoZHBbhAn9uFTzy63Gh0tbxeLG5tdBxtjlvQ5m4MEvMfS m72bAswk/xDbobUZcul5q7gnAIy8i0tT5YlVnTiaZdw6/4NkyFD9SokAwZk0YXAHXU/mGC IwFHZS91RCkuIrdXoadAWZJYKF4qT2U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729233664; x=1760769664; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0lpsj1UvR6AcnHgvukFN7BtQLeSUmvJMMadL8XBpSFM=; b=T6RzztvNKL4z6FnpNAdlXRbdPG5W+jid9EH+1WysK7m35wRpnS/FzTjA M8evfOAQgAjrKGKtY5/RxmAAFD6gKTmXkvGfQ8JLUk0fBkIGunylGS15o PEeF9ONWgFpJLT46hdO9tPdMNhDP+wt1M9lVCcuYTLZCq3kj7yv7LmxuX oZk4KTSdehX6H9VbNu/sxFL83ZwiM6gMzVmbDkxMvxmmpo1FmSoKQWV7x VLSCu5iAPFc6oHInSnoqITVMftcR+7r4an617mHs1rAwGeKH4PnmdsYAN ZreT3vA7wOKuNTrqG5qdjpqJh0FauMs9/Mtow4EB/hNeAJ5oZX1lv4oNt w==; X-CSE-ConnectionGUID: NN5/VhBNRgijujjD3gBH+g== X-CSE-MsgGUID: /ckLpereQtOYWyQHWTlg3A== X-IronPort-AV: E=McAfee;i="6700,10204,11228"; a="28884782" X-IronPort-AV: E=Sophos;i="6.11,212,1725346800"; d="scan'208";a="28884782" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2024 23:41:02 -0700 X-CSE-ConnectionGUID: EXdOqHO4QOiTM5LpwBoMEQ== X-CSE-MsgGUID: X736q6ymTDK46QF8X8oAwg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="83607487" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa003.jf.intel.com with ESMTP; 17 Oct 2024 23:41:01 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, clabbe@baylibre.com, ardb@kernel.org, ebiggers@google.com, surenb@google.com, kristen.c.accardi@intel.com, zanussi@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, mcgrof@kernel.org, kees@kernel.org, joel.granados@kernel.org, bfoster@redhat.com, willy@infradead.org, linux-fsdevel@vger.kernel.org Cc: wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [RFC PATCH v1 01/13] crypto: acomp - Add a poll() operation to acomp_alg and acomp_req Date: Thu, 17 Oct 2024 23:40:49 -0700 Message-Id: <20241018064101.336232-2-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241018064101.336232-1-kanchana.p.sridhar@intel.com> References: <20241018064101.336232-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 9621940005 X-Stat-Signature: g1qngc9wrq7hf9ece15s7pi4e1959ob9 X-Rspam-User: X-HE-Tag: 1729233653-368533 X-HE-Meta: U2FsdGVkX180FIFhkNjk0kVKLCe5zyyp3CPvHX2+HyRvlA281XjuUUcKXjLP/ABAhpD+xiMTIK1SYDTbpuCSSaN4KNTHbYneQsvgYUObsGLR+SAdf916Ra16Hg+vx3XDlcmENBdYG6M4/oRdd+Zy4Z59IhDB3UUliTYha9pAkddkgPNk31OGkChUooGntb9rlcTJ6B7sbHk0IPagfpoZ3iL0jUKrgQ9Tr1pcY6B730S8xDos4J4ATgPSeGriZ1rNrsVl3+t2v8GX+t+HBHn2IArLnu5KXLhyi/iqyTN+39EnJ8iWB1XfTnTBhEcN1h+qFQpakPJQw+JuYmfK3GPXd286uBU8+7/mCXArCg/BTtlT5dhOHc/vMve22jWI2N9VbgYXDIyhD5GHPjwlPuS+Ao8KfyOuRtq40U43LUOSEy8cpWQgxrz7EBBu4E4VvsmnevPZrN8SquPdMIxaT2UPk+YDDfNenfIwroPDshRX1IAtT5VYoDfUW8WgdKq/CDXJDOIUNJaBZ26WbQvLCMt6xwyDhlvOPuCAmH44fPtl4F/9jSdtvvC27hNX6mQOeVtod7WM/nrnDUXSykJ88crb1dXmTJEZYvSESFjm3wNZ2/jvkOp3LlowoCS12gOFyW3q7NQBHzuHrlVwh8qPFmSWWcmepHvYAAVFXsNzr9BXbCiIISQ2WNW1UjfvgQJ1gDl1vLCMSVMHud56SZ0P17JkUDjQyJV0TffQHMBP2sJAgLHLYLlRVpBuAdHoPggAP5gUU/fzNXCcO/UGwCpsFxs7sQ+xAegMIAfc2B9l6/02GrYQ/R9GPUj5UtSxJ2slcDswj/0aWNA1ync3wnz2vZoqhNGAv1Wf9aI8adhhbLx94hKXPQ7NvGjsz/XVzwY4PkqjnUgy1ieyXV9jHiQ1QuO33SgOvNTdfAg+3Rsg31eoBYAsbtXoxXS61yIWJmvh+UA2zAuunDK9xv1mEjw5Wph F34oWI73 clrTH5Vtlziny1qBs4Z49I2GEoMIB08JJbZMDYumPrgNhooiYGs1RAgljpDhe8S1rvDE6vfMWkjqGC/piwoWXmx+Bda1vfVgse8IOBDYpG1uctHoRkGxaFAR6XSYF0FlDm7+V0V01zbDkkYbdDt1QLxaIMYKZ7X4JmxZDsL7zjCCSNLwV8SkIp6XAzL51zxQB5bLiKwHEwFtZNDS9BKYhdtFcQessL6ZhFUBt 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: For async compress/decompress, provide a way for the caller to poll for compress/decompress completion, rather than wait for an interrupt to signal completion. Callers can submit a compress/decompress using crypto_acomp_compress and decompress and rather than wait on a completion, call crypto_acomp_poll() to check for completion. This is useful for hardware accelerators where the overhead of interrupts and waiting for completions is too expensive. Typically the compress/decompress hw operations complete very quickly and in the vast majority of cases, adding the overhead of interrupt handling and waiting for completions simply adds unnecessary delays and cancels the gains of using the hw acceleration. Signed-off-by: Tom Zanussi Signed-off-by: Kanchana P Sridhar --- crypto/acompress.c | 1 + include/crypto/acompress.h | 18 ++++++++++++++++++ include/crypto/internal/acompress.h | 1 + 3 files changed, 20 insertions(+) diff --git a/crypto/acompress.c b/crypto/acompress.c index 6fdf0ff9f3c0..00ec7faa2714 100644 --- a/crypto/acompress.c +++ b/crypto/acompress.c @@ -71,6 +71,7 @@ static int crypto_acomp_init_tfm(struct crypto_tfm *tfm) acomp->compress = alg->compress; acomp->decompress = alg->decompress; + acomp->poll = alg->poll; acomp->dst_free = alg->dst_free; acomp->reqsize = alg->reqsize; diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h index 54937b615239..65b5de30c8b1 100644 --- a/include/crypto/acompress.h +++ b/include/crypto/acompress.h @@ -51,6 +51,7 @@ struct acomp_req { struct crypto_acomp { int (*compress)(struct acomp_req *req); int (*decompress)(struct acomp_req *req); + int (*poll)(struct acomp_req *req); void (*dst_free)(struct scatterlist *dst); unsigned int reqsize; struct crypto_tfm base; @@ -265,4 +266,21 @@ static inline int crypto_acomp_decompress(struct acomp_req *req) return crypto_acomp_reqtfm(req)->decompress(req); } +/** + * crypto_acomp_poll() -- Invoke asynchronous poll operation + * + * Function invokes the asynchronous poll operation + * + * @req: asynchronous request + * + * Return: zero on poll completion, -EAGAIN if not complete, or + * error code in case of error + */ +static inline int crypto_acomp_poll(struct acomp_req *req) +{ + struct crypto_acomp *tfm = crypto_acomp_reqtfm(req); + + return tfm->poll(req); +} + #endif diff --git a/include/crypto/internal/acompress.h b/include/crypto/internal/acompress.h index 8831edaafc05..fbf5f6c6eeb6 100644 --- a/include/crypto/internal/acompress.h +++ b/include/crypto/internal/acompress.h @@ -37,6 +37,7 @@ struct acomp_alg { int (*compress)(struct acomp_req *req); int (*decompress)(struct acomp_req *req); + int (*poll)(struct acomp_req *req); void (*dst_free)(struct scatterlist *dst); int (*init)(struct crypto_acomp *tfm); void (*exit)(struct crypto_acomp *tfm);