[RFC] crypto: qat - enable polling for compression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When a request is synchronous, it is more efficient to submit it and
poll for a response without going through the interrupt path.

This patch adds logic in the transport layer to poll the response ring
and enables polling for compression in the QAT driver.

This is an initial and not complete implementation. The reason why it
has been sent as RFC is to discuss about ways to mark a request as
synchronous from the acomp APIs.

Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@xxxxxxxxx>
---
 drivers/crypto/qat/qat_common/adf_transport.c | 28 +++++++++++++++++++
 drivers/crypto/qat/qat_common/adf_transport.h |  1 +
 drivers/crypto/qat/qat_common/qat_comp_algs.c |  9 +++++-
 .../crypto/qat/qat_common/qat_compression.c   |  2 +-
 4 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_transport.c b/drivers/crypto/qat/qat_common/adf_transport.c
index 630d0483c4e0..af613ee84cdc 100644
--- a/drivers/crypto/qat/qat_common/adf_transport.c
+++ b/drivers/crypto/qat/qat_common/adf_transport.c
@@ -133,6 +133,34 @@ static int adf_handle_response(struct adf_etr_ring_data *ring)
 	return 0;
 }
 
+int adf_poll_message(struct adf_etr_ring_data *ring)
+{
+	struct adf_hw_csr_ops *csr_ops = GET_CSR_OPS(ring->bank->accel_dev);
+	u32 msg_counter = 0;
+	u32 *msg = (u32 *)((uintptr_t)ring->base_addr + ring->head);
+
+	if (atomic_read(ring->inflights) == 0)
+		return 0;
+
+	while (*msg != ADF_RING_EMPTY_SIG) {
+		ring->callback((u32 *)msg);
+		atomic_dec(ring->inflights);
+		*msg = ADF_RING_EMPTY_SIG;
+		ring->head = adf_modulo(ring->head +
+					ADF_MSG_SIZE_TO_BYTES(ring->msg_size),
+					ADF_RING_SIZE_MODULO(ring->ring_size));
+		msg_counter++;
+		msg = (u32 *)((uintptr_t)ring->base_addr + ring->head);
+	}
+	if (msg_counter > 0) {
+		csr_ops->write_csr_ring_head(ring->bank->csr_addr,
+					     ring->bank->bank_number,
+					     ring->ring_number, ring->head);
+		return 0;
+	}
+	return -EAGAIN;
+}
+
 static void adf_configure_tx_ring(struct adf_etr_ring_data *ring)
 {
 	struct adf_hw_csr_ops *csr_ops = GET_CSR_OPS(ring->bank->accel_dev);
diff --git a/drivers/crypto/qat/qat_common/adf_transport.h b/drivers/crypto/qat/qat_common/adf_transport.h
index e6ef6f9b7691..d549081172f8 100644
--- a/drivers/crypto/qat/qat_common/adf_transport.h
+++ b/drivers/crypto/qat/qat_common/adf_transport.h
@@ -16,5 +16,6 @@ int adf_create_ring(struct adf_accel_dev *accel_dev, const char *section,
 
 bool adf_ring_nearly_full(struct adf_etr_ring_data *ring);
 int adf_send_message(struct adf_etr_ring_data *ring, u32 *msg);
+int adf_poll_message(struct adf_etr_ring_data *ring);
 void adf_remove_ring(struct adf_etr_ring_data *ring);
 #endif
diff --git a/drivers/crypto/qat/qat_common/qat_comp_algs.c b/drivers/crypto/qat/qat_common/qat_comp_algs.c
index 1480d36a8d2b..07378e9fe8fa 100644
--- a/drivers/crypto/qat/qat_common/qat_comp_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_comp_algs.c
@@ -291,8 +291,15 @@ static int qat_comp_alg_compress_decompress(struct acomp_req *areq,
 	}
 
 	ret = qat_alg_send_dc_message(qat_req, inst, &areq->base);
-	if (ret == -ENOSPC)
+	if (ret == -ENOSPC) {
 		qat_bl_free_bufl(inst->accel_dev, &qat_req->buf);
+		return ret;
+	}
+
+	do {
+		ret = adf_poll_message(inst->dc_rx);
+		schedule();
+	} while (ret);
 
 	return ret;
 }
diff --git a/drivers/crypto/qat/qat_common/qat_compression.c b/drivers/crypto/qat/qat_common/qat_compression.c
index 9fd10f4242f8..49b34c5ec595 100644
--- a/drivers/crypto/qat/qat_common/qat_compression.c
+++ b/drivers/crypto/qat/qat_common/qat_compression.c
@@ -174,7 +174,7 @@ static int qat_compression_create_instances(struct adf_accel_dev *accel_dev)
 		msg_size = ICP_QAT_FW_RESP_DEFAULT_SZ;
 		snprintf(key, sizeof(key), ADF_DC "%d" ADF_RING_DC_RX, i);
 		ret = adf_create_ring(accel_dev, SEC, bank, num_msg_dc,
-				      msg_size, key, qat_comp_alg_callback, 0,
+				      msg_size, key, qat_comp_alg_callback, 1,
 				      &inst->dc_rx);
 		if (ret)
 			return ret;
-- 
2.39.0




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux