aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/ioat/dma_v2.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/dma/ioat/dma_v2.h')
-rw-r--r--drivers/dma/ioat/dma_v2.h33
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/dma/ioat/dma_v2.h b/drivers/dma/ioat/dma_v2.h
index ef2871fd7868..a2c413b2b8d8 100644
--- a/drivers/dma/ioat/dma_v2.h
+++ b/drivers/dma/ioat/dma_v2.h
@@ -22,6 +22,7 @@
22#define IOATDMA_V2_H 22#define IOATDMA_V2_H
23 23
24#include <linux/dmaengine.h> 24#include <linux/dmaengine.h>
25#include <linux/circ_buf.h>
25#include "dma.h" 26#include "dma.h"
26#include "hw.h" 27#include "hw.h"
27 28
@@ -49,8 +50,9 @@ extern int ioat_ring_alloc_order;
49 * @tail: cleanup index 50 * @tail: cleanup index
50 * @dmacount: identical to 'head' except for occasionally resetting to zero 51 * @dmacount: identical to 'head' except for occasionally resetting to zero
51 * @alloc_order: log2 of the number of allocated descriptors 52 * @alloc_order: log2 of the number of allocated descriptors
53 * @produce: number of descriptors to produce at submit time
52 * @ring: software ring buffer implementation of hardware ring 54 * @ring: software ring buffer implementation of hardware ring
53 * @ring_lock: protects ring attributes 55 * @prep_lock: serializes descriptor preparation (producers)
54 */ 56 */
55struct ioat2_dma_chan { 57struct ioat2_dma_chan {
56 struct ioat_chan_common base; 58 struct ioat_chan_common base;
@@ -60,8 +62,9 @@ struct ioat2_dma_chan {
60 u16 tail; 62 u16 tail;
61 u16 dmacount; 63 u16 dmacount;
62 u16 alloc_order; 64 u16 alloc_order;
65 u16 produce;
63 struct ioat_ring_ent **ring; 66 struct ioat_ring_ent **ring;
64 spinlock_t ring_lock; 67 spinlock_t prep_lock;
65}; 68};
66 69
67static inline struct ioat2_dma_chan *to_ioat2_chan(struct dma_chan *c) 70static inline struct ioat2_dma_chan *to_ioat2_chan(struct dma_chan *c)
@@ -71,38 +74,26 @@ static inline struct ioat2_dma_chan *to_ioat2_chan(struct dma_chan *c)
71 return container_of(chan, struct ioat2_dma_chan, base); 74 return container_of(chan, struct ioat2_dma_chan, base);
72} 75}
73 76
74static inline u16 ioat2_ring_mask(struct ioat2_dma_chan *ioat) 77static inline u16 ioat2_ring_size(struct ioat2_dma_chan *ioat)
75{ 78{
76 return (1 << ioat->alloc_order) - 1; 79 return 1 << ioat->alloc_order;
77} 80}
78 81
79/* count of descriptors in flight with the engine */ 82/* count of descriptors in flight with the engine */
80static inline u16 ioat2_ring_active(struct ioat2_dma_chan *ioat) 83static inline u16 ioat2_ring_active(struct ioat2_dma_chan *ioat)
81{ 84{
82 return (ioat->head - ioat->tail) & ioat2_ring_mask(ioat); 85 return CIRC_CNT(ioat->head, ioat->tail, ioat2_ring_size(ioat));
83} 86}
84 87
85/* count of descriptors pending submission to hardware */ 88/* count of descriptors pending submission to hardware */
86static inline u16 ioat2_ring_pending(struct ioat2_dma_chan *ioat) 89static inline u16 ioat2_ring_pending(struct ioat2_dma_chan *ioat)
87{ 90{
88 return (ioat->head - ioat->issued) & ioat2_ring_mask(ioat); 91 return CIRC_CNT(ioat->head, ioat->issued, ioat2_ring_size(ioat));
89} 92}
90 93
91static inline u16 ioat2_ring_space(struct ioat2_dma_chan *ioat) 94static inline u16 ioat2_ring_space(struct ioat2_dma_chan *ioat)
92{ 95{
93 u16 num_descs = ioat2_ring_mask(ioat) + 1; 96 return ioat2_ring_size(ioat) - ioat2_ring_active(ioat);
94 u16 active = ioat2_ring_active(ioat);
95
96 BUG_ON(active > num_descs);
97
98 return num_descs - active;
99}
100
101/* assumes caller already checked space */
102static inline u16 ioat2_desc_alloc(struct ioat2_dma_chan *ioat, u16 len)
103{
104 ioat->head += len;
105 return ioat->head - len;
106} 97}
107 98
108static inline u16 ioat2_xferlen_to_descs(struct ioat2_dma_chan *ioat, size_t len) 99static inline u16 ioat2_xferlen_to_descs(struct ioat2_dma_chan *ioat, size_t len)
@@ -151,7 +142,7 @@ struct ioat_ring_ent {
151static inline struct ioat_ring_ent * 142static inline struct ioat_ring_ent *
152ioat2_get_ring_ent(struct ioat2_dma_chan *ioat, u16 idx) 143ioat2_get_ring_ent(struct ioat2_dma_chan *ioat, u16 idx)
153{ 144{
154 return ioat->ring[idx & ioat2_ring_mask(ioat)]; 145 return ioat->ring[idx & (ioat2_ring_size(ioat) - 1)];
155} 146}
156 147
157static inline void ioat2_set_chainaddr(struct ioat2_dma_chan *ioat, u64 addr) 148static inline void ioat2_set_chainaddr(struct ioat2_dma_chan *ioat, u64 addr)
@@ -168,7 +159,7 @@ int __devinit ioat2_dma_probe(struct ioatdma_device *dev, int dca);
168int __devinit ioat3_dma_probe(struct ioatdma_device *dev, int dca); 159int __devinit ioat3_dma_probe(struct ioatdma_device *dev, int dca);
169struct dca_provider * __devinit ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase); 160struct dca_provider * __devinit ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase);
170struct dca_provider * __devinit ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase); 161struct dca_provider * __devinit ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase);
171int ioat2_alloc_and_lock(u16 *idx, struct ioat2_dma_chan *ioat, int num_descs); 162int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs);
172int ioat2_enumerate_channels(struct ioatdma_device *device); 163int ioat2_enumerate_channels(struct ioatdma_device *device);
173struct dma_async_tx_descriptor * 164struct dma_async_tx_descriptor *
174ioat2_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest, 165ioat2_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest,