aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dma/ioat/dma_v2.c2
-rw-r--r--drivers/dma/ioat/dma_v2.h18
2 files changed, 8 insertions, 12 deletions
diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c
index b5ae56c211e6..b6699a350989 100644
--- a/drivers/dma/ioat/dma_v2.c
+++ b/drivers/dma/ioat/dma_v2.c
@@ -553,7 +553,7 @@ bool reshape_ring(struct ioat2_dma_chan *ioat, int order)
553 */ 553 */
554 struct ioat_chan_common *chan = &ioat->base; 554 struct ioat_chan_common *chan = &ioat->base;
555 struct dma_chan *c = &chan->common; 555 struct dma_chan *c = &chan->common;
556 const u16 curr_size = ioat2_ring_mask(ioat) + 1; 556 const u16 curr_size = ioat2_ring_size(ioat);
557 const u16 active = ioat2_ring_active(ioat); 557 const u16 active = ioat2_ring_active(ioat);
558 const u16 new_size = 1 << order; 558 const u16 new_size = 1 << order;
559 struct ioat_ring_ent **ring; 559 struct ioat_ring_ent **ring;
diff --git a/drivers/dma/ioat/dma_v2.h b/drivers/dma/ioat/dma_v2.h
index ef2871fd7868..d7b64f188f78 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
@@ -71,31 +72,26 @@ static inline struct ioat2_dma_chan *to_ioat2_chan(struct dma_chan *c)
71 return container_of(chan, struct ioat2_dma_chan, base); 72 return container_of(chan, struct ioat2_dma_chan, base);
72} 73}
73 74
74static inline u16 ioat2_ring_mask(struct ioat2_dma_chan *ioat) 75static inline u16 ioat2_ring_size(struct ioat2_dma_chan *ioat)
75{ 76{
76 return (1 << ioat->alloc_order) - 1; 77 return 1 << ioat->alloc_order;
77} 78}
78 79
79/* count of descriptors in flight with the engine */ 80/* count of descriptors in flight with the engine */
80static inline u16 ioat2_ring_active(struct ioat2_dma_chan *ioat) 81static inline u16 ioat2_ring_active(struct ioat2_dma_chan *ioat)
81{ 82{
82 return (ioat->head - ioat->tail) & ioat2_ring_mask(ioat); 83 return CIRC_CNT(ioat->head, ioat->tail, ioat2_ring_size(ioat));
83} 84}
84 85
85/* count of descriptors pending submission to hardware */ 86/* count of descriptors pending submission to hardware */
86static inline u16 ioat2_ring_pending(struct ioat2_dma_chan *ioat) 87static inline u16 ioat2_ring_pending(struct ioat2_dma_chan *ioat)
87{ 88{
88 return (ioat->head - ioat->issued) & ioat2_ring_mask(ioat); 89 return CIRC_CNT(ioat->head, ioat->issued, ioat2_ring_size(ioat));
89} 90}
90 91
91static inline u16 ioat2_ring_space(struct ioat2_dma_chan *ioat) 92static inline u16 ioat2_ring_space(struct ioat2_dma_chan *ioat)
92{ 93{
93 u16 num_descs = ioat2_ring_mask(ioat) + 1; 94 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} 95}
100 96
101/* assumes caller already checked space */ 97/* assumes caller already checked space */
@@ -151,7 +147,7 @@ struct ioat_ring_ent {
151static inline struct ioat_ring_ent * 147static inline struct ioat_ring_ent *
152ioat2_get_ring_ent(struct ioat2_dma_chan *ioat, u16 idx) 148ioat2_get_ring_ent(struct ioat2_dma_chan *ioat, u16 idx)
153{ 149{
154 return ioat->ring[idx & ioat2_ring_mask(ioat)]; 150 return ioat->ring[idx & (ioat2_ring_size(ioat) - 1)];
155} 151}
156 152
157static inline void ioat2_set_chainaddr(struct ioat2_dma_chan *ioat, u64 addr) 153static inline void ioat2_set_chainaddr(struct ioat2_dma_chan *ioat, u64 addr)