[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251106-qcom-qce-cmd-descr-v8-3-ecddca23ca26@linaro.org>
Date: Thu, 06 Nov 2025 12:33:59 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Vinod Koul <vkoul@...nel.org>, Jonathan Corbet <corbet@....net>,
Thara Gopinath <thara.gopinath@...il.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
Udit Tiwari <quic_utiwari@...cinc.com>,
Daniel Perez-Zoghbi <dperezzo@...cinc.com>,
Md Sadre Alam <mdalam@....qualcomm.com>
Cc: dmaengine@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
linux-crypto@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: [PATCH v8 03/11] dmaengine: qcom: bam_dma: Add bam_pipe_lock flag
support
From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Extend the device match data with a flag indicating whether the IP
supports the BAM lock/unlock feature. Set it to true on BAM IP versions
1.4.0 and above.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
---
drivers/dma/qcom/bam_dma.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index 8861245314b1d13c1abb78f474fd0749fea52f06..68921d22ad7abfef7059b1db78052ff48e842952 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -58,6 +58,8 @@ struct bam_desc_hw {
#define DESC_FLAG_EOB BIT(13)
#define DESC_FLAG_NWD BIT(12)
#define DESC_FLAG_CMD BIT(11)
+#define DESC_FLAG_LOCK BIT(10)
+#define DESC_FLAG_UNLOCK BIT(9)
struct bam_async_desc {
struct virt_dma_desc vd;
@@ -113,6 +115,7 @@ struct reg_offset_data {
struct bam_device_data {
const struct reg_offset_data *reg_info;
+ bool bam_pipe_lock;
};
static const struct reg_offset_data bam_v1_3_reg_info[] = {
@@ -179,6 +182,7 @@ static const struct reg_offset_data bam_v1_4_reg_info[] = {
static const struct bam_device_data bam_v1_4_data = {
.reg_info = bam_v1_4_reg_info,
+ .bam_pipe_lock = true,
};
static const struct reg_offset_data bam_v1_7_reg_info[] = {
@@ -212,6 +216,7 @@ static const struct reg_offset_data bam_v1_7_reg_info[] = {
static const struct bam_device_data bam_v1_7_data = {
.reg_info = bam_v1_7_reg_info,
+ .bam_pipe_lock = true,
};
/* BAM CTRL */
@@ -386,6 +391,9 @@ struct bam_chan {
struct list_head desc_list;
struct list_head node;
+
+ /* Is the BAM currently locked? */
+ bool locked;
};
static inline struct bam_chan *to_bam_chan(struct dma_chan *common)
@@ -667,6 +675,7 @@ static struct dma_async_tx_descriptor *bam_prep_slave_sg(struct dma_chan *chan,
{
struct bam_chan *bchan = to_bam_chan(chan);
struct bam_device *bdev = bchan->bdev;
+ const struct bam_device_data *bdata = bdev->dev_data;
struct bam_async_desc *async_desc;
struct scatterlist *sg;
u32 i;
@@ -707,9 +716,34 @@ static struct dma_async_tx_descriptor *bam_prep_slave_sg(struct dma_chan *chan,
unsigned int curr_offset = 0;
do {
- if (flags & DMA_PREP_CMD)
+ if (flags & DMA_PREP_CMD) {
+ if (!bdata->bam_pipe_lock &&
+ (flags & (DMA_PREP_LOCK | DMA_PREP_UNLOCK))) {
+ dev_err(bdev->dev, "Device doesn't support BAM locking\n");
+ return NULL;
+ }
+
desc->flags |= cpu_to_le16(DESC_FLAG_CMD);
+ if (bdata->bam_pipe_lock && (flags & DMA_PREP_LOCK)) {
+ if (bchan->locked) {
+ dev_err(bdev->dev, "BAM already locked\n");
+ return NULL;
+ }
+
+ desc->flags |= cpu_to_le16(DESC_FLAG_LOCK);
+ bchan->locked = true;
+ } else if (bdata->bam_pipe_lock && (flags & DMA_PREP_UNLOCK)) {
+ if (!bchan->locked) {
+ dev_err(bdev->dev, "BAM is not locked\n");
+ return NULL;
+ }
+
+ desc->flags |= cpu_to_le16(DESC_FLAG_UNLOCK);
+ bchan->locked = false;
+ }
+ }
+
desc->addr = cpu_to_le32(sg_dma_address(sg) +
curr_offset);
--
2.51.0
Powered by blists - more mailing lists