[PATCH v22 14/14] crypto: qce - Communicate the base physical address to the dmaengine
From: Bartosz Golaszewski
Date: Fri Jul 17 2026 - 04:41:02 EST
In order to communicate to the BAM DMA engine which address should be
used as a scratchpad for dummy writes related to BAM pipe locking,
fill out the dedicated BAM peripheral config structure and pass it to
the DMA driver using dmaengine_slave_config().
Reviewed-by: Manivannan Sadhasivam <mani@xxxxxxxxxx>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
---
drivers/crypto/qce/core.c | 6 ++++--
drivers/crypto/qce/dma.c | 13 +++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/qce/core.c b/drivers/crypto/qce/core.c
index 4031b4516d6519fc5024bbbcc439500a7b3314b2..50fdc8d808d0fe1d9d430ec601ab2ccf2ddf6e91 100644
--- a/drivers/crypto/qce/core.c
+++ b/drivers/crypto/qce/core.c
@@ -246,6 +246,9 @@ static int qce_crypto_probe(struct platform_device *pdev)
if (ret)
return ret;
+ qce->base_phys = res->start;
+ qce->dma_size = resource_size(res);
+
ret = devm_qce_dma_request(qce);
if (ret)
return ret;
@@ -263,10 +266,9 @@ static int qce_crypto_probe(struct platform_device *pdev)
qce->async_req_enqueue = qce_async_request_enqueue;
qce->async_req_done = qce_async_request_done;
- qce->dma_size = resource_size(res);
qce->base_dma = dma_map_resource(dev, res->start, qce->dma_size,
DMA_BIDIRECTIONAL, 0);
- qce->base_phys = res->start;
+
ret = dma_mapping_error(dev, qce->base_dma);
if (ret)
return ret;
diff --git a/drivers/crypto/qce/dma.c b/drivers/crypto/qce/dma.c
index 88d253d9147cfc9ed275653f7fd248538378194a..b45a65a2ebb511d6619a49f35a89730a551421c6 100644
--- a/drivers/crypto/qce/dma.c
+++ b/drivers/crypto/qce/dma.c
@@ -11,6 +11,7 @@
#include "core.h"
#include "dma.h"
+#include "regs-v5.h"
#define QCE_IGNORE_BUF_SZ (2 * QCE_BAM_BURST_SIZE)
#define QCE_BAM_CMD_SGL_SIZE 128
@@ -116,8 +117,16 @@ static void qce_dma_terminate(void *data)
int devm_qce_dma_request(struct qce_device *qce)
{
+ struct bam_config peripheral_cfg = {
+ .lock_scratchpad_addr = qce->base_phys + REG_VERSION,
+ };
+ struct dma_slave_config cfg = {
+ .direction = DMA_MEM_TO_DEV,
+ .peripheral_config = &peripheral_cfg,
+ };
struct qce_dma_data *dma = &qce->dma;
struct device *dev = qce->dev;
+ int ret;
dma->result_buf = devm_kmalloc(dev, QCE_RESULT_BUF_SZ + QCE_IGNORE_BUF_SZ, GFP_KERNEL);
if (!dma->result_buf)
@@ -133,6 +142,10 @@ int devm_qce_dma_request(struct qce_device *qce)
return dev_err_probe(dev, PTR_ERR(dma->rxchan),
"Failed to get RX DMA channel\n");
+ ret = dmaengine_slave_config(dma->rxchan, &cfg);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to configure the RX DMA channel\n");
+
dma->bam_txn = devm_kzalloc(dev, sizeof(*dma->bam_txn), GFP_KERNEL);
if (!dma->bam_txn)
return -ENOMEM;
--
2.47.3