hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/dma/virt-dma.h
....@@ -1,11 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Virtual DMA channel support for DMAengine
34 *
45 * Copyright (C) 2012 Russell King
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
96 */
107 #ifndef VIRT_DMA_H
118 #define VIRT_DMA_H
....@@ -17,6 +14,7 @@
1714
1815 struct virt_dma_desc {
1916 struct dma_async_tx_descriptor tx;
17
+ struct dmaengine_result tx_result;
2018 /* protected by vc.lock */
2119 struct list_head node;
2220 };
....@@ -33,9 +31,9 @@
3331 struct list_head desc_submitted;
3432 struct list_head desc_issued;
3533 struct list_head desc_completed;
34
+ struct list_head desc_terminated;
3635
3736 struct virt_dma_desc *cyclic;
38
- struct virt_dma_desc *vd_terminated;
3937 };
4038
4139 static inline struct virt_dma_chan *to_virt_chan(struct dma_chan *chan)
....@@ -64,6 +62,9 @@
6462 vd->tx.flags = tx_flags;
6563 vd->tx.tx_submit = vchan_tx_submit;
6664 vd->tx.desc_free = vchan_tx_desc_free;
65
+
66
+ vd->tx_result.result = DMA_TRANS_NOERROR;
67
+ vd->tx_result.residue = 0;
6768
6869 spin_lock_irqsave(&vc->lock, flags);
6970 list_add_tail(&vd->node, &vc->desc_allocated);
....@@ -112,10 +113,15 @@
112113 {
113114 struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
114115
115
- if (dmaengine_desc_test_reuse(&vd->tx))
116
+ if (dmaengine_desc_test_reuse(&vd->tx)) {
117
+ unsigned long flags;
118
+
119
+ spin_lock_irqsave(&vc->lock, flags);
116120 list_add(&vd->node, &vc->desc_allocated);
117
- else
121
+ spin_unlock_irqrestore(&vc->lock, flags);
122
+ } else {
118123 vc->desc_free(vd);
124
+ }
119125 }
120126
121127 /**
....@@ -140,11 +146,8 @@
140146 {
141147 struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan);
142148
143
- /* free up stuck descriptor */
144
- if (vc->vd_terminated)
145
- vchan_vdesc_fini(vc->vd_terminated);
149
+ list_add_tail(&vd->node, &vc->desc_terminated);
146150
147
- vc->vd_terminated = vd;
148151 if (vc->cyclic == vd)
149152 vc->cyclic = NULL;
150153 }
....@@ -178,6 +181,7 @@
178181 list_splice_tail_init(&vc->desc_submitted, head);
179182 list_splice_tail_init(&vc->desc_issued, head);
180183 list_splice_tail_init(&vc->desc_completed, head);
184
+ list_splice_tail_init(&vc->desc_terminated, head);
181185 }
182186
183187 static inline void vchan_free_chan_resources(struct virt_dma_chan *vc)
....@@ -206,16 +210,18 @@
206210 */
207211 static inline void vchan_synchronize(struct virt_dma_chan *vc)
208212 {
213
+ LIST_HEAD(head);
209214 unsigned long flags;
210215
211216 tasklet_kill(&vc->task);
212217
213218 spin_lock_irqsave(&vc->lock, flags);
214
- if (vc->vd_terminated) {
215
- vchan_vdesc_fini(vc->vd_terminated);
216
- vc->vd_terminated = NULL;
217
- }
219
+
220
+ list_splice_tail_init(&vc->desc_terminated, &head);
221
+
218222 spin_unlock_irqrestore(&vc->lock, flags);
223
+
224
+ vchan_dma_desc_free_list(vc, &head);
219225 }
220226
221227 #endif