hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
kernel/include/linux/dmaengine.h
....@@ -62,6 +62,7 @@
6262 DMA_ASYNC_TX,
6363 DMA_SLAVE,
6464 DMA_CYCLIC,
65
+ DMA_OOB,
6566 DMA_INTERLEAVE,
6667 DMA_COMPLETION_NO_ORDER,
6768 DMA_REPEAT,
....@@ -191,6 +192,13 @@
191192 * transaction is marked with DMA_PREP_REPEAT will cause the new transaction
192193 * to never be processed and stay in the issued queue forever. The flag is
193194 * ignored if the previous transaction is not a repeated transaction.
195
+ * @DMA_OOB_INTERRUPT - if DMA_OOB is supported, handle the completion
196
+ * interrupt for this transaction from the out-of-band stage (implies
197
+ * DMA_PREP_INTERRUPT). This includes calling the completion callback routine
198
+ * from such context if defined for the transaction.
199
+ * @DMA_OOB_PULSE - if DMA_OOB is supported, (slave) transactions on the
200
+ * out-of-band channel should be triggered manually by a call to
201
+ * dma_pulse_oob() (implies DMA_OOB_INTERRUPT).
194202 */
195203 enum dma_ctrl_flags {
196204 DMA_PREP_INTERRUPT = (1 << 0),
....@@ -203,6 +211,8 @@
203211 DMA_PREP_CMD = (1 << 7),
204212 DMA_PREP_REPEAT = (1 << 8),
205213 DMA_PREP_LOAD_EOT = (1 << 9),
214
+ DMA_OOB_INTERRUPT = (1 << 10),
215
+ DMA_OOB_PULSE = (1 << 11),
206216 };
207217
208218 /**
....@@ -940,6 +950,7 @@
940950 dma_cookie_t cookie,
941951 struct dma_tx_state *txstate);
942952 void (*device_issue_pending)(struct dma_chan *chan);
953
+ int (*device_pulse_oob)(struct dma_chan *chan);
943954 void (*device_release)(struct dma_device *dev);
944955 /* debugfs support */
945956 #ifdef CONFIG_DEBUG_FS
....@@ -983,11 +994,22 @@
983994 dir, flags, NULL);
984995 }
985996
997
+static inline bool dmaengine_oob_valid(struct dma_chan *chan,
998
+ unsigned long flags)
999
+{
1000
+ return !(dovetailing() &&
1001
+ flags & (DMA_OOB_INTERRUPT|DMA_OOB_PULSE) &&
1002
+ !test_bit(DMA_OOB, chan->device->cap_mask.bits));
1003
+}
1004
+
9861005 static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_sg(
9871006 struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len,
9881007 enum dma_transfer_direction dir, unsigned long flags)
9891008 {
9901009 if (!chan || !chan->device || !chan->device->device_prep_slave_sg)
1010
+ return NULL;
1011
+
1012
+ if (!dmaengine_oob_valid(chan, flags))
9911013 return NULL;
9921014
9931015 return chan->device->device_prep_slave_sg(chan, sgl, sg_len,
....@@ -1015,6 +1037,9 @@
10151037 unsigned long flags)
10161038 {
10171039 if (!chan || !chan->device || !chan->device->device_prep_dma_cyclic)
1040
+ return NULL;
1041
+
1042
+ if (!dmaengine_oob_valid(chan, flags))
10181043 return NULL;
10191044
10201045 return chan->device->device_prep_dma_cyclic(chan, buf_addr, buf_len,
....@@ -1422,6 +1447,22 @@
14221447 }
14231448
14241449 /**
1450
+ * dma_pulse_oob - manual trigger of an out-of-band transaction
1451
+ * @chan: target DMA channel
1452
+ *
1453
+ * Trigger the next out-of-band transaction immediately.
1454
+ */
1455
+static inline int dma_pulse_oob(struct dma_chan *chan)
1456
+{
1457
+ int ret = -ENOTSUPP;
1458
+
1459
+ if (chan->device->device_pulse_oob)
1460
+ ret = chan->device->device_pulse_oob(chan);
1461
+
1462
+ return ret;
1463
+}
1464
+
1465
+/**
14251466 * dma_async_is_tx_complete - poll for transaction completion
14261467 * @chan: DMA channel
14271468 * @cookie: transaction identifier to check status of