diff options
Diffstat (limited to 'drivers/dma/ioat/dma_v2.h')
-rw-r--r-- | drivers/dma/ioat/dma_v2.h | 33 |
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 | */ |
55 | struct ioat2_dma_chan { | 57 | struct 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 | ||
67 | static inline struct ioat2_dma_chan *to_ioat2_chan(struct dma_chan *c) | 70 | static 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 | ||
74 | static inline u16 ioat2_ring_mask(struct ioat2_dma_chan *ioat) | 77 | static 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 */ |
80 | static inline u16 ioat2_ring_active(struct ioat2_dma_chan *ioat) | 83 | static 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 */ |
86 | static inline u16 ioat2_ring_pending(struct ioat2_dma_chan *ioat) | 89 | static 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 | ||
91 | static inline u16 ioat2_ring_space(struct ioat2_dma_chan *ioat) | 94 | static 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 */ | ||
102 | static 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 | ||
108 | static inline u16 ioat2_xferlen_to_descs(struct ioat2_dma_chan *ioat, size_t len) | 99 | static inline u16 ioat2_xferlen_to_descs(struct ioat2_dma_chan *ioat, size_t len) |
@@ -151,7 +142,7 @@ struct ioat_ring_ent { | |||
151 | static inline struct ioat_ring_ent * | 142 | static inline struct ioat_ring_ent * |
152 | ioat2_get_ring_ent(struct ioat2_dma_chan *ioat, u16 idx) | 143 | ioat2_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 | ||
157 | static inline void ioat2_set_chainaddr(struct ioat2_dma_chan *ioat, u64 addr) | 148 | static 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); | |||
168 | int __devinit ioat3_dma_probe(struct ioatdma_device *dev, int dca); | 159 | int __devinit ioat3_dma_probe(struct ioatdma_device *dev, int dca); |
169 | struct dca_provider * __devinit ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase); | 160 | struct dca_provider * __devinit ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase); |
170 | struct dca_provider * __devinit ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase); | 161 | struct dca_provider * __devinit ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase); |
171 | int ioat2_alloc_and_lock(u16 *idx, struct ioat2_dma_chan *ioat, int num_descs); | 162 | int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs); |
172 | int ioat2_enumerate_channels(struct ioatdma_device *device); | 163 | int ioat2_enumerate_channels(struct ioatdma_device *device); |
173 | struct dma_async_tx_descriptor * | 164 | struct dma_async_tx_descriptor * |
174 | ioat2_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest, | 165 | ioat2_dma_prep_memcpy_lock(struct dma_chan *c, dma_addr_t dma_dest, |