@@ -1785,7 +1785,7 @@ static int iaa_compress(struct crypto_tfm *tfm, struct acomp_req *req,
" src_addr %llx, dst_addr %llx\n", __func__,
active_compression_mode->name,
src_addr, dst_addr);
- } else if (ctx->async_mode) {
+ } else if (ctx->async_mode && (req->base.flags & CRYPTO_ACOMP_REQ_POLL)) {
req->data = idxd_desc;
}
@@ -1807,7 +1807,7 @@ static int iaa_compress(struct crypto_tfm *tfm, struct acomp_req *req,
update_total_comp_calls();
update_wq_comp_calls(wq);
- if (ctx->async_mode) {
+ if (ctx->async_mode && (req->base.flags & CRYPTO_ACOMP_REQ_POLL)) {
ret = -EINPROGRESS;
dev_dbg(dev, "%s: returning -EINPROGRESS\n", __func__);
goto out;
@@ -1836,8 +1836,7 @@ static int iaa_compress(struct crypto_tfm *tfm, struct acomp_req *req,
static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,
struct idxd_wq *wq,
dma_addr_t src_addr, unsigned int slen,
- dma_addr_t dst_addr, unsigned int *dlen,
- bool disable_async)
+ dma_addr_t dst_addr, unsigned int *dlen)
{
struct iaa_device_compression_mode *active_compression_mode;
struct iaa_compression_ctx *ctx = crypto_tfm_ctx(tfm);
@@ -1886,7 +1885,7 @@ static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,
desc->src1_size = slen;
desc->completion_addr = idxd_desc->compl_dma;
- if (ctx->use_irq && !disable_async) {
+ if (ctx->use_irq) {
desc->flags |= IDXD_OP_FLAG_RCI;
idxd_desc->crypto.req = req;
@@ -1899,7 +1898,7 @@ static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,
" src_addr %llx, dst_addr %llx\n", __func__,
active_compression_mode->name,
src_addr, dst_addr);
- } else if (ctx->async_mode && !disable_async) {
+ } else if (ctx->async_mode && (req->base.flags & CRYPTO_ACOMP_REQ_POLL)) {
req->data = idxd_desc;
}
@@ -1921,7 +1920,7 @@ static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,
update_total_decomp_calls();
update_wq_decomp_calls(wq);
- if (ctx->async_mode && !disable_async) {
+ if (ctx->async_mode && (req->base.flags & CRYPTO_ACOMP_REQ_POLL)) {
ret = -EINPROGRESS;
dev_dbg(dev, "%s: returning -EINPROGRESS\n", __func__);
goto out;
@@ -2127,7 +2126,7 @@ static int iaa_comp_adecompress(struct acomp_req *req)
req->dst, req->dlen, sg_dma_len(req->dst));
ret = iaa_decompress(tfm, req, wq, src_addr, req->slen,
- dst_addr, &req->dlen, false);
+ dst_addr, &req->dlen);
if (ret == -EINPROGRESS)
return ret;
@@ -20,6 +20,12 @@
#include <linux/spinlock_types.h>
#include <linux/types.h>
+/*
+ * If set, the driver must have a way to submit the req, then
+ * poll its completion status for success/error.
+ */
+#define CRYPTO_ACOMP_REQ_POLL 0x00000001
+
/* Set this bit if source is virtual address instead of SG list. */
#define CRYPTO_ACOMP_REQ_SRC_VIRT 0x00000002
The purpose of this commit is to allow kernel users of iaa_crypto, such as zswap, to be able to invoke the crypto_acomp_compress() API in fully synchronous mode for non-batching use cases (i.e. today's status-quo), where zswap calls crypto_wait_req(crypto_acomp_compress(req), wait); and to non-instrusively invoke the fully asynchronous batch compress/decompress API that will be introduced in subsequent patches. Both use cases need to reuse same code paths in the driver to interface with hardware: the CRYPTO_ACOMP_REQ_POLL flag allows this shared code to determine whether we need to process an acomp_req synchronously/asynchronously. The idea is to simplify the crypto_acomp sequential/batching interfaces for use by zswap. Thus, regardless of the iaa_crypto driver's 'sync_mode' setting, it can still be forced to use synchronous mode by turning off the CRYPTO_ACOMP_REQ_POLL flag in req->base.flags (the default to support sequential use cases in zswap today). IAA batching functionality will be implemented in subsequent patches, that will set the CRYPTO_ACOMP_REQ_POLL flag for the acomp_reqs in a batch. This enables the iaa_crypto driver to implement true async "submit-polling" for parallel compressions and decompressions in the IAA hardware accelerator. In other words, all three of the following need to be true for a request to be processed in fully async submit-poll mode: 1) async_mode should be "true" 2) use_irq should be "false" 3) req->base.flags & CRYPTO_ACOMP_REQ_POLL should be "true" Subsequent patches will: - Set (1) and (2) as iaa_crypto defaults once async submit-poll is implemented. - Enable (3) for iaa_crypto batching, and clear the CRYPTO_ACOMP_REQ_POLL flags before exiting from the batching routines since the assumption is that the acomp_reqs are created/managed by a higher level kernel user such as zswap, and are reused for both, sequential and batching use cases from zswap's perspective. This patch also removes "disable_async" from iaa_decompress(). Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com> --- drivers/crypto/intel/iaa/iaa_crypto_main.c | 15 +++++++-------- include/crypto/acompress.h | 6 ++++++ 2 files changed, 13 insertions(+), 8 deletions(-)