Skip to contentSkip to conversation

DMAengine: Add support for Immediate commands

RFC PATCH New Sireesh Kodali 1 participant 4 messages Sep 19, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover DMAengine: Add support for Immediate commands

The IPA v2.x block, found on some older Qualcomm SoCs, uses BAM DMA to send and receive packets from the AP. It also uses BAM to receive commands from the AP (and possibly the modem). These commands are encoded as "Immediate Commands". They vary from regular BAM DMA commands, although I'm not sure as to exactly how they vary. Adding support for immediate commands is trivial, but requires also adding Immediate Commands to the dmaengine API, which is what this patch does.

Sireesh Kodali (3):
doc: dmaengine: client-api: Add immediate commands in the DMA client
API
dmaengine: Add support for immediate commands in the client API
dmaengine: qcom: bam_dma: Add support for immediate commands

 Documentation/driver-api/dmaengine/provider.rst | 10 ++++++++++
 drivers/dma/qcom/bam_dma.c                      |  3 +++
 include/linux/dmaengine.h                       |  4 ++++
 3 files changed, 17 insertions(+)
Signature · 1 line
2.33.0
#1 lore raw

PATCH 1/3 doc: dmaengine: client-api: Add immediate commands in the DMA client API

Immediate commands are used by the IPA driver to send commands to the microcontroller over BAM. These are different from PREP_CMD.

---
 Documentation/driver-api/dmaengine/provider.rst | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/driver-api/dmaengine/provider.rst +10 -0
index ddb0a81a796c..f92a0bae06a0 100644
@@ -571,6 +571,16 @@ DMA_CTRL_REUSE
     writes for which the descriptor should be in different format from
     normal data descriptors.
 
+- DMA_PREP_IMM_CMD
+
+  - If set, the client driver tells DMA controller that passed data in DMA
+    API is immediate command data.
+
+  - Interpretation of command data is DMA controller specific. It can be
+    used for issuing immediate commands to other peripherals/register
+    reads/register writes for which the descriptor shoudl be in a
+    different format from normal data descriptors.
+
 - DMA_PREP_REPEAT
 
   - If set, the transfer will be automatically repeated when it ends until a
Signature · 1 line
2.33.0
#2 lore raw

PATCH 2/3 dmaengine: Add support for immediate commands in the client API

In reply to Sireesh Kodali

Immediate commands are needed by the IPA network driver, so that it can send commands via BAM to the microcontroller

---
 include/linux/dmaengine.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/dmaengine.h +4 -0
index e5c2c9e71bf1..9bac959b34a8 100644
@@ -190,6 +190,9 @@ struct dma_interleaved_template {
  *  transaction is marked with DMA_PREP_REPEAT will cause the new transaction
  *  to never be processed and stay in the issued queue forever. The flag is
  *  ignored if the previous transaction is not a repeated transaction.
+ *  @DMA_PREP_IMM_CMD: tell the driver that the data passed to the DMA API is
+ *  immediate command data and the descriptor should be in a different format
+ *  from the normal data and descriptor
  */
 enum dma_ctrl_flags {
 	DMA_PREP_INTERRUPT = (1 << 0),
@@ -202,6 +205,7 @@ enum dma_ctrl_flags {
 	DMA_PREP_CMD = (1 << 7),
 	DMA_PREP_REPEAT = (1 << 8),
 	DMA_PREP_LOAD_EOT = (1 << 9),
+	DMA_PREP_IMM_CMD = (1 << 10),
 };
 
 /**
Signature · 1 line
2.33.0
#3 lore raw

PATCH 3/3 dmaengine: qcom: bam_dma: Add support for immediate commands

In reply to Sireesh Kodali

Immediate commands are needed by the IPA driver to send commands to the IPA controller over BAM. To support immediate commands, all we need to do is set the relevant flag in the descriptor.

---
 drivers/dma/qcom/bam_dma.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/dma/qcom/bam_dma.c +3 -0
index c8a77b428b52..cebec638a994 100644
@@ -58,6 +58,7 @@ 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_IMM BIT(8)
 
 struct bam_async_desc {
 	struct virt_dma_desc vd;
@@ -651,6 +652,8 @@ static struct dma_async_tx_descriptor *bam_prep_slave_sg(struct dma_chan *chan,
 		do {
 			if (flags & DMA_PREP_CMD)
 				desc->flags |= cpu_to_le16(DESC_FLAG_CMD);
+			else if (flags & DMA_PREP_IMM_CMD)
+				desc->flags |= cpu_to_le16(DESC_FLAG_IMM);
 
 			desc->addr = cpu_to_le32(sg_dma_address(sg) +
 						 curr_offset);
Signature · 1 line
2.33.0